1.0.0 • Published 4 years ago

@philipd/lotide v1.0.0

Weekly downloads
-
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 @philipd/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters: Given a string, return and object detailing the number of occurences of each letter present.
  • countOnly: Given an array of values, return the number of occurences of each value specified in an input object.
  • eqArrays: Given two arrays, return whether or not they contain the same data. Supports nested arrays.
  • eqObjects: Given two objects, return whether or not they are equal. Supports nested objects.
  • findKeyByValue: Given an object, return the first key whose value matches the input given.
  • findKey: Given an object and callback function, return the first key for which the corresponding value returns true when passed into the callback function.
  • flatten: Given nested arrays, return an un-nested array with the same values in the same order.
  • head: return the first item in an array.
  • letterPositions: Given a string, return an object specifying the position of each letter in the string as an array of numbers.
  • map: Given an array and a callback function, return the result of applying said function to each element of the array.
  • middle: Return the middle element(s) of an array as an array.
  • tail: Given an array, return an array containing the same elements except the first one.
  • takeUntil: Given an array and a callback function, return an array containing the same elements up to the point where the callback function returns true.
  • without: Given an array, return an array containing the same elements except those specified in an additional input array.