1.0.0 • Published 4 years ago
@sayantan2512/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 @sayantan2512/lotide
Require it:
const _ = require('@sayantan2512/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: it takes in two arrays and prints an appropriate message to the console.assertEqual
: checks if both input and output have a perfect match.head
: returns the element in 0th index of the given array.tail
: returns the rest of the array after removing the 0th index element.middle
: returns the middle element of an array.map
: it will return a new array based on the results of the callback function.min
: returns the lowest number in an array.sum
: it take node arguments and returns thier sum.assertObjectsEqual
: detects that two objects are equal.countLetters
: returns a count of each of the letters in that sentence.countOnly
: it takes in an array and an object & return an object containing counts of everything that the input object listed.eqArrays
: it takes in two arrays and returns true or false, based on a perfect match.eqObjects
: it takes in two objects and returns true or false, based on a perfect match.findKey
: it takes in an object and a callback func and returns the first key for which the callback returns a truthy value. If no key is found, then it returns undefined.findKeyByValue
: it takes in an object and a value and returns the key for that value.flatten
: it takes in an array containing elements including nested arrays of elements, and returns a "flattened" version of the array.letterPositions
: returns all the indices (zero-based positions) in the string where each character is found.takeUntil
: returns a "slice of the array with elements taken from the beginning."without
: return a new array with only those elements from source that are not present in the itemsToRemove array.
1.0.0
4 years ago