A mini clone of the Lodash library.
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 Chelsea Dwarika/@chchchelsay as part of my learnings at Lighthouse Labs.
Install it:
npm install @chchchelsay/lotide
Require it:
const _ = require('@chchchelsay/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
-
Clone this github repository:
git clone git@github.com:chchchelsay/lotide.git
-
npm init
-
npm install --save-dev mocha@9.2.2 chai
-
update package.json file to say "scripts": {
"test": "mocha"
} -
npm test
to test all files with mocha/chai tests available -
npm test test/headTest.js
to test a specific file (in this case the head.js function)
The following functions are currently implemented:
assertArraysEqual()
: compares two arrays and logs assertion message to consoleassertEqual()
: compares two values and logs assertion message to consoleassertObjectsEqual()
: compares two objects and logs assertion message to consolecountLetters()
: takes in string and returns count of each letter occurrence in stringcountOnly()
: takes in array & input object; returns new object with counts of everything listed by input objecteqArrays()
: compares two arrays and returns true/false based on a perfect matcheqObjects()
: compares two objects and returns true/false based on a perfect matchfindKey()
: takes in object & callback; returns first key in object that matches callback ===/else undefinedfindKeyByValue()
: takes in object & value; looks through object and returns first key that matches value/ else undefinedflatten()
: 'flattens' an array that contains nested arrays of elements into a new un-nested onehead()
: returns first item in an arrayletterPositions()
: returns indices for where each character is found in a stringmap()
: takes in array & callback function; returns new array based on callback function resultstail()
: returns everything BUT the first item/head in an arraytakeUntil()
: takes in array and callback function; returns slice of array elements until callback function evaluates to true.middle()
: returns middle-most element(s) of an arraywithout()
: returns subset of given array without specified unwanted elements