Skip to content

Commit

Permalink
ignore return value of [@@dispose]() method when hint is `async-dis…
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jul 19, 2023
1 parent cb0db7c commit 0d62693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- `AsyncIterator.prototype[@@asyncDispose]`
- Moved back into [the initial proposal](https://github.com/tc39/proposal-explicit-resource-management) -> moved to stage 3, [proposal-explicit-resource-management/154](https://github.com/tc39/proposal-explicit-resource-management/pull/154)
- Added `/actual/` namespace entries, disabled forced replacement
- Ignore return value of `[@@dispose]()` method when hint is `async-dispose`, [proposal-explicit-resource-management/180](https://github.com/tc39/proposal-explicit-resource-management/pull/180)
- Added [`DataView` get / set `Uint8Clamped` methods stage 1 proposal](https://github.com/tc39/proposal-dataview-get-set-uint8clamped):
- Methods:
- `DataView.prototype.getUint8Clamped`
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 call = require('../internals/function-call');
var uncurryThis = require('../internals/function-uncurry-this');
var bind = require('../internals/function-bind-context');
var anObject = require('../internals/an-object');
Expand All @@ -13,7 +14,12 @@ var push = uncurryThis([].push);

var getDisposeMethod = function (V, hint) {
if (hint == 'async-dispose') {
return getMethod(V, ASYNC_DISPOSE) || getMethod(V, DISPOSE);
var method = getMethod(V, ASYNC_DISPOSE);
if (method !== undefined) return method;
method = getMethod(V, DISPOSE);
return function () {
call(method, this);
};
} return getMethod(V, DISPOSE);
};

Expand Down

0 comments on commit 0d62693

Please sign in to comment.