1.0.0 • Published 2 years ago
@andymo/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 @andymo/lotide
Require it:
const _ = require('@andymo/lotide');
Call it:
const results = _.head([1, 2, 3]) // => 1
Documentation
The following functions are currently implemented:
countOnly(allItems, itemsToCount)
: Returns the count of how many times an item is in the given array, dependent on the key supplied - but only if the key's value is set to true. Takes an array asallItems
argument, and object asitemsToCount
. Returns objecteqArrays(arr1, arr2)
: Checks to see if two arrays are equal, takes two arrays as arguments. Returns booleanequalObjects(obj1, obj2)
: Checks to see if two objects are equal, takes two objects as arguments. Returns booleanfindKey(obj, cb)
: Finds key from object where the value is equal to a callback functionfindKeyByValue(obj, str)
: Finds key from object where the value is equal to the given string. Returns arrayhead(arr)
: Returns first value from given arraymap(arr, cb)
: Returns values from an iterable that have been changed according to the callbackmiddle(arr)
: Returns middle values from array of any length (as array), array must have at least 3 items in it.takeUntil(arr, cb)
: Returns array of values up until the callback condition has been metwithout(arr1, arr2)
: Returns new array based on arr1 with the values from arr2 removed from it
1.0.0
2 years ago