1.0.1 • Published 1 year ago

@grafuj/lotide v1.0.1

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): returns first element from an array
  • tail(array): returns all elements but the first from an array (minimum 3 elements)
  • middle(array): returns middle element or elements if array length is even
  • countLetters(string): returns an object with characters as keys with values detailing how many times those characters appeared in the string
  • countOnly(array, object): returns an object with strings as keys that detail how many times those strings appeared in the array of strings.
  • eqArrays(array1, array2): returns boolean if arrays are equal
  • eqObjects(object1, object2): returns boolean if objects are equal
  • findKey(object, function): returns value of key in object that is specified in the callback function
  • findKeyByValue(object, value): returns the key that contains the value specified from a callback function
  • flatten(array): returns an array that does not contain sub-arrays
  • letterPositions(string): returns an object with keys for each letter and arrays of positions those letters are found as value for the keys
  • map(array, function): returns an array that has been modified by a callback function
  • takeUntil(array, function): returns a shortened array defined by the callback function which determines at what element to stop
  • without(array, arrayElementsToRemove): removes all elements from first array if specified in second array