1.0.0 • Published 4 years ago
@calvin.xu/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 @calvin.xu/lotide
Require it:
const _ = require('@calvin.xu/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: Returns the first element ofarray
as a one element arraytail(array)
: Returns every element ofarray
except the first as an arraymiddle(array)
: Returns the middle-most element(s) ofarray
as an arraycountLetters(string)
: Returns an object with letters ofstring
as keys with their counts as their valuescountOnly(allItems, itemsToCount)
: Returns a number with the number of timesallItems
containsitemsToCount
findKey(object, callback)
: Returns the first key ofobject
that fulfills the condition set bycallback
findKeyByValue(object, value)
: Returns the first key ofobject
that has the value ofvalue
flatten(array)
: Returns an array of all non-array elements within an inputarray
that may have nested arraysletterPositions(string)
: Returns an object with letters ofstring
as the keys and an array of their index positions instring
as their valuesmap(array, callback)
: Returns an array with the functioncallback
called on each element ofarray
takeUntil(array, callback)
: Returns an array of sequential elements ofarray
until it reaches an element that returns a truthy evaluatedcallback
without(source, itemsToRemove)
: Returns a copy of the arraysource
without elements found initemsToRemove
1.0.0
4 years ago