1.0.1 • Published 2 years ago
@jeremydutton/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 @jeremydutton/lotide
Require it:
const _ = require('@jeremydutton/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(actual, expected): assert function to test function behavioureqArrays(array1, array2): takes in two arrays and compares them for equality, returning boolean valueassertArraysEqual(array1, array2): takes in two arrays, compares them for equality, and console logs the result as a boolean valuewithout(sourceArray, removalArray): returns a subset of a given array, removing unwanted elements.flatten(arrayToFlatten): accepts a two dimensional array and "flattens" to single dimension arraymiddle(array): accepts an array and returns it's middle element, as another arrayhead(array): retrieves the first element from the arraytail(array): returns every element except the first element, of an arraycountOnly(allItems, itemsToCount): takes in a collection of items (an object) and return counts for a specific subset of those itemscountLetters(sentence): takesin a string, counts the number of instances of each letter, and returns the count of each letter as a key-value pair in an objectletterPositions(sentence): returns all the indices (zero-based positions) in the string where each character is found. Return type is stringfindKeyByValue(object, value): takes in a object and value. Scans the object and returns the first key that has that value.eqObjects(object1, object2)): compares two objects and returns boolean valueassertObjectsEqual: compares two objects and prints a boolean value to the consolemap(array, callBack): takes in an array to map and a callback function. Returns new array based on the callback functiontakeUntil(array, callback): takes an array and a callback. It will return a slice of the array with elements taken from the beginning. It will keep going until the callback/predicate returns a truthy value.findKey(object, callback): takes in an array and a callback