Skip to content

Commit

Permalink
Update: Blob-impl.js: Add text() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ArpanSolanki29 committed Apr 20, 2024
1 parent 9e99c6c commit f3a801a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/jsdom/living/file-api/Blob-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,17 @@ exports.implementation = class BlobImpl {
blob._buffer = slicedBuffer;
return blob;
}

text() {
const decoder = new TextDecoder("utf-8");
const buffer = this._buffer;

return new Promise((resolve, reject) => {
try {
resolve(decoder.decode(buffer));
} catch (e) {
reject(e);
}
});
}
};

0 comments on commit f3a801a

Please sign in to comment.