@devhalpin/lotide
v1.0.1
Published
Mini copy of lodash library for LHL project
Downloads
1
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 @devlhalpin/lotide
Require it:
const _ = require('@devhalpin/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: Returns first element of arraytail(arr)
: Returns array minus the first elementmiddle(arr)
: Returns middle of arrayassertEqual(value1, value2)
: Returns if value1 is equal to value2assertArraysEqual(arr1, arr2)
: Same as assertEqual but takes arrays as argumentsassertObjectsEqual(obj1, obj2)
: Same as assertEqual but takes objects as argumentseqObjects(obj1, obj2)
: Used by assertObjectsEqual to test objects are the sameeqArrays(arr1, arr2)
: Used by assertArraysEqual to test arrays are the sameflatten(arr)
: Flattens array with nested elementscountLetters(str)
: Returns object using letters in provided string as keys and number of occurences of each letter as valuescountOnly((arr, obj)
: Returns object using array values as keys and number of occurences of each key as valuesfindKey(obj,callback)
: Returns first key that matches callback in objectfindKeyByValue(obj, value)
: Returns first key whose value matches value in objectletterPositions(str)
: Returns object with each letter in string as key and it's indexes as valuesmap(array, callback)
: Returns array with the results of calling callback on every element in the provided arraytakeUntil(array, callback)
: Returns array containing all elements of provided array up until the index value matches the results of callbackwithout(arr1, arr2)
: Returns array containing all elements that are in arr1 and not in arr2