1.0.0 • Published 5 years ago
@mjoyal/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 @mjoyal/lotide
Require it:
const _ = require('@mjoyal/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
- head(array): takes in an array, returns the head of the array.
- tail(...): takes in an array, returns the tail of the array.
- middle(...): takes in an array, returns the middle of the array (array of one if the array passed was odd, returns array of two if passed an even array)
- countLetter(...): takes a string, returns an object with letters as keys and values as the count of instances of that letter in the string
- countOnly(...): takes an array and object. will return an object containing counts of everything that the input object listed.
- findKey(...): 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.
- findKeyByValue(...): takes an object and value. Returns first key with that value
- flatten(...): takes in an array with nested arrays (one level) and returns an array without nested arrays.
- letterPositions(...): takes a string. returns an object with keys of each letter and values with an array of indices of the letter.
- map(...): takes an array and a callback function. returns a new array based on the results of the callback.
- takeUntil(...): takes an array and callback. will keep collecting items from a provided array until the callback provided returns a truthy value. returns new array
- without(...): takes an array and value. removes all instances of that value from the array and returns a new array without those values.
1.0.0
5 years ago