1.0.0 • Published 5 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(actual, expected): asserts that the expected array matches the program's actual array output.
  • assertEqual(actual, expected): asserts that the expected string input matches the program's actual string output.
  • assertObjectsEqual(actual, expected): asserts that the expected object input matches the program's actual object output.
  • countLetters(itemsToCount): counts the number of times each characters occured in a string and outputs the object with characters broken down.
  • countOnly(allItems, itemsToCount): counts the number of times a given item occured in an object.
  • eqArrays(firstArray, secondArray): checks whether the two given arrays are equal.
  • eqObjects = function(object1, object2): checks whether the two given objects are equal.
  • findKey(object, callback): returns the object's first key for which the callback returns truthy value.
  • findKeyByValue(showsList, theMovie): finds the object's key by the key's value.
  • head(actual): returns the array's first value.
  • middle(array): returns an array's middle value if the array's length is odd and the array's two middle values if the array's length is even. Returns the original array if the input is an empty array or has the length of 1 and 2.
  • tail(actual): returns an array's last element.
  • letterPositions(sentence): takes a string and outputs an object which shows the position index of each string's character.
  • map(array, callback): takes an array and outputs the array which consists of first character of each original array's elements.
  • takeUntil(array, callback): outputs a slice of the array with elements from the beginning until the callback character(s) are met.
  • without(originalArray, itemsToRemove): outputs the given array without the given item.