1.0.1 • Published 5 years ago
@idrking/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 @idrking/lotide
Require it:
const _ = require('@idrking/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(actualArray, expectedArray): Function that logs a string to the console based on the results of comparing two arrays (supports nested arrays)assertEqual(actual, expected): Function that logs a string to the console based on the results of comparing two non-array / non-object valuesassertObjectsEqual(actualObject, expectedObject): Function that logs a string to the console based on the results of comparing two objects (supports nested objects)countLetters(string): Function that returns an object with a count of each non-space character in a stringcountOnly(array, valuesToOmit): Function that returns an object with a count of each value in an array except any value specified in the valuesToOmit arrayeqArrays(arrayOne, arrayTwo): Function that compares two arrays and returns true if they match, false otherwise. Supports nested arrayseqObjects(objectOne, objectTwo): Function that compares two objects and returns true if they match, false otherwise. Supports nested objectsfindKey(object, callback): Function that takes in an object and a callback, executes the callback on each value in the array and then returns the corresponding key for the first value to return truefindKeyByValue(object, value)" Function that takes in an object and any other value, and returns the first key that corresponds to that valueflatten(array): Function that takes in an array and flattens it, taking nested arrays and adding their values in place to the return array.head(array): Function that returns the first element in an arrayletterPositions(string): Function that takes a string and returns an object with all the indices that each non-space character can be found at, as an objectmap(array, callback): Function that takes in an array and a callback function and returns an array populated with the results of calling the callback on each element of the arraymiddle(array): Function that takes in an array and returns the middle element (if odd length) or middle two (if even) elements of an arraytail(array): Function that returns an array with all elements of the original array except the firsttakeUntil(array, callback): Function that takes in an array and a callback, and executes the callback on each item, returning all values up until the first value on which the callback returns truewithout(array, itemsToRemove): Function that takes in two arrays, and returns a copy of the first array after removed all instances of any element found in the itemsToRemove array