1.0.0 • Published 5 years ago

@ninjabattler/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 @ninjabattler/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArrayEqual(Actual, Expected): takes in two arrays and asserts if they are equal or not
  • assertEqual(Actual, Expected): takes in two primitive values and asserts if they are equal or not
  • assertObjectsEqual(Actual, Expected): takes in two objects and asserts if they are equal or not
  • countLetters(String): takes in a string and returns an object with each letter - excluding spaces - as a key and how many time the appear in the string as the key value
  • countOnly(AllItems, ItemsToCount): takes in an array of items and an object of items to count. Will return an object with the count values
  • eqArrays(Array1, Array2): takes in two arrays and returns true/false if they are equal or not
  • eqObjects(Object1, Object2): takes in two objects and returns true/false if they are equal or not
  • findKey(Object, Callback): take in an object and a callback function to search for the key. Will return the key name that evaluates the callback to true
  • findKeyByValue(Object, Value): takes in an object and a primitive value. Will return the first key that's value matches the input value
  • flatten(Array): takes a nested array and returns an unnested version of the input array
  • head(Array): returns the first item in an array
  • letterPositions(String): takes in a string and returns an object with each a key for each letter excluding space. Each key has an array of every position the letter appeared in the string.
  • map(Array, Callback): takes in an array and a callback function. Returns an array of all the values returned by the callback function
  • middle(Array): takes in an array and returns the middle value of an array. Returns an array with two values for arrays with an even length
  • tail(Array): takes in an Array returns every item after the head of the array
  • takeUntil(Array, Callback): takes in an array and a callback function. Returns an array of all items in the input array until the callback evaluates to true
  • without(Array, ItemsToRemove): takes in an array and a second array of items to remove. Returns a copy of the first array with all values in the second array removed