1.0.1 • Published 2 years ago
@cjm1994/lotide v1.0.1
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 @cjm1994/lotide
Require it:
const _ = require('@cjm1994/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: Returns the item in the first index of an arraymiddle(array)
: Returns the middle value(s) of an array, returns an empty array if two or less valuestail(array)
: Returns the tail of an arraycountLetters(string)
: Returns an object with a count of each letter in a stringcountOnly(array, {string/integer : boolean})
: Counts instances of primitive values taken from the key of the object argument, will count keys given the value of true and skip keys given the value falseeqArrays(array1, array2)
: Compares each item in two arrays strictly at each index and returns true if they match and false if an index does not matcheqObjects(object1, object2)
: Compares two objects at each key, if any keys do not strictly match or if number of keys differ returns false. If they match returns true, checks arrays withing objects with assertArraysEqualfindKey(object, callback)
: Calls a function on each key in an objectfindKeyByValue(object, value)
: Returns the first key in an object with a given valueflatten(array)
: Flattens an array that contains arrays, only goes 1 array deepletterPositions(string)
: Returns an object with each character in a string as the key and an array with all indexs of that character as the valuemap(array, callback)
: Calls a callback function on each element in an array and returns a new array with the resulttakeUntil(array, callback)
: Calls a function on each element in an array until the callback returns true, will return the first element where a callback returns truewithout(array1, array2)
: Takes array1 as an argument and returns a new array with all elements contained in array2 removed