1.0.1 • Published 5 years ago
@quinnvoker/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 @quinnvoker/lotide
Require it:
const _ = require('@quinnvoker/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actual, expected): asserts that given arrays are equal, and prints pass or fail to command lineassertEqual(actual, expected): asserts that given primitive values are equal, and prints pass or fail to command lineassertObjectsEqual(actual, expected): asserts that given objects are equal, and prints pass or fail to command linecountLetters(string): returns an object containing all characters which appear in the string, along with how many times they appearcountOnly(allItems, itemsToCount): takes an arrayallItemsand an arrayitemsToCountand returns an object containing the count of times each item appears in the main arrayeqArrays(arrayA, arrayB): returnstrueif both arrays contain the same data,falseotherwise. can work with nested arrayseqObjects(objectA, objectB): returnstrueif both objects have the same properties and values,falseotherwise. can handle nested objectsfindKey(object, callback): runscallbackon each property of the object, and returns the first key in whichcallbackreturnstrue.findKeyByValue(object, value): returns key of first property ofobjectwhich has a value ofvalueflatten(array): takes a nested array and returns an array that has no nesting, but retains all elements in orderhead(array): returns the first element of a given arrayletterPositions(string): returns an object with all the characters that appear instringas keys, and an array of the indices in the string in which they appear as valuesmap(array, callback): callscallbackfor each element ofarray, and returns a new array containing the resultsmiddle(array): returns the middle element of a given arraytail(array): takes an array and returns a new array without the first elementtakeUntil(array, callback): takes an array, runscallbackon each element, and returns an array containing all of the elements up until the first point at whichcallbackreturnedtruewithout(array, items): takes an array, and returns a copy of it with all of the elements ofitemsremoved from it