suppress

Wraps around a function and suppresses its errors.

Usage no npm install needed!

<script type="module">
  import suppress from 'https://cdn.skypack.dev/suppress';
</script>

README

suppress

A Node.js module that wraps around a function and suppresses whatever errors it might throw.

When suppressing errors from functions that normally return a value, you can optionally specify a "fallback value" to be returned in the event of an error.

Installation

npm install suppress --save

Usage

const suppress = require('suppress')

function thrower () {
  throw new Error()
}

suppress(thrower)() // undefined
suppress(thrower, 'return if error')() // 'return if error'