1.0.1 • Published 6 years ago
@fapapa/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 @fapapa/lotide
Require it:
const _ = require('@fapapa/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actualArr, expectedArr): Deeply checks the equality of the two passed-in arrays and logs to the console either a passed or failed messageassertEqual(actual, expected): For primitive values; Checks for strict equality between the two passed-in values.assertObjectsEqual(actualObj, expectedObj): Deeply checks the equality the two passed-in objectscountLetters(string): Givenstringreturns an object with each unique letter in string as a property, with the number of times that letter appears in the string as a valuecountOnly(allItems, itemsToCount): Returns an object with counts for all the items in arrayallItems, whereitemsToCount[*allItems[i]*]returns trueeqArrays(actual, expected): Deeply checks the equality of the two passed in arrays and returns true or falseeqObjects(actual, expected): Deeply checks the equality of the two passed in objects and returns true or falsefindKey(obj, callback): Returns the first property forobjwhere the callback returns truefindKeyByValue(obj, val): Returns the first property inobjwhere its value is equal tovalflatten(array): Flattens multi-dimensionalarrayhead(array): Returns the value at index 0 ofarrayletterPositions(string): Returns an object corresponding tostringwhere each property is a unique letter of string, with the number of times it appears in stringmap(array, callback): Passes in each element ofarraytocallbackand puts the return value ofcallbackinto a new array, and returns itmiddle(arr): Returns the middle one (for odd-length arrays) or two (for even-length arrays) elements ofarraytail(arr): Returns everything but the first element ofarrtakeUntil(array, callback): Returns all the items ofarrayin a new array untilcallbackreturns a falsey valuewithout(array, itemsToRemove): Returns an array with all items inarrayexcept those that are also initemsToremove