1.0.1 • Published 3 years ago
@aarijanwer/lotide v1.0.1
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 @aarijanwer/lotide
Require it:
const _ = require('@aarijanwer/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array): returnsarray[0]as the headtail(array): returns all itmes after the head ofarrayas an arraymiddle(array): returns the middle ofarray(one item if odd, two items if even, none ifarray.length <=2)assertArraysEqual(actual, expected): assert function checking if arraysactual===expected, doesn't return only prints to console.logassertEqual(actual, expected): assert function checking if primitive data typesactual===expected, doesn't return only prints to console.logassertObjectsEqual(actual, expected): assert function checking if objectsactual===expected, doesn't return only prints to console.logcountLetters(phrase): return an object that enumerates each letter of the stringphrasecountOnly(allItems, itemsToCount): given an arrayallItemsand an objectitemsToCount, it will return an object containing counts of everything that the input object listed.eqArrays(array1, array2): returns true ifarray1andarray2have the exact same contents and same lengtheqObjects(object1, object2): returns true ifobject1andobject2have the exact same key-value pairsfindKey(object, callback): scansobjectand returns the first key for whichcallbackreturns a truthy value. If no key is found, returnsundefined.findKeyByValue((obj, value): searches for a key on an object where its value matches a given valueflatten(array): takesarraywith other arrays inside and returns a single-level arrayletterPositions(sentence): returns all the indices (zero-based positions) in the string where each character is foundmap(array, callback): returns a new array based on the results of the callback functiontakeUntil(array, callback): returns a slice of the array with elements taken from the beginningwithout(array1, array2): returns a subsetarray1, removing from it the elements fromarray2.