1.0.0 • Published 2 years ago
@ndav/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 @ndav/lotide
Require it:
const _ = require('@ndav/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(arr)
: outputs first element of an arraytail(arr)
: outputs an array of elements except the first oneeqArrays(arr1, arr2)
: checks if every element of 2 arrays matcheqObjects(obj1, obj 2)
: checks if every key value pair of 2 objects matchwithout(arr, itemsToRemove)
: filters specific items in array from another arraymiddle(arr)
: returns an array of middle-most elementscountOnly(obj, count)
: takes in a collection of items and returns count for specific subset of those itemscountLetters(str)
: returns an object representing count of each letter in a stringletterPositions(str)
: returns an object representing indices of a string where each character is foundfindKeyByValue(obj, value)
: search the object and returns first key containing given valueassertObjectsEqual(obj1, obj2)
: checks the equality of 2 arrays and prints corresponding messageassertArraysEqual(arr1, arr2)
: checks the equality of 2 arrays and prints corresponding messageassertEqual(actual, expected)
: checks the equality of 2 values and prints corresponding messagemap(arr, callback)
: returns a new array of first indices of input array stringstakeUntil(arr, callback)
: slice an array from the beggining until specified condtitionfindKey(obj, callback)
: search for a key in a given obj which satisfies the provided conditionflatten(arr)
: transfroms one-level-nested array to single-level array
1.0.0
2 years ago