@dirtandgrass/lotide
v1.0.1
Published
a collection of utility functions authored for Lighthouse Labs Bootcamp3
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 @dirtandgrass/lotide
Require it:
const _ = require('@dirtandgrass/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: compares two arrays and logs a message to the consoleassertEqual(actual, expected)
: compares two values and logs a message to the consoleassertObjectsEqual(obj1, obj2)
: compares two objects and logs a message to the consolecountLetters(str)
: returns an object with the count of each letter in the input stringcountOnly(allItems, itemsToCount)
: returns an object with the count of each item in the input arrayeqArrays(arr1, arr2)
: compares two arrays and returns a booleaneqObjects(obj1, obj2)
: compares two objects and returns a booleanfindKey(obj, callback)
: returns the first key for which the callback returns a truthy valuefindKeyByValue(obj, value)
: returns the first key for which the value is foundflatten(arr)
: returns a new array with all elements of the input arrayhead(arr)
: returns the first element of the input arrayletterPositions(str)
: returns an object with the position of each letter in the input stringmap(arr, callback)
: returns a new array with the results of the callback functionmiddle(arr)
: returns the middle element(s) of the input arraytail(arr)
: returns a new array with all elements of the input array except the firsttakeUntil(arr, callback)
: returns a new array with elements of the input array until the callback returns a truthy valuewithout(source, itemsToRemove)
: returns a new array with all elements of the input array except the ones to remove