@amurrai/lotide
v1.0.0
Published
Training project for Lighthouse Labs
Downloads
4
Readme
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 @amurrai/lotide
Require it:
const _ = require('@amurrai/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
function1(...)
: description
head(arr)
: returns the first element of an arraytail(arr)
: returns all elements of an array except from the firstmiddle(arr)
: returns the middle index item of an array with an odd number of elements and the middle 2 items of an array with even number of itemsflatten(arr)
: takes a 2 level array and returns a single level array with the same itemsmap(arr, callback)
: returns an array of the results of the callback over each item in arrtakeUntil(arr, callback)
: returns an array of the callback over each item of arrwithout(arr, itemsToRemove)
: returns an array without the items listed to be removedfindKey(obj, callback)
: returns the key of callback in objfindKeyByValue(object, value)
: returns the key of value in objcountLetters(str)
: returns an object with keys for each letter in the string and the value of their respective countscountOnly(arr1, arr2)
: returns an object with the items from arr2 as keys and the values equal to the counts of each item in arr1assertArraysEqual(arr1, arr2)
: console.log the return of eqArraysassertEqual(actual, expected)
: console.log assertion of comparison between actual and expectedassertObjectsEqual(actual, expected)
: deep comparison between objects actual and expectedeqArrays(arr1, arr2)
: shallow comparison between arrays arr1 and arr2eqObjects
:letterPositions(str)
: takes a string and returns an object with a key for each letter and the value of all indexes of the letter occurence