README
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 @username/lotide
Require it:
const _ = require('@shaheerahmed/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: returns the first element of an array (i.e., the head)tail(...)
: returns all elements in an array except the first one as a new arraymiddle(...)
: returns the middle element in an array of numbers if length is odd, otherwise returns the middle element - 1 and the middle element (both as a new array)flatten(...)
: returns a flattened array if an array is nested (regardless of nest-level), otherwise returns the arraycountLetters(...)
: returns the occurence-count of each letter in a string as an objectcountOnly(...)
: returns the middle element in an array if it is odd, otherwise returns the middle element - 1 and the middle element as an objecteqArrays(...)
: returns a boolean after comparing the contents of two arrayseqObjects(...)
: returns a boolean after comparing the contents of two objectsfindKey(...)
: returns a key if a passed in callback function manipulating the key-value evalutes to true otherwise returns undefinedfindKeyByValue(...)
: returns a key when passed an object and the object contains a passed-in object-key-valueletterPositions(...)
: stores the index of each character of a passed-in string and then returns the index of all occurrences of that desired character in an arraymap(...)
: returns a flattened array regardless of nest-leveltakeUntil(...)
: takes elements from an array until the conditions of a passed-in function satisfiedwithout(...)
: takes a source array and a items to remove array and returns a new array with items to remove elements removed from the source arrayassertEqual(...)
: asserts a message after comparing the contents of two primitive valuesassertArraysEqual(...)
: asserts a message after comparing the contents of two arraysassertObjectsEqual(...)
: asserts a message after comparing the contents of two objects