1.0.0 • Published 5 years ago

laurtann-lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(): will assert if arrays are equal and log T or F
  • assertEqual(): will assert if elements are equal and log T or F (not for use on objects)
  • assertObjectsEqual(): will assert if objects are equal and log T or F
  • countLetters(): will take a string as an argument and return an object with counts for each letter
  • countOnly(): will take in an array of elements (arg 1) and return counts for a specific subset of these elements (arg 2)
  • eqArrays(): will check if arrays are equal and return T or F
  • eqObjects(): will check if objects are equal and return T or F
  • findKey(): will take in an object and callback and return first key that callback returns as truthy
  • findKeyByValue(): will take in an object and value and return first key that contains the value
  • flatten(): will flatten a nested array into a single-level array
  • head(): will return element 0 of an element or array.
  • letterPositions(): will take in a string and return all indices where character found
  • map(): will take in an array and callback and return a new array based on callback
  • middle(): will take in an array return the element(s) in the middle position(s). Will return [] if array.length < 3.
  • tail(): will take in an array return all elements except for that at index 0 (the head). Will return [] if array.length < 2.
  • takeUntil(): will take in an array and callback and will slice array from index 0 until callback returns a truthy value.
  • takeUntil(): will take in an array and callback and will slice array from index 0 until callback returns a truthy value.
  • without(): will take in an array and callback and will slice array from index 0 until callback returns a truthy value.