1.0.0 • Published 2 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(...): retrieves the first element from the array
  • tail(...): tail retrieves every element except the head of the array
  • middle(...): returns the middle elements in an array
  • without(...): returns an array without a specified element
  • assertArraysEqual(...): asserts two arrays are equal
  • assertObjectsEqual(...): asserts two objects are equal
  • eqArrays(...): compares two arrays for a perfect match
  • assertEqual(...): compares two values and prints a message telling us if they match or not
  • takeUntil(...): returns a slice of the array with elements taken from the beginning
  • map(...): returns a new array based on the results of the callback function
  • letterPositions(...): takes in a string and return all the indices where each character is found
  • flatten(...): flattens a double-layer nested array into a single-layer nested array
  • findKeyByValue(...): searches for a key in an object where its value matches a given value
  • findKey(...): return the first key for which the callback returns a truthy value
  • eqObjects(...): compares two objects for a perfect match
  • countOnly(...): takes in a collection of items and return counts for a specific subset of those items
  • countLetters(...): takes in a string and returns a count of each of the letters