1.0.0 • Published 3 years ago

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

Require it:

const _ = require('kjohnstondev/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • assertEqual(actual, expected): This compares two values and returns true or false based on results
  • eqArrays(arr1, arr2): compares two arrays
  • eqObjects(object1, object2): compares two objects
  • assertArraysEqual([arr1], [arr2]): returns true if passed arrays are equal and false if they are not
  • assertObjectsEqual({object1}, {object2}: compares two objects and returns true or false
  • head([arr]): returns the first element of an array
  • tail([arr]): returns everything but the first element of an array
  • middle([arr]): returns the middle element or elements of an array
  • countLetters('string'): returns an object that keeps count of how many times each letter occurs in a string
  • letterPositions('sentence'): returns all the indices in the string where each character is found in an object
  • countOnly([arr], itemsToCount): takes an array and a paramater - returns an object with the counts of matching elements in the array
  • findKey({object}, callback): scans the object and returns the first key that is truthy according to the callback
  • findKeyByValue({object}, val): searches for a key on an object where its value matches a given value
  • map([array], callback): creates a new array with the results of a callback on every element in the array entered
  • takeUntil([array], callback): returns a slice of the array with elements taken from the beginning
  • without([array], itemsToRemove): removes specified elements from an array