1.0.1 • Published 3 years ago
@thomasyi/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 @thomasyi/lotide
Require it:
const _ = require('@thomasyi/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: returns the first element of the array or stringtail(...)
: returns the rest of the array without the first elementmiddle([...])
: returns the middle of the array(if array has even number of element, return the middle 2 elements)eqArrays([...], [...])
: returns true if the two input arrays are the same, vice versaeqObjects({obj}, {obj})
: returns true if the two input objects are the same, vice versareverse(...)
: reverse a stringmap([...], callback)
: returns a new array with each element modified through the callback functionwithout([arr1], [arr2])
: returns element that is not presendted in both arraysflatten([..., [...]])
: returns a new arary with has no nested arraysfindKey({obj}, callback)
: returns the key of the object based on the callback functionfindKeyByValue({obj}, value)
: returns the key that matched the input valuecountLetters(string, letter)
: returns the number of letter inside of a stringcountOnly([...], {itemsToCount})
: returns an object which contains the key from the counted element in the input array, and the value is the number of the element presented in the arraytakeUntil([...], callback)
: returns an array of element upto (but not include) the element that met the the condition of the input callbacktail(string)
: returns an object which containes each letter as keys, and their values are an array of the index postion inside the string