1.0.0 • Published 3 years ago
@tripeee/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 @tripeee/lotide
Require it:
const _ = require('@tripeee/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array): returns the first element of an arraytail(array) :returns the last element of an arraymiddle(array): returns a single middle element of an array if the array length is odd, and the two middle element of an array of the length is evenassertArraysEqual(array1, array2): verifies that the two passed arrays are equal in both length and valueassertEqual(actual, expected): verifies that the two values passed are identicalassertObjectsEqual(actualObject, expectedObject): verifies that the two passed objects are identicalcountLetters(str: checks the frequency of letters in a string and pushes those values into an objectcountOnly(allItems, itemsToCount):checks the frequency of certain values in an array, with itemsToCount being an object whose values have boolean values. Only counts those keys that have true values.eqArrays(array1, array2): prints an assertion to the console whether two arrays are equal or noteqObjects(object1, object2): checks whether or not two objects are equalfindKey(obj, callback): scans the object and returns the first key for which the callback returns a truthy value.findKeyByValue(obj, str): scans the object and returns the first key which contains the given value. If no key with that given value is found, then it will return undefined.flatten(arr): takes in an array containing elements including nested arrays of elements, and returns a "flattened" version of the arrayletterPositions(string): returns all the indices (zero-based positions) in the string where each character is foundmap(array, callback): will loop through an array and return a new array with all callback items of the initial arraytakeUntil(array, callback): The function will return a slice of the array with elements taken from the beginning until it hits the callback, which will be a value in the arraytouchOnly(allItems, itemsToCount): will report back how many instances of each string were found in the allItems array of strings.without(source, itemsToRemove): will return a new array with only those elements from source that are not present in the itemsToRemove array.
1.0.0
3 years ago