1.0.0 • Published 4 years ago
@cagregoris/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 @cagregoris
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head
: Returns the first item in an array.tail
: Returns every item after the first item in an array.assertArraysEqual
: Asserts whether two arrays are equal.assertEqual
: Asserts whether two primitive values are equal.assertObjectsEqual
: Asserts whether two objects are equal.countLetters
: Returns an object containing each unique character in the given string as a key and the property will contain the number of occurrences of that character.countOnly
: Given an array and an object, the function will return an object containing counts of everyhting that the input object listed and was contained in the array as well.eqArrays
: Compares the data of two arrays and returns whether or not they are equal.middle
: Returns only the middle elements of an array - the two in the middle for an array with an even .length, and the one in the middle for an array with an odd .length.eqObjects
: Compares the data of two objects and returns whether or not they are equal.findKey
: Takes an object and a callback and returns the first item in the object for which the callback returns a truthy value.findKeyByValue
: Takes an object and a value and returns the first key that contains the given value.letterPositions
: Returns an objects containing each character in a string as the key and its index position as the value.map
: Returns a new array based on the results of the callback function.takeUntil
: Removes the elements of an array until the callback function returns a truthy value.without
: Takes two arrays and returns a new array that only contains the elements that the "contains" array contains and that the "doesn't contain" array does not.
1.0.0
4 years ago