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 @icornell/lotide
Require it:
const _ = require('@icornell/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
assertArraysEqual(actual, expected)
: uses eqArrays to check if two arrays are equal and prints out if they are equal or notassertEqual(actual, expected)
: checks if two values are equalassertObjectsEqual(actual, expected)
: uses eqObjects to check if two objects are equal and prints out if the assertion passed or failedcountLetters(sentence)
: counts all the letters in a given string or sentencecountOnly(allItems, itemsToCount)
: returns an object containing counts of everything in a string that the input object listedeqArrays(array1, array2)
: takes two arrays and returns true or false, dependant on a perfect matcheqObjects(object1, object2)
: takes two objects and compares them to see if they are equalfindKey(obj, callback)
: returns the first key of a given object that matches the callbackfindKeyByValue(object, value)
: finds the first key in a given object which matches the given valueflatten(arr)
: takes nested arrays and flattens them into one single-level arrayhead(arr)
: returns the first element, or head, of an arrayletterPositions.js(sentence)
: returns an object where the keys are the letters in a given sentence and the values the index positions where they appearmap(array, callback)
: returns a new array based on the results of the callback function.middle(arr)
: returns the middle element(s) of an array - one or two, depending on if the array is even or oddtail(arr)
: returns the end elements, or tail, of an array (all but the head)takeUntil(array, callback)
: returns a slice of the array with elements taken from the beginning until the callback returns a truthy valuewithout(source, itemsToRemove)
: returns a new array after having removed the given items in itemsToRemove