Skip to content

Commit 34e4086

Browse files
committed
update the way async disposing of only sync disposable resources
tc39/proposal-explicit-resource-management#218
1 parent 2c3fe4c commit 34e4086

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
- Added built-ins:
55
- `Error.isError`
66
- We have no bulletproof way to polyfill this method / check if the object is an error, so it's an enough naive implementation that is marked as `.sham`
7+
- [Explicit Resource Management stage 3 proposal](https://github.com/tc39/proposal-explicit-resource-management):
8+
- Updated the way async disposing of only sync disposable resources, [tc39/proposal-explicit-resource-management/218](https://github.com/tc39/proposal-explicit-resource-management/pull/218)
79
- [`Iterator` sequencing stage 2.7 proposal](https://github.com/tc39/proposal-iterator-sequencing):
810
- Reuse `IteratorResult` objects when possible, [tc39/proposal-iterator-sequencing/17](https://github.com/tc39/proposal-iterator-sequencing/issues/17), [tc39/proposal-iterator-sequencing/18](https://github.com/tc39/proposal-iterator-sequencing/pull/18), December 2024 TC39 meeting
911
- Added a fix of [V8 < 12.8](https://issues.chromium.org/issues/351332634) / [NodeJS < 22.10](https://github.com/nodejs/node/pull/54883) bug with handling infinite length of set-like objects in `Set` methods

packages/core-js/internals/add-disposable-resource.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
var getBuiltIn = require('../internals/get-built-in');
23
var call = require('../internals/function-call');
34
var uncurryThis = require('../internals/function-uncurry-this');
45
var bind = require('../internals/function-bind-context');
@@ -22,7 +23,12 @@ var getDisposeMethod = function (V, hint) {
2223
method = getMethod(V, DISPOSE);
2324
if (method === undefined) return method;
2425
return function () {
25-
call(method, this);
26+
var O = this;
27+
var Promise = getBuiltIn('Promise');
28+
return new Promise(function (resolve) {
29+
call(method, O);
30+
resolve(undefined);
31+
});
2632
};
2733
} return getMethod(V, DISPOSE);
2834
};

0 commit comments

Comments
 (0)