1.0.0 • Published 2 years ago
@rreiso/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 @rreiso/lotide
Require it:
const _ = require('@rreiso/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 the arraytail(array)
: returns a new array without the first elementmiddle(array)
: returns a new array with one or two middle element(s)assertArraysEqual(array1, array2)
: asserts if two arrays are equalassertEqual(a, b)
: asserts if two primitive values are equalassertObjectsEqual(object1, object2)
: asserts if two objects are equalcountLetters(string)
: returns an object with letters and the number of their occurrencescountOnly(array, object)
: input object syntax: {array_el: true}; returns a new object with elements and their occurrences in the array.eqArrays(array1, array2)
: returns true/falseeqObjects(array1, array2)
: returns true/falsefindKey(object, callback)
: returns a key that satisfies the statement in the callbackfindKeyByValue(object, value)
: returns key if the corresponding value exists in the objectflatten(array)
: returns new one-dimentional arrayletterPositions(string)
: returns an object with letters and their indexesmap(array, callback)
: returns a new array with elements that satisfies the statement in the callbacktakeUntil(array, callback)
: returns new array with elements one by one until the first element that satisfies the statement in the callbackwithout(array1, array2)
: returns a new array with elements from array1 without the elements from the array2
1.0.0
2 years ago