1.0.0 • Published 6 years ago
@alyssalrd/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 @alyssalrd/lotide
Require it:
const _ = require('@alyssalrd/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: returns the first element in an arraytail(...)
: takes off the head of array and returns the restmiddle(...)
: returns value in the middle of array- assertArraysEqual(...) : take in two arrays and console.log an appropriate message to the console.
- assertEqual(...) : Prints "ASSERTION PASSED" or "ASSERTION FAILED" based on if results is true or false
- eqObjects(...): takes in two objects and returns true or false, based on a perfect match.
- assertObjectEqual(...) : which will take in two objects and console.log an appropriate message to the console.
- eqArrays(...) : takes in two arrays and returns true or false, based on a perfect match.
- countLetters(...) : takes in a string and returns an object with each letter that appears as a key and the number of times it appears in the string as a value.
- countOnly(...) : take in a collection of items and return counts for a specific subset of those items
- findKey(...) : which takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined.
- findKeyByValue(...) : takes in an object and a value. It should scan the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.
- flatten(...) : take in an array of arrays and return a "flattened" version of the array.
- letterPositions,
- map(...) : take in two arguments: an array to map + callback function. The map function will return a new array based on the results of the callback function.
- takeUntil(...) : return a "slice of the array with elements taken from the beginning." It should keep going until the callback/predicate returns a truthy value.
- without(...) : takes in a source array and a itemsToRemove array. Returns a new array with only those elements from source that are not present in the itemsToRemove array.
1.0.0
6 years ago