1.0.0 • Published 4 years ago
@mdever/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:
head,: returns the first element of a given arraytail,: returns everything except the first element of a given arraymiddle,: returns the middle element(s) of an array. One element if the array has an odd number of elements and two elements if the array has an even number of elementsassertArraysEqual,: takes in an actual and expected array and prints to the console whether or not they are equalassertObjectsEqual,: takes in an actual and expected object and prints to the console whether or not they are equalcountLetters,: takes a string and counts how many of each charcter are in the string and outputs the result as an objectcountOnly,: counts items in an array and returns an object with the number of each itemeqArrays,: compares arrays for an exact matcheqObjects,: compares objects for an exact matchfindKey,: function that searches an object and return the first key that returns a truthy value from the callback function passed to itfindKeyByValue,: takes in an object and a value and returns the first key in the object with that valueletterPositions,: takes a string and gets the index of each instance of each letter and returns an object containing arrays of the index positonsmap,: takes an array and a callback function and returns a new array based on the callback functiontakeUntil,: takes an array and a callback function and will return values in an array until the callback function returns truewithout: removes unwanted elements from an array
1.0.0
4 years ago