1.0.0 • Published 3 years ago
@hsharif/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 @hsharif
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: Returns the first element in an arraytail(array)
: Returns the last element in an arraymiddle(array)
: Returns the middle element of an array when array length is odd and midlle two elements when array length is evenassertArraysEqual(array1, array2)
: Assert test function console.logs() whether two arrays are equalassertEqual(actual, expected)
: Assert test function console.logs() whether two arguments are strict equalassertObjectsEqual(obj1, obj2)
: Assert test function console.logs() whether two objects are equalcountLetters(string)
: Returns the amount of letters in a stringeqArrays(array1, array2)
: Returns true if every element in array1 is equal to every element in array2eqObjects(obj1, obj2)
: Returns true if every key and value from object1 match object2findKey(obj, callback)
: Returns object key when given the object value passed into the callback functionfindKeyByValue(obj, value)
: Return object key when given obj and valueletterPositions(string)
: Returns an object with every letter in the string as keys and how many times that letter occurs in the string as valuesmap(array, callback)
: Works similar to .map() in js takes in an array and the callback function performs an action of each element of the array and returns the arraytakeUntil(array, callback)
: Takes in an array and returns array until value passed into callback functionwithout(source, itemsToRemove)
: Takes in an array and return new array with items to be removed
1.0.0
3 years ago