1.0.0 • Published 4 years ago

@bryce-mcmath/lotide v1.0.0

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

Require it:

const _ = require('@bryce-mcmath/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • assertEqual(value1, value2): compares two values with strict equality
  • assertArraysEqual(array1, array2): recursively compares arrays that may contain subarrays
  • assertObjectsEqual(object1, object2): recursively compares objects that may contain objects and arrays
  • eqArrays(array1, array2): returns true if arrays are equal, false otherwise. Uses recursion if array contains arrays
  • eqObjects(object1, object2): returns true if objects are equal, false otherwise. Uses recursion if object contains objects
  • countLetters(string): returns an object that lists the count of each letter used in a given string
  • countOnly(array, object): returns a count object that lists the count of each occurence of a key in the input object included in the input array
  • letterPositions(string): returns an object with key value pairs that list arrays of each position that a given letter has in the input string
  • findKey(object, callback): returns the first key of the input object that satisfies the given callback
  • flatten(array): returns a one dimensional array when given a multidimensional array
  • head(array): returns an array of the first element of the input array
  • tail(array): returns an array of every element of an array less the first element
  • takeUntil(array, callback): returns an array of each element until an element that passes the callback is reached
  • without(array1, array2): returns a copy of the first array that doesn't include any of the items in the second array
  • map(array, callback): returns an array of values returns by passing the original array values into a callback

Running Tests

In the root directory:

npm test