1.0.0 • Published 4 years ago
@alicemathews/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 @alicemathews/lotide
Require it:
const _ = require('@alicemathews/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: returns the head of the array (the first element)tail(arr)
: returns and array containing the tail of the input array (every element apart from the head)middle(arr)
: returns an array containing the middle elements of the input arraycountLetters(str)
: returns an object with keys as the characters and values as how many times they occur, does not include spacescountOnly(arr, obj)
: recieves an array of items and an object defining items to count. Returns an object with keys as the original array items and values of the number of times they occur.eqArrays(arr, arr)
: recieves 2 arrays and returns true if they are equal and false if they are noteqObjects(obj, obj)
: recieves 2 objects and returns true if they are equal and false if they are notfindKey(obj, func)
: recieves an object and evaluator function and returns the first key that evaluates to truefindKeyByValue(obj, value)
: returns the key that corresponds to the input value in the objectflatten(arr)
: recieves a nested array and returns the flattened arrayletterPositions(str)
: takes a string and returns an object with each character as a key and its values as an array containing each index it exits inmap(arr, function)
: takes in an array and a function to perform on each element, returns the new arraytakeUntil(arr, func)
: takes in an array and evaluator function. loops through array and writes each element to a new array until function is truewithout(arr)
: takes in an array and an array of items to remove. only writes elements to new array if they are not included in the remove array. returns new array
1.0.0
4 years ago