1.0.2 • Published 3 years ago
@eric-yhf/lotide v1.0.2
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 @eric-yhf/lotide
Require it:
const _ = require('@eric-yhf/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr): Return first item of a given arraytail(arr): Return all item in except the head of a given arraymiddle: Return the middle-most item of a given arrayassertArraysEqual(firstArr, secArr): Write message to console if assertion (array) pass or failassertEqual(actual, expected): Write message to console if assertion (primitive type) pass or failassertObjectsEqualfunction(object1, object2): Write message to console if assertion (Object) pass or failcountLetters(str): Count occurance of each letter in a given stringcountOnly(allItems, itemsToCount): Given a list of item, return counts for a specific subset of those itemseqArrays(arr1, arr2): Compare two arrays, return true if equal else falseeqObjects(object1, object2): Compare two objects, return true if equal, else falsefindKey(object, callback): Scan given object and return the first key for which the callback returns a truthy value. Return undefined if no key is foundfindKeyByValue(object, value): Given an object, return the first key which contains the given value, return undefined if not foundflatten(arr): Flatten nested arraysletterPositions(sentence): Return all the indices in the string where each character is foundmap(array, callback): Take in an array and a callback function,return a new array based on the results of the callback functiontakeUntil(array, callback): Return a slice of the array, with elements taken from the beginning, until callback condition meetswithout(source, itemsToRemove): Remove target(s) from a given array