1.0.1 • Published 11 months ago
@afreeda/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 @afreeda/lotide
Require it:
const _ = require('@afreeda/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(value1, value2)
: logs to the console whether two given values are the samehead(array)
: returns the first element of a given arraytail(array)
: returns every element except the first element in a given array in a form of an arraymiddle(array)
: returns an array of the middle elements of a given arrayeqArrays(arr1, arr2)
: checks if two given arrays are equalassertArraysEqual(arr1, arr2)
: assertion to check if two arrays are equal based on eqArrays()without(arr, itemsToRemove)
: when given an original array and an array of items to be removed, returns a modified original array without elements that were removedflatten(array)
: when given a nested array, returns a 1 dimensional arraycountOnly(allItems, itemsToCount)
: returns the counts for a specific subset of those items in a given arraycountLetters(string)
: returns an object of the number of times a character appears in a given stringletterPositions(sentence)
: returns an object with array values of the index number of each character in a given stringfindKeyByValue(object, value)
: returns the key when given a value corresponding to that keyeqObjects(obj1, obj2)
: checks for equality of given objectsassertObjectsEqual(obj1, obj2)
: assertion to check for object equality using eqObects()map(array, callback)
: given an array and a callback, the function will return a modified array based on the condition of the callbacktakeUntil(array, callback)
: given an array and a callback, returns a new array of items up until a particular condition is metfindKey(object, callback)
: given an object and callback, the function will return the first key associated with the value from the callback