1.0.0 • Published 3 years ago

onaolapodave-lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
-
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 @onaolapodave/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head([arr]): Takes an array and returns the first element.
  • tail([arr]): Takes an array, removes the first element and returns the rest.
  • middle([arr]]): Takes an array, if the length is odd, it returns an array with just the mid value, else it returns an array wit both mid values.
  • assertArraysEqual([arr1], [arr2]): Assertion test. Takes two arrays, passes if they are strictly equal.
  • assertEqual(x,y): Assertion test. Takes two primitive types, passes if they are strictly equal.
  • assertObjectsEqual(obj1, obj2): Assertion test. Takes two objects, passes if they are strictly equal.
  • countLetters(str): Takes a string, returns all letters in the string, doesn't count spaces.
  • countOnly([arr], [obj]): Takes an array and an object indicating either true or false. Counts only the array values that have a true object value. Returns an object of the count.
  • eqArrays([arr], [arr]): Takes two arrays, returns true if they are strictly equal.
  • eqObjects([obj], [obj]): Takes two objects, returns true if they are strictly equal.
  • findKey([obj], callback): Takes an object and a callback function. Finds and returns the first key that returns true from the callback.
  • findKeyByValue([obj], val): Takes an object and a value. Returns the first key that points to that value.
  • letterPositions(str): Takes a string. Returns the position of each letter in an object.
  • without([arr], val): Takes an array and a value to be removed from the array. Returns an array with all instances of the value removed.
  • map([arr], callback): Implements the javascript method.
  • takeUntil([arr], callback): Takes an array and a callback function. Returns an array of all the elements before the callback function returns true.