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 @emmagrannis/lotide
Require it:
const _ = require('@emmagrannis/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
assertEqual
: asserts if two primitive data types are equal in valueeqArrays
: tests if two arrays are equal in valueassertArraysEqual
: asserts if two arrays are equal in valueassertObjectsEqual
: asserts if two objects are equal in valuehead
: returns the first item in the arraytail
: returns the tail (everything except for the first item of an array)middle
: takes in an array and returns the middle-most element(s)countLetters
: takes in a sentence (as a string) and returns a count of each of the letters in that sentencecountOnly
: given an array and an object, it returns an object containing counts of everything in the array that the input object lists as trueeqObjects
: takes in two objects and returns true or false, based on an exact matchfindKey
: takes in an object and a callback function, scans the object, and returns the first key for which the callback returns a truthy valuefindKeyByValue
: takes in an object and a value, scans the object, and returns the first key which contains the given valueletterPositions
: returns all the indices (zero-based positions) in the string where each character is foundmap
: takes in an array and a callback function, and returns a new array based on the results of the callback functiontakeUntil
: takes in an array and a callback function, and returns the first part of the array until an element fulfills the functionwithout
: takes in a source array and items to remove array, and returns a subset of a given array, removing unwanted elements