@sabiat/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 @sabiat/lotide
Require it:
const _ = require('@sabiat/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: returns the first element of an arraytail(array)
: returns the end of an array excluding the first elementmiddle(array)
: returns the middle-most element of a given arraymap(array, callback)
: returns a new array with the results of performsing a callback function on each element of array passed to itletterPositions(sentence)
: takes in a string and returns all indices in the string where each character is foundfindKey(object, callback)
: scans a given object and returns the first key for which a given callback returns a truthy valuecountOnly(allItems, itemToCount)
: takes in a array of items and returns a count for a specific subset of items specified with a given objectcountLetters(sentence)
: takes in a string and returns a count of each of the letters in the stringwithout(source, itemsToRemove)
: takes in a source array and itemsToRemove array and returns a filtered source array without any element from the itemsToRemove arraytakeUntil(array, callback)
: takes in an array and returns a slice of the array with callback function performed on each element from the beginning until callback function returns truthy valuefindKeyByValue(objectToScan, valueToFind)
: takes in an object to scan and returns the first key which matches a given valueassertEqual(actual, expected)
: logs message to console stating if actual is equal to expectedassertArraysEqual(arr1, arr2)
: logs message to console stating if 2 arrays are equalassertObjectsEqual(actual, expected)
: logs message to console stating if 2 objects are equaleqArrays(arr1, arr2)
: checks if given arrays are equal and returns booleaneqObjects(object1, object2)
: checks if given objects are equal and returns boolean
3 years ago