1.0.1 • Published 5 years ago
@j-nny/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 @j-nny/lotide
Require it:
const _ = require('@j-nny/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: takes an array and returns the element at the first indextail(array)
: takes an array and returns all elements after the first indexmiddle(array)
: takes an array and returns the middle element (one element for odd number, two elements for even number)assertArraysEqual([arr1], [arr1])
: assertion that compares two arrays and returns true or falseassertEqual(val1, val2)
: assertion that compares two primitives and returns true or falseeqArrays([arr1], [arr2])
: compares two arrays and returns true or falsewithout(source, itemsToRemove)
: takes an array and returns the modified array without the unwanted elementsflatten(array)
: takes a nested array and returns a 'flattened' array with just the elementscountOnly(allItems, itemsToCount)
: takes an array and returns the number of the desired elements to countcountLetters(string)
: takes a string and returns the number of desired letters to countletterPositions(sentence)
: takes a string and returns the indices of the desired letterfindKeyByValue(object, value)
: takes an object and returns the key of the value argumenteqObject(object1, object2)
: compares two objects and returns true or falseassertObjectsEqual(actual, expected)
: assertion that compares two objects and returns true or falsemap(array, callback)
: takes an array and returns a new array containing the results of the inputted callback functiontakeUntil(array, callback)
: takes an array and returns elements of the array until the callback returns truthyfindKey(array, callback)
: takes an array and returns the index of the first element that returns truthy