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 @t5krishn/lotide
Require it:
const _ = require('@t5krishn/lotide/index');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
head(array)
: Returns the first element of the arraytail(array)
: Returns the array without the first elementmiddle(array)
: Returns an array with the middle one or two element(s)assertArraysEqual(array, array)
: Prints true/false assertion depending on whether two arrays are equalassertEqual(arg1, arg2)
: Prints true/false assertion on whether arguments are equalassertObjectsEqual(object, object)
: Returns true/false depending on whether two objects are equalcountLetters(string)
: Counts number of letters and returns it as an object, with values as letter countscountOnly(array)
: Counts the number of elements and returns it as an object, with values as the array valueeqArrays(array, array)
: Returns a boolean depending on whether two arrays are equaleqObjects(object, object)
: Returns a boolean depending on whether two objects are equalfindKey(object, callback)
: Finds the key that is returned from the object, using the callback functionfindKeyByValue(object, value)
: Finds the key of the object that contains the valueflatten(array)
: Returns a flattened array with only one sublevelletterPositions(string)
: Returns an object with the positions of the letters stored as an arraymap(array, callback)
: Returns an array that has the callback function applies to each elementtakeUntil(array, callback)
: Returns the array with all elements that return false from the callback, and it stops adding when an element returns true from the callbackwithout(array, array)
: Returns an array with values that are not in the second array