1.0.0 • Published 1 year ago

@sa55/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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 @sam55/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(arr1, arr2): Takes in 2 arrays and outputs a message depending on whether they're equal or not.
  • assertEqual(actual, expected): Takes in 2 arrays and outputs a message depending on if their equality is true or not.
  • assertObjectsEqual(actual, expected): Takes in 2 objects and outputs a message depending on their key/value pairs equality
  • countLetters(phrase): Takes in a sentence/phrase and outputs an object containing key/value pairs of each letter's count
  • countOnly(allItems, itemsToCount): Takes in an object and array. Returns a count of appropriate object items that are present in array.
  • eqArrays(array1, array2: Takes 2 arrays, compares their exact values and returns true or false.
  • eqObjects(object1, object2): Takes in 2 objects compares their exact key/values and returns true or false.
  • findKey(object, callback): Takes in an object and a callback. Returns the first key in the object that equals true when matched with the callback value.
  • findKeyByValue(objToScan, valToFind): Takes in an object and a value. Returns the first key which contains the given value or returns undefined.
  • head(array): Takes in an array and returns the first element.
  • letterPositions(phrase): Takes in a sentence/phrase and returns an object displaying the indexes of each letter.
  • map(array, callback): Takes in an array and callback. Returns another array based on what the callback asks for.
  • middle(array): Takes in an array and returns the middle element(s).
  • tail(array): Takes in an array and returns another array containing all elements except for the head element.
  • takeUntil(array, callback): Takes an array and callback. Returns a subset of the array from the beginning up until a value returns true when matched with the callback.
  • without(source, itemsToRemove): Takes in an array and items to remove. Returns a subset of with the indicated items removed.