1.0.0 • Published 5 years ago

@daniel-n-huss/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 @daniel-n-huss/lotide

Require it:

const _ = require('@daniel-n-huss/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters(sentence): given a string, return an object with the letter (key) and the number of times each appears in the sentence (value)
  • countOnly(array, objectWithTestCriteria): given an array, and an object with true/false values tied to keys you want counted, return how many times that key appears in the array
  • findKey(obj, callback): Scan through a passed object for the first key that the callback function returns truthy upon.
  • findKeyByValue(object, value): search through an object and return the first key that holds the value.
  • flatten(array): Flatten nested arrays into a single layer. Works on multiple layers.
  • head(array): return the head (0 index) of an array.
  • letterPositions(string): given a sentence string, return an object of keys for each letter that contain an array of the indexies where that letter appears in the string.
  • map(array, callback): modify a given array based on the properties of the callback function passed.
  • middle(array): return an array containing the value(s) at the centre of a given array.
  • tail(array): return an array that no longer contains the 0 index.
  • takeUntil(array, callback): collect data from an array until the callback provided returns a truthy value; data is returned as an array.
  • without(array, valueToRemove): filter out unwanted values from a given array.