JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2196
  • Score
    100M100P100Q112106F
  • License MIT

Executes fallback behavior if a function was unsuccessful.

Package Exports

  • otherwise

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (otherwise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

otherwise

Executes fallback behavior if a function was unsuccessful. Intended for use in modules that use option object arguments.

Installation

Requires Node.js 6.0.0 or above.

npm i otherwise

API

The module exports a single function.

Parameters

  1. Optional: Object argument:
    • elseCall (function): If provided, this function will be called with at least one argument: a function that will invoke the other fallbacks. (If args are specified, they will be provided as subsequent arguments.) If the function argument is not called, then elseThrow and elseReturn will not be taken into consideration, and the return value of the elseCall function will be forwarded.
    • elseThrow (Error or string): An error to be thrown. A string will be wrapped in an Error object automatically.
    • elseReturn (any): A value to return if elseThrow is omitted.
  2. Optional: Object argument:
    • defaultErrorClass (Class): An Error class in which to wrap elseThrow if it is a string.
    • args (array): An array of arguments that should be passed on to elseCall if provided.

Return Value

Returns the return value of elseCall (if provided) or returns elseReturn.