1.0.0 • Published 5 years ago
@leungcnie/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 @leungcnie/lotide
Require it:
const _ = require('@leungcnie/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array): returns the head of an arraytail(array): returns the tail of an arraymiddle(array): returns the middle element(s) of an arrayassertArraysEqual(arr1, arr2): asserts whether 2 arrays are equalassertEqual(actual, expected): asserts whether values are equaleqArrays(arr1, arr2): returns true if 2 arrays are equal, else return falseflatten(array): flattens an array of nested arrays into a single arraycountOnly(allItems, itemsToCount): looks through an array allItems and returns an object of counts of only the items specified in itemsToCountletterPositions(string): returns the index of each character in a stringfindKeyByValue(obj, val): returns key that matches the value val in a given object objeqObjects(obj1, obj2): returns true if 2 objects are equal, else return falseassertObjectsEqual(obj1, obj2): asserts whether 2 objects are equalcountLetters(string): returns an object of each letter in a string and their respective number of occurencesfindKey(obj, callback): returns key in object obj that satisfies the callback functionmap(array, callback): returns the result of applying the callback function to the arraytakeUntil(arr, callback): returns an array of arr's elements up until the element passed into the callback returns truewithout(source, itemsToRemove): returns a subset of a given array, removing unwanted elements
1.0.0
5 years ago