1.0.1 • Published 2 years ago
@mikenguyentt/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 @mikenguyentt/lotide
Require it:
const _ = require('@mikenguyentt/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: return first element of the input arraytail(array)
: return input array except the first elementmiddle(array)
: return middle element/s of input array, one element if input array length is odd, and two elements if input array length is evenassertArraysEqual(array1, array2)
: to assert if an actual array is equal to an expected arrayassertObjectsEqual(object1, object2)
: to assert if an actual object is equal to an expected objectassertEqual(value1, value2)
: to assert if an actual value is equal to an expected valuecountLetters(string)
: count the occurences of every letter in the given sentencecountOnly(object1, object2)
: take in a collection of items in object1 and return counts for a specific subset of those itemseqArrays(array1, array2)
: compare two arrays, return true if both are equal and false otherwiseeqObjects(object1, object2)
: compare two objects, return true if both are equal and false otherwisefindKey(object, callback)
: return the key of the object depending on the callback function conditionfindKeyByValue(object, value)
: return the key name of a given value if found in the objectflatten(nestedArray)
: take in a multilevel nested array, remove all the nest and return a flat array with all elementsletterPositions(string)
: return an object whose every value is an array of indices when the key letter appearsmap(array, callback)
: return a new array containing elements as the result of callback function manipulating input array.takeUntil(array, callback)
: return a new array only with head elements until the callback function condition is matchedwithout(array1, array2)
: filter out all the element of array2 from the array1 };