MCPcopy Create free account
hub / github.com/Stuk/jszip / StreamHelper

Function StreamHelper

lib/stream/StreamHelper.js:116–144  ·  view source on GitHub ↗

* An helper to easily use workers outside of JSZip. * @constructor * @param {Worker} worker the worker to wrap * @param {String} outputType the type of data expected by the use * @param {String} mimeType the mime type of the content, if applicable.

(worker, outputType, mimeType)

Source from the content-addressed store, hash-verified

114 * @param {String} mimeType the mime type of the content, if applicable.
115 */
116function StreamHelper(worker, outputType, mimeType) {
117 var internalType = outputType;
118 switch(outputType) {
119 case "blob":
120 case "arraybuffer":
121 internalType = "uint8array";
122 break;
123 case "base64":
124 internalType = "string";
125 break;
126 }
127
128 try {
129 // the type used internally
130 this._internalType = internalType;
131 // the type used to output results
132 this._outputType = outputType;
133 // the mime type
134 this._mimeType = mimeType;
135 utils.checkSupport(internalType);
136 this._worker = worker.pipe(new ConvertWorker(internalType));
137 // the last workers can be rewired without issues but we need to
138 // prevent any updates on previous workers.
139 worker.lock();
140 } catch(e) {
141 this._worker = new GenericWorker("error");
142 this._worker.error(e);
143 }
144}
145
146StreamHelper.prototype = {
147 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected