1.0.0 • Published 3 years ago
@cthu97/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 @cthu97/lotide
Require it:
const _ = require('@cthu97/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head
: returns beginning of an arraymiddle
: returns middle of an arraytail
: returns end of an arrayassertEqual
: compare the two values it takes in and print out a message telling us if they match or notassertArraysEqual
: asserts that two arrays are equalassertObjectEqual
: asserts that two objects are equalcountLetters
: counts number of times letter comes up in a stringcountOnly
: only counts the elements in array that it is told to counteqArray
: takes two arrays and returns true if they are equaleqObject
: takes two objects and returns true if they are equalfindKey
: takes an object and a callback function, finds the key using value of keyfindKeyByValue
: search for a key on an object where its value matches a given valueflatten
: takes an array or nested array and flatten it into one arrayletterPositions
: takes a string and tells us the indices of where each letter ismap
: takes in an array to map and a callback function, then will return a new array based on the results of the callback functiontakeUntil
: takes in an array and a callback function, will return a slice of the array with elements taken from beginning until callback returns a truthy valuewithout
: returns a subset of a given array, removing unwanted elements.
1.0.0
3 years ago