electerious / nice-try

Tries to execute a function and discards any error that occurs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Promise support

Richienb opened this issue · comments

It would be useful if nice-try supported promises:

const niceTry = require('nice-try')

const result = await niceTry.promise(async () => {...})

Implementation:

module.exports.promise = async function(fn) {

	try { return await fn() } catch (e) {}

}

// @electerious

Maybe this should be PR instead of an issue; you already have the implementation.

Just published v2.1 🚀