main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var IS_PURE = require('../internals/is-pure');
|
---|
4 | var FORCED_PROMISE_CONSTRUCTOR = require('../internals/promise-constructor-detection').CONSTRUCTOR;
|
---|
5 | var NativePromiseConstructor = require('../internals/promise-native-constructor');
|
---|
6 | var getBuiltIn = require('../internals/get-built-in');
|
---|
7 | var isCallable = require('../internals/is-callable');
|
---|
8 | var defineBuiltIn = require('../internals/define-built-in');
|
---|
9 |
|
---|
10 | var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
|
---|
11 |
|
---|
12 | // `Promise.prototype.catch` method
|
---|
13 | // https://tc39.es/ecma262/#sec-promise.prototype.catch
|
---|
14 | $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
|
---|
15 | 'catch': function (onRejected) {
|
---|
16 | return this.then(undefined, onRejected);
|
---|
17 | }
|
---|
18 | });
|
---|
19 |
|
---|
20 | // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
|
---|
21 | if (!IS_PURE && isCallable(NativePromiseConstructor)) {
|
---|
22 | var method = getBuiltIn('Promise').prototype['catch'];
|
---|
23 | if (NativePromisePrototype['catch'] !== method) {
|
---|
24 | defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
|
---|
25 | }
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.