1.0.0 • Published 2 years ago
@sofpan/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 @sofpan/lotide
Require it:
const _ = require('@sofpan/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
countLetters(string)
: Takes in a string and returns the total of each letter in that stringcountOnly(array, object)
: Takes an array of strings and an object of items to count, then returns the total for the specified subset of those itemseqArrays(array1, array2)
: compares two arrays for equalityeqObjects(object1, object2)
: compares two objects for equalityfindKey(object, callback)
: Takes two arguments, an object and a callback, then returns the first truthy key, or undefined if no key is foundfindKeyByValue(object, string)
: Takes in an object and a value and returns the matching keyflatten(array)
: Takes an array of mixed elements and nested arrays as argument and returns it as a single flattened arrayhead(array)
: Takes in an array and returns the first element of the arrayletterPositions(string)
: Takes in a string and returns the indexed positions of each occurrence of each letter in the stringmap(array, callback)
: Takes in an array and a callback function as arguments, applies the callback to each element of the array, then returns a new array with the resultsmiddle(array)
: Takes an array and returns the middle element(s) as a new arraytail(array)
: Takes an array and returns every element except the first onetakeUntil(array, callback)
: Takes an array and a callback and returns a new array with elements taken from the beginning until the callback condition is met, or the entire array if the condition is never metwithout(array1, array2)
: Takes two arrays and filters out the elements in the second array from the first array, then returns a new array
1.0.0
2 years ago