1.0.0 • Published 1 year ago
@mcl2s/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 @mcl2s/lotide
Require it:
const _ = require('@mcl2s/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual(array1, array2)
: Given two arrays, logs whether the two arrays are equal or not (used for simple testing)assertEqual(any, any)
: Given two items, logs whether they are equal or not (used for simple testing of primitives)assertObjectsEqual(object1, object2)
: Given two objects, logs whether they are equal or not (used for simple testing)countLetters(string)
: Returns a count of each of the letters contained in a stringcountOnly(array, object)
: Given an list of items, and an object specifying the items to count (keys with a bool value true), returns an object showing the results of the counteqArrays(array1, array2)
: Given two arrays, returns true if they are equal, false otherwiseeqObjects(object1, object2)
: Given two objects, returns true if they are equal, false otherwisefindKey(object, callback)
: Given an object and a callback function, returns the first key contained in the object that makes the callback function truthyfindKeyByValue(object, value)
: Given an object and a value, returns the first key with the specified valueflatten(array)
: Given a nested array (1 level), returns a flattened arrayhead(array)
: Given an array, returns the first itemletterPositions(string)
: Given a string, returns the positions of each letter in the string in an object where they keys are the letters, and the values are arrays of the indicies of each letter positionmap(array, callback)
: Given an array and callback function, returns a new array with the callback function applied to each item in the given arraymiddle(array)
: Given an array, returns an array of the middle items in the array (middle array length of 1 for odd sized arrays, 2 for even)tail(array)
: Given an array, returns a copy of the array without the first elementtakeUntil(array, callback)
: Given an array and callback function, returns an array of the elements up until the first element that makes the callback function truthywithout(sourceArray, itemsToRemoveArray)
: Given two arrays: the first being the source array, the second containing the items to be removed from the first, returns a new array with the specified elements removed from the first array.
1.0.0
1 year ago