1.0.1 • Published 1 year ago
@grafuj/lotide v1.0.1
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 @grafuj/lotide
Require it:
const _ = require('@grafuj/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns first element from an arraytail(array)
: returns all elements but the first from an array (minimum 3 elements)middle(array)
: returns middle element or elements if array length is evencountLetters(string)
: returns an object with characters as keys with values detailing how many times those characters appeared in the stringcountOnly(array, object)
: returns an object with strings as keys that detail how many times those strings appeared in the array of strings.eqArrays(array1, array2)
: returns boolean if arrays are equaleqObjects(object1, object2)
: returns boolean if objects are equalfindKey(object, function)
: returns value of key in object that is specified in the callback functionfindKeyByValue(object, value)
: returns the key that contains the value specified from a callback functionflatten(array)
: returns an array that does not contain sub-arraysletterPositions(string)
: returns an object with keys for each letter and arrays of positions those letters are found as value for the keysmap(array, function)
: returns an array that has been modified by a callback functiontakeUntil(array, function)
: returns a shortened array defined by the callback function which determines at what element to stopwithout(array, arrayElementsToRemove)
: removes all elements from first array if specified in second array
1.0.1
1 year ago