1.0.0 • Published 3 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): return the first element of the array
  • tail(array): return all elements except the first of the array
  • middle(array): return the middle value of the array
  • assertEqual(actual, expected): asserts if 2 values are equal
  • assertArraysEqual(actual, expected): asserts if 2 arrays are equal
  • eqArrays(array1, array2): returns a boolean whether or not an array equals another
  • eqObjects(object1, object2): returns a boolean whether or not an object have the same properties as another
  • assertObjectsEqual(actual, expected): asserts if 2 objects are equal
  • countLetters(string): returns the count of each letter in a string
  • letterPositions(string): returns the location of each letter in a string
  • countOnly(string, char): returns the count of the target character in a string
  • findKey(object, callback): find the key in an object that satisfy the condition given in callback
  • findKeyByValue(object, value): find the key that contains the given value
  • flatten(array): get rid of sub arrays
  • map(array, callback): apply the callback function to every element of an array
  • takeUntil(array, callback): return values of array until callback returns true
  • without(source, toRemove): return a new array with given elements removed from original array