@najibmm/lotide
v1.0.1
Published
A shitty lodash clone
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 @najibmm/lotide
Require it:
const _ = require('@najibmm/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2): takes two arrays as arguments and asserts if they are equal or notassertEqual(val1, val2): takes two data types as arguments and asserts if they are strictly equal or notassertObjectsEqual(obj1, obj2): takes two objects as arguments and asserts if they are equal or notcountLetters(str): takes a string as an argument and returns an object containing each letter in the string and the number of times that letter appears in the stringcountOnly(arr, obj): takes an array and an object as arguments and returns an object containing counts of everything that the input object listedeqArrays(arr1, arr2): takes two arrays as arguments and determines if they are equal or noteqObjects(obj1, obj2): takes two objects as arguments and determines if they are equal or notfindKey(obj, cb): takes an object and a callback function as arguments and returns the key of the object that the callback function specifies needs to be foundfindKeyByValue(obj, val): takes an object and value as arguments and returns the first key of which the given value is found to be a value offlatten(arr): takes an array that may or may not contain more arrays as an argument and turns it into an array of values only with no arrays inside the overarching arrayhead(arr): takes an array as an argument and returns the first element in that arrayletterPositions(str): takes a string of characters as arguments, removes the spaces, and returns an object containing the letters as keys and their index positions as arrays of valuesmap(arr, cb): takes an array and a callback function as arguments and returns an array containing the elements of the original array with the callback function applied to each elementmiddle(arr): takes an array as an argument and returns the middle element. If the array has an even length, returns the middle two elementstail(arr): takes an array and returns the array without its first elementtakeUntil(arr, cb): takes an array and a callback function as arguments and returns a sliced version of the array that stops depending on the specified callbackwithout(arr1, arr2): takes a source array and an item removal array as arguments and returns the source array without any of the items from the item removal array
