1.0.0 • Published 3 years ago
@michaeltcdavis/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 @michaeltcdavis/lotide
Require it:
const _ = require('@michaeltcdavis/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: takes an array and returns the first elementtail(array)
: takes an array and returns the array without the first elementmiddle(array)
: takes an array and returns the middle element (middle two elements for an even array)assertArraysEqual(actualArray, expectedArray)
: prints to console whether two arrays are equalassertEqual(actual, expected)
: prints to console whether two values are equalassertObjectsEqual(ActualObj, expectedObj)
: prints to console whether two objects are equalcountLetters(string)
: returns the number of each letter in a given stringcountOnly(array, objectToCount)
: returns an object of the occurences from the given array of the keys to find which are indicated in the given objecteqArrays(array1, array2)
: returns true or false depending on whether the given arrays are equaleqObjects(object1, object2)
:returns true or false depending on whether the given objects are equalfindKey(object, criteriaFunction)
: returns the key of the first occurence of the given criteria function returning true for a given objects keysfindKeyByValue(object, Value)
: returns the key of a given object which has a value matching the given valueflatten(array)
: returns an array which un-nests one level of nested arraysletterPositions(sentence)
: returns an object containing arrays of all the indexes of each letter's occurence in a given sentence (string)map(array, callback)
: takes an array and a function and returns a new array with the function applied to each elementtakeUntil(array, callback)
: copies an array element by element until the given callback function returns truewithout(array, toRemove)
: takes an array and an array with values to remove and returns a new array which does not include any elements matching the elements in the toRemove array
1.0.0
3 years ago