Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextDecoder pollyfill improvement and TypeScript declaration fix for DirHandle #321

Merged
merged 2 commits into from Nov 4, 2022

Conversation

samuelbrian
Copy link
Contributor

Sorry I missed your release with these @saghul.

…. of'

When using the docs TypeScript declaration file, the example async iterator
code...

    const dirIter = await tjs.readdir('.');
    for await (const item of dirIter) {
        console.log(item.name);
    }

...does not compile due to a TypeScript error.

    error TS2504: Type 'DirHandle' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.

The DirHandle must be declared as an AsyncIterableIterator, which the
implementation already satisfies, instead of an AsyncIterator.

The MDN reference on `for await ... of` hints at the need for this:

    Note: for await...of doesn't work with async iterators that are not async iterables.
The UTF-8-only encoder/decoder was performing poorly due to inefficient
array manipulation.
Applied changes from the original text-encoding package that reduce
the amount of copying.

Relates to saghul#316
@saghul
Copy link
Owner

saghul commented Nov 4, 2022

Sorry I missed your release with these @saghul.

No worries, numbers are cheap! 😅

@saghul saghul merged commit ef2f563 into saghul:master Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants