1.0.1 • Published 5 years ago
@raficelkouche/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 @raficelkouche/lotide
Require it:
const _ = require('@raficelkouche/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(actual, expected): checks whether 2 variables of a primitive data type are equal or not, returns a booleanassertArraysEqual(actual,expected): checks whether 2 arrays are equal, returns a booleanassertObjectEqual(actual,expected): checks whether 2 objects are equal, returns a booleancountLetters(string): counts the number of letters in a string (excluding white space)countOnly(allItems, itemsToCount): takes in a collection of items and returns a count for a specific subseteqArrays(arrayA, arrayB): compares two arrays and returns true if they are equal, otherwise falseeqObjects(objA, objB): compares two objects and returns true if they are equal, otherwise falsefindKey(object,callback): returns the first key in which the callback function returns a truthy valuefindKeyByValue(object, value): looks for a value in a given object, returns the key where that property exists otherwise returns undefinedflatten(array): takens in an array of elements (maximum 1 level nesting) and spreads out all the elementshead(array): returns the first element of an arrayletterPositions(sentence): given a sentence, returns an object with the locations of all the occurrences of all the lettersmap(array,callback): calls the callback function on every element in an array and returns a new arraymiddle(array): given an array, returns the middle element. If the array length is odd, returns a single element, otherwise returns an array with 2 elementstail(array): returns an array with all the elements of an input except for the first element.takeUntil(array, callback): keeps collecting items from a provided array until the callback provided returns a truthy value.without(array,arrayOfItemsToRemove): returns an array that contains all the elements that are not part of the arrayOfItemsToRemove array