1.0.0 • Published 1 year ago
@thien-trieu/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 @username/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: Returns first element of anarray
.tail(...)
: Returns a newarray
of all elements except for the first element.middle(...)
: Returns a newarray
with the middle element(s) of an array. If no middle, then and empty array is returned.countOnly(...)
: Returns a new object with the sum of each element found true fromitemsToCount
inallitems
.countLetter(...)
: Returns a new object with the sum of each letter from astring
.without(...)
: Returns a new array with only the elements fromsource
that are not present in theitemsToRemove
array.findKey(...)
: Returns the first key that matchescallback
for aninput
object. If no matches found,undefined
is returned.findKeyByValue(...)
: Returns key of anobject
by searching for a matchingvalue
. If no matches found,undefined
is returned.letterPosition(...)
: Returns an object with the sum of each letter from astring
.map(...)
: Returns a newarray
with the elements that return a truthy value from thecallback
.takeUntil(...)
: Returns a new array with elements taken from the beginning until thecallback
returns atruthy
valueassertEqual(...)
: Returns a pass or fail console.log if assertion equals true or false when comparing the values of two primitives usingactual
andexpected
.eqArrays(...)
: Returns a true or false value when comparing if the values of two arrays are equal.assertArraysEqual(...)
: Returns a pass or fail console.log if assertion equals true or false when comparing the values of two arrays.eqObjects(...)
: Returns a true or false value when comparing if the values of two objects are equal.assertObjectsEqual(...)
: Returns a pass or fail console.log if assertion equals true or false when comparing the values of two objects.
1.0.0
1 year ago