1.0.0 • Published 1 year ago
@kshilina/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 @kshilina/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
eqArrays
: takes in two arrays and returns a boolean value indicating whether they are equal. click here for exampleassertEqual
: compares two values for equality and returns a message indicating whether the assertion passed or failed. click here for exampleassertArraysEqual
: compares two arrays for equality and returns a boolean value. click here for exampleassertObjectsEqual
: compares two objects for equality and returns a message indicating whether the assertion passed or failed. click here for examplecountLetters
: takes in a string and returns an object containing a count of each letter in the string (excluding spaces). click here for 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. click here for exampleeqObjects
: takes in two objects and returns a boolean value indicating whether they are equal. click here for examplefindKey
: takes in an object and a callback function, and returns the first key for which the callback function returns a truthy value. click here for examplefindKeyByValue
: takes in an object and a value, and returns the first key in the object that has the specified value. click here for exampleflatten
: takes in an array and returns a new flattened array (an array with all subarrays flattened into a single level). click here for examplehead
: takes in an array and returns the first element. click here for exampleletterPositions
: takes in a string and returns an object that contains arrays of the positions of each letter in the string. click here for examplemap
: takes in an array and a callback function, and returns a new array with each element transformed by the callback function. click here for examplemiddle
: takes in an array and returns the middle element(s) of the array. click here for exampletail
: takes in an array and returns a new array with all elements except for the first element of the input array. click here for 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. click here for examplewithout
: filters elements from the source array and returns a new array that excludes any elements that are also in the itemsToRemove array. click here for example
1.0.0
1 year ago