diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64215b7..75088ce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-node@v3 with: - node-version: 18.x + node-version: 20.x registry-url: 'https://registry.npmjs.org' - run: npm version - run: npm install diff --git a/.gitignore b/.gitignore index e833970..6ef090c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ _archive .npmrc* lib docs -_sandbox +# _sandbox diff --git a/_sandbox/using-class.ts b/_sandbox/using-class.ts new file mode 100755 index 0000000..a2edfb2 --- /dev/null +++ b/_sandbox/using-class.ts @@ -0,0 +1,22 @@ +#!/usr/bin/env bun + +/* eslint-disable no-console */ + +class TempFile implements Disposable { + constructor(path: string) { + console.log('2 constructor') + } + + [Symbol.dispose]() { + console.log('4 dispose') + } +} + +function fn() { + using f = new TempFile('abc') + console.log('3 fn return') +} + +console.log('1 fn before') +fn() +console.log('5 fn after') diff --git a/_sandbox/using.ts b/_sandbox/using.ts new file mode 100755 index 0000000..2852303 --- /dev/null +++ b/_sandbox/using.ts @@ -0,0 +1,32 @@ +#!/usr/bin/env bun + +/* eslint-disable no-console */ + +// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html + +// try { +// // @ts-expect-error just a polyfill +// Symbol.dispose ??= Symbol("Symbol.dispose") +// // @ts-expect-error just a polyfill +// Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose") +// } finally { } + +function useTempFile(path: string) { + console.log('2 constructor') + return { + path, + [Symbol.dispose]() { + console.log('4 dispose') + } + } +} + +function fn() { + using f = useTempFile('abc') + console.log('x using return:', f) + console.log('3 fn return') +} + +console.log('1 fn before') +fn() +console.log('5 fn after') diff --git a/package.json b/package.json index 41acf5e..23a5710 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.20.8", + "version": "0.20.9", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick",