1.0.2 • Published 5 years ago
@ncolusso/lotide v1.0.2
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 @ncolusso/lotide
Require it:
const _ = require('@ncolusso/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: with help of eqArrays function will log to the console a message whether or not two arrays are equalasserEqual
: logs a message to the console whether or not two values are equalassertObjectsEqual
: with help of eqObjects logs a message to the console whether or not two objects are equalcountLetters
: counts how many letters are in a given string (less spaces)countOnly
: counts how many times a specific value shows up in an array of stringseqArrays
: compares two arrays and returns whether or not they are strictly equaleqObjects
: compares two objects and returns whether or not they are equalfindKey
: takes in an object and a callback and return the first key for which the callback returns a truthy value. If no key is found, returns undefinedfindKeyByValue
: with a given value returns the first key where this value is found, if not undefinedflatten
: takes in an array with nested arrays, and returns a flattened arrayhead
: takes in an array and returns the first value of an array, if the array is empty returns undefinedletterPositions
: takes in a string and returns all the indices where each character is found (less spaces)map
: takes in an array and callback and implement callback on the given arraymiddle
: takes in an array and returns the value at the middle index. If it is even, returns middle 2 valuestail
: takes in an array and returns the array less the first valuetakeUntil
: takes in an array and callback and returns a slice of the array with elements taken from the beginning, until the callback returns a truthy valuewithout
: takes in two arrays and will return the first array less any values in the second