1.0.1 • Published 2 years ago
@dinaganai/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 @dganai/lotide
Require it:
const _ = require('@dganai/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns first element of an arraytail(arr)
: returns tail of an array (not including first element)middle(array)
: returns middle most elements of given arrayassertEqual(actual, expected)
: prints "✅✅✅ Assertion Passed" or "🛑🛑🛑 Assertion Failed" when comparing two values to see if they match or notassertArraysEqual(array1, array2)
: prints "✅✅✅ Assertion Passed" or "🛑🛑🛑 Assertion Failed" when comparing to see if two arrays are equaleqArrays(array1, array2)
: takes in two arrays and returns true or false, based on a perfect matchwithout(source, itemsToRemove)
: returns a subset of the given array, removing unwanted elementscountOnly(allItems, itemsToCount)
: takes in a collection of items and returns counts for a specific subset of those itemscountLetters(string)
: takes in a sentence as a string then returns a count of each of the letters in that sentenceletterPositions(sentence)
: returns all the indices in the string where each character is foundfindKeyByValue(object, value)
: scans the object and returns the first key that contains a given value; undefined if no valueeqObjects(object1, object2)
: returns true or false based on if two object are a match perfect match or notassertObjectsEqual(actual, expected)
: prints "✅✅✅ Assertion Passed" or "🛑🛑🛑 Assertion Failed" when comparing two objects to see if they match or notmap(array, callback)
: returns new array based on results of the callback functiontakeUntil(array, callback)
: returns slice of the array with elements taken from the beginning, until the callback returns a truthy valuefindKey(object, callback)
: scans object and returns the first key for which the callback returns a truthy value; if no key, returns undefined