1.0.0 • Published 3 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • tail(array): returns every element of the array except te first one
  • middle(array): take in an array and return the middle-most element/s of the given array
  • head(array): returns the first item in the array
  • assertArraysEqual(array1, array2): take in two arrays and console.log an appropriate message to the console
  • assertEqual(actual, expected): compares two values it takes in and print out a message telling us if they match or not
  • assertObjectsEqual(actual, expected): take in two objects and console.log an appropriate message to the console
  • countLetters(string): return count of each letter in a given string
  • countOnly(allItems, itemsToCount): return an object containing counts of everything that the input object listed
  • eqArrays(array1, array2): takes in two arrays and returns true or false, based on a perfect match
  • eqObjects(obj1,obj2): take in two objects and returns true or false, based on a perfect match
  • findkey(obj, callback): takes in an object and a callback and return the first key for which the callback returns a truthy value
  • findKeyByValue(obj, value): given an object and a value will return the key to that value
  • flatten(array): take in an array containing elements including nested arrays of elements, and return a "flattened" version of the array
  • letterPositions(string): return object with positions for every letter in a given string
  • map(array, callback): return a new array based on the results of the callback function
  • takeUntil(array, callback): keep collecting items from a provided array until the callback provided returns a truthy value
  • without(source, itemsToRemove): return a subset of a given array, removing unwanted elements