diff --git a/src/promise-try-shim.js b/src/promise-try-shim.js new file mode 100644 index 0000000..aa69b9d --- /dev/null +++ b/src/promise-try-shim.js @@ -0,0 +1,9 @@ +// Polyfill for Promise.try, promisifies synchronous code, +// resolving with function's return value and catching synchronous errors with a promise rejection +if (!Promise.try) { + Promise.try = function(fn) { + return new Promise(resolve => { + resolve(fn()); + }); + }; +} \ No newline at end of file