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 studies at Lighthouse Labs.
Install:
npm install @wjb8/lotide
Require it:
const _ = require('@wjb8/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
assertArraysEqual(arrayOne, arrayTwo)
: compare two arrays and return true if equalassertEqual(actual, expected)
: return true if actual === expectedassertObjectsEqual(obj1, obj2)
: compare two objects and return true if equalcountLetters(string)
: return an object of letters and their occurences in the stringcountOnly(allItems, itemsToCount)
: returns an object of only the items listed in the second parametereqArrays(arrayOne, arrayTwo)
: used with assertArraysEqual to compare two arrayseqObjects(obj1, obj2)
: used with assertObjectsEqual to compare two objectsfindKey(obj, callback)
: returns keys in an object that match the callback function resultfindKeyByValue(object, val)
: similarly returns key that holds the passed value argumentflatten(array)
: returns a new array of all elements in the passed array ignoring nested arrayshead(array)
: returns the first element of an arrayletterPositions(sentence)
: returns the positions in the string of the passed lettermap(array, callback)
: executes a callback function on each element of the array and returns a new array of the resultsmiddle(array)
: returns the middle element of an array (middle two elements if odd)tail(array)
: returns the array with the head removedtakeUntil(arr, callback)
: returns elements in the array until the callback function returns falsewithout(source, itemsToRemove)
: returns new array without the list of items to remove