From e93d686e9d5e797f7e4e02bda56a8b6d535326ca Mon Sep 17 00:00:00 2001 From: Kyra Date: Sun, 4 Nov 2018 19:05:02 +0100 Subject: Web APIs: `File` and `FormData` (#1056) --- js/blob.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/blob.ts') diff --git a/js/blob.ts b/js/blob.ts index b57452dd5..8dcc48ba2 100644 --- a/js/blob.ts +++ b/js/blob.ts @@ -97,6 +97,12 @@ function toUint8Arrays( ret.push(element[bytesSymbol]); } else if (element instanceof Uint8Array) { ret.push(element); + } else if (element instanceof Uint16Array) { + const uint8 = new Uint8Array(element.buffer); + ret.push(uint8); + } else if (element instanceof Uint32Array) { + const uint8 = new Uint8Array(element.buffer); + ret.push(uint8); } else if (ArrayBuffer.isView(element)) { // Convert view to Uint8Array. const uint8 = new Uint8Array(element.buffer); @@ -105,6 +111,8 @@ function toUint8Arrays( // Create a new Uint8Array view for the given ArrayBuffer. const uint8 = new Uint8Array(element); ret.push(uint8); + } else { + ret.push(enc.encode(String(element))); } } return ret; -- cgit v1.2.3