1.0.0 • Published 1 year ago
@robbydhindsa/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 @robbydhindsa/lotide
Require it:
const _ = require('@robbydhindsa/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actual, expected)
: takes in two arrays as parameters and useseqArrays
function to validate if the two arrays are equal to each otherassertEqual(actual, expected)
: takes in two values as parameters and validates if the two values are equal to each other (uses '===')assertObjectsEqual(actual, expected)
: takes in two objects as parameters and useseqObjects
andeqArrays
functions to validate if two objects have the exact same key:value pairscountLetters(sentence)
: takes in a string as a parameter and counts the number of times each character is used in the provided stringcountOnly(allItems, itemsToCount)
: takes in an array of strings (allItems) and an object specifying what to count (itemsToCount); returns the number of occurences of a particular string in allItems parametereqArrays(array1, array2)
: returns a boolean value based on whether array1 and array2 are exactly equivalenteqObjects(object1, object2)
: returns a boolean value based on whether object1 and object2 are exactly equivalentfindKey(obj, callback)
: takes in an object and a callback function as parameters; returns a particular key of the object, based on the callback functionfindKeyByValue(obj, val)
: takes in an object and a value as parameters; returns the specific key of the object (obj) that is equal to the value passed (val)head(arr)
: returns the first element of an arrayletterPositions(sentence)
: returns the index value of a particular character in a stringmap(array, callback)
: alters thearray
parameter based on the passed callback and returns the resultmiddle(arr)
: returns the middle element(s) of an arraytail(arr)
: returns all the elements of an array except for index 0takeUntil(array, callback)
: returns the elements of an array until the value of the callback is equivalent to an array, at which point it stops and returns that specific portion of the arraywithout(source, itemsToRemove)
: removes specific elements of the array that is passed and returns the resulting array
1.0.0
1 year ago