1.0.0 • Published 4 years ago

@schenn1992/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(arr): return the first element of the array
  • tail(arr): return everything except for the first element in the array
  • middle(arr): return an array with only the middle element(s) of the provided array
  • without(source, itemsToRemove): return a new array with only those elements from source that are not present in the itemsToRemove array
  • takeUntil(array, callback): keep collecting items from a given array until the given callback returns a truthy value
  • letterPositions(sentences): take in a sentence as argument and return all the indices in the string where each character is found
  • findKeyByValue(objectToTest, valueToFind):
  • findKey(objectToTest, callback): takes in an object and a callback function as arguments. return the first key for which the callback returns a truthy value. If no key can be found, return undefined
  • map(array, callback): takes in array and a callback function as arguments. Return a new array based on the results of callback funciton
  • countLetters(sentences): take in a sentence(string) as an argument and return a count of each of the letters in the given sentence
  • countOnly(allItems, itemsToCount): return an object containing counts of everything that the input object listed
  • eqArrays(arrA, arrB): take in two arrays as arguments and returns whether true or false based on the result. True if match, vice versa
  • eqObjects(object1, object2): take in two objects as arguments and returns whether true or false based on the result. True if match, vice versa
  • assertObjectsEqual(actual, expected): compare two objects it takes in and print out a message telling us if they match or not
  • assertEqual(actual, expected): compare two primitive values it takes in and print out a message telling us if they match or not
  • assertArraysEqual(actual, expected): compare two arrays it takes in and print out a message telling us if they match or not