@fapapa/lotide
v1.0.1
Published
Like lodash, only worse
Downloads
4
Readme
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 @fapapa/lotide
Require it:
const _ = require('@fapapa/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actualArr, expectedArr)
: Deeply checks the equality of the two passed-in arrays and logs to the console either a passed or failed messageassertEqual(actual, expected)
: For primitive values; Checks for strict equality between the two passed-in values.assertObjectsEqual(actualObj, expectedObj)
: Deeply checks the equality the two passed-in objectscountLetters(string)
: Givenstring
returns an object with each unique letter in string as a property, with the number of times that letter appears in the string as a valuecountOnly(allItems, itemsToCount)
: Returns an object with counts for all the items in arrayallItems
, whereitemsToCount[*allItems[i]*]
returns trueeqArrays(actual, expected)
: Deeply checks the equality of the two passed in arrays and returns true or falseeqObjects(actual, expected)
: Deeply checks the equality of the two passed in objects and returns true or falsefindKey(obj, callback)
: Returns the first property forobj
where the callback returns truefindKeyByValue(obj, val)
: Returns the first property inobj
where its value is equal toval
flatten(array)
: Flattens multi-dimensionalarray
head(array)
: Returns the value at index 0 ofarray
letterPositions(string)
: Returns an object corresponding tostring
where each property is a unique letter of string, with the number of times it appears in stringmap(array, callback)
: Passes in each element ofarray
tocallback
and puts the return value ofcallback
into a new array, and returns itmiddle(arr)
: Returns the middle one (for odd-length arrays) or two (for even-length arrays) elements ofarray
tail(arr)
: Returns everything but the first element ofarr
takeUntil(array, callback)
: Returns all the items ofarray
in a new array untilcallback
returns a falsey valuewithout(array, itemsToRemove)
: Returns an array with all items inarray
except those that are also initemsToremove