mol_data_all 1.1.619 → 1.1.620
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 +460 -460
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +139 -139
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -927,21 +927,24 @@ var $;
|
|
|
927
927
|
//mol/dom/render/children/children.ts
|
|
928
928
|
;
|
|
929
929
|
"use strict";
|
|
930
|
-
//mol/type/
|
|
930
|
+
//mol/type/error/error.ts
|
|
931
931
|
;
|
|
932
932
|
"use strict";
|
|
933
|
-
//mol/type/
|
|
933
|
+
//mol/type/assert/assert.test.ts
|
|
934
934
|
;
|
|
935
935
|
"use strict";
|
|
936
936
|
//mol/type/assert/assert.ts
|
|
937
937
|
;
|
|
938
938
|
"use strict";
|
|
939
|
-
//mol/type/
|
|
939
|
+
//mol/type/equals/equals.test.ts
|
|
940
940
|
;
|
|
941
941
|
"use strict";
|
|
942
942
|
//mol/type/partial/deep/deep.test.ts
|
|
943
943
|
;
|
|
944
944
|
"use strict";
|
|
945
|
+
//mol/type/partial/deep/deep.ts
|
|
946
|
+
;
|
|
947
|
+
"use strict";
|
|
945
948
|
var $;
|
|
946
949
|
(function ($) {
|
|
947
950
|
$mol_test({
|
|
@@ -1261,6 +1264,38 @@ var $;
|
|
|
1261
1264
|
;
|
|
1262
1265
|
"use strict";
|
|
1263
1266
|
var $;
|
|
1267
|
+
(function ($) {
|
|
1268
|
+
$mol_test({
|
|
1269
|
+
'must be false'() {
|
|
1270
|
+
$mol_assert_not(0);
|
|
1271
|
+
},
|
|
1272
|
+
'must be true'() {
|
|
1273
|
+
$mol_assert_ok(1);
|
|
1274
|
+
},
|
|
1275
|
+
'two must be equal'() {
|
|
1276
|
+
$mol_assert_equal(2, 2);
|
|
1277
|
+
},
|
|
1278
|
+
'three must be equal'() {
|
|
1279
|
+
$mol_assert_equal(2, 2, 2);
|
|
1280
|
+
},
|
|
1281
|
+
'two must be unique'() {
|
|
1282
|
+
$mol_assert_unique([3], [3]);
|
|
1283
|
+
},
|
|
1284
|
+
'three must be unique'() {
|
|
1285
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1286
|
+
},
|
|
1287
|
+
'two must be alike'() {
|
|
1288
|
+
$mol_assert_like([3], [3]);
|
|
1289
|
+
},
|
|
1290
|
+
'three must be alike'() {
|
|
1291
|
+
$mol_assert_like([3], [3], [3]);
|
|
1292
|
+
},
|
|
1293
|
+
});
|
|
1294
|
+
})($ || ($ = {}));
|
|
1295
|
+
//mol/assert/assert.test.ts
|
|
1296
|
+
;
|
|
1297
|
+
"use strict";
|
|
1298
|
+
var $;
|
|
1264
1299
|
(function ($) {
|
|
1265
1300
|
function $mol_assert_ok(value) {
|
|
1266
1301
|
if (value)
|
|
@@ -1357,160 +1392,400 @@ var $;
|
|
|
1357
1392
|
var $;
|
|
1358
1393
|
(function ($) {
|
|
1359
1394
|
$mol_test({
|
|
1360
|
-
'
|
|
1361
|
-
$
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
'two must be equal'() {
|
|
1367
|
-
$mol_assert_equal(2, 2);
|
|
1368
|
-
},
|
|
1369
|
-
'three must be equal'() {
|
|
1370
|
-
$mol_assert_equal(2, 2, 2);
|
|
1371
|
-
},
|
|
1372
|
-
'two must be unique'() {
|
|
1373
|
-
$mol_assert_unique([3], [3]);
|
|
1395
|
+
'equal paths'() {
|
|
1396
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
1397
|
+
$mol_assert_like(diff, {
|
|
1398
|
+
prefix: [1, 2, 3, 4],
|
|
1399
|
+
suffix: [[], [], []],
|
|
1400
|
+
});
|
|
1374
1401
|
},
|
|
1375
|
-
'
|
|
1376
|
-
$
|
|
1402
|
+
'different suffix'() {
|
|
1403
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
1404
|
+
$mol_assert_like(diff, {
|
|
1405
|
+
prefix: [1, 2],
|
|
1406
|
+
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
1407
|
+
});
|
|
1377
1408
|
},
|
|
1378
|
-
'
|
|
1379
|
-
$
|
|
1409
|
+
'one contains other'() {
|
|
1410
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
1411
|
+
$mol_assert_like(diff, {
|
|
1412
|
+
prefix: [1, 2],
|
|
1413
|
+
suffix: [[3, 4], [], [3]],
|
|
1414
|
+
});
|
|
1380
1415
|
},
|
|
1381
|
-
'
|
|
1382
|
-
$
|
|
1416
|
+
'fully different'() {
|
|
1417
|
+
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
1418
|
+
$mol_assert_like(diff, {
|
|
1419
|
+
prefix: [],
|
|
1420
|
+
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
1421
|
+
});
|
|
1383
1422
|
},
|
|
1384
1423
|
});
|
|
1385
1424
|
})($ || ($ = {}));
|
|
1386
|
-
//mol/
|
|
1425
|
+
//mol/diff/path/path.test.ts
|
|
1387
1426
|
;
|
|
1388
1427
|
"use strict";
|
|
1389
1428
|
var $;
|
|
1390
|
-
(function ($) {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1429
|
+
(function ($_1) {
|
|
1430
|
+
$mol_test({
|
|
1431
|
+
'FQN of anon function'($) {
|
|
1432
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1433
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1434
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1435
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1436
|
+
},
|
|
1437
|
+
});
|
|
1396
1438
|
})($ || ($ = {}));
|
|
1397
|
-
//mol/
|
|
1439
|
+
//mol/func/name/name.test.ts
|
|
1398
1440
|
;
|
|
1399
1441
|
"use strict";
|
|
1400
1442
|
var $;
|
|
1401
1443
|
(function ($) {
|
|
1402
|
-
|
|
1403
|
-
function $
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
}
|
|
1419
|
-
$.$mol_owning_allow = $mol_owning_allow;
|
|
1420
|
-
function $mol_owning_get(having, Owner) {
|
|
1421
|
-
if (!$mol_owning_allow(having))
|
|
1422
|
-
return null;
|
|
1423
|
-
while (true) {
|
|
1424
|
-
const owner = $.$mol_owning_map.get(having);
|
|
1425
|
-
if (!owner)
|
|
1426
|
-
return owner;
|
|
1427
|
-
if (!Owner)
|
|
1428
|
-
return owner;
|
|
1429
|
-
if (owner instanceof Owner)
|
|
1430
|
-
return owner;
|
|
1431
|
-
having = owner;
|
|
1444
|
+
const named = new WeakSet();
|
|
1445
|
+
function $mol_func_name(func) {
|
|
1446
|
+
let name = func.name;
|
|
1447
|
+
if (name?.length > 1)
|
|
1448
|
+
return name;
|
|
1449
|
+
if (named.has(func))
|
|
1450
|
+
return name;
|
|
1451
|
+
for (let key in this) {
|
|
1452
|
+
try {
|
|
1453
|
+
if (this[key] !== func)
|
|
1454
|
+
continue;
|
|
1455
|
+
name = key;
|
|
1456
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
catch { }
|
|
1432
1460
|
}
|
|
1461
|
+
named.add(func);
|
|
1462
|
+
return name;
|
|
1433
1463
|
}
|
|
1434
|
-
$.$
|
|
1435
|
-
function $
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
if ($.$mol_owning_map.get(having) !== owner)
|
|
1439
|
-
return false;
|
|
1440
|
-
return true;
|
|
1441
|
-
}
|
|
1442
|
-
$.$mol_owning_check = $mol_owning_check;
|
|
1443
|
-
function $mol_owning_catch(owner, having) {
|
|
1444
|
-
if (!$mol_owning_allow(having))
|
|
1445
|
-
return false;
|
|
1446
|
-
if ($.$mol_owning_map.get(having))
|
|
1447
|
-
return false;
|
|
1448
|
-
$.$mol_owning_map.set(having, owner);
|
|
1449
|
-
return true;
|
|
1464
|
+
$.$mol_func_name = $mol_func_name;
|
|
1465
|
+
function $mol_func_name_from(target, source) {
|
|
1466
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
1467
|
+
return target;
|
|
1450
1468
|
}
|
|
1451
|
-
$.$
|
|
1469
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
1452
1470
|
})($ || ($ = {}));
|
|
1453
|
-
//mol/
|
|
1454
|
-
;
|
|
1455
|
-
"use strict";
|
|
1456
|
-
//mol/type/writable/writable.ts
|
|
1471
|
+
//mol/func/name/name.ts
|
|
1457
1472
|
;
|
|
1458
1473
|
"use strict";
|
|
1459
|
-
|
|
1474
|
+
var $;
|
|
1475
|
+
(function ($) {
|
|
1476
|
+
$mol_test({
|
|
1477
|
+
'Is number'() {
|
|
1478
|
+
$mol_data_number(0);
|
|
1479
|
+
},
|
|
1480
|
+
'Is not number'() {
|
|
1481
|
+
$mol_assert_fail(() => {
|
|
1482
|
+
$mol_data_number('x');
|
|
1483
|
+
}, 'x is not a number');
|
|
1484
|
+
},
|
|
1485
|
+
'Is object number'() {
|
|
1486
|
+
$mol_assert_fail(() => {
|
|
1487
|
+
$mol_data_number(new Number(''));
|
|
1488
|
+
}, '0 is not a number');
|
|
1489
|
+
},
|
|
1490
|
+
});
|
|
1491
|
+
})($ || ($ = {}));
|
|
1492
|
+
//mol/data/number/number.test.ts
|
|
1460
1493
|
;
|
|
1461
1494
|
"use strict";
|
|
1462
|
-
|
|
1495
|
+
var $;
|
|
1496
|
+
(function ($) {
|
|
1497
|
+
$mol_test({
|
|
1498
|
+
'config by value'() {
|
|
1499
|
+
const N = $mol_data_setup((a) => a, 5);
|
|
1500
|
+
$mol_assert_equal(N.config, 5);
|
|
1501
|
+
},
|
|
1502
|
+
});
|
|
1503
|
+
})($ || ($ = {}));
|
|
1504
|
+
//mol/data/setup/setup.test.ts
|
|
1463
1505
|
;
|
|
1464
1506
|
"use strict";
|
|
1465
1507
|
var $;
|
|
1466
1508
|
(function ($) {
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
get $() {
|
|
1471
|
-
if (this[$mol_ambient_ref])
|
|
1472
|
-
return this[$mol_ambient_ref];
|
|
1473
|
-
const owner = $mol_owning_get(this);
|
|
1474
|
-
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
1475
|
-
}
|
|
1476
|
-
set $(next) {
|
|
1477
|
-
if (this[$mol_ambient_ref])
|
|
1478
|
-
$mol_fail_hidden(new Error('Context already defined'));
|
|
1479
|
-
this[$mol_ambient_ref] = next;
|
|
1480
|
-
}
|
|
1481
|
-
static create(init) {
|
|
1482
|
-
const obj = new this;
|
|
1483
|
-
if (init)
|
|
1484
|
-
init(obj);
|
|
1485
|
-
return obj;
|
|
1486
|
-
}
|
|
1487
|
-
static [Symbol.toPrimitive]() {
|
|
1488
|
-
return this.toString();
|
|
1489
|
-
}
|
|
1490
|
-
static toString() {
|
|
1491
|
-
if (Symbol.toStringTag in this)
|
|
1492
|
-
return this[Symbol.toStringTag];
|
|
1493
|
-
return this.name;
|
|
1494
|
-
}
|
|
1495
|
-
destructor() { }
|
|
1496
|
-
toString() {
|
|
1497
|
-
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
|
1498
|
-
}
|
|
1499
|
-
toJSON() {
|
|
1500
|
-
return this.toString();
|
|
1501
|
-
}
|
|
1509
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
1510
|
+
function $mol_ambient(overrides) {
|
|
1511
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
1502
1512
|
}
|
|
1503
|
-
$.$
|
|
1513
|
+
$.$mol_ambient = $mol_ambient;
|
|
1504
1514
|
})($ || ($ = {}));
|
|
1505
|
-
//mol/
|
|
1515
|
+
//mol/ambient/ambient.ts
|
|
1506
1516
|
;
|
|
1507
1517
|
"use strict";
|
|
1508
1518
|
var $;
|
|
1509
1519
|
(function ($) {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1520
|
+
$mol_test({
|
|
1521
|
+
'get'() {
|
|
1522
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1523
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1524
|
+
},
|
|
1525
|
+
'has'() {
|
|
1526
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1527
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1528
|
+
},
|
|
1529
|
+
'set'() {
|
|
1530
|
+
const target = { foo: 777 };
|
|
1531
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1532
|
+
proxy.foo = 123;
|
|
1533
|
+
$mol_assert_equal(target.foo, 123);
|
|
1534
|
+
},
|
|
1535
|
+
'getOwnPropertyDescriptor'() {
|
|
1536
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1537
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1538
|
+
value: 777,
|
|
1539
|
+
writable: true,
|
|
1540
|
+
enumerable: true,
|
|
1541
|
+
configurable: true,
|
|
1542
|
+
});
|
|
1543
|
+
},
|
|
1544
|
+
'ownKeys'() {
|
|
1545
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1546
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1547
|
+
},
|
|
1548
|
+
'getPrototypeOf'() {
|
|
1549
|
+
class Foo {
|
|
1550
|
+
}
|
|
1551
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1552
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1553
|
+
},
|
|
1554
|
+
'setPrototypeOf'() {
|
|
1555
|
+
class Foo {
|
|
1556
|
+
}
|
|
1557
|
+
const target = {};
|
|
1558
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1559
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1560
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1561
|
+
},
|
|
1562
|
+
'instanceof'() {
|
|
1563
|
+
class Foo {
|
|
1564
|
+
}
|
|
1565
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1566
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1567
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1568
|
+
},
|
|
1569
|
+
'autobind'() {
|
|
1570
|
+
class Foo {
|
|
1571
|
+
}
|
|
1572
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1573
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1574
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1575
|
+
},
|
|
1576
|
+
});
|
|
1577
|
+
})($ || ($ = {}));
|
|
1578
|
+
//mol/delegate/delegate.test.ts
|
|
1579
|
+
;
|
|
1580
|
+
"use strict";
|
|
1581
|
+
var $;
|
|
1582
|
+
(function ($) {
|
|
1583
|
+
const instances = new WeakSet();
|
|
1584
|
+
function $mol_delegate(proto, target) {
|
|
1585
|
+
const proxy = new Proxy(proto, {
|
|
1586
|
+
get: (_, field) => {
|
|
1587
|
+
const obj = target();
|
|
1588
|
+
let val = Reflect.get(obj, field);
|
|
1589
|
+
if (typeof val === 'function') {
|
|
1590
|
+
val = val.bind(obj);
|
|
1591
|
+
}
|
|
1592
|
+
return val;
|
|
1593
|
+
},
|
|
1594
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1595
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1596
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1597
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1598
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1599
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1600
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1601
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1602
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1603
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1604
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1605
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1606
|
+
});
|
|
1607
|
+
instances.add(proxy);
|
|
1608
|
+
return proxy;
|
|
1609
|
+
}
|
|
1610
|
+
$.$mol_delegate = $mol_delegate;
|
|
1611
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1612
|
+
value: (obj) => instances.has(obj),
|
|
1613
|
+
});
|
|
1614
|
+
})($ || ($ = {}));
|
|
1615
|
+
//mol/delegate/delegate.ts
|
|
1616
|
+
;
|
|
1617
|
+
"use strict";
|
|
1618
|
+
var $;
|
|
1619
|
+
(function ($) {
|
|
1620
|
+
$.$mol_owning_map = new WeakMap();
|
|
1621
|
+
function $mol_owning_allow(having) {
|
|
1622
|
+
try {
|
|
1623
|
+
if (!having)
|
|
1624
|
+
return false;
|
|
1625
|
+
if (typeof having !== 'object')
|
|
1626
|
+
return false;
|
|
1627
|
+
if (having instanceof $mol_delegate)
|
|
1628
|
+
return false;
|
|
1629
|
+
if (typeof having['destructor'] !== 'function')
|
|
1630
|
+
return false;
|
|
1631
|
+
return true;
|
|
1632
|
+
}
|
|
1633
|
+
catch {
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
|
1638
|
+
function $mol_owning_get(having, Owner) {
|
|
1639
|
+
if (!$mol_owning_allow(having))
|
|
1640
|
+
return null;
|
|
1641
|
+
while (true) {
|
|
1642
|
+
const owner = $.$mol_owning_map.get(having);
|
|
1643
|
+
if (!owner)
|
|
1644
|
+
return owner;
|
|
1645
|
+
if (!Owner)
|
|
1646
|
+
return owner;
|
|
1647
|
+
if (owner instanceof Owner)
|
|
1648
|
+
return owner;
|
|
1649
|
+
having = owner;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
$.$mol_owning_get = $mol_owning_get;
|
|
1653
|
+
function $mol_owning_check(owner, having) {
|
|
1654
|
+
if (!$mol_owning_allow(having))
|
|
1655
|
+
return false;
|
|
1656
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
|
1657
|
+
return false;
|
|
1658
|
+
return true;
|
|
1659
|
+
}
|
|
1660
|
+
$.$mol_owning_check = $mol_owning_check;
|
|
1661
|
+
function $mol_owning_catch(owner, having) {
|
|
1662
|
+
if (!$mol_owning_allow(having))
|
|
1663
|
+
return false;
|
|
1664
|
+
if ($.$mol_owning_map.get(having))
|
|
1665
|
+
return false;
|
|
1666
|
+
$.$mol_owning_map.set(having, owner);
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
1670
|
+
})($ || ($ = {}));
|
|
1671
|
+
//mol/owning/owning.ts
|
|
1672
|
+
;
|
|
1673
|
+
"use strict";
|
|
1674
|
+
//mol/type/writable/writable.test.ts
|
|
1675
|
+
;
|
|
1676
|
+
"use strict";
|
|
1677
|
+
//mol/type/writable/writable.ts
|
|
1678
|
+
;
|
|
1679
|
+
"use strict";
|
|
1680
|
+
var $;
|
|
1681
|
+
(function ($) {
|
|
1682
|
+
class $mol_object2 {
|
|
1683
|
+
static $ = $;
|
|
1684
|
+
[$mol_ambient_ref] = null;
|
|
1685
|
+
get $() {
|
|
1686
|
+
if (this[$mol_ambient_ref])
|
|
1687
|
+
return this[$mol_ambient_ref];
|
|
1688
|
+
const owner = $mol_owning_get(this);
|
|
1689
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
1690
|
+
}
|
|
1691
|
+
set $(next) {
|
|
1692
|
+
if (this[$mol_ambient_ref])
|
|
1693
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
1694
|
+
this[$mol_ambient_ref] = next;
|
|
1695
|
+
}
|
|
1696
|
+
static create(init) {
|
|
1697
|
+
const obj = new this;
|
|
1698
|
+
if (init)
|
|
1699
|
+
init(obj);
|
|
1700
|
+
return obj;
|
|
1701
|
+
}
|
|
1702
|
+
static [Symbol.toPrimitive]() {
|
|
1703
|
+
return this.toString();
|
|
1704
|
+
}
|
|
1705
|
+
static toString() {
|
|
1706
|
+
if (Symbol.toStringTag in this)
|
|
1707
|
+
return this[Symbol.toStringTag];
|
|
1708
|
+
return this.name;
|
|
1709
|
+
}
|
|
1710
|
+
destructor() { }
|
|
1711
|
+
toString() {
|
|
1712
|
+
return this[Symbol.toStringTag] || this.constructor.name + '()';
|
|
1713
|
+
}
|
|
1714
|
+
toJSON() {
|
|
1715
|
+
return this.toString();
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
$.$mol_object2 = $mol_object2;
|
|
1719
|
+
})($ || ($ = {}));
|
|
1720
|
+
//mol/object2/object2.ts
|
|
1721
|
+
;
|
|
1722
|
+
"use strict";
|
|
1723
|
+
var $;
|
|
1724
|
+
(function ($_1) {
|
|
1725
|
+
$mol_test({
|
|
1726
|
+
'tree parsing'() {
|
|
1727
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1728
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1729
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1730
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1731
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1732
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1733
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1734
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1735
|
+
},
|
|
1736
|
+
'inserting'() {
|
|
1737
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1738
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1739
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1740
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1741
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1742
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1743
|
+
},
|
|
1744
|
+
'fromJSON'() {
|
|
1745
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1746
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1747
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1748
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
1749
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1750
|
+
},
|
|
1751
|
+
'toJSON'() {
|
|
1752
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1753
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1754
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1755
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
1756
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1757
|
+
},
|
|
1758
|
+
'hack'() {
|
|
1759
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1760
|
+
'': (tree, context) => [tree.hack(context)],
|
|
1761
|
+
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1762
|
+
});
|
|
1763
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1764
|
+
},
|
|
1765
|
+
'errors handling'($) {
|
|
1766
|
+
const errors = [];
|
|
1767
|
+
class Tree extends $mol_tree {
|
|
1768
|
+
static $ = $.$mol_ambient({
|
|
1769
|
+
$mol_fail: error => errors.push(error.message)
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
Tree.fromString(`
|
|
1773
|
+
\t \tfoo
|
|
1774
|
+
bar \\data
|
|
1775
|
+
`, 'test');
|
|
1776
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1777
|
+
},
|
|
1778
|
+
});
|
|
1779
|
+
})($ || ($ = {}));
|
|
1780
|
+
//mol/tree/tree.test.ts
|
|
1781
|
+
;
|
|
1782
|
+
"use strict";
|
|
1783
|
+
var $;
|
|
1784
|
+
(function ($) {
|
|
1785
|
+
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1786
|
+
class $mol_tree extends $mol_object2 {
|
|
1787
|
+
type;
|
|
1788
|
+
data;
|
|
1514
1789
|
sub;
|
|
1515
1790
|
baseUri;
|
|
1516
1791
|
row;
|
|
@@ -1766,348 +2041,73 @@ var $;
|
|
|
1766
2041
|
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
1767
2042
|
return this.clone({ sub });
|
|
1768
2043
|
}
|
|
1769
|
-
else if (typeof type === 'number') {
|
|
1770
|
-
const sub = this.sub.slice();
|
|
1771
|
-
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
1772
|
-
return this.clone({ sub });
|
|
1773
|
-
}
|
|
1774
|
-
else {
|
|
1775
|
-
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
select(...path) {
|
|
1779
|
-
var next = [this];
|
|
1780
|
-
for (var type of path) {
|
|
1781
|
-
if (!next.length)
|
|
1782
|
-
break;
|
|
1783
|
-
var prev = next;
|
|
1784
|
-
next = [];
|
|
1785
|
-
for (var item of prev) {
|
|
1786
|
-
switch (typeof (type)) {
|
|
1787
|
-
case 'string':
|
|
1788
|
-
for (var child of item.sub) {
|
|
1789
|
-
if (!type || (child.type == type)) {
|
|
1790
|
-
next.push(child);
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
break;
|
|
1794
|
-
case 'number':
|
|
1795
|
-
if (type < item.sub.length)
|
|
1796
|
-
next.push(item.sub[type]);
|
|
1797
|
-
break;
|
|
1798
|
-
default: next.push(...item.sub);
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
return new $mol_tree({ sub: next });
|
|
1803
|
-
}
|
|
1804
|
-
filter(path, value) {
|
|
1805
|
-
var sub = this.sub.filter(function (item) {
|
|
1806
|
-
var found = item.select(...path);
|
|
1807
|
-
if (value == null) {
|
|
1808
|
-
return Boolean(found.sub.length);
|
|
1809
|
-
}
|
|
1810
|
-
else {
|
|
1811
|
-
return found.sub.some(child => child.value == value);
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1814
|
-
return new $mol_tree({ sub: sub });
|
|
1815
|
-
}
|
|
1816
|
-
transform(visit, stack = []) {
|
|
1817
|
-
const sub_stack = [this, ...stack];
|
|
1818
|
-
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
1819
|
-
}
|
|
1820
|
-
hack(context) {
|
|
1821
|
-
const sub = [].concat(...this.sub.map(child => {
|
|
1822
|
-
const handle = context[child.type] || context[''];
|
|
1823
|
-
if (!handle)
|
|
1824
|
-
$mol_fail(child.error('Handler not defined'));
|
|
1825
|
-
return handle(child, context);
|
|
1826
|
-
}));
|
|
1827
|
-
return this.clone({ sub });
|
|
1828
|
-
}
|
|
1829
|
-
error(message) {
|
|
1830
|
-
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
$.$mol_tree = $mol_tree;
|
|
1834
|
-
})($ || ($ = {}));
|
|
1835
|
-
//mol/tree/tree.ts
|
|
1836
|
-
;
|
|
1837
|
-
"use strict";
|
|
1838
|
-
var $;
|
|
1839
|
-
(function ($) {
|
|
1840
|
-
const instances = new WeakSet();
|
|
1841
|
-
function $mol_delegate(proto, target) {
|
|
1842
|
-
const proxy = new Proxy(proto, {
|
|
1843
|
-
get: (_, field) => {
|
|
1844
|
-
const obj = target();
|
|
1845
|
-
let val = Reflect.get(obj, field);
|
|
1846
|
-
if (typeof val === 'function') {
|
|
1847
|
-
val = val.bind(obj);
|
|
1848
|
-
}
|
|
1849
|
-
return val;
|
|
1850
|
-
},
|
|
1851
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
1852
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1853
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1854
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
1855
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1856
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1857
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
1858
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1859
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1860
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1861
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1862
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1863
|
-
});
|
|
1864
|
-
instances.add(proxy);
|
|
1865
|
-
return proxy;
|
|
1866
|
-
}
|
|
1867
|
-
$.$mol_delegate = $mol_delegate;
|
|
1868
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1869
|
-
value: (obj) => instances.has(obj),
|
|
1870
|
-
});
|
|
1871
|
-
})($ || ($ = {}));
|
|
1872
|
-
//mol/delegate/delegate.ts
|
|
1873
|
-
;
|
|
1874
|
-
"use strict";
|
|
1875
|
-
var $;
|
|
1876
|
-
(function ($) {
|
|
1877
|
-
$mol_test({
|
|
1878
|
-
'get'() {
|
|
1879
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1880
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
1881
|
-
},
|
|
1882
|
-
'has'() {
|
|
1883
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1884
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
1885
|
-
},
|
|
1886
|
-
'set'() {
|
|
1887
|
-
const target = { foo: 777 };
|
|
1888
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1889
|
-
proxy.foo = 123;
|
|
1890
|
-
$mol_assert_equal(target.foo, 123);
|
|
1891
|
-
},
|
|
1892
|
-
'getOwnPropertyDescriptor'() {
|
|
1893
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1894
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1895
|
-
value: 777,
|
|
1896
|
-
writable: true,
|
|
1897
|
-
enumerable: true,
|
|
1898
|
-
configurable: true,
|
|
1899
|
-
});
|
|
1900
|
-
},
|
|
1901
|
-
'ownKeys'() {
|
|
1902
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1903
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1904
|
-
},
|
|
1905
|
-
'getPrototypeOf'() {
|
|
1906
|
-
class Foo {
|
|
1907
|
-
}
|
|
1908
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1909
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1910
|
-
},
|
|
1911
|
-
'setPrototypeOf'() {
|
|
1912
|
-
class Foo {
|
|
2044
|
+
else if (typeof type === 'number') {
|
|
2045
|
+
const sub = this.sub.slice();
|
|
2046
|
+
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
2047
|
+
return this.clone({ sub });
|
|
1913
2048
|
}
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1917
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1918
|
-
},
|
|
1919
|
-
'instanceof'() {
|
|
1920
|
-
class Foo {
|
|
2049
|
+
else {
|
|
2050
|
+
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
1921
2051
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2052
|
+
}
|
|
2053
|
+
select(...path) {
|
|
2054
|
+
var next = [this];
|
|
2055
|
+
for (var type of path) {
|
|
2056
|
+
if (!next.length)
|
|
2057
|
+
break;
|
|
2058
|
+
var prev = next;
|
|
2059
|
+
next = [];
|
|
2060
|
+
for (var item of prev) {
|
|
2061
|
+
switch (typeof (type)) {
|
|
2062
|
+
case 'string':
|
|
2063
|
+
for (var child of item.sub) {
|
|
2064
|
+
if (!type || (child.type == type)) {
|
|
2065
|
+
next.push(child);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
break;
|
|
2069
|
+
case 'number':
|
|
2070
|
+
if (type < item.sub.length)
|
|
2071
|
+
next.push(item.sub[type]);
|
|
2072
|
+
break;
|
|
2073
|
+
default: next.push(...item.sub);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
1928
2076
|
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
$mol_test({
|
|
1941
|
-
'tree parsing'() {
|
|
1942
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1943
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1944
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1945
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1946
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1947
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1948
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1949
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1950
|
-
},
|
|
1951
|
-
'inserting'() {
|
|
1952
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1953
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1954
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1955
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1956
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1957
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1958
|
-
},
|
|
1959
|
-
'fromJSON'() {
|
|
1960
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1961
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1962
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1963
|
-
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
1964
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1965
|
-
},
|
|
1966
|
-
'toJSON'() {
|
|
1967
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1968
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1969
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1970
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
1971
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1972
|
-
},
|
|
1973
|
-
'hack'() {
|
|
1974
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1975
|
-
'': (tree, context) => [tree.hack(context)],
|
|
1976
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
2077
|
+
return new $mol_tree({ sub: next });
|
|
2078
|
+
}
|
|
2079
|
+
filter(path, value) {
|
|
2080
|
+
var sub = this.sub.filter(function (item) {
|
|
2081
|
+
var found = item.select(...path);
|
|
2082
|
+
if (value == null) {
|
|
2083
|
+
return Boolean(found.sub.length);
|
|
2084
|
+
}
|
|
2085
|
+
else {
|
|
2086
|
+
return found.sub.some(child => child.value == value);
|
|
2087
|
+
}
|
|
1977
2088
|
});
|
|
1978
|
-
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
const
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
//mol/tree/tree.test.ts
|
|
1996
|
-
;
|
|
1997
|
-
"use strict";
|
|
1998
|
-
var $;
|
|
1999
|
-
(function ($) {
|
|
2000
|
-
const named = new WeakSet();
|
|
2001
|
-
function $mol_func_name(func) {
|
|
2002
|
-
let name = func.name;
|
|
2003
|
-
if (name?.length > 1)
|
|
2004
|
-
return name;
|
|
2005
|
-
if (named.has(func))
|
|
2006
|
-
return name;
|
|
2007
|
-
for (let key in this) {
|
|
2008
|
-
try {
|
|
2009
|
-
if (this[key] !== func)
|
|
2010
|
-
continue;
|
|
2011
|
-
name = key;
|
|
2012
|
-
Object.defineProperty(func, 'name', { value: name });
|
|
2013
|
-
break;
|
|
2014
|
-
}
|
|
2015
|
-
catch { }
|
|
2089
|
+
return new $mol_tree({ sub: sub });
|
|
2090
|
+
}
|
|
2091
|
+
transform(visit, stack = []) {
|
|
2092
|
+
const sub_stack = [this, ...stack];
|
|
2093
|
+
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
2094
|
+
}
|
|
2095
|
+
hack(context) {
|
|
2096
|
+
const sub = [].concat(...this.sub.map(child => {
|
|
2097
|
+
const handle = context[child.type] || context[''];
|
|
2098
|
+
if (!handle)
|
|
2099
|
+
$mol_fail(child.error('Handler not defined'));
|
|
2100
|
+
return handle(child, context);
|
|
2101
|
+
}));
|
|
2102
|
+
return this.clone({ sub });
|
|
2103
|
+
}
|
|
2104
|
+
error(message) {
|
|
2105
|
+
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
2016
2106
|
}
|
|
2017
|
-
named.add(func);
|
|
2018
|
-
return name;
|
|
2019
|
-
}
|
|
2020
|
-
$.$mol_func_name = $mol_func_name;
|
|
2021
|
-
function $mol_func_name_from(target, source) {
|
|
2022
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
|
2023
|
-
return target;
|
|
2024
2107
|
}
|
|
2025
|
-
$.$
|
|
2026
|
-
})($ || ($ = {}));
|
|
2027
|
-
//mol/func/name/name.ts
|
|
2028
|
-
;
|
|
2029
|
-
"use strict";
|
|
2030
|
-
var $;
|
|
2031
|
-
(function ($_1) {
|
|
2032
|
-
$mol_test({
|
|
2033
|
-
'FQN of anon function'($) {
|
|
2034
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2035
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2036
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2037
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2038
|
-
},
|
|
2039
|
-
});
|
|
2040
|
-
})($ || ($ = {}));
|
|
2041
|
-
//mol/func/name/name.test.ts
|
|
2042
|
-
;
|
|
2043
|
-
"use strict";
|
|
2044
|
-
var $;
|
|
2045
|
-
(function ($) {
|
|
2046
|
-
$mol_test({
|
|
2047
|
-
'config by value'() {
|
|
2048
|
-
const N = $mol_data_setup((a) => a, 5);
|
|
2049
|
-
$mol_assert_equal(N.config, 5);
|
|
2050
|
-
},
|
|
2051
|
-
});
|
|
2052
|
-
})($ || ($ = {}));
|
|
2053
|
-
//mol/data/setup/setup.test.ts
|
|
2054
|
-
;
|
|
2055
|
-
"use strict";
|
|
2056
|
-
var $;
|
|
2057
|
-
(function ($) {
|
|
2058
|
-
$mol_test({
|
|
2059
|
-
'equal paths'() {
|
|
2060
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
2061
|
-
$mol_assert_like(diff, {
|
|
2062
|
-
prefix: [1, 2, 3, 4],
|
|
2063
|
-
suffix: [[], [], []],
|
|
2064
|
-
});
|
|
2065
|
-
},
|
|
2066
|
-
'different suffix'() {
|
|
2067
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
2068
|
-
$mol_assert_like(diff, {
|
|
2069
|
-
prefix: [1, 2],
|
|
2070
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
2071
|
-
});
|
|
2072
|
-
},
|
|
2073
|
-
'one contains other'() {
|
|
2074
|
-
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
2075
|
-
$mol_assert_like(diff, {
|
|
2076
|
-
prefix: [1, 2],
|
|
2077
|
-
suffix: [[3, 4], [], [3]],
|
|
2078
|
-
});
|
|
2079
|
-
},
|
|
2080
|
-
'fully different'() {
|
|
2081
|
-
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
2082
|
-
$mol_assert_like(diff, {
|
|
2083
|
-
prefix: [],
|
|
2084
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
2085
|
-
});
|
|
2086
|
-
},
|
|
2087
|
-
});
|
|
2088
|
-
})($ || ($ = {}));
|
|
2089
|
-
//mol/diff/path/path.test.ts
|
|
2090
|
-
;
|
|
2091
|
-
"use strict";
|
|
2092
|
-
var $;
|
|
2093
|
-
(function ($) {
|
|
2094
|
-
$mol_test({
|
|
2095
|
-
'Is number'() {
|
|
2096
|
-
$mol_data_number(0);
|
|
2097
|
-
},
|
|
2098
|
-
'Is not number'() {
|
|
2099
|
-
$mol_assert_fail(() => {
|
|
2100
|
-
$mol_data_number('x');
|
|
2101
|
-
}, 'x is not a number');
|
|
2102
|
-
},
|
|
2103
|
-
'Is object number'() {
|
|
2104
|
-
$mol_assert_fail(() => {
|
|
2105
|
-
$mol_data_number(new Number(''));
|
|
2106
|
-
}, '0 is not a number');
|
|
2107
|
-
},
|
|
2108
|
-
});
|
|
2108
|
+
$.$mol_tree = $mol_tree;
|
|
2109
2109
|
})($ || ($ = {}));
|
|
2110
|
-
//mol/
|
|
2110
|
+
//mol/tree/tree.ts
|
|
2111
2111
|
;
|
|
2112
2112
|
"use strict";
|
|
2113
2113
|
var $;
|