1.0.0 • Published 5 years ago

@riztaha/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 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 @riztaha/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • `function head (array)): Outputs the 1st element of an array.
  • `function tail (array)): Outputs the last element of an array.
  • `function middle (array): Outputs the middle element(s) of an array.
  • `function eqArrays (array1, array2): Outputs if two arrays are equal.
  • `function assertEqual (array1, array2): Outputs an assertion if two arrays are equal.
  • `function assertObjectsEqual (object1, object2): Outputs an assertion if two objects are equal.
  • `function countLetters (string): Counts the number of characters in a string.
  • `function countOnly (allItems, itemsToCount): Counts only the number of items within allItems.
  • `function eqArrays (array1, array2): Outputs if two arrays are equal.
  • `function eqObjects (object1, object2): Outputs if two objects are equal.
  • `function findKey (object, callback): Finds the keys of an object with a given callback function.
  • `function findKeyByValue (object, value): Finds the key by giving the object and value names.
  • `function flatten (array): Flattens a multi-nested array out.
  • `function letterPositions (string): Finds the positions that letters are in a given string.
  • `function map (array, callback): Maps out the character given by a callback within a string.
  • `function takeUntil (array, callback): Takes from an array until a callback function is triggered.
  • `function without (array, itemsToRemove): Takes items to remove from an array source and outputs the remaining elements.