1.0.1 • Published 2 years ago
@leeseancw/lotide v1.0.1
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 @leeseancw/lotide
Require it:
const _ = require('@leeseancw/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: assertion function that compares 2 arraysassertEqual(actual, expected)
: assertion function that compares 2 primitivesassertObjectsEqual(obj1, obj2)
: assertion function that compares 2 objects (which are not arrays)countLetters(sentence)
: function that takes in a string and catalogues each instance of each unique charactercountOnly(allItems, itemsToCount)
: function that counts for specific elements listed in itemsToCount in allItemseqArrays(arr1, arr2)
: function that checks if 2 arrays are absolutely identicaleqObjects(object1, object2)
: function that checks if 2 objects (not arrays) are absolutely identicalfindKey(object, callback)
: function that scans the object and return the first key for which the callback returns a truthy value.findKeyByValue(obj, val)
: function that takes in an object and a value. It should scan the object and return the first key which contains the given value.flatten(arr)
: a duplicate function of the built-in .flat()head(arr)
: function that returns the first element of an arrayletterPosition(sentence)
: functoin that returns all the indices (zero-based positions) in the string where each character is found.map(array, callback)
: a duplicate function of the built-in .map()middle(arr)
: function that takes an array and returns the middle (or 2 middle) value in an arraytail(arr)
: function that returns an array without the first elementtakeUntil(array, callback)
: function that takes an array and returns a new array with elements up to when the callback function returns truthywithout(source, itemsToRemove)
: a similar function to the built-in .filter()