1.0.1 • Published 4 years ago
@devmikh/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 @devmikh/lotide
Require it:
const _ = require('@devmikh/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actual, expected)
: assert two arrays are equalassertEqual(actual, expected)
: assert two values are equalassertObjectsEqual(actual, expected)
: assert two objects are equalcountLetters(string)
: returns a count of each of the letters in the passed stringcountOnly(allItems, itemsToCount)
: returns a count for a specific subset of passed itemseqArrays(array1, array2)
: compares two arrays and returns a booleaneqObjects(object1, object2)
: compares two objects and returns a booleanfindKey(object, callback)
: scans the object and returns the first key for which the callback returns a truthy valuefindKeyByValue(object, value)
: scans the object and returns the first key which contains the given valueflatten(array)
: takes in an array containing elements including nested arrays of elements, and returns a "flattened" version of the arrayhead(array
): returns the first item in the arrayletterPositions(string)
: returns all the indices in the string where each character is foundmap(array, callback)
: returns a new array based on the results of the callback functionmiddle(array)
: takes in an array and returns the middle-most element(s) of the given arraytail(array)
: returns everything except for the first item (head) of the provided arraytakeUntil(array, callback)
: keeps collecting items from a provided array until the callback provided returns a truthy valuewithout(source, itemToRemove)
: returns a subset of a given array, removing unwanted elements