1.0.0 • Published 3 years ago
@techvisum/lotide v1.0.0
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 @techvisum/lotide
Require it:
const _ = require('@techvisum/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: return first array elementtail(arr)
: return all array elements except firstmiddle(arr)
: return middle element of an arrayassertEqual(actual, expected)
: assert whether two inputs are same or notassertArraysEqual(array1, array2)
: assert whether two arrays are same or noteqArrays(array1, array2)
: check whether two arrays are same or notassertObjectsEqual(object1, object2)
: assert whether two objects are same or notcountLetters(input)
: return a count of each of the letters in input string.countOnly(arr, obj)
: return an object containing counts of everything that the input object listed.eqObjects(obj1, obj2)
: check whether two objects are same or notfindKey(obj, callback)
: It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined.findKeyByValue(obj, value)
: scans the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.flatten(arr)
: It will take in an array containing elements including nested arrays of elements, and return a "flattened" version of the array.- ` letterPositions,
map(arr, callback)
: return a new array based on the results of the callback function.takeUntil(array, callback)
: The function will return a "slice of the array with elements taken from the beginning." It should keep going until the callback/predicate returns a truthy value.without(sourceArr, itemsToRemove)
: return a new array with only those elements from sourceArr that are not present in the itemsToRemove array.
1.0.0
3 years ago