1.0.1 • Published 3 years ago
@ngoalvin/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 @ngoalvin/lotide
Require it:
const _ = require('@ngoalvin/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(actual, expected)
: asserts the given parameters using ===assertArraysEqual(actual, expected)
: asserts the given arraysassertObjectsEqual(actual, expected)
: asserts the given objectseqArrays(actual, expected)
: checks if the given arrays are the sameeqObjects(actual, expected)
: checks if the given objects are the samecountLetters(str)
: counts the amount of letters(a-z,A-Z) are in a stringcountOnly(allItems, itemsToCount)
: returns an object counting the times an element repeats in allItemsfindKey(data, callback)
: returns the first key found from the given callbackfindKeyByValue(object, value)
: returns the key that has the given valueflatten(array)
: returns a new unested array from the given arrayhead(array)
: returns the first element of the arraytail(array)
: returns a new array without the first element of the given arrayletterPositions(string)
: returns an object with key as a letter from the string and value of which index it was foundmap(array, callback)
: takes in an array and returns an new array depending on the callbackmiddle(array)
: returns an array of the middle elements, if length of array < 2 returns []takeUntil(array, callback)
: takes in an array and returns an array up to the point an element meets the callbackwithout(array, itemsToRemove)
: returns a new array without the items in itemsToRemove