1.0.0 • Published 4 years ago

@gorrinoloco/lotide v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

Lotide

A clone of the lodash JavaScript library to practice creating various types of functions using JS.

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • eqArrays() -> Implements a function that can compare two arrays. It takes in two arrays and returns true or false, based on a perfect match.
  • assertArraysEqual() -> It takes in two arrays and console.log an appropriate message to the console.
  • without() -> It returns a subset of a given array, removing unwanted elements.
  • flatten() -> It takes in an array containing elements including nested arrays of elements, and return a "flattened" version of the array.
  • middle() -> It returns an array with only the middle element(s) of the provided array. This means that the length of the returned elements could vary.
  • countOnly() -> Given an object and a list of values, it returns the number of occurrences of each.
  • countLetters() -> Given a string of letters, it returns an object with the number of occurrences for each.
  • letterPositions() -> It returns all the indices (zero-based positions) in the string where each character is found.
  • findKeyByValue() -> It scans the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.
  • eqObjects() -> assesses whether two objects are equal (returns true or false).
  • assertObjectsEqual() -> It takes in two objects and console.log an appropriate message to the console.
  • takeUntil() -> It collects items from a provided array until the callback provided returns a truthy value.
  • findKey() -> It 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.