1.0.0 • Published 5 years ago

@malloryminchau/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

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 @malloryminchau/lotide

Require it:

const _ = require('@username/lotide');

Call it:

const results = _.tail([1, 2, 3]) // => [2, 3]

Documentation

The following functions are currently implemented:

  • assertArrayEqual(firstArray, secondArray, expect): confirms that two given arrays are or are not equal. The input for the function is two arrays and a boolean value, true or false, based on whether the arrays should be equal or not.
  • assertEqual(actual, expected): compares two values, actual and expected, and returns a boolean value for whether or not they are equal.
  • assertObjectsEqual(object1, object2, expected): compares two objects to determine if they are equal and compares them with a boolean value of the expected boolean to determine whether the assertion passes or not.
  • countLetters(word): counts the number of letters in a given string, input as word.
  • countOnly(allItems, itemsToCount): input assItems is an array of strings or values, itemsToCount is an object corresponding with the values you wish to count. Function returns an object with the numbers of times the elements are used.
  • eqArrays(firstArray, secondArray): compares two arrays and returns a boolean value corresponding to whether the two arrays are equal.
  • eqObjects(object1, object2): compares two objects and returns a boolean corresponding with whether the two objects are equal.
  • findKey(object, callback): input values for function are an object and a callback function. The function iterates over the object until the callback function is satisfied.
  • findKeyByValue(shows, value): the input for the function are an object and a value. the function iterates over the values of an object and returns the key that corresponds with that value.
  • flatten(array): the input is an array of arrays and the function takes all of the arrays and combines them and returns one array with all of the values.
  • head(actual): input is an array and the function returns the first element in the array.
  • letterPositions(sentence): a sentence, as a string, is the input for the function. The function returns an object where the keys are each of the letters in the sentence, and the value of the keys are arrays of the positions of each letter.
  • map(array, callback): input values are an array and a callback function. The function iterates over the array and populates the result array with values of the callback function with the value of each element.
  • middle(array): input an array and returns the value or values in the middle of the array. returns an empty array if there are 0-2 elements.
  • tail(actual): input array and the function returns the array with the first element is cut out.
  • takeUntil(array, callback): inputs an array and a callback function. function iterates over the values of each element of the array until it reaches the value in the callback function and then stops.
  • without(source, itemsToRemove): input an array and a value. iterates over array and compares it to the value. returns an array with the given value removed.