1.0.0 • Published 3 years ago
@ryanthedev/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 @ryanthedev/lotide
Require it:
const _ = require('@ryanthedev/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2): Outputs a console.log message stating ifarr1andarr2are equivalent arraysassertEqual(actual, expected): Outputs a console.log message stating ifactualandexpectedare equalassertObjectsEqual(obj1, obj2): Outputs a console.log message stating ifobj1andobj2have the same key-value pairscountLetters.js(string): Returns an object with the keys being the letters that occur instringand the values being the number of times the letter occurs instringcountOnly(arr, obj): Returns an object containing the counts of everything that obj listedeqArrays(arr1, arr2): Returns true ifarr1andarr2are equivalent, returns false if otherwiseeqObjects(obj1, obj2): Returns true ifobj1andobj2have the same key-value pairs, returns false if otherwisefindKey(obj, callback): Returns the first key inobjfor which thecallbackreturns a truthy value, returns undefined if no key is foundfindKeyByValue(obj, value): Returns the key inobjwhich has the the valuevalue, returns undefined if no key existsflatten(arr): Returns a flattened version ofarrgiven thatarrhas at most, one level of nestinghead(arr): Returns the first element inarr. Ifarris empty, returns an empty arrayletterPosition(string): Returns an object where they keys are the letters that occur instringand the values are all the indices where each letter is found.map(arr, callback): Returns a new array consisting of the values of returned bycallbackon each of the elements inarrmiddle(arr): Returns an array consisting of the middle element(s) inarrtail(arr): Returns an array consisting of the elements inarr, excluding the first elementtakeUntil(arr, callback): Returns a slice ofarrwith elements being taken from the beginning until thecallbackreturns a truthy valuewithout(source, itemsToRemove): Returns a new array with only those elements fromsourcethat are not present initemsToRemove
1.0.0
3 years ago