1.0.0 • Published 3 years ago
@bernadetteroseabalos/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 @bernadetteroseabalos/lotide
Require it:
const _ = require('@bernadetteroseabalos/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arrayOne, arrayTwo)
: Compares two arrays. Assertion test passed if they are equal, failed if not equal.assertEqual(actual, expected)
: Compares two primitive values and asserts true if they are the same.assertObjectsEqual(object1, object2)
: Compares two objects and asserts true if they are the same.countLetters(sentence)
: Takes in a sentence and returns count of each of the letters in the sentence.countOnly(allItems, itemsToCount)
: Takes in a collection of items (allItems) and returns a specific subset of those items (itemsToCount).eqArrays(arrayOne, arrayTwo)
: Compares two arrays and returns true if arrays are equal.eqObjects(object1, object2)
: Compares two objects and returns true if they are equal.findKey(object, callback)
: Takes in an object and a callback. Scans the object and returns the first key for which the callback returns a truthy value. If no key is found, returns undefined.findKeyByValue(object, value)
: Takes in an object and a value. Scans object and returns first key which contains the given value. If no key with that given value is found, returns undefined.flatten(arrayOne, arrayTwo)
: Takes in an array containing nested arrays as elements and flattens them into one array.head(array)
: Takes in an array and returns first item in the array.letterPositions(sentence)
: Takes in a sentence and returns indices of letters in the string.map(array, callback)
: Takes in an array and callback and returns new array based on callback function. Callback function is applied to all elements in the array.middle(array)
: Takes in an array and returns middle element.tail(array)
: Takes in array and returns everything but the first element in the array (tail).takeUntil(array, callback)
: Takes in an array and callback and returns sliced version of array. Will keep collecting items from provided array until callback returns truthy value.without(source, itemsToRemove)
: Takes in source array and removes items in the array (itemsToRemove).
1.0.0
3 years ago