1.0.1 • Published 3 years ago
@sdelacruz/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 @sdelacruz/lotide
Require it:
const _ = require('@sdelacruz/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 array given an arraytail(array)
: Returns all but the first element in an array given an arraymiddle(array)
: Returns the middle one (if array has an odd number of elements) or two (if array has an even number of elements) elements in an array given an arrayeqObjects
: Returns true if two objects are equaleqArrays
: Returns true if two arrays are equalassertArraysEqual
: Prints to the console if two given arrays are equal or notassertEqual
: Prints to the console if two given elements are equal or notassertObjectsEqual
: Prints to the console if two given objects are equal or notcountOnly
: Returns an object with the number of items in an objectcountLetters
: Returns an object with the number of times a letter appears in a stringfindKey
: Returns the first key in an object whose valuse pass a criteriafindKeyByValue
: Returnsflatten(array)
: Returns a non-nested array of elements given an array of elementsletterPositions
: Returns an object with the letters appearing in a string and their positions in a givenstringmap
: Returns a resulted array given a function and arraytakeUntil
: Returns an array with elements from an array that pass a criteria until one failswithout
: Returns an array of elements minus the elements from a second array