1.0.0 • Published 2 years ago

@robotsch/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 @username/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • map(arr, cb): Execute callback function on every element of a given array

  • head(arr): Return the first value of a given array

  • tail(arr): Return the given array with the first element removed
  • middle(arr): Return the middle element(s) of an array
  • flatten(arr): Returns a flattened array up to depth 2
  • without(srcArr, rmArr): Return the source array with any elements of the second array removed
  • takeUntil(arr, cb): Returns an array of values from a given array starting from index 0 until a given callback function returns true
  • countOnly(arr, obj): Returns a count object of array elements that have truthy values in a given object
  • findKey(obj, cb): Returns the first property whos value matches a given callback function
  • countLetters(string): Returns an object which contains letter counts of a provided string
  • findKeyByValue(obj, val): Returns the first property of an object whos value matches a provided value
  • letterPositions(string): Returns an object which contains the index of every character in a given string
  • eqArrays(arr1, arr2): Returns true if both arrays are equal, false if not
  • eqObjects(obj1, obj2): Returns true if both objects are equal, false if not
  • assertEqual(a, b): Displays equality assertion messages in terminal for two primitives
  • assertArraysEqual(arr1, arr2): Displays array equality essertion messages in terminal for two given arrays
  • assertObjectsEqual(obj1, obj2): Displays object equality essertion messages in terminal for two given objects