1.0.0 • Published 2 years ago

@rdininno/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): takes in an array and returns the head(first item)
  • tail(array: takes in an array and return everything but the head(first item)
  • middle(array): takes an array and returns an array of the middle values(s)
  • assertArraysEqual(a, b): assertion for comparison of two arrays
  • assertEqual(actual, expected): assertion for equality
  • assertObjectsEqual(actual, expected): assertion for object equality
  • countLetters(string): take a string and returns how many times each letter appears
  • countOnly(array, item): takes an array and counts how many times item appears
  • eqArrays(a, b): compares two arrays for equality. Works with nested arrays
  • eqObjects(object1, object2): compares two objects. works with nested objects
  • findKey(object, callback): finds a key in an object. Takes callback function to find item
  • findKeyByValue(object, val): finds key with given value
  • letterPositions(string): returns the positions of the letters in the given string
  • map(arr, callback): performs a function on every item of an array
  • takeUntil(array, callback): returns array of given array until callback function cuts
  • without(a, b): returns an array without the given value(b) in array(a)