1.0.0 • Published 8 months ago
@bsaldanha/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 @bsaldanha/lotide
Require it:
const _ = require('@bsaldanha/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array): Gives you the first element of an array
tail(array): Gives you the the tail of an array
middle(array): Gives you the middle of an array
countOnly(allItems, itemsToCount): counts the occurences of itemsToCount in allItems
countLetters(sentence): counts letters in a sentence
findKey(obj,callback): finds a key with a callback function
findKeyByValue(obj, val): finds a key by value,
flatten(array): flattens a nested array,
letterPositions(sentence): returns the position of an alphabet in a sentence,
map(array, callback): iterates over array and performs the callback function,
takeUntil(array, callback): returns a new array with items from given array until the callback specifies
without(array, itemsToRemove): return a new array without itemsToRemove
assertEqual(actual, expected): checks if 2 variables are equal, and prints out pass or fail
assertArraysEqual(firstArray, secondArray): checks if 2 arrays are equal, and prints out pass or fail,
eqObjects(object1, object2): checks if 2 objects are equal
assertObjectsEqual(actual, expected): checks if actual is the same as equal, and prints out pass or fail,
eqArrays(first, second): checks if 2 arrays are equal,
1.0.0
8 months ago