1.0.0 • Published 4 years ago
@snguyenbui/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 @snguyenbui/lotide
Require it:
const _ = require('@snguyenbui/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
countLetters("sentence", () => {})
: counts every letter of a given sentence and returns an object containing that countcountOnly([array], obj{elem: true, elem1: false, ...})
: counts desired elements from an object in an array and returns the counts as an object {key: count, ...}findKeyByValue(obj{key: value, ...}, "value")
: finds the first key that has the desired valuefindKey(obj{key: value, ...}, callback())
: finds the first key that matches the callback functionflatten([array])
: turns a given array to a single-level arrayhead([array])
: returns the first element of the arrayletterPositions("string")
: takes a single string and returns an object {'char': indexes of char, ...}map([array], callback())
: takes an array and returns an array with the callback function applied to each element of the initial arraymiddle([array])
: returns the middle element of an array if the array is longer than 3. Returns an empty array if length is less than 2. Even length arrays return a 2 element arraytail([array])
: returns a copy of the array without the first elementtakeUntil([array], callback())
: returns an array that has each element of the given array until the callback function is falsewithout([baseArray], [removalArray])
: removes an element from the removal array from the base array and returns the base array
1.0.0
4 years ago