1.0.0 • Published 3 years ago

@nyozov/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head: Input array, head returns the first element of an array
  • tail: Input array, tail returns another array with all elements except the first element
  • middle: Input array, middle returns another array with only the middle element or the two middle elements in it
  • assertArraysEqual: Input array and expected outcome, assertArraysEqual will return pass if they are the same, fail if they are different
  • assertEqual: Input string and expected outcome, assertEqual will return pass if they are the same, fail if they are different
  • assertObjectsEqual: Input object and expected outcome, assertObjects equal will return pass if they are the same, fail if they are different
  • countLetters: Input string, countLetters will return the number of letters in the string
  • countOnly: Input object and which items to count with true/false, countOnly will return the count of the items in the object that were input as true
  • eqArrays: Input 2 arrays, eqArrays will return true if they are the same, false if they are different
  • eqObjects: Input 2 objects, eqObjects will return true if they are the same, false if they are different
  • findKey: Input object and argument, findKey will return the first key in the object that matches the argument
  • findKeyByValue: Input object and value of a key, findKeyByValue will return the first key in the object that has that value
  • flatten: Input array, flatten will return a new array with sub-array elements removed at 1 level deep
  • letterPositions: Input string, letterPositions will return an object with letters and keys, and the position of the letter in the string as key values
  • map: Input array and argument, map will return a new array with elements that match the argument
  • takeUntil: Input array and argument, takeUntil removes items from array until argument is met
  • without: Input array and elements to remove, without returns a new array with removed elemets