1.0.0 • Published 2 years ago
@stanwong/lotide v1.0.0
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 @stanwong/lotide
Require it:
const _ = require('@stanwong/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: compares if two arrays are the same, console logs the outcomeassertEqual(actual, expected)
: compares if two values are the same, console logs the outcomeassertObjectsEqual(obj1, obj2)
: compares if two objects are the same, console logs the outcomeletterCount(str)
: returns an object with a count of each letter, spaces are not includedcountOnly(arr, filterObj)
: takes in an array of items and a 'filter' object with names as properties and a boolean value, returning an object that counts each name in the argument object with a true valueeqArrays(arr1, arr2)
: returns a boolean if two arrays are the sameeqObjects(obj1, obj2)
: returns a boolean if two objects are the samefindKey(obj, callback)
: return a key of an object matching the returned value of a callback, returns undefined if nothing is found.findKeyByValue(obj, value)
: returns a key of an object matching the value, returns an empty string if nothing is found.head(arr)
: returns first element of an arrayletterPositions(str)
: returns an object with the index positions of each letter in a stringmap(arr, callback)
: applies the callback function onto each item of an array and returns a new array of the outputsmiddle(arr)
: returns middle element of an array with an odd number of items, returns an empty array if the number of items is even or 1tail(arr)
: returns a new array that excludes the first item of the array that was passedtakeUntil(arr, callback)
: mutates an array by removing elements up to the end of the array starting from the value returned by the callbackwithout(arr, arrayofItemsToRemove)
: returns a new array after removing items that match the array of items to remove
1.0.0
2 years ago