1.0.0 • Published 1 year ago
@juan-escobar/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 @juan-escobar/lotide
Require it:
const _ = require('@juan-escobar/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: Asserts if two arrays are equal.assertEqual
: Asserts if two values are equal.(strings, numbers, booleans, undefined, null and arrays)assertObjectsEqual
: Asserts if two objects are equal.countLetters
: Counts the letters of a string.countOnly
: It takes in a collection of items and return counts for a specific subset of those items.findKeysByValue
: It helps us search for a key on an object where its value matches a given value.head
: It reurns the first element of an array.findKey
: It takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined.letterPositions
: It will return all the indices (zero-based positions) in the string where each character is found.map
: It will return a new array based on the results of the callback function.takeUntil
: It will keep collecting items from a provided array until the callback provided returns a truthy value.without
: It will return a subset of a given array, removing unwanted elements.tail
: returns the "tail" of an array: everything except for the first item (head) of the provided array.middle
: If the length of the array is odd it will return the middle element. If the length of the array is even it will return the two elements in the middle of the array.
1.0.0
1 year ago