1.0.1 • Published 2 years ago
@lucasw4/lotide v1.0.1
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 @lucasw4/lotide
Require it:
const _ = require('@lucasw4/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
middle(array)
: returns the middle value or values of an arraymap(array, callBackFunction)
: returns a new array with the callbackfunction ran on every element of the first arrayletterPositions(sentence)
: returns an object with the positions of every letter in a word or sentenceindex.js
: exports every functionhead(array)
: returns the 0th index of an arrayflatten(array)
: returns a flattened array, from an array with nested arraysfindKeyByValue(object, value)
: finds the key from a value in an objectfindKey(object, callBackFunction
: finds the first key in an object where the parameters if the callbackfunction returns trueeqObjects(object1, object2)
: returns true or false, depending on if 2 objects are equal or noteqArrays(array1, array2)
: returns true or false, depending on if 2 arrays are equal or notcountOnly(array, items)
: takes an array and an array of items and returns a count of each item in the items array that is in the arraycountLetters(sentence)
: returns an object with a count of each letter in a sentenceassertObjectsEqual(actual, expected)
: logs to the console if the actual object === the expected objectassertEqual(actual, expected)
: returns true if actual result === expected result, and false for the inverseassertArraysEqual(actual, expected)
: returns true if actual array === expected array, and false for the inversewithout(array, itemsToRemove)
: returns a new array with items fro the ItemsToRemove array removedtakeUntil(array, callBackFunction)
: returns a new array with all items taken out until the callbackFunction is true