1.0.0 • Published 2 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(arr1, arr2): compares if two arrays are the same, console logs the outcome
  • assertEqual(actual, expected): compares if two values are the same, console logs the outcome
  • assertObjectsEqual(obj1, obj2): compares if two objects are the same, console logs the outcome
  • letterCount(str): returns an object with a count of each letter, spaces are not included
  • countOnly(arr, filterObj): takes in an array of items and a 'filter' object with names as properties and a boolean value, returning an object that counts each name in the argument object with a true value
  • eqArrays(arr1, arr2): returns a boolean if two arrays are the same
  • eqObjects(obj1, obj2): returns a boolean if two objects are the same
  • findKey(obj, callback): return a key of an object matching the returned value of a callback, returns undefined if nothing is found.
  • findKeyByValue(obj, value): returns a key of an object matching the value, returns an empty string if nothing is found.
  • head(arr): returns first element of an array
  • letterPositions(str): returns an object with the index positions of each letter in a string
  • map(arr, callback): applies the callback function onto each item of an array and returns a new array of the outputs
  • middle(arr): returns middle element of an array with an odd number of items, returns an empty array if the number of items is even or 1
  • tail(arr): returns a new array that excludes the first item of the array that was passed
  • takeUntil(arr, callback): mutates an array by removing elements up to the end of the array starting from the value returned by the callback
  • without(arr, arrayofItemsToRemove): returns a new array after removing items that match the array of items to remove
1.0.0

2 years ago