Commit 7c775061 authored by Jonathan Essex's avatar Jonathan Essex 💬

removed Blob from implementation due to cross-platform issues

parent 2b9d745a
......@@ -6,7 +6,6 @@
const { Tokenizer } = require("./tokenizer.js");
const { Parser } = require("./parser.js");
const { Decoder } = require("./decoder.js");
const Blob = require("cross-blob");
function createHeaderSink(callback, encoding) {
return new Decoder(new Tokenizer(new Parser(callback)), encoding);
......@@ -26,19 +25,19 @@ function createBodySink(callback, length) {
}
length -= written;
if (length === 0) {
callback(new Blob(chunks));
callback(chunks);
}
return written;
},
close: () => {
callback(new Blob(chunks));
callback(chunks);
}
};
}
class BlockWriter {
constructor(callback, encoding) {
constructor(callback, encoding, bodyHandler) {
this.encoding = encoding;
this.callback = callback;
this.sink = createHeaderSink(hdr=>this.receiveHeader(hdr), this.encoding);
......
......@@ -9,11 +9,14 @@
const { BlockWriter } = require("../../index.js");
const { getFile } = require("./utils.js");
const { WritableStream } = require("web-streams-polyfill/ponyfill")
const { WritableStream } = require("web-streams-polyfill/ponyfill");
const Blob = require("cross-blob");
function readAll(data) {
let blocks = [];
let callback = (header, blob) => { blocks.push({header, blob}); };
let callback = (header, chunks) => {
blocks.push({header, blob: new Blob(chunks)});
};
let writer = new BlockWriter(callback, "utf-8");
writer.write(data);
writer.close();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment