1.0.1 • Published 4 years ago
@daniel_cy_lu/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 @daniel_cy_lu/lotide
Require it:
const _ = require('@daniel_cy_lu/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: takes in an array and return the first elementtail(arr)
: takes in an array and return the elements other than the first onemiddle(arr)
: takes in an array and return the middle elementassertArraysEqual(arr1, arr2)
: determine whether two arrays are the same and return either pass or failassertEqual(a,b)
: determine whether two primitive-data-type values are the same and return either pass or failassertObjectsEqual(obj1, obj2)
: determine whether two objects are the same and return either pass or failcountLetters(sen)
: return the number of letters, excluding blank space in a sentence as an inputcountOnly(allItems, itemsToCount)
: allItems is an object with items to be counted as the keys and number as value. The itemsToCount is an object that could share keys with the first object and boolean value. The function will return the number counted for the shared keys that has 'true' as value in itemToCounteqArrays(arr1, arr2)
: determine whether two arrays are the same and return either true or falseeqObjects(obj1, obj2)
: determine whether two objects are the same and return either true or falsefindKey(obj, callback)
: the function will loop through the object and perform the callback function using each key and only return the first true conditionfindKeyByValue(obj,key)
: return the key if it matches one in the object argumentletterPositions(sen)
: returns all the indexes of each letter that appear in the sentence inputmap(arr, callback)
: return a new array which is the mutated value of each element in the original array based on the callback functiontakeUntil(arr, val)
: return the part of array from the start until the value argumentwithout(arr1, arr2)
: return the array1 without the contains in array2