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

Consider the following change #1

Open
GrosSacASac opened this issue Sep 20, 2022 · 1 comment
Open

Consider the following change #1

GrosSacASac opened this issue Sep 20, 2022 · 1 comment

Comments

@GrosSacASac
Copy link

Make A not a top level

import {QuickReader} from '[quickreader](https://github.com/EtherDream/QuickReader.git)'

const res = await fetch('https://unpkg.com/quickreader-demo/demo.bin')
const stream = res.body   // ReadableStream
const [reader, A] = QuickReader(stream) // now returns an array with both

do {
  const id   = reader.u32() ?? await A
  const name = reader.txt() ?? await A
  const age  = reader.u8()  ?? await A

  console.log(id, name, age)

} while (!reader.eof)
@EtherDream
Copy link
Owner

I plan to use the Reader instance as the thenable object later, which is simpler, e.g.

  const id   = reader.u32() ?? await reader
  const name = reader.txt() ?? await reader
  const age  = reader.u8()  ?? await reader

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

No branches or pull requests

2 participants