Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.promise.catch.js 1.1KB

1234567891011121314151617181920212223242526
  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. var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
  10. // `Promise.prototype.catch` method
  11. // https://tc39.es/ecma262/#sec-promise.prototype.catch
  12. $({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
  13. 'catch': function (onRejected) {
  14. return this.then(undefined, onRejected);
  15. }
  16. });
  17. // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
  18. if (!IS_PURE && isCallable(NativePromiseConstructor)) {
  19. var method = getBuiltIn('Promise').prototype['catch'];
  20. if (NativePromisePrototype['catch'] !== method) {
  21. defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
  22. }
  23. }