1.0.0 • Published 6 years ago
@lxg1992/sharedlotide 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 Alex and Duncan as part of our learnings at Lighthouse Labs.
Usage
Install it:
npm install @lxg1992/SharedLotide
Require it:
const _ = require('@lxg1992/SharedLotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array): returns the first element of anarraytail(array): returns thearraywithout the first elementmiddle(array): ifarrayhas even number of elements, returns an array of two middle numbers, otherwise if array has odd number of elements, returns an array of a middle numberassertArraysEqual(actual,expected): compares theactualvalue of an array to theexpectedvalue of an array and logs the result to the consoleassertEqual(actual,expected): compares theactualvalue of to theexpectedand logs the result to the consoleassertObjectsEqual(actual,expected): compares theactualvalue of an object to theexpectedvalue of an object and logs the result to the consolecountLetter(string): takes in astringand returns an object with the keys each being a letter that is encountered in thestringand the value of each said key being the number of times that letter is encountered in the stringcountOnly(arrayOfValues, objectOfItemsToCount): returns an object that has the number of times each key ofobjectOfItemsToCountis encountered inarrayOfValueseqArrays(array1, array2): returnstrueifarray1is found equal toarray2, otherwise returnsfalseeqObjects(object1, object2): returnstrueifobject1has the same keys and values asobject2, otherwise returnsfalsefindKey(object, callback): returns the first item within anobjectwhich returns true when tested against thecallbackfunctionfindKeyByValue(objectToScan, valueToUse): Takes anobjectand a specifiedvalue, and returns the first key within theobjectthat has this specifiedvalue.flatten(toFlatten): Takes a nested array and returns an array with one layer.map(array, callback): Takes an array and a callback function. The callback function applies an action to each element of the array, and returns a new array with the results.takeUntil(array, callback): receivesarrayandcallbackfunction. The callback function will assess each value within the inputed array until callback(value) returns true. takeUntil will then a return a new array, containing all of the inputed values up until that value.without(source, itemsToRemove): takes asourcearray and aitemsToRemovearray, and removes the values withinitemsToRemovefrom thesourcearray
1.0.0
6 years ago