lino-levan / astral

A high-level puppeteer/playwright-like library for Deno
https://jsr.io/@astral/astral
MIT License
248 stars 17 forks source link

feat: support async disposing of `Page` and `Browser` #63

Closed marvinhagemeister closed 5 months ago

marvinhagemeister commented 5 months ago

Add support for disposing of Page and Browser instances with the using keyword. It's part of https://github.com/tc39/proposal-explicit-resource-management and it's natively supported in Deno. Allows you to write code like this:

Deno.test("my test", async () => {
   await using browser = await launch();
   await using page = await browser.newPage();

   // No need to manually call page.close() and browser.close()
})