* 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)
| 114 | * @param {String} mimeType the mime type of the content, if applicable. |
| 115 | */ |
| 116 | function 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 | |
| 146 | StreamHelper.prototype = { |
| 147 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected