A mini clone of the Lodash library.
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.
Install it:
npm install @cameronshephard/lotide
Require it:
const _ = require('@cameronshephard/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
head(...)
: returns the first item of an arraytail(...)
: returns an array without the first itemmiddle(...)
: returns the middle or middle two numbers in an arrayflattenArray(...)
: takes an array of arrays and returns it as one ([1,[2,3],4] => [1,2,3,4])countLetters(...)
: returns an array with the count of each letter in the given stringeqObjects(...)
: returns a true or false for if the given objects are the same or notcountOnly(...)
: returns the amound each item appears in the first array, as long as it is also in the second arrayeqArrays(...)
: returns a true if the given arrays are the samefindKey(...)
: returns the key in an object when the callback is fufilledfindKeyByValue(...)
: returns the key in an object to a given valueletterPositions(...)
: returns the psition of each letter in a stringmap(...)
: returns a new array after using the callback function on each item of the given array and pushing the resulttakeUntil(...)
: returns the array untill one of the indexes returns true for the callbackwithout(...)
: returns the first array without the things in the second array
-
Description: Counts the occurrences of specific items in an array based on a provided criteria.
-
Parameters:
-
allItems
(Array): The array of items to be counted. -
itemsToCount
(Object): The object specifying the items to count and their criteria.
-
-
Returns: An object containing the counts of the specified items.