Skip to content

Commit 197ec21

Browse files
committed
Updated our JavaScript playground.
1 parent 6c7a22d commit 197ec21

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

tests/bindings/javascript/res/res/libopencor.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,13 @@ $(() => {
203203

204204
fileReader.readAsArrayBuffer(inputFile);
205205

206-
fileReader.onload = async () => {
206+
fileReader.onload = () => {
207207
try {
208-
// Retrieve the contents of the file.
209-
210-
const fileArrayBuffer = await inputFile.arrayBuffer();
211-
const memPtr = loc._malloc(inputFile.size);
212-
const mem = new Uint8Array(loc.HEAPU8.buffer, memPtr, inputFile.size);
213-
214-
mem.set(new Uint8Array(fileArrayBuffer));
208+
// Retrieve the contents of the file and pass a Uint8Array to the binding.
215209

216210
file = new loc.File(inputFile.name);
217211

218-
file.setContents(memPtr, inputFile.size);
212+
file.setContents(new Uint8Array(fileReader.result));
219213

220214
// Determine the type of the file.
221215

0 commit comments

Comments
 (0)