Re: [web-nfc] Investigate if/how CompressStream/DecompressStream can be used with Web NFC (#321)

It would be nice to easily compress data we are writing to tags but an async streams doesn't work for us as all data needs to be ready when the write happens.

It is probably going to be something like

```
let data = ...
const cs = new CompressStream();
const readable = new Blob(data).stream().pipeThrough(cs);

 while (true) {
    const { value, done } = await reader.read();
    if (done)
      break;
    out.push(value);
    totalSize += value.byteLength;
  }
  const concatenated = new Uint8Array(totalSize);
  let offset = 0;
  for (const array of out) {
    concatenated.set(array, offset);
    offset += array.byteLength;
  }
  return concatenated;
```

-- 
GitHub Notification of comment by kenchris
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/321#issuecomment-526535125 using your GitHub account

Received on Friday, 30 August 2019 09:36:25 UTC