1.1.0 • Published 4 years ago
@forgehe/lotide v1.1.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 @forgehe/lotide
Require it:
const _ = require('@forgehe/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(...)
: given two arrays, prints in console.log if the two arrays are equalassertEqual(...)
: given two primitive data types, prints in console.log if two primitive data types are equalassertObjectsEqual(...)
: given two objects prints in console.log if two objects are equalcountLetters(...)
: returns an object with key of each letter that appears in a string, with a value of how many times that letter appeared in the stringcountOnly(...)
: given an array of strings and an object of keys to check, returns an object with values of how many times the keys appears in the arrayeqArrays(...)
: given two arrays, return a boolean if they are equaleqObjects(...)
: given two objects, return a boolean if they are equalfindKey(...)
: given a object and a callback, returns the first key that returns truthy in the callbackfindKeyByValue(...)
: given an object and a string, return the first key where the value is storedflatten(...)
: given an array with nested arrays, return an array with the first layer of nest arrays moved to the main arrayhead(...)
: given an array, return the first element of the arrayletterPositions(...)
: given a string, return an object listing each letter as a key with the value as the index where each letter is found. Does not work well with strings with multiples of the same lettermap(...)
: given an array and a callback, return a new array with the elements transformed by the callback functionmiddle(...)
: given an array, returns an array of the middle element of the array. If it is an array of even length, returns an array with the two middle elements of the array.takeUntil(...)
: given an array and a string, return a new array with the elements of the array before the given stringtail(...)
: given an array, returns a new array without the first element of the given arraywithout(...)
: given two arrays, returns a new array with the elements of the first array that don't match with any element from the second array