mirror of
https://github.com/appy-one/acebase.git
synced 2026-06-30 06:02:02 -06:00
Promise.try shim
This commit is contained in:
parent
6d5956abfd
commit
ff2b8fac7a
1 changed files with 9 additions and 0 deletions
9
src/promise-try-shim.js
Normal file
9
src/promise-try-shim.js
Normal file
|
|
@ -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());
|
||||
});
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue