1.0.0 • Published 4 years ago

@calvin.xu/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 @calvin.xu/lotide

Require it:

const _ = require('@calvin.xu/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): Returns the first element of array as a one element array
  • tail(array): Returns every element of array except the first as an array
  • middle(array): Returns the middle-most element(s) of array as an array
  • countLetters(string): Returns an object with letters of string as keys with their counts as their values
  • countOnly(allItems, itemsToCount): Returns a number with the number of times allItems contains itemsToCount
  • findKey(object, callback): Returns the first key of object that fulfills the condition set by callback
  • findKeyByValue(object, value): Returns the first key of object that has the value of value
  • flatten(array): Returns an array of all non-array elements within an input array that may have nested arrays
  • letterPositions(string): Returns an object with letters of string as the keys and an array of their index positions in string as their values
  • map(array, callback): Returns an array with the function callback called on each element of array
  • takeUntil(array, callback): Returns an array of sequential elements of array until it reaches an element that returns a truthy evaluated callback
  • without(source, itemsToRemove): Returns a copy of the array source without elements found in itemsToRemove