mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
22 lines
381 B
TypeScript
22 lines
381 B
TypeScript
|
class Resource {
|
||
|
[Symbol.dispose]() {
|
||
|
console.log("Disposed");
|
||
|
}
|
||
|
}
|
||
|
class AsyncResource {
|
||
|
async [Symbol.asyncDispose]() {
|
||
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
||
|
console.log("Async disposed");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{
|
||
|
using resource = new Resource();
|
||
|
console.log("A");
|
||
|
}
|
||
|
{
|
||
|
await using resource = new AsyncResource();
|
||
|
console.log("B");
|
||
|
}
|
||
|
console.log("C");
|