mol_time_all 1.1.724 → 1.1.726
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/node.test.js +296 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +296 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1265,6 +1265,298 @@ var $;
|
|
|
1265
1265
|
;
|
|
1266
1266
|
"use strict";
|
|
1267
1267
|
var $;
|
|
1268
|
+
(function ($) {
|
|
1269
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1270
|
+
for (;;) {
|
|
1271
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1272
|
+
if (exists(id))
|
|
1273
|
+
continue;
|
|
1274
|
+
return id;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
$.$mol_guid = $mol_guid;
|
|
1278
|
+
})($ || ($ = {}));
|
|
1279
|
+
//mol/guid/guid.ts
|
|
1280
|
+
;
|
|
1281
|
+
"use strict";
|
|
1282
|
+
var $;
|
|
1283
|
+
(function ($) {
|
|
1284
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
1285
|
+
return new Proxy(new $mol_range2_array(), {
|
|
1286
|
+
get(target, field) {
|
|
1287
|
+
if (typeof field === 'string') {
|
|
1288
|
+
if (field === 'length')
|
|
1289
|
+
return size();
|
|
1290
|
+
const index = Number(field);
|
|
1291
|
+
if (index < 0)
|
|
1292
|
+
return undefined;
|
|
1293
|
+
if (index >= size())
|
|
1294
|
+
return undefined;
|
|
1295
|
+
if (index === Math.trunc(index))
|
|
1296
|
+
return item(index);
|
|
1297
|
+
}
|
|
1298
|
+
return target[field];
|
|
1299
|
+
},
|
|
1300
|
+
set(target, field) {
|
|
1301
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
1302
|
+
},
|
|
1303
|
+
ownKeys(target) {
|
|
1304
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
1305
|
+
},
|
|
1306
|
+
getOwnPropertyDescriptor(target, field) {
|
|
1307
|
+
if (field === "length")
|
|
1308
|
+
return {
|
|
1309
|
+
value: size(),
|
|
1310
|
+
writable: true,
|
|
1311
|
+
enumerable: false,
|
|
1312
|
+
configurable: false,
|
|
1313
|
+
};
|
|
1314
|
+
const index = Number(field);
|
|
1315
|
+
if (index === Math.trunc(index))
|
|
1316
|
+
return {
|
|
1317
|
+
get: () => this.get(target, field, this),
|
|
1318
|
+
enumerable: true,
|
|
1319
|
+
configurable: true,
|
|
1320
|
+
};
|
|
1321
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
$.$mol_range2 = $mol_range2;
|
|
1326
|
+
class $mol_range2_array extends Array {
|
|
1327
|
+
concat(...tail) {
|
|
1328
|
+
if (tail.length === 0)
|
|
1329
|
+
return this;
|
|
1330
|
+
if (tail.length > 1) {
|
|
1331
|
+
let list = this;
|
|
1332
|
+
for (let item of tail)
|
|
1333
|
+
list = list.concat(item);
|
|
1334
|
+
return list;
|
|
1335
|
+
}
|
|
1336
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
1337
|
+
}
|
|
1338
|
+
filter(check, context) {
|
|
1339
|
+
const filtered = new $mol_range2_array();
|
|
1340
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1341
|
+
const item = this[index];
|
|
1342
|
+
if (check.call(context, item, index, this))
|
|
1343
|
+
filtered.push(item);
|
|
1344
|
+
}
|
|
1345
|
+
return filtered;
|
|
1346
|
+
}
|
|
1347
|
+
forEach(proceed, context) {
|
|
1348
|
+
for (let [key, value] of this.entries())
|
|
1349
|
+
proceed.call(context, value, key, this);
|
|
1350
|
+
}
|
|
1351
|
+
map(proceed, context) {
|
|
1352
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
1353
|
+
}
|
|
1354
|
+
reduce(merge, result) {
|
|
1355
|
+
let index = 0;
|
|
1356
|
+
if (arguments.length === 1) {
|
|
1357
|
+
result = this[index++];
|
|
1358
|
+
}
|
|
1359
|
+
for (; index < this.length; ++index) {
|
|
1360
|
+
result = merge(result, this[index], index, this);
|
|
1361
|
+
}
|
|
1362
|
+
return result;
|
|
1363
|
+
}
|
|
1364
|
+
toReversed() {
|
|
1365
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
1366
|
+
}
|
|
1367
|
+
slice(from = 0, to = this.length) {
|
|
1368
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
1369
|
+
}
|
|
1370
|
+
some(check, context) {
|
|
1371
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1372
|
+
if (check.call(context, this[index], index, this))
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
every(check, context) {
|
|
1378
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1379
|
+
if (!check.call(context, this[index], index, this))
|
|
1380
|
+
return false;
|
|
1381
|
+
}
|
|
1382
|
+
return true;
|
|
1383
|
+
}
|
|
1384
|
+
reverse() {
|
|
1385
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
1386
|
+
}
|
|
1387
|
+
sort() {
|
|
1388
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
1389
|
+
}
|
|
1390
|
+
[Symbol.toPrimitive]() {
|
|
1391
|
+
return $mol_guid();
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
1395
|
+
})($ || ($ = {}));
|
|
1396
|
+
//mol/range2/range2.ts
|
|
1397
|
+
;
|
|
1398
|
+
"use strict";
|
|
1399
|
+
var $;
|
|
1400
|
+
(function ($) {
|
|
1401
|
+
$mol_test({
|
|
1402
|
+
'lazy calls'() {
|
|
1403
|
+
let calls = 0;
|
|
1404
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
1405
|
+
$mol_assert_ok(list instanceof Array);
|
|
1406
|
+
$mol_assert_equal(list.length, 10);
|
|
1407
|
+
$mol_assert_equal(list[-1], undefined);
|
|
1408
|
+
$mol_assert_equal(list[0], 0);
|
|
1409
|
+
$mol_assert_equal(list[9], 9);
|
|
1410
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
1411
|
+
$mol_assert_equal(list[10], undefined);
|
|
1412
|
+
$mol_assert_equal(calls, 2);
|
|
1413
|
+
},
|
|
1414
|
+
'infinity list'() {
|
|
1415
|
+
let calls = 0;
|
|
1416
|
+
const list = $mol_range2(index => (++calls, index));
|
|
1417
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
1418
|
+
$mol_assert_equal(list[0], 0);
|
|
1419
|
+
$mol_assert_equal(list[4], 4);
|
|
1420
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
1421
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
1422
|
+
$mol_assert_equal(calls, 3);
|
|
1423
|
+
},
|
|
1424
|
+
'stringify'() {
|
|
1425
|
+
const list = $mol_range2(i => i, () => 5);
|
|
1426
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
1427
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
1428
|
+
},
|
|
1429
|
+
'for-of'() {
|
|
1430
|
+
let log = '';
|
|
1431
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
1432
|
+
log += i;
|
|
1433
|
+
}
|
|
1434
|
+
$mol_assert_equal(log, '12345');
|
|
1435
|
+
},
|
|
1436
|
+
'for-in'() {
|
|
1437
|
+
let log = '';
|
|
1438
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
1439
|
+
log += i;
|
|
1440
|
+
}
|
|
1441
|
+
$mol_assert_equal(log, '01234');
|
|
1442
|
+
},
|
|
1443
|
+
'forEach'() {
|
|
1444
|
+
let log = '';
|
|
1445
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
1446
|
+
$mol_assert_equal(log, '01234');
|
|
1447
|
+
},
|
|
1448
|
+
'lazy concat'() {
|
|
1449
|
+
let calls1 = 0;
|
|
1450
|
+
let calls2 = 0;
|
|
1451
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
1452
|
+
$mol_assert_ok(list instanceof Array);
|
|
1453
|
+
$mol_assert_equal(list.length, 15);
|
|
1454
|
+
$mol_assert_equal(list[0], 0);
|
|
1455
|
+
$mol_assert_equal(list[4], 4);
|
|
1456
|
+
$mol_assert_equal(list[5], 0);
|
|
1457
|
+
$mol_assert_equal(list[9], 4);
|
|
1458
|
+
$mol_assert_equal(list[10], 0);
|
|
1459
|
+
$mol_assert_equal(list[14], 4);
|
|
1460
|
+
$mol_assert_equal(list[15], undefined);
|
|
1461
|
+
$mol_assert_equal(calls1, 2);
|
|
1462
|
+
$mol_assert_equal(calls2, 2);
|
|
1463
|
+
},
|
|
1464
|
+
'filter'() {
|
|
1465
|
+
let calls = 0;
|
|
1466
|
+
const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
|
|
1467
|
+
$mol_assert_ok(list instanceof Array);
|
|
1468
|
+
$mol_assert_equal(list.length, 3);
|
|
1469
|
+
$mol_assert_equal(list[0], 1);
|
|
1470
|
+
$mol_assert_equal(list[2], 5);
|
|
1471
|
+
$mol_assert_equal(list[3], undefined);
|
|
1472
|
+
$mol_assert_equal(calls, 10);
|
|
1473
|
+
},
|
|
1474
|
+
'reverse'() {
|
|
1475
|
+
let calls = 0;
|
|
1476
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
1477
|
+
$mol_assert_ok(list instanceof Array);
|
|
1478
|
+
$mol_assert_equal(list.length, 3);
|
|
1479
|
+
$mol_assert_equal(list[0], 9);
|
|
1480
|
+
$mol_assert_equal(list[2], 7);
|
|
1481
|
+
$mol_assert_equal(list[3], undefined);
|
|
1482
|
+
$mol_assert_equal(calls, 2);
|
|
1483
|
+
},
|
|
1484
|
+
'reduce'() {
|
|
1485
|
+
let calls = 0;
|
|
1486
|
+
const list = $mol_range2().slice(1, 6);
|
|
1487
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
1488
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
1489
|
+
},
|
|
1490
|
+
'lazy map'() {
|
|
1491
|
+
let calls1 = 0;
|
|
1492
|
+
let calls2 = 0;
|
|
1493
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
1494
|
+
const target = source.map((item, index, self) => {
|
|
1495
|
+
++calls2;
|
|
1496
|
+
$mol_assert_equal(source, self);
|
|
1497
|
+
return index + 10;
|
|
1498
|
+
}, () => 5);
|
|
1499
|
+
$mol_assert_ok(target instanceof Array);
|
|
1500
|
+
$mol_assert_equal(target.length, 5);
|
|
1501
|
+
$mol_assert_equal(target[0], 10);
|
|
1502
|
+
$mol_assert_equal(target[4], 14);
|
|
1503
|
+
$mol_assert_equal(target[5], undefined);
|
|
1504
|
+
$mol_assert_equal(calls1, 2);
|
|
1505
|
+
$mol_assert_equal(calls2, 2);
|
|
1506
|
+
},
|
|
1507
|
+
'lazy slice'() {
|
|
1508
|
+
let calls = 0;
|
|
1509
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
1510
|
+
$mol_assert_ok(list instanceof Array);
|
|
1511
|
+
$mol_assert_equal(list.length, 4);
|
|
1512
|
+
$mol_assert_equal(list[0], 3);
|
|
1513
|
+
$mol_assert_equal(list[3], 6);
|
|
1514
|
+
$mol_assert_equal(list[4], undefined);
|
|
1515
|
+
$mol_assert_equal(calls, 2);
|
|
1516
|
+
},
|
|
1517
|
+
'lazy some'() {
|
|
1518
|
+
let calls = 0;
|
|
1519
|
+
$mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
1520
|
+
$mol_assert_equal(calls, 3);
|
|
1521
|
+
$mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
|
|
1522
|
+
$mol_assert_ok($mol_range2(i => i).some(v => v > 5));
|
|
1523
|
+
},
|
|
1524
|
+
'lazy every'() {
|
|
1525
|
+
let calls = 0;
|
|
1526
|
+
$mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
1527
|
+
$mol_assert_equal(calls, 3);
|
|
1528
|
+
$mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
|
|
1529
|
+
$mol_assert_not($mol_range2(i => i).every(v => v < 5));
|
|
1530
|
+
},
|
|
1531
|
+
'lazyfy'() {
|
|
1532
|
+
let calls = 0;
|
|
1533
|
+
const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
1534
|
+
$mol_assert_ok(list instanceof Array);
|
|
1535
|
+
$mol_assert_equal(list.length, 4);
|
|
1536
|
+
$mol_assert_equal(calls, 0);
|
|
1537
|
+
$mol_assert_equal(list[0], 12);
|
|
1538
|
+
$mol_assert_equal(list[3], 15);
|
|
1539
|
+
$mol_assert_equal(list[4], undefined);
|
|
1540
|
+
$mol_assert_equal(calls, 2);
|
|
1541
|
+
},
|
|
1542
|
+
'prevent modification'() {
|
|
1543
|
+
const list = $mol_range2(i => i, () => 5);
|
|
1544
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
1545
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
1546
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
1547
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
1548
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
1549
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
1550
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
1551
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
1552
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
})($ || ($ = {}));
|
|
1556
|
+
//mol/range2/range2.test.ts
|
|
1557
|
+
;
|
|
1558
|
+
"use strict";
|
|
1559
|
+
var $;
|
|
1268
1560
|
(function ($) {
|
|
1269
1561
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
1270
1562
|
function $mol_compare_deep(left, right) {
|
|
@@ -1310,6 +1602,8 @@ var $;
|
|
|
1310
1602
|
result = compare_pojo(left, right);
|
|
1311
1603
|
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1312
1604
|
result = compare_pojo(left, right);
|
|
1605
|
+
else if (Symbol.toPrimitive in left)
|
|
1606
|
+
result = compare_primitive(left, right);
|
|
1313
1607
|
else if (Array.isArray(left))
|
|
1314
1608
|
result = compare_array(left, right);
|
|
1315
1609
|
else if (left instanceof Set)
|
|
@@ -1320,8 +1614,6 @@ var $;
|
|
|
1320
1614
|
result = compare_buffer(left, right);
|
|
1321
1615
|
else if (Symbol.iterator in left)
|
|
1322
1616
|
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1323
|
-
else if (Symbol.toPrimitive in left)
|
|
1324
|
-
result = compare_primitive(left, right);
|
|
1325
1617
|
else
|
|
1326
1618
|
result = false;
|
|
1327
1619
|
}
|
|
@@ -1431,6 +1723,8 @@ var $;
|
|
|
1431
1723
|
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1432
1724
|
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1433
1725
|
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1726
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
1727
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
1434
1728
|
},
|
|
1435
1729
|
'Non POJO are different'() {
|
|
1436
1730
|
class Thing extends Object {
|