Created
February 16, 2021 17:58
-
-
Save mattdesl/3e9877f959e4c1b54d33b089138c70c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setup a new encoder with a write callback | |
const enc = Module.create_encoder(writeEncodedData); | |
// do some encoding | |
// ... | |
// dispose encoder | |
Module.free_encoder(enc); | |
// The write callback | |
function writeEncodedData (pointer, size) { | |
// Get the encoded data array | |
const data = Module.HEAPU8.slice(pointer, pointer + size); | |
// And write it to a stream | |
myStream.write(data); | |
return 0; // Write status code 0 = success | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment