1.0.0 • Published 4 years ago
@rafh82/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 @RAFH82/lotide
Require it:
const _ = require('@RAFH82/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns the first item in an arraymiddle(array)
: returns middle item in an array of odd length, and the middle two items in an array of even lengthtail(array)
: returns the last item in an arrayassertArraysEqual(array1, array2)
: compares two arrays for strict equality and logs output msg to consoleeqArrays(array1, array2)
: returns boolean when comparing two arraysassertObjectsEqual(object1, object2)
: compares two objects for strict equality and logs output msg to consoleeqObjects(object1, object2)
: returns boolean when comparing two objectsmap(array, callback)
: applys a callback function on an array, returns a new arrayflatten(array)
: flattens an array of arrays to one level deep. returns a new arrayletterPositions(string)
: returns an object where the keys represent each letter of the string, and values are arrays representing the index of where those letters are located in the stringfindKeyByValue(obj, val)
: searches an object keys for a specific value, then returns that keyfindKey(object, callback)
: applys a callback function on every key of an object, and if it returns true, returns that keycountOnly(allItems, itemsToCount)
: iterates through an array (allItems) and counts the number of times an item exists in that array (itemsToCount) and returns an object of with the resultscountLetters(string)
: interates through a string, and retuns an object dispalying how many times each letter was foundtakeUntil(array, callback)
: iterates through an array and pushes each element to a new array until the callback function returns a true. returns the new arraywithout(source, itemsToRemove)
: iterates through an array and pushes each element that does not meet the specified criteria. returns new array
1.0.0
4 years ago