1.0.0 • Published 4 years ago
@jjung219/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 @jjung219/lotide
Require it:
const _ = require('@jjung219/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
countLetters(sentence)
: take in a sentence as a string and then return a count of each of the letters in that sentence as an objectcountOnly(allItems, itemsToCount)
: take in a collection of items and return counts for a specific subset of those itemseqArrays(arr1, arr2)
: compares the length and values of the two arrays and returns true or falseeqObjects(obj1, obj2)
: compares the values of the two objects and returns true or falsefindKey(obj, callback)
: takes in an object and a callback. Scans the object and return the first key for which the callback returns a truthy value. Returns undefined when no key is foundfindKeyByValue(obj, value)
: takes in an object and the value you're looking for. Returns the object key that has the value.flatten(arr)
: takes in an array and if the array has arrays within the array, function takes all the elements out of the array and returns as just one array with all the elements.head(arr)
: takes in an array and returns the first element of the arrayletterPoisitions(str)
: takes in a string and returns an object with letters as keys and index positions of the letters as values as an arraymiddle(arr)
: takes in an array and returns middle element(s). If there is only one element, it returns an empty arraytail(arr)
: takes in an array and retuns an array with all the elements except for the first elementtakeUntil(arr, callback)
: The function will return a "slice of the array with elements taken from the beginning." It should keep going until the callback/predicate returns a truthy valuewithout(sourceArr, itemsToRemove)
: take in a source array and a itemsToRemove array. It should return a new array with only those elements from source that are not present in the itemsToRemove array
1.0.0
4 years ago