1.0.0 • Published 5 years ago
@amarkham/lotide v1.0.0
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('@amarkham/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns the first element of an arraytail(array)
: returns everything but the first element of an arraymiddle(array)
: return the middle elements of an array (note: includes two elements when array size is even)assertArraysEqual(array1, array2)
: logs to console whether provided arrays are equalassertEqual(actual, expected)
: logs to console whether the '===' operator returns true for provided argumentsassertObjectsEqual(object1, object2)
: logs to console whether provided objects are equalcountLetters(sentence)
: returns an object with the frequencies of each character in a stringcountOnly(allItems, itemsToCount)
: returns an object with the frequencies of each character specified in an itemsToCount arrayeqArrays(array1, array2)
: tests deep equality for two arrayseqObjects(object1, object2)
: tests deep equality for two objectsfindKey(object, callback)
: returns the key of the object whose callback on both keys and values returns truefindKeyByValue(object, callback)
: returns the key of the object whose callback function on the values only returns trueflatten(array)
: takes an array of maximum 2D and returns a 1D arrayletterPositions(sentence)
: returns an object with the positions of each of the characters in a sentencemap(array, callback)
: mimics the built-in map function on an arraytakeUntil(array, callback)
: returns an array with all of the original elements until the callback on an element returns falsewithout(array, itemsToRemove)
: returns an array excluding elements provided
1.0.0
5 years ago