1.0.0 • Published 5 years ago
@nkadish/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 @nkadish/lotide
Require it:
const _ = require('@nkadish/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arrayOne, arrayTwo)
: checks to see if two arrays are the same as one anotherassertEqual(actual, expected)
: checks to see if the value put in is the same as what the expected output isassertObjectsEqual(actual, expected)
: checks to see if the outputted object is the same as the expected objectcountLetters(sentence)
: counts the number of letters in a sentencecountOnly(allItems, itemsToCount
: takes in an array and an object of what you want to count, and counts the number of times something from the object is in the arrayeqArrays(array1, array2)
: checks to see if two arrays are the sameeqObjects(object1, object2)
: checks to see if two objects are the samefindKey(object, callback)
: looks through the values of each key in an object for the one specified in the callback, returning the first key associated with that valuefindKeyByValue(objectToSearch, valInput)
: searches through an object for the specified value, returning the key associated with itflatten(arrayWithNested)
: un-nests an array, taking a nested array and returning the flattened version of ithead(array)
: returns the first item in an arrayletterPositions(sentence)
: takes a sentence and populates an object with a key for each letter in the sentence, the value of the keys being an array with the index of each time that letter shows upmap(array, callback)
: modifies the array by the callbackmiddle(array)
: finds the middle of an array and returns a new array with it. if the array is even it returns the two middle numbers and if the passed in array has two or less items it returns an empty arraytail(array)
: returns an array with everything but the first item of the passed in arraytakeUntil(array, callback)
: creates a new array that has all items up to whatever was passed into the callbackwithout(source, itemsToRemove)
: removes the specified items from the source array
1.0.0
5 years ago