1.0.0 • Published 3 years ago
@coughdrops13/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 @coughdrops13/lotide
Require it:
const _ = require('@coughdrops13/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns the first element in an arraytail(array)
: returns all but the first element of an arraymiddle(array)
: returns with middle 1 or two elements of an array depending on array length being odd or even respectivelymin(array)
: returns the smallest value of an arrayassertArraysEqual(array1, array2)
: returns true if two input arrays are idetical and false if notassertEqual(actual, expected)
: returns true if actual is equal to expected and false if notassertObjectsEqual(object1, object2)
: returns true if two input objects are identical and false if notcountLetters(string)
: returns an object whose keys are characters from a string and whose values are the number of instances of that character in the input stringcountOnly(array, itemsToCount)
: returns an object whose keys are the elements of an itemsToCount array and whose values are the number of instances that key occurs in the input arrayeqArrays(array1, array2)
: returns true if two input arrays are identical and false if noteqObjects(object1, object2)
: returns true if two input objects are identical and false if notfindKey(object, callback)
: returns true input function value exists with key in the objectfindKeyByValue(object, value)
: return key name in input object with given input valueflatten(arrayOfArrays)
: returns one array conataining no other arrays and all values of input arrayletterPositions(string)
: returns an object of arrays whose keys are characters in the input string and whose values are the indeces at which those characters occermap(array, callback)
: manual implementation of the .map() functiontakeUntil(array, callback)
: returns an array with elements from original array up until an element inserted into callback function returns truewithout(array, itemsToRemove)
: returns array with all items of the input array aside from those specified by itemsToRemove array
1.0.0
3 years ago