1.0.0 • Published 5 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 thesourcearray except for those included in theitemsToRemovearray.flatten(array): Convert a nestedarrayinto an unnested array.middle(array): Returns the middle element(s) of anarray.countOnly(allItems, itemsToCount): Counts the occurence of each element in theallItemsarray that is a key in theitemsToCountobject 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 anobjectthat 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 thecallbackfunction applied to each element of anarray.takeUntil(array, callback): Returns a slice of anarraywith elements taken from the beginning, untilcallbackfunction returns a truthy value.findKey(object, callback): Returns the first key of anobjectfor which thecallbackreturns a truthy value.
1.0.0
5 years ago