1.0.0 • Published 3 years ago
@jerrica-mj/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 @jerrica-mj/lotide
Require it:
const _ = require('@jerrica-mj/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(...)
: tests assertion that two arrays are exactly equal, and logs a pass or fail message to the consoleassertEqual(...)
: tests assertion that two values are equal, and logs a pass or fail message to the consoleassertObjectsEqual(...)
: tests assertion that two objects are equal, and logs a pass or fail message to the consolecountLetters(...)
: receives a string and returns a count the number of letters in that stringcountOnly(...)
: receives an array and object, then returns an object containing counts of everything listed in the argument objecteqArrays(...)
: compares two arrays for strict equality, returning a boolean resulteqObjects(...)
: compares two objects for strict equality, returning a boolean resultfindKey(...)
: takes in an object and a callback, scans the object, then returns the first key for which the callback returns a truthy valuefindKeyByValue(...)
: receives an object and a value, then returns the first object key whose value contains the given valuehead(...)
: returns the first item in an arrayletterPositions(...)
: receives a string, then returns an object of arrays of each unique letter and all the indeces at which they are located in the stringmap(...)
: receives an array and a callback function, then returns a new array based on the result of the callback on the input array's elementsmiddle(...)
: returns the middle-most element(s) of the given arraytail(...)
: returns an array of all but the first item in a given arraytakeUntil(...)
: receives an array and a callback, then returns a slice of the array with elements taken from the start until the index where the callback returns a truthy valuewithout(...)
: receives a source array and an itemsToRemove array, then returns a new array with only the items from the source array that are not present in the itemsToRemove array
1.0.0
3 years ago