Skip to content

Commit

Permalink
update the way async disposing of only sync disposable resources
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jan 7, 2025
1 parent 2c3fe4c commit 34e4086
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Added built-ins:
- `Error.isError`
- 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`
- [Explicit Resource Management stage 3 proposal](https://github.com/tc39/proposal-explicit-resource-management):
- 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)
- [`Iterator` sequencing stage 2.7 proposal](https://github.com/tc39/proposal-iterator-sequencing):
- 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
- 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
Expand Down
8 changes: 7 additions & 1 deletion packages/core-js/internals/add-disposable-resource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
var getBuiltIn = require('../internals/get-built-in');
var call = require('../internals/function-call');
var uncurryThis = require('../internals/function-uncurry-this');
var bind = require('../internals/function-bind-context');
Expand All @@ -22,7 +23,12 @@ var getDisposeMethod = function (V, hint) {
method = getMethod(V, DISPOSE);
if (method === undefined) return method;
return function () {
call(method, this);
var O = this;
var Promise = getBuiltIn('Promise');
return new Promise(function (resolve) {
call(method, O);
resolve(undefined);
});
};
} return getMethod(V, DISPOSE);
};
Expand Down

0 comments on commit 34e4086

Please sign in to comment.