1.0.1 • Published 4 years ago
@tonyhaofu/lotide v1.0.1
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 @tonyhaofu/lotide
Require it:
const _ = require('@tonyhaofu/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(array1, array2): asserting that two arrays are the same (supports nesting)assertEqual(actual, expected): asserting that two parameters are equal (does not support objects or arrays) using===assertObjectsEqual(object1, object2): asserting that two objects are equal (supports nesting)countLetters(str): counts occurence of letters in stringcountOnly(allItems, itemsToCount): given an arrayallItems, returns obj with key: value pairs representing elements in array and the number of times that element occurs in the array but only for elements that appear in arrayitemsToCounteqArrays(array1, array2): returns boolean of whether the 2 arrays are equal (supports nesting)eqObjects(object1, object2): returns boolean of whether 2 objects are equal (supports nesting)findKey(dict, callback): returns key value for the first property ofdictobject wherecallbackreturnstruefindKeyByValue(dict, value): returns key for the first property ofdictwhere the value is equal tovalueflatten(arr): flattens a nested arrayhead(arr): returns the first element of an arrayletterPositions(sentence): returns an object with keys equal to the letters of the stringsentenceand values equal to an array containing the indices at which those letters appear insentencewith the white-space removedmap(array, callback): returns array with mapped values usingcallbackfunctionmiddle(arr): returns array containing the middle element(s) of arrayarrtail(arr): returns array containing the elements of arrayarrnot including the first elementtakeUntil(array, callback): returns array of elements from arrayarrayuntilcallback(element)returns true. Does not include that valuewithout(source, itemsToRemove): returns array with elements from arraysourcebut with elements contained in arrayitemsToRemoveremoved.