1.0.1 • Published 5 years ago
@jomicm/lotide v1.0.1
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 @jomicm/lotide
Require it:
const _ = require('@jomicm/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: takes an array and returns the element at the first indextail(arr)
: takes an array and returns all elements after the first indexmiddle(arr)
: takes an array and returns the middle element (one element for odd number, two elements for even number)assertArraysEqual([arr1], [arr1])
: It will compare two different arrays and return true if equal or false if differentassertEqual(val1, val2)
: It will compare two different primitives and return true if equal or false if differenteqArrays([arr1], [arr2])
: It will compare two different arrays and return true if equal or false if differentcountLetters(string)
: It will return how many letters a given string hascountOnly(allItems, itemsToCount)
: It will count elements unless they have a false valueeqObject(object1, object2)
: It will compare two objectsfindKey(object, callback)
: It will find the element which key is the string providedfindKeyByValue(object, value)
: It will find the element which value is the string providedflatten([arr1], [arr2])
: It will integrate nested arrays into a single arrayletterPositions(sentence)
: It will return the ocurrences of all the letter in a given stringmap(array, callback)
: It will return a new array based on the callback of the functionassertObjectsEqual(object1, object2)
: It will compare two ObjectstakeUntil(array, callback)
: It will return an array containing all elements of a given array but stopping at a given valuewithout(source, itemsToRemove)
: It will return an array containing all elements of a given array but the ones contained in another given array