disposablestack
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -8,3 +8,3 @@ 'use strict'; | ||
var Type = require('es-abstract/2022/Type'); | ||
var Type = require('es-abstract/2023/Type'); | ||
@@ -27,20 +27,24 @@ var CreateDisposableResource = require('./CreateDisposableResource'); | ||
if (!disposeCapability['[[DisposableResourceStack]]']) { | ||
throw new $TypeError('Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~empty~'); | ||
} | ||
var resource; | ||
if (arguments.length < 4) { | ||
if (arguments.length < 4) { // step 2 | ||
if (V == null) { | ||
return 'unused'; // step 1.a | ||
return 'unused'; // step 2.a | ||
} | ||
if (Type(V) !== 'Object') { | ||
throw new $TypeError('`V` must be an Object'); // step 1.b | ||
throw new $TypeError('`V` must be an Object'); // step 2.b | ||
} | ||
resource = CreateDisposableResource(V, hint); // step 1.c | ||
} else { // step 2 | ||
resource = CreateDisposableResource(V, hint); // step 2.c | ||
} else { // step 3 | ||
if (typeof V !== 'undefined') { | ||
throw new $TypeError('Assertion failed: `V` must be undefined when `method` is present'); // step 2.a | ||
throw new $TypeError('Assertion failed: `V` must be undefined when `method` is present'); // step 3.a | ||
} | ||
resource = CreateDisposableResource(void undefined, hint, method); // step 2.b | ||
resource = CreateDisposableResource(void undefined, hint, method); // step 3.b | ||
} | ||
$push(disposeCapability['[[DisposableResourceStack]]'], resource); // step 3 | ||
$push(disposeCapability['[[DisposableResourceStack]]'], resource); // step 4 | ||
return 'unused'; // step 4 | ||
return 'unused'; // step 5 | ||
}; |
@@ -8,4 +8,4 @@ 'use strict'; | ||
var IsCallable = require('es-abstract/2022/IsCallable'); | ||
var Type = require('es-abstract/2022/Type'); | ||
var IsCallable = require('es-abstract/2023/IsCallable'); | ||
var Type = require('es-abstract/2023/Type'); | ||
@@ -12,0 +12,0 @@ var GetDisposeMethod = require('./GetDisposeMethod'); |
@@ -8,5 +8,5 @@ 'use strict'; | ||
var Call = require('es-abstract/2022/Call'); | ||
var PromiseResolve = require('es-abstract/2022/PromiseResolve'); | ||
var Type = require('es-abstract/2022/Type'); | ||
var Call = require('es-abstract/2023/Call'); | ||
var PromiseResolve = require('es-abstract/2023/PromiseResolve'); | ||
var Type = require('es-abstract/2023/Type'); | ||
@@ -13,0 +13,0 @@ module.exports = function Dispose(V, hint, method) { |
@@ -12,7 +12,7 @@ 'use strict'; | ||
var CompletionRecord = require('es-abstract/2022/CompletionRecord'); | ||
var CompletionRecord = require('es-abstract/2023/CompletionRecord'); | ||
var Dispose = require('./Dispose'); | ||
var NormalCompletion = require('es-abstract/2022/NormalCompletion'); | ||
var PromiseResolve = require('es-abstract/2022/PromiseResolve'); | ||
var ThrowCompletion = require('es-abstract/2022/ThrowCompletion'); | ||
var NormalCompletion = require('es-abstract/2023/NormalCompletion'); | ||
var PromiseResolve = require('es-abstract/2023/PromiseResolve'); | ||
var ThrowCompletion = require('es-abstract/2023/ThrowCompletion'); | ||
@@ -29,2 +29,6 @@ var SuppressedError = require('suppressed-error/polyfill')(); | ||
if (!stack) { | ||
throw new $TypeError('Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~empty~'); // step 1 | ||
} | ||
// for DisposableStack or AsyncDisposableStack, all are sync, or all are async. | ||
@@ -45,10 +49,10 @@ // Only an environment record, via `using` and `await using`, can mix sync and async. | ||
var rejecter = function (e) { | ||
if (completion.type() === 'throw') { // step 1.b.i | ||
var suppressed = completion.value(); // step 1.b.i.2 | ||
var error = new SuppressedError(e, suppressed); // steps 1.b.i.1, 1.b.i.3 - 1.b.i.5 | ||
if (completion.type() === 'throw') { // step 2.b.i | ||
var suppressed = completion.value(); // step 2.b.i.2 | ||
var error = new SuppressedError(e, suppressed); // steps 2.b.i.1, 2.b.i.3 - 2.b.i.5 | ||
// eslint-disable-next-line no-param-reassign | ||
completion = ThrowCompletion(error); // step 1.b.i.6 | ||
} else { // step 1.b.ii | ||
completion = ThrowCompletion(error); // step 2.b.i.6 | ||
} else { // step 2.b.ii | ||
// eslint-disable-next-line no-param-reassign | ||
completion = ThrowCompletion(e); // step 1.b.ii.1 | ||
completion = ThrowCompletion(e); // step 2.b.ii.1 | ||
} | ||
@@ -61,3 +65,3 @@ }; | ||
function () { | ||
var result = Dispose( // step 1.a | ||
var result = Dispose( // step 2.a | ||
resource['[[ResourceValue]]'], | ||
@@ -76,3 +80,3 @@ resource['[[Hint]]'], | ||
for (var i = stack.length - 1; i >= 0; i -= 1) { // step 1 | ||
for (var i = stack.length - 1; i >= 0; i -= 1) { // step 2 | ||
if (actualHint === 'async-dispose') { | ||
@@ -83,3 +87,3 @@ promise = getPromise(stack[i]); | ||
try { | ||
var result = Dispose( // step 1.a | ||
var result = Dispose( // step 2.a | ||
resource['[[ResourceValue]]'], | ||
@@ -98,3 +102,6 @@ resource['[[Hint]]'], | ||
return actualHint === 'async-dispose' ? promise : completion; // step 2 | ||
// eslint-disable-next-line no-param-reassign | ||
disposeCapability['[[DisposableResourceStack]]'] = null; // step 3 | ||
return actualHint === 'async-dispose' ? promise : completion; // step 4 | ||
}; |
@@ -8,4 +8,4 @@ 'use strict'; | ||
var GetMethod = require('es-abstract/2022/GetMethod'); | ||
var Type = require('es-abstract/2022/Type'); | ||
var GetMethod = require('es-abstract/2023/GetMethod'); | ||
var Type = require('es-abstract/2023/Type'); | ||
@@ -12,0 +12,0 @@ var symbolDispose = require('../Symbol.dispose/polyfill')(); |
@@ -12,10 +12,10 @@ 'use strict'; | ||
var AddDisposableResource = require('../aos/AddDisposableResource'); | ||
var Call = require('es-abstract/2022/Call'); | ||
var CreateMethodProperty = require('es-abstract/2022/CreateMethodProperty'); | ||
var DefinePropertyOrThrow = require('es-abstract/2022/DefinePropertyOrThrow'); | ||
var Call = require('es-abstract/2023/Call'); | ||
var CreateMethodProperty = require('es-abstract/2023/CreateMethodProperty'); | ||
var DefinePropertyOrThrow = require('es-abstract/2023/DefinePropertyOrThrow'); | ||
var DisposeResources = require('../aos/DisposeResources'); | ||
var IsCallable = require('es-abstract/2022/IsCallable'); | ||
var IsCallable = require('es-abstract/2023/IsCallable'); | ||
var NewDisposeCapability = require('../aos/NewDisposeCapability'); | ||
var NormalCompletion = require('es-abstract/2022/NormalCompletion'); | ||
var PromiseResolve = require('es-abstract/2022/PromiseResolve'); | ||
var NormalCompletion = require('es-abstract/2023/NormalCompletion'); | ||
var PromiseResolve = require('es-abstract/2023/PromiseResolve'); | ||
@@ -22,0 +22,0 @@ var SLOT = require('internal-slot'); |
@@ -8,2 +8,15 @@ # Changelog | ||
## [v1.1.1](https://github.com/es-shims/DisposableStack/compare/v1.1.0...v1.1.1) - 2023-07-24 | ||
### Commits | ||
- [Deps] update `es-abstract` [`4251c56`](https://github.com/es-shims/DisposableStack/commit/4251c56f0d73a6b09a79eee099e0d0f270e969f5) | ||
- [Refactor] empty out DisposableStack slot on dispose [`4d67178`](https://github.com/es-shims/DisposableStack/commit/4d67178fc7878eb0cf0a88ee84131e0acf72c725) | ||
- [Tests] add some coverage [`001e23c`](https://github.com/es-shims/DisposableStack/commit/001e23cff7b94b29ef5098d2b0b256c23fb85b27) | ||
- [readme] fix package name [`52002d1`](https://github.com/es-shims/DisposableStack/commit/52002d1440b7fa4702e48efa44e9c64d1023c3a8) | ||
- [Tests] node v20.4 ships Symbol dispose polyfills that are registered symbols [`37709d2`](https://github.com/es-shims/DisposableStack/commit/37709d2aa6066952148237beaf086597f4b2aa78) | ||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `tape` [`4716a40`](https://github.com/es-shims/DisposableStack/commit/4716a4033ad2eaff18c02a41d1b9fc7df322e7e2) | ||
- [Dev Deps] update `tape` [`85c5033`](https://github.com/es-shims/DisposableStack/commit/85c503392126770c984b826f281003305cf7b664) | ||
- [Deps] update `get-intrinsic` [`a3b63e2`](https://github.com/es-shims/DisposableStack/commit/a3b63e2de49b93b300cd900c05f35d6cb455e945) | ||
## [v1.1.0](https://github.com/es-shims/DisposableStack/compare/v1.0.0...v1.1.0) - 2023-04-12 | ||
@@ -10,0 +23,0 @@ |
@@ -10,7 +10,7 @@ 'use strict'; | ||
var Call = require('es-abstract/2022/Call'); | ||
var CreateMethodProperty = require('es-abstract/2022/CreateMethodProperty'); | ||
var DefinePropertyOrThrow = require('es-abstract/2022/DefinePropertyOrThrow'); | ||
var IsCallable = require('es-abstract/2022/IsCallable'); | ||
var NormalCompletion = require('es-abstract/2022/NormalCompletion'); | ||
var Call = require('es-abstract/2023/Call'); | ||
var CreateMethodProperty = require('es-abstract/2023/CreateMethodProperty'); | ||
var DefinePropertyOrThrow = require('es-abstract/2023/DefinePropertyOrThrow'); | ||
var IsCallable = require('es-abstract/2023/IsCallable'); | ||
var NormalCompletion = require('es-abstract/2023/NormalCompletion'); | ||
@@ -17,0 +17,0 @@ var SLOT = require('internal-slot'); |
{ | ||
"name": "disposablestack", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "An ESnext spec-compliant `DisposableStack`, `AsyncDisposableStack`, `Symbol.dispose`, and `Symbol.asyncDispose` shim/polyfill/replacement that works as far down as ES3.", | ||
@@ -71,5 +71,5 @@ "main": "index.json", | ||
"define-properties": "^1.2.0", | ||
"es-abstract": "^1.21.2", | ||
"es-abstract": "^1.22.1", | ||
"es-set-tostringtag": "^2.0.1", | ||
"get-intrinsic": "^1.2.0", | ||
"get-intrinsic": "^1.2.1", | ||
"has-symbols": "^1.0.3", | ||
@@ -80,5 +80,5 @@ "internal-slot": "^1.0.5", | ||
"devDependencies": { | ||
"@es-shims/api": "^2.3.1", | ||
"@ljharb/eslint-config": "^21.0.1", | ||
"aud": "^2.0.2", | ||
"@es-shims/api": "^2.4.2", | ||
"@ljharb/eslint-config": "^21.1.0", | ||
"aud": "^2.0.3", | ||
"auto-changelog": "^2.4.0", | ||
@@ -97,3 +97,4 @@ "es-value-fixtures": "^1.4.2", | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.6.3" | ||
"semver": "^6.3.1", | ||
"tape": "^5.6.6" | ||
}, | ||
@@ -100,0 +101,0 @@ "auto-changelog": { |
@@ -21,3 +21,3 @@ # disposablestack <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
```sh | ||
npm install --save disposable-stack | ||
npm install --save disposablestack | ||
``` | ||
@@ -30,3 +30,3 @@ | ||
require('disposable-stack/auto'); | ||
require('disposablestack/auto'); | ||
@@ -56,3 +56,3 @@ assert.equal(typeof Symbol.dispose, 'symbol'); | ||
[package-url]: https://npmjs.org/package/disposable-stack | ||
[package-url]: https://npmjs.org/package/disposablestack | ||
[npm-version-svg]: https://versionbadg.es/es-shims/DisposableStack.svg | ||
@@ -63,7 +63,7 @@ [deps-svg]: https://david-dm.org/es-shims/DisposableStack.svg | ||
[dev-deps-url]: https://david-dm.org/es-shims/DisposableStack#info=devDependencies | ||
[npm-badge-png]: https://nodei.co/npm/disposable-stack.png?downloads=true&stars=true | ||
[license-image]: https://img.shields.io/npm/l/disposable-stack.svg | ||
[npm-badge-png]: https://nodei.co/npm/disposablestack.png?downloads=true&stars=true | ||
[license-image]: https://img.shields.io/npm/l/disposablestack.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: https://img.shields.io/npm/dm/disposable-stack.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=disposable-stack | ||
[downloads-image]: https://img.shields.io/npm/dm/disposablestack.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=disposablestack | ||
[codecov-image]: https://codecov.io/gh/es-shims/DisposableStack/branch/main/graphs/badge.svg | ||
@@ -70,0 +70,0 @@ [codecov-url]: https://app.codecov.io/gh/es-shims/DisposableStack/ |
'use strict'; | ||
var hasSymbols = require('has-symbols'); | ||
var DefinePropertyOrThrow = require('es-abstract/2022/DefinePropertyOrThrow'); | ||
var DefinePropertyOrThrow = require('es-abstract/2023/DefinePropertyOrThrow'); | ||
@@ -6,0 +6,0 @@ var polyfill = require('./polyfill'); |
'use strict'; | ||
var hasSymbols = require('has-symbols'); | ||
var DefinePropertyOrThrow = require('es-abstract/2022/DefinePropertyOrThrow'); | ||
var DefinePropertyOrThrow = require('es-abstract/2023/DefinePropertyOrThrow'); | ||
@@ -6,0 +6,0 @@ var polyfill = require('./polyfill'); |
@@ -12,2 +12,3 @@ 'use strict'; | ||
var v = require('es-value-fixtures'); | ||
var semver = require('semver'); | ||
@@ -560,3 +561,3 @@ module.exports = { | ||
t.test('dispose', { skip: typeof Promise !== 'function' }, function (st) { | ||
t.test('disposeAsync', { skip: typeof Promise !== 'function' }, function (st) { | ||
var disposed = new AsyncDisposableStack(); | ||
@@ -585,2 +586,16 @@ return disposed.disposeAsync().then(function () { | ||
st.equal(instance.disposed, true, 'stack is now disposed'); | ||
// test262: test/built-ins/AsyncDisposableStack/prototype/disposeAsync/Symbol.asyncDispose-method-not-async.js | ||
var resource = { | ||
disposed: false | ||
}; | ||
resource[Symbol.asyncDispose] = function () { | ||
this.disposed = true; | ||
}; | ||
var stack = new AsyncDisposableStack(); | ||
stack.use(resource); | ||
return stack.disposeAsync().then(function () { | ||
st.equal(resource.disposed, true, 'Expected resource to have been disposed'); | ||
}); | ||
}); | ||
@@ -605,3 +620,7 @@ }); | ||
st.ok(isSymbol(symbolDispose), 'is a symbol'); | ||
st.notOk(isRegisteredSymbol(symbolDispose), 'is not a registered symbol'); | ||
st.notOk( | ||
isRegisteredSymbol(symbolDispose), | ||
'is not a registered symbol', | ||
{ skip: semver.satisfies(process.version, '>= 20.4') ? 'node ships a Symbol.dispose polyfill that is registered' : false } | ||
); | ||
@@ -623,3 +642,7 @@ st.end(); | ||
st.ok(isSymbol(symbolAsyncDispose), 'is a symbol'); | ||
st.notOk(isRegisteredSymbol(symbolAsyncDispose), 'is not a registered symbol'); | ||
st.notOk( | ||
isRegisteredSymbol(symbolAsyncDispose), | ||
'is not a registered symbol', | ||
{ skip: semver.satisfies(process.version, '>= 20.4') ? 'node ships a Symbol.dispose polyfill that is registered' : false } | ||
); | ||
@@ -626,0 +649,0 @@ st.end(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56786
1204
18
Updatedes-abstract@^1.22.1
Updatedget-intrinsic@^1.2.1