1.0.1 • Published 3 years ago
@tzheng/lotide1 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 @tzheng/lotide
Require it:
const _ = require('@tzheng/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: assertion function to check if two arrays are equalassertEqual(actual, expected)
: assertion function to check if two primitives are equalassertObjectsEqual(actual, expected)
: assertion function to check if two objects are equalcountLetters(string)
: returns a count of the number of letters in inputcountOnly(allItems, itemsToCount)
: maps a count of each unique element of itemsToCount in allItemseqArrays(arr1, arr2)
: checks if two arrays are equal (deep check to be implemented)eqObjects(actual, expected)
: deep checks if two objects are equalfindKey(object, callback)
: returns the key of the first object with key in object else returns undefinedfindKeyByValue(object, value)
: returns the key of the first object with value in object else returns undefinedflatten(arr)
: returns a 1-dimentional array of flattened n-dimentional arrays of elementshead(arr)
: returns the first element in an arrayletterPositions(sentence)
: returns a map of letters (key) and array of positions that letter appears in sentence (value)map(array, callback)
: returns a new array whose elements consist of each element of the original array after callback functionmiddle(array)
: returns an array of the middle element(s) in an arraytail(arr)
: returns an array of all the elements after the first element in arrtakeUntil(array, callback)
: returns an array of values from original array that until the first element that evaluates to false from the callbackwithout(source, itemsToRemove)
: returns a new array consisting of all elements in source without elements in itemsToRemove