1.0.0 • Published 4 years ago
@robotsch/lotide v1.0.0
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 @username/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
map(arr, cb): Execute callback function on every element of a given arrayhead(arr): Return the first value of a given arraytail(arr): Return the given array with the first element removedmiddle(arr): Return the middle element(s) of an arrayflatten(arr): Returns a flattened array up to depth 2without(srcArr, rmArr): Return the source array with any elements of the second array removedtakeUntil(arr, cb): Returns an array of values from a given array starting from index 0 until a given callback function returns truecountOnly(arr, obj): Returns a count object of array elements that have truthy values in a given objectfindKey(obj, cb): Returns the first property whos value matches a given callback functioncountLetters(string): Returns an object which contains letter counts of a provided stringfindKeyByValue(obj, val): Returns the first property of an object whos value matches a provided valueletterPositions(string): Returns an object which contains the index of every character in a given stringeqArrays(arr1, arr2): Returns true if both arrays are equal, false if noteqObjects(obj1, obj2): Returns true if both objects are equal, false if notassertEqual(a, b): Displays equality assertion messages in terminal for two primitivesassertArraysEqual(arr1, arr2): Displays array equality essertion messages in terminal for two given arraysassertObjectsEqual(obj1, obj2): Displays object equality essertion messages in terminal for two given objects
1.0.0
4 years ago