@leofcoin/codec-format-interface 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +4228 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.js +457 -528
- package/dist/index.js.map +1 -0
- package/dist/module.js +424 -4778
- package/dist/module.js.map +1 -0
- package/package.json +16 -2
package/dist/browser.js
ADDED
|
@@ -0,0 +1,4228 @@
|
|
|
1
|
+
import * as $gHtSl$buffer from "buffer";
|
|
2
|
+
import {nextTick as $gHtSl$nextTick, stdout as $gHtSl$stdout, stderr as $gHtSl$stderr} from "process";
|
|
3
|
+
import {EventEmitter as $gHtSl$EventEmitter} from "events";
|
|
4
|
+
|
|
5
|
+
var $parcel$global =
|
|
6
|
+
typeof globalThis !== 'undefined'
|
|
7
|
+
? globalThis
|
|
8
|
+
: typeof self !== 'undefined'
|
|
9
|
+
? self
|
|
10
|
+
: typeof window !== 'undefined'
|
|
11
|
+
? window
|
|
12
|
+
: typeof global !== 'undefined'
|
|
13
|
+
? global
|
|
14
|
+
: {};
|
|
15
|
+
function $parcel$export(e, n, v, s) {
|
|
16
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
17
|
+
}
|
|
18
|
+
function $parcel$interopDefault(a) {
|
|
19
|
+
return a && a.__esModule ? a.default : a;
|
|
20
|
+
}
|
|
21
|
+
var $parcel$modules = {};
|
|
22
|
+
var $parcel$inits = {};
|
|
23
|
+
|
|
24
|
+
var parcelRequire = $parcel$global["parcelRequire8c5b"];
|
|
25
|
+
if (parcelRequire == null) {
|
|
26
|
+
parcelRequire = function(id) {
|
|
27
|
+
if (id in $parcel$modules) {
|
|
28
|
+
return $parcel$modules[id].exports;
|
|
29
|
+
}
|
|
30
|
+
if (id in $parcel$inits) {
|
|
31
|
+
var init = $parcel$inits[id];
|
|
32
|
+
delete $parcel$inits[id];
|
|
33
|
+
var module = {id: id, exports: {}};
|
|
34
|
+
$parcel$modules[id] = module;
|
|
35
|
+
init.call(module.exports, module, module.exports);
|
|
36
|
+
return module.exports;
|
|
37
|
+
}
|
|
38
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
39
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
40
|
+
throw err;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
parcelRequire.register = function register(id, init) {
|
|
44
|
+
$parcel$inits[id] = init;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
$parcel$global["parcelRequire8c5b"] = parcelRequire;
|
|
48
|
+
}
|
|
49
|
+
parcelRequire.register("O0X0N", function(module, exports) {
|
|
50
|
+
module.exports = $0965686fca2f0b23$var$encode;
|
|
51
|
+
var $0965686fca2f0b23$var$MSB = 0x80, $0965686fca2f0b23$var$REST = 0x7F, $0965686fca2f0b23$var$MSBALL = ~$0965686fca2f0b23$var$REST, $0965686fca2f0b23$var$INT = Math.pow(2, 31);
|
|
52
|
+
function $0965686fca2f0b23$var$encode(num, out, offset) {
|
|
53
|
+
if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) {
|
|
54
|
+
$0965686fca2f0b23$var$encode.bytes = 0;
|
|
55
|
+
throw new RangeError("Could not encode varint");
|
|
56
|
+
}
|
|
57
|
+
out = out || [];
|
|
58
|
+
offset = offset || 0;
|
|
59
|
+
var oldOffset = offset;
|
|
60
|
+
while(num >= $0965686fca2f0b23$var$INT){
|
|
61
|
+
out[offset++] = num & 0xFF | $0965686fca2f0b23$var$MSB;
|
|
62
|
+
num /= 128;
|
|
63
|
+
}
|
|
64
|
+
while(num & $0965686fca2f0b23$var$MSBALL){
|
|
65
|
+
out[offset++] = num & 0xFF | $0965686fca2f0b23$var$MSB;
|
|
66
|
+
num >>>= 7;
|
|
67
|
+
}
|
|
68
|
+
out[offset] = num | 0;
|
|
69
|
+
$0965686fca2f0b23$var$encode.bytes = offset - oldOffset + 1;
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
parcelRequire.register("c0YY7", function(module, exports) {
|
|
76
|
+
module.exports = $8bf4c73d37fa4e04$var$read;
|
|
77
|
+
var $8bf4c73d37fa4e04$var$MSB = 0x80, $8bf4c73d37fa4e04$var$REST = 0x7F;
|
|
78
|
+
function $8bf4c73d37fa4e04$var$read(buf, offset) {
|
|
79
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
80
|
+
do {
|
|
81
|
+
if (counter >= l || shift > 49) {
|
|
82
|
+
$8bf4c73d37fa4e04$var$read.bytes = 0;
|
|
83
|
+
throw new RangeError("Could not decode varint");
|
|
84
|
+
}
|
|
85
|
+
b = buf[counter++];
|
|
86
|
+
res += shift < 28 ? (b & $8bf4c73d37fa4e04$var$REST) << shift : (b & $8bf4c73d37fa4e04$var$REST) * Math.pow(2, shift);
|
|
87
|
+
shift += 7;
|
|
88
|
+
}while (b >= $8bf4c73d37fa4e04$var$MSB);
|
|
89
|
+
$8bf4c73d37fa4e04$var$read.bytes = counter - offset;
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
parcelRequire.register("1H9q1", function(module, exports) {
|
|
96
|
+
var $13c11cf855e8ad94$var$N1 = Math.pow(2, 7);
|
|
97
|
+
var $13c11cf855e8ad94$var$N2 = Math.pow(2, 14);
|
|
98
|
+
var $13c11cf855e8ad94$var$N3 = Math.pow(2, 21);
|
|
99
|
+
var $13c11cf855e8ad94$var$N4 = Math.pow(2, 28);
|
|
100
|
+
var $13c11cf855e8ad94$var$N5 = Math.pow(2, 35);
|
|
101
|
+
var $13c11cf855e8ad94$var$N6 = Math.pow(2, 42);
|
|
102
|
+
var $13c11cf855e8ad94$var$N7 = Math.pow(2, 49);
|
|
103
|
+
var $13c11cf855e8ad94$var$N8 = Math.pow(2, 56);
|
|
104
|
+
var $13c11cf855e8ad94$var$N9 = Math.pow(2, 63);
|
|
105
|
+
module.exports = function(value) {
|
|
106
|
+
return value < $13c11cf855e8ad94$var$N1 ? 1 : value < $13c11cf855e8ad94$var$N2 ? 2 : value < $13c11cf855e8ad94$var$N3 ? 3 : value < $13c11cf855e8ad94$var$N4 ? 4 : value < $13c11cf855e8ad94$var$N5 ? 5 : value < $13c11cf855e8ad94$var$N6 ? 6 : value < $13c11cf855e8ad94$var$N7 ? 7 : value < $13c11cf855e8ad94$var$N8 ? 8 : value < $13c11cf855e8ad94$var$N9 ? 9 : 10;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
parcelRequire.register("4n0nt", function(module, exports) {
|
|
112
|
+
|
|
113
|
+
var $hYVtA = parcelRequire("hYVtA");
|
|
114
|
+
|
|
115
|
+
var $6hFBI = parcelRequire("6hFBI");
|
|
116
|
+
module.exports = function(KeccakState) {
|
|
117
|
+
const Keccak = $hYVtA(KeccakState);
|
|
118
|
+
const Shake = $6hFBI(KeccakState);
|
|
119
|
+
return function(algorithm, options) {
|
|
120
|
+
const hash = typeof algorithm === "string" ? algorithm.toLowerCase() : algorithm;
|
|
121
|
+
switch(hash){
|
|
122
|
+
case "keccak224":
|
|
123
|
+
return new Keccak(1152, 448, null, 224, options);
|
|
124
|
+
case "keccak256":
|
|
125
|
+
return new Keccak(1088, 512, null, 256, options);
|
|
126
|
+
case "keccak384":
|
|
127
|
+
return new Keccak(832, 768, null, 384, options);
|
|
128
|
+
case "keccak512":
|
|
129
|
+
return new Keccak(576, 1024, null, 512, options);
|
|
130
|
+
case "sha3-224":
|
|
131
|
+
return new Keccak(1152, 448, 0x06, 224, options);
|
|
132
|
+
case "sha3-256":
|
|
133
|
+
return new Keccak(1088, 512, 0x06, 256, options);
|
|
134
|
+
case "sha3-384":
|
|
135
|
+
return new Keccak(832, 768, 0x06, 384, options);
|
|
136
|
+
case "sha3-512":
|
|
137
|
+
return new Keccak(576, 1024, 0x06, 512, options);
|
|
138
|
+
case "shake128":
|
|
139
|
+
return new Shake(1344, 256, 0x1f, options);
|
|
140
|
+
case "shake256":
|
|
141
|
+
return new Shake(1088, 512, 0x1f, options);
|
|
142
|
+
default:
|
|
143
|
+
throw new Error("Invald algorithm: " + algorithm);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
});
|
|
149
|
+
parcelRequire.register("hYVtA", function(module, exports) {
|
|
150
|
+
|
|
151
|
+
var $d1749fd7588e76b4$require$Buffer = $gHtSl$Buffer;
|
|
152
|
+
|
|
153
|
+
var $4VNAq = parcelRequire("4VNAq");
|
|
154
|
+
var $d1749fd7588e76b4$require$Transform = $4VNAq.Transform;
|
|
155
|
+
module.exports = (KeccakState)=>{
|
|
156
|
+
class Keccak extends $d1749fd7588e76b4$require$Transform {
|
|
157
|
+
_transform(chunk, encoding, callback) {
|
|
158
|
+
let error = null;
|
|
159
|
+
try {
|
|
160
|
+
this.update(chunk, encoding);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
error = err;
|
|
163
|
+
}
|
|
164
|
+
callback(error);
|
|
165
|
+
}
|
|
166
|
+
_flush(callback) {
|
|
167
|
+
let error = null;
|
|
168
|
+
try {
|
|
169
|
+
this.push(this.digest());
|
|
170
|
+
} catch (err) {
|
|
171
|
+
error = err;
|
|
172
|
+
}
|
|
173
|
+
callback(error);
|
|
174
|
+
}
|
|
175
|
+
update(data, encoding) {
|
|
176
|
+
if (!$d1749fd7588e76b4$require$Buffer.isBuffer(data) && typeof data !== "string") throw new TypeError("Data must be a string or a buffer");
|
|
177
|
+
if (this._finalized) throw new Error("Digest already called");
|
|
178
|
+
if (!$d1749fd7588e76b4$require$Buffer.isBuffer(data)) data = $d1749fd7588e76b4$require$Buffer.from(data, encoding);
|
|
179
|
+
this._state.absorb(data);
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
digest(encoding) {
|
|
183
|
+
if (this._finalized) throw new Error("Digest already called");
|
|
184
|
+
this._finalized = true;
|
|
185
|
+
if (this._delimitedSuffix) this._state.absorbLastFewBits(this._delimitedSuffix);
|
|
186
|
+
let digest = this._state.squeeze(this._hashBitLength / 8);
|
|
187
|
+
if (encoding !== undefined) digest = digest.toString(encoding);
|
|
188
|
+
this._resetState();
|
|
189
|
+
return digest;
|
|
190
|
+
}
|
|
191
|
+
// remove result from memory
|
|
192
|
+
_resetState() {
|
|
193
|
+
this._state.initialize(this._rate, this._capacity);
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
// because sometimes we need hash right now and little later
|
|
197
|
+
_clone() {
|
|
198
|
+
const clone = new Keccak(this._rate, this._capacity, this._delimitedSuffix, this._hashBitLength, this._options);
|
|
199
|
+
this._state.copy(clone._state);
|
|
200
|
+
clone._finalized = this._finalized;
|
|
201
|
+
return clone;
|
|
202
|
+
}
|
|
203
|
+
constructor(rate, capacity, delimitedSuffix, hashBitLength, options){
|
|
204
|
+
super(options);
|
|
205
|
+
this._rate = rate;
|
|
206
|
+
this._capacity = capacity;
|
|
207
|
+
this._delimitedSuffix = delimitedSuffix;
|
|
208
|
+
this._hashBitLength = hashBitLength;
|
|
209
|
+
this._options = options;
|
|
210
|
+
this._state = new KeccakState();
|
|
211
|
+
this._state.initialize(rate, capacity);
|
|
212
|
+
this._finalized = false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return Keccak;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
});
|
|
219
|
+
parcelRequire.register("4VNAq", function(module, exports) {
|
|
220
|
+
|
|
221
|
+
exports = module.exports = (parcelRequire("dRV5p"));
|
|
222
|
+
exports.Stream = exports;
|
|
223
|
+
exports.Readable = exports;
|
|
224
|
+
|
|
225
|
+
exports.Writable = (parcelRequire("8T77c"));
|
|
226
|
+
|
|
227
|
+
exports.Duplex = (parcelRequire("cK2wf"));
|
|
228
|
+
|
|
229
|
+
exports.Transform = (parcelRequire("az4hH"));
|
|
230
|
+
|
|
231
|
+
exports.PassThrough = (parcelRequire("dnNlY"));
|
|
232
|
+
|
|
233
|
+
exports.finished = (parcelRequire("7wU83"));
|
|
234
|
+
|
|
235
|
+
exports.pipeline = (parcelRequire("jq29e"));
|
|
236
|
+
|
|
237
|
+
});
|
|
238
|
+
parcelRequire.register("dRV5p", function(module, exports) {
|
|
239
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
240
|
+
//
|
|
241
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
242
|
+
// copy of this software and associated documentation files (the
|
|
243
|
+
// "Software"), to deal in the Software without restriction, including
|
|
244
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
245
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
246
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
247
|
+
// following conditions:
|
|
248
|
+
//
|
|
249
|
+
// The above copyright notice and this permission notice shall be included
|
|
250
|
+
// in all copies or substantial portions of the Software.
|
|
251
|
+
//
|
|
252
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
253
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
254
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
255
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
256
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
257
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
258
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
259
|
+
"use strict";
|
|
260
|
+
|
|
261
|
+
module.exports = $a18c81ba90bd587c$var$Readable;
|
|
262
|
+
/*<replacement>*/ var $a18c81ba90bd587c$var$Duplex;
|
|
263
|
+
/*</replacement>*/ $a18c81ba90bd587c$var$Readable.ReadableState = $a18c81ba90bd587c$var$ReadableState;
|
|
264
|
+
|
|
265
|
+
var $a18c81ba90bd587c$require$EE = $gHtSl$EventEmitter;
|
|
266
|
+
var $a18c81ba90bd587c$var$EElistenerCount = function EElistenerCount(emitter, type) {
|
|
267
|
+
return emitter.listeners(type).length;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
var $47Ymo = parcelRequire("47Ymo");
|
|
271
|
+
|
|
272
|
+
var $a18c81ba90bd587c$require$Buffer = $gHtSl$Buffer;
|
|
273
|
+
var $a18c81ba90bd587c$var$OurUint8Array = $parcel$global.Uint8Array || function() {};
|
|
274
|
+
function $a18c81ba90bd587c$var$_uint8ArrayToBuffer(chunk) {
|
|
275
|
+
return $a18c81ba90bd587c$require$Buffer.from(chunk);
|
|
276
|
+
}
|
|
277
|
+
function $a18c81ba90bd587c$var$_isUint8Array(obj) {
|
|
278
|
+
return $a18c81ba90bd587c$require$Buffer.isBuffer(obj) || obj instanceof $a18c81ba90bd587c$var$OurUint8Array;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
var $2ueGT = parcelRequire("2ueGT");
|
|
282
|
+
var $a18c81ba90bd587c$var$debug;
|
|
283
|
+
if ($2ueGT && $2ueGT.debuglog) $a18c81ba90bd587c$var$debug = $2ueGT.debuglog("stream");
|
|
284
|
+
else $a18c81ba90bd587c$var$debug = function debug() {};
|
|
285
|
+
|
|
286
|
+
var $3N6Yx = parcelRequire("3N6Yx");
|
|
287
|
+
|
|
288
|
+
var $dU5xr = parcelRequire("dU5xr");
|
|
289
|
+
|
|
290
|
+
var $eGsJg = parcelRequire("eGsJg");
|
|
291
|
+
var $a18c81ba90bd587c$var$getHighWaterMark = $eGsJg.getHighWaterMark;
|
|
292
|
+
|
|
293
|
+
var $6vYby = parcelRequire("6vYby");
|
|
294
|
+
var $a18c81ba90bd587c$require$_require$codes = $6vYby.codes;
|
|
295
|
+
var $a18c81ba90bd587c$var$ERR_INVALID_ARG_TYPE = $a18c81ba90bd587c$require$_require$codes.ERR_INVALID_ARG_TYPE, $a18c81ba90bd587c$var$ERR_STREAM_PUSH_AFTER_EOF = $a18c81ba90bd587c$require$_require$codes.ERR_STREAM_PUSH_AFTER_EOF, $a18c81ba90bd587c$var$ERR_METHOD_NOT_IMPLEMENTED = $a18c81ba90bd587c$require$_require$codes.ERR_METHOD_NOT_IMPLEMENTED, $a18c81ba90bd587c$var$ERR_STREAM_UNSHIFT_AFTER_END_EVENT = $a18c81ba90bd587c$require$_require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
|
|
296
|
+
var $a18c81ba90bd587c$var$StringDecoder;
|
|
297
|
+
var $a18c81ba90bd587c$var$createReadableStreamAsyncIterator;
|
|
298
|
+
var $a18c81ba90bd587c$var$from;
|
|
299
|
+
|
|
300
|
+
(parcelRequire("ghwEg"))($a18c81ba90bd587c$var$Readable, $47Ymo);
|
|
301
|
+
var $a18c81ba90bd587c$var$errorOrDestroy = $dU5xr.errorOrDestroy;
|
|
302
|
+
var $a18c81ba90bd587c$var$kProxyEvents = [
|
|
303
|
+
"error",
|
|
304
|
+
"close",
|
|
305
|
+
"destroy",
|
|
306
|
+
"pause",
|
|
307
|
+
"resume"
|
|
308
|
+
];
|
|
309
|
+
function $a18c81ba90bd587c$var$prependListener(emitter, event, fn) {
|
|
310
|
+
// Sadly this is not cacheable as some libraries bundle their own
|
|
311
|
+
// event emitter implementation with them.
|
|
312
|
+
if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
|
|
313
|
+
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
314
|
+
// to continue to work with older versions of Node.js that do not include
|
|
315
|
+
// the prependListener() method. The goal is to eventually remove this hack.
|
|
316
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
|
|
317
|
+
else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
|
|
318
|
+
else emitter._events[event] = [
|
|
319
|
+
fn,
|
|
320
|
+
emitter._events[event]
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
function $a18c81ba90bd587c$var$ReadableState(options, stream, isDuplex) {
|
|
326
|
+
$a18c81ba90bd587c$var$Duplex = $a18c81ba90bd587c$var$Duplex || (parcelRequire("cK2wf"));
|
|
327
|
+
options = options || {}; // Duplex streams are both readable and writable, but share
|
|
328
|
+
// the same options object.
|
|
329
|
+
// However, some cases require setting options to different
|
|
330
|
+
// values for the readable and the writable sides of the duplex stream.
|
|
331
|
+
// These options can be provided separately as readableXXX and writableXXX.
|
|
332
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof $a18c81ba90bd587c$var$Duplex; // object stream flag. Used to make read(n) ignore n and to
|
|
333
|
+
// make all the buffer merging and length checks go away
|
|
334
|
+
this.objectMode = !!options.objectMode;
|
|
335
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
|
|
336
|
+
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
337
|
+
this.highWaterMark = $a18c81ba90bd587c$var$getHighWaterMark(this, options, "readableHighWaterMark", isDuplex); // A linked list is used to store data chunks instead of an array because the
|
|
338
|
+
// linked list can remove elements from the beginning faster than
|
|
339
|
+
// array.shift()
|
|
340
|
+
this.buffer = new $3N6Yx();
|
|
341
|
+
this.length = 0;
|
|
342
|
+
this.pipes = null;
|
|
343
|
+
this.pipesCount = 0;
|
|
344
|
+
this.flowing = null;
|
|
345
|
+
this.ended = false;
|
|
346
|
+
this.endEmitted = false;
|
|
347
|
+
this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
348
|
+
// immediately, or on a later tick. We set this to true at first, because
|
|
349
|
+
// any actions that shouldn't happen until "later" should generally also
|
|
350
|
+
// not happen before the first read call.
|
|
351
|
+
this.sync = true; // whenever we return null, then we set a flag to say
|
|
352
|
+
// that we're awaiting a 'readable' event emission.
|
|
353
|
+
this.needReadable = false;
|
|
354
|
+
this.emittedReadable = false;
|
|
355
|
+
this.readableListening = false;
|
|
356
|
+
this.resumeScheduled = false;
|
|
357
|
+
this.paused = true; // Should close be emitted on destroy. Defaults to true.
|
|
358
|
+
this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
|
|
359
|
+
this.autoDestroy = !!options.autoDestroy; // has it been destroyed
|
|
360
|
+
this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
|
|
361
|
+
// encoding is 'binary' so we have to make this configurable.
|
|
362
|
+
// Everything else in the universe uses 'utf8', though.
|
|
363
|
+
this.defaultEncoding = options.defaultEncoding || "utf8"; // the number of writers that are awaiting a drain event in .pipe()s
|
|
364
|
+
this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
|
|
365
|
+
this.readingMore = false;
|
|
366
|
+
this.decoder = null;
|
|
367
|
+
this.encoding = null;
|
|
368
|
+
if (options.encoding) {
|
|
369
|
+
if (!$a18c81ba90bd587c$var$StringDecoder) $a18c81ba90bd587c$var$StringDecoder = (parcelRequire("aCyUD")).StringDecoder;
|
|
370
|
+
this.decoder = new $a18c81ba90bd587c$var$StringDecoder(options.encoding);
|
|
371
|
+
this.encoding = options.encoding;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function $a18c81ba90bd587c$var$Readable(options) {
|
|
376
|
+
$a18c81ba90bd587c$var$Duplex = $a18c81ba90bd587c$var$Duplex || (parcelRequire("cK2wf"));
|
|
377
|
+
if (!(this instanceof $a18c81ba90bd587c$var$Readable)) return new $a18c81ba90bd587c$var$Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
|
|
378
|
+
// the ReadableState constructor, at least with V8 6.5
|
|
379
|
+
var isDuplex = this instanceof $a18c81ba90bd587c$var$Duplex;
|
|
380
|
+
this._readableState = new $a18c81ba90bd587c$var$ReadableState(options, this, isDuplex); // legacy
|
|
381
|
+
this.readable = true;
|
|
382
|
+
if (options) {
|
|
383
|
+
if (typeof options.read === "function") this._read = options.read;
|
|
384
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
385
|
+
}
|
|
386
|
+
$47Ymo.call(this);
|
|
387
|
+
}
|
|
388
|
+
Object.defineProperty($a18c81ba90bd587c$var$Readable.prototype, "destroyed", {
|
|
389
|
+
// making it explicit this property is not enumerable
|
|
390
|
+
// because otherwise some prototype manipulation in
|
|
391
|
+
// userland will fail
|
|
392
|
+
enumerable: false,
|
|
393
|
+
get: function get() {
|
|
394
|
+
if (this._readableState === undefined) return false;
|
|
395
|
+
return this._readableState.destroyed;
|
|
396
|
+
},
|
|
397
|
+
set: function set(value) {
|
|
398
|
+
// we ignore the value if the stream
|
|
399
|
+
// has not been initialized yet
|
|
400
|
+
if (!this._readableState) return;
|
|
401
|
+
// backward compatibility, the user is explicitly
|
|
402
|
+
// managing destroyed
|
|
403
|
+
this._readableState.destroyed = value;
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
$a18c81ba90bd587c$var$Readable.prototype.destroy = $dU5xr.destroy;
|
|
407
|
+
$a18c81ba90bd587c$var$Readable.prototype._undestroy = $dU5xr.undestroy;
|
|
408
|
+
$a18c81ba90bd587c$var$Readable.prototype._destroy = function(err, cb) {
|
|
409
|
+
cb(err);
|
|
410
|
+
}; // Manually shove something into the read() buffer.
|
|
411
|
+
// This returns true if the highWaterMark has not been hit yet,
|
|
412
|
+
// similar to how Writable.write() returns true if you should
|
|
413
|
+
// write() some more.
|
|
414
|
+
$a18c81ba90bd587c$var$Readable.prototype.push = function(chunk, encoding) {
|
|
415
|
+
var state = this._readableState;
|
|
416
|
+
var skipChunkCheck;
|
|
417
|
+
if (!state.objectMode) {
|
|
418
|
+
if (typeof chunk === "string") {
|
|
419
|
+
encoding = encoding || state.defaultEncoding;
|
|
420
|
+
if (encoding !== state.encoding) {
|
|
421
|
+
chunk = $a18c81ba90bd587c$require$Buffer.from(chunk, encoding);
|
|
422
|
+
encoding = "";
|
|
423
|
+
}
|
|
424
|
+
skipChunkCheck = true;
|
|
425
|
+
}
|
|
426
|
+
} else skipChunkCheck = true;
|
|
427
|
+
return $a18c81ba90bd587c$var$readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
428
|
+
}; // Unshift should *always* be something directly out of read()
|
|
429
|
+
$a18c81ba90bd587c$var$Readable.prototype.unshift = function(chunk) {
|
|
430
|
+
return $a18c81ba90bd587c$var$readableAddChunk(this, chunk, null, true, false);
|
|
431
|
+
};
|
|
432
|
+
function $a18c81ba90bd587c$var$readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
433
|
+
$a18c81ba90bd587c$var$debug("readableAddChunk", chunk);
|
|
434
|
+
var state = stream._readableState;
|
|
435
|
+
if (chunk === null) {
|
|
436
|
+
state.reading = false;
|
|
437
|
+
$a18c81ba90bd587c$var$onEofChunk(stream, state);
|
|
438
|
+
} else {
|
|
439
|
+
var er;
|
|
440
|
+
if (!skipChunkCheck) er = $a18c81ba90bd587c$var$chunkInvalid(state, chunk);
|
|
441
|
+
if (er) $a18c81ba90bd587c$var$errorOrDestroy(stream, er);
|
|
442
|
+
else if (state.objectMode || chunk && chunk.length > 0) {
|
|
443
|
+
if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== $a18c81ba90bd587c$require$Buffer.prototype) chunk = $a18c81ba90bd587c$var$_uint8ArrayToBuffer(chunk);
|
|
444
|
+
if (addToFront) {
|
|
445
|
+
if (state.endEmitted) $a18c81ba90bd587c$var$errorOrDestroy(stream, new $a18c81ba90bd587c$var$ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
|
|
446
|
+
else $a18c81ba90bd587c$var$addChunk(stream, state, chunk, true);
|
|
447
|
+
} else if (state.ended) $a18c81ba90bd587c$var$errorOrDestroy(stream, new $a18c81ba90bd587c$var$ERR_STREAM_PUSH_AFTER_EOF());
|
|
448
|
+
else if (state.destroyed) return false;
|
|
449
|
+
else {
|
|
450
|
+
state.reading = false;
|
|
451
|
+
if (state.decoder && !encoding) {
|
|
452
|
+
chunk = state.decoder.write(chunk);
|
|
453
|
+
if (state.objectMode || chunk.length !== 0) $a18c81ba90bd587c$var$addChunk(stream, state, chunk, false);
|
|
454
|
+
else $a18c81ba90bd587c$var$maybeReadMore(stream, state);
|
|
455
|
+
} else $a18c81ba90bd587c$var$addChunk(stream, state, chunk, false);
|
|
456
|
+
}
|
|
457
|
+
} else if (!addToFront) {
|
|
458
|
+
state.reading = false;
|
|
459
|
+
$a18c81ba90bd587c$var$maybeReadMore(stream, state);
|
|
460
|
+
}
|
|
461
|
+
} // We can push more data if we are below the highWaterMark.
|
|
462
|
+
// Also, if we have no data yet, we can stand some more bytes.
|
|
463
|
+
// This is to work around cases where hwm=0, such as the repl.
|
|
464
|
+
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
|
|
465
|
+
}
|
|
466
|
+
function $a18c81ba90bd587c$var$addChunk(stream, state, chunk, addToFront) {
|
|
467
|
+
if (state.flowing && state.length === 0 && !state.sync) {
|
|
468
|
+
state.awaitDrain = 0;
|
|
469
|
+
stream.emit("data", chunk);
|
|
470
|
+
} else {
|
|
471
|
+
// update the buffer info.
|
|
472
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
473
|
+
if (addToFront) state.buffer.unshift(chunk);
|
|
474
|
+
else state.buffer.push(chunk);
|
|
475
|
+
if (state.needReadable) $a18c81ba90bd587c$var$emitReadable(stream);
|
|
476
|
+
}
|
|
477
|
+
$a18c81ba90bd587c$var$maybeReadMore(stream, state);
|
|
478
|
+
}
|
|
479
|
+
function $a18c81ba90bd587c$var$chunkInvalid(state, chunk) {
|
|
480
|
+
var er;
|
|
481
|
+
if (!$a18c81ba90bd587c$var$_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== undefined && !state.objectMode) er = new $a18c81ba90bd587c$var$ERR_INVALID_ARG_TYPE("chunk", [
|
|
482
|
+
"string",
|
|
483
|
+
"Buffer",
|
|
484
|
+
"Uint8Array"
|
|
485
|
+
], chunk);
|
|
486
|
+
return er;
|
|
487
|
+
}
|
|
488
|
+
$a18c81ba90bd587c$var$Readable.prototype.isPaused = function() {
|
|
489
|
+
return this._readableState.flowing === false;
|
|
490
|
+
}; // backwards compatibility.
|
|
491
|
+
|
|
492
|
+
$a18c81ba90bd587c$var$Readable.prototype.setEncoding = function(enc) {
|
|
493
|
+
if (!$a18c81ba90bd587c$var$StringDecoder) $a18c81ba90bd587c$var$StringDecoder = (parcelRequire("aCyUD")).StringDecoder;
|
|
494
|
+
var decoder = new $a18c81ba90bd587c$var$StringDecoder(enc);
|
|
495
|
+
this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
|
|
496
|
+
this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
|
|
497
|
+
var p = this._readableState.buffer.head;
|
|
498
|
+
var content = "";
|
|
499
|
+
while(p !== null){
|
|
500
|
+
content += decoder.write(p.data);
|
|
501
|
+
p = p.next;
|
|
502
|
+
}
|
|
503
|
+
this._readableState.buffer.clear();
|
|
504
|
+
if (content !== "") this._readableState.buffer.push(content);
|
|
505
|
+
this._readableState.length = content.length;
|
|
506
|
+
return this;
|
|
507
|
+
}; // Don't raise the hwm > 1GB
|
|
508
|
+
var $a18c81ba90bd587c$var$MAX_HWM = 0x40000000;
|
|
509
|
+
function $a18c81ba90bd587c$var$computeNewHighWaterMark(n) {
|
|
510
|
+
if (n >= $a18c81ba90bd587c$var$MAX_HWM) // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
|
|
511
|
+
n = $a18c81ba90bd587c$var$MAX_HWM;
|
|
512
|
+
else {
|
|
513
|
+
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
|
514
|
+
// tiny amounts
|
|
515
|
+
n--;
|
|
516
|
+
n |= n >>> 1;
|
|
517
|
+
n |= n >>> 2;
|
|
518
|
+
n |= n >>> 4;
|
|
519
|
+
n |= n >>> 8;
|
|
520
|
+
n |= n >>> 16;
|
|
521
|
+
n++;
|
|
522
|
+
}
|
|
523
|
+
return n;
|
|
524
|
+
} // This function is designed to be inlinable, so please take care when making
|
|
525
|
+
// changes to the function body.
|
|
526
|
+
function $a18c81ba90bd587c$var$howMuchToRead(n, state) {
|
|
527
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
528
|
+
if (state.objectMode) return 1;
|
|
529
|
+
if (n !== n) {
|
|
530
|
+
// Only flow one buffer at a time
|
|
531
|
+
if (state.flowing && state.length) return state.buffer.head.data.length;
|
|
532
|
+
else return state.length;
|
|
533
|
+
} // If we're asking for more than the current hwm, then raise the hwm.
|
|
534
|
+
if (n > state.highWaterMark) state.highWaterMark = $a18c81ba90bd587c$var$computeNewHighWaterMark(n);
|
|
535
|
+
if (n <= state.length) return n; // Don't have enough
|
|
536
|
+
if (!state.ended) {
|
|
537
|
+
state.needReadable = true;
|
|
538
|
+
return 0;
|
|
539
|
+
}
|
|
540
|
+
return state.length;
|
|
541
|
+
} // you can override either this method, or the async _read(n) below.
|
|
542
|
+
$a18c81ba90bd587c$var$Readable.prototype.read = function(n) {
|
|
543
|
+
$a18c81ba90bd587c$var$debug("read", n);
|
|
544
|
+
n = parseInt(n, 10);
|
|
545
|
+
var state = this._readableState;
|
|
546
|
+
var nOrig = n;
|
|
547
|
+
if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
|
|
548
|
+
// already have a bunch of data in the buffer, then just trigger
|
|
549
|
+
// the 'readable' event and move on.
|
|
550
|
+
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
551
|
+
$a18c81ba90bd587c$var$debug("read: emitReadable", state.length, state.ended);
|
|
552
|
+
if (state.length === 0 && state.ended) $a18c81ba90bd587c$var$endReadable(this);
|
|
553
|
+
else $a18c81ba90bd587c$var$emitReadable(this);
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
n = $a18c81ba90bd587c$var$howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
|
|
557
|
+
if (n === 0 && state.ended) {
|
|
558
|
+
if (state.length === 0) $a18c81ba90bd587c$var$endReadable(this);
|
|
559
|
+
return null;
|
|
560
|
+
} // All the actual chunk generation logic needs to be
|
|
561
|
+
// *below* the call to _read. The reason is that in certain
|
|
562
|
+
// synthetic stream cases, such as passthrough streams, _read
|
|
563
|
+
// may be a completely synchronous operation which may change
|
|
564
|
+
// the state of the read buffer, providing enough data when
|
|
565
|
+
// before there was *not* enough.
|
|
566
|
+
//
|
|
567
|
+
// So, the steps are:
|
|
568
|
+
// 1. Figure out what the state of things will be after we do
|
|
569
|
+
// a read from the buffer.
|
|
570
|
+
//
|
|
571
|
+
// 2. If that resulting state will trigger a _read, then call _read.
|
|
572
|
+
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
573
|
+
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
574
|
+
// that the Readable class should behave improperly, as streams are
|
|
575
|
+
// designed to be sync/async agnostic.
|
|
576
|
+
// Take note if the _read call is sync or async (ie, if the read call
|
|
577
|
+
// has returned yet), so that we know whether or not it's safe to emit
|
|
578
|
+
// 'readable' etc.
|
|
579
|
+
//
|
|
580
|
+
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
581
|
+
// if we need a readable event, then we need to do some reading.
|
|
582
|
+
var doRead = state.needReadable;
|
|
583
|
+
$a18c81ba90bd587c$var$debug("need readable", doRead); // if we currently have less than the highWaterMark, then also read some
|
|
584
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
585
|
+
doRead = true;
|
|
586
|
+
$a18c81ba90bd587c$var$debug("length less than watermark", doRead);
|
|
587
|
+
} // however, if we've ended, then there's no point, and if we're already
|
|
588
|
+
// reading, then it's unnecessary.
|
|
589
|
+
if (state.ended || state.reading) {
|
|
590
|
+
doRead = false;
|
|
591
|
+
$a18c81ba90bd587c$var$debug("reading or ended", doRead);
|
|
592
|
+
} else if (doRead) {
|
|
593
|
+
$a18c81ba90bd587c$var$debug("do read");
|
|
594
|
+
state.reading = true;
|
|
595
|
+
state.sync = true; // if the length is currently zero, then we *need* a readable event.
|
|
596
|
+
if (state.length === 0) state.needReadable = true; // call internal read method
|
|
597
|
+
this._read(state.highWaterMark);
|
|
598
|
+
state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
|
|
599
|
+
// and we need to re-evaluate how much data we can return to the user.
|
|
600
|
+
if (!state.reading) n = $a18c81ba90bd587c$var$howMuchToRead(nOrig, state);
|
|
601
|
+
}
|
|
602
|
+
var ret;
|
|
603
|
+
if (n > 0) ret = $a18c81ba90bd587c$var$fromList(n, state);
|
|
604
|
+
else ret = null;
|
|
605
|
+
if (ret === null) {
|
|
606
|
+
state.needReadable = state.length <= state.highWaterMark;
|
|
607
|
+
n = 0;
|
|
608
|
+
} else {
|
|
609
|
+
state.length -= n;
|
|
610
|
+
state.awaitDrain = 0;
|
|
611
|
+
}
|
|
612
|
+
if (state.length === 0) {
|
|
613
|
+
// If we have nothing in the buffer, then we want to know
|
|
614
|
+
// as soon as we *do* get something into the buffer.
|
|
615
|
+
if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
|
|
616
|
+
if (nOrig !== n && state.ended) $a18c81ba90bd587c$var$endReadable(this);
|
|
617
|
+
}
|
|
618
|
+
if (ret !== null) this.emit("data", ret);
|
|
619
|
+
return ret;
|
|
620
|
+
};
|
|
621
|
+
function $a18c81ba90bd587c$var$onEofChunk(stream, state) {
|
|
622
|
+
$a18c81ba90bd587c$var$debug("onEofChunk");
|
|
623
|
+
if (state.ended) return;
|
|
624
|
+
if (state.decoder) {
|
|
625
|
+
var chunk = state.decoder.end();
|
|
626
|
+
if (chunk && chunk.length) {
|
|
627
|
+
state.buffer.push(chunk);
|
|
628
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
state.ended = true;
|
|
632
|
+
if (state.sync) // if we are sync, wait until next tick to emit the data.
|
|
633
|
+
// Otherwise we risk emitting data in the flow()
|
|
634
|
+
// the readable code triggers during a read() call
|
|
635
|
+
$a18c81ba90bd587c$var$emitReadable(stream);
|
|
636
|
+
else {
|
|
637
|
+
// emit 'readable' now to make sure it gets picked up.
|
|
638
|
+
state.needReadable = false;
|
|
639
|
+
if (!state.emittedReadable) {
|
|
640
|
+
state.emittedReadable = true;
|
|
641
|
+
$a18c81ba90bd587c$var$emitReadable_(stream);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
} // Don't emit readable right away in sync mode, because this can trigger
|
|
645
|
+
// another read() call => stack overflow. This way, it might trigger
|
|
646
|
+
// a nextTick recursion warning, but that's not so bad.
|
|
647
|
+
function $a18c81ba90bd587c$var$emitReadable(stream) {
|
|
648
|
+
var state = stream._readableState;
|
|
649
|
+
$a18c81ba90bd587c$var$debug("emitReadable", state.needReadable, state.emittedReadable);
|
|
650
|
+
state.needReadable = false;
|
|
651
|
+
if (!state.emittedReadable) {
|
|
652
|
+
$a18c81ba90bd587c$var$debug("emitReadable", state.flowing);
|
|
653
|
+
state.emittedReadable = true;
|
|
654
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$emitReadable_, stream);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function $a18c81ba90bd587c$var$emitReadable_(stream) {
|
|
658
|
+
var state = stream._readableState;
|
|
659
|
+
$a18c81ba90bd587c$var$debug("emitReadable_", state.destroyed, state.length, state.ended);
|
|
660
|
+
if (!state.destroyed && (state.length || state.ended)) {
|
|
661
|
+
stream.emit("readable");
|
|
662
|
+
state.emittedReadable = false;
|
|
663
|
+
} // The stream needs another readable event if
|
|
664
|
+
// 1. It is not flowing, as the flow mechanism will take
|
|
665
|
+
// care of it.
|
|
666
|
+
// 2. It is not ended.
|
|
667
|
+
// 3. It is below the highWaterMark, so we can schedule
|
|
668
|
+
// another readable later.
|
|
669
|
+
state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
|
|
670
|
+
$a18c81ba90bd587c$var$flow(stream);
|
|
671
|
+
} // at this point, the user has presumably seen the 'readable' event,
|
|
672
|
+
// and called read() to consume some data. that may have triggered
|
|
673
|
+
// in turn another _read(n) call, in which case reading = true if
|
|
674
|
+
// it's in progress.
|
|
675
|
+
// However, if we're not ended, or reading, and the length < hwm,
|
|
676
|
+
// then go ahead and try to read some more preemptively.
|
|
677
|
+
function $a18c81ba90bd587c$var$maybeReadMore(stream, state) {
|
|
678
|
+
if (!state.readingMore) {
|
|
679
|
+
state.readingMore = true;
|
|
680
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$maybeReadMore_, stream, state);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
function $a18c81ba90bd587c$var$maybeReadMore_(stream, state) {
|
|
684
|
+
// Attempt to read more data if we should.
|
|
685
|
+
//
|
|
686
|
+
// The conditions for reading more data are (one of):
|
|
687
|
+
// - Not enough data buffered (state.length < state.highWaterMark). The loop
|
|
688
|
+
// is responsible for filling the buffer with enough data if such data
|
|
689
|
+
// is available. If highWaterMark is 0 and we are not in the flowing mode
|
|
690
|
+
// we should _not_ attempt to buffer any extra data. We'll get more data
|
|
691
|
+
// when the stream consumer calls read() instead.
|
|
692
|
+
// - No data in the buffer, and the stream is in flowing mode. In this mode
|
|
693
|
+
// the loop below is responsible for ensuring read() is called. Failing to
|
|
694
|
+
// call read here would abort the flow and there's no other mechanism for
|
|
695
|
+
// continuing the flow if the stream consumer has just subscribed to the
|
|
696
|
+
// 'data' event.
|
|
697
|
+
//
|
|
698
|
+
// In addition to the above conditions to keep reading data, the following
|
|
699
|
+
// conditions prevent the data from being read:
|
|
700
|
+
// - The stream has ended (state.ended).
|
|
701
|
+
// - There is already a pending 'read' operation (state.reading). This is a
|
|
702
|
+
// case where the the stream has called the implementation defined _read()
|
|
703
|
+
// method, but they are processing the call asynchronously and have _not_
|
|
704
|
+
// called push() with new data. In this case we skip performing more
|
|
705
|
+
// read()s. The execution ends in this method again after the _read() ends
|
|
706
|
+
// up calling push() with more data.
|
|
707
|
+
while(!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)){
|
|
708
|
+
var len = state.length;
|
|
709
|
+
$a18c81ba90bd587c$var$debug("maybeReadMore read 0");
|
|
710
|
+
stream.read(0);
|
|
711
|
+
if (len === state.length) break;
|
|
712
|
+
}
|
|
713
|
+
state.readingMore = false;
|
|
714
|
+
} // abstract method. to be overridden in specific implementation classes.
|
|
715
|
+
// call cb(er, data) where data is <= n in length.
|
|
716
|
+
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
717
|
+
// arbitrary, and perhaps not very meaningful.
|
|
718
|
+
$a18c81ba90bd587c$var$Readable.prototype._read = function(n) {
|
|
719
|
+
$a18c81ba90bd587c$var$errorOrDestroy(this, new $a18c81ba90bd587c$var$ERR_METHOD_NOT_IMPLEMENTED("_read()"));
|
|
720
|
+
};
|
|
721
|
+
$a18c81ba90bd587c$var$Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
722
|
+
var src = this;
|
|
723
|
+
var state = this._readableState;
|
|
724
|
+
switch(state.pipesCount){
|
|
725
|
+
case 0:
|
|
726
|
+
state.pipes = dest;
|
|
727
|
+
break;
|
|
728
|
+
case 1:
|
|
729
|
+
state.pipes = [
|
|
730
|
+
state.pipes,
|
|
731
|
+
dest
|
|
732
|
+
];
|
|
733
|
+
break;
|
|
734
|
+
default:
|
|
735
|
+
state.pipes.push(dest);
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
state.pipesCount += 1;
|
|
739
|
+
$a18c81ba90bd587c$var$debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
740
|
+
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== $gHtSl$stdout && dest !== $gHtSl$stderr;
|
|
741
|
+
var endFn = doEnd ? onend : unpipe;
|
|
742
|
+
if (state.endEmitted) $gHtSl$nextTick(endFn);
|
|
743
|
+
else src.once("end", endFn);
|
|
744
|
+
dest.on("unpipe", onunpipe);
|
|
745
|
+
function onunpipe(readable, unpipeInfo) {
|
|
746
|
+
$a18c81ba90bd587c$var$debug("onunpipe");
|
|
747
|
+
if (readable === src) {
|
|
748
|
+
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
749
|
+
unpipeInfo.hasUnpiped = true;
|
|
750
|
+
cleanup();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
function onend() {
|
|
755
|
+
$a18c81ba90bd587c$var$debug("onend");
|
|
756
|
+
dest.end();
|
|
757
|
+
} // when the dest drains, it reduces the awaitDrain counter
|
|
758
|
+
// on the source. This would be more elegant with a .once()
|
|
759
|
+
// handler in flow(), but adding and removing repeatedly is
|
|
760
|
+
// too slow.
|
|
761
|
+
var ondrain = $a18c81ba90bd587c$var$pipeOnDrain(src);
|
|
762
|
+
dest.on("drain", ondrain);
|
|
763
|
+
var cleanedUp = false;
|
|
764
|
+
function cleanup() {
|
|
765
|
+
$a18c81ba90bd587c$var$debug("cleanup"); // cleanup event handlers once the pipe is broken
|
|
766
|
+
dest.removeListener("close", onclose);
|
|
767
|
+
dest.removeListener("finish", onfinish);
|
|
768
|
+
dest.removeListener("drain", ondrain);
|
|
769
|
+
dest.removeListener("error", onerror);
|
|
770
|
+
dest.removeListener("unpipe", onunpipe);
|
|
771
|
+
src.removeListener("end", onend);
|
|
772
|
+
src.removeListener("end", unpipe);
|
|
773
|
+
src.removeListener("data", ondata);
|
|
774
|
+
cleanedUp = true; // if the reader is waiting for a drain event from this
|
|
775
|
+
// specific writer, then it would cause it to never start
|
|
776
|
+
// flowing again.
|
|
777
|
+
// So, if this is awaiting a drain, then we just call it now.
|
|
778
|
+
// If we don't know, then assume that we are waiting for one.
|
|
779
|
+
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
780
|
+
}
|
|
781
|
+
src.on("data", ondata);
|
|
782
|
+
function ondata(chunk) {
|
|
783
|
+
$a18c81ba90bd587c$var$debug("ondata");
|
|
784
|
+
var ret = dest.write(chunk);
|
|
785
|
+
$a18c81ba90bd587c$var$debug("dest.write", ret);
|
|
786
|
+
if (ret === false) {
|
|
787
|
+
// If the user unpiped during `dest.write()`, it is possible
|
|
788
|
+
// to get stuck in a permanently paused state if that write
|
|
789
|
+
// also returned false.
|
|
790
|
+
// => Check whether `dest` is still a piping destination.
|
|
791
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && $a18c81ba90bd587c$var$indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
792
|
+
$a18c81ba90bd587c$var$debug("false write response, pause", state.awaitDrain);
|
|
793
|
+
state.awaitDrain++;
|
|
794
|
+
}
|
|
795
|
+
src.pause();
|
|
796
|
+
}
|
|
797
|
+
} // if the dest has an error, then stop piping into it.
|
|
798
|
+
// however, don't suppress the throwing behavior for this.
|
|
799
|
+
function onerror(er) {
|
|
800
|
+
$a18c81ba90bd587c$var$debug("onerror", er);
|
|
801
|
+
unpipe();
|
|
802
|
+
dest.removeListener("error", onerror);
|
|
803
|
+
if ($a18c81ba90bd587c$var$EElistenerCount(dest, "error") === 0) $a18c81ba90bd587c$var$errorOrDestroy(dest, er);
|
|
804
|
+
} // Make sure our error handler is attached before userland ones.
|
|
805
|
+
$a18c81ba90bd587c$var$prependListener(dest, "error", onerror); // Both close and finish should trigger unpipe, but only once.
|
|
806
|
+
function onclose() {
|
|
807
|
+
dest.removeListener("finish", onfinish);
|
|
808
|
+
unpipe();
|
|
809
|
+
}
|
|
810
|
+
dest.once("close", onclose);
|
|
811
|
+
function onfinish() {
|
|
812
|
+
$a18c81ba90bd587c$var$debug("onfinish");
|
|
813
|
+
dest.removeListener("close", onclose);
|
|
814
|
+
unpipe();
|
|
815
|
+
}
|
|
816
|
+
dest.once("finish", onfinish);
|
|
817
|
+
function unpipe() {
|
|
818
|
+
$a18c81ba90bd587c$var$debug("unpipe");
|
|
819
|
+
src.unpipe(dest);
|
|
820
|
+
} // tell the dest that it's being piped to
|
|
821
|
+
dest.emit("pipe", src); // start the flow if it hasn't been started already.
|
|
822
|
+
if (!state.flowing) {
|
|
823
|
+
$a18c81ba90bd587c$var$debug("pipe resume");
|
|
824
|
+
src.resume();
|
|
825
|
+
}
|
|
826
|
+
return dest;
|
|
827
|
+
};
|
|
828
|
+
function $a18c81ba90bd587c$var$pipeOnDrain(src) {
|
|
829
|
+
return function pipeOnDrainFunctionResult() {
|
|
830
|
+
var state = src._readableState;
|
|
831
|
+
$a18c81ba90bd587c$var$debug("pipeOnDrain", state.awaitDrain);
|
|
832
|
+
if (state.awaitDrain) state.awaitDrain--;
|
|
833
|
+
if (state.awaitDrain === 0 && $a18c81ba90bd587c$var$EElistenerCount(src, "data")) {
|
|
834
|
+
state.flowing = true;
|
|
835
|
+
$a18c81ba90bd587c$var$flow(src);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
$a18c81ba90bd587c$var$Readable.prototype.unpipe = function(dest) {
|
|
840
|
+
var state = this._readableState;
|
|
841
|
+
var unpipeInfo = {
|
|
842
|
+
hasUnpiped: false
|
|
843
|
+
}; // if we're not piping anywhere, then do nothing.
|
|
844
|
+
if (state.pipesCount === 0) return this; // just one destination. most common case.
|
|
845
|
+
if (state.pipesCount === 1) {
|
|
846
|
+
// passed in one, but it's not the right one.
|
|
847
|
+
if (dest && dest !== state.pipes) return this;
|
|
848
|
+
if (!dest) dest = state.pipes; // got a match.
|
|
849
|
+
state.pipes = null;
|
|
850
|
+
state.pipesCount = 0;
|
|
851
|
+
state.flowing = false;
|
|
852
|
+
if (dest) dest.emit("unpipe", this, unpipeInfo);
|
|
853
|
+
return this;
|
|
854
|
+
} // slow case. multiple pipe destinations.
|
|
855
|
+
if (!dest) {
|
|
856
|
+
// remove all.
|
|
857
|
+
var dests = state.pipes;
|
|
858
|
+
var len = state.pipesCount;
|
|
859
|
+
state.pipes = null;
|
|
860
|
+
state.pipesCount = 0;
|
|
861
|
+
state.flowing = false;
|
|
862
|
+
for(var i = 0; i < len; i++)dests[i].emit("unpipe", this, {
|
|
863
|
+
hasUnpiped: false
|
|
864
|
+
});
|
|
865
|
+
return this;
|
|
866
|
+
} // try to find the right one.
|
|
867
|
+
var index = $a18c81ba90bd587c$var$indexOf(state.pipes, dest);
|
|
868
|
+
if (index === -1) return this;
|
|
869
|
+
state.pipes.splice(index, 1);
|
|
870
|
+
state.pipesCount -= 1;
|
|
871
|
+
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
872
|
+
dest.emit("unpipe", this, unpipeInfo);
|
|
873
|
+
return this;
|
|
874
|
+
}; // set up data events if they are asked for
|
|
875
|
+
// Ensure readable listeners eventually get something
|
|
876
|
+
$a18c81ba90bd587c$var$Readable.prototype.on = function(ev, fn) {
|
|
877
|
+
var res = $47Ymo.prototype.on.call(this, ev, fn);
|
|
878
|
+
var state = this._readableState;
|
|
879
|
+
if (ev === "data") {
|
|
880
|
+
// update readableListening so that resume() may be a no-op
|
|
881
|
+
// a few lines down. This is needed to support once('readable').
|
|
882
|
+
state.readableListening = this.listenerCount("readable") > 0; // Try start flowing on next tick if stream isn't explicitly paused
|
|
883
|
+
if (state.flowing !== false) this.resume();
|
|
884
|
+
} else if (ev === "readable") {
|
|
885
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
886
|
+
state.readableListening = state.needReadable = true;
|
|
887
|
+
state.flowing = false;
|
|
888
|
+
state.emittedReadable = false;
|
|
889
|
+
$a18c81ba90bd587c$var$debug("on readable", state.length, state.reading);
|
|
890
|
+
if (state.length) $a18c81ba90bd587c$var$emitReadable(this);
|
|
891
|
+
else if (!state.reading) $gHtSl$nextTick($a18c81ba90bd587c$var$nReadingNextTick, this);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return res;
|
|
895
|
+
};
|
|
896
|
+
$a18c81ba90bd587c$var$Readable.prototype.addListener = $a18c81ba90bd587c$var$Readable.prototype.on;
|
|
897
|
+
$a18c81ba90bd587c$var$Readable.prototype.removeListener = function(ev, fn) {
|
|
898
|
+
var res = $47Ymo.prototype.removeListener.call(this, ev, fn);
|
|
899
|
+
if (ev === "readable") // We need to check if there is someone still listening to
|
|
900
|
+
// readable and reset the state. However this needs to happen
|
|
901
|
+
// after readable has been emitted but before I/O (nextTick) to
|
|
902
|
+
// support once('readable', fn) cycles. This means that calling
|
|
903
|
+
// resume within the same tick will have no
|
|
904
|
+
// effect.
|
|
905
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$updateReadableListening, this);
|
|
906
|
+
return res;
|
|
907
|
+
};
|
|
908
|
+
$a18c81ba90bd587c$var$Readable.prototype.removeAllListeners = function(ev) {
|
|
909
|
+
var res = $47Ymo.prototype.removeAllListeners.apply(this, arguments);
|
|
910
|
+
if (ev === "readable" || ev === undefined) // We need to check if there is someone still listening to
|
|
911
|
+
// readable and reset the state. However this needs to happen
|
|
912
|
+
// after readable has been emitted but before I/O (nextTick) to
|
|
913
|
+
// support once('readable', fn) cycles. This means that calling
|
|
914
|
+
// resume within the same tick will have no
|
|
915
|
+
// effect.
|
|
916
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$updateReadableListening, this);
|
|
917
|
+
return res;
|
|
918
|
+
};
|
|
919
|
+
function $a18c81ba90bd587c$var$updateReadableListening(self) {
|
|
920
|
+
var state = self._readableState;
|
|
921
|
+
state.readableListening = self.listenerCount("readable") > 0;
|
|
922
|
+
if (state.resumeScheduled && !state.paused) // flowing needs to be set to true now, otherwise
|
|
923
|
+
// the upcoming resume will not flow.
|
|
924
|
+
state.flowing = true; // crude way to check if we should resume
|
|
925
|
+
else if (self.listenerCount("data") > 0) self.resume();
|
|
926
|
+
}
|
|
927
|
+
function $a18c81ba90bd587c$var$nReadingNextTick(self) {
|
|
928
|
+
$a18c81ba90bd587c$var$debug("readable nexttick read 0");
|
|
929
|
+
self.read(0);
|
|
930
|
+
} // pause() and resume() are remnants of the legacy readable stream API
|
|
931
|
+
// If the user uses them, then switch into old mode.
|
|
932
|
+
$a18c81ba90bd587c$var$Readable.prototype.resume = function() {
|
|
933
|
+
var state = this._readableState;
|
|
934
|
+
if (!state.flowing) {
|
|
935
|
+
$a18c81ba90bd587c$var$debug("resume"); // we flow only if there is no one listening
|
|
936
|
+
// for readable, but we still have to call
|
|
937
|
+
// resume()
|
|
938
|
+
state.flowing = !state.readableListening;
|
|
939
|
+
$a18c81ba90bd587c$var$resume(this, state);
|
|
940
|
+
}
|
|
941
|
+
state.paused = false;
|
|
942
|
+
return this;
|
|
943
|
+
};
|
|
944
|
+
function $a18c81ba90bd587c$var$resume(stream, state) {
|
|
945
|
+
if (!state.resumeScheduled) {
|
|
946
|
+
state.resumeScheduled = true;
|
|
947
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$resume_, stream, state);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function $a18c81ba90bd587c$var$resume_(stream, state) {
|
|
951
|
+
$a18c81ba90bd587c$var$debug("resume", state.reading);
|
|
952
|
+
if (!state.reading) stream.read(0);
|
|
953
|
+
state.resumeScheduled = false;
|
|
954
|
+
stream.emit("resume");
|
|
955
|
+
$a18c81ba90bd587c$var$flow(stream);
|
|
956
|
+
if (state.flowing && !state.reading) stream.read(0);
|
|
957
|
+
}
|
|
958
|
+
$a18c81ba90bd587c$var$Readable.prototype.pause = function() {
|
|
959
|
+
$a18c81ba90bd587c$var$debug("call pause flowing=%j", this._readableState.flowing);
|
|
960
|
+
if (this._readableState.flowing !== false) {
|
|
961
|
+
$a18c81ba90bd587c$var$debug("pause");
|
|
962
|
+
this._readableState.flowing = false;
|
|
963
|
+
this.emit("pause");
|
|
964
|
+
}
|
|
965
|
+
this._readableState.paused = true;
|
|
966
|
+
return this;
|
|
967
|
+
};
|
|
968
|
+
function $a18c81ba90bd587c$var$flow(stream) {
|
|
969
|
+
var state = stream._readableState;
|
|
970
|
+
$a18c81ba90bd587c$var$debug("flow", state.flowing);
|
|
971
|
+
while(state.flowing && stream.read() !== null);
|
|
972
|
+
} // wrap an old-style stream as the async data source.
|
|
973
|
+
// This is *not* part of the readable stream interface.
|
|
974
|
+
// It is an ugly unfortunate mess of history.
|
|
975
|
+
$a18c81ba90bd587c$var$Readable.prototype.wrap = function(stream) {
|
|
976
|
+
var _this = this;
|
|
977
|
+
var state = this._readableState;
|
|
978
|
+
var paused = false;
|
|
979
|
+
stream.on("end", function() {
|
|
980
|
+
$a18c81ba90bd587c$var$debug("wrapped end");
|
|
981
|
+
if (state.decoder && !state.ended) {
|
|
982
|
+
var chunk = state.decoder.end();
|
|
983
|
+
if (chunk && chunk.length) _this.push(chunk);
|
|
984
|
+
}
|
|
985
|
+
_this.push(null);
|
|
986
|
+
});
|
|
987
|
+
stream.on("data", function(chunk) {
|
|
988
|
+
$a18c81ba90bd587c$var$debug("wrapped data");
|
|
989
|
+
if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
|
|
990
|
+
if (state.objectMode && (chunk === null || chunk === undefined)) return;
|
|
991
|
+
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
992
|
+
var ret = _this.push(chunk);
|
|
993
|
+
if (!ret) {
|
|
994
|
+
paused = true;
|
|
995
|
+
stream.pause();
|
|
996
|
+
}
|
|
997
|
+
}); // proxy all the other methods.
|
|
998
|
+
// important when wrapping filters and duplexes.
|
|
999
|
+
for(var i in stream)if (this[i] === undefined && typeof stream[i] === "function") this[i] = function methodWrap(method) {
|
|
1000
|
+
return function methodWrapReturnFunction() {
|
|
1001
|
+
return stream[method].apply(stream, arguments);
|
|
1002
|
+
};
|
|
1003
|
+
}(i);
|
|
1004
|
+
// proxy certain important events.
|
|
1005
|
+
for(var n = 0; n < $a18c81ba90bd587c$var$kProxyEvents.length; n++)stream.on($a18c81ba90bd587c$var$kProxyEvents[n], this.emit.bind(this, $a18c81ba90bd587c$var$kProxyEvents[n]));
|
|
1006
|
+
// when we try to consume some more bytes, simply unpause the
|
|
1007
|
+
// underlying stream.
|
|
1008
|
+
this._read = function(n) {
|
|
1009
|
+
$a18c81ba90bd587c$var$debug("wrapped _read", n);
|
|
1010
|
+
if (paused) {
|
|
1011
|
+
paused = false;
|
|
1012
|
+
stream.resume();
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
return this;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
if (typeof Symbol === "function") $a18c81ba90bd587c$var$Readable.prototype[Symbol.asyncIterator] = function() {
|
|
1019
|
+
if ($a18c81ba90bd587c$var$createReadableStreamAsyncIterator === undefined) $a18c81ba90bd587c$var$createReadableStreamAsyncIterator = (parcelRequire("5Q095"));
|
|
1020
|
+
return $a18c81ba90bd587c$var$createReadableStreamAsyncIterator(this);
|
|
1021
|
+
};
|
|
1022
|
+
Object.defineProperty($a18c81ba90bd587c$var$Readable.prototype, "readableHighWaterMark", {
|
|
1023
|
+
// making it explicit this property is not enumerable
|
|
1024
|
+
// because otherwise some prototype manipulation in
|
|
1025
|
+
// userland will fail
|
|
1026
|
+
enumerable: false,
|
|
1027
|
+
get: function get() {
|
|
1028
|
+
return this._readableState.highWaterMark;
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
Object.defineProperty($a18c81ba90bd587c$var$Readable.prototype, "readableBuffer", {
|
|
1032
|
+
// making it explicit this property is not enumerable
|
|
1033
|
+
// because otherwise some prototype manipulation in
|
|
1034
|
+
// userland will fail
|
|
1035
|
+
enumerable: false,
|
|
1036
|
+
get: function get() {
|
|
1037
|
+
return this._readableState && this._readableState.buffer;
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
Object.defineProperty($a18c81ba90bd587c$var$Readable.prototype, "readableFlowing", {
|
|
1041
|
+
// making it explicit this property is not enumerable
|
|
1042
|
+
// because otherwise some prototype manipulation in
|
|
1043
|
+
// userland will fail
|
|
1044
|
+
enumerable: false,
|
|
1045
|
+
get: function get() {
|
|
1046
|
+
return this._readableState.flowing;
|
|
1047
|
+
},
|
|
1048
|
+
set: function set(state) {
|
|
1049
|
+
if (this._readableState) this._readableState.flowing = state;
|
|
1050
|
+
}
|
|
1051
|
+
}); // exposed for testing purposes only.
|
|
1052
|
+
$a18c81ba90bd587c$var$Readable._fromList = $a18c81ba90bd587c$var$fromList;
|
|
1053
|
+
Object.defineProperty($a18c81ba90bd587c$var$Readable.prototype, "readableLength", {
|
|
1054
|
+
// making it explicit this property is not enumerable
|
|
1055
|
+
// because otherwise some prototype manipulation in
|
|
1056
|
+
// userland will fail
|
|
1057
|
+
enumerable: false,
|
|
1058
|
+
get: function get() {
|
|
1059
|
+
return this._readableState.length;
|
|
1060
|
+
}
|
|
1061
|
+
}); // Pluck off n bytes from an array of buffers.
|
|
1062
|
+
// Length is the combined lengths of all the buffers in the list.
|
|
1063
|
+
// This function is designed to be inlinable, so please take care when making
|
|
1064
|
+
// changes to the function body.
|
|
1065
|
+
function $a18c81ba90bd587c$var$fromList(n, state) {
|
|
1066
|
+
// nothing buffered
|
|
1067
|
+
if (state.length === 0) return null;
|
|
1068
|
+
var ret;
|
|
1069
|
+
if (state.objectMode) ret = state.buffer.shift();
|
|
1070
|
+
else if (!n || n >= state.length) {
|
|
1071
|
+
// read it all, truncate the list
|
|
1072
|
+
if (state.decoder) ret = state.buffer.join("");
|
|
1073
|
+
else if (state.buffer.length === 1) ret = state.buffer.first();
|
|
1074
|
+
else ret = state.buffer.concat(state.length);
|
|
1075
|
+
state.buffer.clear();
|
|
1076
|
+
} else // read part of list
|
|
1077
|
+
ret = state.buffer.consume(n, state.decoder);
|
|
1078
|
+
return ret;
|
|
1079
|
+
}
|
|
1080
|
+
function $a18c81ba90bd587c$var$endReadable(stream) {
|
|
1081
|
+
var state = stream._readableState;
|
|
1082
|
+
$a18c81ba90bd587c$var$debug("endReadable", state.endEmitted);
|
|
1083
|
+
if (!state.endEmitted) {
|
|
1084
|
+
state.ended = true;
|
|
1085
|
+
$gHtSl$nextTick($a18c81ba90bd587c$var$endReadableNT, state, stream);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function $a18c81ba90bd587c$var$endReadableNT(state, stream) {
|
|
1089
|
+
$a18c81ba90bd587c$var$debug("endReadableNT", state.endEmitted, state.length); // Check that we didn't get one last unshift.
|
|
1090
|
+
if (!state.endEmitted && state.length === 0) {
|
|
1091
|
+
state.endEmitted = true;
|
|
1092
|
+
stream.readable = false;
|
|
1093
|
+
stream.emit("end");
|
|
1094
|
+
if (state.autoDestroy) {
|
|
1095
|
+
// In case of duplex streams we need a way to detect
|
|
1096
|
+
// if the writable side is ready for autoDestroy as well
|
|
1097
|
+
var wState = stream._writableState;
|
|
1098
|
+
if (!wState || wState.autoDestroy && wState.finished) stream.destroy();
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if (typeof Symbol === "function") $a18c81ba90bd587c$var$Readable.from = function(iterable, opts) {
|
|
1104
|
+
if ($a18c81ba90bd587c$var$from === undefined) $a18c81ba90bd587c$var$from = (parcelRequire("3AJhl"));
|
|
1105
|
+
return $a18c81ba90bd587c$var$from($a18c81ba90bd587c$var$Readable, iterable, opts);
|
|
1106
|
+
};
|
|
1107
|
+
function $a18c81ba90bd587c$var$indexOf(xs, x) {
|
|
1108
|
+
for(var i = 0, l = xs.length; i < l; i++){
|
|
1109
|
+
if (xs[i] === x) return i;
|
|
1110
|
+
}
|
|
1111
|
+
return -1;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
});
|
|
1115
|
+
parcelRequire.register("47Ymo", function(module, exports) {
|
|
1116
|
+
|
|
1117
|
+
module.exports = $gHtSl$EventEmitter;
|
|
1118
|
+
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1121
|
+
parcelRequire.register("2ueGT", function(module, exports) {
|
|
1122
|
+
"use strict";
|
|
1123
|
+
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
parcelRequire.register("3N6Yx", function(module, exports) {
|
|
1127
|
+
"use strict";
|
|
1128
|
+
function $2c2b5be471529de8$var$ownKeys(object, enumerableOnly) {
|
|
1129
|
+
var keys = Object.keys(object);
|
|
1130
|
+
if (Object.getOwnPropertySymbols) {
|
|
1131
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1132
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
1133
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1134
|
+
});
|
|
1135
|
+
keys.push.apply(keys, symbols);
|
|
1136
|
+
}
|
|
1137
|
+
return keys;
|
|
1138
|
+
}
|
|
1139
|
+
function $2c2b5be471529de8$var$_objectSpread(target) {
|
|
1140
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1141
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
1142
|
+
if (i % 2) $2c2b5be471529de8$var$ownKeys(Object(source), true).forEach(function(key) {
|
|
1143
|
+
$2c2b5be471529de8$var$_defineProperty(target, key, source[key]);
|
|
1144
|
+
});
|
|
1145
|
+
else if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1146
|
+
else $2c2b5be471529de8$var$ownKeys(Object(source)).forEach(function(key) {
|
|
1147
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
return target;
|
|
1151
|
+
}
|
|
1152
|
+
function $2c2b5be471529de8$var$_defineProperty(obj, key, value) {
|
|
1153
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
1154
|
+
value: value,
|
|
1155
|
+
enumerable: true,
|
|
1156
|
+
configurable: true,
|
|
1157
|
+
writable: true
|
|
1158
|
+
});
|
|
1159
|
+
else obj[key] = value;
|
|
1160
|
+
return obj;
|
|
1161
|
+
}
|
|
1162
|
+
function $2c2b5be471529de8$var$_classCallCheck(instance, Constructor) {
|
|
1163
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
1164
|
+
}
|
|
1165
|
+
function $2c2b5be471529de8$var$_defineProperties(target, props) {
|
|
1166
|
+
for(var i = 0; i < props.length; i++){
|
|
1167
|
+
var descriptor = props[i];
|
|
1168
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1169
|
+
descriptor.configurable = true;
|
|
1170
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1171
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
function $2c2b5be471529de8$var$_createClass(Constructor, protoProps, staticProps) {
|
|
1175
|
+
if (protoProps) $2c2b5be471529de8$var$_defineProperties(Constructor.prototype, protoProps);
|
|
1176
|
+
if (staticProps) $2c2b5be471529de8$var$_defineProperties(Constructor, staticProps);
|
|
1177
|
+
return Constructor;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
var $2c2b5be471529de8$var$Buffer = $gHtSl$Buffer;
|
|
1181
|
+
|
|
1182
|
+
var $2ueGT = parcelRequire("2ueGT");
|
|
1183
|
+
var $2c2b5be471529de8$var$inspect = $2ueGT.inspect;
|
|
1184
|
+
var $2c2b5be471529de8$var$custom = $2c2b5be471529de8$var$inspect && $2c2b5be471529de8$var$inspect.custom || "inspect";
|
|
1185
|
+
function $2c2b5be471529de8$var$copyBuffer(src, target, offset) {
|
|
1186
|
+
$2c2b5be471529de8$var$Buffer.prototype.copy.call(src, target, offset);
|
|
1187
|
+
}
|
|
1188
|
+
module.exports = /*#__PURE__*/ function() {
|
|
1189
|
+
function BufferList() {
|
|
1190
|
+
$2c2b5be471529de8$var$_classCallCheck(this, BufferList);
|
|
1191
|
+
this.head = null;
|
|
1192
|
+
this.tail = null;
|
|
1193
|
+
this.length = 0;
|
|
1194
|
+
}
|
|
1195
|
+
$2c2b5be471529de8$var$_createClass(BufferList, [
|
|
1196
|
+
{
|
|
1197
|
+
key: "push",
|
|
1198
|
+
value: function push(v) {
|
|
1199
|
+
var entry = {
|
|
1200
|
+
data: v,
|
|
1201
|
+
next: null
|
|
1202
|
+
};
|
|
1203
|
+
if (this.length > 0) this.tail.next = entry;
|
|
1204
|
+
else this.head = entry;
|
|
1205
|
+
this.tail = entry;
|
|
1206
|
+
++this.length;
|
|
1207
|
+
}
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
key: "unshift",
|
|
1211
|
+
value: function unshift(v) {
|
|
1212
|
+
var entry = {
|
|
1213
|
+
data: v,
|
|
1214
|
+
next: this.head
|
|
1215
|
+
};
|
|
1216
|
+
if (this.length === 0) this.tail = entry;
|
|
1217
|
+
this.head = entry;
|
|
1218
|
+
++this.length;
|
|
1219
|
+
}
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
key: "shift",
|
|
1223
|
+
value: function shift() {
|
|
1224
|
+
if (this.length === 0) return;
|
|
1225
|
+
var ret = this.head.data;
|
|
1226
|
+
if (this.length === 1) this.head = this.tail = null;
|
|
1227
|
+
else this.head = this.head.next;
|
|
1228
|
+
--this.length;
|
|
1229
|
+
return ret;
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
key: "clear",
|
|
1234
|
+
value: function clear() {
|
|
1235
|
+
this.head = this.tail = null;
|
|
1236
|
+
this.length = 0;
|
|
1237
|
+
}
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
key: "join",
|
|
1241
|
+
value: function join(s) {
|
|
1242
|
+
if (this.length === 0) return "";
|
|
1243
|
+
var p = this.head;
|
|
1244
|
+
var ret = "" + p.data;
|
|
1245
|
+
while(p = p.next)ret += s + p.data;
|
|
1246
|
+
return ret;
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
key: "concat",
|
|
1251
|
+
value: function concat(n) {
|
|
1252
|
+
if (this.length === 0) return $2c2b5be471529de8$var$Buffer.alloc(0);
|
|
1253
|
+
var ret = $2c2b5be471529de8$var$Buffer.allocUnsafe(n >>> 0);
|
|
1254
|
+
var p = this.head;
|
|
1255
|
+
var i = 0;
|
|
1256
|
+
while(p){
|
|
1257
|
+
$2c2b5be471529de8$var$copyBuffer(p.data, ret, i);
|
|
1258
|
+
i += p.data.length;
|
|
1259
|
+
p = p.next;
|
|
1260
|
+
}
|
|
1261
|
+
return ret;
|
|
1262
|
+
} // Consumes a specified amount of bytes or characters from the buffered data.
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
key: "consume",
|
|
1266
|
+
value: function consume(n, hasStrings) {
|
|
1267
|
+
var ret;
|
|
1268
|
+
if (n < this.head.data.length) {
|
|
1269
|
+
// `slice` is the same for buffers and strings.
|
|
1270
|
+
ret = this.head.data.slice(0, n);
|
|
1271
|
+
this.head.data = this.head.data.slice(n);
|
|
1272
|
+
} else if (n === this.head.data.length) // First chunk is a perfect match.
|
|
1273
|
+
ret = this.shift();
|
|
1274
|
+
else // Result spans more than one buffer.
|
|
1275
|
+
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
1276
|
+
return ret;
|
|
1277
|
+
}
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
key: "first",
|
|
1281
|
+
value: function first() {
|
|
1282
|
+
return this.head.data;
|
|
1283
|
+
} // Consumes a specified amount of characters from the buffered data.
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
key: "_getString",
|
|
1287
|
+
value: function _getString(n) {
|
|
1288
|
+
var p = this.head;
|
|
1289
|
+
var c = 1;
|
|
1290
|
+
var ret = p.data;
|
|
1291
|
+
n -= ret.length;
|
|
1292
|
+
while(p = p.next){
|
|
1293
|
+
var str = p.data;
|
|
1294
|
+
var nb = n > str.length ? str.length : n;
|
|
1295
|
+
if (nb === str.length) ret += str;
|
|
1296
|
+
else ret += str.slice(0, n);
|
|
1297
|
+
n -= nb;
|
|
1298
|
+
if (n === 0) {
|
|
1299
|
+
if (nb === str.length) {
|
|
1300
|
+
++c;
|
|
1301
|
+
if (p.next) this.head = p.next;
|
|
1302
|
+
else this.head = this.tail = null;
|
|
1303
|
+
} else {
|
|
1304
|
+
this.head = p;
|
|
1305
|
+
p.data = str.slice(nb);
|
|
1306
|
+
}
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
++c;
|
|
1310
|
+
}
|
|
1311
|
+
this.length -= c;
|
|
1312
|
+
return ret;
|
|
1313
|
+
} // Consumes a specified amount of bytes from the buffered data.
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
key: "_getBuffer",
|
|
1317
|
+
value: function _getBuffer(n) {
|
|
1318
|
+
var ret = $2c2b5be471529de8$var$Buffer.allocUnsafe(n);
|
|
1319
|
+
var p = this.head;
|
|
1320
|
+
var c = 1;
|
|
1321
|
+
p.data.copy(ret);
|
|
1322
|
+
n -= p.data.length;
|
|
1323
|
+
while(p = p.next){
|
|
1324
|
+
var buf = p.data;
|
|
1325
|
+
var nb = n > buf.length ? buf.length : n;
|
|
1326
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
1327
|
+
n -= nb;
|
|
1328
|
+
if (n === 0) {
|
|
1329
|
+
if (nb === buf.length) {
|
|
1330
|
+
++c;
|
|
1331
|
+
if (p.next) this.head = p.next;
|
|
1332
|
+
else this.head = this.tail = null;
|
|
1333
|
+
} else {
|
|
1334
|
+
this.head = p;
|
|
1335
|
+
p.data = buf.slice(nb);
|
|
1336
|
+
}
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
++c;
|
|
1340
|
+
}
|
|
1341
|
+
this.length -= c;
|
|
1342
|
+
return ret;
|
|
1343
|
+
} // Make sure the linked list only shows the minimal necessary information.
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
key: $2c2b5be471529de8$var$custom,
|
|
1347
|
+
value: function value(_, options) {
|
|
1348
|
+
return $2c2b5be471529de8$var$inspect(this, $2c2b5be471529de8$var$_objectSpread({}, options, {
|
|
1349
|
+
// Only inspect one level.
|
|
1350
|
+
depth: 0,
|
|
1351
|
+
// It should not recurse.
|
|
1352
|
+
customInspect: false
|
|
1353
|
+
}));
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
]);
|
|
1357
|
+
return BufferList;
|
|
1358
|
+
}();
|
|
1359
|
+
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
parcelRequire.register("dU5xr", function(module, exports) {
|
|
1363
|
+
"use strict"; // undocumented cb() API, needed for core, not for public API
|
|
1364
|
+
|
|
1365
|
+
function $a1f4cd1ecedd7243$var$destroy(err, cb) {
|
|
1366
|
+
var _this = this;
|
|
1367
|
+
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
1368
|
+
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
1369
|
+
if (readableDestroyed || writableDestroyed) {
|
|
1370
|
+
if (cb) cb(err);
|
|
1371
|
+
else if (err) {
|
|
1372
|
+
if (!this._writableState) $gHtSl$nextTick($a1f4cd1ecedd7243$var$emitErrorNT, this, err);
|
|
1373
|
+
else if (!this._writableState.errorEmitted) {
|
|
1374
|
+
this._writableState.errorEmitted = true;
|
|
1375
|
+
$gHtSl$nextTick($a1f4cd1ecedd7243$var$emitErrorNT, this, err);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return this;
|
|
1379
|
+
} // we set destroyed to true before firing error callbacks in order
|
|
1380
|
+
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
1381
|
+
if (this._readableState) this._readableState.destroyed = true;
|
|
1382
|
+
// if this is a duplex stream mark the writable part as destroyed as well
|
|
1383
|
+
if (this._writableState) this._writableState.destroyed = true;
|
|
1384
|
+
this._destroy(err || null, function(err) {
|
|
1385
|
+
if (!cb && err) {
|
|
1386
|
+
if (!_this._writableState) $gHtSl$nextTick($a1f4cd1ecedd7243$var$emitErrorAndCloseNT, _this, err);
|
|
1387
|
+
else if (!_this._writableState.errorEmitted) {
|
|
1388
|
+
_this._writableState.errorEmitted = true;
|
|
1389
|
+
$gHtSl$nextTick($a1f4cd1ecedd7243$var$emitErrorAndCloseNT, _this, err);
|
|
1390
|
+
} else $gHtSl$nextTick($a1f4cd1ecedd7243$var$emitCloseNT, _this);
|
|
1391
|
+
} else if (cb) {
|
|
1392
|
+
$gHtSl$nextTick($a1f4cd1ecedd7243$var$emitCloseNT, _this);
|
|
1393
|
+
cb(err);
|
|
1394
|
+
} else $gHtSl$nextTick($a1f4cd1ecedd7243$var$emitCloseNT, _this);
|
|
1395
|
+
});
|
|
1396
|
+
return this;
|
|
1397
|
+
}
|
|
1398
|
+
function $a1f4cd1ecedd7243$var$emitErrorAndCloseNT(self, err) {
|
|
1399
|
+
$a1f4cd1ecedd7243$var$emitErrorNT(self, err);
|
|
1400
|
+
$a1f4cd1ecedd7243$var$emitCloseNT(self);
|
|
1401
|
+
}
|
|
1402
|
+
function $a1f4cd1ecedd7243$var$emitCloseNT(self) {
|
|
1403
|
+
if (self._writableState && !self._writableState.emitClose) return;
|
|
1404
|
+
if (self._readableState && !self._readableState.emitClose) return;
|
|
1405
|
+
self.emit("close");
|
|
1406
|
+
}
|
|
1407
|
+
function $a1f4cd1ecedd7243$var$undestroy() {
|
|
1408
|
+
if (this._readableState) {
|
|
1409
|
+
this._readableState.destroyed = false;
|
|
1410
|
+
this._readableState.reading = false;
|
|
1411
|
+
this._readableState.ended = false;
|
|
1412
|
+
this._readableState.endEmitted = false;
|
|
1413
|
+
}
|
|
1414
|
+
if (this._writableState) {
|
|
1415
|
+
this._writableState.destroyed = false;
|
|
1416
|
+
this._writableState.ended = false;
|
|
1417
|
+
this._writableState.ending = false;
|
|
1418
|
+
this._writableState.finalCalled = false;
|
|
1419
|
+
this._writableState.prefinished = false;
|
|
1420
|
+
this._writableState.finished = false;
|
|
1421
|
+
this._writableState.errorEmitted = false;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
function $a1f4cd1ecedd7243$var$emitErrorNT(self, err) {
|
|
1425
|
+
self.emit("error", err);
|
|
1426
|
+
}
|
|
1427
|
+
function $a1f4cd1ecedd7243$var$errorOrDestroy(stream, err) {
|
|
1428
|
+
// We have tests that rely on errors being emitted
|
|
1429
|
+
// in the same tick, so changing this is semver major.
|
|
1430
|
+
// For now when you opt-in to autoDestroy we allow
|
|
1431
|
+
// the error to be emitted nextTick. In a future
|
|
1432
|
+
// semver major update we should change the default to this.
|
|
1433
|
+
var rState = stream._readableState;
|
|
1434
|
+
var wState = stream._writableState;
|
|
1435
|
+
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);
|
|
1436
|
+
else stream.emit("error", err);
|
|
1437
|
+
}
|
|
1438
|
+
module.exports = {
|
|
1439
|
+
destroy: $a1f4cd1ecedd7243$var$destroy,
|
|
1440
|
+
undestroy: $a1f4cd1ecedd7243$var$undestroy,
|
|
1441
|
+
errorOrDestroy: $a1f4cd1ecedd7243$var$errorOrDestroy
|
|
1442
|
+
};
|
|
1443
|
+
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
parcelRequire.register("eGsJg", function(module, exports) {
|
|
1447
|
+
"use strict";
|
|
1448
|
+
|
|
1449
|
+
var $6vYby = parcelRequire("6vYby");
|
|
1450
|
+
var $ab0b45e6eae1438e$var$ERR_INVALID_OPT_VALUE = $6vYby.codes.ERR_INVALID_OPT_VALUE;
|
|
1451
|
+
function $ab0b45e6eae1438e$var$highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
1452
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
1453
|
+
}
|
|
1454
|
+
function $ab0b45e6eae1438e$var$getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
1455
|
+
var hwm = $ab0b45e6eae1438e$var$highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
1456
|
+
if (hwm != null) {
|
|
1457
|
+
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
1458
|
+
var name = isDuplex ? duplexKey : "highWaterMark";
|
|
1459
|
+
throw new $ab0b45e6eae1438e$var$ERR_INVALID_OPT_VALUE(name, hwm);
|
|
1460
|
+
}
|
|
1461
|
+
return Math.floor(hwm);
|
|
1462
|
+
} // Default value
|
|
1463
|
+
return state.objectMode ? 16 : 16384;
|
|
1464
|
+
}
|
|
1465
|
+
module.exports = {
|
|
1466
|
+
getHighWaterMark: $ab0b45e6eae1438e$var$getHighWaterMark
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
});
|
|
1470
|
+
parcelRequire.register("6vYby", function(module, exports) {
|
|
1471
|
+
|
|
1472
|
+
$parcel$export(module.exports, "codes", function () { return $4be452dd8f02bf99$export$e45cb6485273080e; }, function (v) { return $4be452dd8f02bf99$export$e45cb6485273080e = v; });
|
|
1473
|
+
var $4be452dd8f02bf99$export$e45cb6485273080e;
|
|
1474
|
+
"use strict";
|
|
1475
|
+
function $4be452dd8f02bf99$var$_inheritsLoose(subClass, superClass) {
|
|
1476
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
1477
|
+
subClass.prototype.constructor = subClass;
|
|
1478
|
+
subClass.__proto__ = superClass;
|
|
1479
|
+
}
|
|
1480
|
+
var $4be452dd8f02bf99$var$codes = {};
|
|
1481
|
+
function $4be452dd8f02bf99$var$createErrorType(code, message, Base) {
|
|
1482
|
+
if (!Base) Base = Error;
|
|
1483
|
+
function getMessage(arg1, arg2, arg3) {
|
|
1484
|
+
if (typeof message === "string") return message;
|
|
1485
|
+
else return message(arg1, arg2, arg3);
|
|
1486
|
+
}
|
|
1487
|
+
var NodeError = /*#__PURE__*/ function(_Base) {
|
|
1488
|
+
$4be452dd8f02bf99$var$_inheritsLoose(NodeError, _Base);
|
|
1489
|
+
function NodeError(arg1, arg2, arg3) {
|
|
1490
|
+
return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
|
|
1491
|
+
}
|
|
1492
|
+
return NodeError;
|
|
1493
|
+
}(Base);
|
|
1494
|
+
NodeError.prototype.name = Base.name;
|
|
1495
|
+
NodeError.prototype.code = code;
|
|
1496
|
+
$4be452dd8f02bf99$var$codes[code] = NodeError;
|
|
1497
|
+
} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
|
|
1498
|
+
function $4be452dd8f02bf99$var$oneOf(expected, thing) {
|
|
1499
|
+
if (Array.isArray(expected)) {
|
|
1500
|
+
var len = expected.length;
|
|
1501
|
+
expected = expected.map(function(i) {
|
|
1502
|
+
return String(i);
|
|
1503
|
+
});
|
|
1504
|
+
if (len > 2) return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(", "), ", or ") + expected[len - 1];
|
|
1505
|
+
else if (len === 2) return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
|
|
1506
|
+
else return "of ".concat(thing, " ").concat(expected[0]);
|
|
1507
|
+
} else return "of ".concat(thing, " ").concat(String(expected));
|
|
1508
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
|
|
1509
|
+
function $4be452dd8f02bf99$var$startsWith(str, search, pos) {
|
|
1510
|
+
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
1511
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
1512
|
+
function $4be452dd8f02bf99$var$endsWith(str, search, this_len) {
|
|
1513
|
+
if (this_len === undefined || this_len > str.length) this_len = str.length;
|
|
1514
|
+
return str.substring(this_len - search.length, this_len) === search;
|
|
1515
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
|
1516
|
+
function $4be452dd8f02bf99$var$includes(str, search, start) {
|
|
1517
|
+
if (typeof start !== "number") start = 0;
|
|
1518
|
+
if (start + search.length > str.length) return false;
|
|
1519
|
+
else return str.indexOf(search, start) !== -1;
|
|
1520
|
+
}
|
|
1521
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) {
|
|
1522
|
+
return 'The value "' + value + '" is invalid for option "' + name + '"';
|
|
1523
|
+
}, TypeError);
|
|
1524
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) {
|
|
1525
|
+
// determiner: 'must be' or 'must not be'
|
|
1526
|
+
var determiner;
|
|
1527
|
+
if (typeof expected === "string" && $4be452dd8f02bf99$var$startsWith(expected, "not ")) {
|
|
1528
|
+
determiner = "must not be";
|
|
1529
|
+
expected = expected.replace(/^not /, "");
|
|
1530
|
+
} else determiner = "must be";
|
|
1531
|
+
var msg;
|
|
1532
|
+
if ($4be452dd8f02bf99$var$endsWith(name, " argument")) // For cases like 'first argument'
|
|
1533
|
+
msg = "The ".concat(name, " ").concat(determiner, " ").concat($4be452dd8f02bf99$var$oneOf(expected, "type"));
|
|
1534
|
+
else {
|
|
1535
|
+
var type = $4be452dd8f02bf99$var$includes(name, ".") ? "property" : "argument";
|
|
1536
|
+
msg = 'The "'.concat(name, '" ').concat(type, " ").concat(determiner, " ").concat($4be452dd8f02bf99$var$oneOf(expected, "type"));
|
|
1537
|
+
}
|
|
1538
|
+
msg += ". Received type ".concat(typeof actual);
|
|
1539
|
+
return msg;
|
|
1540
|
+
}, TypeError);
|
|
1541
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
|
|
1542
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) {
|
|
1543
|
+
return "The " + name + " method is not implemented";
|
|
1544
|
+
});
|
|
1545
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
|
|
1546
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_DESTROYED", function(name) {
|
|
1547
|
+
return "Cannot call " + name + " after a stream was destroyed";
|
|
1548
|
+
});
|
|
1549
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
|
|
1550
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
|
|
1551
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
|
|
1552
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
|
|
1553
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_UNKNOWN_ENCODING", function(arg) {
|
|
1554
|
+
return "Unknown encoding: " + arg;
|
|
1555
|
+
}, TypeError);
|
|
1556
|
+
$4be452dd8f02bf99$var$createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
|
|
1557
|
+
$4be452dd8f02bf99$export$e45cb6485273080e = $4be452dd8f02bf99$var$codes;
|
|
1558
|
+
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
parcelRequire.register("ghwEg", function(module, exports) {
|
|
1563
|
+
if (typeof Object.create === "function") // implementation from standard node.js 'util' module
|
|
1564
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
1565
|
+
if (superCtor) {
|
|
1566
|
+
ctor.super_ = superCtor;
|
|
1567
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
1568
|
+
constructor: {
|
|
1569
|
+
value: ctor,
|
|
1570
|
+
enumerable: false,
|
|
1571
|
+
writable: true,
|
|
1572
|
+
configurable: true
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
else // old school shim for old browsers
|
|
1578
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
1579
|
+
if (superCtor) {
|
|
1580
|
+
ctor.super_ = superCtor;
|
|
1581
|
+
var TempCtor = function() {};
|
|
1582
|
+
TempCtor.prototype = superCtor.prototype;
|
|
1583
|
+
ctor.prototype = new TempCtor();
|
|
1584
|
+
ctor.prototype.constructor = ctor;
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
parcelRequire.register("cK2wf", function(module, exports) {
|
|
1591
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
1592
|
+
//
|
|
1593
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
1594
|
+
// copy of this software and associated documentation files (the
|
|
1595
|
+
// "Software"), to deal in the Software without restriction, including
|
|
1596
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
1597
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
1598
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
1599
|
+
// following conditions:
|
|
1600
|
+
//
|
|
1601
|
+
// The above copyright notice and this permission notice shall be included
|
|
1602
|
+
// in all copies or substantial portions of the Software.
|
|
1603
|
+
//
|
|
1604
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
1605
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1606
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
1607
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
1608
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
1609
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
1610
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1611
|
+
// a duplex stream is just a stream that is both readable and writable.
|
|
1612
|
+
// Since JS doesn't have multiple prototypal inheritance, this class
|
|
1613
|
+
// prototypally inherits from Readable, and then parasitically from
|
|
1614
|
+
// Writable.
|
|
1615
|
+
"use strict";
|
|
1616
|
+
|
|
1617
|
+
/*<replacement>*/ var $946bbc2642280585$var$objectKeys = Object.keys || function(obj) {
|
|
1618
|
+
var keys = [];
|
|
1619
|
+
for(var key in obj)keys.push(key);
|
|
1620
|
+
return keys;
|
|
1621
|
+
};
|
|
1622
|
+
/*</replacement>*/ module.exports = $946bbc2642280585$var$Duplex;
|
|
1623
|
+
|
|
1624
|
+
var $dRV5p = parcelRequire("dRV5p");
|
|
1625
|
+
|
|
1626
|
+
var $8T77c = parcelRequire("8T77c");
|
|
1627
|
+
|
|
1628
|
+
(parcelRequire("ghwEg"))($946bbc2642280585$var$Duplex, $dRV5p);
|
|
1629
|
+
// Allow the keys array to be GC'ed.
|
|
1630
|
+
var $946bbc2642280585$var$keys = $946bbc2642280585$var$objectKeys($8T77c.prototype);
|
|
1631
|
+
for(var $946bbc2642280585$var$v = 0; $946bbc2642280585$var$v < $946bbc2642280585$var$keys.length; $946bbc2642280585$var$v++){
|
|
1632
|
+
var $946bbc2642280585$var$method = $946bbc2642280585$var$keys[$946bbc2642280585$var$v];
|
|
1633
|
+
if (!$946bbc2642280585$var$Duplex.prototype[$946bbc2642280585$var$method]) $946bbc2642280585$var$Duplex.prototype[$946bbc2642280585$var$method] = $8T77c.prototype[$946bbc2642280585$var$method];
|
|
1634
|
+
}
|
|
1635
|
+
function $946bbc2642280585$var$Duplex(options) {
|
|
1636
|
+
if (!(this instanceof $946bbc2642280585$var$Duplex)) return new $946bbc2642280585$var$Duplex(options);
|
|
1637
|
+
$dRV5p.call(this, options);
|
|
1638
|
+
$8T77c.call(this, options);
|
|
1639
|
+
this.allowHalfOpen = true;
|
|
1640
|
+
if (options) {
|
|
1641
|
+
if (options.readable === false) this.readable = false;
|
|
1642
|
+
if (options.writable === false) this.writable = false;
|
|
1643
|
+
if (options.allowHalfOpen === false) {
|
|
1644
|
+
this.allowHalfOpen = false;
|
|
1645
|
+
this.once("end", $946bbc2642280585$var$onend);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
Object.defineProperty($946bbc2642280585$var$Duplex.prototype, "writableHighWaterMark", {
|
|
1650
|
+
// making it explicit this property is not enumerable
|
|
1651
|
+
// because otherwise some prototype manipulation in
|
|
1652
|
+
// userland will fail
|
|
1653
|
+
enumerable: false,
|
|
1654
|
+
get: function get() {
|
|
1655
|
+
return this._writableState.highWaterMark;
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
Object.defineProperty($946bbc2642280585$var$Duplex.prototype, "writableBuffer", {
|
|
1659
|
+
// making it explicit this property is not enumerable
|
|
1660
|
+
// because otherwise some prototype manipulation in
|
|
1661
|
+
// userland will fail
|
|
1662
|
+
enumerable: false,
|
|
1663
|
+
get: function get() {
|
|
1664
|
+
return this._writableState && this._writableState.getBuffer();
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
Object.defineProperty($946bbc2642280585$var$Duplex.prototype, "writableLength", {
|
|
1668
|
+
// making it explicit this property is not enumerable
|
|
1669
|
+
// because otherwise some prototype manipulation in
|
|
1670
|
+
// userland will fail
|
|
1671
|
+
enumerable: false,
|
|
1672
|
+
get: function get() {
|
|
1673
|
+
return this._writableState.length;
|
|
1674
|
+
}
|
|
1675
|
+
}); // the no-half-open enforcer
|
|
1676
|
+
function $946bbc2642280585$var$onend() {
|
|
1677
|
+
// If the writable side ended, then we're ok.
|
|
1678
|
+
if (this._writableState.ended) return; // no more data can be written.
|
|
1679
|
+
// But allow more writes to happen in this tick.
|
|
1680
|
+
$gHtSl$nextTick($946bbc2642280585$var$onEndNT, this);
|
|
1681
|
+
}
|
|
1682
|
+
function $946bbc2642280585$var$onEndNT(self) {
|
|
1683
|
+
self.end();
|
|
1684
|
+
}
|
|
1685
|
+
Object.defineProperty($946bbc2642280585$var$Duplex.prototype, "destroyed", {
|
|
1686
|
+
// making it explicit this property is not enumerable
|
|
1687
|
+
// because otherwise some prototype manipulation in
|
|
1688
|
+
// userland will fail
|
|
1689
|
+
enumerable: false,
|
|
1690
|
+
get: function get() {
|
|
1691
|
+
if (this._readableState === undefined || this._writableState === undefined) return false;
|
|
1692
|
+
return this._readableState.destroyed && this._writableState.destroyed;
|
|
1693
|
+
},
|
|
1694
|
+
set: function set(value) {
|
|
1695
|
+
// we ignore the value if the stream
|
|
1696
|
+
// has not been initialized yet
|
|
1697
|
+
if (this._readableState === undefined || this._writableState === undefined) return;
|
|
1698
|
+
// backward compatibility, the user is explicitly
|
|
1699
|
+
// managing destroyed
|
|
1700
|
+
this._readableState.destroyed = value;
|
|
1701
|
+
this._writableState.destroyed = value;
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1705
|
+
});
|
|
1706
|
+
parcelRequire.register("8T77c", function(module, exports) {
|
|
1707
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
1708
|
+
//
|
|
1709
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
1710
|
+
// copy of this software and associated documentation files (the
|
|
1711
|
+
// "Software"), to deal in the Software without restriction, including
|
|
1712
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
1713
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
1714
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
1715
|
+
// following conditions:
|
|
1716
|
+
//
|
|
1717
|
+
// The above copyright notice and this permission notice shall be included
|
|
1718
|
+
// in all copies or substantial portions of the Software.
|
|
1719
|
+
//
|
|
1720
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
1721
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1722
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
1723
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
1724
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
1725
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
1726
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1727
|
+
// A bit simpler than readable streams.
|
|
1728
|
+
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
|
1729
|
+
// the drain event emission and buffering.
|
|
1730
|
+
"use strict";
|
|
1731
|
+
|
|
1732
|
+
module.exports = $6788fab3cd405652$var$Writable;
|
|
1733
|
+
/* <replacement> */ function $6788fab3cd405652$var$WriteReq(chunk, encoding, cb) {
|
|
1734
|
+
this.chunk = chunk;
|
|
1735
|
+
this.encoding = encoding;
|
|
1736
|
+
this.callback = cb;
|
|
1737
|
+
this.next = null;
|
|
1738
|
+
} // It seems a linked list but it is not
|
|
1739
|
+
// there will be only 2 of these for each stream
|
|
1740
|
+
function $6788fab3cd405652$var$CorkedRequest(state) {
|
|
1741
|
+
var _this = this;
|
|
1742
|
+
this.next = null;
|
|
1743
|
+
this.entry = null;
|
|
1744
|
+
this.finish = function() {
|
|
1745
|
+
$6788fab3cd405652$var$onCorkedFinish(_this, state);
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
/* </replacement> */ /*<replacement>*/ var $6788fab3cd405652$var$Duplex;
|
|
1749
|
+
/*</replacement>*/ $6788fab3cd405652$var$Writable.WritableState = $6788fab3cd405652$var$WritableState;
|
|
1750
|
+
|
|
1751
|
+
/*<replacement>*/ var $6788fab3cd405652$var$internalUtil = {
|
|
1752
|
+
deprecate: (parcelRequire("gj4lB"))
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
var $47Ymo = parcelRequire("47Ymo");
|
|
1756
|
+
|
|
1757
|
+
var $6788fab3cd405652$require$Buffer = $gHtSl$Buffer;
|
|
1758
|
+
var $6788fab3cd405652$var$OurUint8Array = $parcel$global.Uint8Array || function() {};
|
|
1759
|
+
function $6788fab3cd405652$var$_uint8ArrayToBuffer(chunk) {
|
|
1760
|
+
return $6788fab3cd405652$require$Buffer.from(chunk);
|
|
1761
|
+
}
|
|
1762
|
+
function $6788fab3cd405652$var$_isUint8Array(obj) {
|
|
1763
|
+
return $6788fab3cd405652$require$Buffer.isBuffer(obj) || obj instanceof $6788fab3cd405652$var$OurUint8Array;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
var $dU5xr = parcelRequire("dU5xr");
|
|
1767
|
+
|
|
1768
|
+
var $eGsJg = parcelRequire("eGsJg");
|
|
1769
|
+
var $6788fab3cd405652$var$getHighWaterMark = $eGsJg.getHighWaterMark;
|
|
1770
|
+
|
|
1771
|
+
var $6vYby = parcelRequire("6vYby");
|
|
1772
|
+
var $6788fab3cd405652$require$_require$codes = $6vYby.codes;
|
|
1773
|
+
var $6788fab3cd405652$var$ERR_INVALID_ARG_TYPE = $6788fab3cd405652$require$_require$codes.ERR_INVALID_ARG_TYPE, $6788fab3cd405652$var$ERR_METHOD_NOT_IMPLEMENTED = $6788fab3cd405652$require$_require$codes.ERR_METHOD_NOT_IMPLEMENTED, $6788fab3cd405652$var$ERR_MULTIPLE_CALLBACK = $6788fab3cd405652$require$_require$codes.ERR_MULTIPLE_CALLBACK, $6788fab3cd405652$var$ERR_STREAM_CANNOT_PIPE = $6788fab3cd405652$require$_require$codes.ERR_STREAM_CANNOT_PIPE, $6788fab3cd405652$var$ERR_STREAM_DESTROYED = $6788fab3cd405652$require$_require$codes.ERR_STREAM_DESTROYED, $6788fab3cd405652$var$ERR_STREAM_NULL_VALUES = $6788fab3cd405652$require$_require$codes.ERR_STREAM_NULL_VALUES, $6788fab3cd405652$var$ERR_STREAM_WRITE_AFTER_END = $6788fab3cd405652$require$_require$codes.ERR_STREAM_WRITE_AFTER_END, $6788fab3cd405652$var$ERR_UNKNOWN_ENCODING = $6788fab3cd405652$require$_require$codes.ERR_UNKNOWN_ENCODING;
|
|
1774
|
+
var $6788fab3cd405652$var$errorOrDestroy = $dU5xr.errorOrDestroy;
|
|
1775
|
+
|
|
1776
|
+
(parcelRequire("ghwEg"))($6788fab3cd405652$var$Writable, $47Ymo);
|
|
1777
|
+
function $6788fab3cd405652$var$nop() {}
|
|
1778
|
+
|
|
1779
|
+
function $6788fab3cd405652$var$WritableState(options, stream, isDuplex) {
|
|
1780
|
+
$6788fab3cd405652$var$Duplex = $6788fab3cd405652$var$Duplex || (parcelRequire("cK2wf"));
|
|
1781
|
+
options = options || {}; // Duplex streams are both readable and writable, but share
|
|
1782
|
+
// the same options object.
|
|
1783
|
+
// However, some cases require setting options to different
|
|
1784
|
+
// values for the readable and the writable sides of the duplex stream,
|
|
1785
|
+
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
|
|
1786
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof $6788fab3cd405652$var$Duplex; // object stream flag to indicate whether or not this stream
|
|
1787
|
+
// contains buffers or objects.
|
|
1788
|
+
this.objectMode = !!options.objectMode;
|
|
1789
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
|
|
1790
|
+
// Note: 0 is a valid value, means that we always return false if
|
|
1791
|
+
// the entire buffer is not flushed immediately on write()
|
|
1792
|
+
this.highWaterMark = $6788fab3cd405652$var$getHighWaterMark(this, options, "writableHighWaterMark", isDuplex); // if _final has been called
|
|
1793
|
+
this.finalCalled = false; // drain event flag.
|
|
1794
|
+
this.needDrain = false; // at the start of calling end()
|
|
1795
|
+
this.ending = false; // when end() has been called, and returned
|
|
1796
|
+
this.ended = false; // when 'finish' is emitted
|
|
1797
|
+
this.finished = false; // has it been destroyed
|
|
1798
|
+
this.destroyed = false; // should we decode strings into buffers before passing to _write?
|
|
1799
|
+
// this is here so that some node-core streams can optimize string
|
|
1800
|
+
// handling at a lower level.
|
|
1801
|
+
var noDecode = options.decodeStrings === false;
|
|
1802
|
+
this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
|
|
1803
|
+
// encoding is 'binary' so we have to make this configurable.
|
|
1804
|
+
// Everything else in the universe uses 'utf8', though.
|
|
1805
|
+
this.defaultEncoding = options.defaultEncoding || "utf8"; // not an actual buffer we keep track of, but a measurement
|
|
1806
|
+
// of how much we're waiting to get pushed to some underlying
|
|
1807
|
+
// socket or file.
|
|
1808
|
+
this.length = 0; // a flag to see when we're in the middle of a write.
|
|
1809
|
+
this.writing = false; // when true all writes will be buffered until .uncork() call
|
|
1810
|
+
this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
|
|
1811
|
+
// or on a later tick. We set this to true at first, because any
|
|
1812
|
+
// actions that shouldn't happen until "later" should generally also
|
|
1813
|
+
// not happen before the first write call.
|
|
1814
|
+
this.sync = true; // a flag to know if we're processing previously buffered items, which
|
|
1815
|
+
// may call the _write() callback in the same tick, so that we don't
|
|
1816
|
+
// end up in an overlapped onwrite situation.
|
|
1817
|
+
this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
|
|
1818
|
+
this.onwrite = function(er) {
|
|
1819
|
+
$6788fab3cd405652$var$onwrite(stream, er);
|
|
1820
|
+
}; // the callback that the user supplies to write(chunk,encoding,cb)
|
|
1821
|
+
this.writecb = null; // the amount that is being written when _write is called.
|
|
1822
|
+
this.writelen = 0;
|
|
1823
|
+
this.bufferedRequest = null;
|
|
1824
|
+
this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
|
|
1825
|
+
// this must be 0 before 'finish' can be emitted
|
|
1826
|
+
this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
|
|
1827
|
+
// This is relevant for synchronous Transform streams
|
|
1828
|
+
this.prefinished = false; // True if the error was already emitted and should not be thrown again
|
|
1829
|
+
this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
|
|
1830
|
+
this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
|
|
1831
|
+
this.autoDestroy = !!options.autoDestroy; // count buffered requests
|
|
1832
|
+
this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
|
|
1833
|
+
// one allocated and free to use, and we maintain at most two
|
|
1834
|
+
this.corkedRequestsFree = new $6788fab3cd405652$var$CorkedRequest(this);
|
|
1835
|
+
}
|
|
1836
|
+
$6788fab3cd405652$var$WritableState.prototype.getBuffer = function getBuffer() {
|
|
1837
|
+
var current = this.bufferedRequest;
|
|
1838
|
+
var out = [];
|
|
1839
|
+
while(current){
|
|
1840
|
+
out.push(current);
|
|
1841
|
+
current = current.next;
|
|
1842
|
+
}
|
|
1843
|
+
return out;
|
|
1844
|
+
};
|
|
1845
|
+
(function() {
|
|
1846
|
+
try {
|
|
1847
|
+
Object.defineProperty($6788fab3cd405652$var$WritableState.prototype, "buffer", {
|
|
1848
|
+
get: $6788fab3cd405652$var$internalUtil.deprecate(function writableStateBufferGetter() {
|
|
1849
|
+
return this.getBuffer();
|
|
1850
|
+
}, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")
|
|
1851
|
+
});
|
|
1852
|
+
} catch (_) {}
|
|
1853
|
+
})(); // Test _writableState for inheritance to account for Duplex streams,
|
|
1854
|
+
// whose prototype chain only points to Readable.
|
|
1855
|
+
var $6788fab3cd405652$var$realHasInstance;
|
|
1856
|
+
if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
|
|
1857
|
+
$6788fab3cd405652$var$realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
1858
|
+
Object.defineProperty($6788fab3cd405652$var$Writable, Symbol.hasInstance, {
|
|
1859
|
+
value: function value(object) {
|
|
1860
|
+
if ($6788fab3cd405652$var$realHasInstance.call(this, object)) return true;
|
|
1861
|
+
if (this !== $6788fab3cd405652$var$Writable) return false;
|
|
1862
|
+
return object && object._writableState instanceof $6788fab3cd405652$var$WritableState;
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
} else $6788fab3cd405652$var$realHasInstance = function realHasInstance(object) {
|
|
1866
|
+
return object instanceof this;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
function $6788fab3cd405652$var$Writable(options) {
|
|
1870
|
+
$6788fab3cd405652$var$Duplex = $6788fab3cd405652$var$Duplex || (parcelRequire("cK2wf")); // Writable ctor is applied to Duplexes, too.
|
|
1871
|
+
// `realHasInstance` is necessary because using plain `instanceof`
|
|
1872
|
+
// would return false, as no `_writableState` property is attached.
|
|
1873
|
+
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
1874
|
+
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
1875
|
+
// `_writableState` that would lead to infinite recursion.
|
|
1876
|
+
// Checking for a Stream.Duplex instance is faster here instead of inside
|
|
1877
|
+
// the WritableState constructor, at least with V8 6.5
|
|
1878
|
+
var isDuplex = this instanceof $6788fab3cd405652$var$Duplex;
|
|
1879
|
+
if (!isDuplex && !$6788fab3cd405652$var$realHasInstance.call($6788fab3cd405652$var$Writable, this)) return new $6788fab3cd405652$var$Writable(options);
|
|
1880
|
+
this._writableState = new $6788fab3cd405652$var$WritableState(options, this, isDuplex); // legacy.
|
|
1881
|
+
this.writable = true;
|
|
1882
|
+
if (options) {
|
|
1883
|
+
if (typeof options.write === "function") this._write = options.write;
|
|
1884
|
+
if (typeof options.writev === "function") this._writev = options.writev;
|
|
1885
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
1886
|
+
if (typeof options.final === "function") this._final = options.final;
|
|
1887
|
+
}
|
|
1888
|
+
$47Ymo.call(this);
|
|
1889
|
+
} // Otherwise people can pipe Writable streams, which is just wrong.
|
|
1890
|
+
$6788fab3cd405652$var$Writable.prototype.pipe = function() {
|
|
1891
|
+
$6788fab3cd405652$var$errorOrDestroy(this, new $6788fab3cd405652$var$ERR_STREAM_CANNOT_PIPE());
|
|
1892
|
+
};
|
|
1893
|
+
function $6788fab3cd405652$var$writeAfterEnd(stream, cb) {
|
|
1894
|
+
var er = new $6788fab3cd405652$var$ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
|
|
1895
|
+
$6788fab3cd405652$var$errorOrDestroy(stream, er);
|
|
1896
|
+
$gHtSl$nextTick(cb, er);
|
|
1897
|
+
} // Checks that a user-supplied chunk is valid, especially for the particular
|
|
1898
|
+
// mode the stream is in. Currently this means that `null` is never accepted
|
|
1899
|
+
// and undefined/non-string values are only allowed in object mode.
|
|
1900
|
+
function $6788fab3cd405652$var$validChunk(stream, state, chunk, cb) {
|
|
1901
|
+
var er;
|
|
1902
|
+
if (chunk === null) er = new $6788fab3cd405652$var$ERR_STREAM_NULL_VALUES();
|
|
1903
|
+
else if (typeof chunk !== "string" && !state.objectMode) er = new $6788fab3cd405652$var$ERR_INVALID_ARG_TYPE("chunk", [
|
|
1904
|
+
"string",
|
|
1905
|
+
"Buffer"
|
|
1906
|
+
], chunk);
|
|
1907
|
+
if (er) {
|
|
1908
|
+
$6788fab3cd405652$var$errorOrDestroy(stream, er);
|
|
1909
|
+
$gHtSl$nextTick(cb, er);
|
|
1910
|
+
return false;
|
|
1911
|
+
}
|
|
1912
|
+
return true;
|
|
1913
|
+
}
|
|
1914
|
+
$6788fab3cd405652$var$Writable.prototype.write = function(chunk, encoding, cb) {
|
|
1915
|
+
var state = this._writableState;
|
|
1916
|
+
var ret = false;
|
|
1917
|
+
var isBuf = !state.objectMode && $6788fab3cd405652$var$_isUint8Array(chunk);
|
|
1918
|
+
if (isBuf && !$6788fab3cd405652$require$Buffer.isBuffer(chunk)) chunk = $6788fab3cd405652$var$_uint8ArrayToBuffer(chunk);
|
|
1919
|
+
if (typeof encoding === "function") {
|
|
1920
|
+
cb = encoding;
|
|
1921
|
+
encoding = null;
|
|
1922
|
+
}
|
|
1923
|
+
if (isBuf) encoding = "buffer";
|
|
1924
|
+
else if (!encoding) encoding = state.defaultEncoding;
|
|
1925
|
+
if (typeof cb !== "function") cb = $6788fab3cd405652$var$nop;
|
|
1926
|
+
if (state.ending) $6788fab3cd405652$var$writeAfterEnd(this, cb);
|
|
1927
|
+
else if (isBuf || $6788fab3cd405652$var$validChunk(this, state, chunk, cb)) {
|
|
1928
|
+
state.pendingcb++;
|
|
1929
|
+
ret = $6788fab3cd405652$var$writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
1930
|
+
}
|
|
1931
|
+
return ret;
|
|
1932
|
+
};
|
|
1933
|
+
$6788fab3cd405652$var$Writable.prototype.cork = function() {
|
|
1934
|
+
this._writableState.corked++;
|
|
1935
|
+
};
|
|
1936
|
+
$6788fab3cd405652$var$Writable.prototype.uncork = function() {
|
|
1937
|
+
var state = this._writableState;
|
|
1938
|
+
if (state.corked) {
|
|
1939
|
+
state.corked--;
|
|
1940
|
+
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) $6788fab3cd405652$var$clearBuffer(this, state);
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
$6788fab3cd405652$var$Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
1944
|
+
// node::ParseEncoding() requires lower case.
|
|
1945
|
+
if (typeof encoding === "string") encoding = encoding.toLowerCase();
|
|
1946
|
+
if (!([
|
|
1947
|
+
"hex",
|
|
1948
|
+
"utf8",
|
|
1949
|
+
"utf-8",
|
|
1950
|
+
"ascii",
|
|
1951
|
+
"binary",
|
|
1952
|
+
"base64",
|
|
1953
|
+
"ucs2",
|
|
1954
|
+
"ucs-2",
|
|
1955
|
+
"utf16le",
|
|
1956
|
+
"utf-16le",
|
|
1957
|
+
"raw"
|
|
1958
|
+
].indexOf((encoding + "").toLowerCase()) > -1)) throw new $6788fab3cd405652$var$ERR_UNKNOWN_ENCODING(encoding);
|
|
1959
|
+
this._writableState.defaultEncoding = encoding;
|
|
1960
|
+
return this;
|
|
1961
|
+
};
|
|
1962
|
+
Object.defineProperty($6788fab3cd405652$var$Writable.prototype, "writableBuffer", {
|
|
1963
|
+
// making it explicit this property is not enumerable
|
|
1964
|
+
// because otherwise some prototype manipulation in
|
|
1965
|
+
// userland will fail
|
|
1966
|
+
enumerable: false,
|
|
1967
|
+
get: function get() {
|
|
1968
|
+
return this._writableState && this._writableState.getBuffer();
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
function $6788fab3cd405652$var$decodeChunk(state, chunk, encoding) {
|
|
1972
|
+
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = $6788fab3cd405652$require$Buffer.from(chunk, encoding);
|
|
1973
|
+
return chunk;
|
|
1974
|
+
}
|
|
1975
|
+
Object.defineProperty($6788fab3cd405652$var$Writable.prototype, "writableHighWaterMark", {
|
|
1976
|
+
// making it explicit this property is not enumerable
|
|
1977
|
+
// because otherwise some prototype manipulation in
|
|
1978
|
+
// userland will fail
|
|
1979
|
+
enumerable: false,
|
|
1980
|
+
get: function get() {
|
|
1981
|
+
return this._writableState.highWaterMark;
|
|
1982
|
+
}
|
|
1983
|
+
}); // if we're already writing something, then just put this
|
|
1984
|
+
// in the queue, and wait our turn. Otherwise, call _write
|
|
1985
|
+
// If we return false, then we need a drain event, so set that flag.
|
|
1986
|
+
function $6788fab3cd405652$var$writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
1987
|
+
if (!isBuf) {
|
|
1988
|
+
var newChunk = $6788fab3cd405652$var$decodeChunk(state, chunk, encoding);
|
|
1989
|
+
if (chunk !== newChunk) {
|
|
1990
|
+
isBuf = true;
|
|
1991
|
+
encoding = "buffer";
|
|
1992
|
+
chunk = newChunk;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
1996
|
+
state.length += len;
|
|
1997
|
+
var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
|
|
1998
|
+
if (!ret) state.needDrain = true;
|
|
1999
|
+
if (state.writing || state.corked) {
|
|
2000
|
+
var last = state.lastBufferedRequest;
|
|
2001
|
+
state.lastBufferedRequest = {
|
|
2002
|
+
chunk: chunk,
|
|
2003
|
+
encoding: encoding,
|
|
2004
|
+
isBuf: isBuf,
|
|
2005
|
+
callback: cb,
|
|
2006
|
+
next: null
|
|
2007
|
+
};
|
|
2008
|
+
if (last) last.next = state.lastBufferedRequest;
|
|
2009
|
+
else state.bufferedRequest = state.lastBufferedRequest;
|
|
2010
|
+
state.bufferedRequestCount += 1;
|
|
2011
|
+
} else $6788fab3cd405652$var$doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
2012
|
+
return ret;
|
|
2013
|
+
}
|
|
2014
|
+
function $6788fab3cd405652$var$doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
2015
|
+
state.writelen = len;
|
|
2016
|
+
state.writecb = cb;
|
|
2017
|
+
state.writing = true;
|
|
2018
|
+
state.sync = true;
|
|
2019
|
+
if (state.destroyed) state.onwrite(new $6788fab3cd405652$var$ERR_STREAM_DESTROYED("write"));
|
|
2020
|
+
else if (writev) stream._writev(chunk, state.onwrite);
|
|
2021
|
+
else stream._write(chunk, encoding, state.onwrite);
|
|
2022
|
+
state.sync = false;
|
|
2023
|
+
}
|
|
2024
|
+
function $6788fab3cd405652$var$onwriteError(stream, state, sync, er, cb) {
|
|
2025
|
+
--state.pendingcb;
|
|
2026
|
+
if (sync) {
|
|
2027
|
+
// defer the callback if we are being called synchronously
|
|
2028
|
+
// to avoid piling up things on the stack
|
|
2029
|
+
$gHtSl$nextTick(cb, er); // this can emit finish, and it will always happen
|
|
2030
|
+
// after error
|
|
2031
|
+
$gHtSl$nextTick($6788fab3cd405652$var$finishMaybe, stream, state);
|
|
2032
|
+
stream._writableState.errorEmitted = true;
|
|
2033
|
+
$6788fab3cd405652$var$errorOrDestroy(stream, er);
|
|
2034
|
+
} else {
|
|
2035
|
+
// the caller expect this to happen before if
|
|
2036
|
+
// it is async
|
|
2037
|
+
cb(er);
|
|
2038
|
+
stream._writableState.errorEmitted = true;
|
|
2039
|
+
$6788fab3cd405652$var$errorOrDestroy(stream, er); // this can emit finish, but finish must
|
|
2040
|
+
// always follow error
|
|
2041
|
+
$6788fab3cd405652$var$finishMaybe(stream, state);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
function $6788fab3cd405652$var$onwriteStateUpdate(state) {
|
|
2045
|
+
state.writing = false;
|
|
2046
|
+
state.writecb = null;
|
|
2047
|
+
state.length -= state.writelen;
|
|
2048
|
+
state.writelen = 0;
|
|
2049
|
+
}
|
|
2050
|
+
function $6788fab3cd405652$var$onwrite(stream, er) {
|
|
2051
|
+
var state = stream._writableState;
|
|
2052
|
+
var sync = state.sync;
|
|
2053
|
+
var cb = state.writecb;
|
|
2054
|
+
if (typeof cb !== "function") throw new $6788fab3cd405652$var$ERR_MULTIPLE_CALLBACK();
|
|
2055
|
+
$6788fab3cd405652$var$onwriteStateUpdate(state);
|
|
2056
|
+
if (er) $6788fab3cd405652$var$onwriteError(stream, state, sync, er, cb);
|
|
2057
|
+
else {
|
|
2058
|
+
// Check if we're actually ready to finish, but don't emit yet
|
|
2059
|
+
var finished = $6788fab3cd405652$var$needFinish(state) || stream.destroyed;
|
|
2060
|
+
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) $6788fab3cd405652$var$clearBuffer(stream, state);
|
|
2061
|
+
if (sync) $gHtSl$nextTick($6788fab3cd405652$var$afterWrite, stream, state, finished, cb);
|
|
2062
|
+
else $6788fab3cd405652$var$afterWrite(stream, state, finished, cb);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
function $6788fab3cd405652$var$afterWrite(stream, state, finished, cb) {
|
|
2066
|
+
if (!finished) $6788fab3cd405652$var$onwriteDrain(stream, state);
|
|
2067
|
+
state.pendingcb--;
|
|
2068
|
+
cb();
|
|
2069
|
+
$6788fab3cd405652$var$finishMaybe(stream, state);
|
|
2070
|
+
} // Must force callback to be called on nextTick, so that we don't
|
|
2071
|
+
// emit 'drain' before the write() consumer gets the 'false' return
|
|
2072
|
+
// value, and has a chance to attach a 'drain' listener.
|
|
2073
|
+
function $6788fab3cd405652$var$onwriteDrain(stream, state) {
|
|
2074
|
+
if (state.length === 0 && state.needDrain) {
|
|
2075
|
+
state.needDrain = false;
|
|
2076
|
+
stream.emit("drain");
|
|
2077
|
+
}
|
|
2078
|
+
} // if there's something in the buffer waiting, then process it
|
|
2079
|
+
function $6788fab3cd405652$var$clearBuffer(stream, state) {
|
|
2080
|
+
state.bufferProcessing = true;
|
|
2081
|
+
var entry = state.bufferedRequest;
|
|
2082
|
+
if (stream._writev && entry && entry.next) {
|
|
2083
|
+
// Fast case, write everything using _writev()
|
|
2084
|
+
var l = state.bufferedRequestCount;
|
|
2085
|
+
var buffer = new Array(l);
|
|
2086
|
+
var holder = state.corkedRequestsFree;
|
|
2087
|
+
holder.entry = entry;
|
|
2088
|
+
var count = 0;
|
|
2089
|
+
var allBuffers = true;
|
|
2090
|
+
while(entry){
|
|
2091
|
+
buffer[count] = entry;
|
|
2092
|
+
if (!entry.isBuf) allBuffers = false;
|
|
2093
|
+
entry = entry.next;
|
|
2094
|
+
count += 1;
|
|
2095
|
+
}
|
|
2096
|
+
buffer.allBuffers = allBuffers;
|
|
2097
|
+
$6788fab3cd405652$var$doWrite(stream, state, true, state.length, buffer, "", holder.finish); // doWrite is almost always async, defer these to save a bit of time
|
|
2098
|
+
// as the hot path ends with doWrite
|
|
2099
|
+
state.pendingcb++;
|
|
2100
|
+
state.lastBufferedRequest = null;
|
|
2101
|
+
if (holder.next) {
|
|
2102
|
+
state.corkedRequestsFree = holder.next;
|
|
2103
|
+
holder.next = null;
|
|
2104
|
+
} else state.corkedRequestsFree = new $6788fab3cd405652$var$CorkedRequest(state);
|
|
2105
|
+
state.bufferedRequestCount = 0;
|
|
2106
|
+
} else {
|
|
2107
|
+
// Slow case, write chunks one-by-one
|
|
2108
|
+
while(entry){
|
|
2109
|
+
var chunk = entry.chunk;
|
|
2110
|
+
var encoding = entry.encoding;
|
|
2111
|
+
var cb = entry.callback;
|
|
2112
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
2113
|
+
$6788fab3cd405652$var$doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
2114
|
+
entry = entry.next;
|
|
2115
|
+
state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
|
|
2116
|
+
// it means that we need to wait until it does.
|
|
2117
|
+
// also, that means that the chunk and cb are currently
|
|
2118
|
+
// being processed, so move the buffer counter past them.
|
|
2119
|
+
if (state.writing) break;
|
|
2120
|
+
}
|
|
2121
|
+
if (entry === null) state.lastBufferedRequest = null;
|
|
2122
|
+
}
|
|
2123
|
+
state.bufferedRequest = entry;
|
|
2124
|
+
state.bufferProcessing = false;
|
|
2125
|
+
}
|
|
2126
|
+
$6788fab3cd405652$var$Writable.prototype._write = function(chunk, encoding, cb) {
|
|
2127
|
+
cb(new $6788fab3cd405652$var$ERR_METHOD_NOT_IMPLEMENTED("_write()"));
|
|
2128
|
+
};
|
|
2129
|
+
$6788fab3cd405652$var$Writable.prototype._writev = null;
|
|
2130
|
+
$6788fab3cd405652$var$Writable.prototype.end = function(chunk, encoding, cb) {
|
|
2131
|
+
var state = this._writableState;
|
|
2132
|
+
if (typeof chunk === "function") {
|
|
2133
|
+
cb = chunk;
|
|
2134
|
+
chunk = null;
|
|
2135
|
+
encoding = null;
|
|
2136
|
+
} else if (typeof encoding === "function") {
|
|
2137
|
+
cb = encoding;
|
|
2138
|
+
encoding = null;
|
|
2139
|
+
}
|
|
2140
|
+
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
|
|
2141
|
+
if (state.corked) {
|
|
2142
|
+
state.corked = 1;
|
|
2143
|
+
this.uncork();
|
|
2144
|
+
} // ignore unnecessary end() calls.
|
|
2145
|
+
if (!state.ending) $6788fab3cd405652$var$endWritable(this, state, cb);
|
|
2146
|
+
return this;
|
|
2147
|
+
};
|
|
2148
|
+
Object.defineProperty($6788fab3cd405652$var$Writable.prototype, "writableLength", {
|
|
2149
|
+
// making it explicit this property is not enumerable
|
|
2150
|
+
// because otherwise some prototype manipulation in
|
|
2151
|
+
// userland will fail
|
|
2152
|
+
enumerable: false,
|
|
2153
|
+
get: function get() {
|
|
2154
|
+
return this._writableState.length;
|
|
2155
|
+
}
|
|
2156
|
+
});
|
|
2157
|
+
function $6788fab3cd405652$var$needFinish(state) {
|
|
2158
|
+
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
2159
|
+
}
|
|
2160
|
+
function $6788fab3cd405652$var$callFinal(stream, state) {
|
|
2161
|
+
stream._final(function(err) {
|
|
2162
|
+
state.pendingcb--;
|
|
2163
|
+
if (err) $6788fab3cd405652$var$errorOrDestroy(stream, err);
|
|
2164
|
+
state.prefinished = true;
|
|
2165
|
+
stream.emit("prefinish");
|
|
2166
|
+
$6788fab3cd405652$var$finishMaybe(stream, state);
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
function $6788fab3cd405652$var$prefinish(stream, state) {
|
|
2170
|
+
if (!state.prefinished && !state.finalCalled) {
|
|
2171
|
+
if (typeof stream._final === "function" && !state.destroyed) {
|
|
2172
|
+
state.pendingcb++;
|
|
2173
|
+
state.finalCalled = true;
|
|
2174
|
+
$gHtSl$nextTick($6788fab3cd405652$var$callFinal, stream, state);
|
|
2175
|
+
} else {
|
|
2176
|
+
state.prefinished = true;
|
|
2177
|
+
stream.emit("prefinish");
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
function $6788fab3cd405652$var$finishMaybe(stream, state) {
|
|
2182
|
+
var need = $6788fab3cd405652$var$needFinish(state);
|
|
2183
|
+
if (need) {
|
|
2184
|
+
$6788fab3cd405652$var$prefinish(stream, state);
|
|
2185
|
+
if (state.pendingcb === 0) {
|
|
2186
|
+
state.finished = true;
|
|
2187
|
+
stream.emit("finish");
|
|
2188
|
+
if (state.autoDestroy) {
|
|
2189
|
+
// In case of duplex streams we need a way to detect
|
|
2190
|
+
// if the readable side is ready for autoDestroy as well
|
|
2191
|
+
var rState = stream._readableState;
|
|
2192
|
+
if (!rState || rState.autoDestroy && rState.endEmitted) stream.destroy();
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
return need;
|
|
2197
|
+
}
|
|
2198
|
+
function $6788fab3cd405652$var$endWritable(stream, state, cb) {
|
|
2199
|
+
state.ending = true;
|
|
2200
|
+
$6788fab3cd405652$var$finishMaybe(stream, state);
|
|
2201
|
+
if (cb) {
|
|
2202
|
+
if (state.finished) $gHtSl$nextTick(cb);
|
|
2203
|
+
else stream.once("finish", cb);
|
|
2204
|
+
}
|
|
2205
|
+
state.ended = true;
|
|
2206
|
+
stream.writable = false;
|
|
2207
|
+
}
|
|
2208
|
+
function $6788fab3cd405652$var$onCorkedFinish(corkReq, state, err) {
|
|
2209
|
+
var entry = corkReq.entry;
|
|
2210
|
+
corkReq.entry = null;
|
|
2211
|
+
while(entry){
|
|
2212
|
+
var cb = entry.callback;
|
|
2213
|
+
state.pendingcb--;
|
|
2214
|
+
cb(err);
|
|
2215
|
+
entry = entry.next;
|
|
2216
|
+
} // reuse the free corkReq.
|
|
2217
|
+
state.corkedRequestsFree.next = corkReq;
|
|
2218
|
+
}
|
|
2219
|
+
Object.defineProperty($6788fab3cd405652$var$Writable.prototype, "destroyed", {
|
|
2220
|
+
// making it explicit this property is not enumerable
|
|
2221
|
+
// because otherwise some prototype manipulation in
|
|
2222
|
+
// userland will fail
|
|
2223
|
+
enumerable: false,
|
|
2224
|
+
get: function get() {
|
|
2225
|
+
if (this._writableState === undefined) return false;
|
|
2226
|
+
return this._writableState.destroyed;
|
|
2227
|
+
},
|
|
2228
|
+
set: function set(value) {
|
|
2229
|
+
// we ignore the value if the stream
|
|
2230
|
+
// has not been initialized yet
|
|
2231
|
+
if (!this._writableState) return;
|
|
2232
|
+
// backward compatibility, the user is explicitly
|
|
2233
|
+
// managing destroyed
|
|
2234
|
+
this._writableState.destroyed = value;
|
|
2235
|
+
}
|
|
2236
|
+
});
|
|
2237
|
+
$6788fab3cd405652$var$Writable.prototype.destroy = $dU5xr.destroy;
|
|
2238
|
+
$6788fab3cd405652$var$Writable.prototype._undestroy = $dU5xr.undestroy;
|
|
2239
|
+
$6788fab3cd405652$var$Writable.prototype._destroy = function(err, cb) {
|
|
2240
|
+
cb(err);
|
|
2241
|
+
};
|
|
2242
|
+
|
|
2243
|
+
});
|
|
2244
|
+
parcelRequire.register("gj4lB", function(module, exports) {
|
|
2245
|
+
/**
|
|
2246
|
+
* Module exports.
|
|
2247
|
+
*/ module.exports = $bdf1cafec9128d38$var$deprecate;
|
|
2248
|
+
/**
|
|
2249
|
+
* Mark that a method should not be used.
|
|
2250
|
+
* Returns a modified function which warns once by default.
|
|
2251
|
+
*
|
|
2252
|
+
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
|
2253
|
+
*
|
|
2254
|
+
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
|
2255
|
+
* will throw an Error when invoked.
|
|
2256
|
+
*
|
|
2257
|
+
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
|
2258
|
+
* will invoke `console.trace()` instead of `console.error()`.
|
|
2259
|
+
*
|
|
2260
|
+
* @param {Function} fn - the function to deprecate
|
|
2261
|
+
* @param {String} msg - the string to print to the console when `fn` is invoked
|
|
2262
|
+
* @returns {Function} a new "deprecated" version of `fn`
|
|
2263
|
+
* @api public
|
|
2264
|
+
*/ function $bdf1cafec9128d38$var$deprecate(fn, msg) {
|
|
2265
|
+
if ($bdf1cafec9128d38$var$config("noDeprecation")) return fn;
|
|
2266
|
+
var warned = false;
|
|
2267
|
+
function deprecated() {
|
|
2268
|
+
if (!warned) {
|
|
2269
|
+
if ($bdf1cafec9128d38$var$config("throwDeprecation")) throw new Error(msg);
|
|
2270
|
+
else if ($bdf1cafec9128d38$var$config("traceDeprecation")) console.trace(msg);
|
|
2271
|
+
else console.warn(msg);
|
|
2272
|
+
warned = true;
|
|
2273
|
+
}
|
|
2274
|
+
return fn.apply(this, arguments);
|
|
2275
|
+
}
|
|
2276
|
+
return deprecated;
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Checks `localStorage` for boolean values for the given `name`.
|
|
2280
|
+
*
|
|
2281
|
+
* @param {String} name
|
|
2282
|
+
* @returns {Boolean}
|
|
2283
|
+
* @api private
|
|
2284
|
+
*/ function $bdf1cafec9128d38$var$config(name) {
|
|
2285
|
+
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
|
2286
|
+
try {
|
|
2287
|
+
if (!$parcel$global.localStorage) return false;
|
|
2288
|
+
} catch (_) {
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
var val = $parcel$global.localStorage[name];
|
|
2292
|
+
if (null == val) return false;
|
|
2293
|
+
return String(val).toLowerCase() === "true";
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
});
|
|
2297
|
+
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
parcelRequire.register("aCyUD", function(module, exports) {
|
|
2301
|
+
|
|
2302
|
+
$parcel$export(module.exports, "StringDecoder", function () { return $7bb888e688ae7644$export$63a7aa211a91ed69; }, function (v) { return $7bb888e688ae7644$export$63a7aa211a91ed69 = v; });
|
|
2303
|
+
// StringDecoder provides an interface for efficiently splitting a series of
|
|
2304
|
+
// buffers into a series of JS strings without breaking apart multi-byte
|
|
2305
|
+
// characters.
|
|
2306
|
+
var $7bb888e688ae7644$export$63a7aa211a91ed69;
|
|
2307
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
2308
|
+
//
|
|
2309
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2310
|
+
// copy of this software and associated documentation files (the
|
|
2311
|
+
// "Software"), to deal in the Software without restriction, including
|
|
2312
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2313
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2314
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
2315
|
+
// following conditions:
|
|
2316
|
+
//
|
|
2317
|
+
// The above copyright notice and this permission notice shall be included
|
|
2318
|
+
// in all copies or substantial portions of the Software.
|
|
2319
|
+
//
|
|
2320
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2321
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2322
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2323
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2324
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2325
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2326
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2327
|
+
"use strict";
|
|
2328
|
+
|
|
2329
|
+
var $4MS1v = parcelRequire("4MS1v");
|
|
2330
|
+
var $7bb888e688ae7644$require$Buffer = $4MS1v.Buffer;
|
|
2331
|
+
/*</replacement>*/ var $7bb888e688ae7644$var$isEncoding = $7bb888e688ae7644$require$Buffer.isEncoding || function(encoding) {
|
|
2332
|
+
encoding = "" + encoding;
|
|
2333
|
+
switch(encoding && encoding.toLowerCase()){
|
|
2334
|
+
case "hex":
|
|
2335
|
+
case "utf8":
|
|
2336
|
+
case "utf-8":
|
|
2337
|
+
case "ascii":
|
|
2338
|
+
case "binary":
|
|
2339
|
+
case "base64":
|
|
2340
|
+
case "ucs2":
|
|
2341
|
+
case "ucs-2":
|
|
2342
|
+
case "utf16le":
|
|
2343
|
+
case "utf-16le":
|
|
2344
|
+
case "raw":
|
|
2345
|
+
return true;
|
|
2346
|
+
default:
|
|
2347
|
+
return false;
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
function $7bb888e688ae7644$var$_normalizeEncoding(enc) {
|
|
2351
|
+
if (!enc) return "utf8";
|
|
2352
|
+
var retried;
|
|
2353
|
+
while(true)switch(enc){
|
|
2354
|
+
case "utf8":
|
|
2355
|
+
case "utf-8":
|
|
2356
|
+
return "utf8";
|
|
2357
|
+
case "ucs2":
|
|
2358
|
+
case "ucs-2":
|
|
2359
|
+
case "utf16le":
|
|
2360
|
+
case "utf-16le":
|
|
2361
|
+
return "utf16le";
|
|
2362
|
+
case "latin1":
|
|
2363
|
+
case "binary":
|
|
2364
|
+
return "latin1";
|
|
2365
|
+
case "base64":
|
|
2366
|
+
case "ascii":
|
|
2367
|
+
case "hex":
|
|
2368
|
+
return enc;
|
|
2369
|
+
default:
|
|
2370
|
+
if (retried) return; // undefined
|
|
2371
|
+
enc = ("" + enc).toLowerCase();
|
|
2372
|
+
retried = true;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
|
2376
|
+
// modules monkey-patch it to support additional encodings
|
|
2377
|
+
function $7bb888e688ae7644$var$normalizeEncoding(enc) {
|
|
2378
|
+
var nenc = $7bb888e688ae7644$var$_normalizeEncoding(enc);
|
|
2379
|
+
if (typeof nenc !== "string" && ($7bb888e688ae7644$require$Buffer.isEncoding === $7bb888e688ae7644$var$isEncoding || !$7bb888e688ae7644$var$isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
|
|
2380
|
+
return nenc || enc;
|
|
2381
|
+
}
|
|
2382
|
+
$7bb888e688ae7644$export$63a7aa211a91ed69 = $7bb888e688ae7644$var$StringDecoder;
|
|
2383
|
+
function $7bb888e688ae7644$var$StringDecoder(encoding) {
|
|
2384
|
+
this.encoding = $7bb888e688ae7644$var$normalizeEncoding(encoding);
|
|
2385
|
+
var nb;
|
|
2386
|
+
switch(this.encoding){
|
|
2387
|
+
case "utf16le":
|
|
2388
|
+
this.text = $7bb888e688ae7644$var$utf16Text;
|
|
2389
|
+
this.end = $7bb888e688ae7644$var$utf16End;
|
|
2390
|
+
nb = 4;
|
|
2391
|
+
break;
|
|
2392
|
+
case "utf8":
|
|
2393
|
+
this.fillLast = $7bb888e688ae7644$var$utf8FillLast;
|
|
2394
|
+
nb = 4;
|
|
2395
|
+
break;
|
|
2396
|
+
case "base64":
|
|
2397
|
+
this.text = $7bb888e688ae7644$var$base64Text;
|
|
2398
|
+
this.end = $7bb888e688ae7644$var$base64End;
|
|
2399
|
+
nb = 3;
|
|
2400
|
+
break;
|
|
2401
|
+
default:
|
|
2402
|
+
this.write = $7bb888e688ae7644$var$simpleWrite;
|
|
2403
|
+
this.end = $7bb888e688ae7644$var$simpleEnd;
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
this.lastNeed = 0;
|
|
2407
|
+
this.lastTotal = 0;
|
|
2408
|
+
this.lastChar = $7bb888e688ae7644$require$Buffer.allocUnsafe(nb);
|
|
2409
|
+
}
|
|
2410
|
+
$7bb888e688ae7644$var$StringDecoder.prototype.write = function(buf) {
|
|
2411
|
+
if (buf.length === 0) return "";
|
|
2412
|
+
var r;
|
|
2413
|
+
var i;
|
|
2414
|
+
if (this.lastNeed) {
|
|
2415
|
+
r = this.fillLast(buf);
|
|
2416
|
+
if (r === undefined) return "";
|
|
2417
|
+
i = this.lastNeed;
|
|
2418
|
+
this.lastNeed = 0;
|
|
2419
|
+
} else i = 0;
|
|
2420
|
+
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
2421
|
+
return r || "";
|
|
2422
|
+
};
|
|
2423
|
+
$7bb888e688ae7644$var$StringDecoder.prototype.end = $7bb888e688ae7644$var$utf8End;
|
|
2424
|
+
// Returns only complete characters in a Buffer
|
|
2425
|
+
$7bb888e688ae7644$var$StringDecoder.prototype.text = $7bb888e688ae7644$var$utf8Text;
|
|
2426
|
+
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
|
2427
|
+
$7bb888e688ae7644$var$StringDecoder.prototype.fillLast = function(buf) {
|
|
2428
|
+
if (this.lastNeed <= buf.length) {
|
|
2429
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
2430
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
2431
|
+
}
|
|
2432
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
2433
|
+
this.lastNeed -= buf.length;
|
|
2434
|
+
};
|
|
2435
|
+
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
|
2436
|
+
// continuation byte. If an invalid byte is detected, -2 is returned.
|
|
2437
|
+
function $7bb888e688ae7644$var$utf8CheckByte(byte) {
|
|
2438
|
+
if (byte <= 0x7F) return 0;
|
|
2439
|
+
else if (byte >> 5 === 0x06) return 2;
|
|
2440
|
+
else if (byte >> 4 === 0x0E) return 3;
|
|
2441
|
+
else if (byte >> 3 === 0x1E) return 4;
|
|
2442
|
+
return byte >> 6 === 0x02 ? -1 : -2;
|
|
2443
|
+
}
|
|
2444
|
+
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
|
2445
|
+
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
|
2446
|
+
// needed to complete the UTF-8 character (if applicable) are returned.
|
|
2447
|
+
function $7bb888e688ae7644$var$utf8CheckIncomplete(self, buf, i) {
|
|
2448
|
+
var j = buf.length - 1;
|
|
2449
|
+
if (j < i) return 0;
|
|
2450
|
+
var nb = $7bb888e688ae7644$var$utf8CheckByte(buf[j]);
|
|
2451
|
+
if (nb >= 0) {
|
|
2452
|
+
if (nb > 0) self.lastNeed = nb - 1;
|
|
2453
|
+
return nb;
|
|
2454
|
+
}
|
|
2455
|
+
if (--j < i || nb === -2) return 0;
|
|
2456
|
+
nb = $7bb888e688ae7644$var$utf8CheckByte(buf[j]);
|
|
2457
|
+
if (nb >= 0) {
|
|
2458
|
+
if (nb > 0) self.lastNeed = nb - 2;
|
|
2459
|
+
return nb;
|
|
2460
|
+
}
|
|
2461
|
+
if (--j < i || nb === -2) return 0;
|
|
2462
|
+
nb = $7bb888e688ae7644$var$utf8CheckByte(buf[j]);
|
|
2463
|
+
if (nb >= 0) {
|
|
2464
|
+
if (nb > 0) {
|
|
2465
|
+
if (nb === 2) nb = 0;
|
|
2466
|
+
else self.lastNeed = nb - 3;
|
|
2467
|
+
}
|
|
2468
|
+
return nb;
|
|
2469
|
+
}
|
|
2470
|
+
return 0;
|
|
2471
|
+
}
|
|
2472
|
+
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
|
2473
|
+
// needed or are available. If we see a non-continuation byte where we expect
|
|
2474
|
+
// one, we "replace" the validated continuation bytes we've seen so far with
|
|
2475
|
+
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
|
2476
|
+
// behavior. The continuation byte check is included three times in the case
|
|
2477
|
+
// where all of the continuation bytes for a character exist in the same buffer.
|
|
2478
|
+
// It is also done this way as a slight performance increase instead of using a
|
|
2479
|
+
// loop.
|
|
2480
|
+
function $7bb888e688ae7644$var$utf8CheckExtraBytes(self, buf, p) {
|
|
2481
|
+
if ((buf[0] & 0xC0) !== 0x80) {
|
|
2482
|
+
self.lastNeed = 0;
|
|
2483
|
+
return "�";
|
|
2484
|
+
}
|
|
2485
|
+
if (self.lastNeed > 1 && buf.length > 1) {
|
|
2486
|
+
if ((buf[1] & 0xC0) !== 0x80) {
|
|
2487
|
+
self.lastNeed = 1;
|
|
2488
|
+
return "�";
|
|
2489
|
+
}
|
|
2490
|
+
if (self.lastNeed > 2 && buf.length > 2) {
|
|
2491
|
+
if ((buf[2] & 0xC0) !== 0x80) {
|
|
2492
|
+
self.lastNeed = 2;
|
|
2493
|
+
return "�";
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
|
2499
|
+
function $7bb888e688ae7644$var$utf8FillLast(buf) {
|
|
2500
|
+
var p = this.lastTotal - this.lastNeed;
|
|
2501
|
+
var r = $7bb888e688ae7644$var$utf8CheckExtraBytes(this, buf, p);
|
|
2502
|
+
if (r !== undefined) return r;
|
|
2503
|
+
if (this.lastNeed <= buf.length) {
|
|
2504
|
+
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
2505
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
2506
|
+
}
|
|
2507
|
+
buf.copy(this.lastChar, p, 0, buf.length);
|
|
2508
|
+
this.lastNeed -= buf.length;
|
|
2509
|
+
}
|
|
2510
|
+
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
|
2511
|
+
// partial character, the character's bytes are buffered until the required
|
|
2512
|
+
// number of bytes are available.
|
|
2513
|
+
function $7bb888e688ae7644$var$utf8Text(buf, i) {
|
|
2514
|
+
var total = $7bb888e688ae7644$var$utf8CheckIncomplete(this, buf, i);
|
|
2515
|
+
if (!this.lastNeed) return buf.toString("utf8", i);
|
|
2516
|
+
this.lastTotal = total;
|
|
2517
|
+
var end = buf.length - (total - this.lastNeed);
|
|
2518
|
+
buf.copy(this.lastChar, 0, end);
|
|
2519
|
+
return buf.toString("utf8", i, end);
|
|
2520
|
+
}
|
|
2521
|
+
// For UTF-8, a replacement character is added when ending on a partial
|
|
2522
|
+
// character.
|
|
2523
|
+
function $7bb888e688ae7644$var$utf8End(buf) {
|
|
2524
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
2525
|
+
if (this.lastNeed) return r + "�";
|
|
2526
|
+
return r;
|
|
2527
|
+
}
|
|
2528
|
+
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
|
2529
|
+
// number of bytes available, we need to check if we end on a leading/high
|
|
2530
|
+
// surrogate. In that case, we need to wait for the next two bytes in order to
|
|
2531
|
+
// decode the last character properly.
|
|
2532
|
+
function $7bb888e688ae7644$var$utf16Text(buf, i) {
|
|
2533
|
+
if ((buf.length - i) % 2 === 0) {
|
|
2534
|
+
var r = buf.toString("utf16le", i);
|
|
2535
|
+
if (r) {
|
|
2536
|
+
var c = r.charCodeAt(r.length - 1);
|
|
2537
|
+
if (c >= 0xD800 && c <= 0xDBFF) {
|
|
2538
|
+
this.lastNeed = 2;
|
|
2539
|
+
this.lastTotal = 4;
|
|
2540
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
2541
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
2542
|
+
return r.slice(0, -1);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
return r;
|
|
2546
|
+
}
|
|
2547
|
+
this.lastNeed = 1;
|
|
2548
|
+
this.lastTotal = 2;
|
|
2549
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
2550
|
+
return buf.toString("utf16le", i, buf.length - 1);
|
|
2551
|
+
}
|
|
2552
|
+
// For UTF-16LE we do not explicitly append special replacement characters if we
|
|
2553
|
+
// end on a partial character, we simply let v8 handle that.
|
|
2554
|
+
function $7bb888e688ae7644$var$utf16End(buf) {
|
|
2555
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
2556
|
+
if (this.lastNeed) {
|
|
2557
|
+
var end = this.lastTotal - this.lastNeed;
|
|
2558
|
+
return r + this.lastChar.toString("utf16le", 0, end);
|
|
2559
|
+
}
|
|
2560
|
+
return r;
|
|
2561
|
+
}
|
|
2562
|
+
function $7bb888e688ae7644$var$base64Text(buf, i) {
|
|
2563
|
+
var n = (buf.length - i) % 3;
|
|
2564
|
+
if (n === 0) return buf.toString("base64", i);
|
|
2565
|
+
this.lastNeed = 3 - n;
|
|
2566
|
+
this.lastTotal = 3;
|
|
2567
|
+
if (n === 1) this.lastChar[0] = buf[buf.length - 1];
|
|
2568
|
+
else {
|
|
2569
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
2570
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
2571
|
+
}
|
|
2572
|
+
return buf.toString("base64", i, buf.length - n);
|
|
2573
|
+
}
|
|
2574
|
+
function $7bb888e688ae7644$var$base64End(buf) {
|
|
2575
|
+
var r = buf && buf.length ? this.write(buf) : "";
|
|
2576
|
+
if (this.lastNeed) return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
|
|
2577
|
+
return r;
|
|
2578
|
+
}
|
|
2579
|
+
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
|
2580
|
+
function $7bb888e688ae7644$var$simpleWrite(buf) {
|
|
2581
|
+
return buf.toString(this.encoding);
|
|
2582
|
+
}
|
|
2583
|
+
function $7bb888e688ae7644$var$simpleEnd(buf) {
|
|
2584
|
+
return buf && buf.length ? this.write(buf) : "";
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
});
|
|
2588
|
+
parcelRequire.register("4MS1v", function(module, exports) {
|
|
2589
|
+
|
|
2590
|
+
var $37c58d00832292ca$var$Buffer = $gHtSl$buffer.Buffer;
|
|
2591
|
+
// alternative to using Object.keys for old browsers
|
|
2592
|
+
function $37c58d00832292ca$var$copyProps(src, dst) {
|
|
2593
|
+
for(var key in src)dst[key] = src[key];
|
|
2594
|
+
}
|
|
2595
|
+
if ($37c58d00832292ca$var$Buffer.from && $37c58d00832292ca$var$Buffer.alloc && $37c58d00832292ca$var$Buffer.allocUnsafe && $37c58d00832292ca$var$Buffer.allocUnsafeSlow) module.exports = $gHtSl$buffer;
|
|
2596
|
+
else {
|
|
2597
|
+
// Copy properties from require('buffer')
|
|
2598
|
+
$37c58d00832292ca$var$copyProps($gHtSl$buffer, module.exports);
|
|
2599
|
+
module.exports.Buffer = $37c58d00832292ca$var$SafeBuffer;
|
|
2600
|
+
}
|
|
2601
|
+
function $37c58d00832292ca$var$SafeBuffer(arg, encodingOrOffset, length) {
|
|
2602
|
+
return $37c58d00832292ca$var$Buffer(arg, encodingOrOffset, length);
|
|
2603
|
+
}
|
|
2604
|
+
$37c58d00832292ca$var$SafeBuffer.prototype = Object.create($37c58d00832292ca$var$Buffer.prototype);
|
|
2605
|
+
// Copy static methods from Buffer
|
|
2606
|
+
$37c58d00832292ca$var$copyProps($37c58d00832292ca$var$Buffer, $37c58d00832292ca$var$SafeBuffer);
|
|
2607
|
+
$37c58d00832292ca$var$SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
|
2608
|
+
if (typeof arg === "number") throw new TypeError("Argument must not be a number");
|
|
2609
|
+
return $37c58d00832292ca$var$Buffer(arg, encodingOrOffset, length);
|
|
2610
|
+
};
|
|
2611
|
+
$37c58d00832292ca$var$SafeBuffer.alloc = function(size, fill, encoding) {
|
|
2612
|
+
if (typeof size !== "number") throw new TypeError("Argument must be a number");
|
|
2613
|
+
var buf = $37c58d00832292ca$var$Buffer(size);
|
|
2614
|
+
if (fill !== undefined) {
|
|
2615
|
+
if (typeof encoding === "string") buf.fill(fill, encoding);
|
|
2616
|
+
else buf.fill(fill);
|
|
2617
|
+
} else buf.fill(0);
|
|
2618
|
+
return buf;
|
|
2619
|
+
};
|
|
2620
|
+
$37c58d00832292ca$var$SafeBuffer.allocUnsafe = function(size) {
|
|
2621
|
+
if (typeof size !== "number") throw new TypeError("Argument must be a number");
|
|
2622
|
+
return $37c58d00832292ca$var$Buffer(size);
|
|
2623
|
+
};
|
|
2624
|
+
$37c58d00832292ca$var$SafeBuffer.allocUnsafeSlow = function(size) {
|
|
2625
|
+
if (typeof size !== "number") throw new TypeError("Argument must be a number");
|
|
2626
|
+
return $gHtSl$buffer.SlowBuffer(size);
|
|
2627
|
+
};
|
|
2628
|
+
|
|
2629
|
+
});
|
|
2630
|
+
|
|
2631
|
+
|
|
2632
|
+
parcelRequire.register("5Q095", function(module, exports) {
|
|
2633
|
+
"use strict";
|
|
2634
|
+
|
|
2635
|
+
var $4401ec01a5b39b8a$var$_Object$setPrototypeO;
|
|
2636
|
+
function $4401ec01a5b39b8a$var$_defineProperty(obj, key, value) {
|
|
2637
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
2638
|
+
value: value,
|
|
2639
|
+
enumerable: true,
|
|
2640
|
+
configurable: true,
|
|
2641
|
+
writable: true
|
|
2642
|
+
});
|
|
2643
|
+
else obj[key] = value;
|
|
2644
|
+
return obj;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
var $7wU83 = parcelRequire("7wU83");
|
|
2648
|
+
var $4401ec01a5b39b8a$var$kLastResolve = Symbol("lastResolve");
|
|
2649
|
+
var $4401ec01a5b39b8a$var$kLastReject = Symbol("lastReject");
|
|
2650
|
+
var $4401ec01a5b39b8a$var$kError = Symbol("error");
|
|
2651
|
+
var $4401ec01a5b39b8a$var$kEnded = Symbol("ended");
|
|
2652
|
+
var $4401ec01a5b39b8a$var$kLastPromise = Symbol("lastPromise");
|
|
2653
|
+
var $4401ec01a5b39b8a$var$kHandlePromise = Symbol("handlePromise");
|
|
2654
|
+
var $4401ec01a5b39b8a$var$kStream = Symbol("stream");
|
|
2655
|
+
function $4401ec01a5b39b8a$var$createIterResult(value, done) {
|
|
2656
|
+
return {
|
|
2657
|
+
value: value,
|
|
2658
|
+
done: done
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
function $4401ec01a5b39b8a$var$readAndResolve(iter) {
|
|
2662
|
+
var resolve = iter[$4401ec01a5b39b8a$var$kLastResolve];
|
|
2663
|
+
if (resolve !== null) {
|
|
2664
|
+
var data = iter[$4401ec01a5b39b8a$var$kStream].read(); // we defer if data is null
|
|
2665
|
+
// we can be expecting either 'end' or
|
|
2666
|
+
// 'error'
|
|
2667
|
+
if (data !== null) {
|
|
2668
|
+
iter[$4401ec01a5b39b8a$var$kLastPromise] = null;
|
|
2669
|
+
iter[$4401ec01a5b39b8a$var$kLastResolve] = null;
|
|
2670
|
+
iter[$4401ec01a5b39b8a$var$kLastReject] = null;
|
|
2671
|
+
resolve($4401ec01a5b39b8a$var$createIterResult(data, false));
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
function $4401ec01a5b39b8a$var$onReadable(iter) {
|
|
2676
|
+
// we wait for the next tick, because it might
|
|
2677
|
+
// emit an error with process.nextTick
|
|
2678
|
+
$gHtSl$nextTick($4401ec01a5b39b8a$var$readAndResolve, iter);
|
|
2679
|
+
}
|
|
2680
|
+
function $4401ec01a5b39b8a$var$wrapForNext(lastPromise, iter) {
|
|
2681
|
+
return function(resolve, reject) {
|
|
2682
|
+
lastPromise.then(function() {
|
|
2683
|
+
if (iter[$4401ec01a5b39b8a$var$kEnded]) {
|
|
2684
|
+
resolve($4401ec01a5b39b8a$var$createIterResult(undefined, true));
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
iter[$4401ec01a5b39b8a$var$kHandlePromise](resolve, reject);
|
|
2688
|
+
}, reject);
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
var $4401ec01a5b39b8a$var$AsyncIteratorPrototype = Object.getPrototypeOf(function() {});
|
|
2692
|
+
var $4401ec01a5b39b8a$var$ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf(($4401ec01a5b39b8a$var$_Object$setPrototypeO = {
|
|
2693
|
+
get stream () {
|
|
2694
|
+
return this[$4401ec01a5b39b8a$var$kStream];
|
|
2695
|
+
},
|
|
2696
|
+
next: function next() {
|
|
2697
|
+
var _this = this;
|
|
2698
|
+
// if we have detected an error in the meanwhile
|
|
2699
|
+
// reject straight away
|
|
2700
|
+
var error = this[$4401ec01a5b39b8a$var$kError];
|
|
2701
|
+
if (error !== null) return Promise.reject(error);
|
|
2702
|
+
if (this[$4401ec01a5b39b8a$var$kEnded]) return Promise.resolve($4401ec01a5b39b8a$var$createIterResult(undefined, true));
|
|
2703
|
+
if (this[$4401ec01a5b39b8a$var$kStream].destroyed) // We need to defer via nextTick because if .destroy(err) is
|
|
2704
|
+
// called, the error will be emitted via nextTick, and
|
|
2705
|
+
// we cannot guarantee that there is no error lingering around
|
|
2706
|
+
// waiting to be emitted.
|
|
2707
|
+
return new Promise(function(resolve, reject) {
|
|
2708
|
+
$gHtSl$nextTick(function() {
|
|
2709
|
+
if (_this[$4401ec01a5b39b8a$var$kError]) reject(_this[$4401ec01a5b39b8a$var$kError]);
|
|
2710
|
+
else resolve($4401ec01a5b39b8a$var$createIterResult(undefined, true));
|
|
2711
|
+
});
|
|
2712
|
+
});
|
|
2713
|
+
// if we have multiple next() calls
|
|
2714
|
+
// we will wait for the previous Promise to finish
|
|
2715
|
+
// this logic is optimized to support for await loops,
|
|
2716
|
+
// where next() is only called once at a time
|
|
2717
|
+
var lastPromise = this[$4401ec01a5b39b8a$var$kLastPromise];
|
|
2718
|
+
var promise;
|
|
2719
|
+
if (lastPromise) promise = new Promise($4401ec01a5b39b8a$var$wrapForNext(lastPromise, this));
|
|
2720
|
+
else {
|
|
2721
|
+
// fast path needed to support multiple this.push()
|
|
2722
|
+
// without triggering the next() queue
|
|
2723
|
+
var data = this[$4401ec01a5b39b8a$var$kStream].read();
|
|
2724
|
+
if (data !== null) return Promise.resolve($4401ec01a5b39b8a$var$createIterResult(data, false));
|
|
2725
|
+
promise = new Promise(this[$4401ec01a5b39b8a$var$kHandlePromise]);
|
|
2726
|
+
}
|
|
2727
|
+
this[$4401ec01a5b39b8a$var$kLastPromise] = promise;
|
|
2728
|
+
return promise;
|
|
2729
|
+
}
|
|
2730
|
+
}, $4401ec01a5b39b8a$var$_defineProperty($4401ec01a5b39b8a$var$_Object$setPrototypeO, Symbol.asyncIterator, function() {
|
|
2731
|
+
return this;
|
|
2732
|
+
}), $4401ec01a5b39b8a$var$_defineProperty($4401ec01a5b39b8a$var$_Object$setPrototypeO, "return", function _return() {
|
|
2733
|
+
var _this2 = this;
|
|
2734
|
+
// destroy(err, cb) is a private API
|
|
2735
|
+
// we can guarantee we have that here, because we control the
|
|
2736
|
+
// Readable class this is attached to
|
|
2737
|
+
return new Promise(function(resolve, reject) {
|
|
2738
|
+
_this2[$4401ec01a5b39b8a$var$kStream].destroy(null, function(err) {
|
|
2739
|
+
if (err) {
|
|
2740
|
+
reject(err);
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
resolve($4401ec01a5b39b8a$var$createIterResult(undefined, true));
|
|
2744
|
+
});
|
|
2745
|
+
});
|
|
2746
|
+
}), $4401ec01a5b39b8a$var$_Object$setPrototypeO), $4401ec01a5b39b8a$var$AsyncIteratorPrototype);
|
|
2747
|
+
var $4401ec01a5b39b8a$var$createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
|
|
2748
|
+
var _Object$create;
|
|
2749
|
+
var iterator = Object.create($4401ec01a5b39b8a$var$ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kStream, {
|
|
2750
|
+
value: stream,
|
|
2751
|
+
writable: true
|
|
2752
|
+
}), $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kLastResolve, {
|
|
2753
|
+
value: null,
|
|
2754
|
+
writable: true
|
|
2755
|
+
}), $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kLastReject, {
|
|
2756
|
+
value: null,
|
|
2757
|
+
writable: true
|
|
2758
|
+
}), $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kError, {
|
|
2759
|
+
value: null,
|
|
2760
|
+
writable: true
|
|
2761
|
+
}), $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kEnded, {
|
|
2762
|
+
value: stream._readableState.endEmitted,
|
|
2763
|
+
writable: true
|
|
2764
|
+
}), $4401ec01a5b39b8a$var$_defineProperty(_Object$create, $4401ec01a5b39b8a$var$kHandlePromise, {
|
|
2765
|
+
value: function value(resolve, reject) {
|
|
2766
|
+
var data = iterator[$4401ec01a5b39b8a$var$kStream].read();
|
|
2767
|
+
if (data) {
|
|
2768
|
+
iterator[$4401ec01a5b39b8a$var$kLastPromise] = null;
|
|
2769
|
+
iterator[$4401ec01a5b39b8a$var$kLastResolve] = null;
|
|
2770
|
+
iterator[$4401ec01a5b39b8a$var$kLastReject] = null;
|
|
2771
|
+
resolve($4401ec01a5b39b8a$var$createIterResult(data, false));
|
|
2772
|
+
} else {
|
|
2773
|
+
iterator[$4401ec01a5b39b8a$var$kLastResolve] = resolve;
|
|
2774
|
+
iterator[$4401ec01a5b39b8a$var$kLastReject] = reject;
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
writable: true
|
|
2778
|
+
}), _Object$create));
|
|
2779
|
+
iterator[$4401ec01a5b39b8a$var$kLastPromise] = null;
|
|
2780
|
+
$7wU83(stream, function(err) {
|
|
2781
|
+
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
2782
|
+
var reject = iterator[$4401ec01a5b39b8a$var$kLastReject]; // reject if we are waiting for data in the Promise
|
|
2783
|
+
// returned by next() and store the error
|
|
2784
|
+
if (reject !== null) {
|
|
2785
|
+
iterator[$4401ec01a5b39b8a$var$kLastPromise] = null;
|
|
2786
|
+
iterator[$4401ec01a5b39b8a$var$kLastResolve] = null;
|
|
2787
|
+
iterator[$4401ec01a5b39b8a$var$kLastReject] = null;
|
|
2788
|
+
reject(err);
|
|
2789
|
+
}
|
|
2790
|
+
iterator[$4401ec01a5b39b8a$var$kError] = err;
|
|
2791
|
+
return;
|
|
2792
|
+
}
|
|
2793
|
+
var resolve = iterator[$4401ec01a5b39b8a$var$kLastResolve];
|
|
2794
|
+
if (resolve !== null) {
|
|
2795
|
+
iterator[$4401ec01a5b39b8a$var$kLastPromise] = null;
|
|
2796
|
+
iterator[$4401ec01a5b39b8a$var$kLastResolve] = null;
|
|
2797
|
+
iterator[$4401ec01a5b39b8a$var$kLastReject] = null;
|
|
2798
|
+
resolve($4401ec01a5b39b8a$var$createIterResult(undefined, true));
|
|
2799
|
+
}
|
|
2800
|
+
iterator[$4401ec01a5b39b8a$var$kEnded] = true;
|
|
2801
|
+
});
|
|
2802
|
+
stream.on("readable", $4401ec01a5b39b8a$var$onReadable.bind(null, iterator));
|
|
2803
|
+
return iterator;
|
|
2804
|
+
};
|
|
2805
|
+
module.exports = $4401ec01a5b39b8a$var$createReadableStreamAsyncIterator;
|
|
2806
|
+
|
|
2807
|
+
});
|
|
2808
|
+
parcelRequire.register("7wU83", function(module, exports) {
|
|
2809
|
+
// Ported from https://github.com/mafintosh/end-of-stream with
|
|
2810
|
+
// permission from the author, Mathias Buus (@mafintosh).
|
|
2811
|
+
"use strict";
|
|
2812
|
+
|
|
2813
|
+
var $6vYby = parcelRequire("6vYby");
|
|
2814
|
+
var $57b70f9bbfbf8638$var$ERR_STREAM_PREMATURE_CLOSE = $6vYby.codes.ERR_STREAM_PREMATURE_CLOSE;
|
|
2815
|
+
function $57b70f9bbfbf8638$var$once(callback) {
|
|
2816
|
+
var called = false;
|
|
2817
|
+
return function() {
|
|
2818
|
+
if (called) return;
|
|
2819
|
+
called = true;
|
|
2820
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key];
|
|
2821
|
+
callback.apply(this, args);
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
function $57b70f9bbfbf8638$var$noop() {}
|
|
2825
|
+
function $57b70f9bbfbf8638$var$isRequest(stream) {
|
|
2826
|
+
return stream.setHeader && typeof stream.abort === "function";
|
|
2827
|
+
}
|
|
2828
|
+
function $57b70f9bbfbf8638$var$eos(stream, opts, callback) {
|
|
2829
|
+
if (typeof opts === "function") return $57b70f9bbfbf8638$var$eos(stream, null, opts);
|
|
2830
|
+
if (!opts) opts = {};
|
|
2831
|
+
callback = $57b70f9bbfbf8638$var$once(callback || $57b70f9bbfbf8638$var$noop);
|
|
2832
|
+
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
2833
|
+
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
2834
|
+
var onlegacyfinish = function onlegacyfinish() {
|
|
2835
|
+
if (!stream.writable) onfinish();
|
|
2836
|
+
};
|
|
2837
|
+
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
2838
|
+
var onfinish = function onfinish() {
|
|
2839
|
+
writable = false;
|
|
2840
|
+
writableEnded = true;
|
|
2841
|
+
if (!readable) callback.call(stream);
|
|
2842
|
+
};
|
|
2843
|
+
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
2844
|
+
var onend = function onend() {
|
|
2845
|
+
readable = false;
|
|
2846
|
+
readableEnded = true;
|
|
2847
|
+
if (!writable) callback.call(stream);
|
|
2848
|
+
};
|
|
2849
|
+
var onerror = function onerror(err) {
|
|
2850
|
+
callback.call(stream, err);
|
|
2851
|
+
};
|
|
2852
|
+
var onclose = function onclose() {
|
|
2853
|
+
var err;
|
|
2854
|
+
if (readable && !readableEnded) {
|
|
2855
|
+
if (!stream._readableState || !stream._readableState.ended) err = new $57b70f9bbfbf8638$var$ERR_STREAM_PREMATURE_CLOSE();
|
|
2856
|
+
return callback.call(stream, err);
|
|
2857
|
+
}
|
|
2858
|
+
if (writable && !writableEnded) {
|
|
2859
|
+
if (!stream._writableState || !stream._writableState.ended) err = new $57b70f9bbfbf8638$var$ERR_STREAM_PREMATURE_CLOSE();
|
|
2860
|
+
return callback.call(stream, err);
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
var onrequest = function onrequest() {
|
|
2864
|
+
stream.req.on("finish", onfinish);
|
|
2865
|
+
};
|
|
2866
|
+
if ($57b70f9bbfbf8638$var$isRequest(stream)) {
|
|
2867
|
+
stream.on("complete", onfinish);
|
|
2868
|
+
stream.on("abort", onclose);
|
|
2869
|
+
if (stream.req) onrequest();
|
|
2870
|
+
else stream.on("request", onrequest);
|
|
2871
|
+
} else if (writable && !stream._writableState) {
|
|
2872
|
+
// legacy streams
|
|
2873
|
+
stream.on("end", onlegacyfinish);
|
|
2874
|
+
stream.on("close", onlegacyfinish);
|
|
2875
|
+
}
|
|
2876
|
+
stream.on("end", onend);
|
|
2877
|
+
stream.on("finish", onfinish);
|
|
2878
|
+
if (opts.error !== false) stream.on("error", onerror);
|
|
2879
|
+
stream.on("close", onclose);
|
|
2880
|
+
return function() {
|
|
2881
|
+
stream.removeListener("complete", onfinish);
|
|
2882
|
+
stream.removeListener("abort", onclose);
|
|
2883
|
+
stream.removeListener("request", onrequest);
|
|
2884
|
+
if (stream.req) stream.req.removeListener("finish", onfinish);
|
|
2885
|
+
stream.removeListener("end", onlegacyfinish);
|
|
2886
|
+
stream.removeListener("close", onlegacyfinish);
|
|
2887
|
+
stream.removeListener("finish", onfinish);
|
|
2888
|
+
stream.removeListener("end", onend);
|
|
2889
|
+
stream.removeListener("error", onerror);
|
|
2890
|
+
stream.removeListener("close", onclose);
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
module.exports = $57b70f9bbfbf8638$var$eos;
|
|
2894
|
+
|
|
2895
|
+
});
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
parcelRequire.register("3AJhl", function(module, exports) {
|
|
2899
|
+
module.exports = function() {
|
|
2900
|
+
throw new Error("Readable.from is not available in the browser");
|
|
2901
|
+
};
|
|
2902
|
+
|
|
2903
|
+
});
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
parcelRequire.register("az4hH", function(module, exports) {
|
|
2907
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
2908
|
+
//
|
|
2909
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2910
|
+
// copy of this software and associated documentation files (the
|
|
2911
|
+
// "Software"), to deal in the Software without restriction, including
|
|
2912
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2913
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2914
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
2915
|
+
// following conditions:
|
|
2916
|
+
//
|
|
2917
|
+
// The above copyright notice and this permission notice shall be included
|
|
2918
|
+
// in all copies or substantial portions of the Software.
|
|
2919
|
+
//
|
|
2920
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2921
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2922
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2923
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2924
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2925
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2926
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2927
|
+
// a transform stream is a readable/writable stream where you do
|
|
2928
|
+
// something with the data. Sometimes it's called a "filter",
|
|
2929
|
+
// but that's not a great name for it, since that implies a thing where
|
|
2930
|
+
// some bits pass through, and others are simply ignored. (That would
|
|
2931
|
+
// be a valid example of a transform, of course.)
|
|
2932
|
+
//
|
|
2933
|
+
// While the output is causally related to the input, it's not a
|
|
2934
|
+
// necessarily symmetric or synchronous transformation. For example,
|
|
2935
|
+
// a zlib stream might take multiple plain-text writes(), and then
|
|
2936
|
+
// emit a single compressed chunk some time in the future.
|
|
2937
|
+
//
|
|
2938
|
+
// Here's how this works:
|
|
2939
|
+
//
|
|
2940
|
+
// The Transform stream has all the aspects of the readable and writable
|
|
2941
|
+
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
|
2942
|
+
// internally, and returns false if there's a lot of pending writes
|
|
2943
|
+
// buffered up. When you call read(), that calls _read(n) until
|
|
2944
|
+
// there's enough pending readable data buffered up.
|
|
2945
|
+
//
|
|
2946
|
+
// In a transform stream, the written data is placed in a buffer. When
|
|
2947
|
+
// _read(n) is called, it transforms the queued up data, calling the
|
|
2948
|
+
// buffered _write cb's as it consumes chunks. If consuming a single
|
|
2949
|
+
// written chunk would result in multiple output chunks, then the first
|
|
2950
|
+
// outputted bit calls the readcb, and subsequent chunks just go into
|
|
2951
|
+
// the read buffer, and will cause it to emit 'readable' if necessary.
|
|
2952
|
+
//
|
|
2953
|
+
// This way, back-pressure is actually determined by the reading side,
|
|
2954
|
+
// since _read has to be called to start processing a new chunk. However,
|
|
2955
|
+
// a pathological inflate type of transform can cause excessive buffering
|
|
2956
|
+
// here. For example, imagine a stream where every byte of input is
|
|
2957
|
+
// interpreted as an integer from 0-255, and then results in that many
|
|
2958
|
+
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
|
2959
|
+
// 1kb of data being output. In this case, you could write a very small
|
|
2960
|
+
// amount of input, and end up with a very large amount of output. In
|
|
2961
|
+
// such a pathological inflating mechanism, there'd be no way to tell
|
|
2962
|
+
// the system to stop doing the transform. A single 4MB write could
|
|
2963
|
+
// cause the system to run out of memory.
|
|
2964
|
+
//
|
|
2965
|
+
// However, even in such a pathological case, only a single written chunk
|
|
2966
|
+
// would be consumed, and then the rest would wait (un-transformed) until
|
|
2967
|
+
// the results of the previous transformed chunk were consumed.
|
|
2968
|
+
"use strict";
|
|
2969
|
+
module.exports = $7b107f185708c2ae$var$Transform;
|
|
2970
|
+
|
|
2971
|
+
var $6vYby = parcelRequire("6vYby");
|
|
2972
|
+
var $7b107f185708c2ae$require$_require$codes = $6vYby.codes;
|
|
2973
|
+
var $7b107f185708c2ae$var$ERR_METHOD_NOT_IMPLEMENTED = $7b107f185708c2ae$require$_require$codes.ERR_METHOD_NOT_IMPLEMENTED, $7b107f185708c2ae$var$ERR_MULTIPLE_CALLBACK = $7b107f185708c2ae$require$_require$codes.ERR_MULTIPLE_CALLBACK, $7b107f185708c2ae$var$ERR_TRANSFORM_ALREADY_TRANSFORMING = $7b107f185708c2ae$require$_require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, $7b107f185708c2ae$var$ERR_TRANSFORM_WITH_LENGTH_0 = $7b107f185708c2ae$require$_require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
|
2974
|
+
|
|
2975
|
+
var $cK2wf = parcelRequire("cK2wf");
|
|
2976
|
+
|
|
2977
|
+
(parcelRequire("ghwEg"))($7b107f185708c2ae$var$Transform, $cK2wf);
|
|
2978
|
+
function $7b107f185708c2ae$var$afterTransform(er, data) {
|
|
2979
|
+
var ts = this._transformState;
|
|
2980
|
+
ts.transforming = false;
|
|
2981
|
+
var cb = ts.writecb;
|
|
2982
|
+
if (cb === null) return this.emit("error", new $7b107f185708c2ae$var$ERR_MULTIPLE_CALLBACK());
|
|
2983
|
+
ts.writechunk = null;
|
|
2984
|
+
ts.writecb = null;
|
|
2985
|
+
if (data != null) this.push(data);
|
|
2986
|
+
cb(er);
|
|
2987
|
+
var rs = this._readableState;
|
|
2988
|
+
rs.reading = false;
|
|
2989
|
+
if (rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
2990
|
+
}
|
|
2991
|
+
function $7b107f185708c2ae$var$Transform(options) {
|
|
2992
|
+
if (!(this instanceof $7b107f185708c2ae$var$Transform)) return new $7b107f185708c2ae$var$Transform(options);
|
|
2993
|
+
$cK2wf.call(this, options);
|
|
2994
|
+
this._transformState = {
|
|
2995
|
+
afterTransform: $7b107f185708c2ae$var$afterTransform.bind(this),
|
|
2996
|
+
needTransform: false,
|
|
2997
|
+
transforming: false,
|
|
2998
|
+
writecb: null,
|
|
2999
|
+
writechunk: null,
|
|
3000
|
+
writeencoding: null
|
|
3001
|
+
}; // start out asking for a readable event once data is transformed.
|
|
3002
|
+
this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
|
|
3003
|
+
// that Readable wants before the first _read call, so unset the
|
|
3004
|
+
// sync guard flag.
|
|
3005
|
+
this._readableState.sync = false;
|
|
3006
|
+
if (options) {
|
|
3007
|
+
if (typeof options.transform === "function") this._transform = options.transform;
|
|
3008
|
+
if (typeof options.flush === "function") this._flush = options.flush;
|
|
3009
|
+
} // When the writable side finishes, then flush out anything remaining.
|
|
3010
|
+
this.on("prefinish", $7b107f185708c2ae$var$prefinish);
|
|
3011
|
+
}
|
|
3012
|
+
function $7b107f185708c2ae$var$prefinish() {
|
|
3013
|
+
var _this = this;
|
|
3014
|
+
if (typeof this._flush === "function" && !this._readableState.destroyed) this._flush(function(er, data) {
|
|
3015
|
+
$7b107f185708c2ae$var$done(_this, er, data);
|
|
3016
|
+
});
|
|
3017
|
+
else $7b107f185708c2ae$var$done(this, null, null);
|
|
3018
|
+
}
|
|
3019
|
+
$7b107f185708c2ae$var$Transform.prototype.push = function(chunk, encoding) {
|
|
3020
|
+
this._transformState.needTransform = false;
|
|
3021
|
+
return $cK2wf.prototype.push.call(this, chunk, encoding);
|
|
3022
|
+
}; // This is the part where you do stuff!
|
|
3023
|
+
// override this function in implementation classes.
|
|
3024
|
+
// 'chunk' is an input chunk.
|
|
3025
|
+
//
|
|
3026
|
+
// Call `push(newChunk)` to pass along transformed output
|
|
3027
|
+
// to the readable side. You may call 'push' zero or more times.
|
|
3028
|
+
//
|
|
3029
|
+
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
3030
|
+
// an error, then that'll put the hurt on the whole operation. If you
|
|
3031
|
+
// never call cb(), then you'll never get another chunk.
|
|
3032
|
+
$7b107f185708c2ae$var$Transform.prototype._transform = function(chunk, encoding, cb) {
|
|
3033
|
+
cb(new $7b107f185708c2ae$var$ERR_METHOD_NOT_IMPLEMENTED("_transform()"));
|
|
3034
|
+
};
|
|
3035
|
+
$7b107f185708c2ae$var$Transform.prototype._write = function(chunk, encoding, cb) {
|
|
3036
|
+
var ts = this._transformState;
|
|
3037
|
+
ts.writecb = cb;
|
|
3038
|
+
ts.writechunk = chunk;
|
|
3039
|
+
ts.writeencoding = encoding;
|
|
3040
|
+
if (!ts.transforming) {
|
|
3041
|
+
var rs = this._readableState;
|
|
3042
|
+
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
3043
|
+
}
|
|
3044
|
+
}; // Doesn't matter what the args are here.
|
|
3045
|
+
// _transform does all the work.
|
|
3046
|
+
// That we got here means that the readable side wants more data.
|
|
3047
|
+
$7b107f185708c2ae$var$Transform.prototype._read = function(n) {
|
|
3048
|
+
var ts = this._transformState;
|
|
3049
|
+
if (ts.writechunk !== null && !ts.transforming) {
|
|
3050
|
+
ts.transforming = true;
|
|
3051
|
+
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
3052
|
+
} else // mark that we need a transform, so that any data that comes in
|
|
3053
|
+
// will get processed, now that we've asked for it.
|
|
3054
|
+
ts.needTransform = true;
|
|
3055
|
+
};
|
|
3056
|
+
$7b107f185708c2ae$var$Transform.prototype._destroy = function(err, cb) {
|
|
3057
|
+
$cK2wf.prototype._destroy.call(this, err, function(err2) {
|
|
3058
|
+
cb(err2);
|
|
3059
|
+
});
|
|
3060
|
+
};
|
|
3061
|
+
function $7b107f185708c2ae$var$done(stream, er, data) {
|
|
3062
|
+
if (er) return stream.emit("error", er);
|
|
3063
|
+
if (data != null) stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
|
|
3064
|
+
// if there's nothing in the write buffer, then that means
|
|
3065
|
+
// that nothing more will ever be provided
|
|
3066
|
+
if (stream._writableState.length) throw new $7b107f185708c2ae$var$ERR_TRANSFORM_WITH_LENGTH_0();
|
|
3067
|
+
if (stream._transformState.transforming) throw new $7b107f185708c2ae$var$ERR_TRANSFORM_ALREADY_TRANSFORMING();
|
|
3068
|
+
return stream.push(null);
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
});
|
|
3072
|
+
|
|
3073
|
+
parcelRequire.register("dnNlY", function(module, exports) {
|
|
3074
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
3075
|
+
//
|
|
3076
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
3077
|
+
// copy of this software and associated documentation files (the
|
|
3078
|
+
// "Software"), to deal in the Software without restriction, including
|
|
3079
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
3080
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
3081
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
3082
|
+
// following conditions:
|
|
3083
|
+
//
|
|
3084
|
+
// The above copyright notice and this permission notice shall be included
|
|
3085
|
+
// in all copies or substantial portions of the Software.
|
|
3086
|
+
//
|
|
3087
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
3088
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
3089
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
3090
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
3091
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
3092
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
3093
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3094
|
+
// a passthrough stream.
|
|
3095
|
+
// basically just the most minimal sort of Transform stream.
|
|
3096
|
+
// Every written chunk gets output as-is.
|
|
3097
|
+
"use strict";
|
|
3098
|
+
module.exports = $9be3b4ec608b5234$var$PassThrough;
|
|
3099
|
+
|
|
3100
|
+
var $az4hH = parcelRequire("az4hH");
|
|
3101
|
+
|
|
3102
|
+
(parcelRequire("ghwEg"))($9be3b4ec608b5234$var$PassThrough, $az4hH);
|
|
3103
|
+
function $9be3b4ec608b5234$var$PassThrough(options) {
|
|
3104
|
+
if (!(this instanceof $9be3b4ec608b5234$var$PassThrough)) return new $9be3b4ec608b5234$var$PassThrough(options);
|
|
3105
|
+
$az4hH.call(this, options);
|
|
3106
|
+
}
|
|
3107
|
+
$9be3b4ec608b5234$var$PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
|
3108
|
+
cb(null, chunk);
|
|
3109
|
+
};
|
|
3110
|
+
|
|
3111
|
+
});
|
|
3112
|
+
|
|
3113
|
+
parcelRequire.register("jq29e", function(module, exports) {
|
|
3114
|
+
// Ported from https://github.com/mafintosh/pump with
|
|
3115
|
+
// permission from the author, Mathias Buus (@mafintosh).
|
|
3116
|
+
"use strict";
|
|
3117
|
+
var $e2321c935d2086ef$var$eos;
|
|
3118
|
+
function $e2321c935d2086ef$var$once(callback) {
|
|
3119
|
+
var called = false;
|
|
3120
|
+
return function() {
|
|
3121
|
+
if (called) return;
|
|
3122
|
+
called = true;
|
|
3123
|
+
callback.apply(void 0, arguments);
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
var $6vYby = parcelRequire("6vYby");
|
|
3128
|
+
var $e2321c935d2086ef$require$_require$codes = $6vYby.codes;
|
|
3129
|
+
var $e2321c935d2086ef$var$ERR_MISSING_ARGS = $e2321c935d2086ef$require$_require$codes.ERR_MISSING_ARGS, $e2321c935d2086ef$var$ERR_STREAM_DESTROYED = $e2321c935d2086ef$require$_require$codes.ERR_STREAM_DESTROYED;
|
|
3130
|
+
function $e2321c935d2086ef$var$noop(err) {
|
|
3131
|
+
// Rethrow the error if it exists to avoid swallowing it
|
|
3132
|
+
if (err) throw err;
|
|
3133
|
+
}
|
|
3134
|
+
function $e2321c935d2086ef$var$isRequest(stream) {
|
|
3135
|
+
return stream.setHeader && typeof stream.abort === "function";
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
function $e2321c935d2086ef$var$destroyer(stream, reading, writing, callback) {
|
|
3139
|
+
callback = $e2321c935d2086ef$var$once(callback);
|
|
3140
|
+
var closed = false;
|
|
3141
|
+
stream.on("close", function() {
|
|
3142
|
+
closed = true;
|
|
3143
|
+
});
|
|
3144
|
+
if ($e2321c935d2086ef$var$eos === undefined) $e2321c935d2086ef$var$eos = (parcelRequire("7wU83"));
|
|
3145
|
+
$e2321c935d2086ef$var$eos(stream, {
|
|
3146
|
+
readable: reading,
|
|
3147
|
+
writable: writing
|
|
3148
|
+
}, function(err) {
|
|
3149
|
+
if (err) return callback(err);
|
|
3150
|
+
closed = true;
|
|
3151
|
+
callback();
|
|
3152
|
+
});
|
|
3153
|
+
var destroyed = false;
|
|
3154
|
+
return function(err) {
|
|
3155
|
+
if (closed) return;
|
|
3156
|
+
if (destroyed) return;
|
|
3157
|
+
destroyed = true; // request.destroy just do .end - .abort is what we want
|
|
3158
|
+
if ($e2321c935d2086ef$var$isRequest(stream)) return stream.abort();
|
|
3159
|
+
if (typeof stream.destroy === "function") return stream.destroy();
|
|
3160
|
+
callback(err || new $e2321c935d2086ef$var$ERR_STREAM_DESTROYED("pipe"));
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
3163
|
+
function $e2321c935d2086ef$var$call(fn) {
|
|
3164
|
+
fn();
|
|
3165
|
+
}
|
|
3166
|
+
function $e2321c935d2086ef$var$pipe(from, to) {
|
|
3167
|
+
return from.pipe(to);
|
|
3168
|
+
}
|
|
3169
|
+
function $e2321c935d2086ef$var$popCallback(streams) {
|
|
3170
|
+
if (!streams.length) return $e2321c935d2086ef$var$noop;
|
|
3171
|
+
if (typeof streams[streams.length - 1] !== "function") return $e2321c935d2086ef$var$noop;
|
|
3172
|
+
return streams.pop();
|
|
3173
|
+
}
|
|
3174
|
+
function $e2321c935d2086ef$var$pipeline() {
|
|
3175
|
+
for(var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++)streams[_key] = arguments[_key];
|
|
3176
|
+
var callback = $e2321c935d2086ef$var$popCallback(streams);
|
|
3177
|
+
if (Array.isArray(streams[0])) streams = streams[0];
|
|
3178
|
+
if (streams.length < 2) throw new $e2321c935d2086ef$var$ERR_MISSING_ARGS("streams");
|
|
3179
|
+
var error;
|
|
3180
|
+
var destroys = streams.map(function(stream, i) {
|
|
3181
|
+
var reading = i < streams.length - 1;
|
|
3182
|
+
var writing = i > 0;
|
|
3183
|
+
return $e2321c935d2086ef$var$destroyer(stream, reading, writing, function(err) {
|
|
3184
|
+
if (!error) error = err;
|
|
3185
|
+
if (err) destroys.forEach($e2321c935d2086ef$var$call);
|
|
3186
|
+
if (reading) return;
|
|
3187
|
+
destroys.forEach($e2321c935d2086ef$var$call);
|
|
3188
|
+
callback(error);
|
|
3189
|
+
});
|
|
3190
|
+
});
|
|
3191
|
+
return streams.reduce($e2321c935d2086ef$var$pipe);
|
|
3192
|
+
}
|
|
3193
|
+
module.exports = $e2321c935d2086ef$var$pipeline;
|
|
3194
|
+
|
|
3195
|
+
});
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
parcelRequire.register("6hFBI", function(module, exports) {
|
|
3200
|
+
|
|
3201
|
+
var $49349af5670fa154$require$Buffer = $gHtSl$Buffer;
|
|
3202
|
+
|
|
3203
|
+
var $4VNAq = parcelRequire("4VNAq");
|
|
3204
|
+
var $49349af5670fa154$require$Transform = $4VNAq.Transform;
|
|
3205
|
+
module.exports = (KeccakState)=>{
|
|
3206
|
+
class Shake extends $49349af5670fa154$require$Transform {
|
|
3207
|
+
_transform(chunk, encoding, callback) {
|
|
3208
|
+
let error = null;
|
|
3209
|
+
try {
|
|
3210
|
+
this.update(chunk, encoding);
|
|
3211
|
+
} catch (err) {
|
|
3212
|
+
error = err;
|
|
3213
|
+
}
|
|
3214
|
+
callback(error);
|
|
3215
|
+
}
|
|
3216
|
+
_flush() {}
|
|
3217
|
+
_read(size) {
|
|
3218
|
+
this.push(this.squeeze(size));
|
|
3219
|
+
}
|
|
3220
|
+
update(data, encoding) {
|
|
3221
|
+
if (!$49349af5670fa154$require$Buffer.isBuffer(data) && typeof data !== "string") throw new TypeError("Data must be a string or a buffer");
|
|
3222
|
+
if (this._finalized) throw new Error("Squeeze already called");
|
|
3223
|
+
if (!$49349af5670fa154$require$Buffer.isBuffer(data)) data = $49349af5670fa154$require$Buffer.from(data, encoding);
|
|
3224
|
+
this._state.absorb(data);
|
|
3225
|
+
return this;
|
|
3226
|
+
}
|
|
3227
|
+
squeeze(dataByteLength, encoding) {
|
|
3228
|
+
if (!this._finalized) {
|
|
3229
|
+
this._finalized = true;
|
|
3230
|
+
this._state.absorbLastFewBits(this._delimitedSuffix);
|
|
3231
|
+
}
|
|
3232
|
+
let data = this._state.squeeze(dataByteLength);
|
|
3233
|
+
if (encoding !== undefined) data = data.toString(encoding);
|
|
3234
|
+
return data;
|
|
3235
|
+
}
|
|
3236
|
+
_resetState() {
|
|
3237
|
+
this._state.initialize(this._rate, this._capacity);
|
|
3238
|
+
return this;
|
|
3239
|
+
}
|
|
3240
|
+
_clone() {
|
|
3241
|
+
const clone = new Shake(this._rate, this._capacity, this._delimitedSuffix, this._options);
|
|
3242
|
+
this._state.copy(clone._state);
|
|
3243
|
+
clone._finalized = this._finalized;
|
|
3244
|
+
return clone;
|
|
3245
|
+
}
|
|
3246
|
+
constructor(rate, capacity, delimitedSuffix, options){
|
|
3247
|
+
super(options);
|
|
3248
|
+
this._rate = rate;
|
|
3249
|
+
this._capacity = capacity;
|
|
3250
|
+
this._delimitedSuffix = delimitedSuffix;
|
|
3251
|
+
this._options = options;
|
|
3252
|
+
this._state = new KeccakState();
|
|
3253
|
+
this._state.initialize(rate, capacity);
|
|
3254
|
+
this._finalized = false;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
return Shake;
|
|
3258
|
+
};
|
|
3259
|
+
|
|
3260
|
+
});
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
parcelRequire.register("3isIp", function(module, exports) {
|
|
3264
|
+
|
|
3265
|
+
var $266953d1151965c2$require$Buffer = $gHtSl$Buffer;
|
|
3266
|
+
|
|
3267
|
+
var $avhw2 = parcelRequire("avhw2");
|
|
3268
|
+
function $266953d1151965c2$var$Keccak() {
|
|
3269
|
+
// much faster than `new Array(50)`
|
|
3270
|
+
this.state = [
|
|
3271
|
+
0,
|
|
3272
|
+
0,
|
|
3273
|
+
0,
|
|
3274
|
+
0,
|
|
3275
|
+
0,
|
|
3276
|
+
0,
|
|
3277
|
+
0,
|
|
3278
|
+
0,
|
|
3279
|
+
0,
|
|
3280
|
+
0,
|
|
3281
|
+
0,
|
|
3282
|
+
0,
|
|
3283
|
+
0,
|
|
3284
|
+
0,
|
|
3285
|
+
0,
|
|
3286
|
+
0,
|
|
3287
|
+
0,
|
|
3288
|
+
0,
|
|
3289
|
+
0,
|
|
3290
|
+
0,
|
|
3291
|
+
0,
|
|
3292
|
+
0,
|
|
3293
|
+
0,
|
|
3294
|
+
0,
|
|
3295
|
+
0
|
|
3296
|
+
];
|
|
3297
|
+
this.blockSize = null;
|
|
3298
|
+
this.count = 0;
|
|
3299
|
+
this.squeezing = false;
|
|
3300
|
+
}
|
|
3301
|
+
$266953d1151965c2$var$Keccak.prototype.initialize = function(rate, capacity) {
|
|
3302
|
+
for(let i = 0; i < 50; ++i)this.state[i] = 0;
|
|
3303
|
+
this.blockSize = rate / 8;
|
|
3304
|
+
this.count = 0;
|
|
3305
|
+
this.squeezing = false;
|
|
3306
|
+
};
|
|
3307
|
+
$266953d1151965c2$var$Keccak.prototype.absorb = function(data) {
|
|
3308
|
+
for(let i = 0; i < data.length; ++i){
|
|
3309
|
+
this.state[~~(this.count / 4)] ^= data[i] << 8 * (this.count % 4);
|
|
3310
|
+
this.count += 1;
|
|
3311
|
+
if (this.count === this.blockSize) {
|
|
3312
|
+
$avhw2.p1600(this.state);
|
|
3313
|
+
this.count = 0;
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
};
|
|
3317
|
+
$266953d1151965c2$var$Keccak.prototype.absorbLastFewBits = function(bits) {
|
|
3318
|
+
this.state[~~(this.count / 4)] ^= bits << 8 * (this.count % 4);
|
|
3319
|
+
if ((bits & 0x80) !== 0 && this.count === this.blockSize - 1) $avhw2.p1600(this.state);
|
|
3320
|
+
this.state[~~((this.blockSize - 1) / 4)] ^= 0x80 << 8 * ((this.blockSize - 1) % 4);
|
|
3321
|
+
$avhw2.p1600(this.state);
|
|
3322
|
+
this.count = 0;
|
|
3323
|
+
this.squeezing = true;
|
|
3324
|
+
};
|
|
3325
|
+
$266953d1151965c2$var$Keccak.prototype.squeeze = function(length) {
|
|
3326
|
+
if (!this.squeezing) this.absorbLastFewBits(0x01);
|
|
3327
|
+
const output = $266953d1151965c2$require$Buffer.alloc(length);
|
|
3328
|
+
for(let i = 0; i < length; ++i){
|
|
3329
|
+
output[i] = this.state[~~(this.count / 4)] >>> 8 * (this.count % 4) & 0xff;
|
|
3330
|
+
this.count += 1;
|
|
3331
|
+
if (this.count === this.blockSize) {
|
|
3332
|
+
$avhw2.p1600(this.state);
|
|
3333
|
+
this.count = 0;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
return output;
|
|
3337
|
+
};
|
|
3338
|
+
$266953d1151965c2$var$Keccak.prototype.copy = function(dest) {
|
|
3339
|
+
for(let i = 0; i < 50; ++i)dest.state[i] = this.state[i];
|
|
3340
|
+
dest.blockSize = this.blockSize;
|
|
3341
|
+
dest.count = this.count;
|
|
3342
|
+
dest.squeezing = this.squeezing;
|
|
3343
|
+
};
|
|
3344
|
+
module.exports = $266953d1151965c2$var$Keccak;
|
|
3345
|
+
|
|
3346
|
+
});
|
|
3347
|
+
parcelRequire.register("avhw2", function(module, exports) {
|
|
3348
|
+
|
|
3349
|
+
$parcel$export(module.exports, "p1600", function () { return $7a5a62e98371297f$export$471358fe9e8379c0; }, function (v) { return $7a5a62e98371297f$export$471358fe9e8379c0 = v; });
|
|
3350
|
+
var $7a5a62e98371297f$export$471358fe9e8379c0;
|
|
3351
|
+
const $7a5a62e98371297f$var$P1600_ROUND_CONSTANTS = [
|
|
3352
|
+
1,
|
|
3353
|
+
0,
|
|
3354
|
+
32898,
|
|
3355
|
+
0,
|
|
3356
|
+
32906,
|
|
3357
|
+
2147483648,
|
|
3358
|
+
2147516416,
|
|
3359
|
+
2147483648,
|
|
3360
|
+
32907,
|
|
3361
|
+
0,
|
|
3362
|
+
2147483649,
|
|
3363
|
+
0,
|
|
3364
|
+
2147516545,
|
|
3365
|
+
2147483648,
|
|
3366
|
+
32777,
|
|
3367
|
+
2147483648,
|
|
3368
|
+
138,
|
|
3369
|
+
0,
|
|
3370
|
+
136,
|
|
3371
|
+
0,
|
|
3372
|
+
2147516425,
|
|
3373
|
+
0,
|
|
3374
|
+
2147483658,
|
|
3375
|
+
0,
|
|
3376
|
+
2147516555,
|
|
3377
|
+
0,
|
|
3378
|
+
139,
|
|
3379
|
+
2147483648,
|
|
3380
|
+
32905,
|
|
3381
|
+
2147483648,
|
|
3382
|
+
32771,
|
|
3383
|
+
2147483648,
|
|
3384
|
+
32770,
|
|
3385
|
+
2147483648,
|
|
3386
|
+
128,
|
|
3387
|
+
2147483648,
|
|
3388
|
+
32778,
|
|
3389
|
+
0,
|
|
3390
|
+
2147483658,
|
|
3391
|
+
2147483648,
|
|
3392
|
+
2147516545,
|
|
3393
|
+
2147483648,
|
|
3394
|
+
32896,
|
|
3395
|
+
2147483648,
|
|
3396
|
+
2147483649,
|
|
3397
|
+
0,
|
|
3398
|
+
2147516424,
|
|
3399
|
+
2147483648
|
|
3400
|
+
];
|
|
3401
|
+
$7a5a62e98371297f$export$471358fe9e8379c0 = function(s) {
|
|
3402
|
+
for(let round = 0; round < 24; ++round){
|
|
3403
|
+
// theta
|
|
3404
|
+
const lo0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
|
|
3405
|
+
const hi0 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
|
|
3406
|
+
const lo1 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
|
|
3407
|
+
const hi1 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
|
|
3408
|
+
const lo2 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
|
|
3409
|
+
const hi2 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
|
|
3410
|
+
const lo3 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
|
|
3411
|
+
const hi3 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
|
|
3412
|
+
const lo4 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
|
|
3413
|
+
const hi4 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
|
|
3414
|
+
let lo = lo4 ^ (lo1 << 1 | hi1 >>> 31);
|
|
3415
|
+
let hi = hi4 ^ (hi1 << 1 | lo1 >>> 31);
|
|
3416
|
+
const t1slo0 = s[0] ^ lo;
|
|
3417
|
+
const t1shi0 = s[1] ^ hi;
|
|
3418
|
+
const t1slo5 = s[10] ^ lo;
|
|
3419
|
+
const t1shi5 = s[11] ^ hi;
|
|
3420
|
+
const t1slo10 = s[20] ^ lo;
|
|
3421
|
+
const t1shi10 = s[21] ^ hi;
|
|
3422
|
+
const t1slo15 = s[30] ^ lo;
|
|
3423
|
+
const t1shi15 = s[31] ^ hi;
|
|
3424
|
+
const t1slo20 = s[40] ^ lo;
|
|
3425
|
+
const t1shi20 = s[41] ^ hi;
|
|
3426
|
+
lo = lo0 ^ (lo2 << 1 | hi2 >>> 31);
|
|
3427
|
+
hi = hi0 ^ (hi2 << 1 | lo2 >>> 31);
|
|
3428
|
+
const t1slo1 = s[2] ^ lo;
|
|
3429
|
+
const t1shi1 = s[3] ^ hi;
|
|
3430
|
+
const t1slo6 = s[12] ^ lo;
|
|
3431
|
+
const t1shi6 = s[13] ^ hi;
|
|
3432
|
+
const t1slo11 = s[22] ^ lo;
|
|
3433
|
+
const t1shi11 = s[23] ^ hi;
|
|
3434
|
+
const t1slo16 = s[32] ^ lo;
|
|
3435
|
+
const t1shi16 = s[33] ^ hi;
|
|
3436
|
+
const t1slo21 = s[42] ^ lo;
|
|
3437
|
+
const t1shi21 = s[43] ^ hi;
|
|
3438
|
+
lo = lo1 ^ (lo3 << 1 | hi3 >>> 31);
|
|
3439
|
+
hi = hi1 ^ (hi3 << 1 | lo3 >>> 31);
|
|
3440
|
+
const t1slo2 = s[4] ^ lo;
|
|
3441
|
+
const t1shi2 = s[5] ^ hi;
|
|
3442
|
+
const t1slo7 = s[14] ^ lo;
|
|
3443
|
+
const t1shi7 = s[15] ^ hi;
|
|
3444
|
+
const t1slo12 = s[24] ^ lo;
|
|
3445
|
+
const t1shi12 = s[25] ^ hi;
|
|
3446
|
+
const t1slo17 = s[34] ^ lo;
|
|
3447
|
+
const t1shi17 = s[35] ^ hi;
|
|
3448
|
+
const t1slo22 = s[44] ^ lo;
|
|
3449
|
+
const t1shi22 = s[45] ^ hi;
|
|
3450
|
+
lo = lo2 ^ (lo4 << 1 | hi4 >>> 31);
|
|
3451
|
+
hi = hi2 ^ (hi4 << 1 | lo4 >>> 31);
|
|
3452
|
+
const t1slo3 = s[6] ^ lo;
|
|
3453
|
+
const t1shi3 = s[7] ^ hi;
|
|
3454
|
+
const t1slo8 = s[16] ^ lo;
|
|
3455
|
+
const t1shi8 = s[17] ^ hi;
|
|
3456
|
+
const t1slo13 = s[26] ^ lo;
|
|
3457
|
+
const t1shi13 = s[27] ^ hi;
|
|
3458
|
+
const t1slo18 = s[36] ^ lo;
|
|
3459
|
+
const t1shi18 = s[37] ^ hi;
|
|
3460
|
+
const t1slo23 = s[46] ^ lo;
|
|
3461
|
+
const t1shi23 = s[47] ^ hi;
|
|
3462
|
+
lo = lo3 ^ (lo0 << 1 | hi0 >>> 31);
|
|
3463
|
+
hi = hi3 ^ (hi0 << 1 | lo0 >>> 31);
|
|
3464
|
+
const t1slo4 = s[8] ^ lo;
|
|
3465
|
+
const t1shi4 = s[9] ^ hi;
|
|
3466
|
+
const t1slo9 = s[18] ^ lo;
|
|
3467
|
+
const t1shi9 = s[19] ^ hi;
|
|
3468
|
+
const t1slo14 = s[28] ^ lo;
|
|
3469
|
+
const t1shi14 = s[29] ^ hi;
|
|
3470
|
+
const t1slo19 = s[38] ^ lo;
|
|
3471
|
+
const t1shi19 = s[39] ^ hi;
|
|
3472
|
+
const t1slo24 = s[48] ^ lo;
|
|
3473
|
+
const t1shi24 = s[49] ^ hi;
|
|
3474
|
+
// rho & pi
|
|
3475
|
+
const t2slo0 = t1slo0;
|
|
3476
|
+
const t2shi0 = t1shi0;
|
|
3477
|
+
const t2slo16 = t1shi5 << 4 | t1slo5 >>> 28;
|
|
3478
|
+
const t2shi16 = t1slo5 << 4 | t1shi5 >>> 28;
|
|
3479
|
+
const t2slo7 = t1slo10 << 3 | t1shi10 >>> 29;
|
|
3480
|
+
const t2shi7 = t1shi10 << 3 | t1slo10 >>> 29;
|
|
3481
|
+
const t2slo23 = t1shi15 << 9 | t1slo15 >>> 23;
|
|
3482
|
+
const t2shi23 = t1slo15 << 9 | t1shi15 >>> 23;
|
|
3483
|
+
const t2slo14 = t1slo20 << 18 | t1shi20 >>> 14;
|
|
3484
|
+
const t2shi14 = t1shi20 << 18 | t1slo20 >>> 14;
|
|
3485
|
+
const t2slo10 = t1slo1 << 1 | t1shi1 >>> 31;
|
|
3486
|
+
const t2shi10 = t1shi1 << 1 | t1slo1 >>> 31;
|
|
3487
|
+
const t2slo1 = t1shi6 << 12 | t1slo6 >>> 20;
|
|
3488
|
+
const t2shi1 = t1slo6 << 12 | t1shi6 >>> 20;
|
|
3489
|
+
const t2slo17 = t1slo11 << 10 | t1shi11 >>> 22;
|
|
3490
|
+
const t2shi17 = t1shi11 << 10 | t1slo11 >>> 22;
|
|
3491
|
+
const t2slo8 = t1shi16 << 13 | t1slo16 >>> 19;
|
|
3492
|
+
const t2shi8 = t1slo16 << 13 | t1shi16 >>> 19;
|
|
3493
|
+
const t2slo24 = t1slo21 << 2 | t1shi21 >>> 30;
|
|
3494
|
+
const t2shi24 = t1shi21 << 2 | t1slo21 >>> 30;
|
|
3495
|
+
const t2slo20 = t1shi2 << 30 | t1slo2 >>> 2;
|
|
3496
|
+
const t2shi20 = t1slo2 << 30 | t1shi2 >>> 2;
|
|
3497
|
+
const t2slo11 = t1slo7 << 6 | t1shi7 >>> 26;
|
|
3498
|
+
const t2shi11 = t1shi7 << 6 | t1slo7 >>> 26;
|
|
3499
|
+
const t2slo2 = t1shi12 << 11 | t1slo12 >>> 21;
|
|
3500
|
+
const t2shi2 = t1slo12 << 11 | t1shi12 >>> 21;
|
|
3501
|
+
const t2slo18 = t1slo17 << 15 | t1shi17 >>> 17;
|
|
3502
|
+
const t2shi18 = t1shi17 << 15 | t1slo17 >>> 17;
|
|
3503
|
+
const t2slo9 = t1shi22 << 29 | t1slo22 >>> 3;
|
|
3504
|
+
const t2shi9 = t1slo22 << 29 | t1shi22 >>> 3;
|
|
3505
|
+
const t2slo5 = t1slo3 << 28 | t1shi3 >>> 4;
|
|
3506
|
+
const t2shi5 = t1shi3 << 28 | t1slo3 >>> 4;
|
|
3507
|
+
const t2slo21 = t1shi8 << 23 | t1slo8 >>> 9;
|
|
3508
|
+
const t2shi21 = t1slo8 << 23 | t1shi8 >>> 9;
|
|
3509
|
+
const t2slo12 = t1slo13 << 25 | t1shi13 >>> 7;
|
|
3510
|
+
const t2shi12 = t1shi13 << 25 | t1slo13 >>> 7;
|
|
3511
|
+
const t2slo3 = t1slo18 << 21 | t1shi18 >>> 11;
|
|
3512
|
+
const t2shi3 = t1shi18 << 21 | t1slo18 >>> 11;
|
|
3513
|
+
const t2slo19 = t1shi23 << 24 | t1slo23 >>> 8;
|
|
3514
|
+
const t2shi19 = t1slo23 << 24 | t1shi23 >>> 8;
|
|
3515
|
+
const t2slo15 = t1slo4 << 27 | t1shi4 >>> 5;
|
|
3516
|
+
const t2shi15 = t1shi4 << 27 | t1slo4 >>> 5;
|
|
3517
|
+
const t2slo6 = t1slo9 << 20 | t1shi9 >>> 12;
|
|
3518
|
+
const t2shi6 = t1shi9 << 20 | t1slo9 >>> 12;
|
|
3519
|
+
const t2slo22 = t1shi14 << 7 | t1slo14 >>> 25;
|
|
3520
|
+
const t2shi22 = t1slo14 << 7 | t1shi14 >>> 25;
|
|
3521
|
+
const t2slo13 = t1slo19 << 8 | t1shi19 >>> 24;
|
|
3522
|
+
const t2shi13 = t1shi19 << 8 | t1slo19 >>> 24;
|
|
3523
|
+
const t2slo4 = t1slo24 << 14 | t1shi24 >>> 18;
|
|
3524
|
+
const t2shi4 = t1shi24 << 14 | t1slo24 >>> 18;
|
|
3525
|
+
// chi
|
|
3526
|
+
s[0] = t2slo0 ^ ~t2slo1 & t2slo2;
|
|
3527
|
+
s[1] = t2shi0 ^ ~t2shi1 & t2shi2;
|
|
3528
|
+
s[10] = t2slo5 ^ ~t2slo6 & t2slo7;
|
|
3529
|
+
s[11] = t2shi5 ^ ~t2shi6 & t2shi7;
|
|
3530
|
+
s[20] = t2slo10 ^ ~t2slo11 & t2slo12;
|
|
3531
|
+
s[21] = t2shi10 ^ ~t2shi11 & t2shi12;
|
|
3532
|
+
s[30] = t2slo15 ^ ~t2slo16 & t2slo17;
|
|
3533
|
+
s[31] = t2shi15 ^ ~t2shi16 & t2shi17;
|
|
3534
|
+
s[40] = t2slo20 ^ ~t2slo21 & t2slo22;
|
|
3535
|
+
s[41] = t2shi20 ^ ~t2shi21 & t2shi22;
|
|
3536
|
+
s[2] = t2slo1 ^ ~t2slo2 & t2slo3;
|
|
3537
|
+
s[3] = t2shi1 ^ ~t2shi2 & t2shi3;
|
|
3538
|
+
s[12] = t2slo6 ^ ~t2slo7 & t2slo8;
|
|
3539
|
+
s[13] = t2shi6 ^ ~t2shi7 & t2shi8;
|
|
3540
|
+
s[22] = t2slo11 ^ ~t2slo12 & t2slo13;
|
|
3541
|
+
s[23] = t2shi11 ^ ~t2shi12 & t2shi13;
|
|
3542
|
+
s[32] = t2slo16 ^ ~t2slo17 & t2slo18;
|
|
3543
|
+
s[33] = t2shi16 ^ ~t2shi17 & t2shi18;
|
|
3544
|
+
s[42] = t2slo21 ^ ~t2slo22 & t2slo23;
|
|
3545
|
+
s[43] = t2shi21 ^ ~t2shi22 & t2shi23;
|
|
3546
|
+
s[4] = t2slo2 ^ ~t2slo3 & t2slo4;
|
|
3547
|
+
s[5] = t2shi2 ^ ~t2shi3 & t2shi4;
|
|
3548
|
+
s[14] = t2slo7 ^ ~t2slo8 & t2slo9;
|
|
3549
|
+
s[15] = t2shi7 ^ ~t2shi8 & t2shi9;
|
|
3550
|
+
s[24] = t2slo12 ^ ~t2slo13 & t2slo14;
|
|
3551
|
+
s[25] = t2shi12 ^ ~t2shi13 & t2shi14;
|
|
3552
|
+
s[34] = t2slo17 ^ ~t2slo18 & t2slo19;
|
|
3553
|
+
s[35] = t2shi17 ^ ~t2shi18 & t2shi19;
|
|
3554
|
+
s[44] = t2slo22 ^ ~t2slo23 & t2slo24;
|
|
3555
|
+
s[45] = t2shi22 ^ ~t2shi23 & t2shi24;
|
|
3556
|
+
s[6] = t2slo3 ^ ~t2slo4 & t2slo0;
|
|
3557
|
+
s[7] = t2shi3 ^ ~t2shi4 & t2shi0;
|
|
3558
|
+
s[16] = t2slo8 ^ ~t2slo9 & t2slo5;
|
|
3559
|
+
s[17] = t2shi8 ^ ~t2shi9 & t2shi5;
|
|
3560
|
+
s[26] = t2slo13 ^ ~t2slo14 & t2slo10;
|
|
3561
|
+
s[27] = t2shi13 ^ ~t2shi14 & t2shi10;
|
|
3562
|
+
s[36] = t2slo18 ^ ~t2slo19 & t2slo15;
|
|
3563
|
+
s[37] = t2shi18 ^ ~t2shi19 & t2shi15;
|
|
3564
|
+
s[46] = t2slo23 ^ ~t2slo24 & t2slo20;
|
|
3565
|
+
s[47] = t2shi23 ^ ~t2shi24 & t2shi20;
|
|
3566
|
+
s[8] = t2slo4 ^ ~t2slo0 & t2slo1;
|
|
3567
|
+
s[9] = t2shi4 ^ ~t2shi0 & t2shi1;
|
|
3568
|
+
s[18] = t2slo9 ^ ~t2slo5 & t2slo6;
|
|
3569
|
+
s[19] = t2shi9 ^ ~t2shi5 & t2shi6;
|
|
3570
|
+
s[28] = t2slo14 ^ ~t2slo10 & t2slo11;
|
|
3571
|
+
s[29] = t2shi14 ^ ~t2shi10 & t2shi11;
|
|
3572
|
+
s[38] = t2slo19 ^ ~t2slo15 & t2slo16;
|
|
3573
|
+
s[39] = t2shi19 ^ ~t2shi15 & t2shi16;
|
|
3574
|
+
s[48] = t2slo24 ^ ~t2slo20 & t2slo21;
|
|
3575
|
+
s[49] = t2shi24 ^ ~t2shi20 & t2shi21;
|
|
3576
|
+
// iota
|
|
3577
|
+
s[0] ^= $7a5a62e98371297f$var$P1600_ROUND_CONSTANTS[round * 2];
|
|
3578
|
+
s[1] ^= $7a5a62e98371297f$var$P1600_ROUND_CONSTANTS[round * 2 + 1];
|
|
3579
|
+
}
|
|
3580
|
+
};
|
|
3581
|
+
|
|
3582
|
+
});
|
|
3583
|
+
|
|
3584
|
+
|
|
3585
|
+
// base-x encoding / decoding
|
|
3586
|
+
// Copyright (c) 2018 base-x contributors
|
|
3587
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
3588
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3589
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
3590
|
+
const $7a07e400cb853a78$var$base = (ALPHABET)=>{
|
|
3591
|
+
if (ALPHABET.length >= 255) throw new TypeError("Alphabet too long");
|
|
3592
|
+
const BASE_MAP = new Uint8Array(256);
|
|
3593
|
+
for(let j = 0; j < BASE_MAP.length; j++)BASE_MAP[j] = 255;
|
|
3594
|
+
for(let i = 0; i < ALPHABET.length; i++){
|
|
3595
|
+
const x = ALPHABET.charAt(i);
|
|
3596
|
+
const xc = x.charCodeAt(0);
|
|
3597
|
+
if (BASE_MAP[xc] !== 255) throw new TypeError(x + " is ambiguous");
|
|
3598
|
+
BASE_MAP[xc] = i;
|
|
3599
|
+
}
|
|
3600
|
+
const BASE = ALPHABET.length;
|
|
3601
|
+
const LEADER = ALPHABET.charAt(0);
|
|
3602
|
+
const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
|
|
3603
|
+
;
|
|
3604
|
+
const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
|
|
3605
|
+
;
|
|
3606
|
+
const encode = (source)=>{
|
|
3607
|
+
if (source instanceof Uint8Array) ;
|
|
3608
|
+
else if (ArrayBuffer.isView(source)) source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
3609
|
+
else if (Array.isArray(source)) source = Uint8Array.from(source);
|
|
3610
|
+
if (!(source instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
|
|
3611
|
+
if (source.length === 0) return "";
|
|
3612
|
+
// Skip & count leading zeroes.
|
|
3613
|
+
let zeroes = 0;
|
|
3614
|
+
let length = 0;
|
|
3615
|
+
let pbegin = 0;
|
|
3616
|
+
const pend = source.length;
|
|
3617
|
+
while(pbegin !== pend && source[pbegin] === 0){
|
|
3618
|
+
pbegin++;
|
|
3619
|
+
zeroes++;
|
|
3620
|
+
}
|
|
3621
|
+
// Allocate enough space in big-endian base58 representation.
|
|
3622
|
+
const size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
3623
|
+
const b58 = new Uint8Array(size);
|
|
3624
|
+
// Process the bytes.
|
|
3625
|
+
while(pbegin !== pend){
|
|
3626
|
+
let carry = source[pbegin];
|
|
3627
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
3628
|
+
let i = 0;
|
|
3629
|
+
for(let it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++){
|
|
3630
|
+
carry += 256 * b58[it1] >>> 0;
|
|
3631
|
+
b58[it1] = carry % BASE >>> 0;
|
|
3632
|
+
carry = carry / BASE >>> 0;
|
|
3633
|
+
}
|
|
3634
|
+
if (carry !== 0) throw new Error("Non-zero carry");
|
|
3635
|
+
length = i;
|
|
3636
|
+
pbegin++;
|
|
3637
|
+
}
|
|
3638
|
+
// Skip leading zeroes in base58 result.
|
|
3639
|
+
let it2 = size - length;
|
|
3640
|
+
while(it2 !== size && b58[it2] === 0)it2++;
|
|
3641
|
+
// Translate the result into a string.
|
|
3642
|
+
let str = LEADER.repeat(zeroes);
|
|
3643
|
+
for(; it2 < size; ++it2)str += ALPHABET.charAt(b58[it2]);
|
|
3644
|
+
return str;
|
|
3645
|
+
};
|
|
3646
|
+
const decodeUnsafe = (source)=>{
|
|
3647
|
+
if (typeof source !== "string") throw new TypeError("Expected String");
|
|
3648
|
+
if (source.length === 0) return new Uint8Array();
|
|
3649
|
+
let psz = 0;
|
|
3650
|
+
// Skip and count leading '1's.
|
|
3651
|
+
let zeroes = 0;
|
|
3652
|
+
let length = 0;
|
|
3653
|
+
while(source[psz] === LEADER){
|
|
3654
|
+
zeroes++;
|
|
3655
|
+
psz++;
|
|
3656
|
+
}
|
|
3657
|
+
// Allocate enough space in big-endian base256 representation.
|
|
3658
|
+
const size = (source.length - psz) * FACTOR + 1 >>> 0 // log(58) / log(256), rounded up.
|
|
3659
|
+
;
|
|
3660
|
+
let b256 = new Uint8Array(size);
|
|
3661
|
+
// Process the characters.
|
|
3662
|
+
while(source[psz]){
|
|
3663
|
+
// Decode character
|
|
3664
|
+
let carry = BASE_MAP[source.charCodeAt(psz)];
|
|
3665
|
+
// Invalid character
|
|
3666
|
+
if (carry === 255) return;
|
|
3667
|
+
let i = 0;
|
|
3668
|
+
for(let it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++){
|
|
3669
|
+
carry += BASE * b256[it3] >>> 0;
|
|
3670
|
+
b256[it3] = carry % 256 >>> 0;
|
|
3671
|
+
carry = carry / 256 >>> 0;
|
|
3672
|
+
}
|
|
3673
|
+
if (carry !== 0) throw new Error("Non-zero carry");
|
|
3674
|
+
length = i;
|
|
3675
|
+
psz++;
|
|
3676
|
+
}
|
|
3677
|
+
// Skip leading zeroes in b256.
|
|
3678
|
+
let it4 = size - length;
|
|
3679
|
+
while(it4 !== size && b256[it4] === 0)it4++;
|
|
3680
|
+
let vch = new Uint8Array(zeroes + (size - it4));
|
|
3681
|
+
let j = zeroes;
|
|
3682
|
+
while(it4 !== size)vch[j++] = b256[it4++];
|
|
3683
|
+
return vch;
|
|
3684
|
+
};
|
|
3685
|
+
const decode = (string)=>{
|
|
3686
|
+
const buffer = decodeUnsafe(string);
|
|
3687
|
+
if (buffer) return buffer;
|
|
3688
|
+
throw new Error("Non-base" + BASE + " character");
|
|
3689
|
+
};
|
|
3690
|
+
return {
|
|
3691
|
+
encode: encode,
|
|
3692
|
+
decodeUnsafe: decodeUnsafe,
|
|
3693
|
+
decode: decode
|
|
3694
|
+
};
|
|
3695
|
+
};
|
|
3696
|
+
var $7a07e400cb853a78$export$2e2bcd8739ae039 = $7a07e400cb853a78$var$base;
|
|
3697
|
+
|
|
3698
|
+
|
|
3699
|
+
const $535f3d7412ddf980$var$base32 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
3700
|
+
const $535f3d7412ddf980$var$base32Hex = "0123456789abcdefghijklmnopqrstuv";
|
|
3701
|
+
const $535f3d7412ddf980$var$decode = (uint8Array, hex = false)=>{
|
|
3702
|
+
const decoder = hex ? (0, $7a07e400cb853a78$export$2e2bcd8739ae039)($535f3d7412ddf980$var$base32Hex) : (0, $7a07e400cb853a78$export$2e2bcd8739ae039)($535f3d7412ddf980$var$base32);
|
|
3703
|
+
return decoder.decode(uint8Array);
|
|
3704
|
+
};
|
|
3705
|
+
var $535f3d7412ddf980$export$2e2bcd8739ae039 = {
|
|
3706
|
+
encode: (uint8Array, hex = false)=>{
|
|
3707
|
+
const encoder = hex ? (0, $7a07e400cb853a78$export$2e2bcd8739ae039)($535f3d7412ddf980$var$base32Hex) : (0, $7a07e400cb853a78$export$2e2bcd8739ae039)($535f3d7412ddf980$var$base32);
|
|
3708
|
+
return encoder.encode(uint8Array);
|
|
3709
|
+
},
|
|
3710
|
+
decode: $535f3d7412ddf980$var$decode,
|
|
3711
|
+
isBase32: (uint8Array, hex = false)=>{
|
|
3712
|
+
try {
|
|
3713
|
+
$535f3d7412ddf980$var$decode(uint8Array, hex);
|
|
3714
|
+
return true;
|
|
3715
|
+
} catch (e) {
|
|
3716
|
+
return false;
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
|
|
3723
|
+
const $6aa4c72dbe4d8ebf$var$base58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3724
|
+
const $6aa4c72dbe4d8ebf$var$decode = (uint8Array)=>(0, $7a07e400cb853a78$export$2e2bcd8739ae039)($6aa4c72dbe4d8ebf$var$base58).decode(uint8Array);
|
|
3725
|
+
var $6aa4c72dbe4d8ebf$export$2e2bcd8739ae039 = {
|
|
3726
|
+
encode: (uint8Array)=>(0, $7a07e400cb853a78$export$2e2bcd8739ae039)($6aa4c72dbe4d8ebf$var$base58).encode(uint8Array),
|
|
3727
|
+
decode: $6aa4c72dbe4d8ebf$var$decode,
|
|
3728
|
+
isBase58: (uint8Array)=>{
|
|
3729
|
+
try {
|
|
3730
|
+
$6aa4c72dbe4d8ebf$var$decode(uint8Array);
|
|
3731
|
+
return true;
|
|
3732
|
+
} catch (e) {
|
|
3733
|
+
return false;
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
};
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
var $31d5120d2ce127ae$export$2e2bcd8739ae039 = (string)=>/^[A-F0-9]+$/i.test(string);
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
var $af6c45bdc918b0b2$require$Buffer = $gHtSl$Buffer;
|
|
3744
|
+
class $af6c45bdc918b0b2$export$2e2bcd8739ae039 {
|
|
3745
|
+
handleDecode() {
|
|
3746
|
+
if (!this.decode) throw new Error("bad implementation: needs decode func");
|
|
3747
|
+
return this.decode();
|
|
3748
|
+
}
|
|
3749
|
+
handleEncode() {
|
|
3750
|
+
if (!this.encode) throw new Error("bad implementation: needs encode func");
|
|
3751
|
+
return this.encode();
|
|
3752
|
+
}
|
|
3753
|
+
isHex(string) {
|
|
3754
|
+
return (0, $31d5120d2ce127ae$export$2e2bcd8739ae039)(string);
|
|
3755
|
+
}
|
|
3756
|
+
isBase32(string) {
|
|
3757
|
+
return (0, $535f3d7412ddf980$export$2e2bcd8739ae039).isBase32(string);
|
|
3758
|
+
}
|
|
3759
|
+
isBase58(string) {
|
|
3760
|
+
return (0, $6aa4c72dbe4d8ebf$export$2e2bcd8739ae039).isBase58(string);
|
|
3761
|
+
}
|
|
3762
|
+
/**
|
|
3763
|
+
* @param {String} encoded
|
|
3764
|
+
*/ fromBs32(encoded) {
|
|
3765
|
+
this.encoded = (0, $535f3d7412ddf980$export$2e2bcd8739ae039).decode(encoded);
|
|
3766
|
+
return this.handleDecode();
|
|
3767
|
+
}
|
|
3768
|
+
/**
|
|
3769
|
+
* @param {String} encoded
|
|
3770
|
+
*/ fromBs58(encoded) {
|
|
3771
|
+
this.encoded = (0, $6aa4c72dbe4d8ebf$export$2e2bcd8739ae039).decode(encoded);
|
|
3772
|
+
return this.handleDecode();
|
|
3773
|
+
}
|
|
3774
|
+
async toArray() {
|
|
3775
|
+
const array = [];
|
|
3776
|
+
for await (const value1 of this.encoded.values())array.push(value1);
|
|
3777
|
+
return array;
|
|
3778
|
+
}
|
|
3779
|
+
fromString(string) {
|
|
3780
|
+
this.encoded = new Uint8Array(string.split(","));
|
|
3781
|
+
return this.handleDecode();
|
|
3782
|
+
}
|
|
3783
|
+
fromArray(array) {
|
|
3784
|
+
this.encoded = new Uint8Array([
|
|
3785
|
+
...array
|
|
3786
|
+
]);
|
|
3787
|
+
return this.handleDecode();
|
|
3788
|
+
}
|
|
3789
|
+
/**
|
|
3790
|
+
* @param {Buffer} encoded
|
|
3791
|
+
*/ fromEncoded(encoded) {
|
|
3792
|
+
this.encoded = encoded;
|
|
3793
|
+
return this.handleDecode();
|
|
3794
|
+
}
|
|
3795
|
+
/**
|
|
3796
|
+
* @param {String} encoded
|
|
3797
|
+
*/ fromHex(encoded) {
|
|
3798
|
+
this.encoded = $af6c45bdc918b0b2$require$Buffer.from(encoded, "hex");
|
|
3799
|
+
return this.handleDecode();
|
|
3800
|
+
}
|
|
3801
|
+
async toString(encoding = "utf8") {
|
|
3802
|
+
if (!this.encoded) await this.handleEncode();
|
|
3803
|
+
return this.encoded.toString(encoding);
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* @return {String} encoded
|
|
3807
|
+
*/ toHex() {
|
|
3808
|
+
return this.toString("hex");
|
|
3809
|
+
}
|
|
3810
|
+
/**
|
|
3811
|
+
* @return {String} encoded
|
|
3812
|
+
*/ async toBs32() {
|
|
3813
|
+
if (!this.encoded) await this.handleEncode();
|
|
3814
|
+
return (0, $535f3d7412ddf980$export$2e2bcd8739ae039).encode(this.encoded);
|
|
3815
|
+
}
|
|
3816
|
+
/**
|
|
3817
|
+
* @return {String} encoded
|
|
3818
|
+
*/ async toBs58() {
|
|
3819
|
+
if (!this.encoded) await this.handleEncode();
|
|
3820
|
+
return (0, $6aa4c72dbe4d8ebf$export$2e2bcd8739ae039).encode(this.encoded);
|
|
3821
|
+
}
|
|
3822
|
+
/**
|
|
3823
|
+
* @param {Object} data
|
|
3824
|
+
*/ create(data) {
|
|
3825
|
+
const decoded = {};
|
|
3826
|
+
if (this.keys?.length > 0) {
|
|
3827
|
+
for (const key of this.keys)Object.defineProperties(decoded, {
|
|
3828
|
+
[key]: {
|
|
3829
|
+
enumerable: true,
|
|
3830
|
+
configurable: true,
|
|
3831
|
+
set: (val)=>value = data[key],
|
|
3832
|
+
get: ()=>data[key]
|
|
3833
|
+
}
|
|
3834
|
+
});
|
|
3835
|
+
this.decoded = decoded;
|
|
3836
|
+
return this.encode();
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
var $61722dc45b139836$exports = {};
|
|
3844
|
+
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
$61722dc45b139836$exports = {
|
|
3848
|
+
encode: (parcelRequire("O0X0N")),
|
|
3849
|
+
decode: (parcelRequire("c0YY7")),
|
|
3850
|
+
encodingLength: (parcelRequire("1H9q1"))
|
|
3851
|
+
};
|
|
3852
|
+
|
|
3853
|
+
|
|
3854
|
+
var $73779ceb9ad23576$export$2e2bcd8739ae039 = {
|
|
3855
|
+
// just a hash
|
|
3856
|
+
"disco-hash": {
|
|
3857
|
+
codec: parseInt("30", 16),
|
|
3858
|
+
hashAlg: "dbl-keccak-256"
|
|
3859
|
+
},
|
|
3860
|
+
"peernet-peer-response": {
|
|
3861
|
+
codec: parseInt("707072", 16),
|
|
3862
|
+
hashAlg: "keccak-256"
|
|
3863
|
+
},
|
|
3864
|
+
"peernet-peer": {
|
|
3865
|
+
codec: parseInt("7070", 16),
|
|
3866
|
+
hashAlg: "keccak-256"
|
|
3867
|
+
},
|
|
3868
|
+
"peernet-dht": {
|
|
3869
|
+
codec: parseInt("706468", 16),
|
|
3870
|
+
hashAlg: "keccak-256"
|
|
3871
|
+
},
|
|
3872
|
+
"peernet-dht-response": {
|
|
3873
|
+
codec: parseInt("706472", 16),
|
|
3874
|
+
hashAlg: "keccak-256"
|
|
3875
|
+
},
|
|
3876
|
+
// data
|
|
3877
|
+
"peernet-data": {
|
|
3878
|
+
codec: parseInt("706461", 16),
|
|
3879
|
+
hashAlg: "keccak-256"
|
|
3880
|
+
},
|
|
3881
|
+
"peernet-data-response": {
|
|
3882
|
+
codec: parseInt("70646172", 16),
|
|
3883
|
+
hashAlg: "keccak-256"
|
|
3884
|
+
},
|
|
3885
|
+
// message
|
|
3886
|
+
"peernet-message": {
|
|
3887
|
+
codec: parseInt("706d65", 16),
|
|
3888
|
+
hashAlg: "keccak-256"
|
|
3889
|
+
},
|
|
3890
|
+
// pubsub
|
|
3891
|
+
"peernet-ps": {
|
|
3892
|
+
codec: parseInt("707073", 16),
|
|
3893
|
+
hashAlg: "keccak-256"
|
|
3894
|
+
},
|
|
3895
|
+
"peernet-response": {
|
|
3896
|
+
codec: parseInt("7072", 16),
|
|
3897
|
+
hashAlg: "keccak-256"
|
|
3898
|
+
},
|
|
3899
|
+
"peernet-request": {
|
|
3900
|
+
codec: parseInt("707271", 16),
|
|
3901
|
+
hashAlg: "keccak-256"
|
|
3902
|
+
},
|
|
3903
|
+
// normal block
|
|
3904
|
+
"leofcoin-block": {
|
|
3905
|
+
codec: parseInt("6c62", 16),
|
|
3906
|
+
hashAlg: "dbl-keccak-512"
|
|
3907
|
+
},
|
|
3908
|
+
"leofcoin-tx": {
|
|
3909
|
+
codec: parseInt("6c74", 16),
|
|
3910
|
+
hashAlg: "dbl-keccak-512"
|
|
3911
|
+
},
|
|
3912
|
+
// itx
|
|
3913
|
+
"leofcoin-itx": {
|
|
3914
|
+
codec: parseInt("6c69", 16),
|
|
3915
|
+
hashAlg: "keccak-512"
|
|
3916
|
+
},
|
|
3917
|
+
// peer reputation
|
|
3918
|
+
"leofcoin-pr": {
|
|
3919
|
+
codec: parseInt("6c70", 16),
|
|
3920
|
+
hashAlg: "keccak-256"
|
|
3921
|
+
},
|
|
3922
|
+
// chat message
|
|
3923
|
+
"chat-message": {
|
|
3924
|
+
codec: parseInt("636d", 16),
|
|
3925
|
+
hashAlg: "dbl-keccak-256"
|
|
3926
|
+
},
|
|
3927
|
+
"peernet-file": {
|
|
3928
|
+
codec: parseInt("7066", 16),
|
|
3929
|
+
hashAlg: "keccak-256"
|
|
3930
|
+
},
|
|
3931
|
+
"peernet-file-response": {
|
|
3932
|
+
codec: parseInt("706672", 16),
|
|
3933
|
+
hashAlg: "keccak-256"
|
|
3934
|
+
}
|
|
3935
|
+
};
|
|
3936
|
+
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
class $9ca3109881fa7a7a$export$2e2bcd8739ae039 extends (0, $af6c45bdc918b0b2$export$2e2bcd8739ae039) {
|
|
3940
|
+
get codecs() {
|
|
3941
|
+
return {
|
|
3942
|
+
...globalThis.peernet.codecs,
|
|
3943
|
+
...(0, $73779ceb9ad23576$export$2e2bcd8739ae039)
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
fromEncoded(encoded) {
|
|
3947
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(encoded);
|
|
3948
|
+
const name = this.getCodecName(codec);
|
|
3949
|
+
this.name = name;
|
|
3950
|
+
this.encoded = encoded;
|
|
3951
|
+
this.decode(encoded);
|
|
3952
|
+
}
|
|
3953
|
+
getCodec(name) {
|
|
3954
|
+
return this.codecs[name].codec;
|
|
3955
|
+
}
|
|
3956
|
+
getCodecName(codec) {
|
|
3957
|
+
return Object.keys(this.codecs).reduce((p, c)=>{
|
|
3958
|
+
const item = this.codecs[c];
|
|
3959
|
+
if (item.codec === codec) return c;
|
|
3960
|
+
else return p;
|
|
3961
|
+
}, undefined);
|
|
3962
|
+
}
|
|
3963
|
+
getHashAlg(name) {
|
|
3964
|
+
return this.codecs[name].hashAlg;
|
|
3965
|
+
}
|
|
3966
|
+
fromCodec(codec) {
|
|
3967
|
+
this.name = this.getCodecName(codec);
|
|
3968
|
+
this.hashAlg = this.getHashAlg(this.name);
|
|
3969
|
+
this.codec = this.getCodec(this.name);
|
|
3970
|
+
this.codecBuffer = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).encode(codec);
|
|
3971
|
+
}
|
|
3972
|
+
fromName(name) {
|
|
3973
|
+
const codec = this.getCodec(name);
|
|
3974
|
+
this.name = name;
|
|
3975
|
+
this.codec = codec;
|
|
3976
|
+
this.hashAlg = this.getHashAlg(name);
|
|
3977
|
+
this.codecBuffer = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).encode(codec);
|
|
3978
|
+
}
|
|
3979
|
+
decode() {
|
|
3980
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(this.encoded);
|
|
3981
|
+
this.fromCodec(codec);
|
|
3982
|
+
}
|
|
3983
|
+
encode() {
|
|
3984
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).encode(this.decoded);
|
|
3985
|
+
this.encoded = codec;
|
|
3986
|
+
return this.encoded;
|
|
3987
|
+
}
|
|
3988
|
+
constructor(buffer){
|
|
3989
|
+
super();
|
|
3990
|
+
if (buffer) {
|
|
3991
|
+
if (buffer instanceof Uint8Array) {
|
|
3992
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(buffer);
|
|
3993
|
+
const name = this.getCodecName(codec);
|
|
3994
|
+
if (name) {
|
|
3995
|
+
this.name = name;
|
|
3996
|
+
this.encoded = buffer;
|
|
3997
|
+
this.decode(buffer);
|
|
3998
|
+
} else this.encode(buffer);
|
|
3999
|
+
} else if (buffer instanceof ArrayBuffer) {
|
|
4000
|
+
const encoded = new Uint8Array(buffer.byteLength);
|
|
4001
|
+
for(let i = 0; i < buffer.byteLength; i++)encoded[i] = buffer[i];
|
|
4002
|
+
this.encoded = encoded;
|
|
4003
|
+
// this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength)
|
|
4004
|
+
this.decode(buffer);
|
|
4005
|
+
return;
|
|
4006
|
+
}
|
|
4007
|
+
if (typeof buffer === "string") {
|
|
4008
|
+
if (this.codecs[buffer]) this.fromName(buffer);
|
|
4009
|
+
else if (this.isHex(buffer)) this.fromHex(buffer);
|
|
4010
|
+
else if (this.isBase32(buffer)) this.fromBs32(buffer);
|
|
4011
|
+
else if (this.isBase58(buffer)) this.fromBs58(buffer);
|
|
4012
|
+
else throw new Error(`unsupported string ${buffer}`);
|
|
4013
|
+
}
|
|
4014
|
+
if (!isNaN(buffer)) {
|
|
4015
|
+
if (this.codecs[this.getCodecName(buffer)]) this.fromCodec(buffer);
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
|
|
4022
|
+
var $65534db4b3124287$exports = {};
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
$65534db4b3124287$exports = (parcelRequire("4n0nt"))((parcelRequire("3isIp")));
|
|
4026
|
+
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
var $479b6579a0da0716$require$Buffer = $gHtSl$Buffer;
|
|
4033
|
+
class $479b6579a0da0716$export$2e2bcd8739ae039 extends (0, $af6c45bdc918b0b2$export$2e2bcd8739ae039) {
|
|
4034
|
+
get prefix() {
|
|
4035
|
+
const length = this.length;
|
|
4036
|
+
const uint8Array = new Uint8Array(length.length + this.discoCodec.codecBuffer.length);
|
|
4037
|
+
uint8Array.set(length);
|
|
4038
|
+
uint8Array.set(this.discoCodec.codecBuffer, length.length);
|
|
4039
|
+
return uint8Array;
|
|
4040
|
+
}
|
|
4041
|
+
get length() {
|
|
4042
|
+
return (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).encode(this.size);
|
|
4043
|
+
}
|
|
4044
|
+
get buffer() {
|
|
4045
|
+
return this.encoded;
|
|
4046
|
+
}
|
|
4047
|
+
get hash() {
|
|
4048
|
+
return this.encoded;
|
|
4049
|
+
}
|
|
4050
|
+
fromJSON(json) {
|
|
4051
|
+
return this.encode($479b6579a0da0716$require$Buffer.from(JSON.stringify(json)));
|
|
4052
|
+
}
|
|
4053
|
+
encode(buffer, name) {
|
|
4054
|
+
if (!this.name && name) this.name = name;
|
|
4055
|
+
if (!buffer) buffer = this.buffer;
|
|
4056
|
+
this.discoCodec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(this.name, this.codecs);
|
|
4057
|
+
this.discoCodec.fromName(this.name);
|
|
4058
|
+
let hashAlg = this.discoCodec.hashAlg;
|
|
4059
|
+
if (hashAlg.includes("dbl")) {
|
|
4060
|
+
hashAlg = hashAlg.replace("dbl-", "");
|
|
4061
|
+
buffer = (0, (/*@__PURE__*/$parcel$interopDefault($65534db4b3124287$exports)))(hashAlg.replace("-", "")).update(buffer).digest();
|
|
4062
|
+
}
|
|
4063
|
+
this.digest = (0, (/*@__PURE__*/$parcel$interopDefault($65534db4b3124287$exports)))(hashAlg.replace("-", "")).update(buffer).digest();
|
|
4064
|
+
this.size = this.digest.length;
|
|
4065
|
+
this.codec = this.discoCodec.encode();
|
|
4066
|
+
this.codec = this.discoCodec.codecBuffer;
|
|
4067
|
+
const uint8Array = new Uint8Array(this.digest.length + this.prefix.length);
|
|
4068
|
+
uint8Array.set(this.prefix);
|
|
4069
|
+
uint8Array.set(this.digest, this.prefix.length);
|
|
4070
|
+
this.encoded = uint8Array;
|
|
4071
|
+
return this.encoded;
|
|
4072
|
+
}
|
|
4073
|
+
validate(buffer) {
|
|
4074
|
+
if ($479b6579a0da0716$require$Buffer.isBuffer(buffer)) {
|
|
4075
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(buffer);
|
|
4076
|
+
if (this.codecs[codec]) this.decode(buffer);
|
|
4077
|
+
else this.encode(buffer);
|
|
4078
|
+
}
|
|
4079
|
+
if (typeof buffer === "string") {
|
|
4080
|
+
if (this.isHex(buffer)) this.fromHex(buffer);
|
|
4081
|
+
if (this.isBase32(buffer)) this.fromBs32(buffer);
|
|
4082
|
+
}
|
|
4083
|
+
if (typeof buffer === "object") this.fromJSON(buffer);
|
|
4084
|
+
}
|
|
4085
|
+
decode(buffer) {
|
|
4086
|
+
this.encoded = buffer;
|
|
4087
|
+
const codec = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(buffer);
|
|
4088
|
+
this.discoCodec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(codec, this.codecs);
|
|
4089
|
+
// TODO: validate codec
|
|
4090
|
+
buffer = buffer.slice((0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode.bytes);
|
|
4091
|
+
this.size = (0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode(buffer);
|
|
4092
|
+
this.digest = buffer.slice((0, (/*@__PURE__*/$parcel$interopDefault($61722dc45b139836$exports))).decode.bytes);
|
|
4093
|
+
if (this.digest.length !== this.size) throw new Error(`hash length inconsistent: 0x${this.encoded.toString("hex")}`);
|
|
4094
|
+
// const discoCodec = new Codec(codec, this.codecs)
|
|
4095
|
+
this.name = this.discoCodec.name;
|
|
4096
|
+
this.size = this.digest.length;
|
|
4097
|
+
return {
|
|
4098
|
+
codec: this.codec,
|
|
4099
|
+
name: this.name,
|
|
4100
|
+
size: this.size,
|
|
4101
|
+
length: this.length,
|
|
4102
|
+
digest: this.digest
|
|
4103
|
+
};
|
|
4104
|
+
}
|
|
4105
|
+
constructor(buffer, options = {}){
|
|
4106
|
+
super();
|
|
4107
|
+
if (options.name) this.name = options.name;
|
|
4108
|
+
else this.name = "disco-hash";
|
|
4109
|
+
if (options.codecs) this.codecs = options.codecs;
|
|
4110
|
+
if (buffer) {
|
|
4111
|
+
if (buffer instanceof Uint8Array) {
|
|
4112
|
+
this.discoCodec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(buffer, this.codecs);
|
|
4113
|
+
const name = this.discoCodec.name;
|
|
4114
|
+
if (name) {
|
|
4115
|
+
this.name = name;
|
|
4116
|
+
this.decode(buffer);
|
|
4117
|
+
} else this.encode(buffer);
|
|
4118
|
+
}
|
|
4119
|
+
if (typeof buffer === "string") {
|
|
4120
|
+
if (this.isHex(buffer)) this.fromHex(buffer);
|
|
4121
|
+
if (this.isBase32(buffer)) this.fromBs32(buffer);
|
|
4122
|
+
else if (this.isBase58(buffer)) this.fromBs58(buffer);
|
|
4123
|
+
else throw new Error(`unsupported string ${buffer}`);
|
|
4124
|
+
} else if (typeof buffer === "object") this.fromJSON(buffer);
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
class $20c7f34bf5b0b473$export$2e2bcd8739ae039 extends (0, $af6c45bdc918b0b2$export$2e2bcd8739ae039) {
|
|
4131
|
+
async protoEncode(data) {
|
|
4132
|
+
// check schema
|
|
4133
|
+
return new TextEncoder().encode(data);
|
|
4134
|
+
}
|
|
4135
|
+
async protoDecode(data) {
|
|
4136
|
+
// check schema
|
|
4137
|
+
return new TextDecoder().decode(data);
|
|
4138
|
+
}
|
|
4139
|
+
async init(buffer) {
|
|
4140
|
+
if (buffer instanceof Uint8Array) await this.fromUint8Array(buffer);
|
|
4141
|
+
else if (buffer instanceof ArrayBuffer) await this.fromArrayBuffer(buffer);
|
|
4142
|
+
else if (buffer?.name === this.name) return buffer;
|
|
4143
|
+
else if (buffer instanceof String) {
|
|
4144
|
+
if (this.isHex(buffer)) await this.fromHex(buffer);
|
|
4145
|
+
else if (this.isBase32(buffer)) await this.fromBs32(buffer);
|
|
4146
|
+
else if (this.isBase58(buffer)) await this.fromBs58(buffer);
|
|
4147
|
+
else throw new Error(`unsupported string ${buffer}`);
|
|
4148
|
+
} else await this.create(buffer);
|
|
4149
|
+
return this;
|
|
4150
|
+
}
|
|
4151
|
+
/**
|
|
4152
|
+
* @return {PeernetHash}
|
|
4153
|
+
*/ get peernetHash() {
|
|
4154
|
+
return new (0, $479b6579a0da0716$export$2e2bcd8739ae039)(this.decoded, {
|
|
4155
|
+
name: this.name
|
|
4156
|
+
});
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* @return {peernetHash}
|
|
4160
|
+
*/ get hash() {
|
|
4161
|
+
const upper = this.hashFormat.charAt(0).toUpperCase();
|
|
4162
|
+
const format = `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
|
|
4163
|
+
return this.peernetHash[`to${format}`]();
|
|
4164
|
+
}
|
|
4165
|
+
/**
|
|
4166
|
+
* @return {Object}
|
|
4167
|
+
*/ async decode() {
|
|
4168
|
+
let encoded = this.encoded;
|
|
4169
|
+
const discoCodec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(this.encoded);
|
|
4170
|
+
encoded = encoded.slice(discoCodec.codecBuffer.length);
|
|
4171
|
+
this.name = discoCodec.name;
|
|
4172
|
+
this.decoded = await this.protoDecode(encoded);
|
|
4173
|
+
try {
|
|
4174
|
+
this.decoded = JSON.parse(this.decoded);
|
|
4175
|
+
} catch {}
|
|
4176
|
+
return this.decoded;
|
|
4177
|
+
}
|
|
4178
|
+
/**
|
|
4179
|
+
* @return {Buffer}
|
|
4180
|
+
*/ async encode(decoded) {
|
|
4181
|
+
if (!decoded) decoded = this.decoded;
|
|
4182
|
+
const codec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(this.name);
|
|
4183
|
+
const encoded = await this.protoEncode(typeof decoded === "object" ? JSON.stringify(decoded) : decoded);
|
|
4184
|
+
const uint8Array = new Uint8Array(encoded.length + codec.codecBuffer.length);
|
|
4185
|
+
uint8Array.set(codec.codecBuffer);
|
|
4186
|
+
uint8Array.set(encoded, codec.codecBuffer.length);
|
|
4187
|
+
this.encoded = uint8Array;
|
|
4188
|
+
return this.encoded;
|
|
4189
|
+
}
|
|
4190
|
+
hasCodec() {
|
|
4191
|
+
if (!this.encoded) return false;
|
|
4192
|
+
const codec = new (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039)(this.encoded);
|
|
4193
|
+
if (codec.name) return true;
|
|
4194
|
+
}
|
|
4195
|
+
fromUint8Array(buffer) {
|
|
4196
|
+
this.encoded = buffer;
|
|
4197
|
+
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
4198
|
+
}
|
|
4199
|
+
fromArrayBuffer(buffer) {
|
|
4200
|
+
this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
|
|
4201
|
+
return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
4202
|
+
}
|
|
4203
|
+
/**
|
|
4204
|
+
* @param {Buffer|String|Object} buffer - data - The data needed to create the desired message
|
|
4205
|
+
* @param {Object} proto - {encode, decode}
|
|
4206
|
+
* @param {Object} options - {hashFormat, name}
|
|
4207
|
+
*/ constructor(buffer, proto, options = {}){
|
|
4208
|
+
super();
|
|
4209
|
+
this.proto = proto;
|
|
4210
|
+
this.hashFormat = options.hashFormat || "bs32";
|
|
4211
|
+
if (options.name) this.name = options.name;
|
|
4212
|
+
return this.init(buffer);
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
|
|
4217
|
+
|
|
4218
|
+
|
|
4219
|
+
|
|
4220
|
+
const $428095396ca04bce$export$1b7dbb60aef3044 = (0, $af6c45bdc918b0b2$export$2e2bcd8739ae039);
|
|
4221
|
+
const $428095396ca04bce$export$a3360ca1fc583f9e = (0, $20c7f34bf5b0b473$export$2e2bcd8739ae039);
|
|
4222
|
+
const $428095396ca04bce$export$ea841ad44f0598a2 = (0, $479b6579a0da0716$export$2e2bcd8739ae039);
|
|
4223
|
+
const $428095396ca04bce$export$a111e9ced3f1d2d0 = (0, $9ca3109881fa7a7a$export$2e2bcd8739ae039);
|
|
4224
|
+
const $428095396ca04bce$export$1c4d583cbe1d2b10 = (0, $73779ceb9ad23576$export$2e2bcd8739ae039);
|
|
4225
|
+
|
|
4226
|
+
|
|
4227
|
+
export {$428095396ca04bce$export$1b7dbb60aef3044 as BasicInterface, $428095396ca04bce$export$a3360ca1fc583f9e as FormatInterface, $428095396ca04bce$export$ea841ad44f0598a2 as CodecHash, $428095396ca04bce$export$a111e9ced3f1d2d0 as Codec, $428095396ca04bce$export$1c4d583cbe1d2b10 as Codecs};
|
|
4228
|
+
//# sourceMappingURL=browser.js.map
|