1.0.0 • Published 7 months ago
@brittanyshelley/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 @brittanyshelley/lotide
Require it:
const _ = require('@brittanyshelley/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
:returns first item in arraytail(arr)
:returns last item in arraymiddle(array)
:returns middle item in array of odd length or the middle two items in an array of even lengtheqArrays(arr1, arr2)
:returns true or false when comparing two arraysassertArraysEqual(array1, array2)
:compares two arrays for strict equality and logs output to consoleassertObjectsEqual(object1, object2)
: compares two objects for strict equality and logs assertion message to consolecountLetters(string)
:iterates over string and returns how many times each letter was foundcountOnly(allItems, itemsToCount)
:iterates over array (allItems) and returns the number of times each (itemsToCount) appear in the arrayletterPositions(sentence)
:returns the letters in the string and at what index each of them occurtakeUntil(array, callback)
:pushes each element in array to a new array until the callback returns true, then outputs new arraywithout(source, itemsToRemove)
:takes one array (source) and returns a new array with (itemsToRemove) removedeqObjects(object1, object2)
:compares two objects and returns whether they are equal or not (true or false)findKey(object, callback)
:applys callback function to every key of object and returns the key when it's truefindKeyByValue(obj, val)
:searches object keys for specified value then returns that key when it's trueassertEqual(actual, expected)
:compares two strings to see is they are the same then returns failed or passedflatten(array)
:flattens nested arrays into one and returns the new array
1.0.0
7 months ago