1.0.1 • Published 4 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 arrayallItems
and an arrayitemsToCount
and returns an object containing the count of times each item appears in the main arrayeqArrays(arrayA, arrayB)
: returnstrue
if both arrays contain the same data,false
otherwise. can work with nested arrayseqObjects(objectA, objectB)
: returnstrue
if both objects have the same properties and values,false
otherwise. can handle nested objectsfindKey(object, callback)
: runscallback
on each property of the object, and returns the first key in whichcallback
returnstrue
.findKeyByValue(object, value)
: returns key of first property ofobject
which has a value ofvalue
flatten(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 instring
as keys, and an array of the indices in the string in which they appear as valuesmap(array, callback)
: callscallback
for 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, runscallback
on each element, and returns an array containing all of the elements up until the first point at whichcallback
returnedtrue
without(array, items)
: takes an array, and returns a copy of it with all of the elements ofitems
removed from it