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