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 hsingh01/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
head(array)
: Returns first item of the arraytail(array)
: Returns a new array without the first element of passed arraymiddle(array)
: Returns middle element/element's of an arrayeqArrays(array1, array2)
: Compare two arrays to be equal or notassertArraysEqual(array1, array2)
: Print message if arrays are equal or notassertEqual(actual, expected)
: Compares two primitive values to be equal or noteqObjects(object1, object2)
: Compares two objects to be equal or notassertObjectsEqual(actual, expected)
: Prints a message in console if two objects are euql or notcountLetters(input)
: Takes in a sentence and returns a count of each of the letters in the sentencecountOnly(allItems, itemsToCount)
: Takes in a collection of items and returns a specific subset of those itemsfindKey(object, callback)
: Takes in an object and callback and returns the first key that meets the criteria specified in callbackfindKeyByValue(inputObject, inputString)
: Takes in an object and a value and returns the first key that corresponds to that valueflatten(array)
: Takes in an array that contains elements including nested array of elements and returns a flattened version of the arraylettterPositions(input)
: Takes in a string and returns all indices of letter positions in the stringmap(array, callback)
: Takes in an array and a callback and returns a new array based on the results of the callback on each item in the arraytakeUntil(array, callback)
: Returns slice of the array with elements taken from the beginning until returns a truthy valuewithout(source, itemsToremove)
: Takes in a source array and an itemsToRemove arrays and returns only the items from the source array that are not in the itemsToRemove array