@drizztar/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 @drizztar/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Certainly! Here's the documentation for the functions you provided:
Documentation
The following functions are currently implemented:
assertArraysEqual(arr1, arr2)
: Compares two arraysarr1
andarr2
and asserts whether they are equal, printing a message to the console.assertEqual(actual, expected)
: Comparesactual
andexpected
values and asserts whether they are equal, printing a message to the console.assertObjectsEqual(obj1, obj2)
: Compares two objectsobj1
andobj2
and asserts whether they are equal, printing a message to the console.countLetters(str)
: Counts the occurrences of each letter in a given stringstr
and returns an object with letter counts.countOnly(allItems, itemsToCount)
: Counts the occurrences of specified items in an arrayallItems
based on the criteria specified initemsToCount
and returns an object with item counts.eqArrays(arr1, arr2)
: Compares two arraysarr1
andarr2
and returnstrue
if they are equal,false
otherwise.eqObjects(obj1, obj2)
: Compares two objectsobj1
andobj2
and returnstrue
if they are equal,false
otherwise.findKey(obj, callback)
: Searches for a key in an objectobj
based on the provided callback functioncallback
and returns the first key for which the callback returnstrue
.findKeyByValue(obj, value)
: Searches for a key with a specifiedvalue
in an objectobj
and returns the key if found, orundefined
if not found.flatten(arr)
: Flattens a nested arrayarr
and returns a flattened one-dimensional array.head(arr)
: Returns the first element of an arrayarr
.letterPositions(str)
: Returns an object with the positions of each letter in a given stringstr
.map(arr, callback)
: Applies a callback functioncallback
to each element in an arrayarr
and returns a new array with the results.middle(arr)
: Returns the middle element(s) of an arrayarr
.tail(arr)
: Returns a new array containing all elements of the input arrayarr
except for the first element.takeUntil(arr, callback)
: Returns a new array with elements from the beginning of the input arrayarr
until the callback functioncallback
returnstrue
.without(source, itemsToRemove)
: Returns a new array containing all elements from thesource
array except for those specified initemsToRemove
.
8 months ago