@aidanmattrick/lotide
v1.0.0
Published
A copy of lodash library for learning purposes
Downloads
6
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('@aidanmattrick/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(array1, array2)
: compares two arrays and returns if their values are equalassertEqual(acutal, expected
: compares two values and returns if they are equalassertObjectsEqual(obj1, obj2)
: compares two objects and returns if their keys and values are equalcountLetters(str)
: receives a string and returns the frequency of each character used in the stringcountOnly(key, obj)
: takes in an object and returns the number of times that a given key occurseqArrays(array1, array2)
: takes in two arrays and returns if their values are equaleqObjects(obj1, obj2)
: compares two objects and returns if their keys and values are equalfindKeys(obj, callback)
: takes in an object and returns the first key for which the callback returns a truthy valuefindKeyByValue(obj, callback)
: takes in an object and returns the first key for which the callback returns a truthy valueflatten(array)
: takes in a nested array and returns a single array with list of valueshead(array)
: takes in an array and returns the first element of that arrayletterPositions(str)
: takes in a string and returns an object that displays each character used and the number of times it was used as key-value pairsmap(array)
: takes in an array and a callback and returns a new array with each element having been manipulated according to the callback functionmiddle(array)
: takes in an array and returns the middle element of that array. If there is an even number of elements, it returns the two middle valuestail(array)
: takes in a array and returns a new array indentical to the original array besides removing the first elementtakeUntil(array, callback)
: takes in an array and returns a new array that copies the values of the original array with the callback function determining the endpoint of the returned arraywithout(array1, array2)
: takes in two arrays and removes all the elements in array1 that also occur in array2 before returning a copy of array1