1.0.0 • Published 4 years ago
@georgecctang/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 @georgecctang/lotide
Require it:
const _ = require('@georgecctang/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(expected, actual)
: Prints the result of a strict comparison between two values of primitive data types.head(array)
: Returns the first element of anarray
.tail(array)
: Returns an array consisting of all but the first element of thearray
.eqArrays(array1, array2)
: Performs a deep comparison between two arrays.assertArraysEqual(array1, array2)
: Prints the result of a deep comparison between two arrays.without(source, itemsToRemove)
: Returns an array consisting of all elements in thesource
array except for those included in theitemsToRemove
array.flatten(array)
: Convert a nestedarray
into an unnested array.middle(array)
: Returns the middle element(s) of anarray
.countOnly(allItems, itemsToCount)
: Counts the occurence of each element in theallItems
array that is a key in theitemsToCount
object and has a value of true.countLetters(string)
: Counts the occurrence of each character in astring
.letterPositions(string)
: Returns the position(s) of each character in astring
.findKeyByValue(object, value)
: Returns the first key of anobject
that has a value equal tovalue
.eqObjects(object1, object2)
: Performs deep comparsion between two objects.assertObjectsEqual(object1, object2)
: Prints the result of a deep comparison between two objects.map(array, callback)
: Returns an array with thecallback
function applied to each element of anarray
.takeUntil(array, callback)
: Returns a slice of anarray
with elements taken from the beginning, untilcallback
function returns a truthy value.findKey(object, callback)
: Returns the first key of anobject
for which thecallback
returns a truthy value.
1.0.0
4 years ago