@aaronhopkins/lotide
v1.0.3
Published
## Library which aims to implement helper functions similar to Lodash
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 @username/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: takes in two arrays and returns a message if they are equal or notassertEqual(actual, expected)
: takes in two primitive arguments and returns a message if they are equal or notassertObjectsEqual(obj1, obj2)
: takes in two objects and returns a message if they are equal or notcountLetters(str)
: takes in a string and returns the amount letters excluding spacescountOnly(allItems, itemsToCount)
: takes in two arrays and returns an object containing the frequency of items in the first array found in the second arrayeqArrays(arr1, arr2)
: takes in two arrays and returns true if they are equal, false if they are noteqObjects(obj1, obj2)
: takes in two objects and returns true if they are equal, false if they are notfindKey(obj, callback)
: takes in an object and callback function, which is called with each value in the object. If the callback result is true, the key of the object is returned, otherwise is undefined is returnedfindKeyByValue(obj, val)
: takes in an object and a value, scans the object and returns the first key which contains the given value. If no key with that given value is found, then undefined is returned.flatten(arr)
: takes in an array and returns the array with all its values at a depth of 0head(arr)
: takes in an array and returns the first elementletterPositions(str)
: takes in a string and returns an object with the characters as keys and an array of indexes where they are found as valuesmiddle(arr)
: takes in an array and returns the middle element(s)tail(arr)
: takes in an array and returns a copy of the array excluding the first elementtakeUntil(arr, callback)
: takes in an array and a callback, and returns a new array containing the values for which the result of calling the callback on each element of the original array is true.without(arr, itemsToRemove)
: takes in two arrays and returns a new array that contains items from the first array not found in the second array.