@seangray-dev/lotide
v1.0.2
Published
A mini clone of the lodash library
Downloads
5
Readme
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 @seangray-dev/lotide
Require it:
const _ = require('@seangray-dev/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: compares two arrays for equality and returns a boolean value while also logging a message to the console. See ExampleassertEqual
: compares two values for equality and returns a message indicating whether the assertion passed or failed. See ExampleassertObjectsEqual
: compares two objects for equality and returns a message indicating whether the assertion passed or failed. See ExamplecountLetters
: takes in a string and returns an object containing a count of each letter in the string (excluding spaces). See ExamplecountOnly
: takes in an array of items and an object containing a set of items to count, and returns an object with counts of the items in the original array that are specified in the input object. See ExampleeqArrays
: takes in two arrays and returns a boolean value indicating whether they are equal. See ExampleeqObjects
: takes in two objects and returns a boolean value indicating whether they are equal. See ExamplefindKey
: takes in an object and a callback function, and returns the first key for which the callback function returns a truthy value. See ExamplefindKeyByValue
: takes in an object and a value, and returns the first key in the object that has the specified value. See Exampleflatten
: takes in an array and returns a new flattened array (an array with all subarrays flattened into a single level). See Examplehead
: takes in an array and returns the first element See ExampleletterPositions
: takes in a string and returns an object that contains arrays of the positions of each letter in the string. See Examplemap
: takes in an array and a callback function, and returns a new array with each element transformed by the callback function. See Examplemiddle
: takes in an array and returns the middle element(s) of the array. See Exampletail
: takes in an array and returns a new array with all elements except for the first element of the input array. See ExampletakeUntil
: takes in an array and a callback function, and returns a new array that includes all elements of the input array up until the point where the callback function returns a truthy value. See Examplewithout
: filters elements from thesource
array and returns a new array that excludes any elements that are also in theitemsToRemove
array. See Example