1.0.1 • Published 4 years ago
@wangxx2020/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 @wangxx2020/lotide
Require it:
const _ = require('@wangxx2020/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: returns the first element of input arraytail(...)
: returns every elements except the first element of input arraymiddle(...)
: returns the middle element(s) of input arrayassertArraysEqual(...)
: console log the array comparison resultassertEqual(...)
: console log the comparison resultassertObjectsEqual(...)
: console log the objects comparison resultcountLetters(...)
: returns the count of letters for input stringeqArrays(...)
: compare two input arrays and returns a boolean resulteqObjects(...)
: compare two input obejcts and returns a boolean resultfindKeys(...)
: takes an object and a callback function, returns keys of object that pass through call back functionfindKeysByValue(...)
: takes an object and value, returns the key of the value in the objectflatten(...)
: takes a multi-level nested array and returns one level arrayletterPositions(...)
: takes a string and returns an object with unique letter as keys and the indexes of it in an arraymap(...)
: takes an array and callback function as input, iterate the array and apply callback func on each element and return a new arraytakeUntil(...)
: takes an array and callback function, iterate the array and output until the callback function passed for a certain element, return an array containing the elements before the stop elementwithout(...)
: takes two arrays as input, returns a new array as first array without elements contains in the second array.