@vvalentinv/lotide
v1.0.0
Published
Lotide is a library designed to simplify working with arrays, numbers, objects, strings, etc. published for learning purpose
Downloads
1
Readme
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 @vvalentinv/lotide
Require it:
const _ = require('@vvalentinv/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 copy of the array without the first elementmiddle(array)
: returns the middle value of an array that has at least three elements, if the length is an odd number it will return an array with two elementswithout(array1,array2)
: returns a copy of the first array without elements in the second arraytakeUntil(array,action)
: returns an array containing all elements for which the callback returns false.map(arr, action)
: returns an array for which the action transformed each elementletterPositions(sentence)
: returns an object with the unique letters and their indices in the sentence.findKeyByValue(object, value)
: returns the first key that matches the valuefindKey(object,action)
: returns the first key for which the action returns trueeqObjects(object1,object2)
: returns true if the objects are equaleqArrays(array1,array2)
: returns true if the arrays are equalcountOnly(object1,object2)
: returns an object containg keys from the first object and their number of occurences only if in the second object their value is truecountLetters(sentence)
: returns an object listing all unique letters and their number of occurrencesassertEqual(value1,value2)
: returns an nice formated message if the values are equalassertObjectsEqual(object1,object2)
: returns an nice formated message if the objects are equalassertArraysEqual(array1,array2)
: returns an nice formated message if the arrays are equal