Skip to content

v1.2.188

Compare
Choose a tag to compare
@ackava ackava released this 12 Sep 10:18
· 21 commits to main since this release
a7bb507

New Features

Explicit Resource Management

  1. Support for Symbol.dispose and Symbol.asyncDisposable.
  2. Support for using constResource = and await using constResource = syntax to enable disposable stack in current scope.
  3. Support for CLR IDisposable and IAsyncDisposable marshaling with automatic mapping for JavaScript's disposable symbols.

Example

Disposable implementation

class File {

    [Symbol.dispose]() {
       // close the file handle...
    }
}

function writeText(filePath, text) {
     using s = new File(filePath);
     s.writeText(text);
}

AsyncDisposable implementation

class File {

    async [Symbol.asyncDispose]() {
       // close the file handle...
    }
}

async function writeText(filePath, text) {
     await using s = new File(filePath);
     s.writeText(text);
}

What's Changed

Full Changelog: v1.2.176...v1.2.188