1.0.0 • Published 3 years ago
@fatslabb/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 @fatslabb/lotide
Require it:
const _ = require('@fatslabb/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
_.assertArraysEqual(actual, expected)- Tests if two object arrays are equal and logs true or false.
_.assertEqual(actual, expected)- Tests if two values are equal and logs true or false.
_.assertObjectsEqual(actual, expected)- Compares the value of two objects and logs true or false.
_.countLetters(string)- Takes a stringand returns the number of ocurrences of each character.
_.countOnly(allItems, itemsToCount)- allItemstakes an array of strings and returns an object with a count for each true value in- itemsToCount.
_.eqArrays(array1, array2)- compares if two arrays are indentical and returns true or false.
._findKey(object, (item) => {})
._findKey(object, callbackFn)
._findKey(object, function(item){})- searches an objectusing acallbackFnand returns the first key oncecallbackFnreturns a truthy value.
_.findKeyByValue(object, value)- searches an objectand returns first key which contains the givenvalue
_.flatten(array)- takes in an arrayof arrays and returns a new one-dimensional array.
._head(array)- takes an arrayand returns the element from the first index
._letterPositions(string)- takes a stringand returns an object of characters with values set to their indices of occurance(s) in thestring.
._map(array, (item) => {})
._map(array, callbackFn)
._map(array, function(item){})- takes in an arrayand return new array with each element modified by thecallbackFn.
._middle(array)- changes the contents of the arrayand returns only the element(s) its center.
._tail(array)- removes the first element of the arrayand return a shallow copy.
.takeUntil(array, (item) => {})
.takeUntil(array, callbackFn)
.takeUntil(array, function(item){})- return a slice of the beginning of an arrayand stops once thecallbackFnreturns a truthy value.
._without(array, itemRemoved)- return a shallow copy of the arraywith the array item from theitemRemovedfiltered out.
1.0.0
3 years ago