1.0.0 • Published 2 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head: takes the head' of the array, returns the value at index 0
  • tail: takes the 'tail' of the array, returns array with all values minus the value at index 0
  • middle: return the middle value(s) of an array
  • assertEqual: asserts if two values are equal
  • assertArraysEqual: asserts if two arrays are equal, prints results
  • assertObjectsEqual: asserts if two objects are equal, prints results
  • eqArrays: base code to test if two arrays are equal
  • eqObjects: base code to test if two objects are equal
  • flatten: 'flattens out' an array with nested arrays (up to one level)
  • countOnly: creates an object with keys containing the number of times specific data shows up
  • findKey: accepts a callback function and an object. When the callback function returns true with a specific key in that object, that key is returned
  • findKeyByValues: accepts an object and a value. The first key in the object to hold that value is returned.
  • letterPositions: Returns the index position of specified letters in a string
  • map: test custom version of .map
  • takeUntil: accepts a callback and an array. Pushes elements to a new array until it hits an element which returns true with the callback
  • without: accepts an array, and an element to be removed from that array. Returns an array without those elements.