1.0.0 • Published 5 years ago

@teddyleung/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 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 @teddyleung/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters: Takes a string and returns an object with the count of each letter
  • countOnly: Takes one array of elements and a second array of items to search and returns an object with the count of each item searched
  • eqArrays: Takes two arrays and checks for equality
  • eqObjects: Takes two objects and checks for equality
  • findKey: Takes an object and a callback function and returns the key of the object where the callback evaluates to true
  • findKeyByValue: Takes an object and a value and finds the key that corresponds to the value
  • flatten: Flattens multi-layer arrays
  • head: Takes an array and returns the first element
  • letterPositions: Takes a string and returns an object with keys of each letter and values which are arrays of the letter positions
  • map: Takes an array and a callback, applies the callback to each element in the array, and returns the new array
  • middle: Takes an array and returns an array of the middle element if length is odd or the middle two elements if length is even
  • tail: Takes an array and returns all elements other than the first
  • takeUntil: Takes an array and a callback and returns an array of elements up to the element where the callback returns true
  • without: Takes two arrays and returns the first array without items that exist in the second array