1.0.0 • Published 1 year ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(arr): returns first element of an array as an array
  • tail(arr): returns every element after the head as an array
  • middle(arr): returns the the middle element(s) of an array as an array
  • map(arr, callback): performs a function on a given array
  • assertArraysEqual(arr1, arr2, expected): test for the equivalence of two arrays
  • assertEqual(actual, expected): test for the equivalence of two data structures
  • assertObjectsEqual(actual, expected): test for the equivalence of keys, values of two objects
  • countLetters(str): returns an object of the count of every character in a string
  • countOnly(allItems, itemsToCount): returns an object of the count of every element in an array
  • eqArrays(arr1, arr2): tests the equivalence of two arrays
  • eqObjects(obj1, obj2): tests the equivalence of two objects
  • findKey(obj, callback): performs a callback function on an object
  • findKeyByValue(obj, show): returns the key of a value in an object
  • letterPositions(str): returns the indexes of each character as an object
  • takeUntil(array, callback): returns elements of an array up until a given value
  • without(source, itemsToRemove): removes an item from an array