@waku/core 0.0.4 → 0.0.6

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/bundle/{index-a67d7136.js → index-925587a4.js} +1696 -113
  3. package/bundle/index.js +12942 -15253
  4. package/bundle/lib/predefined_bootstrap_nodes.js +24 -4
  5. package/bundle/lib/wait_for_remote_peer.js +4 -6
  6. package/bundle/lib/waku_message/topic_only_message.js +2 -3
  7. package/bundle/lib/waku_message/version_0.js +17 -4
  8. package/bundle/{message-049c8b67.js → message-70dbb19b.js} +1419 -753
  9. package/bundle/{topic_only_message-5ad3a869.js → topic_only_message-a80fe8b2.js} +2 -2
  10. package/dist/index.d.ts +5 -4
  11. package/dist/index.js +5 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/predefined_bootstrap_nodes.d.ts +1 -2
  14. package/dist/lib/predefined_bootstrap_nodes.js +0 -2
  15. package/dist/lib/predefined_bootstrap_nodes.js.map +1 -1
  16. package/dist/lib/to_proto_message.js +1 -0
  17. package/dist/lib/to_proto_message.js.map +1 -1
  18. package/dist/lib/wait_for_remote_peer.js +2 -2
  19. package/dist/lib/wait_for_remote_peer.js.map +1 -1
  20. package/dist/lib/waku.d.ts +16 -15
  21. package/dist/lib/waku.js +31 -33
  22. package/dist/lib/waku.js.map +1 -1
  23. package/dist/lib/waku_filter/index.d.ts +10 -35
  24. package/dist/lib/waku_filter/index.js +13 -7
  25. package/dist/lib/waku_filter/index.js.map +1 -1
  26. package/dist/lib/waku_light_push/index.d.ts +8 -24
  27. package/dist/lib/waku_light_push/index.js +12 -6
  28. package/dist/lib/waku_light_push/index.js.map +1 -1
  29. package/dist/lib/waku_message/topic_only_message.d.ts +3 -2
  30. package/dist/lib/waku_message/topic_only_message.js +1 -0
  31. package/dist/lib/waku_message/topic_only_message.js.map +1 -1
  32. package/dist/lib/waku_message/version_0.d.ts +5 -2
  33. package/dist/lib/waku_message/version_0.js +9 -2
  34. package/dist/lib/waku_message/version_0.js.map +1 -1
  35. package/dist/lib/waku_relay/index.d.ts +3 -45
  36. package/dist/lib/waku_relay/index.js +6 -3
  37. package/dist/lib/waku_relay/index.js.map +1 -1
  38. package/dist/lib/waku_store/index.d.ts +11 -71
  39. package/dist/lib/waku_store/index.js +34 -10
  40. package/dist/lib/waku_store/index.js.map +1 -1
  41. package/dist/proto/filter.d.ts +1 -0
  42. package/dist/proto/filter.js +7 -0
  43. package/dist/proto/filter.js.map +1 -1
  44. package/dist/proto/light_push.d.ts +1 -0
  45. package/dist/proto/light_push.js +7 -0
  46. package/dist/proto/light_push.js.map +1 -1
  47. package/dist/proto/message.d.ts +1 -0
  48. package/dist/proto/message.js +7 -0
  49. package/dist/proto/message.js.map +1 -1
  50. package/dist/proto/store.d.ts +1 -0
  51. package/dist/proto/store.js +7 -0
  52. package/dist/proto/store.js.map +1 -1
  53. package/package.json +11 -13
  54. package/src/index.ts +10 -4
  55. package/src/lib/predefined_bootstrap_nodes.ts +1 -5
  56. package/src/lib/to_proto_message.ts +1 -0
  57. package/src/lib/wait_for_remote_peer.ts +2 -2
  58. package/src/lib/waku.ts +51 -47
  59. package/src/lib/waku_filter/index.ts +28 -7
  60. package/src/lib/waku_light_push/index.ts +26 -6
  61. package/src/lib/waku_message/topic_only_message.ts +4 -2
  62. package/src/lib/waku_message/version_0.ts +8 -2
  63. package/src/lib/waku_relay/index.ts +13 -3
  64. package/src/lib/waku_store/index.ts +63 -12
  65. package/src/proto/filter.ts +9 -0
  66. package/src/proto/light_push.ts +9 -0
  67. package/src/proto/message.ts +9 -0
  68. package/src/proto/store.ts +9 -0
  69. package/bundle/browser-1e1a2f27.js +0 -722
  70. package/bundle/events-158407bb.js +0 -1929
  71. package/bundle/index-64ce43f0.js +0 -69
  72. package/bundle/index-8710041d.js +0 -2962
  73. package/bundle/lib/peer_discovery_static_list.js +0 -89
  74. package/bundle/random_subset-75d1c511.js +0 -26
  75. package/dist/lib/peer_discovery_static_list.d.ts +0 -44
  76. package/dist/lib/peer_discovery_static_list.js +0 -72
  77. package/dist/lib/peer_discovery_static_list.js.map +0 -1
  78. package/src/lib/peer_discovery_static_list.ts +0 -118
@@ -25,848 +25,1514 @@ function getAugmentedNamespace(n) {
25
25
  return a;
26
26
  }
27
27
 
28
- var protobufjs = {exports: {}};
28
+ var browser = {exports: {}};
29
29
 
30
- var src = {exports: {}};
30
+ /**
31
+ * Helpers.
32
+ */
31
33
 
32
- var indexLight = {exports: {}};
34
+ var ms;
35
+ var hasRequiredMs;
36
+
37
+ function requireMs () {
38
+ if (hasRequiredMs) return ms;
39
+ hasRequiredMs = 1;
40
+ var s = 1000;
41
+ var m = s * 60;
42
+ var h = m * 60;
43
+ var d = h * 24;
44
+ var w = d * 7;
45
+ var y = d * 365.25;
46
+
47
+ /**
48
+ * Parse or format the given `val`.
49
+ *
50
+ * Options:
51
+ *
52
+ * - `long` verbose formatting [false]
53
+ *
54
+ * @param {String|Number} val
55
+ * @param {Object} [options]
56
+ * @throws {Error} throw an error if val is not a non-empty string or a number
57
+ * @return {String|Number}
58
+ * @api public
59
+ */
60
+
61
+ ms = function(val, options) {
62
+ options = options || {};
63
+ var type = typeof val;
64
+ if (type === 'string' && val.length > 0) {
65
+ return parse(val);
66
+ } else if (type === 'number' && isFinite(val)) {
67
+ return options.long ? fmtLong(val) : fmtShort(val);
68
+ }
69
+ throw new Error(
70
+ 'val is not a non-empty string or a valid number. val=' +
71
+ JSON.stringify(val)
72
+ );
73
+ };
33
74
 
34
- var indexMinimal = {};
75
+ /**
76
+ * Parse the given `str` and return milliseconds.
77
+ *
78
+ * @param {String} str
79
+ * @return {Number}
80
+ * @api private
81
+ */
82
+
83
+ function parse(str) {
84
+ str = String(str);
85
+ if (str.length > 100) {
86
+ return;
87
+ }
88
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
89
+ str
90
+ );
91
+ if (!match) {
92
+ return;
93
+ }
94
+ var n = parseFloat(match[1]);
95
+ var type = (match[2] || 'ms').toLowerCase();
96
+ switch (type) {
97
+ case 'years':
98
+ case 'year':
99
+ case 'yrs':
100
+ case 'yr':
101
+ case 'y':
102
+ return n * y;
103
+ case 'weeks':
104
+ case 'week':
105
+ case 'w':
106
+ return n * w;
107
+ case 'days':
108
+ case 'day':
109
+ case 'd':
110
+ return n * d;
111
+ case 'hours':
112
+ case 'hour':
113
+ case 'hrs':
114
+ case 'hr':
115
+ case 'h':
116
+ return n * h;
117
+ case 'minutes':
118
+ case 'minute':
119
+ case 'mins':
120
+ case 'min':
121
+ case 'm':
122
+ return n * m;
123
+ case 'seconds':
124
+ case 'second':
125
+ case 'secs':
126
+ case 'sec':
127
+ case 's':
128
+ return n * s;
129
+ case 'milliseconds':
130
+ case 'millisecond':
131
+ case 'msecs':
132
+ case 'msec':
133
+ case 'ms':
134
+ return n;
135
+ default:
136
+ return undefined;
137
+ }
138
+ }
35
139
 
36
- var minimal = {};
140
+ /**
141
+ * Short format for `ms`.
142
+ *
143
+ * @param {Number} ms
144
+ * @return {String}
145
+ * @api private
146
+ */
147
+
148
+ function fmtShort(ms) {
149
+ var msAbs = Math.abs(ms);
150
+ if (msAbs >= d) {
151
+ return Math.round(ms / d) + 'd';
152
+ }
153
+ if (msAbs >= h) {
154
+ return Math.round(ms / h) + 'h';
155
+ }
156
+ if (msAbs >= m) {
157
+ return Math.round(ms / m) + 'm';
158
+ }
159
+ if (msAbs >= s) {
160
+ return Math.round(ms / s) + 's';
161
+ }
162
+ return ms + 'ms';
163
+ }
37
164
 
38
- var aspromise;
39
- var hasRequiredAspromise;
165
+ /**
166
+ * Long format for `ms`.
167
+ *
168
+ * @param {Number} ms
169
+ * @return {String}
170
+ * @api private
171
+ */
172
+
173
+ function fmtLong(ms) {
174
+ var msAbs = Math.abs(ms);
175
+ if (msAbs >= d) {
176
+ return plural(ms, msAbs, d, 'day');
177
+ }
178
+ if (msAbs >= h) {
179
+ return plural(ms, msAbs, h, 'hour');
180
+ }
181
+ if (msAbs >= m) {
182
+ return plural(ms, msAbs, m, 'minute');
183
+ }
184
+ if (msAbs >= s) {
185
+ return plural(ms, msAbs, s, 'second');
186
+ }
187
+ return ms + ' ms';
188
+ }
40
189
 
41
- function requireAspromise () {
42
- if (hasRequiredAspromise) return aspromise;
43
- hasRequiredAspromise = 1;
44
- aspromise = asPromise;
45
-
46
- /**
47
- * Callback as used by {@link util.asPromise}.
48
- * @typedef asPromiseCallback
49
- * @type {function}
50
- * @param {Error|null} error Error, if any
51
- * @param {...*} params Additional arguments
52
- * @returns {undefined}
53
- */
54
-
55
- /**
56
- * Returns a promise from a node-style callback function.
57
- * @memberof util
58
- * @param {asPromiseCallback} fn Function to call
59
- * @param {*} ctx Function context
60
- * @param {...*} params Function arguments
61
- * @returns {Promise<*>} Promisified function
62
- */
63
- function asPromise(fn, ctx/*, varargs */) {
64
- var params = new Array(arguments.length - 1),
65
- offset = 0,
66
- index = 2,
67
- pending = true;
68
- while (index < arguments.length)
69
- params[offset++] = arguments[index++];
70
- return new Promise(function executor(resolve, reject) {
71
- params[offset] = function callback(err/*, varargs */) {
72
- if (pending) {
73
- pending = false;
74
- if (err)
75
- reject(err);
76
- else {
77
- var params = new Array(arguments.length - 1),
78
- offset = 0;
79
- while (offset < params.length)
80
- params[offset++] = arguments[offset];
81
- resolve.apply(null, params);
82
- }
83
- }
84
- };
85
- try {
86
- fn.apply(ctx || null, params);
87
- } catch (err) {
88
- if (pending) {
89
- pending = false;
90
- reject(err);
91
- }
92
- }
93
- });
190
+ /**
191
+ * Pluralization helper.
192
+ */
193
+
194
+ function plural(ms, msAbs, n, name) {
195
+ var isPlural = msAbs >= n * 1.5;
196
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
94
197
  }
95
- return aspromise;
198
+ return ms;
96
199
  }
97
200
 
98
- var base64$1 = {};
201
+ /**
202
+ * This is the common logic for both the Node.js and web browser
203
+ * implementations of `debug()`.
204
+ */
99
205
 
100
- var hasRequiredBase64;
206
+ function setup(env) {
207
+ createDebug.debug = createDebug;
208
+ createDebug.default = createDebug;
209
+ createDebug.coerce = coerce;
210
+ createDebug.disable = disable;
211
+ createDebug.enable = enable;
212
+ createDebug.enabled = enabled;
213
+ createDebug.humanize = requireMs();
214
+ createDebug.destroy = destroy;
215
+
216
+ Object.keys(env).forEach(key => {
217
+ createDebug[key] = env[key];
218
+ });
101
219
 
102
- function requireBase64 () {
103
- if (hasRequiredBase64) return base64$1;
104
- hasRequiredBase64 = 1;
105
- (function (exports) {
106
-
107
- /**
108
- * A minimal base64 implementation for number arrays.
109
- * @memberof util
110
- * @namespace
111
- */
112
- var base64 = exports;
113
-
114
- /**
115
- * Calculates the byte length of a base64 encoded string.
116
- * @param {string} string Base64 encoded string
117
- * @returns {number} Byte length
118
- */
119
- base64.length = function length(string) {
120
- var p = string.length;
121
- if (!p)
122
- return 0;
123
- var n = 0;
124
- while (--p % 4 > 1 && string.charAt(p) === "=")
125
- ++n;
126
- return Math.ceil(string.length * 3) / 4 - n;
127
- };
128
-
129
- // Base64 encoding table
130
- var b64 = new Array(64);
131
-
132
- // Base64 decoding table
133
- var s64 = new Array(123);
134
-
135
- // 65..90, 97..122, 48..57, 43, 47
136
- for (var i = 0; i < 64;)
137
- s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
138
-
139
- /**
140
- * Encodes a buffer to a base64 encoded string.
141
- * @param {Uint8Array} buffer Source buffer
142
- * @param {number} start Source start
143
- * @param {number} end Source end
144
- * @returns {string} Base64 encoded string
145
- */
146
- base64.encode = function encode(buffer, start, end) {
147
- var parts = null,
148
- chunk = [];
149
- var i = 0, // output index
150
- j = 0, // goto index
151
- t; // temporary
152
- while (start < end) {
153
- var b = buffer[start++];
154
- switch (j) {
155
- case 0:
156
- chunk[i++] = b64[b >> 2];
157
- t = (b & 3) << 4;
158
- j = 1;
159
- break;
160
- case 1:
161
- chunk[i++] = b64[t | b >> 4];
162
- t = (b & 15) << 2;
163
- j = 2;
164
- break;
165
- case 2:
166
- chunk[i++] = b64[t | b >> 6];
167
- chunk[i++] = b64[b & 63];
168
- j = 0;
169
- break;
170
- }
171
- if (i > 8191) {
172
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
173
- i = 0;
174
- }
175
- }
176
- if (j) {
177
- chunk[i++] = b64[t];
178
- chunk[i++] = 61;
179
- if (j === 1)
180
- chunk[i++] = 61;
181
- }
182
- if (parts) {
183
- if (i)
184
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
185
- return parts.join("");
186
- }
187
- return String.fromCharCode.apply(String, chunk.slice(0, i));
188
- };
189
-
190
- var invalidEncoding = "invalid encoding";
220
+ /**
221
+ * The currently active debug mode names, and names to skip.
222
+ */
223
+
224
+ createDebug.names = [];
225
+ createDebug.skips = [];
226
+
227
+ /**
228
+ * Map of special "%n" handling functions, for the debug "format" argument.
229
+ *
230
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
231
+ */
232
+ createDebug.formatters = {};
233
+
234
+ /**
235
+ * Selects a color for a debug namespace
236
+ * @param {String} namespace The namespace string for the debug instance to be colored
237
+ * @return {Number|String} An ANSI color code for the given namespace
238
+ * @api private
239
+ */
240
+ function selectColor(namespace) {
241
+ let hash = 0;
242
+
243
+ for (let i = 0; i < namespace.length; i++) {
244
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
245
+ hash |= 0; // Convert to 32bit integer
246
+ }
247
+
248
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
249
+ }
250
+ createDebug.selectColor = selectColor;
251
+
252
+ /**
253
+ * Create a debugger with the given `namespace`.
254
+ *
255
+ * @param {String} namespace
256
+ * @return {Function}
257
+ * @api public
258
+ */
259
+ function createDebug(namespace) {
260
+ let prevTime;
261
+ let enableOverride = null;
262
+ let namespacesCache;
263
+ let enabledCache;
264
+
265
+ function debug(...args) {
266
+ // Disabled?
267
+ if (!debug.enabled) {
268
+ return;
269
+ }
270
+
271
+ const self = debug;
272
+
273
+ // Set `diff` timestamp
274
+ const curr = Number(new Date());
275
+ const ms = curr - (prevTime || curr);
276
+ self.diff = ms;
277
+ self.prev = prevTime;
278
+ self.curr = curr;
279
+ prevTime = curr;
280
+
281
+ args[0] = createDebug.coerce(args[0]);
282
+
283
+ if (typeof args[0] !== 'string') {
284
+ // Anything else let's inspect with %O
285
+ args.unshift('%O');
286
+ }
287
+
288
+ // Apply any `formatters` transformations
289
+ let index = 0;
290
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
291
+ // If we encounter an escaped % then don't increase the array index
292
+ if (match === '%%') {
293
+ return '%';
294
+ }
295
+ index++;
296
+ const formatter = createDebug.formatters[format];
297
+ if (typeof formatter === 'function') {
298
+ const val = args[index];
299
+ match = formatter.call(self, val);
300
+
301
+ // Now we need to remove `args[index]` since it's inlined in the `format`
302
+ args.splice(index, 1);
303
+ index--;
304
+ }
305
+ return match;
306
+ });
307
+
308
+ // Apply env-specific formatting (colors, etc.)
309
+ createDebug.formatArgs.call(self, args);
310
+
311
+ const logFn = self.log || createDebug.log;
312
+ logFn.apply(self, args);
313
+ }
314
+
315
+ debug.namespace = namespace;
316
+ debug.useColors = createDebug.useColors();
317
+ debug.color = createDebug.selectColor(namespace);
318
+ debug.extend = extend;
319
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
320
+
321
+ Object.defineProperty(debug, 'enabled', {
322
+ enumerable: true,
323
+ configurable: false,
324
+ get: () => {
325
+ if (enableOverride !== null) {
326
+ return enableOverride;
327
+ }
328
+ if (namespacesCache !== createDebug.namespaces) {
329
+ namespacesCache = createDebug.namespaces;
330
+ enabledCache = createDebug.enabled(namespace);
331
+ }
332
+
333
+ return enabledCache;
334
+ },
335
+ set: v => {
336
+ enableOverride = v;
337
+ }
338
+ });
339
+
340
+ // Env-specific initialization logic for debug instances
341
+ if (typeof createDebug.init === 'function') {
342
+ createDebug.init(debug);
343
+ }
344
+
345
+ return debug;
346
+ }
347
+
348
+ function extend(namespace, delimiter) {
349
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
350
+ newDebug.log = this.log;
351
+ return newDebug;
352
+ }
353
+
354
+ /**
355
+ * Enables a debug mode by namespaces. This can include modes
356
+ * separated by a colon and wildcards.
357
+ *
358
+ * @param {String} namespaces
359
+ * @api public
360
+ */
361
+ function enable(namespaces) {
362
+ createDebug.save(namespaces);
363
+ createDebug.namespaces = namespaces;
364
+
365
+ createDebug.names = [];
366
+ createDebug.skips = [];
367
+
368
+ let i;
369
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
370
+ const len = split.length;
371
+
372
+ for (i = 0; i < len; i++) {
373
+ if (!split[i]) {
374
+ // ignore empty strings
375
+ continue;
376
+ }
377
+
378
+ namespaces = split[i].replace(/\*/g, '.*?');
379
+
380
+ if (namespaces[0] === '-') {
381
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
382
+ } else {
383
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
384
+ }
385
+ }
386
+ }
387
+
388
+ /**
389
+ * Disable debug output.
390
+ *
391
+ * @return {String} namespaces
392
+ * @api public
393
+ */
394
+ function disable() {
395
+ const namespaces = [
396
+ ...createDebug.names.map(toNamespace),
397
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
398
+ ].join(',');
399
+ createDebug.enable('');
400
+ return namespaces;
401
+ }
402
+
403
+ /**
404
+ * Returns true if the given mode name is enabled, false otherwise.
405
+ *
406
+ * @param {String} name
407
+ * @return {Boolean}
408
+ * @api public
409
+ */
410
+ function enabled(name) {
411
+ if (name[name.length - 1] === '*') {
412
+ return true;
413
+ }
414
+
415
+ let i;
416
+ let len;
417
+
418
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
419
+ if (createDebug.skips[i].test(name)) {
420
+ return false;
421
+ }
422
+ }
423
+
424
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
425
+ if (createDebug.names[i].test(name)) {
426
+ return true;
427
+ }
428
+ }
429
+
430
+ return false;
431
+ }
432
+
433
+ /**
434
+ * Convert regexp to namespace
435
+ *
436
+ * @param {RegExp} regxep
437
+ * @return {String} namespace
438
+ * @api private
439
+ */
440
+ function toNamespace(regexp) {
441
+ return regexp.toString()
442
+ .substring(2, regexp.toString().length - 2)
443
+ .replace(/\.\*\?$/, '*');
444
+ }
445
+
446
+ /**
447
+ * Coerce `val`.
448
+ *
449
+ * @param {Mixed} val
450
+ * @return {Mixed}
451
+ * @api private
452
+ */
453
+ function coerce(val) {
454
+ if (val instanceof Error) {
455
+ return val.stack || val.message;
456
+ }
457
+ return val;
458
+ }
459
+
460
+ /**
461
+ * XXX DO NOT USE. This is a temporary stub function.
462
+ * XXX It WILL be removed in the next major release.
463
+ */
464
+ function destroy() {
465
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
466
+ }
467
+
468
+ createDebug.enable(createDebug.load());
469
+
470
+ return createDebug;
471
+ }
472
+
473
+ var common$1 = setup;
474
+
475
+ /* eslint-env browser */
476
+
477
+ (function (module, exports) {
478
+ /**
479
+ * This is the web browser implementation of `debug()`.
480
+ */
481
+
482
+ exports.formatArgs = formatArgs;
483
+ exports.save = save;
484
+ exports.load = load;
485
+ exports.useColors = useColors;
486
+ exports.storage = localstorage();
487
+ exports.destroy = (() => {
488
+ let warned = false;
489
+
490
+ return () => {
491
+ if (!warned) {
492
+ warned = true;
493
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
494
+ }
495
+ };
496
+ })();
497
+
498
+ /**
499
+ * Colors.
500
+ */
501
+
502
+ exports.colors = [
503
+ '#0000CC',
504
+ '#0000FF',
505
+ '#0033CC',
506
+ '#0033FF',
507
+ '#0066CC',
508
+ '#0066FF',
509
+ '#0099CC',
510
+ '#0099FF',
511
+ '#00CC00',
512
+ '#00CC33',
513
+ '#00CC66',
514
+ '#00CC99',
515
+ '#00CCCC',
516
+ '#00CCFF',
517
+ '#3300CC',
518
+ '#3300FF',
519
+ '#3333CC',
520
+ '#3333FF',
521
+ '#3366CC',
522
+ '#3366FF',
523
+ '#3399CC',
524
+ '#3399FF',
525
+ '#33CC00',
526
+ '#33CC33',
527
+ '#33CC66',
528
+ '#33CC99',
529
+ '#33CCCC',
530
+ '#33CCFF',
531
+ '#6600CC',
532
+ '#6600FF',
533
+ '#6633CC',
534
+ '#6633FF',
535
+ '#66CC00',
536
+ '#66CC33',
537
+ '#9900CC',
538
+ '#9900FF',
539
+ '#9933CC',
540
+ '#9933FF',
541
+ '#99CC00',
542
+ '#99CC33',
543
+ '#CC0000',
544
+ '#CC0033',
545
+ '#CC0066',
546
+ '#CC0099',
547
+ '#CC00CC',
548
+ '#CC00FF',
549
+ '#CC3300',
550
+ '#CC3333',
551
+ '#CC3366',
552
+ '#CC3399',
553
+ '#CC33CC',
554
+ '#CC33FF',
555
+ '#CC6600',
556
+ '#CC6633',
557
+ '#CC9900',
558
+ '#CC9933',
559
+ '#CCCC00',
560
+ '#CCCC33',
561
+ '#FF0000',
562
+ '#FF0033',
563
+ '#FF0066',
564
+ '#FF0099',
565
+ '#FF00CC',
566
+ '#FF00FF',
567
+ '#FF3300',
568
+ '#FF3333',
569
+ '#FF3366',
570
+ '#FF3399',
571
+ '#FF33CC',
572
+ '#FF33FF',
573
+ '#FF6600',
574
+ '#FF6633',
575
+ '#FF9900',
576
+ '#FF9933',
577
+ '#FFCC00',
578
+ '#FFCC33'
579
+ ];
580
+
581
+ /**
582
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
583
+ * and the Firebug extension (any Firefox version) are known
584
+ * to support "%c" CSS customizations.
585
+ *
586
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
587
+ */
588
+
589
+ // eslint-disable-next-line complexity
590
+ function useColors() {
591
+ // NB: In an Electron preload script, document will be defined but not fully
592
+ // initialized. Since we know we're in Chrome, we'll just detect this case
593
+ // explicitly
594
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
595
+ return true;
596
+ }
597
+
598
+ // Internet Explorer and Edge do not support colors.
599
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
600
+ return false;
601
+ }
602
+
603
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
604
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
605
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
606
+ // Is firebug? http://stackoverflow.com/a/398120/376773
607
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
608
+ // Is firefox >= v31?
609
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
610
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
611
+ // Double check webkit in userAgent just in case we are in a worker
612
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
613
+ }
614
+
615
+ /**
616
+ * Colorize log arguments if enabled.
617
+ *
618
+ * @api public
619
+ */
620
+
621
+ function formatArgs(args) {
622
+ args[0] = (this.useColors ? '%c' : '') +
623
+ this.namespace +
624
+ (this.useColors ? ' %c' : ' ') +
625
+ args[0] +
626
+ (this.useColors ? '%c ' : ' ') +
627
+ '+' + module.exports.humanize(this.diff);
628
+
629
+ if (!this.useColors) {
630
+ return;
631
+ }
632
+
633
+ const c = 'color: ' + this.color;
634
+ args.splice(1, 0, c, 'color: inherit');
635
+
636
+ // The final "%c" is somewhat tricky, because there could be other
637
+ // arguments passed either before or after the %c, so we need to
638
+ // figure out the correct index to insert the CSS into
639
+ let index = 0;
640
+ let lastC = 0;
641
+ args[0].replace(/%[a-zA-Z%]/g, match => {
642
+ if (match === '%%') {
643
+ return;
644
+ }
645
+ index++;
646
+ if (match === '%c') {
647
+ // We only are interested in the *last* %c
648
+ // (the user may have provided their own)
649
+ lastC = index;
650
+ }
651
+ });
652
+
653
+ args.splice(lastC, 0, c);
654
+ }
655
+
656
+ /**
657
+ * Invokes `console.debug()` when available.
658
+ * No-op when `console.debug` is not a "function".
659
+ * If `console.debug` is not available, falls back
660
+ * to `console.log`.
661
+ *
662
+ * @api public
663
+ */
664
+ exports.log = console.debug || console.log || (() => {});
665
+
666
+ /**
667
+ * Save `namespaces`.
668
+ *
669
+ * @param {String} namespaces
670
+ * @api private
671
+ */
672
+ function save(namespaces) {
673
+ try {
674
+ if (namespaces) {
675
+ exports.storage.setItem('debug', namespaces);
676
+ } else {
677
+ exports.storage.removeItem('debug');
678
+ }
679
+ } catch (error) {
680
+ // Swallow
681
+ // XXX (@Qix-) should we be logging these?
682
+ }
683
+ }
684
+
685
+ /**
686
+ * Load `namespaces`.
687
+ *
688
+ * @return {String} returns the previously persisted debug modes
689
+ * @api private
690
+ */
691
+ function load() {
692
+ let r;
693
+ try {
694
+ r = exports.storage.getItem('debug');
695
+ } catch (error) {
696
+ // Swallow
697
+ // XXX (@Qix-) should we be logging these?
698
+ }
699
+
700
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
701
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
702
+ r = process.env.DEBUG;
703
+ }
704
+
705
+ return r;
706
+ }
707
+
708
+ /**
709
+ * Localstorage attempts to return the localstorage.
710
+ *
711
+ * This is necessary because safari throws
712
+ * when a user disables cookies/localstorage
713
+ * and you attempt to access it.
714
+ *
715
+ * @return {LocalStorage}
716
+ * @api private
717
+ */
718
+
719
+ function localstorage() {
720
+ try {
721
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
722
+ // The Browser also has localStorage in the global context.
723
+ return localStorage;
724
+ } catch (error) {
725
+ // Swallow
726
+ // XXX (@Qix-) should we be logging these?
727
+ }
728
+ }
729
+
730
+ module.exports = common$1(exports);
731
+
732
+ const {formatters} = module.exports;
733
+
734
+ /**
735
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
736
+ */
737
+
738
+ formatters.j = function (v) {
739
+ try {
740
+ return JSON.stringify(v);
741
+ } catch (error) {
742
+ return '[UnexpectedJSONParseError]: ' + error.message;
743
+ }
744
+ };
745
+ } (browser, browser.exports));
746
+
747
+ var debug = browser.exports;
748
+
749
+ var protobufjs = {exports: {}};
750
+
751
+ var src = {exports: {}};
752
+
753
+ var indexLight = {exports: {}};
754
+
755
+ var indexMinimal = {};
756
+
757
+ var minimal = {};
758
+
759
+ var aspromise = asPromise$1;
191
760
 
192
- /**
193
- * Decodes a base64 encoded string to a buffer.
194
- * @param {string} string Source string
195
- * @param {Uint8Array} buffer Destination buffer
196
- * @param {number} offset Destination offset
197
- * @returns {number} Number of bytes written
198
- * @throws {Error} If encoding is invalid
199
- */
200
- base64.decode = function decode(string, buffer, offset) {
201
- var start = offset;
202
- var j = 0, // goto index
203
- t; // temporary
204
- for (var i = 0; i < string.length;) {
205
- var c = string.charCodeAt(i++);
206
- if (c === 61 && j > 1)
207
- break;
208
- if ((c = s64[c]) === undefined)
209
- throw Error(invalidEncoding);
210
- switch (j) {
211
- case 0:
212
- t = c;
213
- j = 1;
214
- break;
215
- case 1:
216
- buffer[offset++] = t << 2 | (c & 48) >> 4;
217
- t = c;
218
- j = 2;
219
- break;
220
- case 2:
221
- buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
222
- t = c;
223
- j = 3;
224
- break;
225
- case 3:
226
- buffer[offset++] = (t & 3) << 6 | c;
227
- j = 0;
228
- break;
229
- }
230
- }
231
- if (j === 1)
232
- throw Error(invalidEncoding);
233
- return offset - start;
234
- };
761
+ /**
762
+ * Callback as used by {@link util.asPromise}.
763
+ * @typedef asPromiseCallback
764
+ * @type {function}
765
+ * @param {Error|null} error Error, if any
766
+ * @param {...*} params Additional arguments
767
+ * @returns {undefined}
768
+ */
235
769
 
236
- /**
237
- * Tests if the specified string appears to be base64 encoded.
238
- * @param {string} string String to test
239
- * @returns {boolean} `true` if probably base64 encoded, otherwise false
240
- */
241
- base64.test = function test(string) {
242
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
243
- };
244
- } (base64$1));
245
- return base64$1;
770
+ /**
771
+ * Returns a promise from a node-style callback function.
772
+ * @memberof util
773
+ * @param {asPromiseCallback} fn Function to call
774
+ * @param {*} ctx Function context
775
+ * @param {...*} params Function arguments
776
+ * @returns {Promise<*>} Promisified function
777
+ */
778
+ function asPromise$1(fn, ctx/*, varargs */) {
779
+ var params = new Array(arguments.length - 1),
780
+ offset = 0,
781
+ index = 2,
782
+ pending = true;
783
+ while (index < arguments.length)
784
+ params[offset++] = arguments[index++];
785
+ return new Promise(function executor(resolve, reject) {
786
+ params[offset] = function callback(err/*, varargs */) {
787
+ if (pending) {
788
+ pending = false;
789
+ if (err)
790
+ reject(err);
791
+ else {
792
+ var params = new Array(arguments.length - 1),
793
+ offset = 0;
794
+ while (offset < params.length)
795
+ params[offset++] = arguments[offset];
796
+ resolve.apply(null, params);
797
+ }
798
+ }
799
+ };
800
+ try {
801
+ fn.apply(ctx || null, params);
802
+ } catch (err) {
803
+ if (pending) {
804
+ pending = false;
805
+ reject(err);
806
+ }
807
+ }
808
+ });
246
809
  }
247
810
 
248
- var eventemitter;
249
- var hasRequiredEventemitter;
811
+ var base64$1 = {};
250
812
 
251
- function requireEventemitter () {
252
- if (hasRequiredEventemitter) return eventemitter;
253
- hasRequiredEventemitter = 1;
254
- eventemitter = EventEmitter;
813
+ (function (exports) {
255
814
 
256
815
  /**
257
- * Constructs a new event emitter instance.
258
- * @classdesc A minimal event emitter.
816
+ * A minimal base64 implementation for number arrays.
259
817
  * @memberof util
260
- * @constructor
818
+ * @namespace
261
819
  */
262
- function EventEmitter() {
263
-
264
- /**
265
- * Registered listeners.
266
- * @type {Object.<string,*>}
267
- * @private
268
- */
269
- this._listeners = {};
270
- }
820
+ var base64 = exports;
271
821
 
272
822
  /**
273
- * Registers an event listener.
274
- * @param {string} evt Event name
275
- * @param {function} fn Listener
276
- * @param {*} [ctx] Listener context
277
- * @returns {util.EventEmitter} `this`
823
+ * Calculates the byte length of a base64 encoded string.
824
+ * @param {string} string Base64 encoded string
825
+ * @returns {number} Byte length
278
826
  */
279
- EventEmitter.prototype.on = function on(evt, fn, ctx) {
280
- (this._listeners[evt] || (this._listeners[evt] = [])).push({
281
- fn : fn,
282
- ctx : ctx || this
283
- });
284
- return this;
827
+ base64.length = function length(string) {
828
+ var p = string.length;
829
+ if (!p)
830
+ return 0;
831
+ var n = 0;
832
+ while (--p % 4 > 1 && string.charAt(p) === "=")
833
+ ++n;
834
+ return Math.ceil(string.length * 3) / 4 - n;
285
835
  };
286
836
 
837
+ // Base64 encoding table
838
+ var b64 = new Array(64);
839
+
840
+ // Base64 decoding table
841
+ var s64 = new Array(123);
842
+
843
+ // 65..90, 97..122, 48..57, 43, 47
844
+ for (var i = 0; i < 64;)
845
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
846
+
287
847
  /**
288
- * Removes an event listener or any matching listeners if arguments are omitted.
289
- * @param {string} [evt] Event name. Removes all listeners if omitted.
290
- * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
291
- * @returns {util.EventEmitter} `this`
848
+ * Encodes a buffer to a base64 encoded string.
849
+ * @param {Uint8Array} buffer Source buffer
850
+ * @param {number} start Source start
851
+ * @param {number} end Source end
852
+ * @returns {string} Base64 encoded string
292
853
  */
293
- EventEmitter.prototype.off = function off(evt, fn) {
294
- if (evt === undefined)
295
- this._listeners = {};
296
- else {
297
- if (fn === undefined)
298
- this._listeners[evt] = [];
299
- else {
300
- var listeners = this._listeners[evt];
301
- for (var i = 0; i < listeners.length;)
302
- if (listeners[i].fn === fn)
303
- listeners.splice(i, 1);
304
- else
305
- ++i;
854
+ base64.encode = function encode(buffer, start, end) {
855
+ var parts = null,
856
+ chunk = [];
857
+ var i = 0, // output index
858
+ j = 0, // goto index
859
+ t; // temporary
860
+ while (start < end) {
861
+ var b = buffer[start++];
862
+ switch (j) {
863
+ case 0:
864
+ chunk[i++] = b64[b >> 2];
865
+ t = (b & 3) << 4;
866
+ j = 1;
867
+ break;
868
+ case 1:
869
+ chunk[i++] = b64[t | b >> 4];
870
+ t = (b & 15) << 2;
871
+ j = 2;
872
+ break;
873
+ case 2:
874
+ chunk[i++] = b64[t | b >> 6];
875
+ chunk[i++] = b64[b & 63];
876
+ j = 0;
877
+ break;
878
+ }
879
+ if (i > 8191) {
880
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
881
+ i = 0;
306
882
  }
307
883
  }
308
- return this;
884
+ if (j) {
885
+ chunk[i++] = b64[t];
886
+ chunk[i++] = 61;
887
+ if (j === 1)
888
+ chunk[i++] = 61;
889
+ }
890
+ if (parts) {
891
+ if (i)
892
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
893
+ return parts.join("");
894
+ }
895
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
309
896
  };
310
897
 
898
+ var invalidEncoding = "invalid encoding";
899
+
311
900
  /**
312
- * Emits an event by calling its listeners with the specified arguments.
313
- * @param {string} evt Event name
314
- * @param {...*} args Arguments
315
- * @returns {util.EventEmitter} `this`
901
+ * Decodes a base64 encoded string to a buffer.
902
+ * @param {string} string Source string
903
+ * @param {Uint8Array} buffer Destination buffer
904
+ * @param {number} offset Destination offset
905
+ * @returns {number} Number of bytes written
906
+ * @throws {Error} If encoding is invalid
316
907
  */
317
- EventEmitter.prototype.emit = function emit(evt) {
318
- var listeners = this._listeners[evt];
319
- if (listeners) {
320
- var args = [],
321
- i = 1;
322
- for (; i < arguments.length;)
323
- args.push(arguments[i++]);
324
- for (i = 0; i < listeners.length;)
325
- listeners[i].fn.apply(listeners[i++].ctx, args);
908
+ base64.decode = function decode(string, buffer, offset) {
909
+ var start = offset;
910
+ var j = 0, // goto index
911
+ t; // temporary
912
+ for (var i = 0; i < string.length;) {
913
+ var c = string.charCodeAt(i++);
914
+ if (c === 61 && j > 1)
915
+ break;
916
+ if ((c = s64[c]) === undefined)
917
+ throw Error(invalidEncoding);
918
+ switch (j) {
919
+ case 0:
920
+ t = c;
921
+ j = 1;
922
+ break;
923
+ case 1:
924
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
925
+ t = c;
926
+ j = 2;
927
+ break;
928
+ case 2:
929
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
930
+ t = c;
931
+ j = 3;
932
+ break;
933
+ case 3:
934
+ buffer[offset++] = (t & 3) << 6 | c;
935
+ j = 0;
936
+ break;
937
+ }
326
938
  }
327
- return this;
939
+ if (j === 1)
940
+ throw Error(invalidEncoding);
941
+ return offset - start;
942
+ };
943
+
944
+ /**
945
+ * Tests if the specified string appears to be base64 encoded.
946
+ * @param {string} string String to test
947
+ * @returns {boolean} `true` if probably base64 encoded, otherwise false
948
+ */
949
+ base64.test = function test(string) {
950
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
328
951
  };
329
- return eventemitter;
330
- }
331
-
332
- var float;
333
- var hasRequiredFloat;
952
+ } (base64$1));
334
953
 
335
- function requireFloat () {
336
- if (hasRequiredFloat) return float;
337
- hasRequiredFloat = 1;
954
+ var eventemitter = EventEmitter;
338
955
 
339
- float = factory(factory);
956
+ /**
957
+ * Constructs a new event emitter instance.
958
+ * @classdesc A minimal event emitter.
959
+ * @memberof util
960
+ * @constructor
961
+ */
962
+ function EventEmitter() {
340
963
 
341
- /**
342
- * Reads / writes floats / doubles from / to buffers.
343
- * @name util.float
344
- * @namespace
345
- */
964
+ /**
965
+ * Registered listeners.
966
+ * @type {Object.<string,*>}
967
+ * @private
968
+ */
969
+ this._listeners = {};
970
+ }
346
971
 
347
- /**
348
- * Writes a 32 bit float to a buffer using little endian byte order.
349
- * @name util.float.writeFloatLE
350
- * @function
351
- * @param {number} val Value to write
352
- * @param {Uint8Array} buf Target buffer
353
- * @param {number} pos Target buffer offset
354
- * @returns {undefined}
355
- */
972
+ /**
973
+ * Registers an event listener.
974
+ * @param {string} evt Event name
975
+ * @param {function} fn Listener
976
+ * @param {*} [ctx] Listener context
977
+ * @returns {util.EventEmitter} `this`
978
+ */
979
+ EventEmitter.prototype.on = function on(evt, fn, ctx) {
980
+ (this._listeners[evt] || (this._listeners[evt] = [])).push({
981
+ fn : fn,
982
+ ctx : ctx || this
983
+ });
984
+ return this;
985
+ };
356
986
 
357
- /**
358
- * Writes a 32 bit float to a buffer using big endian byte order.
359
- * @name util.float.writeFloatBE
360
- * @function
361
- * @param {number} val Value to write
362
- * @param {Uint8Array} buf Target buffer
363
- * @param {number} pos Target buffer offset
364
- * @returns {undefined}
365
- */
987
+ /**
988
+ * Removes an event listener or any matching listeners if arguments are omitted.
989
+ * @param {string} [evt] Event name. Removes all listeners if omitted.
990
+ * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
991
+ * @returns {util.EventEmitter} `this`
992
+ */
993
+ EventEmitter.prototype.off = function off(evt, fn) {
994
+ if (evt === undefined)
995
+ this._listeners = {};
996
+ else {
997
+ if (fn === undefined)
998
+ this._listeners[evt] = [];
999
+ else {
1000
+ var listeners = this._listeners[evt];
1001
+ for (var i = 0; i < listeners.length;)
1002
+ if (listeners[i].fn === fn)
1003
+ listeners.splice(i, 1);
1004
+ else
1005
+ ++i;
1006
+ }
1007
+ }
1008
+ return this;
1009
+ };
366
1010
 
367
- /**
368
- * Reads a 32 bit float from a buffer using little endian byte order.
369
- * @name util.float.readFloatLE
370
- * @function
371
- * @param {Uint8Array} buf Source buffer
372
- * @param {number} pos Source buffer offset
373
- * @returns {number} Value read
374
- */
1011
+ /**
1012
+ * Emits an event by calling its listeners with the specified arguments.
1013
+ * @param {string} evt Event name
1014
+ * @param {...*} args Arguments
1015
+ * @returns {util.EventEmitter} `this`
1016
+ */
1017
+ EventEmitter.prototype.emit = function emit(evt) {
1018
+ var listeners = this._listeners[evt];
1019
+ if (listeners) {
1020
+ var args = [],
1021
+ i = 1;
1022
+ for (; i < arguments.length;)
1023
+ args.push(arguments[i++]);
1024
+ for (i = 0; i < listeners.length;)
1025
+ listeners[i].fn.apply(listeners[i++].ctx, args);
1026
+ }
1027
+ return this;
1028
+ };
1029
+
1030
+ var float = factory(factory);
375
1031
 
376
- /**
377
- * Reads a 32 bit float from a buffer using big endian byte order.
378
- * @name util.float.readFloatBE
379
- * @function
380
- * @param {Uint8Array} buf Source buffer
381
- * @param {number} pos Source buffer offset
382
- * @returns {number} Value read
383
- */
1032
+ /**
1033
+ * Reads / writes floats / doubles from / to buffers.
1034
+ * @name util.float
1035
+ * @namespace
1036
+ */
384
1037
 
385
- /**
386
- * Writes a 64 bit double to a buffer using little endian byte order.
387
- * @name util.float.writeDoubleLE
388
- * @function
389
- * @param {number} val Value to write
390
- * @param {Uint8Array} buf Target buffer
391
- * @param {number} pos Target buffer offset
392
- * @returns {undefined}
393
- */
1038
+ /**
1039
+ * Writes a 32 bit float to a buffer using little endian byte order.
1040
+ * @name util.float.writeFloatLE
1041
+ * @function
1042
+ * @param {number} val Value to write
1043
+ * @param {Uint8Array} buf Target buffer
1044
+ * @param {number} pos Target buffer offset
1045
+ * @returns {undefined}
1046
+ */
394
1047
 
395
- /**
396
- * Writes a 64 bit double to a buffer using big endian byte order.
397
- * @name util.float.writeDoubleBE
398
- * @function
399
- * @param {number} val Value to write
400
- * @param {Uint8Array} buf Target buffer
401
- * @param {number} pos Target buffer offset
402
- * @returns {undefined}
403
- */
1048
+ /**
1049
+ * Writes a 32 bit float to a buffer using big endian byte order.
1050
+ * @name util.float.writeFloatBE
1051
+ * @function
1052
+ * @param {number} val Value to write
1053
+ * @param {Uint8Array} buf Target buffer
1054
+ * @param {number} pos Target buffer offset
1055
+ * @returns {undefined}
1056
+ */
404
1057
 
405
- /**
406
- * Reads a 64 bit double from a buffer using little endian byte order.
407
- * @name util.float.readDoubleLE
408
- * @function
409
- * @param {Uint8Array} buf Source buffer
410
- * @param {number} pos Source buffer offset
411
- * @returns {number} Value read
412
- */
1058
+ /**
1059
+ * Reads a 32 bit float from a buffer using little endian byte order.
1060
+ * @name util.float.readFloatLE
1061
+ * @function
1062
+ * @param {Uint8Array} buf Source buffer
1063
+ * @param {number} pos Source buffer offset
1064
+ * @returns {number} Value read
1065
+ */
413
1066
 
414
- /**
415
- * Reads a 64 bit double from a buffer using big endian byte order.
416
- * @name util.float.readDoubleBE
417
- * @function
418
- * @param {Uint8Array} buf Source buffer
419
- * @param {number} pos Source buffer offset
420
- * @returns {number} Value read
421
- */
1067
+ /**
1068
+ * Reads a 32 bit float from a buffer using big endian byte order.
1069
+ * @name util.float.readFloatBE
1070
+ * @function
1071
+ * @param {Uint8Array} buf Source buffer
1072
+ * @param {number} pos Source buffer offset
1073
+ * @returns {number} Value read
1074
+ */
422
1075
 
423
- // Factory function for the purpose of node-based testing in modified global environments
424
- function factory(exports) {
1076
+ /**
1077
+ * Writes a 64 bit double to a buffer using little endian byte order.
1078
+ * @name util.float.writeDoubleLE
1079
+ * @function
1080
+ * @param {number} val Value to write
1081
+ * @param {Uint8Array} buf Target buffer
1082
+ * @param {number} pos Target buffer offset
1083
+ * @returns {undefined}
1084
+ */
425
1085
 
426
- // float: typed array
427
- if (typeof Float32Array !== "undefined") (function() {
1086
+ /**
1087
+ * Writes a 64 bit double to a buffer using big endian byte order.
1088
+ * @name util.float.writeDoubleBE
1089
+ * @function
1090
+ * @param {number} val Value to write
1091
+ * @param {Uint8Array} buf Target buffer
1092
+ * @param {number} pos Target buffer offset
1093
+ * @returns {undefined}
1094
+ */
428
1095
 
429
- var f32 = new Float32Array([ -0 ]),
430
- f8b = new Uint8Array(f32.buffer),
431
- le = f8b[3] === 128;
1096
+ /**
1097
+ * Reads a 64 bit double from a buffer using little endian byte order.
1098
+ * @name util.float.readDoubleLE
1099
+ * @function
1100
+ * @param {Uint8Array} buf Source buffer
1101
+ * @param {number} pos Source buffer offset
1102
+ * @returns {number} Value read
1103
+ */
432
1104
 
433
- function writeFloat_f32_cpy(val, buf, pos) {
434
- f32[0] = val;
435
- buf[pos ] = f8b[0];
436
- buf[pos + 1] = f8b[1];
437
- buf[pos + 2] = f8b[2];
438
- buf[pos + 3] = f8b[3];
439
- }
1105
+ /**
1106
+ * Reads a 64 bit double from a buffer using big endian byte order.
1107
+ * @name util.float.readDoubleBE
1108
+ * @function
1109
+ * @param {Uint8Array} buf Source buffer
1110
+ * @param {number} pos Source buffer offset
1111
+ * @returns {number} Value read
1112
+ */
440
1113
 
441
- function writeFloat_f32_rev(val, buf, pos) {
442
- f32[0] = val;
443
- buf[pos ] = f8b[3];
444
- buf[pos + 1] = f8b[2];
445
- buf[pos + 2] = f8b[1];
446
- buf[pos + 3] = f8b[0];
447
- }
1114
+ // Factory function for the purpose of node-based testing in modified global environments
1115
+ function factory(exports) {
448
1116
 
449
- /* istanbul ignore next */
450
- exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
451
- /* istanbul ignore next */
452
- exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
1117
+ // float: typed array
1118
+ if (typeof Float32Array !== "undefined") (function() {
453
1119
 
454
- function readFloat_f32_cpy(buf, pos) {
455
- f8b[0] = buf[pos ];
456
- f8b[1] = buf[pos + 1];
457
- f8b[2] = buf[pos + 2];
458
- f8b[3] = buf[pos + 3];
459
- return f32[0];
460
- }
1120
+ var f32 = new Float32Array([ -0 ]),
1121
+ f8b = new Uint8Array(f32.buffer),
1122
+ le = f8b[3] === 128;
461
1123
 
462
- function readFloat_f32_rev(buf, pos) {
463
- f8b[3] = buf[pos ];
464
- f8b[2] = buf[pos + 1];
465
- f8b[1] = buf[pos + 2];
466
- f8b[0] = buf[pos + 3];
467
- return f32[0];
468
- }
1124
+ function writeFloat_f32_cpy(val, buf, pos) {
1125
+ f32[0] = val;
1126
+ buf[pos ] = f8b[0];
1127
+ buf[pos + 1] = f8b[1];
1128
+ buf[pos + 2] = f8b[2];
1129
+ buf[pos + 3] = f8b[3];
1130
+ }
469
1131
 
470
- /* istanbul ignore next */
471
- exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
472
- /* istanbul ignore next */
473
- exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
1132
+ function writeFloat_f32_rev(val, buf, pos) {
1133
+ f32[0] = val;
1134
+ buf[pos ] = f8b[3];
1135
+ buf[pos + 1] = f8b[2];
1136
+ buf[pos + 2] = f8b[1];
1137
+ buf[pos + 3] = f8b[0];
1138
+ }
474
1139
 
475
- // float: ieee754
476
- })(); else (function() {
1140
+ /* istanbul ignore next */
1141
+ exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
1142
+ /* istanbul ignore next */
1143
+ exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
477
1144
 
478
- function writeFloat_ieee754(writeUint, val, buf, pos) {
479
- var sign = val < 0 ? 1 : 0;
480
- if (sign)
481
- val = -val;
482
- if (val === 0)
483
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
484
- else if (isNaN(val))
485
- writeUint(2143289344, buf, pos);
486
- else if (val > 3.4028234663852886e+38) // +-Infinity
487
- writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
488
- else if (val < 1.1754943508222875e-38) // denormal
489
- writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
490
- else {
491
- var exponent = Math.floor(Math.log(val) / Math.LN2),
492
- mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
493
- writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
494
- }
495
- }
1145
+ function readFloat_f32_cpy(buf, pos) {
1146
+ f8b[0] = buf[pos ];
1147
+ f8b[1] = buf[pos + 1];
1148
+ f8b[2] = buf[pos + 2];
1149
+ f8b[3] = buf[pos + 3];
1150
+ return f32[0];
1151
+ }
496
1152
 
497
- exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
498
- exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
1153
+ function readFloat_f32_rev(buf, pos) {
1154
+ f8b[3] = buf[pos ];
1155
+ f8b[2] = buf[pos + 1];
1156
+ f8b[1] = buf[pos + 2];
1157
+ f8b[0] = buf[pos + 3];
1158
+ return f32[0];
1159
+ }
499
1160
 
500
- function readFloat_ieee754(readUint, buf, pos) {
501
- var uint = readUint(buf, pos),
502
- sign = (uint >> 31) * 2 + 1,
503
- exponent = uint >>> 23 & 255,
504
- mantissa = uint & 8388607;
505
- return exponent === 255
506
- ? mantissa
507
- ? NaN
508
- : sign * Infinity
509
- : exponent === 0 // denormal
510
- ? sign * 1.401298464324817e-45 * mantissa
511
- : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
512
- }
1161
+ /* istanbul ignore next */
1162
+ exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
1163
+ /* istanbul ignore next */
1164
+ exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
513
1165
 
514
- exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
515
- exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
1166
+ // float: ieee754
1167
+ })(); else (function() {
516
1168
 
517
- })();
1169
+ function writeFloat_ieee754(writeUint, val, buf, pos) {
1170
+ var sign = val < 0 ? 1 : 0;
1171
+ if (sign)
1172
+ val = -val;
1173
+ if (val === 0)
1174
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
1175
+ else if (isNaN(val))
1176
+ writeUint(2143289344, buf, pos);
1177
+ else if (val > 3.4028234663852886e+38) // +-Infinity
1178
+ writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
1179
+ else if (val < 1.1754943508222875e-38) // denormal
1180
+ writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
1181
+ else {
1182
+ var exponent = Math.floor(Math.log(val) / Math.LN2),
1183
+ mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
1184
+ writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
1185
+ }
1186
+ }
518
1187
 
519
- // double: typed array
520
- if (typeof Float64Array !== "undefined") (function() {
1188
+ exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
1189
+ exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
521
1190
 
522
- var f64 = new Float64Array([-0]),
523
- f8b = new Uint8Array(f64.buffer),
524
- le = f8b[7] === 128;
1191
+ function readFloat_ieee754(readUint, buf, pos) {
1192
+ var uint = readUint(buf, pos),
1193
+ sign = (uint >> 31) * 2 + 1,
1194
+ exponent = uint >>> 23 & 255,
1195
+ mantissa = uint & 8388607;
1196
+ return exponent === 255
1197
+ ? mantissa
1198
+ ? NaN
1199
+ : sign * Infinity
1200
+ : exponent === 0 // denormal
1201
+ ? sign * 1.401298464324817e-45 * mantissa
1202
+ : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
1203
+ }
525
1204
 
526
- function writeDouble_f64_cpy(val, buf, pos) {
527
- f64[0] = val;
528
- buf[pos ] = f8b[0];
529
- buf[pos + 1] = f8b[1];
530
- buf[pos + 2] = f8b[2];
531
- buf[pos + 3] = f8b[3];
532
- buf[pos + 4] = f8b[4];
533
- buf[pos + 5] = f8b[5];
534
- buf[pos + 6] = f8b[6];
535
- buf[pos + 7] = f8b[7];
536
- }
1205
+ exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
1206
+ exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
537
1207
 
538
- function writeDouble_f64_rev(val, buf, pos) {
539
- f64[0] = val;
540
- buf[pos ] = f8b[7];
541
- buf[pos + 1] = f8b[6];
542
- buf[pos + 2] = f8b[5];
543
- buf[pos + 3] = f8b[4];
544
- buf[pos + 4] = f8b[3];
545
- buf[pos + 5] = f8b[2];
546
- buf[pos + 6] = f8b[1];
547
- buf[pos + 7] = f8b[0];
548
- }
1208
+ })();
549
1209
 
550
- /* istanbul ignore next */
551
- exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
552
- /* istanbul ignore next */
553
- exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
1210
+ // double: typed array
1211
+ if (typeof Float64Array !== "undefined") (function() {
554
1212
 
555
- function readDouble_f64_cpy(buf, pos) {
556
- f8b[0] = buf[pos ];
557
- f8b[1] = buf[pos + 1];
558
- f8b[2] = buf[pos + 2];
559
- f8b[3] = buf[pos + 3];
560
- f8b[4] = buf[pos + 4];
561
- f8b[5] = buf[pos + 5];
562
- f8b[6] = buf[pos + 6];
563
- f8b[7] = buf[pos + 7];
564
- return f64[0];
565
- }
1213
+ var f64 = new Float64Array([-0]),
1214
+ f8b = new Uint8Array(f64.buffer),
1215
+ le = f8b[7] === 128;
566
1216
 
567
- function readDouble_f64_rev(buf, pos) {
568
- f8b[7] = buf[pos ];
569
- f8b[6] = buf[pos + 1];
570
- f8b[5] = buf[pos + 2];
571
- f8b[4] = buf[pos + 3];
572
- f8b[3] = buf[pos + 4];
573
- f8b[2] = buf[pos + 5];
574
- f8b[1] = buf[pos + 6];
575
- f8b[0] = buf[pos + 7];
576
- return f64[0];
577
- }
1217
+ function writeDouble_f64_cpy(val, buf, pos) {
1218
+ f64[0] = val;
1219
+ buf[pos ] = f8b[0];
1220
+ buf[pos + 1] = f8b[1];
1221
+ buf[pos + 2] = f8b[2];
1222
+ buf[pos + 3] = f8b[3];
1223
+ buf[pos + 4] = f8b[4];
1224
+ buf[pos + 5] = f8b[5];
1225
+ buf[pos + 6] = f8b[6];
1226
+ buf[pos + 7] = f8b[7];
1227
+ }
578
1228
 
579
- /* istanbul ignore next */
580
- exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
581
- /* istanbul ignore next */
582
- exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
1229
+ function writeDouble_f64_rev(val, buf, pos) {
1230
+ f64[0] = val;
1231
+ buf[pos ] = f8b[7];
1232
+ buf[pos + 1] = f8b[6];
1233
+ buf[pos + 2] = f8b[5];
1234
+ buf[pos + 3] = f8b[4];
1235
+ buf[pos + 4] = f8b[3];
1236
+ buf[pos + 5] = f8b[2];
1237
+ buf[pos + 6] = f8b[1];
1238
+ buf[pos + 7] = f8b[0];
1239
+ }
583
1240
 
584
- // double: ieee754
585
- })(); else (function() {
1241
+ /* istanbul ignore next */
1242
+ exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
1243
+ /* istanbul ignore next */
1244
+ exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
586
1245
 
587
- function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
588
- var sign = val < 0 ? 1 : 0;
589
- if (sign)
590
- val = -val;
591
- if (val === 0) {
592
- writeUint(0, buf, pos + off0);
593
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
594
- } else if (isNaN(val)) {
595
- writeUint(0, buf, pos + off0);
596
- writeUint(2146959360, buf, pos + off1);
597
- } else if (val > 1.7976931348623157e+308) { // +-Infinity
598
- writeUint(0, buf, pos + off0);
599
- writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
600
- } else {
601
- var mantissa;
602
- if (val < 2.2250738585072014e-308) { // denormal
603
- mantissa = val / 5e-324;
604
- writeUint(mantissa >>> 0, buf, pos + off0);
605
- writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
606
- } else {
607
- var exponent = Math.floor(Math.log(val) / Math.LN2);
608
- if (exponent === 1024)
609
- exponent = 1023;
610
- mantissa = val * Math.pow(2, -exponent);
611
- writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
612
- writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
613
- }
614
- }
615
- }
1246
+ function readDouble_f64_cpy(buf, pos) {
1247
+ f8b[0] = buf[pos ];
1248
+ f8b[1] = buf[pos + 1];
1249
+ f8b[2] = buf[pos + 2];
1250
+ f8b[3] = buf[pos + 3];
1251
+ f8b[4] = buf[pos + 4];
1252
+ f8b[5] = buf[pos + 5];
1253
+ f8b[6] = buf[pos + 6];
1254
+ f8b[7] = buf[pos + 7];
1255
+ return f64[0];
1256
+ }
616
1257
 
617
- exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
618
- exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
1258
+ function readDouble_f64_rev(buf, pos) {
1259
+ f8b[7] = buf[pos ];
1260
+ f8b[6] = buf[pos + 1];
1261
+ f8b[5] = buf[pos + 2];
1262
+ f8b[4] = buf[pos + 3];
1263
+ f8b[3] = buf[pos + 4];
1264
+ f8b[2] = buf[pos + 5];
1265
+ f8b[1] = buf[pos + 6];
1266
+ f8b[0] = buf[pos + 7];
1267
+ return f64[0];
1268
+ }
619
1269
 
620
- function readDouble_ieee754(readUint, off0, off1, buf, pos) {
621
- var lo = readUint(buf, pos + off0),
622
- hi = readUint(buf, pos + off1);
623
- var sign = (hi >> 31) * 2 + 1,
624
- exponent = hi >>> 20 & 2047,
625
- mantissa = 4294967296 * (hi & 1048575) + lo;
626
- return exponent === 2047
627
- ? mantissa
628
- ? NaN
629
- : sign * Infinity
630
- : exponent === 0 // denormal
631
- ? sign * 5e-324 * mantissa
632
- : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
633
- }
1270
+ /* istanbul ignore next */
1271
+ exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
1272
+ /* istanbul ignore next */
1273
+ exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
634
1274
 
635
- exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
636
- exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
1275
+ // double: ieee754
1276
+ })(); else (function() {
637
1277
 
638
- })();
1278
+ function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
1279
+ var sign = val < 0 ? 1 : 0;
1280
+ if (sign)
1281
+ val = -val;
1282
+ if (val === 0) {
1283
+ writeUint(0, buf, pos + off0);
1284
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
1285
+ } else if (isNaN(val)) {
1286
+ writeUint(0, buf, pos + off0);
1287
+ writeUint(2146959360, buf, pos + off1);
1288
+ } else if (val > 1.7976931348623157e+308) { // +-Infinity
1289
+ writeUint(0, buf, pos + off0);
1290
+ writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
1291
+ } else {
1292
+ var mantissa;
1293
+ if (val < 2.2250738585072014e-308) { // denormal
1294
+ mantissa = val / 5e-324;
1295
+ writeUint(mantissa >>> 0, buf, pos + off0);
1296
+ writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
1297
+ } else {
1298
+ var exponent = Math.floor(Math.log(val) / Math.LN2);
1299
+ if (exponent === 1024)
1300
+ exponent = 1023;
1301
+ mantissa = val * Math.pow(2, -exponent);
1302
+ writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
1303
+ writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
1304
+ }
1305
+ }
1306
+ }
639
1307
 
640
- return exports;
641
- }
1308
+ exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
1309
+ exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
642
1310
 
643
- // uint helpers
1311
+ function readDouble_ieee754(readUint, off0, off1, buf, pos) {
1312
+ var lo = readUint(buf, pos + off0),
1313
+ hi = readUint(buf, pos + off1);
1314
+ var sign = (hi >> 31) * 2 + 1,
1315
+ exponent = hi >>> 20 & 2047,
1316
+ mantissa = 4294967296 * (hi & 1048575) + lo;
1317
+ return exponent === 2047
1318
+ ? mantissa
1319
+ ? NaN
1320
+ : sign * Infinity
1321
+ : exponent === 0 // denormal
1322
+ ? sign * 5e-324 * mantissa
1323
+ : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
1324
+ }
644
1325
 
645
- function writeUintLE(val, buf, pos) {
646
- buf[pos ] = val & 255;
647
- buf[pos + 1] = val >>> 8 & 255;
648
- buf[pos + 2] = val >>> 16 & 255;
649
- buf[pos + 3] = val >>> 24;
650
- }
1326
+ exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
1327
+ exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
651
1328
 
652
- function writeUintBE(val, buf, pos) {
653
- buf[pos ] = val >>> 24;
654
- buf[pos + 1] = val >>> 16 & 255;
655
- buf[pos + 2] = val >>> 8 & 255;
656
- buf[pos + 3] = val & 255;
657
- }
1329
+ })();
658
1330
 
659
- function readUintLE(buf, pos) {
660
- return (buf[pos ]
661
- | buf[pos + 1] << 8
662
- | buf[pos + 2] << 16
663
- | buf[pos + 3] << 24) >>> 0;
664
- }
1331
+ return exports;
1332
+ }
665
1333
 
666
- function readUintBE(buf, pos) {
667
- return (buf[pos ] << 24
668
- | buf[pos + 1] << 16
669
- | buf[pos + 2] << 8
670
- | buf[pos + 3]) >>> 0;
671
- }
672
- return float;
673
- }
674
-
675
- var inquire_1;
676
- var hasRequiredInquire;
677
-
678
- function requireInquire () {
679
- if (hasRequiredInquire) return inquire_1;
680
- hasRequiredInquire = 1;
681
- inquire_1 = inquire;
1334
+ // uint helpers
682
1335
 
683
- /**
684
- * Requires a module only if available.
685
- * @memberof util
686
- * @param {string} moduleName Module to require
687
- * @returns {?Object} Required module if available and not empty, otherwise `null`
688
- */
689
- function inquire(moduleName) {
690
- try {
691
- var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
692
- if (mod && (mod.length || Object.keys(mod).length))
693
- return mod;
694
- } catch (e) {} // eslint-disable-line no-empty
695
- return null;
696
- }
697
- return inquire_1;
698
- }
699
-
700
- var utf8$2 = {};
701
-
702
- var hasRequiredUtf8;
703
-
704
- function requireUtf8 () {
705
- if (hasRequiredUtf8) return utf8$2;
706
- hasRequiredUtf8 = 1;
707
- (function (exports) {
1336
+ function writeUintLE(val, buf, pos) {
1337
+ buf[pos ] = val & 255;
1338
+ buf[pos + 1] = val >>> 8 & 255;
1339
+ buf[pos + 2] = val >>> 16 & 255;
1340
+ buf[pos + 3] = val >>> 24;
1341
+ }
708
1342
 
709
- /**
710
- * A minimal UTF8 implementation for number arrays.
711
- * @memberof util
712
- * @namespace
713
- */
714
- var utf8 = exports;
1343
+ function writeUintBE(val, buf, pos) {
1344
+ buf[pos ] = val >>> 24;
1345
+ buf[pos + 1] = val >>> 16 & 255;
1346
+ buf[pos + 2] = val >>> 8 & 255;
1347
+ buf[pos + 3] = val & 255;
1348
+ }
715
1349
 
716
- /**
717
- * Calculates the UTF8 byte length of a string.
718
- * @param {string} string String
719
- * @returns {number} Byte length
720
- */
721
- utf8.length = function utf8_length(string) {
722
- var len = 0,
723
- c = 0;
724
- for (var i = 0; i < string.length; ++i) {
725
- c = string.charCodeAt(i);
726
- if (c < 128)
727
- len += 1;
728
- else if (c < 2048)
729
- len += 2;
730
- else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
731
- ++i;
732
- len += 4;
733
- } else
734
- len += 3;
735
- }
736
- return len;
737
- };
1350
+ function readUintLE(buf, pos) {
1351
+ return (buf[pos ]
1352
+ | buf[pos + 1] << 8
1353
+ | buf[pos + 2] << 16
1354
+ | buf[pos + 3] << 24) >>> 0;
1355
+ }
738
1356
 
739
- /**
740
- * Reads UTF8 bytes as a string.
741
- * @param {Uint8Array} buffer Source buffer
742
- * @param {number} start Source start
743
- * @param {number} end Source end
744
- * @returns {string} String read
745
- */
746
- utf8.read = function utf8_read(buffer, start, end) {
747
- var len = end - start;
748
- if (len < 1)
749
- return "";
750
- var parts = null,
751
- chunk = [],
752
- i = 0, // char offset
753
- t; // temporary
754
- while (start < end) {
755
- t = buffer[start++];
756
- if (t < 128)
757
- chunk[i++] = t;
758
- else if (t > 191 && t < 224)
759
- chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
760
- else if (t > 239 && t < 365) {
761
- t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
762
- chunk[i++] = 0xD800 + (t >> 10);
763
- chunk[i++] = 0xDC00 + (t & 1023);
764
- } else
765
- chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
766
- if (i > 8191) {
767
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
768
- i = 0;
769
- }
770
- }
771
- if (parts) {
772
- if (i)
773
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
774
- return parts.join("");
775
- }
776
- return String.fromCharCode.apply(String, chunk.slice(0, i));
777
- };
1357
+ function readUintBE(buf, pos) {
1358
+ return (buf[pos ] << 24
1359
+ | buf[pos + 1] << 16
1360
+ | buf[pos + 2] << 8
1361
+ | buf[pos + 3]) >>> 0;
1362
+ }
1363
+
1364
+ var inquire_1 = inquire$1;
778
1365
 
779
- /**
780
- * Writes a string as UTF8 bytes.
781
- * @param {string} string Source string
782
- * @param {Uint8Array} buffer Destination buffer
783
- * @param {number} offset Destination offset
784
- * @returns {number} Bytes written
785
- */
786
- utf8.write = function utf8_write(string, buffer, offset) {
787
- var start = offset,
788
- c1, // character 1
789
- c2; // character 2
790
- for (var i = 0; i < string.length; ++i) {
791
- c1 = string.charCodeAt(i);
792
- if (c1 < 128) {
793
- buffer[offset++] = c1;
794
- } else if (c1 < 2048) {
795
- buffer[offset++] = c1 >> 6 | 192;
796
- buffer[offset++] = c1 & 63 | 128;
797
- } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
798
- c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
799
- ++i;
800
- buffer[offset++] = c1 >> 18 | 240;
801
- buffer[offset++] = c1 >> 12 & 63 | 128;
802
- buffer[offset++] = c1 >> 6 & 63 | 128;
803
- buffer[offset++] = c1 & 63 | 128;
804
- } else {
805
- buffer[offset++] = c1 >> 12 | 224;
806
- buffer[offset++] = c1 >> 6 & 63 | 128;
807
- buffer[offset++] = c1 & 63 | 128;
808
- }
809
- }
810
- return offset - start;
811
- };
812
- } (utf8$2));
813
- return utf8$2;
1366
+ /**
1367
+ * Requires a module only if available.
1368
+ * @memberof util
1369
+ * @param {string} moduleName Module to require
1370
+ * @returns {?Object} Required module if available and not empty, otherwise `null`
1371
+ */
1372
+ function inquire$1(moduleName) {
1373
+ try {
1374
+ var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
1375
+ if (mod && (mod.length || Object.keys(mod).length))
1376
+ return mod;
1377
+ } catch (e) {} // eslint-disable-line no-empty
1378
+ return null;
814
1379
  }
815
1380
 
816
- var pool_1;
817
- var hasRequiredPool;
1381
+ var utf8$2 = {};
818
1382
 
819
- function requirePool () {
820
- if (hasRequiredPool) return pool_1;
821
- hasRequiredPool = 1;
822
- pool_1 = pool;
1383
+ (function (exports) {
823
1384
 
824
1385
  /**
825
- * An allocator as used by {@link util.pool}.
826
- * @typedef PoolAllocator
827
- * @type {function}
828
- * @param {number} size Buffer size
829
- * @returns {Uint8Array} Buffer
1386
+ * A minimal UTF8 implementation for number arrays.
1387
+ * @memberof util
1388
+ * @namespace
830
1389
  */
1390
+ var utf8 = exports;
831
1391
 
832
1392
  /**
833
- * A slicer as used by {@link util.pool}.
834
- * @typedef PoolSlicer
835
- * @type {function}
836
- * @param {number} start Start offset
837
- * @param {number} end End offset
838
- * @returns {Uint8Array} Buffer slice
839
- * @this {Uint8Array}
1393
+ * Calculates the UTF8 byte length of a string.
1394
+ * @param {string} string String
1395
+ * @returns {number} Byte length
840
1396
  */
1397
+ utf8.length = function utf8_length(string) {
1398
+ var len = 0,
1399
+ c = 0;
1400
+ for (var i = 0; i < string.length; ++i) {
1401
+ c = string.charCodeAt(i);
1402
+ if (c < 128)
1403
+ len += 1;
1404
+ else if (c < 2048)
1405
+ len += 2;
1406
+ else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
1407
+ ++i;
1408
+ len += 4;
1409
+ } else
1410
+ len += 3;
1411
+ }
1412
+ return len;
1413
+ };
841
1414
 
842
1415
  /**
843
- * A general purpose buffer pool.
844
- * @memberof util
845
- * @function
846
- * @param {PoolAllocator} alloc Allocator
847
- * @param {PoolSlicer} slice Slicer
848
- * @param {number} [size=8192] Slab size
849
- * @returns {PoolAllocator} Pooled allocator
1416
+ * Reads UTF8 bytes as a string.
1417
+ * @param {Uint8Array} buffer Source buffer
1418
+ * @param {number} start Source start
1419
+ * @param {number} end Source end
1420
+ * @returns {string} String read
850
1421
  */
851
- function pool(alloc, slice, size) {
852
- var SIZE = size || 8192;
853
- var MAX = SIZE >>> 1;
854
- var slab = null;
855
- var offset = SIZE;
856
- return function pool_alloc(size) {
857
- if (size < 1 || size > MAX)
858
- return alloc(size);
859
- if (offset + size > SIZE) {
860
- slab = alloc(SIZE);
861
- offset = 0;
1422
+ utf8.read = function utf8_read(buffer, start, end) {
1423
+ var len = end - start;
1424
+ if (len < 1)
1425
+ return "";
1426
+ var parts = null,
1427
+ chunk = [],
1428
+ i = 0, // char offset
1429
+ t; // temporary
1430
+ while (start < end) {
1431
+ t = buffer[start++];
1432
+ if (t < 128)
1433
+ chunk[i++] = t;
1434
+ else if (t > 191 && t < 224)
1435
+ chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
1436
+ else if (t > 239 && t < 365) {
1437
+ t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
1438
+ chunk[i++] = 0xD800 + (t >> 10);
1439
+ chunk[i++] = 0xDC00 + (t & 1023);
1440
+ } else
1441
+ chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
1442
+ if (i > 8191) {
1443
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
1444
+ i = 0;
862
1445
  }
863
- var buf = slice.call(slab, offset, offset += size);
864
- if (offset & 7) // align to 32 bit
865
- offset = (offset | 7) + 1;
866
- return buf;
867
- };
868
- }
869
- return pool_1;
1446
+ }
1447
+ if (parts) {
1448
+ if (i)
1449
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
1450
+ return parts.join("");
1451
+ }
1452
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
1453
+ };
1454
+
1455
+ /**
1456
+ * Writes a string as UTF8 bytes.
1457
+ * @param {string} string Source string
1458
+ * @param {Uint8Array} buffer Destination buffer
1459
+ * @param {number} offset Destination offset
1460
+ * @returns {number} Bytes written
1461
+ */
1462
+ utf8.write = function utf8_write(string, buffer, offset) {
1463
+ var start = offset,
1464
+ c1, // character 1
1465
+ c2; // character 2
1466
+ for (var i = 0; i < string.length; ++i) {
1467
+ c1 = string.charCodeAt(i);
1468
+ if (c1 < 128) {
1469
+ buffer[offset++] = c1;
1470
+ } else if (c1 < 2048) {
1471
+ buffer[offset++] = c1 >> 6 | 192;
1472
+ buffer[offset++] = c1 & 63 | 128;
1473
+ } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
1474
+ c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
1475
+ ++i;
1476
+ buffer[offset++] = c1 >> 18 | 240;
1477
+ buffer[offset++] = c1 >> 12 & 63 | 128;
1478
+ buffer[offset++] = c1 >> 6 & 63 | 128;
1479
+ buffer[offset++] = c1 & 63 | 128;
1480
+ } else {
1481
+ buffer[offset++] = c1 >> 12 | 224;
1482
+ buffer[offset++] = c1 >> 6 & 63 | 128;
1483
+ buffer[offset++] = c1 & 63 | 128;
1484
+ }
1485
+ }
1486
+ return offset - start;
1487
+ };
1488
+ } (utf8$2));
1489
+
1490
+ var pool_1 = pool;
1491
+
1492
+ /**
1493
+ * An allocator as used by {@link util.pool}.
1494
+ * @typedef PoolAllocator
1495
+ * @type {function}
1496
+ * @param {number} size Buffer size
1497
+ * @returns {Uint8Array} Buffer
1498
+ */
1499
+
1500
+ /**
1501
+ * A slicer as used by {@link util.pool}.
1502
+ * @typedef PoolSlicer
1503
+ * @type {function}
1504
+ * @param {number} start Start offset
1505
+ * @param {number} end End offset
1506
+ * @returns {Uint8Array} Buffer slice
1507
+ * @this {Uint8Array}
1508
+ */
1509
+
1510
+ /**
1511
+ * A general purpose buffer pool.
1512
+ * @memberof util
1513
+ * @function
1514
+ * @param {PoolAllocator} alloc Allocator
1515
+ * @param {PoolSlicer} slice Slicer
1516
+ * @param {number} [size=8192] Slab size
1517
+ * @returns {PoolAllocator} Pooled allocator
1518
+ */
1519
+ function pool(alloc, slice, size) {
1520
+ var SIZE = size || 8192;
1521
+ var MAX = SIZE >>> 1;
1522
+ var slab = null;
1523
+ var offset = SIZE;
1524
+ return function pool_alloc(size) {
1525
+ if (size < 1 || size > MAX)
1526
+ return alloc(size);
1527
+ if (offset + size > SIZE) {
1528
+ slab = alloc(SIZE);
1529
+ offset = 0;
1530
+ }
1531
+ var buf = slice.call(slab, offset, offset += size);
1532
+ if (offset & 7) // align to 32 bit
1533
+ offset = (offset | 7) + 1;
1534
+ return buf;
1535
+ };
870
1536
  }
871
1537
 
872
1538
  var longbits;
@@ -1086,25 +1752,25 @@ function requireMinimal () {
1086
1752
  var util = exports;
1087
1753
 
1088
1754
  // used to return a Promise where callback is omitted
1089
- util.asPromise = requireAspromise();
1755
+ util.asPromise = aspromise;
1090
1756
 
1091
1757
  // converts to / from base64 encoded strings
1092
- util.base64 = requireBase64();
1758
+ util.base64 = base64$1;
1093
1759
 
1094
1760
  // base class of rpc.Service
1095
- util.EventEmitter = requireEventemitter();
1761
+ util.EventEmitter = eventemitter;
1096
1762
 
1097
1763
  // float handling accross browsers
1098
- util.float = requireFloat();
1764
+ util.float = float;
1099
1765
 
1100
1766
  // requires modules optionally and hides the call from bundlers
1101
- util.inquire = requireInquire();
1767
+ util.inquire = inquire_1;
1102
1768
 
1103
1769
  // converts to / from utf8 encoded strings
1104
- util.utf8 = requireUtf8();
1770
+ util.utf8 = utf8$2;
1105
1771
 
1106
1772
  // provides a node-like buffer pool in the browser
1107
- util.pool = requirePool();
1773
+ util.pool = pool_1;
1108
1774
 
1109
1775
  // utility to work with the low and high bits of a 64 bit value
1110
1776
  util.LongBits = requireLongbits();
@@ -2861,8 +3527,8 @@ codegen.verbose = false;
2861
3527
 
2862
3528
  var fetch_1 = fetch;
2863
3529
 
2864
- var asPromise = requireAspromise(),
2865
- inquire = requireInquire();
3530
+ var asPromise = aspromise,
3531
+ inquire = inquire_1;
2866
3532
 
2867
3533
  var fs = inquire("fs");
2868
3534
 
@@ -9249,4 +9915,4 @@ function message(encode, decode) {
9249
9915
  return createCodec('message', CODEC_TYPES.LENGTH_DELIMITED, encode, decode);
9250
9916
  }
9251
9917
 
9252
- export { CODEC_TYPES as C, requireBase64 as a, requireEventemitter as b, requireFloat as c, requireInquire as d, requireUtf8 as e, requirePool as f, commonjsGlobal as g, getAugmentedNamespace as h, createCodec as i, encodeMessage as j, decodeMessage as k, message as m, requireAspromise as r };
9918
+ export { CODEC_TYPES as C, aspromise as a, base64$1 as b, commonjsGlobal as c, debug as d, eventemitter as e, float as f, getAugmentedNamespace as g, getDefaultExportFromCjs as h, inquire_1 as i, createCodec as j, encodeMessage as k, decodeMessage as l, message as m, pool_1 as p, utf8$2 as u };