1.0.1 • Published 5 years ago
@ilaksono/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 @ilaksono/lotide
Require it:
const _ = require('@ilaksono/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: returns first element of an arraytail(arr)
: returns an array without first elementmiddle(arr)
: returns array of middle element(s) of argument arraycountLetters(str)
: returns object with count of letters in argument string,countOnly(arrSource, objToCount)
: returns object of count for each array element with true in objeqArrays(arr1, arr2)
: returns true for 2 equal arrays, and false for 2 non equal arraysflatten(arr)
: returns a flattened 2D array to 1DflattenDeep(arr)
: returns a flattened array of multiple nestings to 1D,letterPositions(str)
: returns object with arrays of index positions for each letter in arg stringmap(arr, cb)
: returns array of elements from src array with true on cbfindKey(obj, cb)
: returns first key in obj which valuates true in cbfindKeyByValue(obj, val)
: returns first property in obj with value(val)eqObjects(obj1, obj2)
: returns true for 2 equal objects, and false for 2 non equaltakeUntil(arr, cb)
: returns array elements from index 0 until value where cb evaluates truewithout(arr1, arr2)
: returns array of elements from arr1 with arr2 elements removedassertArraysEqual(arr1, arr2)
: returns undefined; logs assertion pass if 2 arrays are equalassertObjectsEqual(obj1, obj2
: returns undefined; logs assertion pass if 2 objects are equalassertEqual(val1, val2)
: returns undefined; logs assertion pass if 2 values are equal