1.0.0 • Published 5 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 ofarrayas a one element arraytail(array): Returns every element ofarrayexcept the first as an arraymiddle(array): Returns the middle-most element(s) ofarrayas an arraycountLetters(string): Returns an object with letters ofstringas keys with their counts as their valuescountOnly(allItems, itemsToCount): Returns a number with the number of timesallItemscontainsitemsToCountfindKey(object, callback): Returns the first key ofobjectthat fulfills the condition set bycallbackfindKeyByValue(object, value): Returns the first key ofobjectthat has the value ofvalueflatten(array): Returns an array of all non-array elements within an inputarraythat may have nested arraysletterPositions(string): Returns an object with letters ofstringas the keys and an array of their index positions instringas their valuesmap(array, callback): Returns an array with the functioncallbackcalled on each element ofarraytakeUntil(array, callback): Returns an array of sequential elements ofarrayuntil it reaches an element that returns a truthy evaluatedcallbackwithout(source, itemsToRemove): Returns a copy of the arraysourcewithout elements found initemsToRemove
1.0.0
5 years ago