1.0.0 • Published 2 years ago

@bgriffin/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 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 @bgriffin/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(arr): Returns the first element of an array.
  • tail(arr): Returns a new array without the first element of the input array.
  • middle(arr): Returns the middle element(s) of an array.
  • countOnly(arr, itemsToCount): Counts the number of occurrences of specific items in an array.
  • countLetters(str): Counts the number of occurrences of each letter in a string.
  • findKey(obj, callback): Returns the first key in an object for which the callback function returns a truthy value.
  • findKeyByValue(obj, value): Returns the first key in an object whose value matches a given value.
  • letterPositions(str): Returns the indices of each letter in a string. map(arr, callback): Returns a new array with each element transformed by the callback function.
  • takeUntil(arr, callback): Returns a new array containing elements from the input array until the callback function returns a truthy value.
  • without(source, itemsToRemove): Returns a new array with all instances of items to remove removed from the source array.
  • eqArrays(arr1, arr2): Returns true if two arrays are identical in length and values, false otherwise.
  • eqObjects(obj1, obj2): Returns true if two objects are identical in their key-value pairs, false otherwise.
  • assertArraysEqual(arr1, arr2): Logs a message indicating whether two arrays are equal or not.
  • assertEqual(actual, expected): Logs a message indicating whether two values are equal or not.
  • assertObjectsEqual(obj1, obj2): Logs a message indicating whether two objects are equal or not.
1.0.0

2 years ago