1.0.0 • Published 3 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): Returns an array with the first element of original array.
  • middle(array): Returns an array with the middle element or elements in the case there are even amount of elements.
  • tail(array): Return an array without the first element of the original array.
  • assertArrayEqual(arr1, arr2): Assertion test to check whether two arrays are the same.
  • assertEqual(val1, val2): Assertion test to determine if values passed in are the same.
  • assertObjectEqual(obj1, obj2): Assertion test to determine if objects passed in are the same.
  • countLetters(str): Returns an object with characters as keys and their number of Occurences as values. The function does not count whitespace and capital letters are counted as lowercase letters.
  • countOnly(array, object): Returns an object counting only the elements in the inputed array that were given by the inputed object key with value true.
  • eqArrays(arr1, arr2): Returns a boolean value that compares whether the two input arrays are the same.
  • eqObjects(obj1,obj2): Returns a boolean value that compares whether the two input objects are the same.
  • findKey(obj, callback): Returns the key string of the input object that satisfies the callback function.
  • findkeyByValue(obj, value): Returns a key string from input object if matching input value is found.
  • flatten(array): Returns an array that removes all inner nested arrays.
  • letterPositions(str): Returns an object with keys of all the characters of the input string. The value is an array of all the index positions that the character occured in the input string. All whitespaces are ignored and capital letters are counted as lowercase characters.
  • map(array,callback): Returns an array that perfoms the callback function on each item in the original array.
  • reverse(array): Returns a single concatenated string of each element in the orignal array in reverse.
  • takeUntil(array, callback): Returns an array with each elements from original array stopping only when callback function is satisfied.
  • without(array1,array2): Returns a modified array1 without the elements in array2.