1.0.0 • Published 3 years ago

@sophiejoliver/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 @sjoliver/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head: returns the first element in a given array
  • tail: returns a (new) array of all elements in a given array except for the first element
  • middle: returns the middle element in a given array (returns 2 elements if the array length is an even number)
  • assertArraysEqual: writes an assertion message to the console when 2 arrays are compared (assertion passes or fails)
  • countLetters: counts how many instances there are of each unique letter in a given string (returns an object)
  • eqObjects: checks if 2 objects are equal
  • map: iterates over an array and creates a new array with the first value of each element in the first/original array
  • takeUntil: iterates over an array and creates a new array using elements from the original array until a certain condition is met while iterating through original array
  • assertEqual: writes assertion message when 2 (primitive) values are compared
  • countOnly: returns an object containg counts of each item in the given array (when object value is true)
  • findKeyByValue: takes an object and returns the key when given the value
  • assertObjectsEqual: writes assertion message when 2 objects are equal
  • eqArrays: checks if 2 arrays are equal
  • findKey: returns they when given an object and a value
  • letterPositions: returns an object where each key is a unique value in the given argument and the value is an array of that key's index (or indices) -- i.e., tells you where in the array each value is located
  • without: removes items from a given array and returns a newArray