1.0.0 • Published 3 years ago

@gerard-c/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 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 @gerard-c/lotide

Require it:

const _ = require('@gerard-c/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual: receive 2 arrays and print whether or not they are equal
  • assertEqual: receive 2 values and print whether or not they are equal
  • assertObjectsEqual: receive 2 objects and print whether or not they are equal
  • countLetters: receive a string and output an object displaying how often each character occurs
  • countOnly: receive an array and an object designating which items should be counted, outputs an object displaying amount of times each specified item occurs in array
  • eqArrays: receive 2 arrays and output true if they are equal and false if they are not
  • eqObjects: receive 2 objects and output true if they are equal and false if they are not
  • findKey: receive an object and a callback function specifying desired value, outputs key found by function
  • findKeyByValue: receive an object and a string representing desired value, outputs key matching value
  • flatten: receive a nested array and outputs an array with one level of nesting removed
  • head: receive an array and output the value at index 0
  • letterPositions: receive a string and output an object with characters as keys and arrays with their indicies as values
  • map: receive an array and a callback function, outputting a new array with each value in input array modified by function
  • middle: receive an array and output an array with the middle value(s) of input
  • tail: receive an array and output a new array containing all but the first value in the input array
  • takeUntil: receive an array and a callback function to check each value in array for specific truthy value, returning an array with every value prior to the truthy value
  • without: receive two arrays, returning the first array minus the contents of the second