Resource management

Raul-Sebastian Mihăilă raul.mihaila at gmail.com
Wed Dec 28 12:30:34 UTC 2016


Such a protocol would make sense only if new specific syntax was added to
the language. But is that really necessary when this can be implemented
very easily without new syntax?

```js
async function open(file, opts, func) {
  const fd = await fsp.open(file, opts);

  await func(fd);
  await fsp.close(fd);
}

await open("/path/to/file", {mode: "r+"}, async function (fd) {
  const bit = await fsp.read(fd);
});
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161228/0ac85207/attachment.html>


More information about the es-discuss mailing list