A mini clone of the Lodash library.
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.
Install it:
npm install @rmcwhae/lotide
Require it:
const _ = require('@rmcwhae/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
head(array)
: returns first element of arraytail(array)
: removes first element of arraymiddle(array)
: returns the item with the middle index of the input array (odd number of items), or the middle two items (even nember of items)countLetters(string)
: counts the number of letters (ignores spaces)countOnly(allItems, itemsToCount)
: returns how many instances of each string in itemsToCount were found in the allItems array of stringseqArrays(array1, array2)
: returns true if arrays are equivalenteqObjects(object1, object2)
: returns true if objects are equivalentfindkey(object, callback)
: returns object key that matches the callback functionfindKeyByValue(object, value)
: returns object key of given valueflatten(array)
: converts nest arrays intwo one-dimensional arrayletterPositions(string)
: returns an object with the indices of each letter in the stringmap(array, callback)
: returns array items where the callback returns a truthy valuetakeUntil(array, callback)
: return a slice of the array with elements taken from the beginning until the callback returns a truthy valuewithout(sourceArray, itemsToRemoveArray)
: removes items in itemsToRemoveArray from sourceArray