1.0.0 • Published 2 years ago
@jangw/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 @jangw/lotide
Require it:
const _ = require('@jangw/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
function head(arr)
:returns first element of an arrayfunction middle(arr)
: returns middle element of an array, in case of array with even number of elements returns middle two elementsfunction tail(arr)
: returns all the elements from an array except head i.e first elementfunction countLetters(str)
: returns the number of occurrence of character in a stringfunction countOnly(arr,obj)
: returns the number of occurrence of character of object in an arrayfunction findKey(obj,callback)
: returns the key where callback is true for object valuefunction findKeyByValue(obj,value)
: returns the key of for the value of the given objectfunction flatten(arr)
: returns one array from the nested arrayfunction letterPosition(str)
: returns index value of given stringfunction map(arr,callback)
: returns new arr by applying callback on each element of the arrayfunction takeUntil(arr,callback)
: returns the array with values before the callback return true for the arrayfunction without(arr,val)
: returns the array excluding the val from the array
1.0.0
2 years ago