1.0.0 • Published 4 years ago
@amblinglea/lotide v1.0.0
Lotide
A mini clone of the Lodash library.
Purpose
BEWARE: This library was published for learning purposes. It is not intended for use in production-grade software.
This project was created and published by me as part of my learnings at Lighthouse Labs.
Usage
Install it:
npm install @amblinglea/lotide
Require it:
const _ = require('@amblinglea/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: returns the first element of an arraytail(arr)
: returns an array with the first element removedmiddle(arr)
: returns the middle element(s) of an arrayassertArraysEqual(arr1, arr2)
: checks if two arrays are equalassertEqual(actual, expected)
: checks if two numbers or strings are equalassertObjectsEqual(actual, expected)
: checks if two objects are equalcountLetters(string)
: counts a specified letter in a string and returns the number of times it appearscountOnly(allItems, itemsToCount)
: returns how many instances of each string were found in the array of stringseqArrays(arr1, arr2)
: checks if two arrays are equaleqObjects(object1, object2)
: checks if two objects are equalfindKey(object, callback)
: returns the first key for which the callback returns a truthy valuefindKeyByValue(objectToScan, value)
: returns the first key which contains a given valueflatten(arr)
: returns a flat arrayletterPositions(sentence)
: returns all the indices in the string where each object is foundmap(array, callback)
: returns a new array based on the results of the callback functiontakeUntil(array, callback)
: return a slice of the array with elements taken from the beginningwithout(source, itemsToRemove)
: returns a new array with only those elements from source that are not present in the itemsToRemove array
1.0.0
4 years ago