1.0.0 • Published 3 years ago

@cthu97/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head: returns beginning of an array
  • middle: returns middle of an array
  • tail: returns end of an array
  • assertEqual: compare the two values it takes in and print out a message telling us if they match or not
  • assertArraysEqual: asserts that two arrays are equal
  • assertObjectEqual: asserts that two objects are equal
  • countLetters: counts number of times letter comes up in a string
  • countOnly: only counts the elements in array that it is told to count
  • eqArray: takes two arrays and returns true if they are equal
  • eqObject: takes two objects and returns true if they are equal
  • findKey: takes an object and a callback function, finds the key using value of key
  • findKeyByValue: search for a key on an object where its value matches a given value
  • flatten: takes an array or nested array and flatten it into one array
  • letterPositions: takes a string and tells us the indices of where each letter is
  • map: takes in an array to map and a callback function, then will return a new array based on the results of the callback function
  • takeUntil: takes in an array and a callback function, will return a slice of the array with elements taken from beginning until callback returns a truthy value
  • without: returns a subset of a given array, removing unwanted elements.