1.0.0 • Published 2 years ago

@kcmoon/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head: Returns the first element of an array.
  • tail: Returns every element of an array except for the first element.
  • middle: Returns the middle most element(s) of an array.
  • map: Takes in an array and will implement a callback function on each element of the aray.
  • takeUntil: Will keep collecting items from a provided array until the callback provided returns a truthy value.
  • without: Returns a subset of a given aray, removing unwanted elements.
  • letterPositions: Will return all the indices (zero-based positions) in the string where each character is found.
  • findKeyByValue: Will take in an object and a value, scan the object for the input value and return the first key which contains the value.
  • findKey: Will take in an object and a callback and 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.
  • eqObjects: Will take in two objects and returns a boolean based on a perfect match.
  • eqArrays: Will take in two arrays and will return a boolean value based on a perfect match.
  • countOnly: Will be given an array and an object, and return an object containing counts of everything that the input object listed.
  • countLetters: Will take in a string sentence and return an object of the count of each letter in that sentence.
  • assertObjectsEqual: Will take in two objects and console.log a message based on a match or not.
  • assertEqual: Will compare two values and console log a message based on a match or not.
  • assertArraysEqual: Will take in two arrays and console log a message after evaluating if they are equal.