Skip to content

Commit

Permalink
Implement FileReader.readAsBinaryString()
Browse files Browse the repository at this point in the history
It was re-added to the specification in w3c/FileAPI#44.
  • Loading branch information
Zirro authored and domenic committed Apr 1, 2018
1 parent d80648f commit 5e86716
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/jsdom/living/file-api/FileReader-impl.js
Expand Up @@ -31,6 +31,9 @@ class FileReaderImpl extends EventTargetImpl {
readAsArrayBuffer(file) {
this._readFile(file, "buffer");
}
readAsBinaryString(file) {
this._readFile(file, "binaryString");
}
readAsDataURL(file) {
this._readFile(file, "dataURL");
}
Expand Down Expand Up @@ -96,6 +99,10 @@ class FileReaderImpl extends EventTargetImpl {
this.result = (new Uint8Array(data)).buffer;
break;
}
case "binaryString": {
this.result = data.toString("binary");
break;
}
case "dataURL": {
// Spec seems very unclear here; see https://github.com/whatwg/fetch/issues/665#issuecomment-362930079.
let dataUrl = "data:";
Expand Down
2 changes: 1 addition & 1 deletion lib/jsdom/living/file-api/FileReader.webidl
Expand Up @@ -3,7 +3,7 @@ interface FileReader: EventTarget {

// async read methods
void readAsArrayBuffer(Blob blob);
// void readAsBinaryString(Blob blob);
void readAsBinaryString(Blob blob);
void readAsText(Blob blob, optional DOMString label);
void readAsDataURL(Blob blob);

Expand Down

0 comments on commit 5e86716

Please sign in to comment.