mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* rename proposal-explicit-resource-management to transform-explicit-resource-management * update library description * bump Babel/core version requirements to ^7.23.9 * add deprecation reminder * remove outdated reminders * update reminder date
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
return (async function () {
|
|
let log = [];
|
|
|
|
function disposable(name, symbolName, cb){
|
|
return {
|
|
async [Symbol[symbolName] || Symbol.for("Symbol." + symbolName)]() {
|
|
log.push(name);
|
|
if (cb) cb();
|
|
}
|
|
};
|
|
}
|
|
|
|
let inBmicrotick = false;
|
|
let inBmicrotickWhileC = false;
|
|
let inBmicrotickWhileD = false;
|
|
let inBmicrotickWhileE = false;
|
|
{
|
|
using e = disposable("e", "dispose", () => {
|
|
inBmicrotickWhileE = inBmicrotick;
|
|
});
|
|
await using d = disposable("d", "asyncDispose", () => {
|
|
inBmicrotickWhileD = inBmicrotick;
|
|
});
|
|
using c = disposable("c", "dispose", () => {
|
|
inBmicrotickWhileC = inBmicrotick;
|
|
});
|
|
using b = disposable("b", "dispose", () => {
|
|
inBmicrotick = true;
|
|
Promise.resolve().then(() => {
|
|
inBmicrotick = false;
|
|
});
|
|
});
|
|
await using a = disposable("a", "asyncDispose");
|
|
}
|
|
|
|
expect(log).toEqual(["a", "b", "c", "d", "e"]);
|
|
expect(inBmicrotick).toBe(false);
|
|
expect(inBmicrotickWhileC).toBe(true);
|
|
expect(inBmicrotickWhileD).toBe(true);
|
|
expect(inBmicrotickWhileE).toBe(false);
|
|
})();
|