1.0.0 • Published 1 year ago

@lindseyogilvie/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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 @lindseyogilvie/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(array1, array2): Function compares two arrays for equality, returning 'Assertion Passed' if the same, and 'Assertion Failed' if different.
  • assertEqual(actual, expected): Function compares two values for equality, returning 'Assertion Passed' if the same, and 'Assertion Failed' if different.
  • assertObjectsEqual(object1, object2): Function compares two objects for equality, returning 'Assertion Passed' if the same, and 'Assertion Failed' if different.
  • countLetters(sentence): Function takes in a sentence as a string and returns a count of each letter in the sentence.
  • countOnly(allItems, itemsToCount): Function takes in an array containing all items and an object outlining what to count and returns an object with the count of the designated items.
  • eqArrays(array1, array2): Function compares two arrays for equality, returning true if the same and false if different.
  • eqObjects(object1, object2): Function compares two objects for equality, returning true if the same and false if different.
  • findKey(object, callback): Function takes in an object and a callback, scans the obejct and returns the first key for which the callback returns a truthy value.
  • findKeyByValue(object, value): Function takes in an object and a value and returns the first object key which contains the given value.
  • head(array): Function takes in an array and returns the first element of the array.
  • letterPositions(sentence): Function takes in a sentence as a string and returns every index in the string where each character is found.
  • map(array, callback): Function takes in an array and a callback function and returns a new array containing the results of the callback function.
  • middle(arrays): Function takes in an array and returns the middle-most element(s) of the array.
  • tail(array): Function takes in an array and returns all elements except the head.
  • takeUntil(array, callback): Function takes in an array and a callback and executes the callback function on all elements in the array until a truthy value is returned. Function returns an array containing all elements of the original array up to this truthy value.
  • without(source, itemsToRemove): Function takes in a source array and an itemsToRemove array and returns an array with only those elements from the source that are not present in the itemsToRemove array.
1.0.0

1 year ago