(self, thenable)
| 4689 | } |
| 4690 | |
| 4691 | function safelyResolveThenable(self, thenable) { |
| 4692 | // Either fulfill, reject or reject with error |
| 4693 | var called = false; |
| 4694 | function onError(value) { |
| 4695 | if (called) { |
| 4696 | return; |
| 4697 | } |
| 4698 | called = true; |
| 4699 | handlers.reject(self, value); |
| 4700 | } |
| 4701 | |
| 4702 | function onSuccess(value) { |
| 4703 | if (called) { |
| 4704 | return; |
| 4705 | } |
| 4706 | called = true; |
| 4707 | handlers.resolve(self, value); |
| 4708 | } |
| 4709 | |
| 4710 | function tryToUnwrap() { |
| 4711 | thenable(onSuccess, onError); |
| 4712 | } |
| 4713 | |
| 4714 | var result = tryCatch(tryToUnwrap); |
| 4715 | if (result.status === 'error') { |
| 4716 | onError(result.value); |
| 4717 | } |
| 4718 | } |
| 4719 | |
| 4720 | function tryCatch(func, value) { |
| 4721 | var out = {}; |
no test coverage detected