@xchainjs/xchain-thorchain 0.28.4 → 0.28.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.
- package/lib/index.esm.js +778 -718
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +778 -718
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -4382,783 +4382,838 @@ var indexMinimal = {};
|
|
|
4382
4382
|
|
|
4383
4383
|
var minimal$1 = {};
|
|
4384
4384
|
|
|
4385
|
-
var aspromise
|
|
4385
|
+
var aspromise;
|
|
4386
|
+
var hasRequiredAspromise;
|
|
4387
|
+
|
|
4388
|
+
function requireAspromise () {
|
|
4389
|
+
if (hasRequiredAspromise) return aspromise;
|
|
4390
|
+
hasRequiredAspromise = 1;
|
|
4391
|
+
aspromise = asPromise;
|
|
4386
4392
|
|
|
4387
|
-
/**
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4393
|
+
/**
|
|
4394
|
+
* Callback as used by {@link util.asPromise}.
|
|
4395
|
+
* @typedef asPromiseCallback
|
|
4396
|
+
* @type {function}
|
|
4397
|
+
* @param {Error|null} error Error, if any
|
|
4398
|
+
* @param {...*} params Additional arguments
|
|
4399
|
+
* @returns {undefined}
|
|
4400
|
+
*/
|
|
4395
4401
|
|
|
4396
|
-
/**
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
function asPromise(fn, ctx/*, varargs */) {
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4402
|
+
/**
|
|
4403
|
+
* Returns a promise from a node-style callback function.
|
|
4404
|
+
* @memberof util
|
|
4405
|
+
* @param {asPromiseCallback} fn Function to call
|
|
4406
|
+
* @param {*} ctx Function context
|
|
4407
|
+
* @param {...*} params Function arguments
|
|
4408
|
+
* @returns {Promise<*>} Promisified function
|
|
4409
|
+
*/
|
|
4410
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
4411
|
+
var params = new Array(arguments.length - 1),
|
|
4412
|
+
offset = 0,
|
|
4413
|
+
index = 2,
|
|
4414
|
+
pending = true;
|
|
4415
|
+
while (index < arguments.length)
|
|
4416
|
+
params[offset++] = arguments[index++];
|
|
4417
|
+
return new Promise(function executor(resolve, reject) {
|
|
4418
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
4419
|
+
if (pending) {
|
|
4420
|
+
pending = false;
|
|
4421
|
+
if (err)
|
|
4422
|
+
reject(err);
|
|
4423
|
+
else {
|
|
4424
|
+
var params = new Array(arguments.length - 1),
|
|
4425
|
+
offset = 0;
|
|
4426
|
+
while (offset < params.length)
|
|
4427
|
+
params[offset++] = arguments[offset];
|
|
4428
|
+
resolve.apply(null, params);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
};
|
|
4432
|
+
try {
|
|
4433
|
+
fn.apply(ctx || null, params);
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
if (pending) {
|
|
4436
|
+
pending = false;
|
|
4437
|
+
reject(err);
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
});
|
|
4441
|
+
}
|
|
4442
|
+
return aspromise;
|
|
4435
4443
|
}
|
|
4436
4444
|
|
|
4437
4445
|
var base64$1 = {};
|
|
4438
4446
|
|
|
4439
|
-
|
|
4447
|
+
var hasRequiredBase64;
|
|
4448
|
+
|
|
4449
|
+
function requireBase64 () {
|
|
4450
|
+
if (hasRequiredBase64) return base64$1;
|
|
4451
|
+
hasRequiredBase64 = 1;
|
|
4452
|
+
(function (exports) {
|
|
4440
4453
|
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4454
|
+
/**
|
|
4455
|
+
* A minimal base64 implementation for number arrays.
|
|
4456
|
+
* @memberof util
|
|
4457
|
+
* @namespace
|
|
4458
|
+
*/
|
|
4459
|
+
var base64 = exports;
|
|
4460
|
+
|
|
4461
|
+
/**
|
|
4462
|
+
* Calculates the byte length of a base64 encoded string.
|
|
4463
|
+
* @param {string} string Base64 encoded string
|
|
4464
|
+
* @returns {number} Byte length
|
|
4465
|
+
*/
|
|
4466
|
+
base64.length = function length(string) {
|
|
4467
|
+
var p = string.length;
|
|
4468
|
+
if (!p)
|
|
4469
|
+
return 0;
|
|
4470
|
+
var n = 0;
|
|
4471
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4472
|
+
++n;
|
|
4473
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
4474
|
+
};
|
|
4475
|
+
|
|
4476
|
+
// Base64 encoding table
|
|
4477
|
+
var b64 = new Array(64);
|
|
4478
|
+
|
|
4479
|
+
// Base64 decoding table
|
|
4480
|
+
var s64 = new Array(123);
|
|
4481
|
+
|
|
4482
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
4483
|
+
for (var i = 0; i < 64;)
|
|
4484
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
4485
|
+
|
|
4486
|
+
/**
|
|
4487
|
+
* Encodes a buffer to a base64 encoded string.
|
|
4488
|
+
* @param {Uint8Array} buffer Source buffer
|
|
4489
|
+
* @param {number} start Source start
|
|
4490
|
+
* @param {number} end Source end
|
|
4491
|
+
* @returns {string} Base64 encoded string
|
|
4492
|
+
*/
|
|
4493
|
+
base64.encode = function encode(buffer, start, end) {
|
|
4494
|
+
var parts = null,
|
|
4495
|
+
chunk = [];
|
|
4496
|
+
var i = 0, // output index
|
|
4497
|
+
j = 0, // goto index
|
|
4498
|
+
t; // temporary
|
|
4499
|
+
while (start < end) {
|
|
4500
|
+
var b = buffer[start++];
|
|
4501
|
+
switch (j) {
|
|
4502
|
+
case 0:
|
|
4503
|
+
chunk[i++] = b64[b >> 2];
|
|
4504
|
+
t = (b & 3) << 4;
|
|
4505
|
+
j = 1;
|
|
4506
|
+
break;
|
|
4507
|
+
case 1:
|
|
4508
|
+
chunk[i++] = b64[t | b >> 4];
|
|
4509
|
+
t = (b & 15) << 2;
|
|
4510
|
+
j = 2;
|
|
4511
|
+
break;
|
|
4512
|
+
case 2:
|
|
4513
|
+
chunk[i++] = b64[t | b >> 6];
|
|
4514
|
+
chunk[i++] = b64[b & 63];
|
|
4515
|
+
j = 0;
|
|
4516
|
+
break;
|
|
4517
|
+
}
|
|
4518
|
+
if (i > 8191) {
|
|
4519
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4520
|
+
i = 0;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
if (j) {
|
|
4524
|
+
chunk[i++] = b64[t];
|
|
4525
|
+
chunk[i++] = 61;
|
|
4526
|
+
if (j === 1)
|
|
4527
|
+
chunk[i++] = 61;
|
|
4528
|
+
}
|
|
4529
|
+
if (parts) {
|
|
4530
|
+
if (i)
|
|
4531
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4532
|
+
return parts.join("");
|
|
4533
|
+
}
|
|
4534
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4535
|
+
};
|
|
4536
|
+
|
|
4537
|
+
var invalidEncoding = "invalid encoding";
|
|
4538
|
+
|
|
4539
|
+
/**
|
|
4540
|
+
* Decodes a base64 encoded string to a buffer.
|
|
4541
|
+
* @param {string} string Source string
|
|
4542
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
4543
|
+
* @param {number} offset Destination offset
|
|
4544
|
+
* @returns {number} Number of bytes written
|
|
4545
|
+
* @throws {Error} If encoding is invalid
|
|
4546
|
+
*/
|
|
4547
|
+
base64.decode = function decode(string, buffer, offset) {
|
|
4548
|
+
var start = offset;
|
|
4549
|
+
var j = 0, // goto index
|
|
4550
|
+
t; // temporary
|
|
4551
|
+
for (var i = 0; i < string.length;) {
|
|
4552
|
+
var c = string.charCodeAt(i++);
|
|
4553
|
+
if (c === 61 && j > 1)
|
|
4554
|
+
break;
|
|
4555
|
+
if ((c = s64[c]) === undefined)
|
|
4556
|
+
throw Error(invalidEncoding);
|
|
4557
|
+
switch (j) {
|
|
4558
|
+
case 0:
|
|
4559
|
+
t = c;
|
|
4560
|
+
j = 1;
|
|
4561
|
+
break;
|
|
4562
|
+
case 1:
|
|
4563
|
+
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4564
|
+
t = c;
|
|
4565
|
+
j = 2;
|
|
4566
|
+
break;
|
|
4567
|
+
case 2:
|
|
4568
|
+
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4569
|
+
t = c;
|
|
4570
|
+
j = 3;
|
|
4571
|
+
break;
|
|
4572
|
+
case 3:
|
|
4573
|
+
buffer[offset++] = (t & 3) << 6 | c;
|
|
4574
|
+
j = 0;
|
|
4575
|
+
break;
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
if (j === 1)
|
|
4579
|
+
throw Error(invalidEncoding);
|
|
4580
|
+
return offset - start;
|
|
4581
|
+
};
|
|
4582
|
+
|
|
4583
|
+
/**
|
|
4584
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
4585
|
+
* @param {string} string String to test
|
|
4586
|
+
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
4587
|
+
*/
|
|
4588
|
+
base64.test = function test(string) {
|
|
4589
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
4590
|
+
};
|
|
4591
|
+
} (base64$1));
|
|
4592
|
+
return base64$1;
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4595
|
+
var eventemitter;
|
|
4596
|
+
var hasRequiredEventemitter;
|
|
4597
|
+
|
|
4598
|
+
function requireEventemitter () {
|
|
4599
|
+
if (hasRequiredEventemitter) return eventemitter;
|
|
4600
|
+
hasRequiredEventemitter = 1;
|
|
4601
|
+
eventemitter = EventEmitter;
|
|
4447
4602
|
|
|
4448
4603
|
/**
|
|
4449
|
-
*
|
|
4450
|
-
* @
|
|
4451
|
-
* @
|
|
4604
|
+
* Constructs a new event emitter instance.
|
|
4605
|
+
* @classdesc A minimal event emitter.
|
|
4606
|
+
* @memberof util
|
|
4607
|
+
* @constructor
|
|
4452
4608
|
*/
|
|
4453
|
-
|
|
4454
|
-
var p = string.length;
|
|
4455
|
-
if (!p)
|
|
4456
|
-
return 0;
|
|
4457
|
-
var n = 0;
|
|
4458
|
-
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
4459
|
-
++n;
|
|
4460
|
-
return Math.ceil(string.length * 3) / 4 - n;
|
|
4461
|
-
};
|
|
4462
|
-
|
|
4463
|
-
// Base64 encoding table
|
|
4464
|
-
var b64 = new Array(64);
|
|
4609
|
+
function EventEmitter() {
|
|
4465
4610
|
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4611
|
+
/**
|
|
4612
|
+
* Registered listeners.
|
|
4613
|
+
* @type {Object.<string,*>}
|
|
4614
|
+
* @private
|
|
4615
|
+
*/
|
|
4616
|
+
this._listeners = {};
|
|
4617
|
+
}
|
|
4472
4618
|
|
|
4473
4619
|
/**
|
|
4474
|
-
*
|
|
4475
|
-
* @param {
|
|
4476
|
-
* @param {
|
|
4477
|
-
* @param {
|
|
4478
|
-
* @returns {
|
|
4620
|
+
* Registers an event listener.
|
|
4621
|
+
* @param {string} evt Event name
|
|
4622
|
+
* @param {function} fn Listener
|
|
4623
|
+
* @param {*} [ctx] Listener context
|
|
4624
|
+
* @returns {util.EventEmitter} `this`
|
|
4479
4625
|
*/
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
while (start < end) {
|
|
4487
|
-
var b = buffer[start++];
|
|
4488
|
-
switch (j) {
|
|
4489
|
-
case 0:
|
|
4490
|
-
chunk[i++] = b64[b >> 2];
|
|
4491
|
-
t = (b & 3) << 4;
|
|
4492
|
-
j = 1;
|
|
4493
|
-
break;
|
|
4494
|
-
case 1:
|
|
4495
|
-
chunk[i++] = b64[t | b >> 4];
|
|
4496
|
-
t = (b & 15) << 2;
|
|
4497
|
-
j = 2;
|
|
4498
|
-
break;
|
|
4499
|
-
case 2:
|
|
4500
|
-
chunk[i++] = b64[t | b >> 6];
|
|
4501
|
-
chunk[i++] = b64[b & 63];
|
|
4502
|
-
j = 0;
|
|
4503
|
-
break;
|
|
4504
|
-
}
|
|
4505
|
-
if (i > 8191) {
|
|
4506
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
4507
|
-
i = 0;
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
if (j) {
|
|
4511
|
-
chunk[i++] = b64[t];
|
|
4512
|
-
chunk[i++] = 61;
|
|
4513
|
-
if (j === 1)
|
|
4514
|
-
chunk[i++] = 61;
|
|
4515
|
-
}
|
|
4516
|
-
if (parts) {
|
|
4517
|
-
if (i)
|
|
4518
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
4519
|
-
return parts.join("");
|
|
4520
|
-
}
|
|
4521
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
4626
|
+
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4627
|
+
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
4628
|
+
fn : fn,
|
|
4629
|
+
ctx : ctx || this
|
|
4630
|
+
});
|
|
4631
|
+
return this;
|
|
4522
4632
|
};
|
|
4523
4633
|
|
|
4524
|
-
var invalidEncoding = "invalid encoding";
|
|
4525
|
-
|
|
4526
4634
|
/**
|
|
4527
|
-
*
|
|
4528
|
-
* @param {string}
|
|
4529
|
-
* @param {
|
|
4530
|
-
* @
|
|
4531
|
-
* @returns {number} Number of bytes written
|
|
4532
|
-
* @throws {Error} If encoding is invalid
|
|
4635
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
4636
|
+
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
4637
|
+
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
4638
|
+
* @returns {util.EventEmitter} `this`
|
|
4533
4639
|
*/
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
j = 1;
|
|
4548
|
-
break;
|
|
4549
|
-
case 1:
|
|
4550
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
4551
|
-
t = c;
|
|
4552
|
-
j = 2;
|
|
4553
|
-
break;
|
|
4554
|
-
case 2:
|
|
4555
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
4556
|
-
t = c;
|
|
4557
|
-
j = 3;
|
|
4558
|
-
break;
|
|
4559
|
-
case 3:
|
|
4560
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
4561
|
-
j = 0;
|
|
4562
|
-
break;
|
|
4640
|
+
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4641
|
+
if (evt === undefined)
|
|
4642
|
+
this._listeners = {};
|
|
4643
|
+
else {
|
|
4644
|
+
if (fn === undefined)
|
|
4645
|
+
this._listeners[evt] = [];
|
|
4646
|
+
else {
|
|
4647
|
+
var listeners = this._listeners[evt];
|
|
4648
|
+
for (var i = 0; i < listeners.length;)
|
|
4649
|
+
if (listeners[i].fn === fn)
|
|
4650
|
+
listeners.splice(i, 1);
|
|
4651
|
+
else
|
|
4652
|
+
++i;
|
|
4563
4653
|
}
|
|
4564
4654
|
}
|
|
4565
|
-
|
|
4566
|
-
throw Error(invalidEncoding);
|
|
4567
|
-
return offset - start;
|
|
4655
|
+
return this;
|
|
4568
4656
|
};
|
|
4569
4657
|
|
|
4570
4658
|
/**
|
|
4571
|
-
*
|
|
4572
|
-
* @param {string}
|
|
4573
|
-
* @
|
|
4659
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
4660
|
+
* @param {string} evt Event name
|
|
4661
|
+
* @param {...*} args Arguments
|
|
4662
|
+
* @returns {util.EventEmitter} `this`
|
|
4574
4663
|
*/
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4664
|
+
EventEmitter.prototype.emit = function emit(evt) {
|
|
4665
|
+
var listeners = this._listeners[evt];
|
|
4666
|
+
if (listeners) {
|
|
4667
|
+
var args = [],
|
|
4668
|
+
i = 1;
|
|
4669
|
+
for (; i < arguments.length;)
|
|
4670
|
+
args.push(arguments[i++]);
|
|
4671
|
+
for (i = 0; i < listeners.length;)
|
|
4672
|
+
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
4673
|
+
}
|
|
4674
|
+
return this;
|
|
4675
|
+
};
|
|
4676
|
+
return eventemitter;
|
|
4677
|
+
}
|
|
4579
4678
|
|
|
4580
|
-
var
|
|
4581
|
-
|
|
4582
|
-
/**
|
|
4583
|
-
* Constructs a new event emitter instance.
|
|
4584
|
-
* @classdesc A minimal event emitter.
|
|
4585
|
-
* @memberof util
|
|
4586
|
-
* @constructor
|
|
4587
|
-
*/
|
|
4588
|
-
function EventEmitter() {
|
|
4589
|
-
|
|
4590
|
-
/**
|
|
4591
|
-
* Registered listeners.
|
|
4592
|
-
* @type {Object.<string,*>}
|
|
4593
|
-
* @private
|
|
4594
|
-
*/
|
|
4595
|
-
this._listeners = {};
|
|
4596
|
-
}
|
|
4597
|
-
|
|
4598
|
-
/**
|
|
4599
|
-
* Registers an event listener.
|
|
4600
|
-
* @param {string} evt Event name
|
|
4601
|
-
* @param {function} fn Listener
|
|
4602
|
-
* @param {*} [ctx] Listener context
|
|
4603
|
-
* @returns {util.EventEmitter} `this`
|
|
4604
|
-
*/
|
|
4605
|
-
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
4606
|
-
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
4607
|
-
fn : fn,
|
|
4608
|
-
ctx : ctx || this
|
|
4609
|
-
});
|
|
4610
|
-
return this;
|
|
4611
|
-
};
|
|
4612
|
-
|
|
4613
|
-
/**
|
|
4614
|
-
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
4615
|
-
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
4616
|
-
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
4617
|
-
* @returns {util.EventEmitter} `this`
|
|
4618
|
-
*/
|
|
4619
|
-
EventEmitter.prototype.off = function off(evt, fn) {
|
|
4620
|
-
if (evt === undefined)
|
|
4621
|
-
this._listeners = {};
|
|
4622
|
-
else {
|
|
4623
|
-
if (fn === undefined)
|
|
4624
|
-
this._listeners[evt] = [];
|
|
4625
|
-
else {
|
|
4626
|
-
var listeners = this._listeners[evt];
|
|
4627
|
-
for (var i = 0; i < listeners.length;)
|
|
4628
|
-
if (listeners[i].fn === fn)
|
|
4629
|
-
listeners.splice(i, 1);
|
|
4630
|
-
else
|
|
4631
|
-
++i;
|
|
4632
|
-
}
|
|
4633
|
-
}
|
|
4634
|
-
return this;
|
|
4635
|
-
};
|
|
4636
|
-
|
|
4637
|
-
/**
|
|
4638
|
-
* Emits an event by calling its listeners with the specified arguments.
|
|
4639
|
-
* @param {string} evt Event name
|
|
4640
|
-
* @param {...*} args Arguments
|
|
4641
|
-
* @returns {util.EventEmitter} `this`
|
|
4642
|
-
*/
|
|
4643
|
-
EventEmitter.prototype.emit = function emit(evt) {
|
|
4644
|
-
var listeners = this._listeners[evt];
|
|
4645
|
-
if (listeners) {
|
|
4646
|
-
var args = [],
|
|
4647
|
-
i = 1;
|
|
4648
|
-
for (; i < arguments.length;)
|
|
4649
|
-
args.push(arguments[i++]);
|
|
4650
|
-
for (i = 0; i < listeners.length;)
|
|
4651
|
-
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
4652
|
-
}
|
|
4653
|
-
return this;
|
|
4654
|
-
};
|
|
4679
|
+
var float;
|
|
4680
|
+
var hasRequiredFloat;
|
|
4655
4681
|
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
* Reads / writes floats / doubles from / to buffers.
|
|
4660
|
-
* @name util.float
|
|
4661
|
-
* @namespace
|
|
4662
|
-
*/
|
|
4682
|
+
function requireFloat () {
|
|
4683
|
+
if (hasRequiredFloat) return float;
|
|
4684
|
+
hasRequiredFloat = 1;
|
|
4663
4685
|
|
|
4664
|
-
|
|
4665
|
-
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
4666
|
-
* @name util.float.writeFloatLE
|
|
4667
|
-
* @function
|
|
4668
|
-
* @param {number} val Value to write
|
|
4669
|
-
* @param {Uint8Array} buf Target buffer
|
|
4670
|
-
* @param {number} pos Target buffer offset
|
|
4671
|
-
* @returns {undefined}
|
|
4672
|
-
*/
|
|
4686
|
+
float = factory(factory);
|
|
4673
4687
|
|
|
4674
|
-
/**
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
* @param {Uint8Array} buf Target buffer
|
|
4680
|
-
* @param {number} pos Target buffer offset
|
|
4681
|
-
* @returns {undefined}
|
|
4682
|
-
*/
|
|
4683
|
-
|
|
4684
|
-
/**
|
|
4685
|
-
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
4686
|
-
* @name util.float.readFloatLE
|
|
4687
|
-
* @function
|
|
4688
|
-
* @param {Uint8Array} buf Source buffer
|
|
4689
|
-
* @param {number} pos Source buffer offset
|
|
4690
|
-
* @returns {number} Value read
|
|
4691
|
-
*/
|
|
4692
|
-
|
|
4693
|
-
/**
|
|
4694
|
-
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
4695
|
-
* @name util.float.readFloatBE
|
|
4696
|
-
* @function
|
|
4697
|
-
* @param {Uint8Array} buf Source buffer
|
|
4698
|
-
* @param {number} pos Source buffer offset
|
|
4699
|
-
* @returns {number} Value read
|
|
4700
|
-
*/
|
|
4701
|
-
|
|
4702
|
-
/**
|
|
4703
|
-
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
4704
|
-
* @name util.float.writeDoubleLE
|
|
4705
|
-
* @function
|
|
4706
|
-
* @param {number} val Value to write
|
|
4707
|
-
* @param {Uint8Array} buf Target buffer
|
|
4708
|
-
* @param {number} pos Target buffer offset
|
|
4709
|
-
* @returns {undefined}
|
|
4710
|
-
*/
|
|
4711
|
-
|
|
4712
|
-
/**
|
|
4713
|
-
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
4714
|
-
* @name util.float.writeDoubleBE
|
|
4715
|
-
* @function
|
|
4716
|
-
* @param {number} val Value to write
|
|
4717
|
-
* @param {Uint8Array} buf Target buffer
|
|
4718
|
-
* @param {number} pos Target buffer offset
|
|
4719
|
-
* @returns {undefined}
|
|
4720
|
-
*/
|
|
4721
|
-
|
|
4722
|
-
/**
|
|
4723
|
-
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
4724
|
-
* @name util.float.readDoubleLE
|
|
4725
|
-
* @function
|
|
4726
|
-
* @param {Uint8Array} buf Source buffer
|
|
4727
|
-
* @param {number} pos Source buffer offset
|
|
4728
|
-
* @returns {number} Value read
|
|
4729
|
-
*/
|
|
4688
|
+
/**
|
|
4689
|
+
* Reads / writes floats / doubles from / to buffers.
|
|
4690
|
+
* @name util.float
|
|
4691
|
+
* @namespace
|
|
4692
|
+
*/
|
|
4730
4693
|
|
|
4731
|
-
/**
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4694
|
+
/**
|
|
4695
|
+
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
4696
|
+
* @name util.float.writeFloatLE
|
|
4697
|
+
* @function
|
|
4698
|
+
* @param {number} val Value to write
|
|
4699
|
+
* @param {Uint8Array} buf Target buffer
|
|
4700
|
+
* @param {number} pos Target buffer offset
|
|
4701
|
+
* @returns {undefined}
|
|
4702
|
+
*/
|
|
4739
4703
|
|
|
4740
|
-
|
|
4741
|
-
|
|
4704
|
+
/**
|
|
4705
|
+
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
4706
|
+
* @name util.float.writeFloatBE
|
|
4707
|
+
* @function
|
|
4708
|
+
* @param {number} val Value to write
|
|
4709
|
+
* @param {Uint8Array} buf Target buffer
|
|
4710
|
+
* @param {number} pos Target buffer offset
|
|
4711
|
+
* @returns {undefined}
|
|
4712
|
+
*/
|
|
4742
4713
|
|
|
4743
|
-
|
|
4744
|
-
|
|
4714
|
+
/**
|
|
4715
|
+
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
4716
|
+
* @name util.float.readFloatLE
|
|
4717
|
+
* @function
|
|
4718
|
+
* @param {Uint8Array} buf Source buffer
|
|
4719
|
+
* @param {number} pos Source buffer offset
|
|
4720
|
+
* @returns {number} Value read
|
|
4721
|
+
*/
|
|
4745
4722
|
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4723
|
+
/**
|
|
4724
|
+
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
4725
|
+
* @name util.float.readFloatBE
|
|
4726
|
+
* @function
|
|
4727
|
+
* @param {Uint8Array} buf Source buffer
|
|
4728
|
+
* @param {number} pos Source buffer offset
|
|
4729
|
+
* @returns {number} Value read
|
|
4730
|
+
*/
|
|
4749
4731
|
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4732
|
+
/**
|
|
4733
|
+
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
4734
|
+
* @name util.float.writeDoubleLE
|
|
4735
|
+
* @function
|
|
4736
|
+
* @param {number} val Value to write
|
|
4737
|
+
* @param {Uint8Array} buf Target buffer
|
|
4738
|
+
* @param {number} pos Target buffer offset
|
|
4739
|
+
* @returns {undefined}
|
|
4740
|
+
*/
|
|
4757
4741
|
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4742
|
+
/**
|
|
4743
|
+
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
4744
|
+
* @name util.float.writeDoubleBE
|
|
4745
|
+
* @function
|
|
4746
|
+
* @param {number} val Value to write
|
|
4747
|
+
* @param {Uint8Array} buf Target buffer
|
|
4748
|
+
* @param {number} pos Target buffer offset
|
|
4749
|
+
* @returns {undefined}
|
|
4750
|
+
*/
|
|
4765
4751
|
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
f8b[2] = buf[pos + 2];
|
|
4775
|
-
f8b[3] = buf[pos + 3];
|
|
4776
|
-
return f32[0];
|
|
4777
|
-
}
|
|
4752
|
+
/**
|
|
4753
|
+
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
4754
|
+
* @name util.float.readDoubleLE
|
|
4755
|
+
* @function
|
|
4756
|
+
* @param {Uint8Array} buf Source buffer
|
|
4757
|
+
* @param {number} pos Source buffer offset
|
|
4758
|
+
* @returns {number} Value read
|
|
4759
|
+
*/
|
|
4778
4760
|
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4761
|
+
/**
|
|
4762
|
+
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
4763
|
+
* @name util.float.readDoubleBE
|
|
4764
|
+
* @function
|
|
4765
|
+
* @param {Uint8Array} buf Source buffer
|
|
4766
|
+
* @param {number} pos Source buffer offset
|
|
4767
|
+
* @returns {number} Value read
|
|
4768
|
+
*/
|
|
4786
4769
|
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
/* istanbul ignore next */
|
|
4790
|
-
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
4791
|
-
|
|
4792
|
-
// float: ieee754
|
|
4793
|
-
})(); else (function() {
|
|
4794
|
-
|
|
4795
|
-
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
4796
|
-
var sign = val < 0 ? 1 : 0;
|
|
4797
|
-
if (sign)
|
|
4798
|
-
val = -val;
|
|
4799
|
-
if (val === 0)
|
|
4800
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
4801
|
-
else if (isNaN(val))
|
|
4802
|
-
writeUint(2143289344, buf, pos);
|
|
4803
|
-
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
4804
|
-
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
4805
|
-
else if (val < 1.1754943508222875e-38) // denormal
|
|
4806
|
-
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
4807
|
-
else {
|
|
4808
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
4809
|
-
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
4810
|
-
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
4811
|
-
}
|
|
4812
|
-
}
|
|
4770
|
+
// Factory function for the purpose of node-based testing in modified global environments
|
|
4771
|
+
function factory(exports) {
|
|
4813
4772
|
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
function readFloat_ieee754(readUint, buf, pos) {
|
|
4818
|
-
var uint = readUint(buf, pos),
|
|
4819
|
-
sign = (uint >> 31) * 2 + 1,
|
|
4820
|
-
exponent = uint >>> 23 & 255,
|
|
4821
|
-
mantissa = uint & 8388607;
|
|
4822
|
-
return exponent === 255
|
|
4823
|
-
? mantissa
|
|
4824
|
-
? NaN
|
|
4825
|
-
: sign * Infinity
|
|
4826
|
-
: exponent === 0 // denormal
|
|
4827
|
-
? sign * 1.401298464324817e-45 * mantissa
|
|
4828
|
-
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
4829
|
-
}
|
|
4773
|
+
// float: typed array
|
|
4774
|
+
if (typeof Float32Array !== "undefined") (function() {
|
|
4830
4775
|
|
|
4831
|
-
|
|
4832
|
-
|
|
4776
|
+
var f32 = new Float32Array([ -0 ]),
|
|
4777
|
+
f8b = new Uint8Array(f32.buffer),
|
|
4778
|
+
le = f8b[3] === 128;
|
|
4833
4779
|
|
|
4834
|
-
|
|
4780
|
+
function writeFloat_f32_cpy(val, buf, pos) {
|
|
4781
|
+
f32[0] = val;
|
|
4782
|
+
buf[pos ] = f8b[0];
|
|
4783
|
+
buf[pos + 1] = f8b[1];
|
|
4784
|
+
buf[pos + 2] = f8b[2];
|
|
4785
|
+
buf[pos + 3] = f8b[3];
|
|
4786
|
+
}
|
|
4835
4787
|
|
|
4836
|
-
|
|
4837
|
-
|
|
4788
|
+
function writeFloat_f32_rev(val, buf, pos) {
|
|
4789
|
+
f32[0] = val;
|
|
4790
|
+
buf[pos ] = f8b[3];
|
|
4791
|
+
buf[pos + 1] = f8b[2];
|
|
4792
|
+
buf[pos + 2] = f8b[1];
|
|
4793
|
+
buf[pos + 3] = f8b[0];
|
|
4794
|
+
}
|
|
4838
4795
|
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4796
|
+
/* istanbul ignore next */
|
|
4797
|
+
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
|
|
4798
|
+
/* istanbul ignore next */
|
|
4799
|
+
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
|
|
4800
|
+
|
|
4801
|
+
function readFloat_f32_cpy(buf, pos) {
|
|
4802
|
+
f8b[0] = buf[pos ];
|
|
4803
|
+
f8b[1] = buf[pos + 1];
|
|
4804
|
+
f8b[2] = buf[pos + 2];
|
|
4805
|
+
f8b[3] = buf[pos + 3];
|
|
4806
|
+
return f32[0];
|
|
4807
|
+
}
|
|
4842
4808
|
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
buf[pos + 5] = f8b[5];
|
|
4851
|
-
buf[pos + 6] = f8b[6];
|
|
4852
|
-
buf[pos + 7] = f8b[7];
|
|
4853
|
-
}
|
|
4809
|
+
function readFloat_f32_rev(buf, pos) {
|
|
4810
|
+
f8b[3] = buf[pos ];
|
|
4811
|
+
f8b[2] = buf[pos + 1];
|
|
4812
|
+
f8b[1] = buf[pos + 2];
|
|
4813
|
+
f8b[0] = buf[pos + 3];
|
|
4814
|
+
return f32[0];
|
|
4815
|
+
}
|
|
4854
4816
|
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4817
|
+
/* istanbul ignore next */
|
|
4818
|
+
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
|
|
4819
|
+
/* istanbul ignore next */
|
|
4820
|
+
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
4821
|
+
|
|
4822
|
+
// float: ieee754
|
|
4823
|
+
})(); else (function() {
|
|
4824
|
+
|
|
4825
|
+
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
4826
|
+
var sign = val < 0 ? 1 : 0;
|
|
4827
|
+
if (sign)
|
|
4828
|
+
val = -val;
|
|
4829
|
+
if (val === 0)
|
|
4830
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
4831
|
+
else if (isNaN(val))
|
|
4832
|
+
writeUint(2143289344, buf, pos);
|
|
4833
|
+
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
4834
|
+
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
4835
|
+
else if (val < 1.1754943508222875e-38) // denormal
|
|
4836
|
+
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
4837
|
+
else {
|
|
4838
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
4839
|
+
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
4840
|
+
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4866
4843
|
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4844
|
+
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
4845
|
+
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
4846
|
+
|
|
4847
|
+
function readFloat_ieee754(readUint, buf, pos) {
|
|
4848
|
+
var uint = readUint(buf, pos),
|
|
4849
|
+
sign = (uint >> 31) * 2 + 1,
|
|
4850
|
+
exponent = uint >>> 23 & 255,
|
|
4851
|
+
mantissa = uint & 8388607;
|
|
4852
|
+
return exponent === 255
|
|
4853
|
+
? mantissa
|
|
4854
|
+
? NaN
|
|
4855
|
+
: sign * Infinity
|
|
4856
|
+
: exponent === 0 // denormal
|
|
4857
|
+
? sign * 1.401298464324817e-45 * mantissa
|
|
4858
|
+
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
4859
|
+
}
|
|
4883
4860
|
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
f8b[6] = buf[pos + 1];
|
|
4887
|
-
f8b[5] = buf[pos + 2];
|
|
4888
|
-
f8b[4] = buf[pos + 3];
|
|
4889
|
-
f8b[3] = buf[pos + 4];
|
|
4890
|
-
f8b[2] = buf[pos + 5];
|
|
4891
|
-
f8b[1] = buf[pos + 6];
|
|
4892
|
-
f8b[0] = buf[pos + 7];
|
|
4893
|
-
return f64[0];
|
|
4894
|
-
}
|
|
4861
|
+
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
4862
|
+
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
4895
4863
|
|
|
4896
|
-
|
|
4897
|
-
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
4898
|
-
/* istanbul ignore next */
|
|
4899
|
-
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
4900
|
-
|
|
4901
|
-
// double: ieee754
|
|
4902
|
-
})(); else (function() {
|
|
4903
|
-
|
|
4904
|
-
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
4905
|
-
var sign = val < 0 ? 1 : 0;
|
|
4906
|
-
if (sign)
|
|
4907
|
-
val = -val;
|
|
4908
|
-
if (val === 0) {
|
|
4909
|
-
writeUint(0, buf, pos + off0);
|
|
4910
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
4911
|
-
} else if (isNaN(val)) {
|
|
4912
|
-
writeUint(0, buf, pos + off0);
|
|
4913
|
-
writeUint(2146959360, buf, pos + off1);
|
|
4914
|
-
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
4915
|
-
writeUint(0, buf, pos + off0);
|
|
4916
|
-
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
4917
|
-
} else {
|
|
4918
|
-
var mantissa;
|
|
4919
|
-
if (val < 2.2250738585072014e-308) { // denormal
|
|
4920
|
-
mantissa = val / 5e-324;
|
|
4921
|
-
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
4922
|
-
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
4923
|
-
} else {
|
|
4924
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
4925
|
-
if (exponent === 1024)
|
|
4926
|
-
exponent = 1023;
|
|
4927
|
-
mantissa = val * Math.pow(2, -exponent);
|
|
4928
|
-
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
4929
|
-
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
}
|
|
4864
|
+
})();
|
|
4933
4865
|
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
4938
|
-
var lo = readUint(buf, pos + off0),
|
|
4939
|
-
hi = readUint(buf, pos + off1);
|
|
4940
|
-
var sign = (hi >> 31) * 2 + 1,
|
|
4941
|
-
exponent = hi >>> 20 & 2047,
|
|
4942
|
-
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
4943
|
-
return exponent === 2047
|
|
4944
|
-
? mantissa
|
|
4945
|
-
? NaN
|
|
4946
|
-
: sign * Infinity
|
|
4947
|
-
: exponent === 0 // denormal
|
|
4948
|
-
? sign * 5e-324 * mantissa
|
|
4949
|
-
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
4950
|
-
}
|
|
4866
|
+
// double: typed array
|
|
4867
|
+
if (typeof Float64Array !== "undefined") (function() {
|
|
4951
4868
|
|
|
4952
|
-
|
|
4953
|
-
|
|
4869
|
+
var f64 = new Float64Array([-0]),
|
|
4870
|
+
f8b = new Uint8Array(f64.buffer),
|
|
4871
|
+
le = f8b[7] === 128;
|
|
4954
4872
|
|
|
4955
|
-
|
|
4873
|
+
function writeDouble_f64_cpy(val, buf, pos) {
|
|
4874
|
+
f64[0] = val;
|
|
4875
|
+
buf[pos ] = f8b[0];
|
|
4876
|
+
buf[pos + 1] = f8b[1];
|
|
4877
|
+
buf[pos + 2] = f8b[2];
|
|
4878
|
+
buf[pos + 3] = f8b[3];
|
|
4879
|
+
buf[pos + 4] = f8b[4];
|
|
4880
|
+
buf[pos + 5] = f8b[5];
|
|
4881
|
+
buf[pos + 6] = f8b[6];
|
|
4882
|
+
buf[pos + 7] = f8b[7];
|
|
4883
|
+
}
|
|
4956
4884
|
|
|
4957
|
-
|
|
4958
|
-
|
|
4885
|
+
function writeDouble_f64_rev(val, buf, pos) {
|
|
4886
|
+
f64[0] = val;
|
|
4887
|
+
buf[pos ] = f8b[7];
|
|
4888
|
+
buf[pos + 1] = f8b[6];
|
|
4889
|
+
buf[pos + 2] = f8b[5];
|
|
4890
|
+
buf[pos + 3] = f8b[4];
|
|
4891
|
+
buf[pos + 4] = f8b[3];
|
|
4892
|
+
buf[pos + 5] = f8b[2];
|
|
4893
|
+
buf[pos + 6] = f8b[1];
|
|
4894
|
+
buf[pos + 7] = f8b[0];
|
|
4895
|
+
}
|
|
4959
4896
|
|
|
4960
|
-
|
|
4897
|
+
/* istanbul ignore next */
|
|
4898
|
+
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
|
|
4899
|
+
/* istanbul ignore next */
|
|
4900
|
+
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
4901
|
+
|
|
4902
|
+
function readDouble_f64_cpy(buf, pos) {
|
|
4903
|
+
f8b[0] = buf[pos ];
|
|
4904
|
+
f8b[1] = buf[pos + 1];
|
|
4905
|
+
f8b[2] = buf[pos + 2];
|
|
4906
|
+
f8b[3] = buf[pos + 3];
|
|
4907
|
+
f8b[4] = buf[pos + 4];
|
|
4908
|
+
f8b[5] = buf[pos + 5];
|
|
4909
|
+
f8b[6] = buf[pos + 6];
|
|
4910
|
+
f8b[7] = buf[pos + 7];
|
|
4911
|
+
return f64[0];
|
|
4912
|
+
}
|
|
4961
4913
|
|
|
4962
|
-
function
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4914
|
+
function readDouble_f64_rev(buf, pos) {
|
|
4915
|
+
f8b[7] = buf[pos ];
|
|
4916
|
+
f8b[6] = buf[pos + 1];
|
|
4917
|
+
f8b[5] = buf[pos + 2];
|
|
4918
|
+
f8b[4] = buf[pos + 3];
|
|
4919
|
+
f8b[3] = buf[pos + 4];
|
|
4920
|
+
f8b[2] = buf[pos + 5];
|
|
4921
|
+
f8b[1] = buf[pos + 6];
|
|
4922
|
+
f8b[0] = buf[pos + 7];
|
|
4923
|
+
return f64[0];
|
|
4924
|
+
}
|
|
4968
4925
|
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4926
|
+
/* istanbul ignore next */
|
|
4927
|
+
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
4928
|
+
/* istanbul ignore next */
|
|
4929
|
+
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
4930
|
+
|
|
4931
|
+
// double: ieee754
|
|
4932
|
+
})(); else (function() {
|
|
4933
|
+
|
|
4934
|
+
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
4935
|
+
var sign = val < 0 ? 1 : 0;
|
|
4936
|
+
if (sign)
|
|
4937
|
+
val = -val;
|
|
4938
|
+
if (val === 0) {
|
|
4939
|
+
writeUint(0, buf, pos + off0);
|
|
4940
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
4941
|
+
} else if (isNaN(val)) {
|
|
4942
|
+
writeUint(0, buf, pos + off0);
|
|
4943
|
+
writeUint(2146959360, buf, pos + off1);
|
|
4944
|
+
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
4945
|
+
writeUint(0, buf, pos + off0);
|
|
4946
|
+
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
4947
|
+
} else {
|
|
4948
|
+
var mantissa;
|
|
4949
|
+
if (val < 2.2250738585072014e-308) { // denormal
|
|
4950
|
+
mantissa = val / 5e-324;
|
|
4951
|
+
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
4952
|
+
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
4953
|
+
} else {
|
|
4954
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
4955
|
+
if (exponent === 1024)
|
|
4956
|
+
exponent = 1023;
|
|
4957
|
+
mantissa = val * Math.pow(2, -exponent);
|
|
4958
|
+
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
4959
|
+
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4975
4963
|
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4964
|
+
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
|
|
4965
|
+
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
4966
|
+
|
|
4967
|
+
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
4968
|
+
var lo = readUint(buf, pos + off0),
|
|
4969
|
+
hi = readUint(buf, pos + off1);
|
|
4970
|
+
var sign = (hi >> 31) * 2 + 1,
|
|
4971
|
+
exponent = hi >>> 20 & 2047,
|
|
4972
|
+
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
4973
|
+
return exponent === 2047
|
|
4974
|
+
? mantissa
|
|
4975
|
+
? NaN
|
|
4976
|
+
: sign * Infinity
|
|
4977
|
+
: exponent === 0 // denormal
|
|
4978
|
+
? sign * 5e-324 * mantissa
|
|
4979
|
+
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
4980
|
+
}
|
|
4982
4981
|
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4982
|
+
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
4983
|
+
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
4984
|
+
|
|
4985
|
+
})();
|
|
4986
|
+
|
|
4987
|
+
return exports;
|
|
4988
|
+
}
|
|
4989
|
+
|
|
4990
|
+
// uint helpers
|
|
4991
|
+
|
|
4992
|
+
function writeUintLE(val, buf, pos) {
|
|
4993
|
+
buf[pos ] = val & 255;
|
|
4994
|
+
buf[pos + 1] = val >>> 8 & 255;
|
|
4995
|
+
buf[pos + 2] = val >>> 16 & 255;
|
|
4996
|
+
buf[pos + 3] = val >>> 24;
|
|
4997
|
+
}
|
|
4998
|
+
|
|
4999
|
+
function writeUintBE(val, buf, pos) {
|
|
5000
|
+
buf[pos ] = val >>> 24;
|
|
5001
|
+
buf[pos + 1] = val >>> 16 & 255;
|
|
5002
|
+
buf[pos + 2] = val >>> 8 & 255;
|
|
5003
|
+
buf[pos + 3] = val & 255;
|
|
5004
|
+
}
|
|
5005
|
+
|
|
5006
|
+
function readUintLE(buf, pos) {
|
|
5007
|
+
return (buf[pos ]
|
|
5008
|
+
| buf[pos + 1] << 8
|
|
5009
|
+
| buf[pos + 2] << 16
|
|
5010
|
+
| buf[pos + 3] << 24) >>> 0;
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
function readUintBE(buf, pos) {
|
|
5014
|
+
return (buf[pos ] << 24
|
|
5015
|
+
| buf[pos + 1] << 16
|
|
5016
|
+
| buf[pos + 2] << 8
|
|
5017
|
+
| buf[pos + 3]) >>> 0;
|
|
5018
|
+
}
|
|
5019
|
+
return float;
|
|
4988
5020
|
}
|
|
4989
5021
|
|
|
4990
|
-
var inquire_1
|
|
5022
|
+
var inquire_1;
|
|
5023
|
+
var hasRequiredInquire;
|
|
5024
|
+
|
|
5025
|
+
function requireInquire () {
|
|
5026
|
+
if (hasRequiredInquire) return inquire_1;
|
|
5027
|
+
hasRequiredInquire = 1;
|
|
5028
|
+
inquire_1 = inquire;
|
|
4991
5029
|
|
|
4992
|
-
/**
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
function inquire(moduleName) {
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5030
|
+
/**
|
|
5031
|
+
* Requires a module only if available.
|
|
5032
|
+
* @memberof util
|
|
5033
|
+
* @param {string} moduleName Module to require
|
|
5034
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
5035
|
+
*/
|
|
5036
|
+
function inquire(moduleName) {
|
|
5037
|
+
try {
|
|
5038
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
5039
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
5040
|
+
return mod;
|
|
5041
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
5042
|
+
return null;
|
|
5043
|
+
}
|
|
5044
|
+
return inquire_1;
|
|
5005
5045
|
}
|
|
5006
5046
|
|
|
5007
5047
|
var utf8$2 = {};
|
|
5008
5048
|
|
|
5009
|
-
|
|
5049
|
+
var hasRequiredUtf8;
|
|
5050
|
+
|
|
5051
|
+
function requireUtf8 () {
|
|
5052
|
+
if (hasRequiredUtf8) return utf8$2;
|
|
5053
|
+
hasRequiredUtf8 = 1;
|
|
5054
|
+
(function (exports) {
|
|
5010
5055
|
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5056
|
+
/**
|
|
5057
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5058
|
+
* @memberof util
|
|
5059
|
+
* @namespace
|
|
5060
|
+
*/
|
|
5061
|
+
var utf8 = exports;
|
|
5062
|
+
|
|
5063
|
+
/**
|
|
5064
|
+
* Calculates the UTF8 byte length of a string.
|
|
5065
|
+
* @param {string} string String
|
|
5066
|
+
* @returns {number} Byte length
|
|
5067
|
+
*/
|
|
5068
|
+
utf8.length = function utf8_length(string) {
|
|
5069
|
+
var len = 0,
|
|
5070
|
+
c = 0;
|
|
5071
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5072
|
+
c = string.charCodeAt(i);
|
|
5073
|
+
if (c < 128)
|
|
5074
|
+
len += 1;
|
|
5075
|
+
else if (c < 2048)
|
|
5076
|
+
len += 2;
|
|
5077
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5078
|
+
++i;
|
|
5079
|
+
len += 4;
|
|
5080
|
+
} else
|
|
5081
|
+
len += 3;
|
|
5082
|
+
}
|
|
5083
|
+
return len;
|
|
5084
|
+
};
|
|
5085
|
+
|
|
5086
|
+
/**
|
|
5087
|
+
* Reads UTF8 bytes as a string.
|
|
5088
|
+
* @param {Uint8Array} buffer Source buffer
|
|
5089
|
+
* @param {number} start Source start
|
|
5090
|
+
* @param {number} end Source end
|
|
5091
|
+
* @returns {string} String read
|
|
5092
|
+
*/
|
|
5093
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
5094
|
+
var len = end - start;
|
|
5095
|
+
if (len < 1)
|
|
5096
|
+
return "";
|
|
5097
|
+
var parts = null,
|
|
5098
|
+
chunk = [],
|
|
5099
|
+
i = 0, // char offset
|
|
5100
|
+
t; // temporary
|
|
5101
|
+
while (start < end) {
|
|
5102
|
+
t = buffer[start++];
|
|
5103
|
+
if (t < 128)
|
|
5104
|
+
chunk[i++] = t;
|
|
5105
|
+
else if (t > 191 && t < 224)
|
|
5106
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5107
|
+
else if (t > 239 && t < 365) {
|
|
5108
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5109
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
5110
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5111
|
+
} else
|
|
5112
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5113
|
+
if (i > 8191) {
|
|
5114
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5115
|
+
i = 0;
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
if (parts) {
|
|
5119
|
+
if (i)
|
|
5120
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5121
|
+
return parts.join("");
|
|
5122
|
+
}
|
|
5123
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5124
|
+
};
|
|
5125
|
+
|
|
5126
|
+
/**
|
|
5127
|
+
* Writes a string as UTF8 bytes.
|
|
5128
|
+
* @param {string} string Source string
|
|
5129
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
5130
|
+
* @param {number} offset Destination offset
|
|
5131
|
+
* @returns {number} Bytes written
|
|
5132
|
+
*/
|
|
5133
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
5134
|
+
var start = offset,
|
|
5135
|
+
c1, // character 1
|
|
5136
|
+
c2; // character 2
|
|
5137
|
+
for (var i = 0; i < string.length; ++i) {
|
|
5138
|
+
c1 = string.charCodeAt(i);
|
|
5139
|
+
if (c1 < 128) {
|
|
5140
|
+
buffer[offset++] = c1;
|
|
5141
|
+
} else if (c1 < 2048) {
|
|
5142
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
5143
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5144
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5145
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5146
|
+
++i;
|
|
5147
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
5148
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5149
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5150
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5151
|
+
} else {
|
|
5152
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
5153
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5154
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
return offset - start;
|
|
5158
|
+
};
|
|
5159
|
+
} (utf8$2));
|
|
5160
|
+
return utf8$2;
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
var pool_1;
|
|
5164
|
+
var hasRequiredPool;
|
|
5165
|
+
|
|
5166
|
+
function requirePool () {
|
|
5167
|
+
if (hasRequiredPool) return pool_1;
|
|
5168
|
+
hasRequiredPool = 1;
|
|
5169
|
+
pool_1 = pool;
|
|
5017
5170
|
|
|
5018
5171
|
/**
|
|
5019
|
-
*
|
|
5020
|
-
* @
|
|
5021
|
-
* @
|
|
5172
|
+
* An allocator as used by {@link util.pool}.
|
|
5173
|
+
* @typedef PoolAllocator
|
|
5174
|
+
* @type {function}
|
|
5175
|
+
* @param {number} size Buffer size
|
|
5176
|
+
* @returns {Uint8Array} Buffer
|
|
5022
5177
|
*/
|
|
5023
|
-
utf8.length = function utf8_length(string) {
|
|
5024
|
-
var len = 0,
|
|
5025
|
-
c = 0;
|
|
5026
|
-
for (var i = 0; i < string.length; ++i) {
|
|
5027
|
-
c = string.charCodeAt(i);
|
|
5028
|
-
if (c < 128)
|
|
5029
|
-
len += 1;
|
|
5030
|
-
else if (c < 2048)
|
|
5031
|
-
len += 2;
|
|
5032
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
5033
|
-
++i;
|
|
5034
|
-
len += 4;
|
|
5035
|
-
} else
|
|
5036
|
-
len += 3;
|
|
5037
|
-
}
|
|
5038
|
-
return len;
|
|
5039
|
-
};
|
|
5040
5178
|
|
|
5041
5179
|
/**
|
|
5042
|
-
*
|
|
5043
|
-
* @
|
|
5044
|
-
* @
|
|
5045
|
-
* @param {number}
|
|
5046
|
-
* @
|
|
5180
|
+
* A slicer as used by {@link util.pool}.
|
|
5181
|
+
* @typedef PoolSlicer
|
|
5182
|
+
* @type {function}
|
|
5183
|
+
* @param {number} start Start offset
|
|
5184
|
+
* @param {number} end End offset
|
|
5185
|
+
* @returns {Uint8Array} Buffer slice
|
|
5186
|
+
* @this {Uint8Array}
|
|
5047
5187
|
*/
|
|
5048
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
5049
|
-
var len = end - start;
|
|
5050
|
-
if (len < 1)
|
|
5051
|
-
return "";
|
|
5052
|
-
var parts = null,
|
|
5053
|
-
chunk = [],
|
|
5054
|
-
i = 0, // char offset
|
|
5055
|
-
t; // temporary
|
|
5056
|
-
while (start < end) {
|
|
5057
|
-
t = buffer[start++];
|
|
5058
|
-
if (t < 128)
|
|
5059
|
-
chunk[i++] = t;
|
|
5060
|
-
else if (t > 191 && t < 224)
|
|
5061
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
5062
|
-
else if (t > 239 && t < 365) {
|
|
5063
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
5064
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
5065
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
5066
|
-
} else
|
|
5067
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
5068
|
-
if (i > 8191) {
|
|
5069
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
5070
|
-
i = 0;
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
|
-
if (parts) {
|
|
5074
|
-
if (i)
|
|
5075
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
5076
|
-
return parts.join("");
|
|
5077
|
-
}
|
|
5078
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
5079
|
-
};
|
|
5080
5188
|
|
|
5081
5189
|
/**
|
|
5082
|
-
*
|
|
5083
|
-
* @
|
|
5084
|
-
* @
|
|
5085
|
-
* @param {
|
|
5086
|
-
* @
|
|
5190
|
+
* A general purpose buffer pool.
|
|
5191
|
+
* @memberof util
|
|
5192
|
+
* @function
|
|
5193
|
+
* @param {PoolAllocator} alloc Allocator
|
|
5194
|
+
* @param {PoolSlicer} slice Slicer
|
|
5195
|
+
* @param {number} [size=8192] Slab size
|
|
5196
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
5087
5197
|
*/
|
|
5088
|
-
|
|
5089
|
-
var
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
if (
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
5100
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
5101
|
-
++i;
|
|
5102
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
5103
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
5104
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5105
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5106
|
-
} else {
|
|
5107
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
5108
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
5109
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
5198
|
+
function pool(alloc, slice, size) {
|
|
5199
|
+
var SIZE = size || 8192;
|
|
5200
|
+
var MAX = SIZE >>> 1;
|
|
5201
|
+
var slab = null;
|
|
5202
|
+
var offset = SIZE;
|
|
5203
|
+
return function pool_alloc(size) {
|
|
5204
|
+
if (size < 1 || size > MAX)
|
|
5205
|
+
return alloc(size);
|
|
5206
|
+
if (offset + size > SIZE) {
|
|
5207
|
+
slab = alloc(SIZE);
|
|
5208
|
+
offset = 0;
|
|
5110
5209
|
}
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
/**
|
|
5119
|
-
* An allocator as used by {@link util.pool}.
|
|
5120
|
-
* @typedef PoolAllocator
|
|
5121
|
-
* @type {function}
|
|
5122
|
-
* @param {number} size Buffer size
|
|
5123
|
-
* @returns {Uint8Array} Buffer
|
|
5124
|
-
*/
|
|
5125
|
-
|
|
5126
|
-
/**
|
|
5127
|
-
* A slicer as used by {@link util.pool}.
|
|
5128
|
-
* @typedef PoolSlicer
|
|
5129
|
-
* @type {function}
|
|
5130
|
-
* @param {number} start Start offset
|
|
5131
|
-
* @param {number} end End offset
|
|
5132
|
-
* @returns {Uint8Array} Buffer slice
|
|
5133
|
-
* @this {Uint8Array}
|
|
5134
|
-
*/
|
|
5135
|
-
|
|
5136
|
-
/**
|
|
5137
|
-
* A general purpose buffer pool.
|
|
5138
|
-
* @memberof util
|
|
5139
|
-
* @function
|
|
5140
|
-
* @param {PoolAllocator} alloc Allocator
|
|
5141
|
-
* @param {PoolSlicer} slice Slicer
|
|
5142
|
-
* @param {number} [size=8192] Slab size
|
|
5143
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
5144
|
-
*/
|
|
5145
|
-
function pool(alloc, slice, size) {
|
|
5146
|
-
var SIZE = size || 8192;
|
|
5147
|
-
var MAX = SIZE >>> 1;
|
|
5148
|
-
var slab = null;
|
|
5149
|
-
var offset = SIZE;
|
|
5150
|
-
return function pool_alloc(size) {
|
|
5151
|
-
if (size < 1 || size > MAX)
|
|
5152
|
-
return alloc(size);
|
|
5153
|
-
if (offset + size > SIZE) {
|
|
5154
|
-
slab = alloc(SIZE);
|
|
5155
|
-
offset = 0;
|
|
5156
|
-
}
|
|
5157
|
-
var buf = slice.call(slab, offset, offset += size);
|
|
5158
|
-
if (offset & 7) // align to 32 bit
|
|
5159
|
-
offset = (offset | 7) + 1;
|
|
5160
|
-
return buf;
|
|
5161
|
-
};
|
|
5210
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
5211
|
+
if (offset & 7) // align to 32 bit
|
|
5212
|
+
offset = (offset | 7) + 1;
|
|
5213
|
+
return buf;
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5216
|
+
return pool_1;
|
|
5162
5217
|
}
|
|
5163
5218
|
|
|
5164
5219
|
var longbits;
|
|
@@ -5378,25 +5433,25 @@ function requireMinimal () {
|
|
|
5378
5433
|
var util = exports;
|
|
5379
5434
|
|
|
5380
5435
|
// used to return a Promise where callback is omitted
|
|
5381
|
-
util.asPromise =
|
|
5436
|
+
util.asPromise = requireAspromise();
|
|
5382
5437
|
|
|
5383
5438
|
// converts to / from base64 encoded strings
|
|
5384
|
-
util.base64 =
|
|
5439
|
+
util.base64 = requireBase64();
|
|
5385
5440
|
|
|
5386
5441
|
// base class of rpc.Service
|
|
5387
|
-
util.EventEmitter =
|
|
5442
|
+
util.EventEmitter = requireEventemitter();
|
|
5388
5443
|
|
|
5389
5444
|
// float handling accross browsers
|
|
5390
|
-
util.float =
|
|
5445
|
+
util.float = requireFloat();
|
|
5391
5446
|
|
|
5392
5447
|
// requires modules optionally and hides the call from bundlers
|
|
5393
|
-
util.inquire =
|
|
5448
|
+
util.inquire = requireInquire();
|
|
5394
5449
|
|
|
5395
5450
|
// converts to / from utf8 encoded strings
|
|
5396
|
-
util.utf8 =
|
|
5451
|
+
util.utf8 = requireUtf8();
|
|
5397
5452
|
|
|
5398
5453
|
// provides a node-like buffer pool in the browser
|
|
5399
|
-
util.pool =
|
|
5454
|
+
util.pool = requirePool();
|
|
5400
5455
|
|
|
5401
5456
|
// utility to work with the low and high bits of a 64 bit value
|
|
5402
5457
|
util.LongBits = requireLongbits();
|
|
@@ -9843,8 +9898,12 @@ const getDepositTxDataFromLogs = (logs, address, senderAsset, receiverAsset) =>
|
|
|
9843
9898
|
newData.sender = value;
|
|
9844
9899
|
if (key === 'recipient')
|
|
9845
9900
|
newData.recipient = value;
|
|
9846
|
-
if (key === 'amount')
|
|
9847
|
-
|
|
9901
|
+
if (key === 'amount') {
|
|
9902
|
+
const amountAsset = value.match(/(\d+)(\D+)/);
|
|
9903
|
+
if (amountAsset) {
|
|
9904
|
+
newData.amount = xchainUtil.baseAmount(parseInt(amountAsset[1]));
|
|
9905
|
+
}
|
|
9906
|
+
}
|
|
9848
9907
|
return acc2;
|
|
9849
9908
|
}, acc);
|
|
9850
9909
|
}
|
|
@@ -10417,13 +10476,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10417
10476
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10418
10477
|
*/
|
|
10419
10478
|
getTransactionData(txId, address) {
|
|
10420
|
-
var _a, _b, _c, _d, _e, _f;
|
|
10479
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
10421
10480
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10422
10481
|
const txResult = yield this.fetchTransaction(txId);
|
|
10423
10482
|
if (txResult && txResult.logs) {
|
|
10424
10483
|
// extract values from the response
|
|
10425
10484
|
const transferEvent = (_a = txResult.logs[0].events) === null || _a === void 0 ? void 0 : _a.find((event) => event.type === 'transfer');
|
|
10426
10485
|
const messageEvent = (_b = txResult.logs[0].events) === null || _b === void 0 ? void 0 : _b.find((event) => event.type === 'message');
|
|
10486
|
+
const coinReceivedEvent = (_c = txResult.logs[0].events) === null || _c === void 0 ? void 0 : _c.find((event) => event.type === 'coin_received');
|
|
10427
10487
|
if (!transferEvent || !messageEvent) {
|
|
10428
10488
|
throw new Error('Invalid transaction data');
|
|
10429
10489
|
}
|
|
@@ -10446,14 +10506,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10446
10506
|
.split(/(?<=\d)(?=\D)/)
|
|
10447
10507
|
.filter(Boolean)[1]
|
|
10448
10508
|
.replace(/[a-z]/g, (letter) => letter.toUpperCase());
|
|
10449
|
-
const fromAddress = ((
|
|
10450
|
-
? (
|
|
10509
|
+
const fromAddress = ((_d = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _d === void 0 ? void 0 : _d.value)
|
|
10510
|
+
? (_e = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _e === void 0 ? void 0 : _e.value
|
|
10451
10511
|
: address;
|
|
10452
|
-
const memo = ((
|
|
10512
|
+
const memo = ((_f = txResult.tx) === null || _f === void 0 ? void 0 : _f.body) ? txResult.tx.body.memo.split(':') : '';
|
|
10453
10513
|
const toAddress = memo[2] ? memo[2] : '';
|
|
10454
|
-
const toAsset = memo[1] ? xchainUtil.assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10514
|
+
const toAsset = memo[1] && !coinReceivedEvent ? xchainUtil.assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10455
10515
|
const date = new Date(txResult.timestamp);
|
|
10456
|
-
const typeString = (
|
|
10516
|
+
const typeString = (_g = messageEvent.attributes.find((attr) => attr.key === 'action')) === null || _g === void 0 ? void 0 : _g.value;
|
|
10457
10517
|
const hash = txResult.txhash;
|
|
10458
10518
|
if (assetString && hash && fromAddress && typeString) {
|
|
10459
10519
|
const fromAsset = assetString === 'RUNE' ? AssetRuneNative : xchainUtil.assetFromStringEx(assetString);
|