1.0.0 • Published 5 years ago
@kaushikmehta/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 @kaushikmeghta/lotide
Require it:
const _ = require('@kaushikmehta/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head([...]): take an array of items and returns the first element;tail([...]): take an array of items and returns the all but the first element;middle([...]): takes an array of elements and return the item in the middle index for odd lengths and the middle two elements for even lengthsassertArraysEqual([...], [...]): checks whether two arrays are equal and logs to console.assertEqual(...): checks whether two items are equalassertObjectsEqual({...}, {...}): checks whether two objects are equalcountLetters: takes a string and return a list of unique letters and how many times they occur in the stringcountOnly(...): counts the number of times a parameter occurs in a listeqArrays(...): checks whether two arrays are equaleqObjects(...): checks whether two objects are equalfindKey(...): finds the key of a particular item in objectfindKeyByValue(...): finds the key corresponding to a particular value in objectflatten(...): take a multi-dimensional array and returns a one-dimensional arrayletterPosition(...): takes a string and returns the indices of where the letter occursmap(...): maps the elements of an array to a new array based on conditions passedtakeUntil(...): pushes elements of one array into another until a condition is met, then stopswithout(...): takes a list of items and returns another list without a particular element
1.0.0
5 years ago