Remove nonstandard Promise.prototype.done implementation

Summary:
Changelog:
[General][Breaking] - Remove nonstandard Promise.prototype.done

`Promise.prototype.done` has been deprecated since D34222667 (https://github.com/facebook/react-native/commit/35800962c16a33eb8e9ff1adfd428cf00bb670d3). Here we remove it from React Native's default Promise polyfill. Users should switch to using standard Promise features like `.then()`, or install their own custom polyfills for advanced use cases.

Reviewed By: kodafb

Differential Revision: D36001688

fbshipit-source-id: 37f452000c16279280ef6a50b2ce616776377c4e
This commit is contained in:
Moti Zilberman
2022-05-05 03:55:10 -07:00
committed by Facebook GitHub Bot
parent 20d9d3aa6a
commit 018d5cf985
2 changed files with 0 additions and 33 deletions
-32
View File
@@ -11,7 +11,6 @@
'use strict';
const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
const warnOnce = require('../Utilities/warnOnce');
/**
* Set up Promise. The native Promise implementation throws the following error:
@@ -37,34 +36,3 @@ if (global?.HermesInternal?.hasPromise?.()) {
} else {
polyfillGlobal('Promise', () => require('../Promise'));
}
if (__DEV__) {
// $FlowFixMe
const done = Promise.prototype.done;
if (done != null) {
let depth = 0;
/* eslint-disable no-extend-native */
// $FlowFixMe
Promise.prototype.done = function () {
++depth;
try {
// Avoid infinite recursion if done() happens to be triggered by warnOnce.
if (depth === 1) {
// Warn once per unique call stack. Not super efficient, but we're in
// __DEV__ and .done() calls are rare to begin with.
const key = new Error().stack;
warnOnce(
key,
'Promise.prototype.done(): This nonstandard polyfill ' +
'has been deprecated and will be removed in a future release. ' +
'Please instead use `.then()`.',
);
}
} finally {
--depth;
}
return done.apply(this, arguments);
};
/* eslint-enable no-extend-native */
}
}
-1
View File
@@ -12,7 +12,6 @@
const Promise = require('promise/setimmediate/es6-extensions');
require('promise/setimmediate/done');
require('promise/setimmediate/finally');
if (__DEV__) {