1.0.0 • Published 4 years ago
@schenn1992/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 @schenn1992/lotide
Require it:
const _ = require('@schenn1992/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: return the first element of the arraytail(arr)
: return everything except for the first element in the arraymiddle(arr)
: return an array with only the middle element(s) of the provided arraywithout(source, itemsToRemove)
: return a new array with only those elements from source that are not present in the itemsToRemove arraytakeUntil(array, callback)
: keep collecting items from a given array until the given callback returns a truthy valueletterPositions(sentences)
: take in a sentence as argument and return all the indices in the string where each character is foundfindKeyByValue(objectToTest, valueToFind)
:findKey(objectToTest, callback)
: takes in an object and a callback function as arguments. return the first key for which the callback returns a truthy value. If no key can be found, return undefinedmap(array, callback)
: takes in array and a callback function as arguments. Return a new array based on the results of callback funcitoncountLetters(sentences)
: take in a sentence(string) as an argument and return a count of each of the letters in the given sentencecountOnly(allItems, itemsToCount)
: return an object containing counts of everything that the input object listedeqArrays(arrA, arrB)
: take in two arrays as arguments and returns whether true or false based on the result. True if match, vice versaeqObjects(object1, object2)
: take in two objects as arguments and returns whether true or false based on the result. True if match, vice versaassertObjectsEqual(actual, expected)
: compare two objects it takes in and print out a message telling us if they match or notassertEqual(actual, expected)
: compare two primitive values it takes in and print out a message telling us if they match or notassertArraysEqual(actual, expected)
: compare two arrays it takes in and print out a message telling us if they match or not
1.0.0
4 years ago