1.0.0 • Published 3 years ago
@nikaffa/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 @nikaffa/lotide
Require it:
const _ = require('@nikaffa/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head (_.head)
: Returns the first element of an arraytail (_.tail)
: Returns all elements of an array exept the first onemiddle (_.middle)
: Takes in array and returns a new array with only the middle element(s) of the provided arrayassertEqual (_.assertEqual)
: Compares two values on equalityeqArrays (_.eqArrays)
: Takes in two arrays and returns true or false, based on a perfect matcheqObjects (_.eqObjects)
: Compares two objects: checks if they have identical keys and valuesassertArraysEqual (_.assertArraysEqual)
: Compares two arrays on equality and outputs a message whether they are equal or notassertObjectsEqual (_.assertObjectsEqual)
: Compares two objects on equality and outputs a message whether they are equal or notcountOnly (_.countOnly)
: Given an array of strings and object returns a new object with string as the key and as value - counts of each string were found in the given arraycountLetters (_.countLetters)
: Given a sentence (as a string), returns an object contains a letter and a count of that letter in the sentenceletterPositions (_.letterPositions)
: Given a string, returns an object contains letter as a key and as a value - an array with all the indices of the letter in stringfindKey (_.findKey)
: Takes in an object and a callback function, returns the first key for which the callback returns truefindKeyByValue (_.findKeyByValue)
: Given an object and a string, returns a key which value matched the stringtakeUntil (_.takeUntil)
: Returns a slice of the array with elements taken from the beginning until the callback returns truewithout (_.without)
: Takes in two arrays, returns a new array, removing unwanted elements from the sourcemap (_.map)
: Taking in an array and a callback function, returns a new array modified by callback
1.0.0
3 years ago