@whereby.com/browser-sdk 2.0.0-alpha12 → 2.0.0-alpha13
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/README.md +2 -3
- package/dist/lib.cjs +3110 -41
- package/dist/lib.esm.js +3069 -7
- package/dist/types.d.ts +1 -1
- package/dist/{v2-alpha12.js → v2-alpha13.js} +3 -3
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -8,7 +8,14 @@ var React = require('react');
|
|
|
8
8
|
var adapter = require('webrtc-adapter');
|
|
9
9
|
var io = require('socket.io-client');
|
|
10
10
|
var SDPUtils = require('sdp');
|
|
11
|
-
var
|
|
11
|
+
var require$$0 = require('is-arguments');
|
|
12
|
+
var require$$1 = require('is-generator-function');
|
|
13
|
+
var require$$2 = require('which-typed-array');
|
|
14
|
+
var require$$3 = require('is-typed-array');
|
|
15
|
+
var require$$2$1 = require('inherits');
|
|
16
|
+
var require$$3$1 = require('es6-object-assign');
|
|
17
|
+
var require$$0$1 = require('object-is');
|
|
18
|
+
var require$$1$1 = require('is-nan');
|
|
12
19
|
var mediasoupClient = require('mediasoup-client');
|
|
13
20
|
var EventEmitter = require('events');
|
|
14
21
|
var uuid = require('uuid');
|
|
@@ -21,7 +28,14 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
21
28
|
var adapter__default = /*#__PURE__*/_interopDefaultLegacy(adapter);
|
|
22
29
|
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
23
30
|
var SDPUtils__default = /*#__PURE__*/_interopDefaultLegacy(SDPUtils);
|
|
24
|
-
var
|
|
31
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
32
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
33
|
+
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
34
|
+
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
35
|
+
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
36
|
+
var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
|
|
37
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
38
|
+
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
25
39
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
26
40
|
var nodeBtoa__default = /*#__PURE__*/_interopDefaultLegacy(nodeBtoa);
|
|
27
41
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
@@ -136,7 +150,7 @@ heresy.define("WherebyEmbed", {
|
|
|
136
150
|
if (roomUrl.searchParams.get("roomKey")) {
|
|
137
151
|
this.url.searchParams.append("roomKey", roomUrl.searchParams.get("roomKey"));
|
|
138
152
|
}
|
|
139
|
-
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-
|
|
153
|
+
Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ jsApi: true, we: "2.0.0-alpha13", iframeSource: subdomain }, (displayName && { displayName })), (lang && { lang })), (metadata && { metadata })), (groups && { groups })), (virtualBackgroundUrl && { virtualBackgroundUrl })), (avatarUrl && { avatarUrl })), (minimal != null && { embed: minimal })), boolAttrs.reduce(
|
|
140
154
|
// add to URL if set in any way
|
|
141
155
|
(o, v) => (this[v.toLowerCase()] != null ? Object.assign(Object.assign({}, o), { [v]: this[v.toLowerCase()] }) : o), {}))).forEach(([k, v]) => {
|
|
142
156
|
if (!this.url.searchParams.has(k) && typeof v === "string") {
|
|
@@ -1180,14 +1194,3069 @@ class Session {
|
|
|
1180
1194
|
}
|
|
1181
1195
|
}
|
|
1182
1196
|
|
|
1197
|
+
function getDefaultExportFromCjs (x) {
|
|
1198
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
var assertExports$1 = {};
|
|
1202
|
+
var assert$1 = {
|
|
1203
|
+
get exports(){ return assertExports$1; },
|
|
1204
|
+
set exports(v){ assertExports$1 = v; },
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
var errors = {};
|
|
1208
|
+
|
|
1209
|
+
var util = {};
|
|
1210
|
+
|
|
1211
|
+
var types = {};
|
|
1212
|
+
|
|
1213
|
+
(function (exports) {
|
|
1214
|
+
|
|
1215
|
+
var isArgumentsObject = require$$0__default["default"];
|
|
1216
|
+
var isGeneratorFunction = require$$1__default["default"];
|
|
1217
|
+
var whichTypedArray = require$$2__default["default"];
|
|
1218
|
+
var isTypedArray = require$$3__default["default"];
|
|
1219
|
+
|
|
1220
|
+
function uncurryThis(f) {
|
|
1221
|
+
return f.call.bind(f);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
var BigIntSupported = typeof BigInt !== 'undefined';
|
|
1225
|
+
var SymbolSupported = typeof Symbol !== 'undefined';
|
|
1226
|
+
|
|
1227
|
+
var ObjectToString = uncurryThis(Object.prototype.toString);
|
|
1228
|
+
|
|
1229
|
+
var numberValue = uncurryThis(Number.prototype.valueOf);
|
|
1230
|
+
var stringValue = uncurryThis(String.prototype.valueOf);
|
|
1231
|
+
var booleanValue = uncurryThis(Boolean.prototype.valueOf);
|
|
1232
|
+
|
|
1233
|
+
if (BigIntSupported) {
|
|
1234
|
+
var bigIntValue = uncurryThis(BigInt.prototype.valueOf);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
if (SymbolSupported) {
|
|
1238
|
+
var symbolValue = uncurryThis(Symbol.prototype.valueOf);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
function checkBoxedPrimitive(value, prototypeValueOf) {
|
|
1242
|
+
if (typeof value !== 'object') {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
try {
|
|
1246
|
+
prototypeValueOf(value);
|
|
1247
|
+
return true;
|
|
1248
|
+
} catch(e) {
|
|
1249
|
+
return false;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
exports.isArgumentsObject = isArgumentsObject;
|
|
1254
|
+
exports.isGeneratorFunction = isGeneratorFunction;
|
|
1255
|
+
exports.isTypedArray = isTypedArray;
|
|
1256
|
+
|
|
1257
|
+
// Taken from here and modified for better browser support
|
|
1258
|
+
// https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js
|
|
1259
|
+
function isPromise(input) {
|
|
1260
|
+
return (
|
|
1261
|
+
(
|
|
1262
|
+
typeof Promise !== 'undefined' &&
|
|
1263
|
+
input instanceof Promise
|
|
1264
|
+
) ||
|
|
1265
|
+
(
|
|
1266
|
+
input !== null &&
|
|
1267
|
+
typeof input === 'object' &&
|
|
1268
|
+
typeof input.then === 'function' &&
|
|
1269
|
+
typeof input.catch === 'function'
|
|
1270
|
+
)
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
exports.isPromise = isPromise;
|
|
1274
|
+
|
|
1275
|
+
function isArrayBufferView(value) {
|
|
1276
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
1277
|
+
return ArrayBuffer.isView(value);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
return (
|
|
1281
|
+
isTypedArray(value) ||
|
|
1282
|
+
isDataView(value)
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
exports.isArrayBufferView = isArrayBufferView;
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
function isUint8Array(value) {
|
|
1289
|
+
return whichTypedArray(value) === 'Uint8Array';
|
|
1290
|
+
}
|
|
1291
|
+
exports.isUint8Array = isUint8Array;
|
|
1292
|
+
|
|
1293
|
+
function isUint8ClampedArray(value) {
|
|
1294
|
+
return whichTypedArray(value) === 'Uint8ClampedArray';
|
|
1295
|
+
}
|
|
1296
|
+
exports.isUint8ClampedArray = isUint8ClampedArray;
|
|
1297
|
+
|
|
1298
|
+
function isUint16Array(value) {
|
|
1299
|
+
return whichTypedArray(value) === 'Uint16Array';
|
|
1300
|
+
}
|
|
1301
|
+
exports.isUint16Array = isUint16Array;
|
|
1302
|
+
|
|
1303
|
+
function isUint32Array(value) {
|
|
1304
|
+
return whichTypedArray(value) === 'Uint32Array';
|
|
1305
|
+
}
|
|
1306
|
+
exports.isUint32Array = isUint32Array;
|
|
1307
|
+
|
|
1308
|
+
function isInt8Array(value) {
|
|
1309
|
+
return whichTypedArray(value) === 'Int8Array';
|
|
1310
|
+
}
|
|
1311
|
+
exports.isInt8Array = isInt8Array;
|
|
1312
|
+
|
|
1313
|
+
function isInt16Array(value) {
|
|
1314
|
+
return whichTypedArray(value) === 'Int16Array';
|
|
1315
|
+
}
|
|
1316
|
+
exports.isInt16Array = isInt16Array;
|
|
1317
|
+
|
|
1318
|
+
function isInt32Array(value) {
|
|
1319
|
+
return whichTypedArray(value) === 'Int32Array';
|
|
1320
|
+
}
|
|
1321
|
+
exports.isInt32Array = isInt32Array;
|
|
1322
|
+
|
|
1323
|
+
function isFloat32Array(value) {
|
|
1324
|
+
return whichTypedArray(value) === 'Float32Array';
|
|
1325
|
+
}
|
|
1326
|
+
exports.isFloat32Array = isFloat32Array;
|
|
1327
|
+
|
|
1328
|
+
function isFloat64Array(value) {
|
|
1329
|
+
return whichTypedArray(value) === 'Float64Array';
|
|
1330
|
+
}
|
|
1331
|
+
exports.isFloat64Array = isFloat64Array;
|
|
1332
|
+
|
|
1333
|
+
function isBigInt64Array(value) {
|
|
1334
|
+
return whichTypedArray(value) === 'BigInt64Array';
|
|
1335
|
+
}
|
|
1336
|
+
exports.isBigInt64Array = isBigInt64Array;
|
|
1337
|
+
|
|
1338
|
+
function isBigUint64Array(value) {
|
|
1339
|
+
return whichTypedArray(value) === 'BigUint64Array';
|
|
1340
|
+
}
|
|
1341
|
+
exports.isBigUint64Array = isBigUint64Array;
|
|
1342
|
+
|
|
1343
|
+
function isMapToString(value) {
|
|
1344
|
+
return ObjectToString(value) === '[object Map]';
|
|
1345
|
+
}
|
|
1346
|
+
isMapToString.working = (
|
|
1347
|
+
typeof Map !== 'undefined' &&
|
|
1348
|
+
isMapToString(new Map())
|
|
1349
|
+
);
|
|
1350
|
+
|
|
1351
|
+
function isMap(value) {
|
|
1352
|
+
if (typeof Map === 'undefined') {
|
|
1353
|
+
return false;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
return isMapToString.working
|
|
1357
|
+
? isMapToString(value)
|
|
1358
|
+
: value instanceof Map;
|
|
1359
|
+
}
|
|
1360
|
+
exports.isMap = isMap;
|
|
1361
|
+
|
|
1362
|
+
function isSetToString(value) {
|
|
1363
|
+
return ObjectToString(value) === '[object Set]';
|
|
1364
|
+
}
|
|
1365
|
+
isSetToString.working = (
|
|
1366
|
+
typeof Set !== 'undefined' &&
|
|
1367
|
+
isSetToString(new Set())
|
|
1368
|
+
);
|
|
1369
|
+
function isSet(value) {
|
|
1370
|
+
if (typeof Set === 'undefined') {
|
|
1371
|
+
return false;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
return isSetToString.working
|
|
1375
|
+
? isSetToString(value)
|
|
1376
|
+
: value instanceof Set;
|
|
1377
|
+
}
|
|
1378
|
+
exports.isSet = isSet;
|
|
1379
|
+
|
|
1380
|
+
function isWeakMapToString(value) {
|
|
1381
|
+
return ObjectToString(value) === '[object WeakMap]';
|
|
1382
|
+
}
|
|
1383
|
+
isWeakMapToString.working = (
|
|
1384
|
+
typeof WeakMap !== 'undefined' &&
|
|
1385
|
+
isWeakMapToString(new WeakMap())
|
|
1386
|
+
);
|
|
1387
|
+
function isWeakMap(value) {
|
|
1388
|
+
if (typeof WeakMap === 'undefined') {
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
return isWeakMapToString.working
|
|
1393
|
+
? isWeakMapToString(value)
|
|
1394
|
+
: value instanceof WeakMap;
|
|
1395
|
+
}
|
|
1396
|
+
exports.isWeakMap = isWeakMap;
|
|
1397
|
+
|
|
1398
|
+
function isWeakSetToString(value) {
|
|
1399
|
+
return ObjectToString(value) === '[object WeakSet]';
|
|
1400
|
+
}
|
|
1401
|
+
isWeakSetToString.working = (
|
|
1402
|
+
typeof WeakSet !== 'undefined' &&
|
|
1403
|
+
isWeakSetToString(new WeakSet())
|
|
1404
|
+
);
|
|
1405
|
+
function isWeakSet(value) {
|
|
1406
|
+
return isWeakSetToString(value);
|
|
1407
|
+
}
|
|
1408
|
+
exports.isWeakSet = isWeakSet;
|
|
1409
|
+
|
|
1410
|
+
function isArrayBufferToString(value) {
|
|
1411
|
+
return ObjectToString(value) === '[object ArrayBuffer]';
|
|
1412
|
+
}
|
|
1413
|
+
isArrayBufferToString.working = (
|
|
1414
|
+
typeof ArrayBuffer !== 'undefined' &&
|
|
1415
|
+
isArrayBufferToString(new ArrayBuffer())
|
|
1416
|
+
);
|
|
1417
|
+
function isArrayBuffer(value) {
|
|
1418
|
+
if (typeof ArrayBuffer === 'undefined') {
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
return isArrayBufferToString.working
|
|
1423
|
+
? isArrayBufferToString(value)
|
|
1424
|
+
: value instanceof ArrayBuffer;
|
|
1425
|
+
}
|
|
1426
|
+
exports.isArrayBuffer = isArrayBuffer;
|
|
1427
|
+
|
|
1428
|
+
function isDataViewToString(value) {
|
|
1429
|
+
return ObjectToString(value) === '[object DataView]';
|
|
1430
|
+
}
|
|
1431
|
+
isDataViewToString.working = (
|
|
1432
|
+
typeof ArrayBuffer !== 'undefined' &&
|
|
1433
|
+
typeof DataView !== 'undefined' &&
|
|
1434
|
+
isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1))
|
|
1435
|
+
);
|
|
1436
|
+
function isDataView(value) {
|
|
1437
|
+
if (typeof DataView === 'undefined') {
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
return isDataViewToString.working
|
|
1442
|
+
? isDataViewToString(value)
|
|
1443
|
+
: value instanceof DataView;
|
|
1444
|
+
}
|
|
1445
|
+
exports.isDataView = isDataView;
|
|
1446
|
+
|
|
1447
|
+
// Store a copy of SharedArrayBuffer in case it's deleted elsewhere
|
|
1448
|
+
var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined;
|
|
1449
|
+
function isSharedArrayBufferToString(value) {
|
|
1450
|
+
return ObjectToString(value) === '[object SharedArrayBuffer]';
|
|
1451
|
+
}
|
|
1452
|
+
function isSharedArrayBuffer(value) {
|
|
1453
|
+
if (typeof SharedArrayBufferCopy === 'undefined') {
|
|
1454
|
+
return false;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
if (typeof isSharedArrayBufferToString.working === 'undefined') {
|
|
1458
|
+
isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy());
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
return isSharedArrayBufferToString.working
|
|
1462
|
+
? isSharedArrayBufferToString(value)
|
|
1463
|
+
: value instanceof SharedArrayBufferCopy;
|
|
1464
|
+
}
|
|
1465
|
+
exports.isSharedArrayBuffer = isSharedArrayBuffer;
|
|
1466
|
+
|
|
1467
|
+
function isAsyncFunction(value) {
|
|
1468
|
+
return ObjectToString(value) === '[object AsyncFunction]';
|
|
1469
|
+
}
|
|
1470
|
+
exports.isAsyncFunction = isAsyncFunction;
|
|
1471
|
+
|
|
1472
|
+
function isMapIterator(value) {
|
|
1473
|
+
return ObjectToString(value) === '[object Map Iterator]';
|
|
1474
|
+
}
|
|
1475
|
+
exports.isMapIterator = isMapIterator;
|
|
1476
|
+
|
|
1477
|
+
function isSetIterator(value) {
|
|
1478
|
+
return ObjectToString(value) === '[object Set Iterator]';
|
|
1479
|
+
}
|
|
1480
|
+
exports.isSetIterator = isSetIterator;
|
|
1481
|
+
|
|
1482
|
+
function isGeneratorObject(value) {
|
|
1483
|
+
return ObjectToString(value) === '[object Generator]';
|
|
1484
|
+
}
|
|
1485
|
+
exports.isGeneratorObject = isGeneratorObject;
|
|
1486
|
+
|
|
1487
|
+
function isWebAssemblyCompiledModule(value) {
|
|
1488
|
+
return ObjectToString(value) === '[object WebAssembly.Module]';
|
|
1489
|
+
}
|
|
1490
|
+
exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule;
|
|
1491
|
+
|
|
1492
|
+
function isNumberObject(value) {
|
|
1493
|
+
return checkBoxedPrimitive(value, numberValue);
|
|
1494
|
+
}
|
|
1495
|
+
exports.isNumberObject = isNumberObject;
|
|
1496
|
+
|
|
1497
|
+
function isStringObject(value) {
|
|
1498
|
+
return checkBoxedPrimitive(value, stringValue);
|
|
1499
|
+
}
|
|
1500
|
+
exports.isStringObject = isStringObject;
|
|
1501
|
+
|
|
1502
|
+
function isBooleanObject(value) {
|
|
1503
|
+
return checkBoxedPrimitive(value, booleanValue);
|
|
1504
|
+
}
|
|
1505
|
+
exports.isBooleanObject = isBooleanObject;
|
|
1506
|
+
|
|
1507
|
+
function isBigIntObject(value) {
|
|
1508
|
+
return BigIntSupported && checkBoxedPrimitive(value, bigIntValue);
|
|
1509
|
+
}
|
|
1510
|
+
exports.isBigIntObject = isBigIntObject;
|
|
1511
|
+
|
|
1512
|
+
function isSymbolObject(value) {
|
|
1513
|
+
return SymbolSupported && checkBoxedPrimitive(value, symbolValue);
|
|
1514
|
+
}
|
|
1515
|
+
exports.isSymbolObject = isSymbolObject;
|
|
1516
|
+
|
|
1517
|
+
function isBoxedPrimitive(value) {
|
|
1518
|
+
return (
|
|
1519
|
+
isNumberObject(value) ||
|
|
1520
|
+
isStringObject(value) ||
|
|
1521
|
+
isBooleanObject(value) ||
|
|
1522
|
+
isBigIntObject(value) ||
|
|
1523
|
+
isSymbolObject(value)
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1526
|
+
exports.isBoxedPrimitive = isBoxedPrimitive;
|
|
1527
|
+
|
|
1528
|
+
function isAnyArrayBuffer(value) {
|
|
1529
|
+
return typeof Uint8Array !== 'undefined' && (
|
|
1530
|
+
isArrayBuffer(value) ||
|
|
1531
|
+
isSharedArrayBuffer(value)
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
exports.isAnyArrayBuffer = isAnyArrayBuffer;
|
|
1535
|
+
|
|
1536
|
+
['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) {
|
|
1537
|
+
Object.defineProperty(exports, method, {
|
|
1538
|
+
enumerable: false,
|
|
1539
|
+
value: function() {
|
|
1540
|
+
throw new Error(method + ' is not supported in userland');
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
});
|
|
1544
|
+
} (types));
|
|
1545
|
+
|
|
1546
|
+
var isBuffer = function isBuffer(arg) {
|
|
1547
|
+
return arg instanceof Buffer;
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
(function (exports) {
|
|
1551
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
1552
|
+
//
|
|
1553
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
1554
|
+
// copy of this software and associated documentation files (the
|
|
1555
|
+
// "Software"), to deal in the Software without restriction, including
|
|
1556
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
1557
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
1558
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
1559
|
+
// following conditions:
|
|
1560
|
+
//
|
|
1561
|
+
// The above copyright notice and this permission notice shall be included
|
|
1562
|
+
// in all copies or substantial portions of the Software.
|
|
1563
|
+
//
|
|
1564
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
1565
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1566
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
1567
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
1568
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
1569
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
1570
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1571
|
+
|
|
1572
|
+
var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
|
|
1573
|
+
function getOwnPropertyDescriptors(obj) {
|
|
1574
|
+
var keys = Object.keys(obj);
|
|
1575
|
+
var descriptors = {};
|
|
1576
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1577
|
+
descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
|
|
1578
|
+
}
|
|
1579
|
+
return descriptors;
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
var formatRegExp = /%[sdj%]/g;
|
|
1583
|
+
exports.format = function(f) {
|
|
1584
|
+
if (!isString(f)) {
|
|
1585
|
+
var objects = [];
|
|
1586
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
1587
|
+
objects.push(inspect(arguments[i]));
|
|
1588
|
+
}
|
|
1589
|
+
return objects.join(' ');
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
var i = 1;
|
|
1593
|
+
var args = arguments;
|
|
1594
|
+
var len = args.length;
|
|
1595
|
+
var str = String(f).replace(formatRegExp, function(x) {
|
|
1596
|
+
if (x === '%%') return '%';
|
|
1597
|
+
if (i >= len) return x;
|
|
1598
|
+
switch (x) {
|
|
1599
|
+
case '%s': return String(args[i++]);
|
|
1600
|
+
case '%d': return Number(args[i++]);
|
|
1601
|
+
case '%j':
|
|
1602
|
+
try {
|
|
1603
|
+
return JSON.stringify(args[i++]);
|
|
1604
|
+
} catch (_) {
|
|
1605
|
+
return '[Circular]';
|
|
1606
|
+
}
|
|
1607
|
+
default:
|
|
1608
|
+
return x;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
for (var x = args[i]; i < len; x = args[++i]) {
|
|
1612
|
+
if (isNull(x) || !isObject(x)) {
|
|
1613
|
+
str += ' ' + x;
|
|
1614
|
+
} else {
|
|
1615
|
+
str += ' ' + inspect(x);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return str;
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
// Mark that a method should not be used.
|
|
1623
|
+
// Returns a modified function which warns once by default.
|
|
1624
|
+
// If --no-deprecation is set, then it is a no-op.
|
|
1625
|
+
exports.deprecate = function(fn, msg) {
|
|
1626
|
+
if (typeof process !== 'undefined' && process.noDeprecation === true) {
|
|
1627
|
+
return fn;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// Allow for deprecating things in the process of starting up.
|
|
1631
|
+
if (typeof process === 'undefined') {
|
|
1632
|
+
return function() {
|
|
1633
|
+
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
var warned = false;
|
|
1638
|
+
function deprecated() {
|
|
1639
|
+
if (!warned) {
|
|
1640
|
+
if (process.throwDeprecation) {
|
|
1641
|
+
throw new Error(msg);
|
|
1642
|
+
} else if (process.traceDeprecation) {
|
|
1643
|
+
console.trace(msg);
|
|
1644
|
+
} else {
|
|
1645
|
+
console.error(msg);
|
|
1646
|
+
}
|
|
1647
|
+
warned = true;
|
|
1648
|
+
}
|
|
1649
|
+
return fn.apply(this, arguments);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
return deprecated;
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
|
|
1656
|
+
var debugs = {};
|
|
1657
|
+
var debugEnvRegex = /^$/;
|
|
1658
|
+
exports.debuglog = function(set) {
|
|
1659
|
+
set = set.toUpperCase();
|
|
1660
|
+
if (!debugs[set]) {
|
|
1661
|
+
if (debugEnvRegex.test(set)) {
|
|
1662
|
+
var pid = process.pid;
|
|
1663
|
+
debugs[set] = function() {
|
|
1664
|
+
var msg = exports.format.apply(exports, arguments);
|
|
1665
|
+
console.error('%s %d: %s', set, pid, msg);
|
|
1666
|
+
};
|
|
1667
|
+
} else {
|
|
1668
|
+
debugs[set] = function() {};
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
return debugs[set];
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* Echos the value of a value. Trys to print the value out
|
|
1677
|
+
* in the best way possible given the different types.
|
|
1678
|
+
*
|
|
1679
|
+
* @param {Object} obj The object to print out.
|
|
1680
|
+
* @param {Object} opts Optional options object that alters the output.
|
|
1681
|
+
*/
|
|
1682
|
+
/* legacy: obj, showHidden, depth, colors*/
|
|
1683
|
+
function inspect(obj, opts) {
|
|
1684
|
+
// default options
|
|
1685
|
+
var ctx = {
|
|
1686
|
+
seen: [],
|
|
1687
|
+
stylize: stylizeNoColor
|
|
1688
|
+
};
|
|
1689
|
+
// legacy...
|
|
1690
|
+
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
1691
|
+
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
1692
|
+
if (isBoolean(opts)) {
|
|
1693
|
+
// legacy...
|
|
1694
|
+
ctx.showHidden = opts;
|
|
1695
|
+
} else if (opts) {
|
|
1696
|
+
// got an "options" object
|
|
1697
|
+
exports._extend(ctx, opts);
|
|
1698
|
+
}
|
|
1699
|
+
// set default options
|
|
1700
|
+
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
1701
|
+
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
1702
|
+
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
1703
|
+
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
1704
|
+
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
1705
|
+
return formatValue(ctx, obj, ctx.depth);
|
|
1706
|
+
}
|
|
1707
|
+
exports.inspect = inspect;
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
|
1711
|
+
inspect.colors = {
|
|
1712
|
+
'bold' : [1, 22],
|
|
1713
|
+
'italic' : [3, 23],
|
|
1714
|
+
'underline' : [4, 24],
|
|
1715
|
+
'inverse' : [7, 27],
|
|
1716
|
+
'white' : [37, 39],
|
|
1717
|
+
'grey' : [90, 39],
|
|
1718
|
+
'black' : [30, 39],
|
|
1719
|
+
'blue' : [34, 39],
|
|
1720
|
+
'cyan' : [36, 39],
|
|
1721
|
+
'green' : [32, 39],
|
|
1722
|
+
'magenta' : [35, 39],
|
|
1723
|
+
'red' : [31, 39],
|
|
1724
|
+
'yellow' : [33, 39]
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
// Don't use 'blue' not visible on cmd.exe
|
|
1728
|
+
inspect.styles = {
|
|
1729
|
+
'special': 'cyan',
|
|
1730
|
+
'number': 'yellow',
|
|
1731
|
+
'boolean': 'yellow',
|
|
1732
|
+
'undefined': 'grey',
|
|
1733
|
+
'null': 'bold',
|
|
1734
|
+
'string': 'green',
|
|
1735
|
+
'date': 'magenta',
|
|
1736
|
+
// "name": intentionally not styling
|
|
1737
|
+
'regexp': 'red'
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
function stylizeWithColor(str, styleType) {
|
|
1742
|
+
var style = inspect.styles[styleType];
|
|
1743
|
+
|
|
1744
|
+
if (style) {
|
|
1745
|
+
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
|
1746
|
+
'\u001b[' + inspect.colors[style][1] + 'm';
|
|
1747
|
+
} else {
|
|
1748
|
+
return str;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
|
|
1753
|
+
function stylizeNoColor(str, styleType) {
|
|
1754
|
+
return str;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
function arrayToHash(array) {
|
|
1759
|
+
var hash = {};
|
|
1760
|
+
|
|
1761
|
+
array.forEach(function(val, idx) {
|
|
1762
|
+
hash[val] = true;
|
|
1763
|
+
});
|
|
1764
|
+
|
|
1765
|
+
return hash;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
|
|
1769
|
+
function formatValue(ctx, value, recurseTimes) {
|
|
1770
|
+
// Provide a hook for user-specified inspect functions.
|
|
1771
|
+
// Check that value is an object with an inspect function on it
|
|
1772
|
+
if (ctx.customInspect &&
|
|
1773
|
+
value &&
|
|
1774
|
+
isFunction(value.inspect) &&
|
|
1775
|
+
// Filter out the util module, it's inspect function is special
|
|
1776
|
+
value.inspect !== exports.inspect &&
|
|
1777
|
+
// Also filter out any prototype objects using the circular check.
|
|
1778
|
+
!(value.constructor && value.constructor.prototype === value)) {
|
|
1779
|
+
var ret = value.inspect(recurseTimes, ctx);
|
|
1780
|
+
if (!isString(ret)) {
|
|
1781
|
+
ret = formatValue(ctx, ret, recurseTimes);
|
|
1782
|
+
}
|
|
1783
|
+
return ret;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
// Primitive types cannot have properties
|
|
1787
|
+
var primitive = formatPrimitive(ctx, value);
|
|
1788
|
+
if (primitive) {
|
|
1789
|
+
return primitive;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// Look up the keys of the object.
|
|
1793
|
+
var keys = Object.keys(value);
|
|
1794
|
+
var visibleKeys = arrayToHash(keys);
|
|
1795
|
+
|
|
1796
|
+
if (ctx.showHidden) {
|
|
1797
|
+
keys = Object.getOwnPropertyNames(value);
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
// IE doesn't make error fields non-enumerable
|
|
1801
|
+
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
|
1802
|
+
if (isError(value)
|
|
1803
|
+
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
1804
|
+
return formatError(value);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
// Some type of object without properties can be shortcutted.
|
|
1808
|
+
if (keys.length === 0) {
|
|
1809
|
+
if (isFunction(value)) {
|
|
1810
|
+
var name = value.name ? ': ' + value.name : '';
|
|
1811
|
+
return ctx.stylize('[Function' + name + ']', 'special');
|
|
1812
|
+
}
|
|
1813
|
+
if (isRegExp(value)) {
|
|
1814
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
1815
|
+
}
|
|
1816
|
+
if (isDate(value)) {
|
|
1817
|
+
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
1818
|
+
}
|
|
1819
|
+
if (isError(value)) {
|
|
1820
|
+
return formatError(value);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
var base = '', array = false, braces = ['{', '}'];
|
|
1825
|
+
|
|
1826
|
+
// Make Array say that they are Array
|
|
1827
|
+
if (isArray(value)) {
|
|
1828
|
+
array = true;
|
|
1829
|
+
braces = ['[', ']'];
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// Make functions say that they are functions
|
|
1833
|
+
if (isFunction(value)) {
|
|
1834
|
+
var n = value.name ? ': ' + value.name : '';
|
|
1835
|
+
base = ' [Function' + n + ']';
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// Make RegExps say that they are RegExps
|
|
1839
|
+
if (isRegExp(value)) {
|
|
1840
|
+
base = ' ' + RegExp.prototype.toString.call(value);
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// Make dates with properties first say the date
|
|
1844
|
+
if (isDate(value)) {
|
|
1845
|
+
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
// Make error with message first say the error
|
|
1849
|
+
if (isError(value)) {
|
|
1850
|
+
base = ' ' + formatError(value);
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
1854
|
+
return braces[0] + base + braces[1];
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
if (recurseTimes < 0) {
|
|
1858
|
+
if (isRegExp(value)) {
|
|
1859
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
1860
|
+
} else {
|
|
1861
|
+
return ctx.stylize('[Object]', 'special');
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
ctx.seen.push(value);
|
|
1866
|
+
|
|
1867
|
+
var output;
|
|
1868
|
+
if (array) {
|
|
1869
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
1870
|
+
} else {
|
|
1871
|
+
output = keys.map(function(key) {
|
|
1872
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
ctx.seen.pop();
|
|
1877
|
+
|
|
1878
|
+
return reduceToSingleString(output, base, braces);
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
|
|
1882
|
+
function formatPrimitive(ctx, value) {
|
|
1883
|
+
if (isUndefined(value))
|
|
1884
|
+
return ctx.stylize('undefined', 'undefined');
|
|
1885
|
+
if (isString(value)) {
|
|
1886
|
+
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
|
1887
|
+
.replace(/'/g, "\\'")
|
|
1888
|
+
.replace(/\\"/g, '"') + '\'';
|
|
1889
|
+
return ctx.stylize(simple, 'string');
|
|
1890
|
+
}
|
|
1891
|
+
if (isNumber(value))
|
|
1892
|
+
return ctx.stylize('' + value, 'number');
|
|
1893
|
+
if (isBoolean(value))
|
|
1894
|
+
return ctx.stylize('' + value, 'boolean');
|
|
1895
|
+
// For some reason typeof null is "object", so special case here.
|
|
1896
|
+
if (isNull(value))
|
|
1897
|
+
return ctx.stylize('null', 'null');
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
|
|
1901
|
+
function formatError(value) {
|
|
1902
|
+
return '[' + Error.prototype.toString.call(value) + ']';
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
1907
|
+
var output = [];
|
|
1908
|
+
for (var i = 0, l = value.length; i < l; ++i) {
|
|
1909
|
+
if (hasOwnProperty(value, String(i))) {
|
|
1910
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
1911
|
+
String(i), true));
|
|
1912
|
+
} else {
|
|
1913
|
+
output.push('');
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
keys.forEach(function(key) {
|
|
1917
|
+
if (!key.match(/^\d+$/)) {
|
|
1918
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
1919
|
+
key, true));
|
|
1920
|
+
}
|
|
1921
|
+
});
|
|
1922
|
+
return output;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
1927
|
+
var name, str, desc;
|
|
1928
|
+
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
1929
|
+
if (desc.get) {
|
|
1930
|
+
if (desc.set) {
|
|
1931
|
+
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
1932
|
+
} else {
|
|
1933
|
+
str = ctx.stylize('[Getter]', 'special');
|
|
1934
|
+
}
|
|
1935
|
+
} else {
|
|
1936
|
+
if (desc.set) {
|
|
1937
|
+
str = ctx.stylize('[Setter]', 'special');
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (!hasOwnProperty(visibleKeys, key)) {
|
|
1941
|
+
name = '[' + key + ']';
|
|
1942
|
+
}
|
|
1943
|
+
if (!str) {
|
|
1944
|
+
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
1945
|
+
if (isNull(recurseTimes)) {
|
|
1946
|
+
str = formatValue(ctx, desc.value, null);
|
|
1947
|
+
} else {
|
|
1948
|
+
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
1949
|
+
}
|
|
1950
|
+
if (str.indexOf('\n') > -1) {
|
|
1951
|
+
if (array) {
|
|
1952
|
+
str = str.split('\n').map(function(line) {
|
|
1953
|
+
return ' ' + line;
|
|
1954
|
+
}).join('\n').slice(2);
|
|
1955
|
+
} else {
|
|
1956
|
+
str = '\n' + str.split('\n').map(function(line) {
|
|
1957
|
+
return ' ' + line;
|
|
1958
|
+
}).join('\n');
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
} else {
|
|
1962
|
+
str = ctx.stylize('[Circular]', 'special');
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if (isUndefined(name)) {
|
|
1966
|
+
if (array && key.match(/^\d+$/)) {
|
|
1967
|
+
return str;
|
|
1968
|
+
}
|
|
1969
|
+
name = JSON.stringify('' + key);
|
|
1970
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
1971
|
+
name = name.slice(1, -1);
|
|
1972
|
+
name = ctx.stylize(name, 'name');
|
|
1973
|
+
} else {
|
|
1974
|
+
name = name.replace(/'/g, "\\'")
|
|
1975
|
+
.replace(/\\"/g, '"')
|
|
1976
|
+
.replace(/(^"|"$)/g, "'");
|
|
1977
|
+
name = ctx.stylize(name, 'string');
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
return name + ': ' + str;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
function reduceToSingleString(output, base, braces) {
|
|
1986
|
+
var length = output.reduce(function(prev, cur) {
|
|
1987
|
+
if (cur.indexOf('\n') >= 0) ;
|
|
1988
|
+
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
1989
|
+
}, 0);
|
|
1990
|
+
|
|
1991
|
+
if (length > 60) {
|
|
1992
|
+
return braces[0] +
|
|
1993
|
+
(base === '' ? '' : base + '\n ') +
|
|
1994
|
+
' ' +
|
|
1995
|
+
output.join(',\n ') +
|
|
1996
|
+
' ' +
|
|
1997
|
+
braces[1];
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
2005
|
+
// because it is fragile and can be easily faked with `Object.create()`.
|
|
2006
|
+
exports.types = types;
|
|
2007
|
+
|
|
2008
|
+
function isArray(ar) {
|
|
2009
|
+
return Array.isArray(ar);
|
|
2010
|
+
}
|
|
2011
|
+
exports.isArray = isArray;
|
|
2012
|
+
|
|
2013
|
+
function isBoolean(arg) {
|
|
2014
|
+
return typeof arg === 'boolean';
|
|
2015
|
+
}
|
|
2016
|
+
exports.isBoolean = isBoolean;
|
|
2017
|
+
|
|
2018
|
+
function isNull(arg) {
|
|
2019
|
+
return arg === null;
|
|
2020
|
+
}
|
|
2021
|
+
exports.isNull = isNull;
|
|
2022
|
+
|
|
2023
|
+
function isNullOrUndefined(arg) {
|
|
2024
|
+
return arg == null;
|
|
2025
|
+
}
|
|
2026
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
2027
|
+
|
|
2028
|
+
function isNumber(arg) {
|
|
2029
|
+
return typeof arg === 'number';
|
|
2030
|
+
}
|
|
2031
|
+
exports.isNumber = isNumber;
|
|
2032
|
+
|
|
2033
|
+
function isString(arg) {
|
|
2034
|
+
return typeof arg === 'string';
|
|
2035
|
+
}
|
|
2036
|
+
exports.isString = isString;
|
|
2037
|
+
|
|
2038
|
+
function isSymbol(arg) {
|
|
2039
|
+
return typeof arg === 'symbol';
|
|
2040
|
+
}
|
|
2041
|
+
exports.isSymbol = isSymbol;
|
|
2042
|
+
|
|
2043
|
+
function isUndefined(arg) {
|
|
2044
|
+
return arg === void 0;
|
|
2045
|
+
}
|
|
2046
|
+
exports.isUndefined = isUndefined;
|
|
2047
|
+
|
|
2048
|
+
function isRegExp(re) {
|
|
2049
|
+
return isObject(re) && objectToString(re) === '[object RegExp]';
|
|
2050
|
+
}
|
|
2051
|
+
exports.isRegExp = isRegExp;
|
|
2052
|
+
exports.types.isRegExp = isRegExp;
|
|
2053
|
+
|
|
2054
|
+
function isObject(arg) {
|
|
2055
|
+
return typeof arg === 'object' && arg !== null;
|
|
2056
|
+
}
|
|
2057
|
+
exports.isObject = isObject;
|
|
2058
|
+
|
|
2059
|
+
function isDate(d) {
|
|
2060
|
+
return isObject(d) && objectToString(d) === '[object Date]';
|
|
2061
|
+
}
|
|
2062
|
+
exports.isDate = isDate;
|
|
2063
|
+
exports.types.isDate = isDate;
|
|
2064
|
+
|
|
2065
|
+
function isError(e) {
|
|
2066
|
+
return isObject(e) &&
|
|
2067
|
+
(objectToString(e) === '[object Error]' || e instanceof Error);
|
|
2068
|
+
}
|
|
2069
|
+
exports.isError = isError;
|
|
2070
|
+
exports.types.isNativeError = isError;
|
|
2071
|
+
|
|
2072
|
+
function isFunction(arg) {
|
|
2073
|
+
return typeof arg === 'function';
|
|
2074
|
+
}
|
|
2075
|
+
exports.isFunction = isFunction;
|
|
2076
|
+
|
|
2077
|
+
function isPrimitive(arg) {
|
|
2078
|
+
return arg === null ||
|
|
2079
|
+
typeof arg === 'boolean' ||
|
|
2080
|
+
typeof arg === 'number' ||
|
|
2081
|
+
typeof arg === 'string' ||
|
|
2082
|
+
typeof arg === 'symbol' || // ES6 symbol
|
|
2083
|
+
typeof arg === 'undefined';
|
|
2084
|
+
}
|
|
2085
|
+
exports.isPrimitive = isPrimitive;
|
|
2086
|
+
|
|
2087
|
+
exports.isBuffer = isBuffer;
|
|
2088
|
+
|
|
2089
|
+
function objectToString(o) {
|
|
2090
|
+
return Object.prototype.toString.call(o);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
function pad(n) {
|
|
2095
|
+
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
|
2100
|
+
'Oct', 'Nov', 'Dec'];
|
|
2101
|
+
|
|
2102
|
+
// 26 Feb 16:19:34
|
|
2103
|
+
function timestamp() {
|
|
2104
|
+
var d = new Date();
|
|
2105
|
+
var time = [pad(d.getHours()),
|
|
2106
|
+
pad(d.getMinutes()),
|
|
2107
|
+
pad(d.getSeconds())].join(':');
|
|
2108
|
+
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
// log is just a thin wrapper to console.log that prepends a timestamp
|
|
2113
|
+
exports.log = function() {
|
|
2114
|
+
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
2115
|
+
};
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Inherit the prototype methods from one constructor into another.
|
|
2120
|
+
*
|
|
2121
|
+
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
2122
|
+
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
2123
|
+
* during bootstrapping this function needs to be rewritten using some native
|
|
2124
|
+
* functions as prototype setup using normal JavaScript does not work as
|
|
2125
|
+
* expected during bootstrapping (see mirror.js in r114903).
|
|
2126
|
+
*
|
|
2127
|
+
* @param {function} ctor Constructor function which needs to inherit the
|
|
2128
|
+
* prototype.
|
|
2129
|
+
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
2130
|
+
*/
|
|
2131
|
+
exports.inherits = require$$2__default$1["default"];
|
|
2132
|
+
|
|
2133
|
+
exports._extend = function(origin, add) {
|
|
2134
|
+
// Don't do anything if add isn't an object
|
|
2135
|
+
if (!add || !isObject(add)) return origin;
|
|
2136
|
+
|
|
2137
|
+
var keys = Object.keys(add);
|
|
2138
|
+
var i = keys.length;
|
|
2139
|
+
while (i--) {
|
|
2140
|
+
origin[keys[i]] = add[keys[i]];
|
|
2141
|
+
}
|
|
2142
|
+
return origin;
|
|
2143
|
+
};
|
|
2144
|
+
|
|
2145
|
+
function hasOwnProperty(obj, prop) {
|
|
2146
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
|
|
2150
|
+
|
|
2151
|
+
exports.promisify = function promisify(original) {
|
|
2152
|
+
if (typeof original !== 'function')
|
|
2153
|
+
throw new TypeError('The "original" argument must be of type Function');
|
|
2154
|
+
|
|
2155
|
+
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
|
|
2156
|
+
var fn = original[kCustomPromisifiedSymbol];
|
|
2157
|
+
if (typeof fn !== 'function') {
|
|
2158
|
+
throw new TypeError('The "util.promisify.custom" argument must be of type Function');
|
|
2159
|
+
}
|
|
2160
|
+
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
2161
|
+
value: fn, enumerable: false, writable: false, configurable: true
|
|
2162
|
+
});
|
|
2163
|
+
return fn;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
function fn() {
|
|
2167
|
+
var promiseResolve, promiseReject;
|
|
2168
|
+
var promise = new Promise(function (resolve, reject) {
|
|
2169
|
+
promiseResolve = resolve;
|
|
2170
|
+
promiseReject = reject;
|
|
2171
|
+
});
|
|
2172
|
+
|
|
2173
|
+
var args = [];
|
|
2174
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
2175
|
+
args.push(arguments[i]);
|
|
2176
|
+
}
|
|
2177
|
+
args.push(function (err, value) {
|
|
2178
|
+
if (err) {
|
|
2179
|
+
promiseReject(err);
|
|
2180
|
+
} else {
|
|
2181
|
+
promiseResolve(value);
|
|
2182
|
+
}
|
|
2183
|
+
});
|
|
2184
|
+
|
|
2185
|
+
try {
|
|
2186
|
+
original.apply(this, args);
|
|
2187
|
+
} catch (err) {
|
|
2188
|
+
promiseReject(err);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
return promise;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
|
|
2195
|
+
|
|
2196
|
+
if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
|
2197
|
+
value: fn, enumerable: false, writable: false, configurable: true
|
|
2198
|
+
});
|
|
2199
|
+
return Object.defineProperties(
|
|
2200
|
+
fn,
|
|
2201
|
+
getOwnPropertyDescriptors(original)
|
|
2202
|
+
);
|
|
2203
|
+
};
|
|
2204
|
+
|
|
2205
|
+
exports.promisify.custom = kCustomPromisifiedSymbol;
|
|
2206
|
+
|
|
2207
|
+
function callbackifyOnRejected(reason, cb) {
|
|
2208
|
+
// `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
|
|
2209
|
+
// Because `null` is a special error value in callbacks which means "no error
|
|
2210
|
+
// occurred", we error-wrap so the callback consumer can distinguish between
|
|
2211
|
+
// "the promise rejected with null" or "the promise fulfilled with undefined".
|
|
2212
|
+
if (!reason) {
|
|
2213
|
+
var newReason = new Error('Promise was rejected with a falsy value');
|
|
2214
|
+
newReason.reason = reason;
|
|
2215
|
+
reason = newReason;
|
|
2216
|
+
}
|
|
2217
|
+
return cb(reason);
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
function callbackify(original) {
|
|
2221
|
+
if (typeof original !== 'function') {
|
|
2222
|
+
throw new TypeError('The "original" argument must be of type Function');
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// We DO NOT return the promise as it gives the user a false sense that
|
|
2226
|
+
// the promise is actually somehow related to the callback's execution
|
|
2227
|
+
// and that the callback throwing will reject the promise.
|
|
2228
|
+
function callbackified() {
|
|
2229
|
+
var args = [];
|
|
2230
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
2231
|
+
args.push(arguments[i]);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
var maybeCb = args.pop();
|
|
2235
|
+
if (typeof maybeCb !== 'function') {
|
|
2236
|
+
throw new TypeError('The last argument must be of type Function');
|
|
2237
|
+
}
|
|
2238
|
+
var self = this;
|
|
2239
|
+
var cb = function() {
|
|
2240
|
+
return maybeCb.apply(self, arguments);
|
|
2241
|
+
};
|
|
2242
|
+
// In true node style we process the callback on `nextTick` with all the
|
|
2243
|
+
// implications (stack, `uncaughtException`, `async_hooks`)
|
|
2244
|
+
original.apply(this, args)
|
|
2245
|
+
.then(function(ret) { process.nextTick(cb.bind(null, null, ret)); },
|
|
2246
|
+
function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)); });
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
|
|
2250
|
+
Object.defineProperties(callbackified,
|
|
2251
|
+
getOwnPropertyDescriptors(original));
|
|
2252
|
+
return callbackified;
|
|
2253
|
+
}
|
|
2254
|
+
exports.callbackify = callbackify;
|
|
2255
|
+
} (util));
|
|
2256
|
+
|
|
2257
|
+
var hasRequiredErrors;
|
|
2258
|
+
|
|
2259
|
+
function requireErrors () {
|
|
2260
|
+
if (hasRequiredErrors) return errors;
|
|
2261
|
+
hasRequiredErrors = 1;
|
|
2262
|
+
// longer be forced to treat every error message change as a semver-major
|
|
2263
|
+
// change. The NodeError classes here all expose a `code` property whose
|
|
2264
|
+
// value statically and permanently identifies the error. While the error
|
|
2265
|
+
// message may change, the code should not.
|
|
2266
|
+
|
|
2267
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2268
|
+
|
|
2269
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2270
|
+
|
|
2271
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
2272
|
+
|
|
2273
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2274
|
+
|
|
2275
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2276
|
+
|
|
2277
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
2278
|
+
|
|
2279
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
2280
|
+
|
|
2281
|
+
var codes = {}; // Lazy loaded
|
|
2282
|
+
|
|
2283
|
+
var assert;
|
|
2284
|
+
var util$1;
|
|
2285
|
+
|
|
2286
|
+
function createErrorType(code, message, Base) {
|
|
2287
|
+
if (!Base) {
|
|
2288
|
+
Base = Error;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
function getMessage(arg1, arg2, arg3) {
|
|
2292
|
+
if (typeof message === 'string') {
|
|
2293
|
+
return message;
|
|
2294
|
+
} else {
|
|
2295
|
+
return message(arg1, arg2, arg3);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
var NodeError =
|
|
2300
|
+
/*#__PURE__*/
|
|
2301
|
+
function (_Base) {
|
|
2302
|
+
_inherits(NodeError, _Base);
|
|
2303
|
+
|
|
2304
|
+
function NodeError(arg1, arg2, arg3) {
|
|
2305
|
+
var _this;
|
|
2306
|
+
|
|
2307
|
+
_classCallCheck(this, NodeError);
|
|
2308
|
+
|
|
2309
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(NodeError).call(this, getMessage(arg1, arg2, arg3)));
|
|
2310
|
+
_this.code = code;
|
|
2311
|
+
return _this;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
return NodeError;
|
|
2315
|
+
}(Base);
|
|
2316
|
+
|
|
2317
|
+
codes[code] = NodeError;
|
|
2318
|
+
} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
function oneOf(expected, thing) {
|
|
2322
|
+
if (Array.isArray(expected)) {
|
|
2323
|
+
var len = expected.length;
|
|
2324
|
+
expected = expected.map(function (i) {
|
|
2325
|
+
return String(i);
|
|
2326
|
+
});
|
|
2327
|
+
|
|
2328
|
+
if (len > 2) {
|
|
2329
|
+
return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
|
|
2330
|
+
} else if (len === 2) {
|
|
2331
|
+
return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
|
|
2332
|
+
} else {
|
|
2333
|
+
return "of ".concat(thing, " ").concat(expected[0]);
|
|
2334
|
+
}
|
|
2335
|
+
} else {
|
|
2336
|
+
return "of ".concat(thing, " ").concat(String(expected));
|
|
2337
|
+
}
|
|
2338
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
function startsWith(str, search, pos) {
|
|
2342
|
+
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
2343
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
function endsWith(str, search, this_len) {
|
|
2347
|
+
if (this_len === undefined || this_len > str.length) {
|
|
2348
|
+
this_len = str.length;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
return str.substring(this_len - search.length, this_len) === search;
|
|
2352
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
|
2353
|
+
|
|
2354
|
+
|
|
2355
|
+
function includes(str, search, start) {
|
|
2356
|
+
if (typeof start !== 'number') {
|
|
2357
|
+
start = 0;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
if (start + search.length > str.length) {
|
|
2361
|
+
return false;
|
|
2362
|
+
} else {
|
|
2363
|
+
return str.indexOf(search, start) !== -1;
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
createErrorType('ERR_AMBIGUOUS_ARGUMENT', 'The "%s" argument is ambiguous. %s', TypeError);
|
|
2368
|
+
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
|
|
2369
|
+
if (assert === undefined) assert = requireAssert();
|
|
2370
|
+
assert(typeof name === 'string', "'name' must be a string"); // determiner: 'must be' or 'must not be'
|
|
2371
|
+
|
|
2372
|
+
var determiner;
|
|
2373
|
+
|
|
2374
|
+
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
|
|
2375
|
+
determiner = 'must not be';
|
|
2376
|
+
expected = expected.replace(/^not /, '');
|
|
2377
|
+
} else {
|
|
2378
|
+
determiner = 'must be';
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
var msg;
|
|
2382
|
+
|
|
2383
|
+
if (endsWith(name, ' argument')) {
|
|
2384
|
+
// For cases like 'first argument'
|
|
2385
|
+
msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
|
|
2386
|
+
} else {
|
|
2387
|
+
var type = includes(name, '.') ? 'property' : 'argument';
|
|
2388
|
+
msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
|
|
2389
|
+
} // TODO(BridgeAR): Improve the output by showing `null` and similar.
|
|
2390
|
+
|
|
2391
|
+
|
|
2392
|
+
msg += ". Received type ".concat(_typeof(actual));
|
|
2393
|
+
return msg;
|
|
2394
|
+
}, TypeError);
|
|
2395
|
+
createErrorType('ERR_INVALID_ARG_VALUE', function (name, value) {
|
|
2396
|
+
var reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'is invalid';
|
|
2397
|
+
if (util$1 === undefined) util$1 = util;
|
|
2398
|
+
var inspected = util$1.inspect(value);
|
|
2399
|
+
|
|
2400
|
+
if (inspected.length > 128) {
|
|
2401
|
+
inspected = "".concat(inspected.slice(0, 128), "...");
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
return "The argument '".concat(name, "' ").concat(reason, ". Received ").concat(inspected);
|
|
2405
|
+
}, TypeError);
|
|
2406
|
+
createErrorType('ERR_INVALID_RETURN_VALUE', function (input, name, value) {
|
|
2407
|
+
var type;
|
|
2408
|
+
|
|
2409
|
+
if (value && value.constructor && value.constructor.name) {
|
|
2410
|
+
type = "instance of ".concat(value.constructor.name);
|
|
2411
|
+
} else {
|
|
2412
|
+
type = "type ".concat(_typeof(value));
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
return "Expected ".concat(input, " to be returned from the \"").concat(name, "\"") + " function but got ".concat(type, ".");
|
|
2416
|
+
}, TypeError);
|
|
2417
|
+
createErrorType('ERR_MISSING_ARGS', function () {
|
|
2418
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2419
|
+
args[_key] = arguments[_key];
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
if (assert === undefined) assert = requireAssert();
|
|
2423
|
+
assert(args.length > 0, 'At least one arg needs to be specified');
|
|
2424
|
+
var msg = 'The ';
|
|
2425
|
+
var len = args.length;
|
|
2426
|
+
args = args.map(function (a) {
|
|
2427
|
+
return "\"".concat(a, "\"");
|
|
2428
|
+
});
|
|
2429
|
+
|
|
2430
|
+
switch (len) {
|
|
2431
|
+
case 1:
|
|
2432
|
+
msg += "".concat(args[0], " argument");
|
|
2433
|
+
break;
|
|
2434
|
+
|
|
2435
|
+
case 2:
|
|
2436
|
+
msg += "".concat(args[0], " and ").concat(args[1], " arguments");
|
|
2437
|
+
break;
|
|
2438
|
+
|
|
2439
|
+
default:
|
|
2440
|
+
msg += args.slice(0, len - 1).join(', ');
|
|
2441
|
+
msg += ", and ".concat(args[len - 1], " arguments");
|
|
2442
|
+
break;
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
return "".concat(msg, " must be specified");
|
|
2446
|
+
}, TypeError);
|
|
2447
|
+
errors.codes = codes;
|
|
2448
|
+
return errors;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
var assertion_error;
|
|
2452
|
+
var hasRequiredAssertion_error;
|
|
2453
|
+
|
|
2454
|
+
function requireAssertion_error () {
|
|
2455
|
+
if (hasRequiredAssertion_error) return assertion_error;
|
|
2456
|
+
hasRequiredAssertion_error = 1;
|
|
2457
|
+
|
|
2458
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
2459
|
+
|
|
2460
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2461
|
+
|
|
2462
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2463
|
+
|
|
2464
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
2465
|
+
|
|
2466
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
2467
|
+
|
|
2468
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
2469
|
+
|
|
2470
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2471
|
+
|
|
2472
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
2473
|
+
|
|
2474
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
2475
|
+
|
|
2476
|
+
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
2477
|
+
|
|
2478
|
+
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
2479
|
+
|
|
2480
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
2481
|
+
|
|
2482
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
2483
|
+
|
|
2484
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2485
|
+
|
|
2486
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2487
|
+
|
|
2488
|
+
var _require = util,
|
|
2489
|
+
inspect = _require.inspect;
|
|
2490
|
+
|
|
2491
|
+
var _require2 = requireErrors(),
|
|
2492
|
+
ERR_INVALID_ARG_TYPE = _require2.codes.ERR_INVALID_ARG_TYPE; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
function endsWith(str, search, this_len) {
|
|
2496
|
+
if (this_len === undefined || this_len > str.length) {
|
|
2497
|
+
this_len = str.length;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
return str.substring(this_len - search.length, this_len) === search;
|
|
2501
|
+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
|
|
2502
|
+
|
|
2503
|
+
|
|
2504
|
+
function repeat(str, count) {
|
|
2505
|
+
count = Math.floor(count);
|
|
2506
|
+
if (str.length == 0 || count == 0) return '';
|
|
2507
|
+
var maxCount = str.length * count;
|
|
2508
|
+
count = Math.floor(Math.log(count) / Math.log(2));
|
|
2509
|
+
|
|
2510
|
+
while (count) {
|
|
2511
|
+
str += str;
|
|
2512
|
+
count--;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
str += str.substring(0, maxCount - str.length);
|
|
2516
|
+
return str;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
var blue = '';
|
|
2520
|
+
var green = '';
|
|
2521
|
+
var red = '';
|
|
2522
|
+
var white = '';
|
|
2523
|
+
var kReadableOperator = {
|
|
2524
|
+
deepStrictEqual: 'Expected values to be strictly deep-equal:',
|
|
2525
|
+
strictEqual: 'Expected values to be strictly equal:',
|
|
2526
|
+
strictEqualObject: 'Expected "actual" to be reference-equal to "expected":',
|
|
2527
|
+
deepEqual: 'Expected values to be loosely deep-equal:',
|
|
2528
|
+
equal: 'Expected values to be loosely equal:',
|
|
2529
|
+
notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:',
|
|
2530
|
+
notStrictEqual: 'Expected "actual" to be strictly unequal to:',
|
|
2531
|
+
notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":',
|
|
2532
|
+
notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:',
|
|
2533
|
+
notEqual: 'Expected "actual" to be loosely unequal to:',
|
|
2534
|
+
notIdentical: 'Values identical but not reference-equal:'
|
|
2535
|
+
}; // Comparing short primitives should just show === / !== instead of using the
|
|
2536
|
+
// diff.
|
|
2537
|
+
|
|
2538
|
+
var kMaxShortLength = 10;
|
|
2539
|
+
|
|
2540
|
+
function copyError(source) {
|
|
2541
|
+
var keys = Object.keys(source);
|
|
2542
|
+
var target = Object.create(Object.getPrototypeOf(source));
|
|
2543
|
+
keys.forEach(function (key) {
|
|
2544
|
+
target[key] = source[key];
|
|
2545
|
+
});
|
|
2546
|
+
Object.defineProperty(target, 'message', {
|
|
2547
|
+
value: source.message
|
|
2548
|
+
});
|
|
2549
|
+
return target;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
function inspectValue(val) {
|
|
2553
|
+
// The util.inspect default values could be changed. This makes sure the
|
|
2554
|
+
// error messages contain the necessary information nevertheless.
|
|
2555
|
+
return inspect(val, {
|
|
2556
|
+
compact: false,
|
|
2557
|
+
customInspect: false,
|
|
2558
|
+
depth: 1000,
|
|
2559
|
+
maxArrayLength: Infinity,
|
|
2560
|
+
// Assert compares only enumerable properties (with a few exceptions).
|
|
2561
|
+
showHidden: false,
|
|
2562
|
+
// Having a long line as error is better than wrapping the line for
|
|
2563
|
+
// comparison for now.
|
|
2564
|
+
// TODO(BridgeAR): `breakLength` should be limited as soon as soon as we
|
|
2565
|
+
// have meta information about the inspected properties (i.e., know where
|
|
2566
|
+
// in what line the property starts and ends).
|
|
2567
|
+
breakLength: Infinity,
|
|
2568
|
+
// Assert does not detect proxies currently.
|
|
2569
|
+
showProxy: false,
|
|
2570
|
+
sorted: true,
|
|
2571
|
+
// Inspect getters as we also check them when comparing entries.
|
|
2572
|
+
getters: true
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
function createErrDiff(actual, expected, operator) {
|
|
2577
|
+
var other = '';
|
|
2578
|
+
var res = '';
|
|
2579
|
+
var lastPos = 0;
|
|
2580
|
+
var end = '';
|
|
2581
|
+
var skipped = false;
|
|
2582
|
+
var actualInspected = inspectValue(actual);
|
|
2583
|
+
var actualLines = actualInspected.split('\n');
|
|
2584
|
+
var expectedLines = inspectValue(expected).split('\n');
|
|
2585
|
+
var i = 0;
|
|
2586
|
+
var indicator = ''; // In case both values are objects explicitly mark them as not reference equal
|
|
2587
|
+
// for the `strictEqual` operator.
|
|
2588
|
+
|
|
2589
|
+
if (operator === 'strictEqual' && _typeof(actual) === 'object' && _typeof(expected) === 'object' && actual !== null && expected !== null) {
|
|
2590
|
+
operator = 'strictEqualObject';
|
|
2591
|
+
} // If "actual" and "expected" fit on a single line and they are not strictly
|
|
2592
|
+
// equal, check further special handling.
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
if (actualLines.length === 1 && expectedLines.length === 1 && actualLines[0] !== expectedLines[0]) {
|
|
2596
|
+
var inputLength = actualLines[0].length + expectedLines[0].length; // If the character length of "actual" and "expected" together is less than
|
|
2597
|
+
// kMaxShortLength and if neither is an object and at least one of them is
|
|
2598
|
+
// not `zero`, use the strict equal comparison to visualize the output.
|
|
2599
|
+
|
|
2600
|
+
if (inputLength <= kMaxShortLength) {
|
|
2601
|
+
if ((_typeof(actual) !== 'object' || actual === null) && (_typeof(expected) !== 'object' || expected === null) && (actual !== 0 || expected !== 0)) {
|
|
2602
|
+
// -0 === +0
|
|
2603
|
+
return "".concat(kReadableOperator[operator], "\n\n") + "".concat(actualLines[0], " !== ").concat(expectedLines[0], "\n");
|
|
2604
|
+
}
|
|
2605
|
+
} else if (operator !== 'strictEqualObject') {
|
|
2606
|
+
// If the stderr is a tty and the input length is lower than the current
|
|
2607
|
+
// columns per line, add a mismatch indicator below the output. If it is
|
|
2608
|
+
// not a tty, use a default value of 80 characters.
|
|
2609
|
+
var maxLength = process.stderr && process.stderr.isTTY ? process.stderr.columns : 80;
|
|
2610
|
+
|
|
2611
|
+
if (inputLength < maxLength) {
|
|
2612
|
+
while (actualLines[0][i] === expectedLines[0][i]) {
|
|
2613
|
+
i++;
|
|
2614
|
+
} // Ignore the first characters.
|
|
2615
|
+
|
|
2616
|
+
|
|
2617
|
+
if (i > 2) {
|
|
2618
|
+
// Add position indicator for the first mismatch in case it is a
|
|
2619
|
+
// single line and the input length is less than the column length.
|
|
2620
|
+
indicator = "\n ".concat(repeat(' ', i), "^");
|
|
2621
|
+
i = 0;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
} // Remove all ending lines that match (this optimizes the output for
|
|
2626
|
+
// readability by reducing the number of total changed lines).
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
var a = actualLines[actualLines.length - 1];
|
|
2630
|
+
var b = expectedLines[expectedLines.length - 1];
|
|
2631
|
+
|
|
2632
|
+
while (a === b) {
|
|
2633
|
+
if (i++ < 2) {
|
|
2634
|
+
end = "\n ".concat(a).concat(end);
|
|
2635
|
+
} else {
|
|
2636
|
+
other = a;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
actualLines.pop();
|
|
2640
|
+
expectedLines.pop();
|
|
2641
|
+
if (actualLines.length === 0 || expectedLines.length === 0) break;
|
|
2642
|
+
a = actualLines[actualLines.length - 1];
|
|
2643
|
+
b = expectedLines[expectedLines.length - 1];
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
var maxLines = Math.max(actualLines.length, expectedLines.length); // Strict equal with identical objects that are not identical by reference.
|
|
2647
|
+
// E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
|
|
2648
|
+
|
|
2649
|
+
if (maxLines === 0) {
|
|
2650
|
+
// We have to get the result again. The lines were all removed before.
|
|
2651
|
+
var _actualLines = actualInspected.split('\n'); // Only remove lines in case it makes sense to collapse those.
|
|
2652
|
+
// TODO: Accept env to always show the full error.
|
|
2653
|
+
|
|
2654
|
+
|
|
2655
|
+
if (_actualLines.length > 30) {
|
|
2656
|
+
_actualLines[26] = "".concat(blue, "...").concat(white);
|
|
2657
|
+
|
|
2658
|
+
while (_actualLines.length > 27) {
|
|
2659
|
+
_actualLines.pop();
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
return "".concat(kReadableOperator.notIdentical, "\n\n").concat(_actualLines.join('\n'), "\n");
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
if (i > 3) {
|
|
2667
|
+
end = "\n".concat(blue, "...").concat(white).concat(end);
|
|
2668
|
+
skipped = true;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
if (other !== '') {
|
|
2672
|
+
end = "\n ".concat(other).concat(end);
|
|
2673
|
+
other = '';
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
var printedLines = 0;
|
|
2677
|
+
var msg = kReadableOperator[operator] + "\n".concat(green, "+ actual").concat(white, " ").concat(red, "- expected").concat(white);
|
|
2678
|
+
var skippedMsg = " ".concat(blue, "...").concat(white, " Lines skipped");
|
|
2679
|
+
|
|
2680
|
+
for (i = 0; i < maxLines; i++) {
|
|
2681
|
+
// Only extra expected lines exist
|
|
2682
|
+
var cur = i - lastPos;
|
|
2683
|
+
|
|
2684
|
+
if (actualLines.length < i + 1) {
|
|
2685
|
+
// If the last diverging line is more than one line above and the
|
|
2686
|
+
// current line is at least line three, add some of the former lines and
|
|
2687
|
+
// also add dots to indicate skipped entries.
|
|
2688
|
+
if (cur > 1 && i > 2) {
|
|
2689
|
+
if (cur > 4) {
|
|
2690
|
+
res += "\n".concat(blue, "...").concat(white);
|
|
2691
|
+
skipped = true;
|
|
2692
|
+
} else if (cur > 3) {
|
|
2693
|
+
res += "\n ".concat(expectedLines[i - 2]);
|
|
2694
|
+
printedLines++;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
res += "\n ".concat(expectedLines[i - 1]);
|
|
2698
|
+
printedLines++;
|
|
2699
|
+
} // Mark the current line as the last diverging one.
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
lastPos = i; // Add the expected line to the cache.
|
|
2703
|
+
|
|
2704
|
+
other += "\n".concat(red, "-").concat(white, " ").concat(expectedLines[i]);
|
|
2705
|
+
printedLines++; // Only extra actual lines exist
|
|
2706
|
+
} else if (expectedLines.length < i + 1) {
|
|
2707
|
+
// If the last diverging line is more than one line above and the
|
|
2708
|
+
// current line is at least line three, add some of the former lines and
|
|
2709
|
+
// also add dots to indicate skipped entries.
|
|
2710
|
+
if (cur > 1 && i > 2) {
|
|
2711
|
+
if (cur > 4) {
|
|
2712
|
+
res += "\n".concat(blue, "...").concat(white);
|
|
2713
|
+
skipped = true;
|
|
2714
|
+
} else if (cur > 3) {
|
|
2715
|
+
res += "\n ".concat(actualLines[i - 2]);
|
|
2716
|
+
printedLines++;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
res += "\n ".concat(actualLines[i - 1]);
|
|
2720
|
+
printedLines++;
|
|
2721
|
+
} // Mark the current line as the last diverging one.
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
lastPos = i; // Add the actual line to the result.
|
|
2725
|
+
|
|
2726
|
+
res += "\n".concat(green, "+").concat(white, " ").concat(actualLines[i]);
|
|
2727
|
+
printedLines++; // Lines diverge
|
|
2728
|
+
} else {
|
|
2729
|
+
var expectedLine = expectedLines[i];
|
|
2730
|
+
var actualLine = actualLines[i]; // If the lines diverge, specifically check for lines that only diverge by
|
|
2731
|
+
// a trailing comma. In that case it is actually identical and we should
|
|
2732
|
+
// mark it as such.
|
|
2733
|
+
|
|
2734
|
+
var divergingLines = actualLine !== expectedLine && (!endsWith(actualLine, ',') || actualLine.slice(0, -1) !== expectedLine); // If the expected line has a trailing comma but is otherwise identical,
|
|
2735
|
+
// add a comma at the end of the actual line. Otherwise the output could
|
|
2736
|
+
// look weird as in:
|
|
2737
|
+
//
|
|
2738
|
+
// [
|
|
2739
|
+
// 1 // No comma at the end!
|
|
2740
|
+
// + 2
|
|
2741
|
+
// ]
|
|
2742
|
+
//
|
|
2743
|
+
|
|
2744
|
+
if (divergingLines && endsWith(expectedLine, ',') && expectedLine.slice(0, -1) === actualLine) {
|
|
2745
|
+
divergingLines = false;
|
|
2746
|
+
actualLine += ',';
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
if (divergingLines) {
|
|
2750
|
+
// If the last diverging line is more than one line above and the
|
|
2751
|
+
// current line is at least line three, add some of the former lines and
|
|
2752
|
+
// also add dots to indicate skipped entries.
|
|
2753
|
+
if (cur > 1 && i > 2) {
|
|
2754
|
+
if (cur > 4) {
|
|
2755
|
+
res += "\n".concat(blue, "...").concat(white);
|
|
2756
|
+
skipped = true;
|
|
2757
|
+
} else if (cur > 3) {
|
|
2758
|
+
res += "\n ".concat(actualLines[i - 2]);
|
|
2759
|
+
printedLines++;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
res += "\n ".concat(actualLines[i - 1]);
|
|
2763
|
+
printedLines++;
|
|
2764
|
+
} // Mark the current line as the last diverging one.
|
|
2765
|
+
|
|
2766
|
+
|
|
2767
|
+
lastPos = i; // Add the actual line to the result and cache the expected diverging
|
|
2768
|
+
// line so consecutive diverging lines show up as +++--- and not +-+-+-.
|
|
2769
|
+
|
|
2770
|
+
res += "\n".concat(green, "+").concat(white, " ").concat(actualLine);
|
|
2771
|
+
other += "\n".concat(red, "-").concat(white, " ").concat(expectedLine);
|
|
2772
|
+
printedLines += 2; // Lines are identical
|
|
2773
|
+
} else {
|
|
2774
|
+
// Add all cached information to the result before adding other things
|
|
2775
|
+
// and reset the cache.
|
|
2776
|
+
res += other;
|
|
2777
|
+
other = ''; // If the last diverging line is exactly one line above or if it is the
|
|
2778
|
+
// very first line, add the line to the result.
|
|
2779
|
+
|
|
2780
|
+
if (cur === 1 || i === 0) {
|
|
2781
|
+
res += "\n ".concat(actualLine);
|
|
2782
|
+
printedLines++;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
} // Inspected object to big (Show ~20 rows max)
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
if (printedLines > 20 && i < maxLines - 2) {
|
|
2789
|
+
return "".concat(msg).concat(skippedMsg, "\n").concat(res, "\n").concat(blue, "...").concat(white).concat(other, "\n") + "".concat(blue, "...").concat(white);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
return "".concat(msg).concat(skipped ? skippedMsg : '', "\n").concat(res).concat(other).concat(end).concat(indicator);
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
var AssertionError =
|
|
2797
|
+
/*#__PURE__*/
|
|
2798
|
+
function (_Error) {
|
|
2799
|
+
_inherits(AssertionError, _Error);
|
|
2800
|
+
|
|
2801
|
+
function AssertionError(options) {
|
|
2802
|
+
var _this;
|
|
2803
|
+
|
|
2804
|
+
_classCallCheck(this, AssertionError);
|
|
2805
|
+
|
|
2806
|
+
if (_typeof(options) !== 'object' || options === null) {
|
|
2807
|
+
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
var message = options.message,
|
|
2811
|
+
operator = options.operator,
|
|
2812
|
+
stackStartFn = options.stackStartFn;
|
|
2813
|
+
var actual = options.actual,
|
|
2814
|
+
expected = options.expected;
|
|
2815
|
+
var limit = Error.stackTraceLimit;
|
|
2816
|
+
Error.stackTraceLimit = 0;
|
|
2817
|
+
|
|
2818
|
+
if (message != null) {
|
|
2819
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, String(message)));
|
|
2820
|
+
} else {
|
|
2821
|
+
if (process.stderr && process.stderr.isTTY) {
|
|
2822
|
+
// Reset on each call to make sure we handle dynamically set environment
|
|
2823
|
+
// variables correct.
|
|
2824
|
+
if (process.stderr && process.stderr.getColorDepth && process.stderr.getColorDepth() !== 1) {
|
|
2825
|
+
blue = "\x1B[34m";
|
|
2826
|
+
green = "\x1B[32m";
|
|
2827
|
+
white = "\x1B[39m";
|
|
2828
|
+
red = "\x1B[31m";
|
|
2829
|
+
} else {
|
|
2830
|
+
blue = '';
|
|
2831
|
+
green = '';
|
|
2832
|
+
white = '';
|
|
2833
|
+
red = '';
|
|
2834
|
+
}
|
|
2835
|
+
} // Prevent the error stack from being visible by duplicating the error
|
|
2836
|
+
// in a very close way to the original in case both sides are actually
|
|
2837
|
+
// instances of Error.
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
if (_typeof(actual) === 'object' && actual !== null && _typeof(expected) === 'object' && expected !== null && 'stack' in actual && actual instanceof Error && 'stack' in expected && expected instanceof Error) {
|
|
2841
|
+
actual = copyError(actual);
|
|
2842
|
+
expected = copyError(expected);
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
if (operator === 'deepStrictEqual' || operator === 'strictEqual') {
|
|
2846
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, createErrDiff(actual, expected, operator)));
|
|
2847
|
+
} else if (operator === 'notDeepStrictEqual' || operator === 'notStrictEqual') {
|
|
2848
|
+
// In case the objects are equal but the operator requires unequal, show
|
|
2849
|
+
// the first object and say A equals B
|
|
2850
|
+
var base = kReadableOperator[operator];
|
|
2851
|
+
var res = inspectValue(actual).split('\n'); // In case "actual" is an object, it should not be reference equal.
|
|
2852
|
+
|
|
2853
|
+
if (operator === 'notStrictEqual' && _typeof(actual) === 'object' && actual !== null) {
|
|
2854
|
+
base = kReadableOperator.notStrictEqualObject;
|
|
2855
|
+
} // Only remove lines in case it makes sense to collapse those.
|
|
2856
|
+
// TODO: Accept env to always show the full error.
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
if (res.length > 30) {
|
|
2860
|
+
res[26] = "".concat(blue, "...").concat(white);
|
|
2861
|
+
|
|
2862
|
+
while (res.length > 27) {
|
|
2863
|
+
res.pop();
|
|
2864
|
+
}
|
|
2865
|
+
} // Only print a single input.
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
if (res.length === 1) {
|
|
2869
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, " ").concat(res[0])));
|
|
2870
|
+
} else {
|
|
2871
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, "\n\n").concat(res.join('\n'), "\n")));
|
|
2872
|
+
}
|
|
2873
|
+
} else {
|
|
2874
|
+
var _res = inspectValue(actual);
|
|
2875
|
+
|
|
2876
|
+
var other = '';
|
|
2877
|
+
var knownOperators = kReadableOperator[operator];
|
|
2878
|
+
|
|
2879
|
+
if (operator === 'notDeepEqual' || operator === 'notEqual') {
|
|
2880
|
+
_res = "".concat(kReadableOperator[operator], "\n\n").concat(_res);
|
|
2881
|
+
|
|
2882
|
+
if (_res.length > 1024) {
|
|
2883
|
+
_res = "".concat(_res.slice(0, 1021), "...");
|
|
2884
|
+
}
|
|
2885
|
+
} else {
|
|
2886
|
+
other = "".concat(inspectValue(expected));
|
|
2887
|
+
|
|
2888
|
+
if (_res.length > 512) {
|
|
2889
|
+
_res = "".concat(_res.slice(0, 509), "...");
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
if (other.length > 512) {
|
|
2893
|
+
other = "".concat(other.slice(0, 509), "...");
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
if (operator === 'deepEqual' || operator === 'equal') {
|
|
2897
|
+
_res = "".concat(knownOperators, "\n\n").concat(_res, "\n\nshould equal\n\n");
|
|
2898
|
+
} else {
|
|
2899
|
+
other = " ".concat(operator, " ").concat(other);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(_res).concat(other)));
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
Error.stackTraceLimit = limit;
|
|
2908
|
+
_this.generatedMessage = !message;
|
|
2909
|
+
Object.defineProperty(_assertThisInitialized(_this), 'name', {
|
|
2910
|
+
value: 'AssertionError [ERR_ASSERTION]',
|
|
2911
|
+
enumerable: false,
|
|
2912
|
+
writable: true,
|
|
2913
|
+
configurable: true
|
|
2914
|
+
});
|
|
2915
|
+
_this.code = 'ERR_ASSERTION';
|
|
2916
|
+
_this.actual = actual;
|
|
2917
|
+
_this.expected = expected;
|
|
2918
|
+
_this.operator = operator;
|
|
2919
|
+
|
|
2920
|
+
if (Error.captureStackTrace) {
|
|
2921
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
2922
|
+
Error.captureStackTrace(_assertThisInitialized(_this), stackStartFn);
|
|
2923
|
+
} // Create error message including the error code in the name.
|
|
2924
|
+
|
|
2925
|
+
|
|
2926
|
+
_this.stack; // Reset the name.
|
|
2927
|
+
|
|
2928
|
+
_this.name = 'AssertionError';
|
|
2929
|
+
return _possibleConstructorReturn(_this);
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
_createClass(AssertionError, [{
|
|
2933
|
+
key: "toString",
|
|
2934
|
+
value: function toString() {
|
|
2935
|
+
return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message);
|
|
2936
|
+
}
|
|
2937
|
+
}, {
|
|
2938
|
+
key: inspect.custom,
|
|
2939
|
+
value: function value(recurseTimes, ctx) {
|
|
2940
|
+
// This limits the `actual` and `expected` property default inspection to
|
|
2941
|
+
// the minimum depth. Otherwise those values would be too verbose compared
|
|
2942
|
+
// to the actual error message which contains a combined view of these two
|
|
2943
|
+
// input values.
|
|
2944
|
+
return inspect(this, _objectSpread({}, ctx, {
|
|
2945
|
+
customInspect: false,
|
|
2946
|
+
depth: 0
|
|
2947
|
+
}));
|
|
2948
|
+
}
|
|
2949
|
+
}]);
|
|
2950
|
+
|
|
2951
|
+
return AssertionError;
|
|
2952
|
+
}(_wrapNativeSuper(Error));
|
|
2953
|
+
|
|
2954
|
+
assertion_error = AssertionError;
|
|
2955
|
+
return assertion_error;
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
var comparisons;
|
|
2959
|
+
var hasRequiredComparisons;
|
|
2960
|
+
|
|
2961
|
+
function requireComparisons () {
|
|
2962
|
+
if (hasRequiredComparisons) return comparisons;
|
|
2963
|
+
hasRequiredComparisons = 1;
|
|
2964
|
+
|
|
2965
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
2966
|
+
|
|
2967
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
2968
|
+
|
|
2969
|
+
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
2970
|
+
|
|
2971
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2972
|
+
|
|
2973
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2974
|
+
|
|
2975
|
+
var regexFlagsSupported = /a/g.flags !== undefined;
|
|
2976
|
+
|
|
2977
|
+
var arrayFromSet = function arrayFromSet(set) {
|
|
2978
|
+
var array = [];
|
|
2979
|
+
set.forEach(function (value) {
|
|
2980
|
+
return array.push(value);
|
|
2981
|
+
});
|
|
2982
|
+
return array;
|
|
2983
|
+
};
|
|
2984
|
+
|
|
2985
|
+
var arrayFromMap = function arrayFromMap(map) {
|
|
2986
|
+
var array = [];
|
|
2987
|
+
map.forEach(function (value, key) {
|
|
2988
|
+
return array.push([key, value]);
|
|
2989
|
+
});
|
|
2990
|
+
return array;
|
|
2991
|
+
};
|
|
2992
|
+
|
|
2993
|
+
var objectIs = Object.is ? Object.is : require$$0__default$1["default"];
|
|
2994
|
+
var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function () {
|
|
2995
|
+
return [];
|
|
2996
|
+
};
|
|
2997
|
+
var numberIsNaN = Number.isNaN ? Number.isNaN : require$$1__default$1["default"];
|
|
2998
|
+
|
|
2999
|
+
function uncurryThis(f) {
|
|
3000
|
+
return f.call.bind(f);
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
var hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
|
|
3004
|
+
var propertyIsEnumerable = uncurryThis(Object.prototype.propertyIsEnumerable);
|
|
3005
|
+
var objectToString = uncurryThis(Object.prototype.toString);
|
|
3006
|
+
|
|
3007
|
+
var _require$types = util.types,
|
|
3008
|
+
isAnyArrayBuffer = _require$types.isAnyArrayBuffer,
|
|
3009
|
+
isArrayBufferView = _require$types.isArrayBufferView,
|
|
3010
|
+
isDate = _require$types.isDate,
|
|
3011
|
+
isMap = _require$types.isMap,
|
|
3012
|
+
isRegExp = _require$types.isRegExp,
|
|
3013
|
+
isSet = _require$types.isSet,
|
|
3014
|
+
isNativeError = _require$types.isNativeError,
|
|
3015
|
+
isBoxedPrimitive = _require$types.isBoxedPrimitive,
|
|
3016
|
+
isNumberObject = _require$types.isNumberObject,
|
|
3017
|
+
isStringObject = _require$types.isStringObject,
|
|
3018
|
+
isBooleanObject = _require$types.isBooleanObject,
|
|
3019
|
+
isBigIntObject = _require$types.isBigIntObject,
|
|
3020
|
+
isSymbolObject = _require$types.isSymbolObject,
|
|
3021
|
+
isFloat32Array = _require$types.isFloat32Array,
|
|
3022
|
+
isFloat64Array = _require$types.isFloat64Array;
|
|
3023
|
+
|
|
3024
|
+
function isNonIndex(key) {
|
|
3025
|
+
if (key.length === 0 || key.length > 10) return true;
|
|
3026
|
+
|
|
3027
|
+
for (var i = 0; i < key.length; i++) {
|
|
3028
|
+
var code = key.charCodeAt(i);
|
|
3029
|
+
if (code < 48 || code > 57) return true;
|
|
3030
|
+
} // The maximum size for an array is 2 ** 32 -1.
|
|
3031
|
+
|
|
3032
|
+
|
|
3033
|
+
return key.length === 10 && key >= Math.pow(2, 32);
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
function getOwnNonIndexProperties(value) {
|
|
3037
|
+
return Object.keys(value).filter(isNonIndex).concat(objectGetOwnPropertySymbols(value).filter(Object.prototype.propertyIsEnumerable.bind(value)));
|
|
3038
|
+
} // Taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
|
|
3039
|
+
// original notice:
|
|
3040
|
+
|
|
3041
|
+
/*!
|
|
3042
|
+
* The buffer module from node.js, for the browser.
|
|
3043
|
+
*
|
|
3044
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
3045
|
+
* @license MIT
|
|
3046
|
+
*/
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
function compare(a, b) {
|
|
3050
|
+
if (a === b) {
|
|
3051
|
+
return 0;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
var x = a.length;
|
|
3055
|
+
var y = b.length;
|
|
3056
|
+
|
|
3057
|
+
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
3058
|
+
if (a[i] !== b[i]) {
|
|
3059
|
+
x = a[i];
|
|
3060
|
+
y = b[i];
|
|
3061
|
+
break;
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
if (x < y) {
|
|
3066
|
+
return -1;
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
if (y < x) {
|
|
3070
|
+
return 1;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
return 0;
|
|
3074
|
+
}
|
|
3075
|
+
var kStrict = true;
|
|
3076
|
+
var kLoose = false;
|
|
3077
|
+
var kNoIterator = 0;
|
|
3078
|
+
var kIsArray = 1;
|
|
3079
|
+
var kIsSet = 2;
|
|
3080
|
+
var kIsMap = 3; // Check if they have the same source and flags
|
|
3081
|
+
|
|
3082
|
+
function areSimilarRegExps(a, b) {
|
|
3083
|
+
return regexFlagsSupported ? a.source === b.source && a.flags === b.flags : RegExp.prototype.toString.call(a) === RegExp.prototype.toString.call(b);
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
function areSimilarFloatArrays(a, b) {
|
|
3087
|
+
if (a.byteLength !== b.byteLength) {
|
|
3088
|
+
return false;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
for (var offset = 0; offset < a.byteLength; offset++) {
|
|
3092
|
+
if (a[offset] !== b[offset]) {
|
|
3093
|
+
return false;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
return true;
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
function areSimilarTypedArrays(a, b) {
|
|
3101
|
+
if (a.byteLength !== b.byteLength) {
|
|
3102
|
+
return false;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
return compare(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
function areEqualArrayBuffers(buf1, buf2) {
|
|
3109
|
+
return buf1.byteLength === buf2.byteLength && compare(new Uint8Array(buf1), new Uint8Array(buf2)) === 0;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
function isEqualBoxedPrimitive(val1, val2) {
|
|
3113
|
+
if (isNumberObject(val1)) {
|
|
3114
|
+
return isNumberObject(val2) && objectIs(Number.prototype.valueOf.call(val1), Number.prototype.valueOf.call(val2));
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
if (isStringObject(val1)) {
|
|
3118
|
+
return isStringObject(val2) && String.prototype.valueOf.call(val1) === String.prototype.valueOf.call(val2);
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
if (isBooleanObject(val1)) {
|
|
3122
|
+
return isBooleanObject(val2) && Boolean.prototype.valueOf.call(val1) === Boolean.prototype.valueOf.call(val2);
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
if (isBigIntObject(val1)) {
|
|
3126
|
+
return isBigIntObject(val2) && BigInt.prototype.valueOf.call(val1) === BigInt.prototype.valueOf.call(val2);
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
return isSymbolObject(val2) && Symbol.prototype.valueOf.call(val1) === Symbol.prototype.valueOf.call(val2);
|
|
3130
|
+
} // Notes: Type tags are historical [[Class]] properties that can be set by
|
|
3131
|
+
// FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS
|
|
3132
|
+
// and retrieved using Object.prototype.toString.call(obj) in JS
|
|
3133
|
+
// See https://tc39.github.io/ecma262/#sec-object.prototype.tostring
|
|
3134
|
+
// for a list of tags pre-defined in the spec.
|
|
3135
|
+
// There are some unspecified tags in the wild too (e.g. typed array tags).
|
|
3136
|
+
// Since tags can be altered, they only serve fast failures
|
|
3137
|
+
//
|
|
3138
|
+
// Typed arrays and buffers are checked by comparing the content in their
|
|
3139
|
+
// underlying ArrayBuffer. This optimization requires that it's
|
|
3140
|
+
// reasonable to interpret their underlying memory in the same way,
|
|
3141
|
+
// which is checked by comparing their type tags.
|
|
3142
|
+
// (e.g. a Uint8Array and a Uint16Array with the same memory content
|
|
3143
|
+
// could still be different because they will be interpreted differently).
|
|
3144
|
+
//
|
|
3145
|
+
// For strict comparison, objects should have
|
|
3146
|
+
// a) The same built-in type tags
|
|
3147
|
+
// b) The same prototypes.
|
|
3148
|
+
|
|
3149
|
+
|
|
3150
|
+
function innerDeepEqual(val1, val2, strict, memos) {
|
|
3151
|
+
// All identical values are equivalent, as determined by ===.
|
|
3152
|
+
if (val1 === val2) {
|
|
3153
|
+
if (val1 !== 0) return true;
|
|
3154
|
+
return strict ? objectIs(val1, val2) : true;
|
|
3155
|
+
} // Check more closely if val1 and val2 are equal.
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
if (strict) {
|
|
3159
|
+
if (_typeof(val1) !== 'object') {
|
|
3160
|
+
return typeof val1 === 'number' && numberIsNaN(val1) && numberIsNaN(val2);
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
if (_typeof(val2) !== 'object' || val1 === null || val2 === null) {
|
|
3164
|
+
return false;
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
if (Object.getPrototypeOf(val1) !== Object.getPrototypeOf(val2)) {
|
|
3168
|
+
return false;
|
|
3169
|
+
}
|
|
3170
|
+
} else {
|
|
3171
|
+
if (val1 === null || _typeof(val1) !== 'object') {
|
|
3172
|
+
if (val2 === null || _typeof(val2) !== 'object') {
|
|
3173
|
+
// eslint-disable-next-line eqeqeq
|
|
3174
|
+
return val1 == val2;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
return false;
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
if (val2 === null || _typeof(val2) !== 'object') {
|
|
3181
|
+
return false;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
var val1Tag = objectToString(val1);
|
|
3186
|
+
var val2Tag = objectToString(val2);
|
|
3187
|
+
|
|
3188
|
+
if (val1Tag !== val2Tag) {
|
|
3189
|
+
return false;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
if (Array.isArray(val1)) {
|
|
3193
|
+
// Check for sparse arrays and general fast path
|
|
3194
|
+
if (val1.length !== val2.length) {
|
|
3195
|
+
return false;
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
var keys1 = getOwnNonIndexProperties(val1);
|
|
3199
|
+
var keys2 = getOwnNonIndexProperties(val2);
|
|
3200
|
+
|
|
3201
|
+
if (keys1.length !== keys2.length) {
|
|
3202
|
+
return false;
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
return keyCheck(val1, val2, strict, memos, kIsArray, keys1);
|
|
3206
|
+
} // [browserify] This triggers on certain types in IE (Map/Set) so we don't
|
|
3207
|
+
// wan't to early return out of the rest of the checks. However we can check
|
|
3208
|
+
// if the second value is one of these values and the first isn't.
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
if (val1Tag === '[object Object]') {
|
|
3212
|
+
// return keyCheck(val1, val2, strict, memos, kNoIterator);
|
|
3213
|
+
if (!isMap(val1) && isMap(val2) || !isSet(val1) && isSet(val2)) {
|
|
3214
|
+
return false;
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
if (isDate(val1)) {
|
|
3219
|
+
if (!isDate(val2) || Date.prototype.getTime.call(val1) !== Date.prototype.getTime.call(val2)) {
|
|
3220
|
+
return false;
|
|
3221
|
+
}
|
|
3222
|
+
} else if (isRegExp(val1)) {
|
|
3223
|
+
if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) {
|
|
3224
|
+
return false;
|
|
3225
|
+
}
|
|
3226
|
+
} else if (isNativeError(val1) || val1 instanceof Error) {
|
|
3227
|
+
// Do not compare the stack as it might differ even though the error itself
|
|
3228
|
+
// is otherwise identical.
|
|
3229
|
+
if (val1.message !== val2.message || val1.name !== val2.name) {
|
|
3230
|
+
return false;
|
|
3231
|
+
}
|
|
3232
|
+
} else if (isArrayBufferView(val1)) {
|
|
3233
|
+
if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) {
|
|
3234
|
+
if (!areSimilarFloatArrays(val1, val2)) {
|
|
3235
|
+
return false;
|
|
3236
|
+
}
|
|
3237
|
+
} else if (!areSimilarTypedArrays(val1, val2)) {
|
|
3238
|
+
return false;
|
|
3239
|
+
} // Buffer.compare returns true, so val1.length === val2.length. If they both
|
|
3240
|
+
// only contain numeric keys, we don't need to exam further than checking
|
|
3241
|
+
// the symbols.
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
var _keys = getOwnNonIndexProperties(val1);
|
|
3245
|
+
|
|
3246
|
+
var _keys2 = getOwnNonIndexProperties(val2);
|
|
3247
|
+
|
|
3248
|
+
if (_keys.length !== _keys2.length) {
|
|
3249
|
+
return false;
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
return keyCheck(val1, val2, strict, memos, kNoIterator, _keys);
|
|
3253
|
+
} else if (isSet(val1)) {
|
|
3254
|
+
if (!isSet(val2) || val1.size !== val2.size) {
|
|
3255
|
+
return false;
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
return keyCheck(val1, val2, strict, memos, kIsSet);
|
|
3259
|
+
} else if (isMap(val1)) {
|
|
3260
|
+
if (!isMap(val2) || val1.size !== val2.size) {
|
|
3261
|
+
return false;
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
return keyCheck(val1, val2, strict, memos, kIsMap);
|
|
3265
|
+
} else if (isAnyArrayBuffer(val1)) {
|
|
3266
|
+
if (!areEqualArrayBuffers(val1, val2)) {
|
|
3267
|
+
return false;
|
|
3268
|
+
}
|
|
3269
|
+
} else if (isBoxedPrimitive(val1) && !isEqualBoxedPrimitive(val1, val2)) {
|
|
3270
|
+
return false;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
return keyCheck(val1, val2, strict, memos, kNoIterator);
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
function getEnumerables(val, keys) {
|
|
3277
|
+
return keys.filter(function (k) {
|
|
3278
|
+
return propertyIsEnumerable(val, k);
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
|
|
3283
|
+
// For all remaining Object pairs, including Array, objects and Maps,
|
|
3284
|
+
// equivalence is determined by having:
|
|
3285
|
+
// a) The same number of owned enumerable properties
|
|
3286
|
+
// b) The same set of keys/indexes (although not necessarily the same order)
|
|
3287
|
+
// c) Equivalent values for every corresponding key/index
|
|
3288
|
+
// d) For Sets and Maps, equal contents
|
|
3289
|
+
// Note: this accounts for both named and indexed properties on Arrays.
|
|
3290
|
+
if (arguments.length === 5) {
|
|
3291
|
+
aKeys = Object.keys(val1);
|
|
3292
|
+
var bKeys = Object.keys(val2); // The pair must have the same number of owned properties.
|
|
3293
|
+
|
|
3294
|
+
if (aKeys.length !== bKeys.length) {
|
|
3295
|
+
return false;
|
|
3296
|
+
}
|
|
3297
|
+
} // Cheap key test
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
var i = 0;
|
|
3301
|
+
|
|
3302
|
+
for (; i < aKeys.length; i++) {
|
|
3303
|
+
if (!hasOwnProperty(val2, aKeys[i])) {
|
|
3304
|
+
return false;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
if (strict && arguments.length === 5) {
|
|
3309
|
+
var symbolKeysA = objectGetOwnPropertySymbols(val1);
|
|
3310
|
+
|
|
3311
|
+
if (symbolKeysA.length !== 0) {
|
|
3312
|
+
var count = 0;
|
|
3313
|
+
|
|
3314
|
+
for (i = 0; i < symbolKeysA.length; i++) {
|
|
3315
|
+
var key = symbolKeysA[i];
|
|
3316
|
+
|
|
3317
|
+
if (propertyIsEnumerable(val1, key)) {
|
|
3318
|
+
if (!propertyIsEnumerable(val2, key)) {
|
|
3319
|
+
return false;
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
aKeys.push(key);
|
|
3323
|
+
count++;
|
|
3324
|
+
} else if (propertyIsEnumerable(val2, key)) {
|
|
3325
|
+
return false;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
|
|
3329
|
+
var symbolKeysB = objectGetOwnPropertySymbols(val2);
|
|
3330
|
+
|
|
3331
|
+
if (symbolKeysA.length !== symbolKeysB.length && getEnumerables(val2, symbolKeysB).length !== count) {
|
|
3332
|
+
return false;
|
|
3333
|
+
}
|
|
3334
|
+
} else {
|
|
3335
|
+
var _symbolKeysB = objectGetOwnPropertySymbols(val2);
|
|
3336
|
+
|
|
3337
|
+
if (_symbolKeysB.length !== 0 && getEnumerables(val2, _symbolKeysB).length !== 0) {
|
|
3338
|
+
return false;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
if (aKeys.length === 0 && (iterationType === kNoIterator || iterationType === kIsArray && val1.length === 0 || val1.size === 0)) {
|
|
3344
|
+
return true;
|
|
3345
|
+
} // Use memos to handle cycles.
|
|
3346
|
+
|
|
3347
|
+
|
|
3348
|
+
if (memos === undefined) {
|
|
3349
|
+
memos = {
|
|
3350
|
+
val1: new Map(),
|
|
3351
|
+
val2: new Map(),
|
|
3352
|
+
position: 0
|
|
3353
|
+
};
|
|
3354
|
+
} else {
|
|
3355
|
+
// We prevent up to two map.has(x) calls by directly retrieving the value
|
|
3356
|
+
// and checking for undefined. The map can only contain numbers, so it is
|
|
3357
|
+
// safe to check for undefined only.
|
|
3358
|
+
var val2MemoA = memos.val1.get(val1);
|
|
3359
|
+
|
|
3360
|
+
if (val2MemoA !== undefined) {
|
|
3361
|
+
var val2MemoB = memos.val2.get(val2);
|
|
3362
|
+
|
|
3363
|
+
if (val2MemoB !== undefined) {
|
|
3364
|
+
return val2MemoA === val2MemoB;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
memos.position++;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
memos.val1.set(val1, memos.position);
|
|
3372
|
+
memos.val2.set(val2, memos.position);
|
|
3373
|
+
var areEq = objEquiv(val1, val2, strict, aKeys, memos, iterationType);
|
|
3374
|
+
memos.val1.delete(val1);
|
|
3375
|
+
memos.val2.delete(val2);
|
|
3376
|
+
return areEq;
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
function setHasEqualElement(set, val1, strict, memo) {
|
|
3380
|
+
// Go looking.
|
|
3381
|
+
var setValues = arrayFromSet(set);
|
|
3382
|
+
|
|
3383
|
+
for (var i = 0; i < setValues.length; i++) {
|
|
3384
|
+
var val2 = setValues[i];
|
|
3385
|
+
|
|
3386
|
+
if (innerDeepEqual(val1, val2, strict, memo)) {
|
|
3387
|
+
// Remove the matching element to make sure we do not check that again.
|
|
3388
|
+
set.delete(val2);
|
|
3389
|
+
return true;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
return false;
|
|
3394
|
+
} // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Loose_equality_using
|
|
3395
|
+
// Sadly it is not possible to detect corresponding values properly in case the
|
|
3396
|
+
// type is a string, number, bigint or boolean. The reason is that those values
|
|
3397
|
+
// can match lots of different string values (e.g., 1n == '+00001').
|
|
3398
|
+
|
|
3399
|
+
|
|
3400
|
+
function findLooseMatchingPrimitives(prim) {
|
|
3401
|
+
switch (_typeof(prim)) {
|
|
3402
|
+
case 'undefined':
|
|
3403
|
+
return null;
|
|
3404
|
+
|
|
3405
|
+
case 'object':
|
|
3406
|
+
// Only pass in null as object!
|
|
3407
|
+
return undefined;
|
|
3408
|
+
|
|
3409
|
+
case 'symbol':
|
|
3410
|
+
return false;
|
|
3411
|
+
|
|
3412
|
+
case 'string':
|
|
3413
|
+
prim = +prim;
|
|
3414
|
+
// Loose equal entries exist only if the string is possible to convert to
|
|
3415
|
+
// a regular number and not NaN.
|
|
3416
|
+
// Fall through
|
|
3417
|
+
|
|
3418
|
+
case 'number':
|
|
3419
|
+
if (numberIsNaN(prim)) {
|
|
3420
|
+
return false;
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
return true;
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
function setMightHaveLoosePrim(a, b, prim) {
|
|
3429
|
+
var altValue = findLooseMatchingPrimitives(prim);
|
|
3430
|
+
if (altValue != null) return altValue;
|
|
3431
|
+
return b.has(altValue) && !a.has(altValue);
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
function mapMightHaveLoosePrim(a, b, prim, item, memo) {
|
|
3435
|
+
var altValue = findLooseMatchingPrimitives(prim);
|
|
3436
|
+
|
|
3437
|
+
if (altValue != null) {
|
|
3438
|
+
return altValue;
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
var curB = b.get(altValue);
|
|
3442
|
+
|
|
3443
|
+
if (curB === undefined && !b.has(altValue) || !innerDeepEqual(item, curB, false, memo)) {
|
|
3444
|
+
return false;
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
return !a.has(altValue) && innerDeepEqual(item, curB, false, memo);
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
function setEquiv(a, b, strict, memo) {
|
|
3451
|
+
// This is a lazily initiated Set of entries which have to be compared
|
|
3452
|
+
// pairwise.
|
|
3453
|
+
var set = null;
|
|
3454
|
+
var aValues = arrayFromSet(a);
|
|
3455
|
+
|
|
3456
|
+
for (var i = 0; i < aValues.length; i++) {
|
|
3457
|
+
var val = aValues[i]; // Note: Checking for the objects first improves the performance for object
|
|
3458
|
+
// heavy sets but it is a minor slow down for primitives. As they are fast
|
|
3459
|
+
// to check this improves the worst case scenario instead.
|
|
3460
|
+
|
|
3461
|
+
if (_typeof(val) === 'object' && val !== null) {
|
|
3462
|
+
if (set === null) {
|
|
3463
|
+
set = new Set();
|
|
3464
|
+
} // If the specified value doesn't exist in the second set its an not null
|
|
3465
|
+
// object (or non strict only: a not matching primitive) we'll need to go
|
|
3466
|
+
// hunting for something thats deep-(strict-)equal to it. To make this
|
|
3467
|
+
// O(n log n) complexity we have to copy these values in a new set first.
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
set.add(val);
|
|
3471
|
+
} else if (!b.has(val)) {
|
|
3472
|
+
if (strict) return false; // Fast path to detect missing string, symbol, undefined and null values.
|
|
3473
|
+
|
|
3474
|
+
if (!setMightHaveLoosePrim(a, b, val)) {
|
|
3475
|
+
return false;
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
if (set === null) {
|
|
3479
|
+
set = new Set();
|
|
3480
|
+
}
|
|
3481
|
+
|
|
3482
|
+
set.add(val);
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
if (set !== null) {
|
|
3487
|
+
var bValues = arrayFromSet(b);
|
|
3488
|
+
|
|
3489
|
+
for (var _i = 0; _i < bValues.length; _i++) {
|
|
3490
|
+
var _val = bValues[_i]; // We have to check if a primitive value is already
|
|
3491
|
+
// matching and only if it's not, go hunting for it.
|
|
3492
|
+
|
|
3493
|
+
if (_typeof(_val) === 'object' && _val !== null) {
|
|
3494
|
+
if (!setHasEqualElement(set, _val, strict, memo)) return false;
|
|
3495
|
+
} else if (!strict && !a.has(_val) && !setHasEqualElement(set, _val, strict, memo)) {
|
|
3496
|
+
return false;
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3500
|
+
return set.size === 0;
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
return true;
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
function mapHasEqualEntry(set, map, key1, item1, strict, memo) {
|
|
3507
|
+
// To be able to handle cases like:
|
|
3508
|
+
// Map([[{}, 'a'], [{}, 'b']]) vs Map([[{}, 'b'], [{}, 'a']])
|
|
3509
|
+
// ... we need to consider *all* matching keys, not just the first we find.
|
|
3510
|
+
var setValues = arrayFromSet(set);
|
|
3511
|
+
|
|
3512
|
+
for (var i = 0; i < setValues.length; i++) {
|
|
3513
|
+
var key2 = setValues[i];
|
|
3514
|
+
|
|
3515
|
+
if (innerDeepEqual(key1, key2, strict, memo) && innerDeepEqual(item1, map.get(key2), strict, memo)) {
|
|
3516
|
+
set.delete(key2);
|
|
3517
|
+
return true;
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
return false;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
function mapEquiv(a, b, strict, memo) {
|
|
3525
|
+
var set = null;
|
|
3526
|
+
var aEntries = arrayFromMap(a);
|
|
3527
|
+
|
|
3528
|
+
for (var i = 0; i < aEntries.length; i++) {
|
|
3529
|
+
var _aEntries$i = _slicedToArray(aEntries[i], 2),
|
|
3530
|
+
key = _aEntries$i[0],
|
|
3531
|
+
item1 = _aEntries$i[1];
|
|
3532
|
+
|
|
3533
|
+
if (_typeof(key) === 'object' && key !== null) {
|
|
3534
|
+
if (set === null) {
|
|
3535
|
+
set = new Set();
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
set.add(key);
|
|
3539
|
+
} else {
|
|
3540
|
+
// By directly retrieving the value we prevent another b.has(key) check in
|
|
3541
|
+
// almost all possible cases.
|
|
3542
|
+
var item2 = b.get(key);
|
|
3543
|
+
|
|
3544
|
+
if (item2 === undefined && !b.has(key) || !innerDeepEqual(item1, item2, strict, memo)) {
|
|
3545
|
+
if (strict) return false; // Fast path to detect missing string, symbol, undefined and null
|
|
3546
|
+
// keys.
|
|
3547
|
+
|
|
3548
|
+
if (!mapMightHaveLoosePrim(a, b, key, item1, memo)) return false;
|
|
3549
|
+
|
|
3550
|
+
if (set === null) {
|
|
3551
|
+
set = new Set();
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
set.add(key);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
if (set !== null) {
|
|
3560
|
+
var bEntries = arrayFromMap(b);
|
|
3561
|
+
|
|
3562
|
+
for (var _i2 = 0; _i2 < bEntries.length; _i2++) {
|
|
3563
|
+
var _bEntries$_i = _slicedToArray(bEntries[_i2], 2),
|
|
3564
|
+
key = _bEntries$_i[0],
|
|
3565
|
+
item = _bEntries$_i[1];
|
|
3566
|
+
|
|
3567
|
+
if (_typeof(key) === 'object' && key !== null) {
|
|
3568
|
+
if (!mapHasEqualEntry(set, a, key, item, strict, memo)) return false;
|
|
3569
|
+
} else if (!strict && (!a.has(key) || !innerDeepEqual(a.get(key), item, false, memo)) && !mapHasEqualEntry(set, a, key, item, false, memo)) {
|
|
3570
|
+
return false;
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
return set.size === 0;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
return true;
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
function objEquiv(a, b, strict, keys, memos, iterationType) {
|
|
3581
|
+
// Sets and maps don't have their entries accessible via normal object
|
|
3582
|
+
// properties.
|
|
3583
|
+
var i = 0;
|
|
3584
|
+
|
|
3585
|
+
if (iterationType === kIsSet) {
|
|
3586
|
+
if (!setEquiv(a, b, strict, memos)) {
|
|
3587
|
+
return false;
|
|
3588
|
+
}
|
|
3589
|
+
} else if (iterationType === kIsMap) {
|
|
3590
|
+
if (!mapEquiv(a, b, strict, memos)) {
|
|
3591
|
+
return false;
|
|
3592
|
+
}
|
|
3593
|
+
} else if (iterationType === kIsArray) {
|
|
3594
|
+
for (; i < a.length; i++) {
|
|
3595
|
+
if (hasOwnProperty(a, i)) {
|
|
3596
|
+
if (!hasOwnProperty(b, i) || !innerDeepEqual(a[i], b[i], strict, memos)) {
|
|
3597
|
+
return false;
|
|
3598
|
+
}
|
|
3599
|
+
} else if (hasOwnProperty(b, i)) {
|
|
3600
|
+
return false;
|
|
3601
|
+
} else {
|
|
3602
|
+
// Array is sparse.
|
|
3603
|
+
var keysA = Object.keys(a);
|
|
3604
|
+
|
|
3605
|
+
for (; i < keysA.length; i++) {
|
|
3606
|
+
var key = keysA[i];
|
|
3607
|
+
|
|
3608
|
+
if (!hasOwnProperty(b, key) || !innerDeepEqual(a[key], b[key], strict, memos)) {
|
|
3609
|
+
return false;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
3614
|
+
return false;
|
|
3615
|
+
}
|
|
3616
|
+
|
|
3617
|
+
return true;
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
} // The pair must have equivalent values for every corresponding key.
|
|
3621
|
+
// Possibly expensive deep test:
|
|
3622
|
+
|
|
3623
|
+
|
|
3624
|
+
for (i = 0; i < keys.length; i++) {
|
|
3625
|
+
var _key = keys[i];
|
|
3626
|
+
|
|
3627
|
+
if (!innerDeepEqual(a[_key], b[_key], strict, memos)) {
|
|
3628
|
+
return false;
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
return true;
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
function isDeepEqual(val1, val2) {
|
|
3636
|
+
return innerDeepEqual(val1, val2, kLoose);
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3639
|
+
function isDeepStrictEqual(val1, val2) {
|
|
3640
|
+
return innerDeepEqual(val1, val2, kStrict);
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
comparisons = {
|
|
3644
|
+
isDeepEqual: isDeepEqual,
|
|
3645
|
+
isDeepStrictEqual: isDeepStrictEqual
|
|
3646
|
+
};
|
|
3647
|
+
return comparisons;
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
var hasRequiredAssert;
|
|
3651
|
+
|
|
3652
|
+
function requireAssert () {
|
|
3653
|
+
if (hasRequiredAssert) return assertExports$1;
|
|
3654
|
+
hasRequiredAssert = 1;
|
|
3655
|
+
|
|
3656
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
3657
|
+
|
|
3658
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3659
|
+
|
|
3660
|
+
var _require = requireErrors(),
|
|
3661
|
+
_require$codes = _require.codes,
|
|
3662
|
+
ERR_AMBIGUOUS_ARGUMENT = _require$codes.ERR_AMBIGUOUS_ARGUMENT,
|
|
3663
|
+
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
|
3664
|
+
ERR_INVALID_ARG_VALUE = _require$codes.ERR_INVALID_ARG_VALUE,
|
|
3665
|
+
ERR_INVALID_RETURN_VALUE = _require$codes.ERR_INVALID_RETURN_VALUE,
|
|
3666
|
+
ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS;
|
|
3667
|
+
|
|
3668
|
+
var AssertionError = requireAssertion_error();
|
|
3669
|
+
|
|
3670
|
+
var _require2 = util,
|
|
3671
|
+
inspect = _require2.inspect;
|
|
3672
|
+
|
|
3673
|
+
var _require$types = util.types,
|
|
3674
|
+
isPromise = _require$types.isPromise,
|
|
3675
|
+
isRegExp = _require$types.isRegExp;
|
|
3676
|
+
|
|
3677
|
+
var objectAssign = Object.assign ? Object.assign : require$$3__default$1["default"].assign;
|
|
3678
|
+
var objectIs = Object.is ? Object.is : require$$0__default$1["default"];
|
|
3679
|
+
var isDeepEqual;
|
|
3680
|
+
var isDeepStrictEqual;
|
|
3681
|
+
|
|
3682
|
+
function lazyLoadComparison() {
|
|
3683
|
+
var comparison = requireComparisons();
|
|
3684
|
+
|
|
3685
|
+
isDeepEqual = comparison.isDeepEqual;
|
|
3686
|
+
isDeepStrictEqual = comparison.isDeepStrictEqual;
|
|
3687
|
+
} // Escape control characters but not \n and \t to keep the line breaks and
|
|
3688
|
+
|
|
3689
|
+
var warned = false; // The assert module provides functions that throw
|
|
3690
|
+
// AssertionError's when particular conditions are not met. The
|
|
3691
|
+
// assert module must conform to the following interface.
|
|
3692
|
+
|
|
3693
|
+
var assert = assert$1.exports = ok;
|
|
3694
|
+
var NO_EXCEPTION_SENTINEL = {}; // All of the following functions must throw an AssertionError
|
|
3695
|
+
// when a corresponding condition is not met, with a message that
|
|
3696
|
+
// may be undefined if not provided. All assertion methods provide
|
|
3697
|
+
// both the actual and expected values to the assertion error for
|
|
3698
|
+
// display purposes.
|
|
3699
|
+
|
|
3700
|
+
function innerFail(obj) {
|
|
3701
|
+
if (obj.message instanceof Error) throw obj.message;
|
|
3702
|
+
throw new AssertionError(obj);
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
function fail(actual, expected, message, operator, stackStartFn) {
|
|
3706
|
+
var argsLen = arguments.length;
|
|
3707
|
+
var internalMessage;
|
|
3708
|
+
|
|
3709
|
+
if (argsLen === 0) {
|
|
3710
|
+
internalMessage = 'Failed';
|
|
3711
|
+
} else if (argsLen === 1) {
|
|
3712
|
+
message = actual;
|
|
3713
|
+
actual = undefined;
|
|
3714
|
+
} else {
|
|
3715
|
+
if (warned === false) {
|
|
3716
|
+
warned = true;
|
|
3717
|
+
var warn = process.emitWarning ? process.emitWarning : console.warn.bind(console);
|
|
3718
|
+
warn('assert.fail() with more than one argument is deprecated. ' + 'Please use assert.strictEqual() instead or only pass a message.', 'DeprecationWarning', 'DEP0094');
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
if (argsLen === 2) operator = '!=';
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
if (message instanceof Error) throw message;
|
|
3725
|
+
var errArgs = {
|
|
3726
|
+
actual: actual,
|
|
3727
|
+
expected: expected,
|
|
3728
|
+
operator: operator === undefined ? 'fail' : operator,
|
|
3729
|
+
stackStartFn: stackStartFn || fail
|
|
3730
|
+
};
|
|
3731
|
+
|
|
3732
|
+
if (message !== undefined) {
|
|
3733
|
+
errArgs.message = message;
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
var err = new AssertionError(errArgs);
|
|
3737
|
+
|
|
3738
|
+
if (internalMessage) {
|
|
3739
|
+
err.message = internalMessage;
|
|
3740
|
+
err.generatedMessage = true;
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
throw err;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
assert.fail = fail; // The AssertionError is defined in internal/error.
|
|
3747
|
+
|
|
3748
|
+
assert.AssertionError = AssertionError;
|
|
3749
|
+
|
|
3750
|
+
function innerOk(fn, argLen, value, message) {
|
|
3751
|
+
if (!value) {
|
|
3752
|
+
var generatedMessage = false;
|
|
3753
|
+
|
|
3754
|
+
if (argLen === 0) {
|
|
3755
|
+
generatedMessage = true;
|
|
3756
|
+
message = 'No value argument passed to `assert.ok()`';
|
|
3757
|
+
} else if (message instanceof Error) {
|
|
3758
|
+
throw message;
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
var err = new AssertionError({
|
|
3762
|
+
actual: value,
|
|
3763
|
+
expected: true,
|
|
3764
|
+
message: message,
|
|
3765
|
+
operator: '==',
|
|
3766
|
+
stackStartFn: fn
|
|
3767
|
+
});
|
|
3768
|
+
err.generatedMessage = generatedMessage;
|
|
3769
|
+
throw err;
|
|
3770
|
+
}
|
|
3771
|
+
} // Pure assertion tests whether a value is truthy, as determined
|
|
3772
|
+
// by !!value.
|
|
3773
|
+
|
|
3774
|
+
|
|
3775
|
+
function ok() {
|
|
3776
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3777
|
+
args[_key] = arguments[_key];
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
|
+
innerOk.apply(void 0, [ok, args.length].concat(args));
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
assert.ok = ok; // The equality assertion tests shallow, coercive equality with ==.
|
|
3784
|
+
|
|
3785
|
+
/* eslint-disable no-restricted-properties */
|
|
3786
|
+
|
|
3787
|
+
assert.equal = function equal(actual, expected, message) {
|
|
3788
|
+
if (arguments.length < 2) {
|
|
3789
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3790
|
+
} // eslint-disable-next-line eqeqeq
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
if (actual != expected) {
|
|
3794
|
+
innerFail({
|
|
3795
|
+
actual: actual,
|
|
3796
|
+
expected: expected,
|
|
3797
|
+
message: message,
|
|
3798
|
+
operator: '==',
|
|
3799
|
+
stackStartFn: equal
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
}; // The non-equality assertion tests for whether two objects are not
|
|
3803
|
+
// equal with !=.
|
|
3804
|
+
|
|
3805
|
+
|
|
3806
|
+
assert.notEqual = function notEqual(actual, expected, message) {
|
|
3807
|
+
if (arguments.length < 2) {
|
|
3808
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3809
|
+
} // eslint-disable-next-line eqeqeq
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
if (actual == expected) {
|
|
3813
|
+
innerFail({
|
|
3814
|
+
actual: actual,
|
|
3815
|
+
expected: expected,
|
|
3816
|
+
message: message,
|
|
3817
|
+
operator: '!=',
|
|
3818
|
+
stackStartFn: notEqual
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3821
|
+
}; // The equivalence assertion tests a deep equality relation.
|
|
3822
|
+
|
|
3823
|
+
|
|
3824
|
+
assert.deepEqual = function deepEqual(actual, expected, message) {
|
|
3825
|
+
if (arguments.length < 2) {
|
|
3826
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
if (isDeepEqual === undefined) lazyLoadComparison();
|
|
3830
|
+
|
|
3831
|
+
if (!isDeepEqual(actual, expected)) {
|
|
3832
|
+
innerFail({
|
|
3833
|
+
actual: actual,
|
|
3834
|
+
expected: expected,
|
|
3835
|
+
message: message,
|
|
3836
|
+
operator: 'deepEqual',
|
|
3837
|
+
stackStartFn: deepEqual
|
|
3838
|
+
});
|
|
3839
|
+
}
|
|
3840
|
+
}; // The non-equivalence assertion tests for any deep inequality.
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
|
3844
|
+
if (arguments.length < 2) {
|
|
3845
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
if (isDeepEqual === undefined) lazyLoadComparison();
|
|
3849
|
+
|
|
3850
|
+
if (isDeepEqual(actual, expected)) {
|
|
3851
|
+
innerFail({
|
|
3852
|
+
actual: actual,
|
|
3853
|
+
expected: expected,
|
|
3854
|
+
message: message,
|
|
3855
|
+
operator: 'notDeepEqual',
|
|
3856
|
+
stackStartFn: notDeepEqual
|
|
3857
|
+
});
|
|
3858
|
+
}
|
|
3859
|
+
};
|
|
3860
|
+
/* eslint-enable */
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
|
|
3864
|
+
if (arguments.length < 2) {
|
|
3865
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
if (isDeepEqual === undefined) lazyLoadComparison();
|
|
3869
|
+
|
|
3870
|
+
if (!isDeepStrictEqual(actual, expected)) {
|
|
3871
|
+
innerFail({
|
|
3872
|
+
actual: actual,
|
|
3873
|
+
expected: expected,
|
|
3874
|
+
message: message,
|
|
3875
|
+
operator: 'deepStrictEqual',
|
|
3876
|
+
stackStartFn: deepStrictEqual
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
};
|
|
3880
|
+
|
|
3881
|
+
assert.notDeepStrictEqual = notDeepStrictEqual;
|
|
3882
|
+
|
|
3883
|
+
function notDeepStrictEqual(actual, expected, message) {
|
|
3884
|
+
if (arguments.length < 2) {
|
|
3885
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3888
|
+
if (isDeepEqual === undefined) lazyLoadComparison();
|
|
3889
|
+
|
|
3890
|
+
if (isDeepStrictEqual(actual, expected)) {
|
|
3891
|
+
innerFail({
|
|
3892
|
+
actual: actual,
|
|
3893
|
+
expected: expected,
|
|
3894
|
+
message: message,
|
|
3895
|
+
operator: 'notDeepStrictEqual',
|
|
3896
|
+
stackStartFn: notDeepStrictEqual
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
assert.strictEqual = function strictEqual(actual, expected, message) {
|
|
3902
|
+
if (arguments.length < 2) {
|
|
3903
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
if (!objectIs(actual, expected)) {
|
|
3907
|
+
innerFail({
|
|
3908
|
+
actual: actual,
|
|
3909
|
+
expected: expected,
|
|
3910
|
+
message: message,
|
|
3911
|
+
operator: 'strictEqual',
|
|
3912
|
+
stackStartFn: strictEqual
|
|
3913
|
+
});
|
|
3914
|
+
}
|
|
3915
|
+
};
|
|
3916
|
+
|
|
3917
|
+
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
|
3918
|
+
if (arguments.length < 2) {
|
|
3919
|
+
throw new ERR_MISSING_ARGS('actual', 'expected');
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
if (objectIs(actual, expected)) {
|
|
3923
|
+
innerFail({
|
|
3924
|
+
actual: actual,
|
|
3925
|
+
expected: expected,
|
|
3926
|
+
message: message,
|
|
3927
|
+
operator: 'notStrictEqual',
|
|
3928
|
+
stackStartFn: notStrictEqual
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3933
|
+
var Comparison = function Comparison(obj, keys, actual) {
|
|
3934
|
+
var _this = this;
|
|
3935
|
+
|
|
3936
|
+
_classCallCheck(this, Comparison);
|
|
3937
|
+
|
|
3938
|
+
keys.forEach(function (key) {
|
|
3939
|
+
if (key in obj) {
|
|
3940
|
+
if (actual !== undefined && typeof actual[key] === 'string' && isRegExp(obj[key]) && obj[key].test(actual[key])) {
|
|
3941
|
+
_this[key] = actual[key];
|
|
3942
|
+
} else {
|
|
3943
|
+
_this[key] = obj[key];
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
});
|
|
3947
|
+
};
|
|
3948
|
+
|
|
3949
|
+
function compareExceptionKey(actual, expected, key, message, keys, fn) {
|
|
3950
|
+
if (!(key in actual) || !isDeepStrictEqual(actual[key], expected[key])) {
|
|
3951
|
+
if (!message) {
|
|
3952
|
+
// Create placeholder objects to create a nice output.
|
|
3953
|
+
var a = new Comparison(actual, keys);
|
|
3954
|
+
var b = new Comparison(expected, keys, actual);
|
|
3955
|
+
var err = new AssertionError({
|
|
3956
|
+
actual: a,
|
|
3957
|
+
expected: b,
|
|
3958
|
+
operator: 'deepStrictEqual',
|
|
3959
|
+
stackStartFn: fn
|
|
3960
|
+
});
|
|
3961
|
+
err.actual = actual;
|
|
3962
|
+
err.expected = expected;
|
|
3963
|
+
err.operator = fn.name;
|
|
3964
|
+
throw err;
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
innerFail({
|
|
3968
|
+
actual: actual,
|
|
3969
|
+
expected: expected,
|
|
3970
|
+
message: message,
|
|
3971
|
+
operator: fn.name,
|
|
3972
|
+
stackStartFn: fn
|
|
3973
|
+
});
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
function expectedException(actual, expected, msg, fn) {
|
|
3978
|
+
if (typeof expected !== 'function') {
|
|
3979
|
+
if (isRegExp(expected)) return expected.test(actual); // assert.doesNotThrow does not accept objects.
|
|
3980
|
+
|
|
3981
|
+
if (arguments.length === 2) {
|
|
3982
|
+
throw new ERR_INVALID_ARG_TYPE('expected', ['Function', 'RegExp'], expected);
|
|
3983
|
+
} // Handle primitives properly.
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
if (_typeof(actual) !== 'object' || actual === null) {
|
|
3987
|
+
var err = new AssertionError({
|
|
3988
|
+
actual: actual,
|
|
3989
|
+
expected: expected,
|
|
3990
|
+
message: msg,
|
|
3991
|
+
operator: 'deepStrictEqual',
|
|
3992
|
+
stackStartFn: fn
|
|
3993
|
+
});
|
|
3994
|
+
err.operator = fn.name;
|
|
3995
|
+
throw err;
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
var keys = Object.keys(expected); // Special handle errors to make sure the name and the message are compared
|
|
3999
|
+
// as well.
|
|
4000
|
+
|
|
4001
|
+
if (expected instanceof Error) {
|
|
4002
|
+
keys.push('name', 'message');
|
|
4003
|
+
} else if (keys.length === 0) {
|
|
4004
|
+
throw new ERR_INVALID_ARG_VALUE('error', expected, 'may not be an empty object');
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
if (isDeepEqual === undefined) lazyLoadComparison();
|
|
4008
|
+
keys.forEach(function (key) {
|
|
4009
|
+
if (typeof actual[key] === 'string' && isRegExp(expected[key]) && expected[key].test(actual[key])) {
|
|
4010
|
+
return;
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
compareExceptionKey(actual, expected, key, msg, keys, fn);
|
|
4014
|
+
});
|
|
4015
|
+
return true;
|
|
4016
|
+
} // Guard instanceof against arrow functions as they don't have a prototype.
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
if (expected.prototype !== undefined && actual instanceof expected) {
|
|
4020
|
+
return true;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
if (Error.isPrototypeOf(expected)) {
|
|
4024
|
+
return false;
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
return expected.call({}, actual) === true;
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
function getActual(fn) {
|
|
4031
|
+
if (typeof fn !== 'function') {
|
|
4032
|
+
throw new ERR_INVALID_ARG_TYPE('fn', 'Function', fn);
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
try {
|
|
4036
|
+
fn();
|
|
4037
|
+
} catch (e) {
|
|
4038
|
+
return e;
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
return NO_EXCEPTION_SENTINEL;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
function checkIsPromise(obj) {
|
|
4045
|
+
// Accept native ES6 promises and promises that are implemented in a similar
|
|
4046
|
+
// way. Do not accept thenables that use a function as `obj` and that have no
|
|
4047
|
+
// `catch` handler.
|
|
4048
|
+
// TODO: thenables are checked up until they have the correct methods,
|
|
4049
|
+
// but according to documentation, the `then` method should receive
|
|
4050
|
+
// the `fulfill` and `reject` arguments as well or it may be never resolved.
|
|
4051
|
+
return isPromise(obj) || obj !== null && _typeof(obj) === 'object' && typeof obj.then === 'function' && typeof obj.catch === 'function';
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
function waitForActual(promiseFn) {
|
|
4055
|
+
return Promise.resolve().then(function () {
|
|
4056
|
+
var resultPromise;
|
|
4057
|
+
|
|
4058
|
+
if (typeof promiseFn === 'function') {
|
|
4059
|
+
// Return a rejected promise if `promiseFn` throws synchronously.
|
|
4060
|
+
resultPromise = promiseFn(); // Fail in case no promise is returned.
|
|
4061
|
+
|
|
4062
|
+
if (!checkIsPromise(resultPromise)) {
|
|
4063
|
+
throw new ERR_INVALID_RETURN_VALUE('instance of Promise', 'promiseFn', resultPromise);
|
|
4064
|
+
}
|
|
4065
|
+
} else if (checkIsPromise(promiseFn)) {
|
|
4066
|
+
resultPromise = promiseFn;
|
|
4067
|
+
} else {
|
|
4068
|
+
throw new ERR_INVALID_ARG_TYPE('promiseFn', ['Function', 'Promise'], promiseFn);
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
return Promise.resolve().then(function () {
|
|
4072
|
+
return resultPromise;
|
|
4073
|
+
}).then(function () {
|
|
4074
|
+
return NO_EXCEPTION_SENTINEL;
|
|
4075
|
+
}).catch(function (e) {
|
|
4076
|
+
return e;
|
|
4077
|
+
});
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
|
+
function expectsError(stackStartFn, actual, error, message) {
|
|
4082
|
+
if (typeof error === 'string') {
|
|
4083
|
+
if (arguments.length === 4) {
|
|
4084
|
+
throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error);
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
if (_typeof(actual) === 'object' && actual !== null) {
|
|
4088
|
+
if (actual.message === error) {
|
|
4089
|
+
throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error message \"".concat(actual.message, "\" is identical to the message."));
|
|
4090
|
+
}
|
|
4091
|
+
} else if (actual === error) {
|
|
4092
|
+
throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error \"".concat(actual, "\" is identical to the message."));
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4095
|
+
message = error;
|
|
4096
|
+
error = undefined;
|
|
4097
|
+
} else if (error != null && _typeof(error) !== 'object' && typeof error !== 'function') {
|
|
4098
|
+
throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error);
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
if (actual === NO_EXCEPTION_SENTINEL) {
|
|
4102
|
+
var details = '';
|
|
4103
|
+
|
|
4104
|
+
if (error && error.name) {
|
|
4105
|
+
details += " (".concat(error.name, ")");
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
details += message ? ": ".concat(message) : '.';
|
|
4109
|
+
var fnType = stackStartFn.name === 'rejects' ? 'rejection' : 'exception';
|
|
4110
|
+
innerFail({
|
|
4111
|
+
actual: undefined,
|
|
4112
|
+
expected: error,
|
|
4113
|
+
operator: stackStartFn.name,
|
|
4114
|
+
message: "Missing expected ".concat(fnType).concat(details),
|
|
4115
|
+
stackStartFn: stackStartFn
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
if (error && !expectedException(actual, error, message, stackStartFn)) {
|
|
4120
|
+
throw actual;
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
function expectsNoError(stackStartFn, actual, error, message) {
|
|
4125
|
+
if (actual === NO_EXCEPTION_SENTINEL) return;
|
|
4126
|
+
|
|
4127
|
+
if (typeof error === 'string') {
|
|
4128
|
+
message = error;
|
|
4129
|
+
error = undefined;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
if (!error || expectedException(actual, error)) {
|
|
4133
|
+
var details = message ? ": ".concat(message) : '.';
|
|
4134
|
+
var fnType = stackStartFn.name === 'doesNotReject' ? 'rejection' : 'exception';
|
|
4135
|
+
innerFail({
|
|
4136
|
+
actual: actual,
|
|
4137
|
+
expected: error,
|
|
4138
|
+
operator: stackStartFn.name,
|
|
4139
|
+
message: "Got unwanted ".concat(fnType).concat(details, "\n") + "Actual message: \"".concat(actual && actual.message, "\""),
|
|
4140
|
+
stackStartFn: stackStartFn
|
|
4141
|
+
});
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
throw actual;
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
assert.throws = function throws(promiseFn) {
|
|
4148
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4149
|
+
args[_key2 - 1] = arguments[_key2];
|
|
4150
|
+
}
|
|
4151
|
+
|
|
4152
|
+
expectsError.apply(void 0, [throws, getActual(promiseFn)].concat(args));
|
|
4153
|
+
};
|
|
4154
|
+
|
|
4155
|
+
assert.rejects = function rejects(promiseFn) {
|
|
4156
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
4157
|
+
args[_key3 - 1] = arguments[_key3];
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
return waitForActual(promiseFn).then(function (result) {
|
|
4161
|
+
return expectsError.apply(void 0, [rejects, result].concat(args));
|
|
4162
|
+
});
|
|
4163
|
+
};
|
|
4164
|
+
|
|
4165
|
+
assert.doesNotThrow = function doesNotThrow(fn) {
|
|
4166
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
4167
|
+
args[_key4 - 1] = arguments[_key4];
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
expectsNoError.apply(void 0, [doesNotThrow, getActual(fn)].concat(args));
|
|
4171
|
+
};
|
|
4172
|
+
|
|
4173
|
+
assert.doesNotReject = function doesNotReject(fn) {
|
|
4174
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
4175
|
+
args[_key5 - 1] = arguments[_key5];
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
return waitForActual(fn).then(function (result) {
|
|
4179
|
+
return expectsNoError.apply(void 0, [doesNotReject, result].concat(args));
|
|
4180
|
+
});
|
|
4181
|
+
};
|
|
4182
|
+
|
|
4183
|
+
assert.ifError = function ifError(err) {
|
|
4184
|
+
if (err !== null && err !== undefined) {
|
|
4185
|
+
var message = 'ifError got unwanted exception: ';
|
|
4186
|
+
|
|
4187
|
+
if (_typeof(err) === 'object' && typeof err.message === 'string') {
|
|
4188
|
+
if (err.message.length === 0 && err.constructor) {
|
|
4189
|
+
message += err.constructor.name;
|
|
4190
|
+
} else {
|
|
4191
|
+
message += err.message;
|
|
4192
|
+
}
|
|
4193
|
+
} else {
|
|
4194
|
+
message += inspect(err);
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4197
|
+
var newErr = new AssertionError({
|
|
4198
|
+
actual: err,
|
|
4199
|
+
expected: null,
|
|
4200
|
+
operator: 'ifError',
|
|
4201
|
+
message: message,
|
|
4202
|
+
stackStartFn: ifError
|
|
4203
|
+
}); // Make sure we actually have a stack trace!
|
|
4204
|
+
|
|
4205
|
+
var origStack = err.stack;
|
|
4206
|
+
|
|
4207
|
+
if (typeof origStack === 'string') {
|
|
4208
|
+
// This will remove any duplicated frames from the error frames taken
|
|
4209
|
+
// from within `ifError` and add the original error frames to the newly
|
|
4210
|
+
// created ones.
|
|
4211
|
+
var tmp2 = origStack.split('\n');
|
|
4212
|
+
tmp2.shift(); // Filter all frames existing in err.stack.
|
|
4213
|
+
|
|
4214
|
+
var tmp1 = newErr.stack.split('\n');
|
|
4215
|
+
|
|
4216
|
+
for (var i = 0; i < tmp2.length; i++) {
|
|
4217
|
+
// Find the first occurrence of the frame.
|
|
4218
|
+
var pos = tmp1.indexOf(tmp2[i]);
|
|
4219
|
+
|
|
4220
|
+
if (pos !== -1) {
|
|
4221
|
+
// Only keep new frames.
|
|
4222
|
+
tmp1 = tmp1.slice(0, pos);
|
|
4223
|
+
break;
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
|
|
4227
|
+
newErr.stack = "".concat(tmp1.join('\n'), "\n").concat(tmp2.join('\n'));
|
|
4228
|
+
}
|
|
4229
|
+
|
|
4230
|
+
throw newErr;
|
|
4231
|
+
}
|
|
4232
|
+
}; // Expose a strict only variant of assert
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
function strict() {
|
|
4236
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
4237
|
+
args[_key6] = arguments[_key6];
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
innerOk.apply(void 0, [strict, args.length].concat(args));
|
|
4241
|
+
}
|
|
4242
|
+
|
|
4243
|
+
assert.strict = objectAssign(strict, assert, {
|
|
4244
|
+
equal: assert.strictEqual,
|
|
4245
|
+
deepEqual: assert.deepStrictEqual,
|
|
4246
|
+
notEqual: assert.notStrictEqual,
|
|
4247
|
+
notDeepEqual: assert.notDeepStrictEqual
|
|
4248
|
+
});
|
|
4249
|
+
assert.strict.strict = assert.strict;
|
|
4250
|
+
return assertExports$1;
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
var assertExports = requireAssert();
|
|
4254
|
+
var assert = /*@__PURE__*/getDefaultExportFromCjs(assertExports);
|
|
4255
|
+
|
|
1183
4256
|
const MAXIMUM_TURN_BANDWIDTH = 512; // kbps;
|
|
1184
4257
|
const MAXIMUM_TURN_BANDWIDTH_PREMIUM = 768; // kbps;
|
|
1185
4258
|
|
|
1186
4259
|
/* globals process */
|
|
1187
|
-
|
|
1188
|
-
process.env.AWF_BASE_URL;
|
|
1189
|
-
process.env.AWF_API_BASE_URL;
|
|
1190
|
-
process.env.AP_ROOM_BASE_URL;
|
|
1191
4260
|
const CAMERA_STREAM_ID = "0";
|
|
1192
4261
|
|
|
1193
4262
|
const logger$2 = console;
|
|
@@ -1197,11 +4266,11 @@ const browserVersion = adapter__default["default"].browserDetails.version;
|
|
|
1197
4266
|
|
|
1198
4267
|
class BaseRtcManager {
|
|
1199
4268
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features }) {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
4269
|
+
assert.ok(selfId, "selfId is required");
|
|
4270
|
+
assert.ok(room, "room is required");
|
|
4271
|
+
assert.ok(emitter && emitter.emit, "emitter is required");
|
|
4272
|
+
assert.ok(serverSocket instanceof ServerSocket, "serverSocket is required");
|
|
4273
|
+
assert.ok(webrtcProvider, "webrtcProvider is required");
|
|
1205
4274
|
|
|
1206
4275
|
const { name, session, iceServers, sfuServer, mediaserverConfigTtlSeconds } = room;
|
|
1207
4276
|
|
|
@@ -2510,10 +5579,10 @@ const OUTBOUND_SCREEN_OUTBOUND_STREAM_ID = uuid.v4();
|
|
|
2510
5579
|
|
|
2511
5580
|
class VegaRtcManager {
|
|
2512
5581
|
constructor({ selfId, room, emitter, serverSocket, webrtcProvider, features, eventClaim }) {
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
5582
|
+
assert.ok(selfId, "selfId is required");
|
|
5583
|
+
assert.ok(room, "room is required");
|
|
5584
|
+
assert.ok(emitter && emitter.emit, "emitter is required");
|
|
5585
|
+
assert.ok(webrtcProvider, "webrtcProvider is required");
|
|
2517
5586
|
|
|
2518
5587
|
const { session, iceServers, sfuServer, mediaserverConfigTtlSeconds } = room;
|
|
2519
5588
|
|
|
@@ -3901,7 +6970,7 @@ class Response {
|
|
|
3901
6970
|
* @param {string} parameterName - The name of the parameter.
|
|
3902
6971
|
*/
|
|
3903
6972
|
function assertTruthy(value, parameterName) {
|
|
3904
|
-
|
|
6973
|
+
assert.ok(value, `${parameterName} is required`);
|
|
3905
6974
|
return value;
|
|
3906
6975
|
}
|
|
3907
6976
|
/**
|
|
@@ -3911,7 +6980,7 @@ function assertTruthy(value, parameterName) {
|
|
|
3911
6980
|
* @param {string} parameterName - The name of the parameter.
|
|
3912
6981
|
*/
|
|
3913
6982
|
function assertBoolean(value, parameterName) {
|
|
3914
|
-
|
|
6983
|
+
assert.ok(typeof value === "boolean", `${parameterName}<boolean> is required`);
|
|
3915
6984
|
return value;
|
|
3916
6985
|
}
|
|
3917
6986
|
/**
|
|
@@ -3921,7 +6990,7 @@ function assertBoolean(value, parameterName) {
|
|
|
3921
6990
|
* @param {string} parameterName - The name of the parameter.
|
|
3922
6991
|
*/
|
|
3923
6992
|
function assertNumber(value, parameterName) {
|
|
3924
|
-
|
|
6993
|
+
assert.ok(typeof value === "number", `${parameterName}<number> is required`);
|
|
3925
6994
|
return value;
|
|
3926
6995
|
}
|
|
3927
6996
|
/**
|
|
@@ -3931,7 +7000,7 @@ function assertNumber(value, parameterName) {
|
|
|
3931
7000
|
* @param {string} parameterName - The name of the parameter.
|
|
3932
7001
|
*/
|
|
3933
7002
|
function assertString(value, parameterName) {
|
|
3934
|
-
|
|
7003
|
+
assert.ok(typeof value === "string", `${parameterName}<string> is required`);
|
|
3935
7004
|
return value;
|
|
3936
7005
|
}
|
|
3937
7006
|
/**
|
|
@@ -3943,7 +7012,7 @@ function assertString(value, parameterName) {
|
|
|
3943
7012
|
*/
|
|
3944
7013
|
function assertInstanceOf(value, type, parameterName) {
|
|
3945
7014
|
const resolvedParameterName = parameterName || type.name[0].toLowerCase() + type.name.substring(1);
|
|
3946
|
-
|
|
7015
|
+
assert.ok(value instanceof type, `${resolvedParameterName}<${type.name}> is required`);
|
|
3947
7016
|
return value;
|
|
3948
7017
|
}
|
|
3949
7018
|
/**
|
|
@@ -3954,7 +7023,7 @@ function assertInstanceOf(value, type, parameterName) {
|
|
|
3954
7023
|
*/
|
|
3955
7024
|
function assertRoomName(roomName, parameterName = "roomName") {
|
|
3956
7025
|
assertString(roomName, parameterName);
|
|
3957
|
-
|
|
7026
|
+
assert.equal(typeof roomName === "string" && roomName[0], "/", `${parameterName} must begin with a '/'`);
|
|
3958
7027
|
return roomName;
|
|
3959
7028
|
}
|
|
3960
7029
|
/**
|
|
@@ -3964,7 +7033,7 @@ function assertRoomName(roomName, parameterName = "roomName") {
|
|
|
3964
7033
|
* @param {string} [parameterName] - The name of the parameter.
|
|
3965
7034
|
*/
|
|
3966
7035
|
function assertArray(array, parameterName) {
|
|
3967
|
-
|
|
7036
|
+
assert.ok(Array.isArray(array), `${parameterName}<array> is required`);
|
|
3968
7037
|
return array;
|
|
3969
7038
|
}
|
|
3970
7039
|
/**
|
|
@@ -4006,7 +7075,7 @@ function assertRecord(ref, name) {
|
|
|
4006
7075
|
function assertNullOrType(ref, type, name, message) {
|
|
4007
7076
|
assertString(name, "name");
|
|
4008
7077
|
const errorMessage = message || `${name} must be null or of type ${type}`;
|
|
4009
|
-
|
|
7078
|
+
assert.ok(ref === null || typeof ref === type, errorMessage);
|
|
4010
7079
|
}
|
|
4011
7080
|
/**
|
|
4012
7081
|
* Asserts that the provided reference is either null or a string.
|
|
@@ -4021,7 +7090,7 @@ function assertNullOrString(ref, name, message) {
|
|
|
4021
7090
|
}
|
|
4022
7091
|
|
|
4023
7092
|
function _getAbsoluteUrl({ baseUrl, url }) {
|
|
4024
|
-
|
|
7093
|
+
assert.ok(typeof url === "string", "url<String> is required");
|
|
4025
7094
|
return baseUrl ? baseUrl + url : url;
|
|
4026
7095
|
}
|
|
4027
7096
|
/**
|
|
@@ -4055,8 +7124,8 @@ class HttpClient {
|
|
|
4055
7124
|
*/
|
|
4056
7125
|
request(url, options) {
|
|
4057
7126
|
assertString(url, "url");
|
|
4058
|
-
|
|
4059
|
-
|
|
7127
|
+
assert.equal(url[0], "/", 'url<String> only accepts relative URLs beginning with "/".');
|
|
7128
|
+
assert.ok(options, "options are required");
|
|
4060
7129
|
return this._requestAxios(url, options)
|
|
4061
7130
|
.then((response) => {
|
|
4062
7131
|
const { data, headers, status, statusText, config } = response;
|
|
@@ -4093,7 +7162,7 @@ class HttpClient {
|
|
|
4093
7162
|
*/
|
|
4094
7163
|
class MultipartHttpClient {
|
|
4095
7164
|
constructor({ httpClient }) {
|
|
4096
|
-
|
|
7165
|
+
assert.ok(httpClient, "httpClient is required");
|
|
4097
7166
|
this._httpClient = httpClient;
|
|
4098
7167
|
}
|
|
4099
7168
|
/**
|
|
@@ -4102,7 +7171,7 @@ class MultipartHttpClient {
|
|
|
4102
7171
|
* @returns {FormData}
|
|
4103
7172
|
*/
|
|
4104
7173
|
static dataToFormData(data) {
|
|
4105
|
-
|
|
7174
|
+
assert.ok(data, "data is required");
|
|
4106
7175
|
const fd = new FormData();
|
|
4107
7176
|
Object.keys(data).forEach((key) => {
|
|
4108
7177
|
const value = data[key];
|
|
@@ -4174,7 +7243,7 @@ class ApiClient {
|
|
|
4174
7243
|
*/
|
|
4175
7244
|
constructor({ baseUrl = "https://api.appearin.net", fetchDeviceCredentials = noCredentials, } = {}) {
|
|
4176
7245
|
assertString(baseUrl, "baseUrl");
|
|
4177
|
-
|
|
7246
|
+
assert.ok(typeof fetchDeviceCredentials === "function", "fetchDeviceCredentials<Function> is required");
|
|
4178
7247
|
this.authenticatedHttpClient = new AuthenticatedHttpClient({
|
|
4179
7248
|
httpClient: new HttpClient({
|
|
4180
7249
|
baseUrl,
|
|
@@ -4188,8 +7257,8 @@ class ApiClient {
|
|
|
4188
7257
|
*/
|
|
4189
7258
|
request(url, options) {
|
|
4190
7259
|
assertString(url, "url");
|
|
4191
|
-
|
|
4192
|
-
|
|
7260
|
+
assert.equal(url[0], "/", 'url<String> only accepts relative URLs beginning with "/".');
|
|
7261
|
+
assert.ok(options, "options are required");
|
|
4193
7262
|
return this.authenticatedHttpClient.request(url, options);
|
|
4194
7263
|
}
|
|
4195
7264
|
/**
|
|
@@ -4197,8 +7266,8 @@ class ApiClient {
|
|
|
4197
7266
|
*/
|
|
4198
7267
|
requestMultipart(url, options) {
|
|
4199
7268
|
assertString(url, "url");
|
|
4200
|
-
|
|
4201
|
-
|
|
7269
|
+
assert.equal(url[0], "/", 'url<String> only accepts relative URLs beginning with "/".');
|
|
7270
|
+
assert.ok(options, "options are required");
|
|
4202
7271
|
return this.authenticatedFormDataHttpClient.request(url, options);
|
|
4203
7272
|
}
|
|
4204
7273
|
}
|
|
@@ -4574,14 +7643,14 @@ class OrganizationApiClient {
|
|
|
4574
7643
|
*/
|
|
4575
7644
|
constructor({ apiClient, fetchOrganization = noOrganization, }) {
|
|
4576
7645
|
this._apiClient = assertInstanceOf(apiClient, ApiClient);
|
|
4577
|
-
|
|
7646
|
+
assert.ok(typeof fetchOrganization === "function", "fetchOrganization<Function> is required");
|
|
4578
7647
|
this._fetchOrganization = fetchOrganization;
|
|
4579
7648
|
this._apiClient = apiClient;
|
|
4580
7649
|
}
|
|
4581
7650
|
_callRequestMethod(method, url, options) {
|
|
4582
7651
|
assertString(url, "url");
|
|
4583
|
-
|
|
4584
|
-
|
|
7652
|
+
assert.equal(url[0], "/", 'url<String> only accepts relative URLs beginning with "/".');
|
|
7653
|
+
assert.ok(options, "options are required");
|
|
4585
7654
|
return this._fetchOrganization().then((organization) => {
|
|
4586
7655
|
if (!organization) {
|
|
4587
7656
|
return this._apiClient[method](url, options);
|
|
@@ -4739,7 +7808,7 @@ class OrganizationService {
|
|
|
4739
7808
|
assertString(subdomain, "subdomain");
|
|
4740
7809
|
assertString(organizationName, "organizationName");
|
|
4741
7810
|
assertString(displayName, "owner.displayName");
|
|
4742
|
-
|
|
7811
|
+
assert.ok(email || idToken, "owner.email or owner.idToken is required");
|
|
4743
7812
|
if (consents) {
|
|
4744
7813
|
assertArray(consents, "consents");
|
|
4745
7814
|
for (const { consentRevisionId, action } of consents) {
|
|
@@ -4818,7 +7887,7 @@ class OrganizationService {
|
|
|
4818
7887
|
const { code } = options;
|
|
4819
7888
|
const email = "email" in options ? options.email : null;
|
|
4820
7889
|
const phoneNumber = "phoneNumber" in options ? options.phoneNumber : null;
|
|
4821
|
-
|
|
7890
|
+
assert.ok((email || phoneNumber) && !(email && phoneNumber), "either email or phoneNumber is required");
|
|
4822
7891
|
assertString(code, "code");
|
|
4823
7892
|
const contactPoint = email ? { type: "email", value: email } : { type: "phoneNumber", value: phoneNumber };
|
|
4824
7893
|
return this._apiClient
|
|
@@ -4934,7 +8003,7 @@ class OrganizationServiceCache {
|
|
|
4934
8003
|
// @ts-nocheck
|
|
4935
8004
|
class Room {
|
|
4936
8005
|
constructor(properties = {}) {
|
|
4937
|
-
|
|
8006
|
+
assert.ok(properties instanceof Object, "properties<object> must be empty or an object");
|
|
4938
8007
|
this.isClaimed = false;
|
|
4939
8008
|
this.isBanned = false;
|
|
4940
8009
|
this.isLocked = false;
|
|
@@ -5861,7 +8930,7 @@ function useRoomConnection(roomUrl, roomConnectionOptions) {
|
|
|
5861
8930
|
};
|
|
5862
8931
|
}
|
|
5863
8932
|
|
|
5864
|
-
const sdkVersion = "2.0.0-
|
|
8933
|
+
const sdkVersion = "2.0.0-alpha13";
|
|
5865
8934
|
|
|
5866
8935
|
exports.VideoView = VideoView;
|
|
5867
8936
|
exports.sdkVersion = sdkVersion;
|