1.0.0 • Published 3 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • function1(assertArraysEqual): Takes 2 arrays and the eqArrays function to test if two arrays are the same. when using this function you also need to import eqArrays.
  • function2(assertEqual): Takes two values and if they are the same it returns true, otherwise it returns false.
  • function3(assertObjectsEqual): Takes 2 Objects and compares they have the same keys.
  • function4(countLetters): Takes a string and counts the amount of letters. The functions returns an object with the different characters and their count.
  • function5(countOnly): Takes an array of strings with a match, the function returns the amount of times it matched.
  • function6(eqArrays): Takes 2 arrays and checks the values and the arrays are the same, returns either true or false.
  • function7(eqObjects): Takes 2 objects and checks that they are the same, returns true or false.
  • function8(findKey): Takes an object and checks if the key is in the object, if the key exists it return the key otherwise returns undefined.
  • function9(findKeyByValue): Takes an object and if the value of a key matches, the function returns a key.
  • function10(flatten): Takes an array and flattens it.
  • function11(head): Returns the index 0 of an array.
  • function12(letterPositions): Takes a string and returns an array with the position of the letters.
  • function13(map): Takes an array and a callback function that mutates the input array.
  • function14(middle): Takes an array and if its odd or even it will return one middle value if its odd and 2 middle values if its even.
  • function15(tails): Takes and array and returns everything but the index 0.
  • function16(takeUntil): Takes an array and a function, the array gets traversed until the function matches and then returns the values previous to the match.
  • function17(without): Takes two arrays one that will be sorted and the other the values to be excluded.