1.0.1 • Published 4 years ago
@justin1002/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 @justin1002/lotide
Require it:
const _ = require('justin1002/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented: input values are as follows: 1) arr = array 2) obj = object 3) str = string 4) callback = callback function
head(arr)
: returns the first element in an arraytail(arr)
: returns all elements after the first in an arraymiddle(arr)
: returns the middle element of an array, returns two elements if the length is an even numbereqObjects(obj1,obj2)
: returns a boolean value comparing two objects for equalityeqArrays(arr1,arr2)
: returns a boolean value comparing two arrays for equalityassertArraysEqual(arr1,arr2)
assertion function that compares two arrays for equalityassertObjectsEqual(obj1,obj2)
assertion function that compares two objects for equalitycountLetters(str)
creates an object which presents the letter(key) and the count(value)countOnly(arr,obj)
creates an object that counts items in an array based on boolean keys-values an objectfindKey(obj,callback)
returns the first key that matches the callback function requirementsfindKeyByValue(obj,key)
returns the first key that matches the value in an objectflatten(arr)
takes an array with multiple dimensions and flattens to one dimension (only works with one additional dim)without(arr1,arr2)
filters array 1 without items in array 2letterPositions(str)
returns an object that shows the letter(key) and their relative index in an arraytakeUntil(arr, callback)
returns an array that takes values until it reaches a certain condition from the callbackmap(arr, callback)
returns an array that is mapped based on the callback function