1.0.0 • Published 3 years ago
@eascan/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 @username/lotide
Require it:
const _ = require('@eascan/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head([array])
: returns first elementtail([array])
: returns array of all elements other than the first onemiddle([array])
: returns an array with the middle element(s)assertArraysEqual(actual, expected)
: logs an assert statement if actual array is equal or not to expected arrayassertEqual(actual, expected)
: logs an assert statement if actual equals expectedassertObjectsEqual(actual, expected)
: logs and assert statement if actual object is equal to expected objectcountLetters(input)
: returns an object with each letter of the input as key, and values are the number of times each key is repeated in the inputcountOnly(allItems, itemsToCount)
: This function should take in a collection of items as an object and return counts for a specific subset of those items (also inputed as an object, key + value pairs with values being true or false)eqArrays(array1, array2)
: takes two arrays and returns true if they are equal and false if noteqObjects(object1, object2)
: takes two objects as inputs and returns true if equal, false if notfindKey(object, callback)
: takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined.findKeyByValue(object, value)
: search for a key on an object where its value matches a given value.letterPositions(sentence)
: return an object where character of sentence is a key and the value is an array of all indices where the letter is found in the sentencemap(array, callback)
: will take an inputted array, perform a callback function on each element of the array and return a new array based on those actions.takeUntil(array, callback)
: will return an array which will include the elements of original array up until the callback returns a truthy valuewithout(array, arrayItemsToRemove)
: return a new array based on original array without the items that needed to be removed
1.0.0
3 years ago