1.0.0 • Published 2 years ago

@mdever/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 @username/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head,: returns the first element of a given array
  • tail,: returns everything except the first element of a given array
  • middle,: returns the middle element(s) of an array. One element if the array has an odd number of elements and two elements if the array has an even number of elements
  • assertArraysEqual,: takes in an actual and expected array and prints to the console whether or not they are equal
  • assertObjectsEqual,: takes in an actual and expected object and prints to the console whether or not they are equal
  • countLetters,: takes a string and counts how many of each charcter are in the string and outputs the result as an object
  • countOnly,: counts items in an array and returns an object with the number of each item
  • eqArrays,: compares arrays for an exact match
  • eqObjects,: compares objects for an exact match
  • findKey,: function that searches an object and return the first key that returns a truthy value from the callback function passed to it
  • findKeyByValue,: takes in an object and a value and returns the first key in the object with that value
  • letterPositions,: takes a string and gets the index of each instance of each letter and returns an object containing arrays of the index positons
  • map,: takes an array and a callback function and returns a new array based on the callback function
  • takeUntil,: takes an array and a callback function and will return values in an array until the callback function returns true
  • without: removes unwanted elements from an array