1.0.0 • Published 3 years ago

@hsharif/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 @hsharif

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): Returns the first element in an array
  • tail(array): Returns the last element in an array
  • middle(array): Returns the middle element of an array when array length is odd and midlle two elements when array length is even
  • assertArraysEqual(array1, array2): Assert test function console.logs() whether two arrays are equal
  • assertEqual(actual, expected): Assert test function console.logs() whether two arguments are strict equal
  • assertObjectsEqual(obj1, obj2): Assert test function console.logs() whether two objects are equal
  • countLetters(string): Returns the amount of letters in a string
  • eqArrays(array1, array2): Returns true if every element in array1 is equal to every element in array2
  • eqObjects(obj1, obj2): Returns true if every key and value from object1 match object2
  • findKey(obj, callback): Returns object key when given the object value passed into the callback function
  • findKeyByValue(obj, value): Return object key when given obj and value
  • letterPositions(string): Returns an object with every letter in the string as keys and how many times that letter occurs in the string as values
  • map(array, callback): Works similar to .map() in js takes in an array and the callback function performs an action of each element of the array and returns the array
  • takeUntil(array, callback): Takes in an array and returns array until value passed into callback function
  • without(source, itemsToRemove): Takes in an array and return new array with items to be removed