@neurosity/sdk 6.4.1 → 6.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/neurosity.iife.js +2598 -107
- package/dist/browser/neurosity.js +129 -113
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/Neurosity.js +5 -1
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +1 -1
- package/dist/cjs/api/bluetooth/BluetoothClient.js +10 -8
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +3 -1
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +17 -17
- package/dist/cjs/api/bluetooth/types/index.d.ts +1 -0
- package/dist/cjs/api/bluetooth/utils/binaryBufferToEpoch.d.ts +51 -0
- package/dist/cjs/api/bluetooth/utils/binaryBufferToEpoch.js +116 -0
- package/dist/cjs/api/bluetooth/utils/decodeJSONChunks.d.ts +15 -0
- package/dist/cjs/api/bluetooth/utils/decodeJSONChunks.js +25 -0
- package/dist/cjs/api/bluetooth/utils/textCodec.d.ts +17 -0
- package/dist/cjs/api/bluetooth/utils/textCodec.js +40 -0
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +3 -1
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +19 -34
- package/dist/cjs/utils/heartbeat.js +14 -4
- package/dist/electron/index.js +17 -15
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/Neurosity.js +6 -2
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +1 -1
- package/dist/esm/api/bluetooth/BluetoothClient.js +10 -8
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +3 -1
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +18 -18
- package/dist/esm/api/bluetooth/types/index.d.ts +1 -0
- package/dist/esm/api/bluetooth/utils/binaryBufferToEpoch.d.ts +51 -0
- package/dist/esm/api/bluetooth/utils/binaryBufferToEpoch.js +109 -0
- package/dist/esm/api/bluetooth/utils/decodeJSONChunks.d.ts +15 -0
- package/dist/esm/api/bluetooth/utils/decodeJSONChunks.js +21 -0
- package/dist/esm/api/bluetooth/utils/textCodec.d.ts +17 -0
- package/dist/esm/api/bluetooth/utils/textCodec.js +36 -0
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +3 -1
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +20 -35
- package/dist/esm/neurosity.mjs +2598 -107
- package/dist/esm/utils/heartbeat.js +14 -4
- package/dist/examples/neurosity.iife.js +2598 -107
- package/dist/examples/neurosity.js +129 -113
- package/dist/examples/neurosity.mjs +2598 -107
- package/package.json +2 -1
- package/dist/cjs/api/bluetooth/utils/encoding.d.ts +0 -3
- package/dist/cjs/api/bluetooth/utils/encoding.js +0 -22
- package/dist/esm/api/bluetooth/utils/encoding.d.ts +0 -3
- package/dist/esm/api/bluetooth/utils/encoding.js +0 -17
|
@@ -2774,7 +2774,7 @@ var Neurosity = (function (exports) {
|
|
|
2774
2774
|
return a!==a && b!==b;
|
|
2775
2775
|
};
|
|
2776
2776
|
|
|
2777
|
-
|
|
2777
|
+
/******************************************************************************
|
|
2778
2778
|
Copyright (c) Microsoft Corporation.
|
|
2779
2779
|
|
|
2780
2780
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -2800,7 +2800,7 @@ var Neurosity = (function (exports) {
|
|
|
2800
2800
|
return __assign$1.apply(this, arguments);
|
|
2801
2801
|
};
|
|
2802
2802
|
|
|
2803
|
-
|
|
2803
|
+
/******************************************************************************
|
|
2804
2804
|
Copyright (c) Microsoft Corporation.
|
|
2805
2805
|
|
|
2806
2806
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -4402,7 +4402,7 @@ var Neurosity = (function (exports) {
|
|
|
4402
4402
|
}
|
|
4403
4403
|
}
|
|
4404
4404
|
|
|
4405
|
-
|
|
4405
|
+
/******************************************************************************
|
|
4406
4406
|
Copyright (c) Microsoft Corporation.
|
|
4407
4407
|
|
|
4408
4408
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -4433,7 +4433,7 @@ var Neurosity = (function (exports) {
|
|
|
4433
4433
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
4434
4434
|
function step(op) {
|
|
4435
4435
|
if (f) throw new TypeError("Generator is already executing.");
|
|
4436
|
-
while (_) try {
|
|
4436
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
4437
4437
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
4438
4438
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
4439
4439
|
switch (op[0]) {
|
|
@@ -5912,7 +5912,7 @@ var Neurosity = (function (exports) {
|
|
|
5912
5912
|
firebase.registerVersion(name$d, version$2, 'app');
|
|
5913
5913
|
firebase.SDK_VERSION = version$2;
|
|
5914
5914
|
|
|
5915
|
-
|
|
5915
|
+
/******************************************************************************
|
|
5916
5916
|
Copyright (c) Microsoft Corporation.
|
|
5917
5917
|
|
|
5918
5918
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -5970,7 +5970,7 @@ var Neurosity = (function (exports) {
|
|
|
5970
5970
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
5971
5971
|
function step(op) {
|
|
5972
5972
|
if (f) throw new TypeError("Generator is already executing.");
|
|
5973
|
-
while (_) try {
|
|
5973
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
5974
5974
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
5975
5975
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
5976
5976
|
switch (op[0]) {
|
|
@@ -21724,7 +21724,7 @@ var Neurosity = (function (exports) {
|
|
|
21724
21724
|
firebase.INTERNAL.registerComponent({name:"auth-internal",instanceFactory:function(b){b=b.getProvider("auth").getImmediate();return {getUid:q(b.getUid,b),getToken:q(b.nc,b),addAuthTokenListener:q(b.cc,b),removeAuthTokenListener:q(b.Pc,b)}},multipleInstances:!1,instantiationMode:"LAZY",type:"PRIVATE"});firebase.registerVersion("@firebase/auth","0.16.8");firebase.INTERNAL.extendNamespace({User:Im});}else throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");
|
|
21725
21725
|
})();}).apply(typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {});
|
|
21726
21726
|
|
|
21727
|
-
|
|
21727
|
+
/******************************************************************************
|
|
21728
21728
|
Copyright (c) Microsoft Corporation.
|
|
21729
21729
|
|
|
21730
21730
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -21771,7 +21771,7 @@ var Neurosity = (function (exports) {
|
|
|
21771
21771
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21772
21772
|
function step(op) {
|
|
21773
21773
|
if (f) throw new TypeError("Generator is already executing.");
|
|
21774
|
-
while (_) try {
|
|
21774
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
21775
21775
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21776
21776
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21777
21777
|
switch (op[0]) {
|
|
@@ -22493,7 +22493,7 @@ var Neurosity = (function (exports) {
|
|
|
22493
22493
|
registerFunctions(firebase, fetch.bind(self));
|
|
22494
22494
|
firebase.registerVersion(name$f, version$4);
|
|
22495
22495
|
|
|
22496
|
-
|
|
22496
|
+
/******************************************************************************
|
|
22497
22497
|
Copyright (c) Microsoft Corporation.
|
|
22498
22498
|
|
|
22499
22499
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -22540,7 +22540,7 @@ var Neurosity = (function (exports) {
|
|
|
22540
22540
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
22541
22541
|
function step(op) {
|
|
22542
22542
|
if (f) throw new TypeError("Generator is already executing.");
|
|
22543
|
-
while (_) try {
|
|
22543
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22544
22544
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
22545
22545
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22546
22546
|
switch (op[0]) {
|
|
@@ -42939,10 +42939,11 @@ var Neurosity = (function (exports) {
|
|
|
42939
42939
|
})(SLEEP_MODE_REASON || (SLEEP_MODE_REASON = {}));
|
|
42940
42940
|
|
|
42941
42941
|
const HEARTBEAT_UPDATE_INTERVAL = 30000; // 30 seconds - set by the OS
|
|
42942
|
-
const
|
|
42942
|
+
const LOST_LOCAL_HEARTBEAT_AFTER = HEARTBEAT_UPDATE_INTERVAL * 2.5; // 75 seconds
|
|
42943
|
+
const LOST_REMOTE_HEARTBEAT_AFTER = 8.64e7; // 24 hours
|
|
42943
42944
|
function heartbeatAwareStatus(status$) {
|
|
42944
42945
|
const lastLocalHeartbeat$ = status$.pipe(map(({ lastHeartbeat }) => lastHeartbeat), distinctUntilChanged(), map(() => Date.now()));
|
|
42945
|
-
const lostHeartbeat$ = lastLocalHeartbeat$.pipe(switchMap(() => timer(
|
|
42946
|
+
const lostHeartbeat$ = lastLocalHeartbeat$.pipe(switchMap(() => timer(LOST_LOCAL_HEARTBEAT_AFTER)), map(() => null), startWith(null));
|
|
42946
42947
|
return combineLatest({
|
|
42947
42948
|
status: status$,
|
|
42948
42949
|
lostHeartbeat: lostHeartbeat$ // @important - do not remove, adeed for state synchronization, value not used
|
|
@@ -42963,8 +42964,17 @@ var Neurosity = (function (exports) {
|
|
|
42963
42964
|
// implementation that used the server timestamp had bug where SDK clients
|
|
42964
42965
|
// running on hardware with drifted/out-of-sync clocks (cough cough Android)
|
|
42965
42966
|
// would override the state to offline when the heartbeat was active.
|
|
42966
|
-
const
|
|
42967
|
-
|
|
42967
|
+
const lostLocalHeartbeat = Date.now() - lastLocalHeartbeat > LOST_LOCAL_HEARTBEAT_AFTER;
|
|
42968
|
+
if (lostLocalHeartbeat) {
|
|
42969
|
+
return true;
|
|
42970
|
+
}
|
|
42971
|
+
// Addresses devices with wrongful "online" state. This rarely happens, the
|
|
42972
|
+
// OS would have to crash without updating the state to "offline".
|
|
42973
|
+
const lostRemoteHeartbeat = Date.now() - status.lastHeartbeat > LOST_REMOTE_HEARTBEAT_AFTER;
|
|
42974
|
+
if (lostRemoteHeartbeat) {
|
|
42975
|
+
return true;
|
|
42976
|
+
}
|
|
42977
|
+
return false;
|
|
42968
42978
|
}
|
|
42969
42979
|
|
|
42970
42980
|
function filterInternalKeys() {
|
|
@@ -45694,23 +45704,2385 @@ var Neurosity = (function (exports) {
|
|
|
45694
45704
|
return Math.floor(100000 + Math.random() * 900000);
|
|
45695
45705
|
}
|
|
45696
45706
|
|
|
45697
|
-
function
|
|
45698
|
-
|
|
45699
|
-
|
|
45700
|
-
|
|
45701
|
-
|
|
45707
|
+
function createCommonjsModule(fn, module) {
|
|
45708
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
45709
|
+
}
|
|
45710
|
+
|
|
45711
|
+
var byteLength_1 = byteLength;
|
|
45712
|
+
var toByteArray_1 = toByteArray;
|
|
45713
|
+
var fromByteArray_1 = fromByteArray;
|
|
45714
|
+
|
|
45715
|
+
var lookup = [];
|
|
45716
|
+
var revLookup = [];
|
|
45717
|
+
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
|
|
45718
|
+
|
|
45719
|
+
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
45720
|
+
for (var i = 0, len = code.length; i < len; ++i) {
|
|
45721
|
+
lookup[i] = code[i];
|
|
45722
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
45723
|
+
}
|
|
45724
|
+
|
|
45725
|
+
// Support decoding URL-safe base64 strings, as Node.js does.
|
|
45726
|
+
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
45727
|
+
revLookup['-'.charCodeAt(0)] = 62;
|
|
45728
|
+
revLookup['_'.charCodeAt(0)] = 63;
|
|
45729
|
+
|
|
45730
|
+
function getLens (b64) {
|
|
45731
|
+
var len = b64.length;
|
|
45732
|
+
|
|
45733
|
+
if (len % 4 > 0) {
|
|
45734
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
45735
|
+
}
|
|
45736
|
+
|
|
45737
|
+
// Trim off extra bytes after placeholder bytes are found
|
|
45738
|
+
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
45739
|
+
var validLen = b64.indexOf('=');
|
|
45740
|
+
if (validLen === -1) validLen = len;
|
|
45741
|
+
|
|
45742
|
+
var placeHoldersLen = validLen === len
|
|
45743
|
+
? 0
|
|
45744
|
+
: 4 - (validLen % 4);
|
|
45745
|
+
|
|
45746
|
+
return [validLen, placeHoldersLen]
|
|
45747
|
+
}
|
|
45748
|
+
|
|
45749
|
+
// base64 is 4/3 + up to two characters of the original data
|
|
45750
|
+
function byteLength (b64) {
|
|
45751
|
+
var lens = getLens(b64);
|
|
45752
|
+
var validLen = lens[0];
|
|
45753
|
+
var placeHoldersLen = lens[1];
|
|
45754
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
45755
|
+
}
|
|
45756
|
+
|
|
45757
|
+
function _byteLength (b64, validLen, placeHoldersLen) {
|
|
45758
|
+
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
45759
|
+
}
|
|
45760
|
+
|
|
45761
|
+
function toByteArray (b64) {
|
|
45762
|
+
var tmp;
|
|
45763
|
+
var lens = getLens(b64);
|
|
45764
|
+
var validLen = lens[0];
|
|
45765
|
+
var placeHoldersLen = lens[1];
|
|
45766
|
+
|
|
45767
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
45768
|
+
|
|
45769
|
+
var curByte = 0;
|
|
45770
|
+
|
|
45771
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
|
45772
|
+
var len = placeHoldersLen > 0
|
|
45773
|
+
? validLen - 4
|
|
45774
|
+
: validLen;
|
|
45775
|
+
|
|
45776
|
+
var i;
|
|
45777
|
+
for (i = 0; i < len; i += 4) {
|
|
45778
|
+
tmp =
|
|
45779
|
+
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
45780
|
+
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
|
45781
|
+
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
|
45782
|
+
revLookup[b64.charCodeAt(i + 3)];
|
|
45783
|
+
arr[curByte++] = (tmp >> 16) & 0xFF;
|
|
45784
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
45785
|
+
arr[curByte++] = tmp & 0xFF;
|
|
45786
|
+
}
|
|
45787
|
+
|
|
45788
|
+
if (placeHoldersLen === 2) {
|
|
45789
|
+
tmp =
|
|
45790
|
+
(revLookup[b64.charCodeAt(i)] << 2) |
|
|
45791
|
+
(revLookup[b64.charCodeAt(i + 1)] >> 4);
|
|
45792
|
+
arr[curByte++] = tmp & 0xFF;
|
|
45793
|
+
}
|
|
45794
|
+
|
|
45795
|
+
if (placeHoldersLen === 1) {
|
|
45796
|
+
tmp =
|
|
45797
|
+
(revLookup[b64.charCodeAt(i)] << 10) |
|
|
45798
|
+
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
|
45799
|
+
(revLookup[b64.charCodeAt(i + 2)] >> 2);
|
|
45800
|
+
arr[curByte++] = (tmp >> 8) & 0xFF;
|
|
45801
|
+
arr[curByte++] = tmp & 0xFF;
|
|
45802
|
+
}
|
|
45803
|
+
|
|
45804
|
+
return arr
|
|
45805
|
+
}
|
|
45806
|
+
|
|
45807
|
+
function tripletToBase64 (num) {
|
|
45808
|
+
return lookup[num >> 18 & 0x3F] +
|
|
45809
|
+
lookup[num >> 12 & 0x3F] +
|
|
45810
|
+
lookup[num >> 6 & 0x3F] +
|
|
45811
|
+
lookup[num & 0x3F]
|
|
45812
|
+
}
|
|
45813
|
+
|
|
45814
|
+
function encodeChunk (uint8, start, end) {
|
|
45815
|
+
var tmp;
|
|
45816
|
+
var output = [];
|
|
45817
|
+
for (var i = start; i < end; i += 3) {
|
|
45818
|
+
tmp =
|
|
45819
|
+
((uint8[i] << 16) & 0xFF0000) +
|
|
45820
|
+
((uint8[i + 1] << 8) & 0xFF00) +
|
|
45821
|
+
(uint8[i + 2] & 0xFF);
|
|
45822
|
+
output.push(tripletToBase64(tmp));
|
|
45823
|
+
}
|
|
45824
|
+
return output.join('')
|
|
45825
|
+
}
|
|
45826
|
+
|
|
45827
|
+
function fromByteArray (uint8) {
|
|
45828
|
+
var tmp;
|
|
45829
|
+
var len = uint8.length;
|
|
45830
|
+
var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
|
45831
|
+
var parts = [];
|
|
45832
|
+
var maxChunkLength = 16383; // must be multiple of 3
|
|
45833
|
+
|
|
45834
|
+
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
45835
|
+
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
45836
|
+
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
|
|
45837
|
+
}
|
|
45838
|
+
|
|
45839
|
+
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
45840
|
+
if (extraBytes === 1) {
|
|
45841
|
+
tmp = uint8[len - 1];
|
|
45842
|
+
parts.push(
|
|
45843
|
+
lookup[tmp >> 2] +
|
|
45844
|
+
lookup[(tmp << 4) & 0x3F] +
|
|
45845
|
+
'=='
|
|
45846
|
+
);
|
|
45847
|
+
} else if (extraBytes === 2) {
|
|
45848
|
+
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
45849
|
+
parts.push(
|
|
45850
|
+
lookup[tmp >> 10] +
|
|
45851
|
+
lookup[(tmp >> 4) & 0x3F] +
|
|
45852
|
+
lookup[(tmp << 2) & 0x3F] +
|
|
45853
|
+
'='
|
|
45854
|
+
);
|
|
45855
|
+
}
|
|
45856
|
+
|
|
45857
|
+
return parts.join('')
|
|
45858
|
+
}
|
|
45859
|
+
|
|
45860
|
+
var base64Js = {
|
|
45861
|
+
byteLength: byteLength_1,
|
|
45862
|
+
toByteArray: toByteArray_1,
|
|
45863
|
+
fromByteArray: fromByteArray_1
|
|
45864
|
+
};
|
|
45865
|
+
|
|
45866
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
45867
|
+
var read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
45868
|
+
var e, m;
|
|
45869
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
45870
|
+
var eMax = (1 << eLen) - 1;
|
|
45871
|
+
var eBias = eMax >> 1;
|
|
45872
|
+
var nBits = -7;
|
|
45873
|
+
var i = isLE ? (nBytes - 1) : 0;
|
|
45874
|
+
var d = isLE ? -1 : 1;
|
|
45875
|
+
var s = buffer[offset + i];
|
|
45876
|
+
|
|
45877
|
+
i += d;
|
|
45878
|
+
|
|
45879
|
+
e = s & ((1 << (-nBits)) - 1);
|
|
45880
|
+
s >>= (-nBits);
|
|
45881
|
+
nBits += eLen;
|
|
45882
|
+
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
45883
|
+
|
|
45884
|
+
m = e & ((1 << (-nBits)) - 1);
|
|
45885
|
+
e >>= (-nBits);
|
|
45886
|
+
nBits += mLen;
|
|
45887
|
+
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
|
45888
|
+
|
|
45889
|
+
if (e === 0) {
|
|
45890
|
+
e = 1 - eBias;
|
|
45891
|
+
} else if (e === eMax) {
|
|
45892
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
45893
|
+
} else {
|
|
45894
|
+
m = m + Math.pow(2, mLen);
|
|
45895
|
+
e = e - eBias;
|
|
45896
|
+
}
|
|
45897
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
45898
|
+
};
|
|
45899
|
+
|
|
45900
|
+
var write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
45901
|
+
var e, m, c;
|
|
45902
|
+
var eLen = (nBytes * 8) - mLen - 1;
|
|
45903
|
+
var eMax = (1 << eLen) - 1;
|
|
45904
|
+
var eBias = eMax >> 1;
|
|
45905
|
+
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
|
|
45906
|
+
var i = isLE ? 0 : (nBytes - 1);
|
|
45907
|
+
var d = isLE ? 1 : -1;
|
|
45908
|
+
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
45909
|
+
|
|
45910
|
+
value = Math.abs(value);
|
|
45911
|
+
|
|
45912
|
+
if (isNaN(value) || value === Infinity) {
|
|
45913
|
+
m = isNaN(value) ? 1 : 0;
|
|
45914
|
+
e = eMax;
|
|
45915
|
+
} else {
|
|
45916
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
45917
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
45918
|
+
e--;
|
|
45919
|
+
c *= 2;
|
|
45920
|
+
}
|
|
45921
|
+
if (e + eBias >= 1) {
|
|
45922
|
+
value += rt / c;
|
|
45923
|
+
} else {
|
|
45924
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
45925
|
+
}
|
|
45926
|
+
if (value * c >= 2) {
|
|
45927
|
+
e++;
|
|
45928
|
+
c /= 2;
|
|
45929
|
+
}
|
|
45930
|
+
|
|
45931
|
+
if (e + eBias >= eMax) {
|
|
45932
|
+
m = 0;
|
|
45933
|
+
e = eMax;
|
|
45934
|
+
} else if (e + eBias >= 1) {
|
|
45935
|
+
m = ((value * c) - 1) * Math.pow(2, mLen);
|
|
45936
|
+
e = e + eBias;
|
|
45937
|
+
} else {
|
|
45938
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
45939
|
+
e = 0;
|
|
45940
|
+
}
|
|
45941
|
+
}
|
|
45942
|
+
|
|
45943
|
+
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
45944
|
+
|
|
45945
|
+
e = (e << mLen) | m;
|
|
45946
|
+
eLen += mLen;
|
|
45947
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
45948
|
+
|
|
45949
|
+
buffer[offset + i - d] |= s * 128;
|
|
45950
|
+
};
|
|
45951
|
+
|
|
45952
|
+
var ieee754 = {
|
|
45953
|
+
read: read,
|
|
45954
|
+
write: write
|
|
45955
|
+
};
|
|
45956
|
+
|
|
45957
|
+
var buffer$1 = createCommonjsModule(function (module, exports) {
|
|
45958
|
+
/*!
|
|
45959
|
+
* The buffer module from node.js, for the browser.
|
|
45960
|
+
*
|
|
45961
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
45962
|
+
* @license MIT
|
|
45963
|
+
*/
|
|
45964
|
+
/* eslint-disable no-proto */
|
|
45965
|
+
|
|
45966
|
+
console.log("********* buffer start *********");
|
|
45967
|
+
|
|
45968
|
+
|
|
45969
|
+
|
|
45970
|
+
const customInspectSymbol =
|
|
45971
|
+
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
45972
|
+
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
45973
|
+
: null;
|
|
45974
|
+
|
|
45975
|
+
exports.Buffer = Buffer;
|
|
45976
|
+
exports.SlowBuffer = SlowBuffer;
|
|
45977
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
45978
|
+
|
|
45979
|
+
const K_MAX_LENGTH = 0x7fffffff;
|
|
45980
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
45981
|
+
|
|
45982
|
+
/**
|
|
45983
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
45984
|
+
* === true Use Uint8Array implementation (fastest)
|
|
45985
|
+
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
45986
|
+
* implementation (most compatible, even IE6)
|
|
45987
|
+
*
|
|
45988
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
45989
|
+
* Opera 11.6+, iOS 4.2+.
|
|
45990
|
+
*
|
|
45991
|
+
* We report that the browser does not support typed arrays if the are not subclassable
|
|
45992
|
+
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
45993
|
+
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
45994
|
+
* for __proto__ and has a buggy typed array implementation.
|
|
45995
|
+
*/
|
|
45996
|
+
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
45997
|
+
|
|
45998
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
45999
|
+
typeof console.error === 'function') {
|
|
46000
|
+
console.error(
|
|
46001
|
+
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
46002
|
+
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
46003
|
+
);
|
|
46004
|
+
}
|
|
46005
|
+
|
|
46006
|
+
function typedArraySupport () {
|
|
46007
|
+
// Can typed array instances can be augmented?
|
|
46008
|
+
try {
|
|
46009
|
+
const arr = new Uint8Array(1);
|
|
46010
|
+
const proto = { foo: function () { return 42 } };
|
|
46011
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
46012
|
+
Object.setPrototypeOf(arr, proto);
|
|
46013
|
+
return arr.foo() === 42
|
|
46014
|
+
} catch (e) {
|
|
46015
|
+
return false
|
|
46016
|
+
}
|
|
46017
|
+
}
|
|
46018
|
+
|
|
46019
|
+
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
46020
|
+
enumerable: true,
|
|
46021
|
+
get: function () {
|
|
46022
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
46023
|
+
return this.buffer
|
|
46024
|
+
}
|
|
46025
|
+
});
|
|
46026
|
+
|
|
46027
|
+
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
46028
|
+
enumerable: true,
|
|
46029
|
+
get: function () {
|
|
46030
|
+
if (!Buffer.isBuffer(this)) return undefined
|
|
46031
|
+
return this.byteOffset
|
|
46032
|
+
}
|
|
46033
|
+
});
|
|
46034
|
+
|
|
46035
|
+
function createBuffer (length) {
|
|
46036
|
+
if (length > K_MAX_LENGTH) {
|
|
46037
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
46038
|
+
}
|
|
46039
|
+
// Return an augmented `Uint8Array` instance
|
|
46040
|
+
const buf = new Uint8Array(length);
|
|
46041
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
46042
|
+
return buf
|
|
46043
|
+
}
|
|
46044
|
+
|
|
46045
|
+
/**
|
|
46046
|
+
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
46047
|
+
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
46048
|
+
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
46049
|
+
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
46050
|
+
* returns a single octet.
|
|
46051
|
+
*
|
|
46052
|
+
* The `Uint8Array` prototype remains unmodified.
|
|
46053
|
+
*/
|
|
46054
|
+
|
|
46055
|
+
function Buffer (arg, encodingOrOffset, length) {
|
|
46056
|
+
// Common case.
|
|
46057
|
+
if (typeof arg === 'number') {
|
|
46058
|
+
if (typeof encodingOrOffset === 'string') {
|
|
46059
|
+
throw new TypeError(
|
|
46060
|
+
'The "string" argument must be of type string. Received type number'
|
|
46061
|
+
)
|
|
46062
|
+
}
|
|
46063
|
+
return allocUnsafe(arg)
|
|
46064
|
+
}
|
|
46065
|
+
return from(arg, encodingOrOffset, length)
|
|
46066
|
+
}
|
|
46067
|
+
|
|
46068
|
+
Buffer.poolSize = 8192; // not used by this implementation
|
|
46069
|
+
|
|
46070
|
+
function from (value, encodingOrOffset, length) {
|
|
46071
|
+
if (typeof value === 'string') {
|
|
46072
|
+
return fromString(value, encodingOrOffset)
|
|
46073
|
+
}
|
|
46074
|
+
|
|
46075
|
+
if (ArrayBuffer.isView(value)) {
|
|
46076
|
+
return fromArrayView(value)
|
|
46077
|
+
}
|
|
46078
|
+
|
|
46079
|
+
if (value == null) {
|
|
46080
|
+
throw new TypeError(
|
|
46081
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
46082
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
46083
|
+
)
|
|
46084
|
+
}
|
|
46085
|
+
|
|
46086
|
+
if (isInstance(value, ArrayBuffer) ||
|
|
46087
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
46088
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
46089
|
+
}
|
|
46090
|
+
|
|
46091
|
+
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
46092
|
+
(isInstance(value, SharedArrayBuffer) ||
|
|
46093
|
+
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
46094
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
46095
|
+
}
|
|
46096
|
+
|
|
46097
|
+
console.log("********* buffer line 142 *********");
|
|
46098
|
+
|
|
46099
|
+
|
|
46100
|
+
if (typeof value === 'number') {
|
|
46101
|
+
throw new TypeError(
|
|
46102
|
+
'The "value" argument must not be of type number. Received type number'
|
|
46103
|
+
)
|
|
46104
|
+
}
|
|
46105
|
+
|
|
46106
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
46107
|
+
if (valueOf != null && valueOf !== value) {
|
|
46108
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
46109
|
+
}
|
|
46110
|
+
|
|
46111
|
+
const b = fromObject(value);
|
|
46112
|
+
if (b) return b
|
|
46113
|
+
|
|
46114
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
46115
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
|
46116
|
+
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
|
46117
|
+
}
|
|
46118
|
+
|
|
46119
|
+
throw new TypeError(
|
|
46120
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
46121
|
+
'or Array-like Object. Received type ' + (typeof value)
|
|
46122
|
+
)
|
|
46123
|
+
}
|
|
46124
|
+
|
|
46125
|
+
/**
|
|
46126
|
+
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
46127
|
+
* if value is a number.
|
|
46128
|
+
* Buffer.from(str[, encoding])
|
|
46129
|
+
* Buffer.from(array)
|
|
46130
|
+
* Buffer.from(buffer)
|
|
46131
|
+
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
46132
|
+
**/
|
|
46133
|
+
Buffer.from = function (value, encodingOrOffset, length) {
|
|
46134
|
+
return from(value, encodingOrOffset, length)
|
|
46135
|
+
};
|
|
46136
|
+
|
|
46137
|
+
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
46138
|
+
// https://github.com/feross/buffer/pull/148
|
|
46139
|
+
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
46140
|
+
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
46141
|
+
|
|
46142
|
+
function assertSize (size) {
|
|
46143
|
+
if (typeof size !== 'number') {
|
|
46144
|
+
throw new TypeError('"size" argument must be of type number')
|
|
46145
|
+
} else if (size < 0) {
|
|
46146
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
46147
|
+
}
|
|
46148
|
+
}
|
|
46149
|
+
|
|
46150
|
+
function alloc (size, fill, encoding) {
|
|
46151
|
+
assertSize(size);
|
|
46152
|
+
if (size <= 0) {
|
|
46153
|
+
return createBuffer(size)
|
|
46154
|
+
}
|
|
46155
|
+
if (fill !== undefined) {
|
|
46156
|
+
// Only pay attention to encoding if it's a string. This
|
|
46157
|
+
// prevents accidentally sending in a number that would
|
|
46158
|
+
// be interpreted as a start offset.
|
|
46159
|
+
return typeof encoding === 'string'
|
|
46160
|
+
? createBuffer(size).fill(fill, encoding)
|
|
46161
|
+
: createBuffer(size).fill(fill)
|
|
46162
|
+
}
|
|
46163
|
+
return createBuffer(size)
|
|
46164
|
+
}
|
|
46165
|
+
|
|
46166
|
+
/**
|
|
46167
|
+
* Creates a new filled Buffer instance.
|
|
46168
|
+
* alloc(size[, fill[, encoding]])
|
|
46169
|
+
**/
|
|
46170
|
+
Buffer.alloc = function (size, fill, encoding) {
|
|
46171
|
+
return alloc(size, fill, encoding)
|
|
46172
|
+
};
|
|
46173
|
+
|
|
46174
|
+
function allocUnsafe (size) {
|
|
46175
|
+
assertSize(size);
|
|
46176
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
46177
|
+
}
|
|
46178
|
+
|
|
46179
|
+
/**
|
|
46180
|
+
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
46181
|
+
* */
|
|
46182
|
+
Buffer.allocUnsafe = function (size) {
|
|
46183
|
+
return allocUnsafe(size)
|
|
46184
|
+
};
|
|
46185
|
+
/**
|
|
46186
|
+
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
46187
|
+
*/
|
|
46188
|
+
Buffer.allocUnsafeSlow = function (size) {
|
|
46189
|
+
return allocUnsafe(size)
|
|
46190
|
+
};
|
|
46191
|
+
|
|
46192
|
+
function fromString (string, encoding) {
|
|
46193
|
+
if (typeof encoding !== 'string' || encoding === '') {
|
|
46194
|
+
encoding = 'utf8';
|
|
46195
|
+
}
|
|
46196
|
+
|
|
46197
|
+
if (!Buffer.isEncoding(encoding)) {
|
|
46198
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
46199
|
+
}
|
|
46200
|
+
|
|
46201
|
+
const length = byteLength(string, encoding) | 0;
|
|
46202
|
+
let buf = createBuffer(length);
|
|
46203
|
+
|
|
46204
|
+
const actual = buf.write(string, encoding);
|
|
46205
|
+
|
|
46206
|
+
if (actual !== length) {
|
|
46207
|
+
// Writing a hex string, for example, that contains invalid characters will
|
|
46208
|
+
// cause everything after the first invalid character to be ignored. (e.g.
|
|
46209
|
+
// 'abxxcd' will be treated as 'ab')
|
|
46210
|
+
buf = buf.slice(0, actual);
|
|
46211
|
+
}
|
|
46212
|
+
|
|
46213
|
+
return buf
|
|
46214
|
+
}
|
|
46215
|
+
|
|
46216
|
+
function fromArrayLike (array) {
|
|
46217
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
46218
|
+
const buf = createBuffer(length);
|
|
46219
|
+
for (let i = 0; i < length; i += 1) {
|
|
46220
|
+
buf[i] = array[i] & 255;
|
|
46221
|
+
}
|
|
46222
|
+
return buf
|
|
46223
|
+
}
|
|
46224
|
+
|
|
46225
|
+
function fromArrayView (arrayView) {
|
|
46226
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
46227
|
+
const copy = new Uint8Array(arrayView);
|
|
46228
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
46229
|
+
}
|
|
46230
|
+
return fromArrayLike(arrayView)
|
|
46231
|
+
}
|
|
46232
|
+
|
|
46233
|
+
function fromArrayBuffer (array, byteOffset, length) {
|
|
46234
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
46235
|
+
throw new RangeError('"offset" is outside of buffer bounds')
|
|
46236
|
+
}
|
|
46237
|
+
|
|
46238
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
46239
|
+
throw new RangeError('"length" is outside of buffer bounds')
|
|
46240
|
+
}
|
|
46241
|
+
|
|
46242
|
+
let buf;
|
|
46243
|
+
if (byteOffset === undefined && length === undefined) {
|
|
46244
|
+
buf = new Uint8Array(array);
|
|
46245
|
+
} else if (length === undefined) {
|
|
46246
|
+
buf = new Uint8Array(array, byteOffset);
|
|
46247
|
+
} else {
|
|
46248
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
46249
|
+
}
|
|
46250
|
+
|
|
46251
|
+
// Return an augmented `Uint8Array` instance
|
|
46252
|
+
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
46253
|
+
|
|
46254
|
+
return buf
|
|
46255
|
+
}
|
|
46256
|
+
|
|
46257
|
+
function fromObject (obj) {
|
|
46258
|
+
if (Buffer.isBuffer(obj)) {
|
|
46259
|
+
const len = checked(obj.length) | 0;
|
|
46260
|
+
const buf = createBuffer(len);
|
|
46261
|
+
|
|
46262
|
+
if (buf.length === 0) {
|
|
46263
|
+
return buf
|
|
46264
|
+
}
|
|
46265
|
+
|
|
46266
|
+
obj.copy(buf, 0, 0, len);
|
|
46267
|
+
return buf
|
|
46268
|
+
}
|
|
46269
|
+
|
|
46270
|
+
if (obj.length !== undefined) {
|
|
46271
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
46272
|
+
return createBuffer(0)
|
|
46273
|
+
}
|
|
46274
|
+
return fromArrayLike(obj)
|
|
46275
|
+
}
|
|
46276
|
+
|
|
46277
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
46278
|
+
return fromArrayLike(obj.data)
|
|
46279
|
+
}
|
|
46280
|
+
}
|
|
46281
|
+
|
|
46282
|
+
console.log("********* buffer line 327 *********");
|
|
46283
|
+
|
|
46284
|
+
|
|
46285
|
+
function checked (length) {
|
|
46286
|
+
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
46287
|
+
// length is NaN (which is otherwise coerced to zero.)
|
|
46288
|
+
if (length >= K_MAX_LENGTH) {
|
|
46289
|
+
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
46290
|
+
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
46291
|
+
}
|
|
46292
|
+
return length | 0
|
|
46293
|
+
}
|
|
46294
|
+
|
|
46295
|
+
function SlowBuffer (length) {
|
|
46296
|
+
if (+length != length) { // eslint-disable-line eqeqeq
|
|
46297
|
+
length = 0;
|
|
46298
|
+
}
|
|
46299
|
+
return Buffer.alloc(+length)
|
|
46300
|
+
}
|
|
46301
|
+
|
|
46302
|
+
Buffer.isBuffer = function isBuffer (b) {
|
|
46303
|
+
return b != null && b._isBuffer === true &&
|
|
46304
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
46305
|
+
};
|
|
46306
|
+
|
|
46307
|
+
Buffer.compare = function compare (a, b) {
|
|
46308
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
46309
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
46310
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
46311
|
+
throw new TypeError(
|
|
46312
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
46313
|
+
)
|
|
46314
|
+
}
|
|
46315
|
+
|
|
46316
|
+
if (a === b) return 0
|
|
46317
|
+
|
|
46318
|
+
let x = a.length;
|
|
46319
|
+
let y = b.length;
|
|
46320
|
+
|
|
46321
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
46322
|
+
if (a[i] !== b[i]) {
|
|
46323
|
+
x = a[i];
|
|
46324
|
+
y = b[i];
|
|
46325
|
+
break
|
|
46326
|
+
}
|
|
46327
|
+
}
|
|
46328
|
+
|
|
46329
|
+
if (x < y) return -1
|
|
46330
|
+
if (y < x) return 1
|
|
46331
|
+
return 0
|
|
46332
|
+
};
|
|
46333
|
+
|
|
46334
|
+
Buffer.isEncoding = function isEncoding (encoding) {
|
|
46335
|
+
switch (String(encoding).toLowerCase()) {
|
|
46336
|
+
case 'hex':
|
|
46337
|
+
case 'utf8':
|
|
46338
|
+
case 'utf-8':
|
|
46339
|
+
case 'ascii':
|
|
46340
|
+
case 'latin1':
|
|
46341
|
+
case 'binary':
|
|
46342
|
+
case 'base64':
|
|
46343
|
+
case 'ucs2':
|
|
46344
|
+
case 'ucs-2':
|
|
46345
|
+
case 'utf16le':
|
|
46346
|
+
case 'utf-16le':
|
|
46347
|
+
return true
|
|
46348
|
+
default:
|
|
46349
|
+
return false
|
|
46350
|
+
}
|
|
46351
|
+
};
|
|
46352
|
+
|
|
46353
|
+
Buffer.concat = function concat (list, length) {
|
|
46354
|
+
if (!Array.isArray(list)) {
|
|
46355
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
46356
|
+
}
|
|
46357
|
+
|
|
46358
|
+
if (list.length === 0) {
|
|
46359
|
+
return Buffer.alloc(0)
|
|
46360
|
+
}
|
|
46361
|
+
|
|
46362
|
+
let i;
|
|
46363
|
+
if (length === undefined) {
|
|
46364
|
+
length = 0;
|
|
46365
|
+
for (i = 0; i < list.length; ++i) {
|
|
46366
|
+
length += list[i].length;
|
|
46367
|
+
}
|
|
46368
|
+
}
|
|
46369
|
+
|
|
46370
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
46371
|
+
let pos = 0;
|
|
46372
|
+
for (i = 0; i < list.length; ++i) {
|
|
46373
|
+
let buf = list[i];
|
|
46374
|
+
if (isInstance(buf, Uint8Array)) {
|
|
46375
|
+
if (pos + buf.length > buffer.length) {
|
|
46376
|
+
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
|
|
46377
|
+
buf.copy(buffer, pos);
|
|
46378
|
+
} else {
|
|
46379
|
+
Uint8Array.prototype.set.call(
|
|
46380
|
+
buffer,
|
|
46381
|
+
buf,
|
|
46382
|
+
pos
|
|
46383
|
+
);
|
|
46384
|
+
}
|
|
46385
|
+
} else if (!Buffer.isBuffer(buf)) {
|
|
46386
|
+
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
46387
|
+
} else {
|
|
46388
|
+
buf.copy(buffer, pos);
|
|
46389
|
+
}
|
|
46390
|
+
pos += buf.length;
|
|
46391
|
+
}
|
|
46392
|
+
return buffer
|
|
46393
|
+
};
|
|
46394
|
+
|
|
46395
|
+
console.log("********* buffer line 440 *********");
|
|
46396
|
+
|
|
46397
|
+
|
|
46398
|
+
function byteLength (string, encoding) {
|
|
46399
|
+
if (Buffer.isBuffer(string)) {
|
|
46400
|
+
return string.length
|
|
46401
|
+
}
|
|
46402
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
46403
|
+
return string.byteLength
|
|
46404
|
+
}
|
|
46405
|
+
if (typeof string !== 'string') {
|
|
46406
|
+
throw new TypeError(
|
|
46407
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
46408
|
+
'Received type ' + typeof string
|
|
46409
|
+
)
|
|
46410
|
+
}
|
|
46411
|
+
|
|
46412
|
+
const len = string.length;
|
|
46413
|
+
const mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
46414
|
+
if (!mustMatch && len === 0) return 0
|
|
46415
|
+
|
|
46416
|
+
// Use a for loop to avoid recursion
|
|
46417
|
+
let loweredCase = false;
|
|
46418
|
+
for (;;) {
|
|
46419
|
+
switch (encoding) {
|
|
46420
|
+
case 'ascii':
|
|
46421
|
+
case 'latin1':
|
|
46422
|
+
case 'binary':
|
|
46423
|
+
return len
|
|
46424
|
+
case 'utf8':
|
|
46425
|
+
case 'utf-8':
|
|
46426
|
+
return utf8ToBytes(string).length
|
|
46427
|
+
case 'ucs2':
|
|
46428
|
+
case 'ucs-2':
|
|
46429
|
+
case 'utf16le':
|
|
46430
|
+
case 'utf-16le':
|
|
46431
|
+
return len * 2
|
|
46432
|
+
case 'hex':
|
|
46433
|
+
return len >>> 1
|
|
46434
|
+
case 'base64':
|
|
46435
|
+
return base64ToBytes(string).length
|
|
46436
|
+
default:
|
|
46437
|
+
if (loweredCase) {
|
|
46438
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
45702
46439
|
}
|
|
45703
|
-
|
|
45704
|
-
|
|
46440
|
+
encoding = ('' + encoding).toLowerCase();
|
|
46441
|
+
loweredCase = true;
|
|
46442
|
+
}
|
|
46443
|
+
}
|
|
46444
|
+
}
|
|
46445
|
+
Buffer.byteLength = byteLength;
|
|
46446
|
+
|
|
46447
|
+
function slowToString (encoding, start, end) {
|
|
46448
|
+
let loweredCase = false;
|
|
46449
|
+
|
|
46450
|
+
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
46451
|
+
// property of a typed array.
|
|
46452
|
+
|
|
46453
|
+
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
46454
|
+
// to their upper/lower bounds if the value passed is out of range.
|
|
46455
|
+
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
46456
|
+
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
46457
|
+
if (start === undefined || start < 0) {
|
|
46458
|
+
start = 0;
|
|
46459
|
+
}
|
|
46460
|
+
// Return early if start > this.length. Done here to prevent potential uint32
|
|
46461
|
+
// coercion fail below.
|
|
46462
|
+
if (start > this.length) {
|
|
46463
|
+
return ''
|
|
46464
|
+
}
|
|
46465
|
+
|
|
46466
|
+
if (end === undefined || end > this.length) {
|
|
46467
|
+
end = this.length;
|
|
46468
|
+
}
|
|
46469
|
+
|
|
46470
|
+
if (end <= 0) {
|
|
46471
|
+
return ''
|
|
46472
|
+
}
|
|
46473
|
+
|
|
46474
|
+
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
46475
|
+
end >>>= 0;
|
|
46476
|
+
start >>>= 0;
|
|
46477
|
+
|
|
46478
|
+
if (end <= start) {
|
|
46479
|
+
return ''
|
|
46480
|
+
}
|
|
46481
|
+
|
|
46482
|
+
if (!encoding) encoding = 'utf8';
|
|
46483
|
+
|
|
46484
|
+
while (true) {
|
|
46485
|
+
switch (encoding) {
|
|
46486
|
+
case 'hex':
|
|
46487
|
+
return hexSlice(this, start, end)
|
|
46488
|
+
|
|
46489
|
+
case 'utf8':
|
|
46490
|
+
case 'utf-8':
|
|
46491
|
+
return utf8Slice(this, start, end)
|
|
46492
|
+
|
|
46493
|
+
case 'ascii':
|
|
46494
|
+
return asciiSlice(this, start, end)
|
|
46495
|
+
|
|
46496
|
+
case 'latin1':
|
|
46497
|
+
case 'binary':
|
|
46498
|
+
return latin1Slice(this, start, end)
|
|
46499
|
+
|
|
46500
|
+
case 'base64':
|
|
46501
|
+
return base64Slice(this, start, end)
|
|
46502
|
+
|
|
46503
|
+
case 'ucs2':
|
|
46504
|
+
case 'ucs-2':
|
|
46505
|
+
case 'utf16le':
|
|
46506
|
+
case 'utf-16le':
|
|
46507
|
+
return utf16leSlice(this, start, end)
|
|
46508
|
+
|
|
46509
|
+
default:
|
|
46510
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
46511
|
+
encoding = (encoding + '').toLowerCase();
|
|
46512
|
+
loweredCase = true;
|
|
46513
|
+
}
|
|
46514
|
+
}
|
|
46515
|
+
}
|
|
46516
|
+
|
|
46517
|
+
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
46518
|
+
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
46519
|
+
// reliably in a browserify context because there could be multiple different
|
|
46520
|
+
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
46521
|
+
// instances that were created from another copy of the `buffer` package.
|
|
46522
|
+
// See: https://github.com/feross/buffer/issues/154
|
|
46523
|
+
Buffer.prototype._isBuffer = true;
|
|
46524
|
+
|
|
46525
|
+
function swap (b, n, m) {
|
|
46526
|
+
const i = b[n];
|
|
46527
|
+
b[n] = b[m];
|
|
46528
|
+
b[m] = i;
|
|
46529
|
+
}
|
|
46530
|
+
|
|
46531
|
+
Buffer.prototype.swap16 = function swap16 () {
|
|
46532
|
+
const len = this.length;
|
|
46533
|
+
if (len % 2 !== 0) {
|
|
46534
|
+
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
46535
|
+
}
|
|
46536
|
+
for (let i = 0; i < len; i += 2) {
|
|
46537
|
+
swap(this, i, i + 1);
|
|
46538
|
+
}
|
|
46539
|
+
return this
|
|
46540
|
+
};
|
|
46541
|
+
|
|
46542
|
+
Buffer.prototype.swap32 = function swap32 () {
|
|
46543
|
+
const len = this.length;
|
|
46544
|
+
if (len % 4 !== 0) {
|
|
46545
|
+
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
46546
|
+
}
|
|
46547
|
+
for (let i = 0; i < len; i += 4) {
|
|
46548
|
+
swap(this, i, i + 3);
|
|
46549
|
+
swap(this, i + 1, i + 2);
|
|
46550
|
+
}
|
|
46551
|
+
return this
|
|
46552
|
+
};
|
|
46553
|
+
|
|
46554
|
+
Buffer.prototype.swap64 = function swap64 () {
|
|
46555
|
+
const len = this.length;
|
|
46556
|
+
if (len % 8 !== 0) {
|
|
46557
|
+
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
46558
|
+
}
|
|
46559
|
+
for (let i = 0; i < len; i += 8) {
|
|
46560
|
+
swap(this, i, i + 7);
|
|
46561
|
+
swap(this, i + 1, i + 6);
|
|
46562
|
+
swap(this, i + 2, i + 5);
|
|
46563
|
+
swap(this, i + 3, i + 4);
|
|
46564
|
+
}
|
|
46565
|
+
return this
|
|
46566
|
+
};
|
|
46567
|
+
|
|
46568
|
+
Buffer.prototype.toString = function toString () {
|
|
46569
|
+
const length = this.length;
|
|
46570
|
+
if (length === 0) return ''
|
|
46571
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
46572
|
+
return slowToString.apply(this, arguments)
|
|
46573
|
+
};
|
|
46574
|
+
|
|
46575
|
+
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
46576
|
+
|
|
46577
|
+
Buffer.prototype.equals = function equals (b) {
|
|
46578
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
46579
|
+
if (this === b) return true
|
|
46580
|
+
return Buffer.compare(this, b) === 0
|
|
46581
|
+
};
|
|
46582
|
+
|
|
46583
|
+
Buffer.prototype.inspect = function inspect () {
|
|
46584
|
+
let str = '';
|
|
46585
|
+
const max = exports.INSPECT_MAX_BYTES;
|
|
46586
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
46587
|
+
if (this.length > max) str += ' ... ';
|
|
46588
|
+
return '<Buffer ' + str + '>'
|
|
46589
|
+
};
|
|
46590
|
+
if (customInspectSymbol) {
|
|
46591
|
+
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
46592
|
+
}
|
|
46593
|
+
|
|
46594
|
+
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
46595
|
+
if (isInstance(target, Uint8Array)) {
|
|
46596
|
+
target = Buffer.from(target, target.offset, target.byteLength);
|
|
46597
|
+
}
|
|
46598
|
+
if (!Buffer.isBuffer(target)) {
|
|
46599
|
+
throw new TypeError(
|
|
46600
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
46601
|
+
'Received type ' + (typeof target)
|
|
46602
|
+
)
|
|
46603
|
+
}
|
|
46604
|
+
|
|
46605
|
+
if (start === undefined) {
|
|
46606
|
+
start = 0;
|
|
46607
|
+
}
|
|
46608
|
+
if (end === undefined) {
|
|
46609
|
+
end = target ? target.length : 0;
|
|
46610
|
+
}
|
|
46611
|
+
if (thisStart === undefined) {
|
|
46612
|
+
thisStart = 0;
|
|
46613
|
+
}
|
|
46614
|
+
if (thisEnd === undefined) {
|
|
46615
|
+
thisEnd = this.length;
|
|
46616
|
+
}
|
|
46617
|
+
|
|
46618
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
46619
|
+
throw new RangeError('out of range index')
|
|
46620
|
+
}
|
|
46621
|
+
|
|
46622
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
46623
|
+
return 0
|
|
46624
|
+
}
|
|
46625
|
+
if (thisStart >= thisEnd) {
|
|
46626
|
+
return -1
|
|
46627
|
+
}
|
|
46628
|
+
if (start >= end) {
|
|
46629
|
+
return 1
|
|
46630
|
+
}
|
|
46631
|
+
|
|
46632
|
+
start >>>= 0;
|
|
46633
|
+
end >>>= 0;
|
|
46634
|
+
thisStart >>>= 0;
|
|
46635
|
+
thisEnd >>>= 0;
|
|
46636
|
+
|
|
46637
|
+
if (this === target) return 0
|
|
46638
|
+
|
|
46639
|
+
let x = thisEnd - thisStart;
|
|
46640
|
+
let y = end - start;
|
|
46641
|
+
const len = Math.min(x, y);
|
|
46642
|
+
|
|
46643
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
46644
|
+
const targetCopy = target.slice(start, end);
|
|
46645
|
+
|
|
46646
|
+
for (let i = 0; i < len; ++i) {
|
|
46647
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
46648
|
+
x = thisCopy[i];
|
|
46649
|
+
y = targetCopy[i];
|
|
46650
|
+
break
|
|
46651
|
+
}
|
|
46652
|
+
}
|
|
46653
|
+
|
|
46654
|
+
if (x < y) return -1
|
|
46655
|
+
if (y < x) return 1
|
|
46656
|
+
return 0
|
|
46657
|
+
};
|
|
46658
|
+
|
|
46659
|
+
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
46660
|
+
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
46661
|
+
//
|
|
46662
|
+
// Arguments:
|
|
46663
|
+
// - buffer - a Buffer to search
|
|
46664
|
+
// - val - a string, Buffer, or number
|
|
46665
|
+
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
46666
|
+
// - encoding - an optional encoding, relevant is val is a string
|
|
46667
|
+
// - dir - true for indexOf, false for lastIndexOf
|
|
46668
|
+
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
46669
|
+
// Empty buffer means no match
|
|
46670
|
+
if (buffer.length === 0) return -1
|
|
46671
|
+
|
|
46672
|
+
// Normalize byteOffset
|
|
46673
|
+
if (typeof byteOffset === 'string') {
|
|
46674
|
+
encoding = byteOffset;
|
|
46675
|
+
byteOffset = 0;
|
|
46676
|
+
} else if (byteOffset > 0x7fffffff) {
|
|
46677
|
+
byteOffset = 0x7fffffff;
|
|
46678
|
+
} else if (byteOffset < -0x80000000) {
|
|
46679
|
+
byteOffset = -0x80000000;
|
|
46680
|
+
}
|
|
46681
|
+
byteOffset = +byteOffset; // Coerce to Number.
|
|
46682
|
+
if (numberIsNaN(byteOffset)) {
|
|
46683
|
+
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
46684
|
+
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
46685
|
+
}
|
|
46686
|
+
|
|
46687
|
+
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
46688
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
46689
|
+
if (byteOffset >= buffer.length) {
|
|
46690
|
+
if (dir) return -1
|
|
46691
|
+
else byteOffset = buffer.length - 1;
|
|
46692
|
+
} else if (byteOffset < 0) {
|
|
46693
|
+
if (dir) byteOffset = 0;
|
|
46694
|
+
else return -1
|
|
46695
|
+
}
|
|
46696
|
+
|
|
46697
|
+
// Normalize val
|
|
46698
|
+
if (typeof val === 'string') {
|
|
46699
|
+
val = Buffer.from(val, encoding);
|
|
46700
|
+
}
|
|
46701
|
+
|
|
46702
|
+
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
46703
|
+
if (Buffer.isBuffer(val)) {
|
|
46704
|
+
// Special case: looking for empty string/buffer always fails
|
|
46705
|
+
if (val.length === 0) {
|
|
46706
|
+
return -1
|
|
46707
|
+
}
|
|
46708
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
46709
|
+
} else if (typeof val === 'number') {
|
|
46710
|
+
val = val & 0xFF; // Search for a byte value [0-255]
|
|
46711
|
+
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
46712
|
+
if (dir) {
|
|
46713
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
46714
|
+
} else {
|
|
46715
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
46716
|
+
}
|
|
46717
|
+
}
|
|
46718
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
46719
|
+
}
|
|
46720
|
+
|
|
46721
|
+
throw new TypeError('val must be string, number or Buffer')
|
|
46722
|
+
}
|
|
46723
|
+
|
|
46724
|
+
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
46725
|
+
let indexSize = 1;
|
|
46726
|
+
let arrLength = arr.length;
|
|
46727
|
+
let valLength = val.length;
|
|
46728
|
+
|
|
46729
|
+
if (encoding !== undefined) {
|
|
46730
|
+
encoding = String(encoding).toLowerCase();
|
|
46731
|
+
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
46732
|
+
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
46733
|
+
if (arr.length < 2 || val.length < 2) {
|
|
46734
|
+
return -1
|
|
46735
|
+
}
|
|
46736
|
+
indexSize = 2;
|
|
46737
|
+
arrLength /= 2;
|
|
46738
|
+
valLength /= 2;
|
|
46739
|
+
byteOffset /= 2;
|
|
46740
|
+
}
|
|
46741
|
+
}
|
|
46742
|
+
|
|
46743
|
+
function read (buf, i) {
|
|
46744
|
+
if (indexSize === 1) {
|
|
46745
|
+
return buf[i]
|
|
46746
|
+
} else {
|
|
46747
|
+
return buf.readUInt16BE(i * indexSize)
|
|
46748
|
+
}
|
|
46749
|
+
}
|
|
46750
|
+
|
|
46751
|
+
let i;
|
|
46752
|
+
if (dir) {
|
|
46753
|
+
let foundIndex = -1;
|
|
46754
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
46755
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
46756
|
+
if (foundIndex === -1) foundIndex = i;
|
|
46757
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
46758
|
+
} else {
|
|
46759
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
46760
|
+
foundIndex = -1;
|
|
46761
|
+
}
|
|
46762
|
+
}
|
|
46763
|
+
} else {
|
|
46764
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
46765
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
46766
|
+
let found = true;
|
|
46767
|
+
for (let j = 0; j < valLength; j++) {
|
|
46768
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
46769
|
+
found = false;
|
|
46770
|
+
break
|
|
45705
46771
|
}
|
|
45706
|
-
|
|
45707
|
-
|
|
45708
|
-
|
|
45709
|
-
|
|
45710
|
-
|
|
45711
|
-
|
|
46772
|
+
}
|
|
46773
|
+
if (found) return i
|
|
46774
|
+
}
|
|
46775
|
+
}
|
|
46776
|
+
|
|
46777
|
+
return -1
|
|
46778
|
+
}
|
|
46779
|
+
|
|
46780
|
+
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
46781
|
+
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
46782
|
+
};
|
|
46783
|
+
|
|
46784
|
+
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
46785
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
46786
|
+
};
|
|
46787
|
+
|
|
46788
|
+
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
46789
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
46790
|
+
};
|
|
46791
|
+
|
|
46792
|
+
function hexWrite (buf, string, offset, length) {
|
|
46793
|
+
offset = Number(offset) || 0;
|
|
46794
|
+
const remaining = buf.length - offset;
|
|
46795
|
+
if (!length) {
|
|
46796
|
+
length = remaining;
|
|
46797
|
+
} else {
|
|
46798
|
+
length = Number(length);
|
|
46799
|
+
if (length > remaining) {
|
|
46800
|
+
length = remaining;
|
|
46801
|
+
}
|
|
46802
|
+
}
|
|
46803
|
+
|
|
46804
|
+
const strLen = string.length;
|
|
46805
|
+
|
|
46806
|
+
if (length > strLen / 2) {
|
|
46807
|
+
length = strLen / 2;
|
|
46808
|
+
}
|
|
46809
|
+
let i;
|
|
46810
|
+
for (i = 0; i < length; ++i) {
|
|
46811
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
46812
|
+
if (numberIsNaN(parsed)) return i
|
|
46813
|
+
buf[offset + i] = parsed;
|
|
46814
|
+
}
|
|
46815
|
+
return i
|
|
46816
|
+
}
|
|
46817
|
+
|
|
46818
|
+
function utf8Write (buf, string, offset, length) {
|
|
46819
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
45712
46820
|
}
|
|
45713
46821
|
|
|
46822
|
+
function asciiWrite (buf, string, offset, length) {
|
|
46823
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
46824
|
+
}
|
|
46825
|
+
|
|
46826
|
+
function base64Write (buf, string, offset, length) {
|
|
46827
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
46828
|
+
}
|
|
46829
|
+
|
|
46830
|
+
function ucs2Write (buf, string, offset, length) {
|
|
46831
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
46832
|
+
}
|
|
46833
|
+
|
|
46834
|
+
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
46835
|
+
// Buffer#write(string)
|
|
46836
|
+
if (offset === undefined) {
|
|
46837
|
+
encoding = 'utf8';
|
|
46838
|
+
length = this.length;
|
|
46839
|
+
offset = 0;
|
|
46840
|
+
// Buffer#write(string, encoding)
|
|
46841
|
+
} else if (length === undefined && typeof offset === 'string') {
|
|
46842
|
+
encoding = offset;
|
|
46843
|
+
length = this.length;
|
|
46844
|
+
offset = 0;
|
|
46845
|
+
// Buffer#write(string, offset[, length][, encoding])
|
|
46846
|
+
} else if (isFinite(offset)) {
|
|
46847
|
+
offset = offset >>> 0;
|
|
46848
|
+
if (isFinite(length)) {
|
|
46849
|
+
length = length >>> 0;
|
|
46850
|
+
if (encoding === undefined) encoding = 'utf8';
|
|
46851
|
+
} else {
|
|
46852
|
+
encoding = length;
|
|
46853
|
+
length = undefined;
|
|
46854
|
+
}
|
|
46855
|
+
} else {
|
|
46856
|
+
throw new Error(
|
|
46857
|
+
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
46858
|
+
)
|
|
46859
|
+
}
|
|
46860
|
+
|
|
46861
|
+
const remaining = this.length - offset;
|
|
46862
|
+
if (length === undefined || length > remaining) length = remaining;
|
|
46863
|
+
|
|
46864
|
+
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
46865
|
+
throw new RangeError('Attempt to write outside buffer bounds')
|
|
46866
|
+
}
|
|
46867
|
+
|
|
46868
|
+
if (!encoding) encoding = 'utf8';
|
|
46869
|
+
|
|
46870
|
+
let loweredCase = false;
|
|
46871
|
+
for (;;) {
|
|
46872
|
+
switch (encoding) {
|
|
46873
|
+
case 'hex':
|
|
46874
|
+
return hexWrite(this, string, offset, length)
|
|
46875
|
+
|
|
46876
|
+
case 'utf8':
|
|
46877
|
+
case 'utf-8':
|
|
46878
|
+
return utf8Write(this, string, offset, length)
|
|
46879
|
+
|
|
46880
|
+
case 'ascii':
|
|
46881
|
+
case 'latin1':
|
|
46882
|
+
case 'binary':
|
|
46883
|
+
return asciiWrite(this, string, offset, length)
|
|
46884
|
+
|
|
46885
|
+
case 'base64':
|
|
46886
|
+
// Warning: maxLength not taken into account in base64Write
|
|
46887
|
+
return base64Write(this, string, offset, length)
|
|
46888
|
+
|
|
46889
|
+
case 'ucs2':
|
|
46890
|
+
case 'ucs-2':
|
|
46891
|
+
case 'utf16le':
|
|
46892
|
+
case 'utf-16le':
|
|
46893
|
+
return ucs2Write(this, string, offset, length)
|
|
46894
|
+
|
|
46895
|
+
default:
|
|
46896
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
46897
|
+
encoding = ('' + encoding).toLowerCase();
|
|
46898
|
+
loweredCase = true;
|
|
46899
|
+
}
|
|
46900
|
+
}
|
|
46901
|
+
};
|
|
46902
|
+
|
|
46903
|
+
Buffer.prototype.toJSON = function toJSON () {
|
|
46904
|
+
return {
|
|
46905
|
+
type: 'Buffer',
|
|
46906
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
46907
|
+
}
|
|
46908
|
+
};
|
|
46909
|
+
|
|
46910
|
+
function base64Slice (buf, start, end) {
|
|
46911
|
+
if (start === 0 && end === buf.length) {
|
|
46912
|
+
return base64Js.fromByteArray(buf)
|
|
46913
|
+
} else {
|
|
46914
|
+
return base64Js.fromByteArray(buf.slice(start, end))
|
|
46915
|
+
}
|
|
46916
|
+
}
|
|
46917
|
+
|
|
46918
|
+
function utf8Slice (buf, start, end) {
|
|
46919
|
+
end = Math.min(buf.length, end);
|
|
46920
|
+
const res = [];
|
|
46921
|
+
|
|
46922
|
+
let i = start;
|
|
46923
|
+
while (i < end) {
|
|
46924
|
+
const firstByte = buf[i];
|
|
46925
|
+
let codePoint = null;
|
|
46926
|
+
let bytesPerSequence = (firstByte > 0xEF)
|
|
46927
|
+
? 4
|
|
46928
|
+
: (firstByte > 0xDF)
|
|
46929
|
+
? 3
|
|
46930
|
+
: (firstByte > 0xBF)
|
|
46931
|
+
? 2
|
|
46932
|
+
: 1;
|
|
46933
|
+
|
|
46934
|
+
if (i + bytesPerSequence <= end) {
|
|
46935
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
46936
|
+
|
|
46937
|
+
switch (bytesPerSequence) {
|
|
46938
|
+
case 1:
|
|
46939
|
+
if (firstByte < 0x80) {
|
|
46940
|
+
codePoint = firstByte;
|
|
46941
|
+
}
|
|
46942
|
+
break
|
|
46943
|
+
case 2:
|
|
46944
|
+
secondByte = buf[i + 1];
|
|
46945
|
+
if ((secondByte & 0xC0) === 0x80) {
|
|
46946
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
46947
|
+
if (tempCodePoint > 0x7F) {
|
|
46948
|
+
codePoint = tempCodePoint;
|
|
46949
|
+
}
|
|
46950
|
+
}
|
|
46951
|
+
break
|
|
46952
|
+
case 3:
|
|
46953
|
+
secondByte = buf[i + 1];
|
|
46954
|
+
thirdByte = buf[i + 2];
|
|
46955
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
46956
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
46957
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
46958
|
+
codePoint = tempCodePoint;
|
|
46959
|
+
}
|
|
46960
|
+
}
|
|
46961
|
+
break
|
|
46962
|
+
case 4:
|
|
46963
|
+
secondByte = buf[i + 1];
|
|
46964
|
+
thirdByte = buf[i + 2];
|
|
46965
|
+
fourthByte = buf[i + 3];
|
|
46966
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
46967
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
46968
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
46969
|
+
codePoint = tempCodePoint;
|
|
46970
|
+
}
|
|
46971
|
+
}
|
|
46972
|
+
}
|
|
46973
|
+
}
|
|
46974
|
+
|
|
46975
|
+
if (codePoint === null) {
|
|
46976
|
+
// we did not generate a valid codePoint so insert a
|
|
46977
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
|
46978
|
+
codePoint = 0xFFFD;
|
|
46979
|
+
bytesPerSequence = 1;
|
|
46980
|
+
} else if (codePoint > 0xFFFF) {
|
|
46981
|
+
// encode to utf16 (surrogate pair dance)
|
|
46982
|
+
codePoint -= 0x10000;
|
|
46983
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
46984
|
+
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
46985
|
+
}
|
|
46986
|
+
|
|
46987
|
+
res.push(codePoint);
|
|
46988
|
+
i += bytesPerSequence;
|
|
46989
|
+
}
|
|
46990
|
+
|
|
46991
|
+
return decodeCodePointsArray(res)
|
|
46992
|
+
}
|
|
46993
|
+
|
|
46994
|
+
console.log("********* buffer line 1039 *********");
|
|
46995
|
+
|
|
46996
|
+
|
|
46997
|
+
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
46998
|
+
// the lowest limit is Chrome, with 0x10000 args.
|
|
46999
|
+
// We go 1 magnitude less, for safety
|
|
47000
|
+
const MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
47001
|
+
|
|
47002
|
+
function decodeCodePointsArray (codePoints) {
|
|
47003
|
+
const len = codePoints.length;
|
|
47004
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
47005
|
+
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
47006
|
+
}
|
|
47007
|
+
|
|
47008
|
+
// Decode in chunks to avoid "call stack size exceeded".
|
|
47009
|
+
let res = '';
|
|
47010
|
+
let i = 0;
|
|
47011
|
+
while (i < len) {
|
|
47012
|
+
res += String.fromCharCode.apply(
|
|
47013
|
+
String,
|
|
47014
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
47015
|
+
);
|
|
47016
|
+
}
|
|
47017
|
+
return res
|
|
47018
|
+
}
|
|
47019
|
+
|
|
47020
|
+
function asciiSlice (buf, start, end) {
|
|
47021
|
+
let ret = '';
|
|
47022
|
+
end = Math.min(buf.length, end);
|
|
47023
|
+
|
|
47024
|
+
for (let i = start; i < end; ++i) {
|
|
47025
|
+
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
47026
|
+
}
|
|
47027
|
+
return ret
|
|
47028
|
+
}
|
|
47029
|
+
|
|
47030
|
+
function latin1Slice (buf, start, end) {
|
|
47031
|
+
let ret = '';
|
|
47032
|
+
end = Math.min(buf.length, end);
|
|
47033
|
+
|
|
47034
|
+
for (let i = start; i < end; ++i) {
|
|
47035
|
+
ret += String.fromCharCode(buf[i]);
|
|
47036
|
+
}
|
|
47037
|
+
return ret
|
|
47038
|
+
}
|
|
47039
|
+
|
|
47040
|
+
function hexSlice (buf, start, end) {
|
|
47041
|
+
const len = buf.length;
|
|
47042
|
+
|
|
47043
|
+
if (!start || start < 0) start = 0;
|
|
47044
|
+
if (!end || end < 0 || end > len) end = len;
|
|
47045
|
+
|
|
47046
|
+
let out = '';
|
|
47047
|
+
for (let i = start; i < end; ++i) {
|
|
47048
|
+
out += hexSliceLookupTable[buf[i]];
|
|
47049
|
+
}
|
|
47050
|
+
return out
|
|
47051
|
+
}
|
|
47052
|
+
|
|
47053
|
+
function utf16leSlice (buf, start, end) {
|
|
47054
|
+
const bytes = buf.slice(start, end);
|
|
47055
|
+
let res = '';
|
|
47056
|
+
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
47057
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
47058
|
+
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
47059
|
+
}
|
|
47060
|
+
return res
|
|
47061
|
+
}
|
|
47062
|
+
|
|
47063
|
+
Buffer.prototype.slice = function slice (start, end) {
|
|
47064
|
+
const len = this.length;
|
|
47065
|
+
start = ~~start;
|
|
47066
|
+
end = end === undefined ? len : ~~end;
|
|
47067
|
+
|
|
47068
|
+
if (start < 0) {
|
|
47069
|
+
start += len;
|
|
47070
|
+
if (start < 0) start = 0;
|
|
47071
|
+
} else if (start > len) {
|
|
47072
|
+
start = len;
|
|
47073
|
+
}
|
|
47074
|
+
|
|
47075
|
+
if (end < 0) {
|
|
47076
|
+
end += len;
|
|
47077
|
+
if (end < 0) end = 0;
|
|
47078
|
+
} else if (end > len) {
|
|
47079
|
+
end = len;
|
|
47080
|
+
}
|
|
47081
|
+
|
|
47082
|
+
if (end < start) end = start;
|
|
47083
|
+
|
|
47084
|
+
const newBuf = this.subarray(start, end);
|
|
47085
|
+
// Return an augmented `Uint8Array` instance
|
|
47086
|
+
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
47087
|
+
|
|
47088
|
+
return newBuf
|
|
47089
|
+
};
|
|
47090
|
+
|
|
47091
|
+
/*
|
|
47092
|
+
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
47093
|
+
*/
|
|
47094
|
+
function checkOffset (offset, ext, length) {
|
|
47095
|
+
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
47096
|
+
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
47097
|
+
}
|
|
47098
|
+
|
|
47099
|
+
Buffer.prototype.readUintLE =
|
|
47100
|
+
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
47101
|
+
offset = offset >>> 0;
|
|
47102
|
+
byteLength = byteLength >>> 0;
|
|
47103
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
47104
|
+
|
|
47105
|
+
let val = this[offset];
|
|
47106
|
+
let mul = 1;
|
|
47107
|
+
let i = 0;
|
|
47108
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
47109
|
+
val += this[offset + i] * mul;
|
|
47110
|
+
}
|
|
47111
|
+
|
|
47112
|
+
return val
|
|
47113
|
+
};
|
|
47114
|
+
|
|
47115
|
+
Buffer.prototype.readUintBE =
|
|
47116
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
47117
|
+
offset = offset >>> 0;
|
|
47118
|
+
byteLength = byteLength >>> 0;
|
|
47119
|
+
if (!noAssert) {
|
|
47120
|
+
checkOffset(offset, byteLength, this.length);
|
|
47121
|
+
}
|
|
47122
|
+
|
|
47123
|
+
let val = this[offset + --byteLength];
|
|
47124
|
+
let mul = 1;
|
|
47125
|
+
while (byteLength > 0 && (mul *= 0x100)) {
|
|
47126
|
+
val += this[offset + --byteLength] * mul;
|
|
47127
|
+
}
|
|
47128
|
+
|
|
47129
|
+
return val
|
|
47130
|
+
};
|
|
47131
|
+
|
|
47132
|
+
Buffer.prototype.readUint8 =
|
|
47133
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
47134
|
+
offset = offset >>> 0;
|
|
47135
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
47136
|
+
return this[offset]
|
|
47137
|
+
};
|
|
47138
|
+
|
|
47139
|
+
Buffer.prototype.readUint16LE =
|
|
47140
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
47141
|
+
offset = offset >>> 0;
|
|
47142
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
47143
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
47144
|
+
};
|
|
47145
|
+
|
|
47146
|
+
Buffer.prototype.readUint16BE =
|
|
47147
|
+
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
47148
|
+
offset = offset >>> 0;
|
|
47149
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
47150
|
+
return (this[offset] << 8) | this[offset + 1]
|
|
47151
|
+
};
|
|
47152
|
+
|
|
47153
|
+
Buffer.prototype.readUint32LE =
|
|
47154
|
+
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
47155
|
+
offset = offset >>> 0;
|
|
47156
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47157
|
+
|
|
47158
|
+
return ((this[offset]) |
|
|
47159
|
+
(this[offset + 1] << 8) |
|
|
47160
|
+
(this[offset + 2] << 16)) +
|
|
47161
|
+
(this[offset + 3] * 0x1000000)
|
|
47162
|
+
};
|
|
47163
|
+
|
|
47164
|
+
Buffer.prototype.readUint32BE =
|
|
47165
|
+
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
47166
|
+
offset = offset >>> 0;
|
|
47167
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47168
|
+
|
|
47169
|
+
return (this[offset] * 0x1000000) +
|
|
47170
|
+
((this[offset + 1] << 16) |
|
|
47171
|
+
(this[offset + 2] << 8) |
|
|
47172
|
+
this[offset + 3])
|
|
47173
|
+
};
|
|
47174
|
+
|
|
47175
|
+
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
|
47176
|
+
offset = offset >>> 0;
|
|
47177
|
+
validateNumber(offset, 'offset');
|
|
47178
|
+
const first = this[offset];
|
|
47179
|
+
const last = this[offset + 7];
|
|
47180
|
+
if (first === undefined || last === undefined) {
|
|
47181
|
+
boundsError(offset, this.length - 8);
|
|
47182
|
+
}
|
|
47183
|
+
|
|
47184
|
+
const lo = first +
|
|
47185
|
+
this[++offset] * 2 ** 8 +
|
|
47186
|
+
this[++offset] * 2 ** 16 +
|
|
47187
|
+
this[++offset] * 2 ** 24;
|
|
47188
|
+
|
|
47189
|
+
const hi = this[++offset] +
|
|
47190
|
+
this[++offset] * 2 ** 8 +
|
|
47191
|
+
this[++offset] * 2 ** 16 +
|
|
47192
|
+
last * 2 ** 24;
|
|
47193
|
+
|
|
47194
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
|
47195
|
+
});
|
|
47196
|
+
|
|
47197
|
+
console.log("********* buffer line 1241 *********");
|
|
47198
|
+
|
|
47199
|
+
|
|
47200
|
+
console.log("beofre readBigUInt64BE!");
|
|
47201
|
+
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
|
47202
|
+
offset = offset >>> 0;
|
|
47203
|
+
validateNumber(offset, 'offset');
|
|
47204
|
+
const first = this[offset];
|
|
47205
|
+
const last = this[offset + 7];
|
|
47206
|
+
if (first === undefined || last === undefined) {
|
|
47207
|
+
boundsError(offset, this.length - 8);
|
|
47208
|
+
}
|
|
47209
|
+
|
|
47210
|
+
const hi = first * 2 ** 24 +
|
|
47211
|
+
this[++offset] * 2 ** 16 +
|
|
47212
|
+
this[++offset] * 2 ** 8 +
|
|
47213
|
+
this[++offset];
|
|
47214
|
+
|
|
47215
|
+
const lo = this[++offset] * 2 ** 24 +
|
|
47216
|
+
this[++offset] * 2 ** 16 +
|
|
47217
|
+
this[++offset] * 2 ** 8 +
|
|
47218
|
+
last;
|
|
47219
|
+
|
|
47220
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
47221
|
+
});
|
|
47222
|
+
|
|
47223
|
+
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
47224
|
+
offset = offset >>> 0;
|
|
47225
|
+
byteLength = byteLength >>> 0;
|
|
47226
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
47227
|
+
|
|
47228
|
+
let val = this[offset];
|
|
47229
|
+
let mul = 1;
|
|
47230
|
+
let i = 0;
|
|
47231
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
47232
|
+
val += this[offset + i] * mul;
|
|
47233
|
+
}
|
|
47234
|
+
mul *= 0x80;
|
|
47235
|
+
|
|
47236
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
47237
|
+
|
|
47238
|
+
return val
|
|
47239
|
+
};
|
|
47240
|
+
|
|
47241
|
+
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
47242
|
+
offset = offset >>> 0;
|
|
47243
|
+
byteLength = byteLength >>> 0;
|
|
47244
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
47245
|
+
|
|
47246
|
+
let i = byteLength;
|
|
47247
|
+
let mul = 1;
|
|
47248
|
+
let val = this[offset + --i];
|
|
47249
|
+
while (i > 0 && (mul *= 0x100)) {
|
|
47250
|
+
val += this[offset + --i] * mul;
|
|
47251
|
+
}
|
|
47252
|
+
mul *= 0x80;
|
|
47253
|
+
|
|
47254
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
47255
|
+
|
|
47256
|
+
return val
|
|
47257
|
+
};
|
|
47258
|
+
|
|
47259
|
+
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
47260
|
+
offset = offset >>> 0;
|
|
47261
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
47262
|
+
if (!(this[offset] & 0x80)) return (this[offset])
|
|
47263
|
+
return ((0xff - this[offset] + 1) * -1)
|
|
47264
|
+
};
|
|
47265
|
+
|
|
47266
|
+
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
47267
|
+
offset = offset >>> 0;
|
|
47268
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
47269
|
+
const val = this[offset] | (this[offset + 1] << 8);
|
|
47270
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
47271
|
+
};
|
|
47272
|
+
|
|
47273
|
+
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
47274
|
+
offset = offset >>> 0;
|
|
47275
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
47276
|
+
const val = this[offset + 1] | (this[offset] << 8);
|
|
47277
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
47278
|
+
};
|
|
47279
|
+
|
|
47280
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
47281
|
+
offset = offset >>> 0;
|
|
47282
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47283
|
+
|
|
47284
|
+
return (this[offset]) |
|
|
47285
|
+
(this[offset + 1] << 8) |
|
|
47286
|
+
(this[offset + 2] << 16) |
|
|
47287
|
+
(this[offset + 3] << 24)
|
|
47288
|
+
};
|
|
47289
|
+
|
|
47290
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
47291
|
+
offset = offset >>> 0;
|
|
47292
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47293
|
+
|
|
47294
|
+
return (this[offset] << 24) |
|
|
47295
|
+
(this[offset + 1] << 16) |
|
|
47296
|
+
(this[offset + 2] << 8) |
|
|
47297
|
+
(this[offset + 3])
|
|
47298
|
+
};
|
|
47299
|
+
|
|
47300
|
+
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
|
|
47301
|
+
offset = offset >>> 0;
|
|
47302
|
+
validateNumber(offset, 'offset');
|
|
47303
|
+
const first = this[offset];
|
|
47304
|
+
const last = this[offset + 7];
|
|
47305
|
+
if (first === undefined || last === undefined) {
|
|
47306
|
+
boundsError(offset, this.length - 8);
|
|
47307
|
+
}
|
|
47308
|
+
|
|
47309
|
+
const val = this[offset + 4] +
|
|
47310
|
+
this[offset + 5] * 2 ** 8 +
|
|
47311
|
+
this[offset + 6] * 2 ** 16 +
|
|
47312
|
+
(last << 24); // Overflow
|
|
47313
|
+
|
|
47314
|
+
return (BigInt(val) << BigInt(32)) +
|
|
47315
|
+
BigInt(first +
|
|
47316
|
+
this[++offset] * 2 ** 8 +
|
|
47317
|
+
this[++offset] * 2 ** 16 +
|
|
47318
|
+
this[++offset] * 2 ** 24)
|
|
47319
|
+
});
|
|
47320
|
+
|
|
47321
|
+
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
|
47322
|
+
offset = offset >>> 0;
|
|
47323
|
+
validateNumber(offset, 'offset');
|
|
47324
|
+
const first = this[offset];
|
|
47325
|
+
const last = this[offset + 7];
|
|
47326
|
+
if (first === undefined || last === undefined) {
|
|
47327
|
+
boundsError(offset, this.length - 8);
|
|
47328
|
+
}
|
|
47329
|
+
|
|
47330
|
+
const val = (first << 24) + // Overflow
|
|
47331
|
+
this[++offset] * 2 ** 16 +
|
|
47332
|
+
this[++offset] * 2 ** 8 +
|
|
47333
|
+
this[++offset];
|
|
47334
|
+
|
|
47335
|
+
return (BigInt(val) << BigInt(32)) +
|
|
47336
|
+
BigInt(this[++offset] * 2 ** 24 +
|
|
47337
|
+
this[++offset] * 2 ** 16 +
|
|
47338
|
+
this[++offset] * 2 ** 8 +
|
|
47339
|
+
last)
|
|
47340
|
+
});
|
|
47341
|
+
|
|
47342
|
+
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
47343
|
+
offset = offset >>> 0;
|
|
47344
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47345
|
+
return ieee754.read(this, offset, true, 23, 4)
|
|
47346
|
+
};
|
|
47347
|
+
|
|
47348
|
+
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
47349
|
+
offset = offset >>> 0;
|
|
47350
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
47351
|
+
return ieee754.read(this, offset, false, 23, 4)
|
|
47352
|
+
};
|
|
47353
|
+
|
|
47354
|
+
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
47355
|
+
offset = offset >>> 0;
|
|
47356
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
47357
|
+
return ieee754.read(this, offset, true, 52, 8)
|
|
47358
|
+
};
|
|
47359
|
+
|
|
47360
|
+
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
47361
|
+
offset = offset >>> 0;
|
|
47362
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
47363
|
+
return ieee754.read(this, offset, false, 52, 8)
|
|
47364
|
+
};
|
|
47365
|
+
|
|
47366
|
+
function checkInt (buf, value, offset, ext, max, min) {
|
|
47367
|
+
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
47368
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
47369
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
47370
|
+
}
|
|
47371
|
+
|
|
47372
|
+
Buffer.prototype.writeUintLE =
|
|
47373
|
+
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
47374
|
+
value = +value;
|
|
47375
|
+
offset = offset >>> 0;
|
|
47376
|
+
byteLength = byteLength >>> 0;
|
|
47377
|
+
if (!noAssert) {
|
|
47378
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
47379
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
47380
|
+
}
|
|
47381
|
+
|
|
47382
|
+
let mul = 1;
|
|
47383
|
+
let i = 0;
|
|
47384
|
+
this[offset] = value & 0xFF;
|
|
47385
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
47386
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
47387
|
+
}
|
|
47388
|
+
|
|
47389
|
+
return offset + byteLength
|
|
47390
|
+
};
|
|
47391
|
+
|
|
47392
|
+
Buffer.prototype.writeUintBE =
|
|
47393
|
+
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
47394
|
+
value = +value;
|
|
47395
|
+
offset = offset >>> 0;
|
|
47396
|
+
byteLength = byteLength >>> 0;
|
|
47397
|
+
if (!noAssert) {
|
|
47398
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
47399
|
+
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
47400
|
+
}
|
|
47401
|
+
|
|
47402
|
+
let i = byteLength - 1;
|
|
47403
|
+
let mul = 1;
|
|
47404
|
+
this[offset + i] = value & 0xFF;
|
|
47405
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
47406
|
+
this[offset + i] = (value / mul) & 0xFF;
|
|
47407
|
+
}
|
|
47408
|
+
|
|
47409
|
+
return offset + byteLength
|
|
47410
|
+
};
|
|
47411
|
+
|
|
47412
|
+
Buffer.prototype.writeUint8 =
|
|
47413
|
+
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
47414
|
+
value = +value;
|
|
47415
|
+
offset = offset >>> 0;
|
|
47416
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
47417
|
+
this[offset] = (value & 0xff);
|
|
47418
|
+
return offset + 1
|
|
47419
|
+
};
|
|
47420
|
+
|
|
47421
|
+
Buffer.prototype.writeUint16LE =
|
|
47422
|
+
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
47423
|
+
value = +value;
|
|
47424
|
+
offset = offset >>> 0;
|
|
47425
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
47426
|
+
this[offset] = (value & 0xff);
|
|
47427
|
+
this[offset + 1] = (value >>> 8);
|
|
47428
|
+
return offset + 2
|
|
47429
|
+
};
|
|
47430
|
+
|
|
47431
|
+
Buffer.prototype.writeUint16BE =
|
|
47432
|
+
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
47433
|
+
value = +value;
|
|
47434
|
+
offset = offset >>> 0;
|
|
47435
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
47436
|
+
this[offset] = (value >>> 8);
|
|
47437
|
+
this[offset + 1] = (value & 0xff);
|
|
47438
|
+
return offset + 2
|
|
47439
|
+
};
|
|
47440
|
+
|
|
47441
|
+
Buffer.prototype.writeUint32LE =
|
|
47442
|
+
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
47443
|
+
value = +value;
|
|
47444
|
+
offset = offset >>> 0;
|
|
47445
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
47446
|
+
this[offset + 3] = (value >>> 24);
|
|
47447
|
+
this[offset + 2] = (value >>> 16);
|
|
47448
|
+
this[offset + 1] = (value >>> 8);
|
|
47449
|
+
this[offset] = (value & 0xff);
|
|
47450
|
+
return offset + 4
|
|
47451
|
+
};
|
|
47452
|
+
|
|
47453
|
+
Buffer.prototype.writeUint32BE =
|
|
47454
|
+
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
47455
|
+
value = +value;
|
|
47456
|
+
offset = offset >>> 0;
|
|
47457
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
47458
|
+
this[offset] = (value >>> 24);
|
|
47459
|
+
this[offset + 1] = (value >>> 16);
|
|
47460
|
+
this[offset + 2] = (value >>> 8);
|
|
47461
|
+
this[offset + 3] = (value & 0xff);
|
|
47462
|
+
return offset + 4
|
|
47463
|
+
};
|
|
47464
|
+
|
|
47465
|
+
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
|
47466
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
47467
|
+
|
|
47468
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
47469
|
+
buf[offset++] = lo;
|
|
47470
|
+
lo = lo >> 8;
|
|
47471
|
+
buf[offset++] = lo;
|
|
47472
|
+
lo = lo >> 8;
|
|
47473
|
+
buf[offset++] = lo;
|
|
47474
|
+
lo = lo >> 8;
|
|
47475
|
+
buf[offset++] = lo;
|
|
47476
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
47477
|
+
buf[offset++] = hi;
|
|
47478
|
+
hi = hi >> 8;
|
|
47479
|
+
buf[offset++] = hi;
|
|
47480
|
+
hi = hi >> 8;
|
|
47481
|
+
buf[offset++] = hi;
|
|
47482
|
+
hi = hi >> 8;
|
|
47483
|
+
buf[offset++] = hi;
|
|
47484
|
+
return offset
|
|
47485
|
+
}
|
|
47486
|
+
|
|
47487
|
+
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
|
47488
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
47489
|
+
|
|
47490
|
+
let lo = Number(value & BigInt(0xffffffff));
|
|
47491
|
+
buf[offset + 7] = lo;
|
|
47492
|
+
lo = lo >> 8;
|
|
47493
|
+
buf[offset + 6] = lo;
|
|
47494
|
+
lo = lo >> 8;
|
|
47495
|
+
buf[offset + 5] = lo;
|
|
47496
|
+
lo = lo >> 8;
|
|
47497
|
+
buf[offset + 4] = lo;
|
|
47498
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
|
|
47499
|
+
buf[offset + 3] = hi;
|
|
47500
|
+
hi = hi >> 8;
|
|
47501
|
+
buf[offset + 2] = hi;
|
|
47502
|
+
hi = hi >> 8;
|
|
47503
|
+
buf[offset + 1] = hi;
|
|
47504
|
+
hi = hi >> 8;
|
|
47505
|
+
buf[offset] = hi;
|
|
47506
|
+
return offset + 8
|
|
47507
|
+
}
|
|
47508
|
+
|
|
47509
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
47510
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
47511
|
+
});
|
|
47512
|
+
|
|
47513
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
47514
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
47515
|
+
});
|
|
47516
|
+
|
|
47517
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
47518
|
+
value = +value;
|
|
47519
|
+
offset = offset >>> 0;
|
|
47520
|
+
if (!noAssert) {
|
|
47521
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
47522
|
+
|
|
47523
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
47524
|
+
}
|
|
47525
|
+
|
|
47526
|
+
let i = 0;
|
|
47527
|
+
let mul = 1;
|
|
47528
|
+
let sub = 0;
|
|
47529
|
+
this[offset] = value & 0xFF;
|
|
47530
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
47531
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
47532
|
+
sub = 1;
|
|
47533
|
+
}
|
|
47534
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
47535
|
+
}
|
|
47536
|
+
|
|
47537
|
+
return offset + byteLength
|
|
47538
|
+
};
|
|
47539
|
+
|
|
47540
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
47541
|
+
value = +value;
|
|
47542
|
+
offset = offset >>> 0;
|
|
47543
|
+
if (!noAssert) {
|
|
47544
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
47545
|
+
|
|
47546
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
47547
|
+
}
|
|
47548
|
+
|
|
47549
|
+
let i = byteLength - 1;
|
|
47550
|
+
let mul = 1;
|
|
47551
|
+
let sub = 0;
|
|
47552
|
+
this[offset + i] = value & 0xFF;
|
|
47553
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
47554
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
47555
|
+
sub = 1;
|
|
47556
|
+
}
|
|
47557
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
47558
|
+
}
|
|
47559
|
+
|
|
47560
|
+
return offset + byteLength
|
|
47561
|
+
};
|
|
47562
|
+
|
|
47563
|
+
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
47564
|
+
value = +value;
|
|
47565
|
+
offset = offset >>> 0;
|
|
47566
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
|
|
47567
|
+
if (value < 0) value = 0xff + value + 1;
|
|
47568
|
+
this[offset] = (value & 0xff);
|
|
47569
|
+
return offset + 1
|
|
47570
|
+
};
|
|
47571
|
+
|
|
47572
|
+
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
47573
|
+
value = +value;
|
|
47574
|
+
offset = offset >>> 0;
|
|
47575
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
|
|
47576
|
+
this[offset] = (value & 0xff);
|
|
47577
|
+
this[offset + 1] = (value >>> 8);
|
|
47578
|
+
return offset + 2
|
|
47579
|
+
};
|
|
47580
|
+
|
|
47581
|
+
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
47582
|
+
value = +value;
|
|
47583
|
+
offset = offset >>> 0;
|
|
47584
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
|
|
47585
|
+
this[offset] = (value >>> 8);
|
|
47586
|
+
this[offset + 1] = (value & 0xff);
|
|
47587
|
+
return offset + 2
|
|
47588
|
+
};
|
|
47589
|
+
|
|
47590
|
+
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
47591
|
+
value = +value;
|
|
47592
|
+
offset = offset >>> 0;
|
|
47593
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
|
|
47594
|
+
this[offset] = (value & 0xff);
|
|
47595
|
+
this[offset + 1] = (value >>> 8);
|
|
47596
|
+
this[offset + 2] = (value >>> 16);
|
|
47597
|
+
this[offset + 3] = (value >>> 24);
|
|
47598
|
+
return offset + 4
|
|
47599
|
+
};
|
|
47600
|
+
|
|
47601
|
+
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
47602
|
+
value = +value;
|
|
47603
|
+
offset = offset >>> 0;
|
|
47604
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
|
|
47605
|
+
if (value < 0) value = 0xffffffff + value + 1;
|
|
47606
|
+
this[offset] = (value >>> 24);
|
|
47607
|
+
this[offset + 1] = (value >>> 16);
|
|
47608
|
+
this[offset + 2] = (value >>> 8);
|
|
47609
|
+
this[offset + 3] = (value & 0xff);
|
|
47610
|
+
return offset + 4
|
|
47611
|
+
};
|
|
47612
|
+
|
|
47613
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
47614
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
47615
|
+
});
|
|
47616
|
+
|
|
47617
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
47618
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
47619
|
+
});
|
|
47620
|
+
|
|
47621
|
+
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
47622
|
+
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
47623
|
+
if (offset < 0) throw new RangeError('Index out of range')
|
|
47624
|
+
}
|
|
47625
|
+
|
|
47626
|
+
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
47627
|
+
value = +value;
|
|
47628
|
+
offset = offset >>> 0;
|
|
47629
|
+
if (!noAssert) {
|
|
47630
|
+
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
|
|
47631
|
+
}
|
|
47632
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
47633
|
+
return offset + 4
|
|
47634
|
+
}
|
|
47635
|
+
|
|
47636
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
47637
|
+
return writeFloat(this, value, offset, true, noAssert)
|
|
47638
|
+
};
|
|
47639
|
+
|
|
47640
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
47641
|
+
return writeFloat(this, value, offset, false, noAssert)
|
|
47642
|
+
};
|
|
47643
|
+
|
|
47644
|
+
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
47645
|
+
value = +value;
|
|
47646
|
+
offset = offset >>> 0;
|
|
47647
|
+
if (!noAssert) {
|
|
47648
|
+
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
|
|
47649
|
+
}
|
|
47650
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
47651
|
+
return offset + 8
|
|
47652
|
+
}
|
|
47653
|
+
|
|
47654
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
47655
|
+
return writeDouble(this, value, offset, true, noAssert)
|
|
47656
|
+
};
|
|
47657
|
+
|
|
47658
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
47659
|
+
return writeDouble(this, value, offset, false, noAssert)
|
|
47660
|
+
};
|
|
47661
|
+
|
|
47662
|
+
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
47663
|
+
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
47664
|
+
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
47665
|
+
if (!start) start = 0;
|
|
47666
|
+
if (!end && end !== 0) end = this.length;
|
|
47667
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
47668
|
+
if (!targetStart) targetStart = 0;
|
|
47669
|
+
if (end > 0 && end < start) end = start;
|
|
47670
|
+
|
|
47671
|
+
// Copy 0 bytes; we're done
|
|
47672
|
+
if (end === start) return 0
|
|
47673
|
+
if (target.length === 0 || this.length === 0) return 0
|
|
47674
|
+
|
|
47675
|
+
// Fatal error conditions
|
|
47676
|
+
if (targetStart < 0) {
|
|
47677
|
+
throw new RangeError('targetStart out of bounds')
|
|
47678
|
+
}
|
|
47679
|
+
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
47680
|
+
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
47681
|
+
|
|
47682
|
+
// Are we oob?
|
|
47683
|
+
if (end > this.length) end = this.length;
|
|
47684
|
+
if (target.length - targetStart < end - start) {
|
|
47685
|
+
end = target.length - targetStart + start;
|
|
47686
|
+
}
|
|
47687
|
+
|
|
47688
|
+
const len = end - start;
|
|
47689
|
+
|
|
47690
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
47691
|
+
// Use built-in when available, missing from IE11
|
|
47692
|
+
this.copyWithin(targetStart, start, end);
|
|
47693
|
+
} else {
|
|
47694
|
+
Uint8Array.prototype.set.call(
|
|
47695
|
+
target,
|
|
47696
|
+
this.subarray(start, end),
|
|
47697
|
+
targetStart
|
|
47698
|
+
);
|
|
47699
|
+
}
|
|
47700
|
+
|
|
47701
|
+
return len
|
|
47702
|
+
};
|
|
47703
|
+
|
|
47704
|
+
// Usage:
|
|
47705
|
+
// buffer.fill(number[, offset[, end]])
|
|
47706
|
+
// buffer.fill(buffer[, offset[, end]])
|
|
47707
|
+
// buffer.fill(string[, offset[, end]][, encoding])
|
|
47708
|
+
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
47709
|
+
// Handle string cases:
|
|
47710
|
+
if (typeof val === 'string') {
|
|
47711
|
+
if (typeof start === 'string') {
|
|
47712
|
+
encoding = start;
|
|
47713
|
+
start = 0;
|
|
47714
|
+
end = this.length;
|
|
47715
|
+
} else if (typeof end === 'string') {
|
|
47716
|
+
encoding = end;
|
|
47717
|
+
end = this.length;
|
|
47718
|
+
}
|
|
47719
|
+
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
47720
|
+
throw new TypeError('encoding must be a string')
|
|
47721
|
+
}
|
|
47722
|
+
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
47723
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
47724
|
+
}
|
|
47725
|
+
if (val.length === 1) {
|
|
47726
|
+
const code = val.charCodeAt(0);
|
|
47727
|
+
if ((encoding === 'utf8' && code < 128) ||
|
|
47728
|
+
encoding === 'latin1') {
|
|
47729
|
+
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
47730
|
+
val = code;
|
|
47731
|
+
}
|
|
47732
|
+
}
|
|
47733
|
+
} else if (typeof val === 'number') {
|
|
47734
|
+
val = val & 255;
|
|
47735
|
+
} else if (typeof val === 'boolean') {
|
|
47736
|
+
val = Number(val);
|
|
47737
|
+
}
|
|
47738
|
+
|
|
47739
|
+
// Invalid ranges are not set to a default, so can range check early.
|
|
47740
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
47741
|
+
throw new RangeError('Out of range index')
|
|
47742
|
+
}
|
|
47743
|
+
|
|
47744
|
+
if (end <= start) {
|
|
47745
|
+
return this
|
|
47746
|
+
}
|
|
47747
|
+
|
|
47748
|
+
start = start >>> 0;
|
|
47749
|
+
end = end === undefined ? this.length : end >>> 0;
|
|
47750
|
+
|
|
47751
|
+
if (!val) val = 0;
|
|
47752
|
+
|
|
47753
|
+
let i;
|
|
47754
|
+
if (typeof val === 'number') {
|
|
47755
|
+
for (i = start; i < end; ++i) {
|
|
47756
|
+
this[i] = val;
|
|
47757
|
+
}
|
|
47758
|
+
} else {
|
|
47759
|
+
const bytes = Buffer.isBuffer(val)
|
|
47760
|
+
? val
|
|
47761
|
+
: Buffer.from(val, encoding);
|
|
47762
|
+
const len = bytes.length;
|
|
47763
|
+
if (len === 0) {
|
|
47764
|
+
throw new TypeError('The value "' + val +
|
|
47765
|
+
'" is invalid for argument "value"')
|
|
47766
|
+
}
|
|
47767
|
+
for (i = 0; i < end - start; ++i) {
|
|
47768
|
+
this[i + start] = bytes[i % len];
|
|
47769
|
+
}
|
|
47770
|
+
}
|
|
47771
|
+
|
|
47772
|
+
return this
|
|
47773
|
+
};
|
|
47774
|
+
|
|
47775
|
+
// CUSTOM ERRORS
|
|
47776
|
+
// =============
|
|
47777
|
+
|
|
47778
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
|
47779
|
+
const errors = {};
|
|
47780
|
+
function E (sym, getMessage, Base) {
|
|
47781
|
+
errors[sym] = class NodeError extends Base {
|
|
47782
|
+
constructor () {
|
|
47783
|
+
super();
|
|
47784
|
+
|
|
47785
|
+
Object.defineProperty(this, 'message', {
|
|
47786
|
+
value: getMessage.apply(this, arguments),
|
|
47787
|
+
writable: true,
|
|
47788
|
+
configurable: true
|
|
47789
|
+
});
|
|
47790
|
+
|
|
47791
|
+
// Add the error code to the name to include it in the stack trace.
|
|
47792
|
+
this.name = `${this.name} [${sym}]`;
|
|
47793
|
+
// Access the stack to generate the error message including the error code
|
|
47794
|
+
// from the name.
|
|
47795
|
+
this.stack; // eslint-disable-line no-unused-expressions
|
|
47796
|
+
// Reset the name to the actual name.
|
|
47797
|
+
delete this.name;
|
|
47798
|
+
}
|
|
47799
|
+
|
|
47800
|
+
get code () {
|
|
47801
|
+
return sym
|
|
47802
|
+
}
|
|
47803
|
+
|
|
47804
|
+
set code (value) {
|
|
47805
|
+
Object.defineProperty(this, 'code', {
|
|
47806
|
+
configurable: true,
|
|
47807
|
+
enumerable: true,
|
|
47808
|
+
value,
|
|
47809
|
+
writable: true
|
|
47810
|
+
});
|
|
47811
|
+
}
|
|
47812
|
+
|
|
47813
|
+
toString () {
|
|
47814
|
+
return `${this.name} [${sym}]: ${this.message}`
|
|
47815
|
+
}
|
|
47816
|
+
};
|
|
47817
|
+
}
|
|
47818
|
+
|
|
47819
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
47820
|
+
function (name) {
|
|
47821
|
+
if (name) {
|
|
47822
|
+
return `${name} is outside of buffer bounds`
|
|
47823
|
+
}
|
|
47824
|
+
|
|
47825
|
+
return 'Attempt to access memory outside buffer bounds'
|
|
47826
|
+
}, RangeError);
|
|
47827
|
+
E('ERR_INVALID_ARG_TYPE',
|
|
47828
|
+
function (name, actual) {
|
|
47829
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
47830
|
+
}, TypeError);
|
|
47831
|
+
E('ERR_OUT_OF_RANGE',
|
|
47832
|
+
function (str, range, input) {
|
|
47833
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
47834
|
+
let received = input;
|
|
47835
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
47836
|
+
received = addNumericalSeparator(String(input));
|
|
47837
|
+
} else if (typeof input === 'bigint') {
|
|
47838
|
+
received = String(input);
|
|
47839
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
47840
|
+
received = addNumericalSeparator(received);
|
|
47841
|
+
}
|
|
47842
|
+
received += 'n';
|
|
47843
|
+
}
|
|
47844
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
47845
|
+
return msg
|
|
47846
|
+
}, RangeError);
|
|
47847
|
+
|
|
47848
|
+
function addNumericalSeparator (val) {
|
|
47849
|
+
let res = '';
|
|
47850
|
+
let i = val.length;
|
|
47851
|
+
const start = val[0] === '-' ? 1 : 0;
|
|
47852
|
+
for (; i >= start + 4; i -= 3) {
|
|
47853
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
47854
|
+
}
|
|
47855
|
+
return `${val.slice(0, i)}${res}`
|
|
47856
|
+
}
|
|
47857
|
+
|
|
47858
|
+
// CHECK FUNCTIONS
|
|
47859
|
+
// ===============
|
|
47860
|
+
|
|
47861
|
+
function checkBounds (buf, offset, byteLength) {
|
|
47862
|
+
validateNumber(offset, 'offset');
|
|
47863
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
47864
|
+
boundsError(offset, buf.length - (byteLength + 1));
|
|
47865
|
+
}
|
|
47866
|
+
}
|
|
47867
|
+
|
|
47868
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
47869
|
+
if (value > max || value < min) {
|
|
47870
|
+
const n = typeof min === 'bigint' ? 'n' : '';
|
|
47871
|
+
let range;
|
|
47872
|
+
if (byteLength > 3) {
|
|
47873
|
+
if (min === 0 || min === BigInt(0)) {
|
|
47874
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
47875
|
+
} else {
|
|
47876
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
47877
|
+
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
47878
|
+
}
|
|
47879
|
+
} else {
|
|
47880
|
+
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
47881
|
+
}
|
|
47882
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
47883
|
+
}
|
|
47884
|
+
checkBounds(buf, offset, byteLength);
|
|
47885
|
+
}
|
|
47886
|
+
|
|
47887
|
+
function validateNumber (value, name) {
|
|
47888
|
+
if (typeof value !== 'number') {
|
|
47889
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
47890
|
+
}
|
|
47891
|
+
}
|
|
47892
|
+
|
|
47893
|
+
function boundsError (value, length, type) {
|
|
47894
|
+
if (Math.floor(value) !== value) {
|
|
47895
|
+
validateNumber(value, type);
|
|
47896
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
|
|
47897
|
+
}
|
|
47898
|
+
|
|
47899
|
+
if (length < 0) {
|
|
47900
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
47901
|
+
}
|
|
47902
|
+
|
|
47903
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
|
|
47904
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
47905
|
+
value)
|
|
47906
|
+
}
|
|
47907
|
+
|
|
47908
|
+
// HELPER FUNCTIONS
|
|
47909
|
+
// ================
|
|
47910
|
+
|
|
47911
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
47912
|
+
|
|
47913
|
+
function base64clean (str) {
|
|
47914
|
+
// Node takes equal signs as end of the Base64 encoding
|
|
47915
|
+
str = str.split('=')[0];
|
|
47916
|
+
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
47917
|
+
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
47918
|
+
// Node converts strings with length < 2 to ''
|
|
47919
|
+
if (str.length < 2) return ''
|
|
47920
|
+
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
47921
|
+
while (str.length % 4 !== 0) {
|
|
47922
|
+
str = str + '=';
|
|
47923
|
+
}
|
|
47924
|
+
return str
|
|
47925
|
+
}
|
|
47926
|
+
|
|
47927
|
+
function utf8ToBytes (string, units) {
|
|
47928
|
+
units = units || Infinity;
|
|
47929
|
+
let codePoint;
|
|
47930
|
+
const length = string.length;
|
|
47931
|
+
let leadSurrogate = null;
|
|
47932
|
+
const bytes = [];
|
|
47933
|
+
|
|
47934
|
+
for (let i = 0; i < length; ++i) {
|
|
47935
|
+
codePoint = string.charCodeAt(i);
|
|
47936
|
+
|
|
47937
|
+
// is surrogate component
|
|
47938
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
47939
|
+
// last char was a lead
|
|
47940
|
+
if (!leadSurrogate) {
|
|
47941
|
+
// no lead yet
|
|
47942
|
+
if (codePoint > 0xDBFF) {
|
|
47943
|
+
// unexpected trail
|
|
47944
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
47945
|
+
continue
|
|
47946
|
+
} else if (i + 1 === length) {
|
|
47947
|
+
// unpaired lead
|
|
47948
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
47949
|
+
continue
|
|
47950
|
+
}
|
|
47951
|
+
|
|
47952
|
+
// valid lead
|
|
47953
|
+
leadSurrogate = codePoint;
|
|
47954
|
+
|
|
47955
|
+
continue
|
|
47956
|
+
}
|
|
47957
|
+
|
|
47958
|
+
// 2 leads in a row
|
|
47959
|
+
if (codePoint < 0xDC00) {
|
|
47960
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
47961
|
+
leadSurrogate = codePoint;
|
|
47962
|
+
continue
|
|
47963
|
+
}
|
|
47964
|
+
|
|
47965
|
+
// valid surrogate pair
|
|
47966
|
+
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
47967
|
+
} else if (leadSurrogate) {
|
|
47968
|
+
// valid bmp char, but last char was a lead
|
|
47969
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
47970
|
+
}
|
|
47971
|
+
|
|
47972
|
+
leadSurrogate = null;
|
|
47973
|
+
|
|
47974
|
+
// encode utf8
|
|
47975
|
+
if (codePoint < 0x80) {
|
|
47976
|
+
if ((units -= 1) < 0) break
|
|
47977
|
+
bytes.push(codePoint);
|
|
47978
|
+
} else if (codePoint < 0x800) {
|
|
47979
|
+
if ((units -= 2) < 0) break
|
|
47980
|
+
bytes.push(
|
|
47981
|
+
codePoint >> 0x6 | 0xC0,
|
|
47982
|
+
codePoint & 0x3F | 0x80
|
|
47983
|
+
);
|
|
47984
|
+
} else if (codePoint < 0x10000) {
|
|
47985
|
+
if ((units -= 3) < 0) break
|
|
47986
|
+
bytes.push(
|
|
47987
|
+
codePoint >> 0xC | 0xE0,
|
|
47988
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
47989
|
+
codePoint & 0x3F | 0x80
|
|
47990
|
+
);
|
|
47991
|
+
} else if (codePoint < 0x110000) {
|
|
47992
|
+
if ((units -= 4) < 0) break
|
|
47993
|
+
bytes.push(
|
|
47994
|
+
codePoint >> 0x12 | 0xF0,
|
|
47995
|
+
codePoint >> 0xC & 0x3F | 0x80,
|
|
47996
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
47997
|
+
codePoint & 0x3F | 0x80
|
|
47998
|
+
);
|
|
47999
|
+
} else {
|
|
48000
|
+
throw new Error('Invalid code point')
|
|
48001
|
+
}
|
|
48002
|
+
}
|
|
48003
|
+
|
|
48004
|
+
return bytes
|
|
48005
|
+
}
|
|
48006
|
+
|
|
48007
|
+
function asciiToBytes (str) {
|
|
48008
|
+
const byteArray = [];
|
|
48009
|
+
for (let i = 0; i < str.length; ++i) {
|
|
48010
|
+
// Node's code seems to be doing this and not & 0x7F..
|
|
48011
|
+
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
48012
|
+
}
|
|
48013
|
+
return byteArray
|
|
48014
|
+
}
|
|
48015
|
+
|
|
48016
|
+
function utf16leToBytes (str, units) {
|
|
48017
|
+
let c, hi, lo;
|
|
48018
|
+
const byteArray = [];
|
|
48019
|
+
for (let i = 0; i < str.length; ++i) {
|
|
48020
|
+
if ((units -= 2) < 0) break
|
|
48021
|
+
|
|
48022
|
+
c = str.charCodeAt(i);
|
|
48023
|
+
hi = c >> 8;
|
|
48024
|
+
lo = c % 256;
|
|
48025
|
+
byteArray.push(lo);
|
|
48026
|
+
byteArray.push(hi);
|
|
48027
|
+
}
|
|
48028
|
+
|
|
48029
|
+
return byteArray
|
|
48030
|
+
}
|
|
48031
|
+
|
|
48032
|
+
function base64ToBytes (str) {
|
|
48033
|
+
return base64Js.toByteArray(base64clean(str))
|
|
48034
|
+
}
|
|
48035
|
+
|
|
48036
|
+
function blitBuffer (src, dst, offset, length) {
|
|
48037
|
+
let i;
|
|
48038
|
+
for (i = 0; i < length; ++i) {
|
|
48039
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
48040
|
+
dst[i + offset] = src[i];
|
|
48041
|
+
}
|
|
48042
|
+
return i
|
|
48043
|
+
}
|
|
48044
|
+
|
|
48045
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
48046
|
+
// the `instanceof` check but they should be treated as of that type.
|
|
48047
|
+
// See: https://github.com/feross/buffer/issues/166
|
|
48048
|
+
function isInstance (obj, type) {
|
|
48049
|
+
return obj instanceof type ||
|
|
48050
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
48051
|
+
obj.constructor.name === type.name)
|
|
48052
|
+
}
|
|
48053
|
+
function numberIsNaN (obj) {
|
|
48054
|
+
// For IE11 support
|
|
48055
|
+
return obj !== obj // eslint-disable-line no-self-compare
|
|
48056
|
+
}
|
|
48057
|
+
|
|
48058
|
+
// Create lookup table for `toString('hex')`
|
|
48059
|
+
// See: https://github.com/feross/buffer/issues/219
|
|
48060
|
+
const hexSliceLookupTable = (function () {
|
|
48061
|
+
const alphabet = '0123456789abcdef';
|
|
48062
|
+
const table = new Array(256);
|
|
48063
|
+
for (let i = 0; i < 16; ++i) {
|
|
48064
|
+
const i16 = i * 16;
|
|
48065
|
+
for (let j = 0; j < 16; ++j) {
|
|
48066
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
48067
|
+
}
|
|
48068
|
+
}
|
|
48069
|
+
return table
|
|
48070
|
+
})();
|
|
48071
|
+
|
|
48072
|
+
// Return not function with Error if BigInt not supported
|
|
48073
|
+
function defineBigIntMethod (fn) {
|
|
48074
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
48075
|
+
}
|
|
48076
|
+
|
|
48077
|
+
function BufferBigIntNotDefined () {
|
|
48078
|
+
throw new Error('BigInt not supported')
|
|
48079
|
+
}
|
|
48080
|
+
});
|
|
48081
|
+
var buffer_1 = buffer$1.Buffer;
|
|
48082
|
+
var buffer_2 = buffer$1.SlowBuffer;
|
|
48083
|
+
var buffer_3 = buffer$1.INSPECT_MAX_BYTES;
|
|
48084
|
+
var buffer_4 = buffer$1.kMaxLength;
|
|
48085
|
+
|
|
45714
48086
|
/**
|
|
45715
48087
|
* @hidden
|
|
45716
48088
|
*/
|
|
@@ -45731,21 +48103,39 @@ var Neurosity = (function (exports) {
|
|
|
45731
48103
|
TRANSPORT_TYPE["REACT_NATIVE"] = "reactNative";
|
|
45732
48104
|
})(exports.TRANSPORT_TYPE || (exports.TRANSPORT_TYPE = {}));
|
|
45733
48105
|
|
|
45734
|
-
|
|
45735
|
-
|
|
45736
|
-
|
|
45737
|
-
|
|
45738
|
-
|
|
45739
|
-
|
|
45740
|
-
|
|
45741
|
-
|
|
45742
|
-
|
|
45743
|
-
|
|
45744
|
-
|
|
45745
|
-
|
|
45746
|
-
|
|
48106
|
+
/**
|
|
48107
|
+
* @hidden
|
|
48108
|
+
*/
|
|
48109
|
+
class TextCodec {
|
|
48110
|
+
constructor(transportType) {
|
|
48111
|
+
this.transportType = transportType;
|
|
48112
|
+
if (transportType === exports.TRANSPORT_TYPE.WEB) {
|
|
48113
|
+
this.webEncoder = new TextEncoder();
|
|
48114
|
+
this.webDecoder = new TextDecoder("utf-8");
|
|
48115
|
+
}
|
|
48116
|
+
}
|
|
48117
|
+
encode(data) {
|
|
48118
|
+
if (this.transportType === exports.TRANSPORT_TYPE.WEB) {
|
|
48119
|
+
const encoded = this.webEncoder.encode(data);
|
|
48120
|
+
return encoded;
|
|
48121
|
+
}
|
|
48122
|
+
if (this.transportType === exports.TRANSPORT_TYPE.REACT_NATIVE) {
|
|
48123
|
+
// React Native BLE Manager expects a number[] instead of a Uint8Array
|
|
48124
|
+
const encoded = [...buffer_1.from(data)];
|
|
48125
|
+
return encoded;
|
|
48126
|
+
}
|
|
48127
|
+
const encoded = buffer_1.from(data);
|
|
48128
|
+
return encoded;
|
|
48129
|
+
}
|
|
48130
|
+
decode(arrayBuffer) {
|
|
48131
|
+
if (this.transportType === exports.TRANSPORT_TYPE.WEB) {
|
|
48132
|
+
const decoded = this.webDecoder.decode(arrayBuffer);
|
|
48133
|
+
return decoded;
|
|
48134
|
+
}
|
|
48135
|
+
// For React Native, and as a default
|
|
48136
|
+
const decoded = buffer_1.from(arrayBuffer).toString("utf-8");
|
|
48137
|
+
return decoded;
|
|
45747
48138
|
}
|
|
45748
|
-
return decoder.decode(data);
|
|
45749
48139
|
}
|
|
45750
48140
|
|
|
45751
48141
|
const ANDROID_MAX_MTU = 512;
|
|
@@ -45754,6 +48144,43 @@ var Neurosity = (function (exports) {
|
|
|
45754
48144
|
// Reverse BLUETOOTH_CHARACTERISTICS key/values for easy lookup
|
|
45755
48145
|
const CHARACTERISTIC_UUIDS_TO_NAMES = Object.fromEntries(Object.entries(BLUETOOTH_CHARACTERISTICS).map((entries) => entries.reverse()));
|
|
45756
48146
|
|
|
48147
|
+
function stitchChunks({ delimiter }) {
|
|
48148
|
+
return pipe(scan(([remainder], currentBuffer) => {
|
|
48149
|
+
const nextBuffer = remainder + currentBuffer;
|
|
48150
|
+
if (!nextBuffer.includes(delimiter)) {
|
|
48151
|
+
return [nextBuffer, ""];
|
|
48152
|
+
}
|
|
48153
|
+
if (nextBuffer.endsWith(delimiter)) {
|
|
48154
|
+
return ["", nextBuffer];
|
|
48155
|
+
}
|
|
48156
|
+
const remainderStart = nextBuffer.lastIndexOf(delimiter);
|
|
48157
|
+
const remainderIndex = remainderStart + delimiter.length;
|
|
48158
|
+
const nextPacket = nextBuffer.slice(0, remainderIndex);
|
|
48159
|
+
const nextRemainder = nextBuffer.slice(remainderIndex);
|
|
48160
|
+
return [nextRemainder, nextPacket];
|
|
48161
|
+
}, ["", ""]), map(([, nextPacket]) => nextPacket.slice(0, -delimiter.length)), filter((nextPacket) => !!nextPacket.length));
|
|
48162
|
+
}
|
|
48163
|
+
|
|
48164
|
+
/**
|
|
48165
|
+
* @hidden
|
|
48166
|
+
*/
|
|
48167
|
+
function decodeJSONChunks({ textCodec, characteristicName, delimiter, addLog }) {
|
|
48168
|
+
return pipe(map((arrayBuffer) => {
|
|
48169
|
+
const decoded = textCodec.decode(arrayBuffer);
|
|
48170
|
+
addLog(`Received chunk with buffer size of ${arrayBuffer.byteLength} and decoded size ${decoded.length} for ${characteristicName} characteristic: \n${decoded}`);
|
|
48171
|
+
return decoded;
|
|
48172
|
+
}), stitchChunks({ delimiter }), map((payload) => {
|
|
48173
|
+
var _a;
|
|
48174
|
+
try {
|
|
48175
|
+
return JSON.parse(payload);
|
|
48176
|
+
}
|
|
48177
|
+
catch (error) {
|
|
48178
|
+
addLog(`Failed to parse JSON for ${characteristicName} characteristic. Falling back to unparsed string. ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
48179
|
+
return payload;
|
|
48180
|
+
}
|
|
48181
|
+
}));
|
|
48182
|
+
}
|
|
48183
|
+
|
|
45757
48184
|
var __awaiter$d = function (thisArg, _arguments, P, generator) {
|
|
45758
48185
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
45759
48186
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45769,6 +48196,7 @@ var Neurosity = (function (exports) {
|
|
|
45769
48196
|
class WebBluetoothTransport {
|
|
45770
48197
|
constructor(options = {}) {
|
|
45771
48198
|
this.type = exports.TRANSPORT_TYPE.WEB;
|
|
48199
|
+
this.textCodec = new TextCodec(this.type);
|
|
45772
48200
|
this.characteristicsByName = {};
|
|
45773
48201
|
this.connection$ = new BehaviorSubject(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
45774
48202
|
this.pendingActions$ = new BehaviorSubject([]);
|
|
@@ -45948,7 +48376,7 @@ var Neurosity = (function (exports) {
|
|
|
45948
48376
|
return (_a = this.characteristicsByName) === null || _a === void 0 ? void 0 : _a[characteristicName];
|
|
45949
48377
|
});
|
|
45950
48378
|
}
|
|
45951
|
-
subscribeToCharacteristic({ characteristicName, manageNotifications = true }) {
|
|
48379
|
+
subscribeToCharacteristic({ characteristicName, manageNotifications = true, skipJSONDecoding = false }) {
|
|
45952
48380
|
const data$ = defer(() => this.getCharacteristicByName(characteristicName)).pipe(switchMap((characteristic) => __awaiter$d(this, void 0, void 0, function* () {
|
|
45953
48381
|
var _a;
|
|
45954
48382
|
if (this.isConnected() && manageNotifications) {
|
|
@@ -45974,33 +48402,17 @@ var Neurosity = (function (exports) {
|
|
|
45974
48402
|
}
|
|
45975
48403
|
}
|
|
45976
48404
|
}));
|
|
45977
|
-
}), map((event) =>
|
|
45978
|
-
|
|
45979
|
-
|
|
45980
|
-
|
|
45981
|
-
|
|
45982
|
-
|
|
45983
|
-
|
|
45984
|
-
|
|
45985
|
-
|
|
45986
|
-
|
|
45987
|
-
|
|
45988
|
-
this.addLog(`Failed to parse JSON for ${characteristicName} characteristic. Falling back to unparsed string. ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
45989
|
-
return payload;
|
|
45990
|
-
}
|
|
45991
|
-
})
|
|
45992
|
-
// when streaming at ultra-low latency, the logs will slow down rendering
|
|
45993
|
-
// tap((data) => {
|
|
45994
|
-
// this.addLog(
|
|
45995
|
-
// `Received data for ${characteristicName} characteristic: \n${JSON.stringify(
|
|
45996
|
-
// data,
|
|
45997
|
-
// null,
|
|
45998
|
-
// 2
|
|
45999
|
-
// )}`
|
|
46000
|
-
// );
|
|
46001
|
-
// })
|
|
46002
|
-
);
|
|
46003
|
-
return this.connection$.pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED ? data$ : NEVER));
|
|
48405
|
+
}), map((event) => event.target.value.buffer));
|
|
48406
|
+
return this.connection$.pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
|
|
48407
|
+
? data$.pipe(skipJSONDecoding
|
|
48408
|
+
? identity // noop
|
|
48409
|
+
: decodeJSONChunks({
|
|
48410
|
+
textCodec: this.textCodec,
|
|
48411
|
+
characteristicName,
|
|
48412
|
+
delimiter: BLUETOOTH_CHUNK_DELIMITER,
|
|
48413
|
+
addLog: (message) => this.addLog(message)
|
|
48414
|
+
}))
|
|
48415
|
+
: NEVER));
|
|
46004
48416
|
}
|
|
46005
48417
|
readCharacteristic(characteristicName, parse = false) {
|
|
46006
48418
|
return __awaiter$d(this, void 0, void 0, function* () {
|
|
@@ -46011,9 +48423,9 @@ var Neurosity = (function (exports) {
|
|
|
46011
48423
|
this.addLog(`Did not fund ${characteristicName} characteristic`);
|
|
46012
48424
|
return Promise.reject(`Did not find characteristic by the name: ${characteristicName}`);
|
|
46013
48425
|
}
|
|
46014
|
-
const
|
|
46015
|
-
const
|
|
46016
|
-
const decodedValue = decode
|
|
48426
|
+
const dataview = yield characteristic.readValue();
|
|
48427
|
+
const arrayBuffer = dataview.buffer;
|
|
48428
|
+
const decodedValue = this.textCodec.decode(arrayBuffer);
|
|
46017
48429
|
const data = parse ? JSON.parse(decodedValue) : decodedValue;
|
|
46018
48430
|
this.addLog(`Received read data from ${characteristicName} characteristic: \n${data}`);
|
|
46019
48431
|
return data;
|
|
@@ -46031,7 +48443,7 @@ var Neurosity = (function (exports) {
|
|
|
46031
48443
|
this.addLog(`Did not fund ${characteristicName} characteristic`);
|
|
46032
48444
|
return Promise.reject(`Did not find characteristic by the name: ${characteristicName}`);
|
|
46033
48445
|
}
|
|
46034
|
-
const encoded = encode
|
|
48446
|
+
const encoded = this.textCodec.encode(data);
|
|
46035
48447
|
yield characteristic.writeValueWithResponse(encoded);
|
|
46036
48448
|
});
|
|
46037
48449
|
}
|
|
@@ -46174,6 +48586,7 @@ var Neurosity = (function (exports) {
|
|
|
46174
48586
|
class ReactNativeTransport {
|
|
46175
48587
|
constructor(options) {
|
|
46176
48588
|
this.type = exports.TRANSPORT_TYPE.REACT_NATIVE;
|
|
48589
|
+
this.textCodec = new TextCodec(this.type);
|
|
46177
48590
|
this.characteristicsByName = {};
|
|
46178
48591
|
this.connection$ = new BehaviorSubject(exports.BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
46179
48592
|
this.pendingActions$ = new BehaviorSubject([]);
|
|
@@ -46324,7 +48737,8 @@ var Neurosity = (function (exports) {
|
|
|
46324
48737
|
// it only has peripheral.advertising.localName as deviceNickname
|
|
46325
48738
|
// and OS v16 has both as deviceNickname
|
|
46326
48739
|
const peripheralName = (_c = (_b = (_a = peripheral === null || peripheral === void 0 ? void 0 : peripheral.advertising) === null || _a === void 0 ? void 0 : _a.localName) !== null && _b !== void 0 ? _b : peripheral.name) !== null && _c !== void 0 ? _c : "";
|
|
46327
|
-
const manufactureDataString = (_h = (_g =
|
|
48740
|
+
const manufactureDataString = (_h = (_g = this.textCodec
|
|
48741
|
+
.decode((_f = (_e = (_d = peripheral === null || peripheral === void 0 ? void 0 : peripheral.advertising) === null || _d === void 0 ? void 0 : _d.manufacturerData) === null || _e === void 0 ? void 0 : _e.bytes) !== null && _f !== void 0 ? _f : [])) === null || _g === void 0 ? void 0 : _g.slice) === null || _h === void 0 ? void 0 : _h.call(_g, 2); // First 2 bytes are reserved for the Neurosity company code
|
|
46328
48742
|
return Object.assign(Object.assign({}, acc), { [peripheral.id]: Object.assign(Object.assign({}, peripheral), { name: peripheralName, manufactureDataString }) });
|
|
46329
48743
|
}, {}), distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), map((peripheralMap) => Object.values(peripheralMap)), share());
|
|
46330
48744
|
return peripherals$;
|
|
@@ -46399,7 +48813,7 @@ var Neurosity = (function (exports) {
|
|
|
46399
48813
|
}
|
|
46400
48814
|
return (_a = this.characteristicsByName) === null || _a === void 0 ? void 0 : _a[characteristicName];
|
|
46401
48815
|
}
|
|
46402
|
-
subscribeToCharacteristic({ characteristicName, manageNotifications = true }) {
|
|
48816
|
+
subscribeToCharacteristic({ characteristicName, manageNotifications = true, skipJSONDecoding = false }) {
|
|
46403
48817
|
const getData = ({ peripheralId, serviceUUID, characteristicUUID }) => defer(() => __awaiter$e(this, void 0, void 0, function* () {
|
|
46404
48818
|
var _a;
|
|
46405
48819
|
if (manageNotifications) {
|
|
@@ -46422,18 +48836,16 @@ var Neurosity = (function (exports) {
|
|
|
46422
48836
|
this.addLog(`Attemped to stop notifications for ${characteristicName} characteristic: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
46423
48837
|
}
|
|
46424
48838
|
}
|
|
46425
|
-
})), filter(({ characteristic }) => characteristic === characteristicUUID), map(({ value }) =>
|
|
46426
|
-
var _a;
|
|
46427
|
-
try {
|
|
46428
|
-
return JSON.parse(payload);
|
|
46429
|
-
}
|
|
46430
|
-
catch (error) {
|
|
46431
|
-
this.addLog(`Failed to parse JSON for ${characteristicName} characteristic. Falling back to unparsed string. ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
46432
|
-
return payload;
|
|
46433
|
-
}
|
|
46434
|
-
}));
|
|
48839
|
+
})), filter(({ characteristic }) => characteristic === characteristicUUID), map(({ value }) => new Uint8Array(value)));
|
|
46435
48840
|
return this.connection$.pipe(switchMap((connection) => connection === exports.BLUETOOTH_CONNECTION.CONNECTED
|
|
46436
|
-
? getData(this.getCharacteristicByName(characteristicName))
|
|
48841
|
+
? getData(this.getCharacteristicByName(characteristicName)).pipe(skipJSONDecoding
|
|
48842
|
+
? identity // noop
|
|
48843
|
+
: decodeJSONChunks({
|
|
48844
|
+
textCodec: this.textCodec,
|
|
48845
|
+
characteristicName,
|
|
48846
|
+
delimiter: BLUETOOTH_CHUNK_DELIMITER,
|
|
48847
|
+
addLog: (message) => this.addLog(message)
|
|
48848
|
+
}))
|
|
46437
48849
|
: NEVER));
|
|
46438
48850
|
}
|
|
46439
48851
|
readCharacteristic(characteristicName, parse = false) {
|
|
@@ -46446,7 +48858,7 @@ var Neurosity = (function (exports) {
|
|
|
46446
48858
|
}
|
|
46447
48859
|
try {
|
|
46448
48860
|
const value = yield this.BleManager.read(peripheralId, serviceUUID, characteristicUUID);
|
|
46449
|
-
const decodedValue = decode
|
|
48861
|
+
const decodedValue = this.textCodec.decode(new Uint8Array(value));
|
|
46450
48862
|
const data = parse ? JSON.parse(decodedValue) : decodedValue;
|
|
46451
48863
|
this.addLog(`Received read data from ${characteristicName} characteristic: \n${data}`);
|
|
46452
48864
|
return data;
|
|
@@ -46463,7 +48875,7 @@ var Neurosity = (function (exports) {
|
|
|
46463
48875
|
if (!characteristicUUID) {
|
|
46464
48876
|
return Promise.reject(new Error(`Did not find characteristic matching ${characteristicName}`));
|
|
46465
48877
|
}
|
|
46466
|
-
const encoded = encode
|
|
48878
|
+
const encoded = this.textCodec.encode(data);
|
|
46467
48879
|
yield this.BleManager.write(peripheralId, serviceUUID, characteristicUUID, encoded, REACT_NATIVE_MAX_BYTE_SIZE);
|
|
46468
48880
|
});
|
|
46469
48881
|
}
|
|
@@ -46615,15 +49027,21 @@ var Neurosity = (function (exports) {
|
|
|
46615
49027
|
|
|
46616
49028
|
const EPOCH_BUFFER_SIZE = 16;
|
|
46617
49029
|
const SAMPLING_RATE_FALLBACK = 256; // Crown's sampling rate
|
|
49030
|
+
/** Size in bytes for each channel's payload. */
|
|
49031
|
+
const TimestampSize = 8; // UInt64
|
|
49032
|
+
const MarkerSize = 2; // UInt16
|
|
49033
|
+
const ChannelDataSize = 8; // Double
|
|
49034
|
+
/** Size in bytes for the static payload of every sample (Timestamp + Marker) */
|
|
49035
|
+
const SampleFixedSize = TimestampSize + MarkerSize;
|
|
46618
49036
|
/**
|
|
46619
49037
|
* @hidden
|
|
46620
49038
|
*/
|
|
46621
|
-
function
|
|
49039
|
+
function binaryBufferToEpoch(deviceInfo) {
|
|
46622
49040
|
var _a;
|
|
46623
49041
|
if (!(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.samplingRate)) {
|
|
46624
49042
|
console.warn(`Didn't receive a sampling rate, defaulting to ${SAMPLING_RATE_FALLBACK}`);
|
|
46625
49043
|
}
|
|
46626
|
-
return pipe(
|
|
49044
|
+
return pipe(binaryBufferToSamples(deviceInfo.channels), epoch({
|
|
46627
49045
|
duration: EPOCH_BUFFER_SIZE,
|
|
46628
49046
|
interval: EPOCH_BUFFER_SIZE,
|
|
46629
49047
|
samplingRate: (_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.samplingRate) !== null && _a !== void 0 ? _a : SAMPLING_RATE_FALLBACK
|
|
@@ -46635,11 +49053,82 @@ var Neurosity = (function (exports) {
|
|
|
46635
49053
|
/**
|
|
46636
49054
|
* @hidden
|
|
46637
49055
|
*/
|
|
46638
|
-
function
|
|
46639
|
-
return pipe(mergeMap((
|
|
46640
|
-
|
|
46641
|
-
|
|
46642
|
-
|
|
49056
|
+
function binaryBufferToSamples(channelCount) {
|
|
49057
|
+
return pipe(mergeMap((arrayBuffer) => {
|
|
49058
|
+
const buffer$$1 = buffer_1.from(arrayBuffer);
|
|
49059
|
+
const decoded = decode$1(buffer$$1, channelCount);
|
|
49060
|
+
return from(decoded); // `from` creates an Observable emission from each item (Sample) in the array
|
|
49061
|
+
}));
|
|
49062
|
+
}
|
|
49063
|
+
/**
|
|
49064
|
+
* @hidden
|
|
49065
|
+
*
|
|
49066
|
+
* Decode the supplied Buffer as a list of Sample.
|
|
49067
|
+
*
|
|
49068
|
+
* Supplied buffer's length must be multiple of
|
|
49069
|
+
* `encodedSampleSize(channelCount)`.
|
|
49070
|
+
*
|
|
49071
|
+
* NB: This method does not guarantee validity of decoded samples. When
|
|
49072
|
+
* supplied with a buffer of appropriate length, it will always return a
|
|
49073
|
+
* matching number of Sample8. Since the encoding protocol defines no
|
|
49074
|
+
* metadata/checksum, correctness must be guaranteed via test coverage.
|
|
49075
|
+
*
|
|
49076
|
+
* @param buffer Buffer with binary payload to decode.
|
|
49077
|
+
* @param channelCount Number of expected channels in each sample.
|
|
49078
|
+
*
|
|
49079
|
+
* @returns List of decoded Samples present in buffer.
|
|
49080
|
+
*/
|
|
49081
|
+
function decode$1(buffer$$1, channelCount) {
|
|
49082
|
+
let sampleLen = encodedSampleSize(channelCount);
|
|
49083
|
+
// Alternative: relax this check, process sampleLen at a time, discard remainder?
|
|
49084
|
+
if (buffer$$1.length % sampleLen != 0) {
|
|
49085
|
+
throw new Error(`buffer.length (${buffer$$1.length}) for ${channelCount} channels must be multiple of ${sampleLen}B)`);
|
|
49086
|
+
}
|
|
49087
|
+
let sampleCount = buffer$$1.length / sampleLen;
|
|
49088
|
+
let samples = new Array(sampleCount);
|
|
49089
|
+
for (let i = 0; i < sampleCount; i++) {
|
|
49090
|
+
let offset = i * sampleLen;
|
|
49091
|
+
let channelData = new Array(channelCount);
|
|
49092
|
+
// Read 8 bytes for timestamp & advance offset
|
|
49093
|
+
let ts = buffer$$1.readBigUInt64BE(offset);
|
|
49094
|
+
offset += TimestampSize;
|
|
49095
|
+
// Read 1 byte for marker & advance offset
|
|
49096
|
+
let marker = buffer$$1.readUInt16BE(offset);
|
|
49097
|
+
offset += MarkerSize;
|
|
49098
|
+
// Read 8 bytes for each channel & advance offset
|
|
49099
|
+
for (let i = 0; i < channelCount; i++) {
|
|
49100
|
+
channelData[i] = buffer$$1.readDoubleBE(offset);
|
|
49101
|
+
offset += ChannelDataSize;
|
|
49102
|
+
}
|
|
49103
|
+
samples[i] = {
|
|
49104
|
+
timestamp: Number(ts),
|
|
49105
|
+
// TODO: uncomment when ready
|
|
49106
|
+
// marker: marker,
|
|
49107
|
+
data: channelData
|
|
49108
|
+
};
|
|
49109
|
+
}
|
|
49110
|
+
return samples;
|
|
49111
|
+
}
|
|
49112
|
+
/**
|
|
49113
|
+
* @hidden
|
|
49114
|
+
*
|
|
49115
|
+
* Calculate the size of each sample based on the number of channels.
|
|
49116
|
+
*
|
|
49117
|
+
* Each sample has the following 3 segments:
|
|
49118
|
+
* - Timestamp: 8 bytes (UInt64); contains current time in millis since epoch)
|
|
49119
|
+
* - Marker: 2 bytes (UInt16); for classifier data
|
|
49120
|
+
* - Data: N * 8 bytes (Double), each entry representing data from a different
|
|
49121
|
+
* electrode.
|
|
49122
|
+
*
|
|
49123
|
+
* +-----------+--------+------------------+
|
|
49124
|
+
* | timestamp | marker | data (e1 ... eN) |
|
|
49125
|
+
* +-----------+--------+------------------+
|
|
49126
|
+
*
|
|
49127
|
+
* The number of entries for Data varies per hardware model. It can be assumed
|
|
49128
|
+
* to remain constant for the lifetime of the program.
|
|
49129
|
+
*/
|
|
49130
|
+
function encodedSampleSize(channelCount) {
|
|
49131
|
+
return SampleFixedSize + channelCount * ChannelDataSize;
|
|
46643
49132
|
}
|
|
46644
49133
|
|
|
46645
49134
|
var __awaiter$f = function (thisArg, _arguments, P, generator) {
|
|
@@ -46697,9 +49186,10 @@ var Neurosity = (function (exports) {
|
|
|
46697
49186
|
this._focus$ = this._subscribeWhileAuthenticated("focus");
|
|
46698
49187
|
this._calm$ = this._subscribeWhileAuthenticated("calm");
|
|
46699
49188
|
this._accelerometer$ = this._subscribeWhileAuthenticated("accelerometer");
|
|
46700
|
-
this._brainwavesRaw$ = this._subscribeWhileAuthenticated("raw"
|
|
46701
|
-
|
|
46702
|
-
|
|
49189
|
+
this._brainwavesRaw$ = this._subscribeWhileAuthenticated("raw", true // skipJSONDecoding
|
|
49190
|
+
);
|
|
49191
|
+
this._brainwavesRawUnfiltered$ = this._subscribeWhileAuthenticated("rawUnfiltered", true // skipJSONDecoding
|
|
49192
|
+
);
|
|
46703
49193
|
this._brainwavesPSD$ = this._subscribeWhileAuthenticated("psd");
|
|
46704
49194
|
this._brainwavesPowerByBand$ =
|
|
46705
49195
|
this._subscribeWhileAuthenticated("powerByBand");
|
|
@@ -46821,10 +49311,11 @@ var Neurosity = (function (exports) {
|
|
|
46821
49311
|
return yield getter();
|
|
46822
49312
|
});
|
|
46823
49313
|
}
|
|
46824
|
-
_subscribeWhileAuthenticated(characteristicName) {
|
|
49314
|
+
_subscribeWhileAuthenticated(characteristicName, skipJSONDecoding = false) {
|
|
46825
49315
|
return this.osHasBluetoothSupport$.pipe(switchMap((osHasBluetoothSupport) => osHasBluetoothSupport ? this.isAuthenticated$ : EMPTY), distinctUntilChanged(), switchMap((isAuthenticated) => isAuthenticated
|
|
46826
49316
|
? this.transport.subscribeToCharacteristic({
|
|
46827
|
-
characteristicName
|
|
49317
|
+
characteristicName,
|
|
49318
|
+
skipJSONDecoding
|
|
46828
49319
|
})
|
|
46829
49320
|
: EMPTY), share());
|
|
46830
49321
|
}
|
|
@@ -46841,9 +49332,9 @@ var Neurosity = (function (exports) {
|
|
|
46841
49332
|
switch (label) {
|
|
46842
49333
|
default:
|
|
46843
49334
|
case "raw":
|
|
46844
|
-
return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRaw$.pipe(
|
|
49335
|
+
return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRaw$.pipe(binaryBufferToEpoch(deviceInfo))));
|
|
46845
49336
|
case "rawUnfiltered":
|
|
46846
|
-
return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRawUnfiltered$.pipe(
|
|
49337
|
+
return defer(() => this.getInfo()).pipe(switchMap((deviceInfo) => this._brainwavesRawUnfiltered$.pipe(binaryBufferToEpoch(deviceInfo))));
|
|
46847
49338
|
case "psd":
|
|
46848
49339
|
return this._brainwavesPSD$;
|
|
46849
49340
|
case "powerByBand":
|
|
@@ -46983,10 +49474,6 @@ var Neurosity = (function (exports) {
|
|
|
46983
49474
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
46984
49475
|
};
|
|
46985
49476
|
|
|
46986
|
-
function createCommonjsModule(fn, module) {
|
|
46987
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
46988
|
-
}
|
|
46989
|
-
|
|
46990
49477
|
var re_1 = createCommonjsModule(function (module, exports) {
|
|
46991
49478
|
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
|
46992
49479
|
|
|
@@ -47640,7 +50127,11 @@ var Neurosity = (function (exports) {
|
|
|
47640
50127
|
osHasBluetoothSupport: this._osHasBluetoothSupport()
|
|
47641
50128
|
}).pipe(switchMap(({ selectedDevice, osHasBluetoothSupport: osHasBluetoothSupport$$1 }) => {
|
|
47642
50129
|
if (!selectedDevice) {
|
|
47643
|
-
return
|
|
50130
|
+
return of({
|
|
50131
|
+
connected: false,
|
|
50132
|
+
streamingMode,
|
|
50133
|
+
activeMode: STREAMING_TYPE.WIFI
|
|
50134
|
+
});
|
|
47644
50135
|
}
|
|
47645
50136
|
const isUnableToUseBluetooth = this.isMissingBluetoothTransport || !osHasBluetoothSupport$$1;
|
|
47646
50137
|
if (isUnableToUseBluetooth) {
|