1.0.0 • Published 5 years ago
@ninjabattler/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 @ninjabattler/lotide
Require it:
const _ = require('@ninjabattler/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArrayEqual(Actual, Expected): takes in two arrays and asserts if they are equal or notassertEqual(Actual, Expected): takes in two primitive values and asserts if they are equal or notassertObjectsEqual(Actual, Expected): takes in two objects and asserts if they are equal or notcountLetters(String): takes in a string and returns an object with each letter - excluding spaces - as a key and how many time the appear in the string as the key valuecountOnly(AllItems, ItemsToCount): takes in an array of items and an object of items to count. Will return an object with the count valueseqArrays(Array1, Array2): takes in two arrays and returns true/false if they are equal or noteqObjects(Object1, Object2): takes in two objects and returns true/false if they are equal or notfindKey(Object, Callback): take in an object and a callback function to search for the key. Will return the key name that evaluates the callback to truefindKeyByValue(Object, Value): takes in an object and a primitive value. Will return the first key that's value matches the input valueflatten(Array): takes a nested array and returns an unnested version of the input arrayhead(Array): returns the first item in an arrayletterPositions(String): takes in a string and returns an object with each a key for each letter excluding space. Each key has an array of every position the letter appeared in the string.map(Array, Callback): takes in an array and a callback function. Returns an array of all the values returned by the callback functionmiddle(Array): takes in an array and returns the middle value of an array. Returns an array with two values for arrays with an even lengthtail(Array): takes in an Array returns every item after the head of the arraytakeUntil(Array, Callback): takes in an array and a callback function. Returns an array of all items in the input array until the callback evaluates to truewithout(Array, ItemsToRemove): takes in an array and a second array of items to remove. Returns a copy of the first array with all values in the second array removed
1.0.0
5 years ago