1.0.0 • Published 6 years ago

@msiregar/lotide v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 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 @msiregar/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): return first item in array
  • tail(array): return all items in array except the first
  • middle(array): take the middle element(s) of an array
  • assertArraysEqual(array1, array2): take two arrays and console.log appropriate message
  • assertEqual(actual, expected): check if two values are equal
  • assertObjectsEqual(actualObject, expectedObject): take two objects and console.log appropriate message
  • countLetters(string): count letters in a string
  • countOnly(array, object): take array and object, return object containing total of everything that the input object listed
  • eqArrays(array1, array2): check if two arrays are equal
  • eqObjects(object1, object2): check if two objects are equal
  • findKey(object, callback): scan the object and return the first key for which the callback returns a truthy value. if no key is found, then it should return undefined
  • findKeyByValue(object, value): scan object and return the first key which contains the given value
  • flatten(array): take in an array of arrays and flatten to a single-level array
  • letterPositions(string): return all the indices (zero-based positions) in the string where each character is found
  • map(array, callback): return a new array based on the results of the callback function
  • takeUntil(array, callback): keep collecting items from a provided array until the callback provided returns a truthy value
  • without(array, itemsToRemove): return a subset of a given array, removing unwanted elements