1.0.0 • Published 3 years ago

@eascan/lotide v1.0.0

Weekly downloads
2
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 @username/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head([array]): returns first element
  • tail([array]): returns array of all elements other than the first one
  • middle([array]): returns an array with the middle element(s)
  • assertArraysEqual(actual, expected): logs an assert statement if actual array is equal or not to expected array
  • assertEqual(actual, expected): logs an assert statement if actual equals expected
  • assertObjectsEqual(actual, expected): logs and assert statement if actual object is equal to expected object
  • countLetters(input): returns an object with each letter of the input as key, and values are the number of times each key is repeated in the input
  • countOnly(allItems, itemsToCount): This function should take in a collection of items as an object and return counts for a specific subset of those items (also inputed as an object, key + value pairs with values being true or false)
  • eqArrays(array1, array2): takes two arrays and returns true if they are equal and false if not
  • eqObjects(object1, object2): takes two objects as inputs and returns true if equal, false if not
  • findKey(object, callback): takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined.
  • findKeyByValue(object, value): search for a key on an object where its value matches a given value.
  • letterPositions(sentence): return an object where character of sentence is a key and the value is an array of all indices where the letter is found in the sentence
  • map(array, callback): will take an inputted array, perform a callback function on each element of the array and return a new array based on those actions.
  • takeUntil(array, callback): will return an array which will include the elements of original array up until the callback returns a truthy value
  • without(array, arrayItemsToRemove): return a new array based on original array without the items that needed to be removed