mol_time_all 1.1.24 → 1.1.28
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.d.ts +3 -0
- package/node.deps.json +1 -1
- package/node.esm.js +9 -0
- package/node.esm.js.map +1 -1
- package/node.js +9 -0
- package/node.js.map +1 -1
- package/node.test.js +149 -219
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +3 -0
- package/web.deps.json +1 -1
- package/web.esm.js +9 -0
- package/web.esm.js.map +1 -1
- package/web.js +9 -0
- package/web.js.map +1 -1
- package/web.test.js +140 -219
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -151,6 +151,9 @@ var $;
|
|
|
151
151
|
toString(pattern = 'P#Y#M#DT#h#m#s') {
|
|
152
152
|
return super.toString(pattern);
|
|
153
153
|
}
|
|
154
|
+
[Symbol.toPrimitive](mode) {
|
|
155
|
+
return mode === 'number' ? this.valueOf() : this.toString();
|
|
156
|
+
}
|
|
154
157
|
static patterns = {
|
|
155
158
|
'#Y': (duration) => {
|
|
156
159
|
if (!duration.year)
|
|
@@ -357,6 +360,9 @@ var $;
|
|
|
357
360
|
toString(pattern = 'YYYY-MM-DDThh:mm:ss.sssZ') {
|
|
358
361
|
return super.toString(pattern);
|
|
359
362
|
}
|
|
363
|
+
[Symbol.toPrimitive](mode) {
|
|
364
|
+
return mode === 'number' ? this.valueOf() : this.toString();
|
|
365
|
+
}
|
|
360
366
|
static patterns = {
|
|
361
367
|
'YYYY': (moment) => {
|
|
362
368
|
if (moment.year == null)
|
|
@@ -640,6 +646,9 @@ var $;
|
|
|
640
646
|
toString() {
|
|
641
647
|
return (this._start || this._duration || '').toString() + '/' + (this._end || this._duration || '').toString();
|
|
642
648
|
}
|
|
649
|
+
[Symbol.toPrimitive](mode) {
|
|
650
|
+
return this.toString();
|
|
651
|
+
}
|
|
643
652
|
}
|
|
644
653
|
$.$mol_time_interval = $mol_time_interval;
|
|
645
654
|
})($ || ($ = {}));
|
|
@@ -1037,23 +1046,16 @@ var $;
|
|
|
1037
1046
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
1038
1047
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
1039
1048
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
1040
|
-
},
|
|
1041
|
-
'Number'() {
|
|
1042
1049
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
1043
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
1044
1050
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
1045
1051
|
},
|
|
1046
|
-
'
|
|
1052
|
+
'POJO'() {
|
|
1047
1053
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
1048
|
-
},
|
|
1049
|
-
'different POJOs'() {
|
|
1050
1054
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1051
|
-
},
|
|
1052
|
-
'different POJOs with same keys but different values'() {
|
|
1053
1055
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1054
|
-
},
|
|
1055
|
-
'different POJOs with different keys but same values'() {
|
|
1056
1056
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
1057
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1058
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1057
1059
|
},
|
|
1058
1060
|
'Array'() {
|
|
1059
1061
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -1061,17 +1063,12 @@ var $;
|
|
|
1061
1063
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
1062
1064
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1063
1065
|
},
|
|
1064
|
-
'
|
|
1065
|
-
|
|
1066
|
-
},
|
|
1067
|
-
'different classes with same values'() {
|
|
1068
|
-
class Obj {
|
|
1069
|
-
foo = 1;
|
|
1066
|
+
'Non POJO are different'() {
|
|
1067
|
+
class Thing extends Object {
|
|
1070
1068
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
1069
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
1070
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
1071
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1075
1072
|
},
|
|
1076
1073
|
'same POJOs with cyclic reference'() {
|
|
1077
1074
|
const a = { foo: {} };
|
|
@@ -1080,41 +1077,6 @@ var $;
|
|
|
1080
1077
|
b['self'] = b;
|
|
1081
1078
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
1082
1079
|
},
|
|
1083
|
-
'empty Element'() {
|
|
1084
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
1085
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
1086
|
-
},
|
|
1087
|
-
'Element with attributes'() {
|
|
1088
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
1089
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
1090
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
1091
|
-
},
|
|
1092
|
-
'Element with styles'() {
|
|
1093
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
1094
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
1095
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
1096
|
-
},
|
|
1097
|
-
'Element with content'() {
|
|
1098
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1099
|
-
"foo",
|
|
1100
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1101
|
-
"foo",
|
|
1102
|
-
$.$mol_jsx("br", null))));
|
|
1103
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1104
|
-
"foo",
|
|
1105
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1106
|
-
"bar",
|
|
1107
|
-
$.$mol_jsx("br", null))));
|
|
1108
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1109
|
-
"foo",
|
|
1110
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1111
|
-
"foo",
|
|
1112
|
-
$.$mol_jsx("hr", null))));
|
|
1113
|
-
},
|
|
1114
|
-
'Element with handlers'() {
|
|
1115
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
1116
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
1117
|
-
},
|
|
1118
1080
|
'Date'() {
|
|
1119
1081
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1120
1082
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -1126,8 +1088,9 @@ var $;
|
|
|
1126
1088
|
},
|
|
1127
1089
|
'Map'() {
|
|
1128
1090
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
1129
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
1091
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1130
1092
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1093
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1131
1094
|
},
|
|
1132
1095
|
'Set'() {
|
|
1133
1096
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -1139,6 +1102,21 @@ var $;
|
|
|
1139
1102
|
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1140
1103
|
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1141
1104
|
},
|
|
1105
|
+
'Custom comparator'() {
|
|
1106
|
+
class User {
|
|
1107
|
+
name;
|
|
1108
|
+
rand;
|
|
1109
|
+
constructor(name, rand = Math.random()) {
|
|
1110
|
+
this.name = name;
|
|
1111
|
+
this.rand = rand;
|
|
1112
|
+
}
|
|
1113
|
+
[Symbol.toPrimitive](mode) {
|
|
1114
|
+
return this.name;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
$.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1118
|
+
$.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
|
|
1119
|
+
},
|
|
1142
1120
|
});
|
|
1143
1121
|
})($ || ($ = {}));
|
|
1144
1122
|
//deep.test.js.map
|
|
@@ -1146,97 +1124,123 @@ var $;
|
|
|
1146
1124
|
"use strict";
|
|
1147
1125
|
var $;
|
|
1148
1126
|
(function ($) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
function $mol_compare_deep(a, b) {
|
|
1153
|
-
if (Object.is(a, b))
|
|
1127
|
+
let cache = new WeakMap();
|
|
1128
|
+
function $mol_compare_deep(left, right) {
|
|
1129
|
+
if (Object.is(left, right))
|
|
1154
1130
|
return true;
|
|
1155
|
-
|
|
1156
|
-
const b_type = typeof b;
|
|
1157
|
-
if (a_type !== b_type)
|
|
1131
|
+
if (left === null)
|
|
1158
1132
|
return false;
|
|
1159
|
-
if (
|
|
1160
|
-
return a['toString']() === b['toString']();
|
|
1161
|
-
if (a_type !== 'object')
|
|
1133
|
+
if (right === null)
|
|
1162
1134
|
return false;
|
|
1163
|
-
if (
|
|
1135
|
+
if (typeof left !== 'object')
|
|
1164
1136
|
return false;
|
|
1165
|
-
if (
|
|
1137
|
+
if (typeof right !== 'object')
|
|
1166
1138
|
return false;
|
|
1167
|
-
|
|
1139
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1140
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1141
|
+
if (left_proto !== right_proto)
|
|
1168
1142
|
return false;
|
|
1169
|
-
if (
|
|
1170
|
-
return
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
if (
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1143
|
+
if (left instanceof Boolean)
|
|
1144
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1145
|
+
if (left instanceof Number)
|
|
1146
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1147
|
+
if (left instanceof String)
|
|
1148
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1149
|
+
if (left instanceof Date)
|
|
1150
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1151
|
+
if (left instanceof RegExp)
|
|
1152
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
1153
|
+
let left_cache = cache.get(left);
|
|
1154
|
+
if (left_cache) {
|
|
1155
|
+
const right_cache = left_cache.get(right);
|
|
1156
|
+
if (typeof right_cache === 'boolean')
|
|
1157
|
+
return right_cache;
|
|
1182
1158
|
}
|
|
1183
1159
|
else {
|
|
1184
|
-
|
|
1185
|
-
cache.set(
|
|
1160
|
+
left_cache = new WeakMap([[right, true]]);
|
|
1161
|
+
cache.set(left, left_cache);
|
|
1186
1162
|
}
|
|
1187
|
-
a_stack.push(a);
|
|
1188
|
-
b_stack.push(b);
|
|
1189
1163
|
let result;
|
|
1190
1164
|
try {
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
let count = 0;
|
|
1207
|
-
for (let key in a) {
|
|
1208
|
-
try {
|
|
1209
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
1210
|
-
return result = false;
|
|
1211
|
-
}
|
|
1212
|
-
catch (error) {
|
|
1213
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
1214
|
-
}
|
|
1215
|
-
++count;
|
|
1216
|
-
}
|
|
1217
|
-
for (let key in b) {
|
|
1218
|
-
--count;
|
|
1219
|
-
if (count < 0)
|
|
1220
|
-
return result = false;
|
|
1221
|
-
}
|
|
1222
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
1223
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
1224
|
-
return result = false;
|
|
1225
|
-
}
|
|
1226
|
-
return result = true;
|
|
1165
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
1166
|
+
result = compare_pojo(left, right);
|
|
1167
|
+
else if (Array.isArray(left))
|
|
1168
|
+
result = compare_array(left, right);
|
|
1169
|
+
else if (left instanceof Set)
|
|
1170
|
+
result = compare_set(left, right);
|
|
1171
|
+
else if (left instanceof Map)
|
|
1172
|
+
result = compare_map(left, right);
|
|
1173
|
+
else if (ArrayBuffer.isView(left))
|
|
1174
|
+
result = compare_buffer(left, right);
|
|
1175
|
+
else if (Symbol.toPrimitive in left)
|
|
1176
|
+
result = compare_primitive(left, right);
|
|
1177
|
+
else
|
|
1178
|
+
result = false;
|
|
1227
1179
|
}
|
|
1228
1180
|
finally {
|
|
1229
|
-
|
|
1230
|
-
b_stack.pop();
|
|
1231
|
-
if (a_stack.length === 0) {
|
|
1232
|
-
cache = null;
|
|
1233
|
-
}
|
|
1234
|
-
else {
|
|
1235
|
-
a_cache.set(b, result);
|
|
1236
|
-
}
|
|
1181
|
+
left_cache.set(right, result);
|
|
1237
1182
|
}
|
|
1183
|
+
return result;
|
|
1238
1184
|
}
|
|
1239
1185
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
1186
|
+
function compare_array(left, right) {
|
|
1187
|
+
const len = left.length;
|
|
1188
|
+
if (len !== right.length)
|
|
1189
|
+
return false;
|
|
1190
|
+
for (let i = 0; i < len; ++i) {
|
|
1191
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
return true;
|
|
1195
|
+
}
|
|
1196
|
+
function compare_buffer(left, right) {
|
|
1197
|
+
const len = left.byteLength;
|
|
1198
|
+
if (len !== right.byteLength)
|
|
1199
|
+
return false;
|
|
1200
|
+
for (let i = 0; i < len; ++i) {
|
|
1201
|
+
if (left[i] !== right[i])
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
return true;
|
|
1205
|
+
}
|
|
1206
|
+
function compare_iterator(left, right, compare) {
|
|
1207
|
+
while (true) {
|
|
1208
|
+
const left_next = left.next();
|
|
1209
|
+
const right_next = right.next();
|
|
1210
|
+
if (left_next.done !== right_next.done)
|
|
1211
|
+
return false;
|
|
1212
|
+
if (left_next.done)
|
|
1213
|
+
break;
|
|
1214
|
+
if (!compare(left_next.value, right_next.value))
|
|
1215
|
+
return false;
|
|
1216
|
+
}
|
|
1217
|
+
return true;
|
|
1218
|
+
}
|
|
1219
|
+
function compare_set(left, right) {
|
|
1220
|
+
if (left.size !== right.size)
|
|
1221
|
+
return false;
|
|
1222
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1223
|
+
}
|
|
1224
|
+
function compare_map(left, right) {
|
|
1225
|
+
if (left.size !== right.size)
|
|
1226
|
+
return false;
|
|
1227
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
1228
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1229
|
+
}
|
|
1230
|
+
function compare_pojo(left, right) {
|
|
1231
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1232
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1233
|
+
if (left_keys.length !== right_keys.length)
|
|
1234
|
+
return false;
|
|
1235
|
+
for (let key of left_keys) {
|
|
1236
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
return true;
|
|
1240
|
+
}
|
|
1241
|
+
function compare_primitive(left, right) {
|
|
1242
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1243
|
+
}
|
|
1240
1244
|
})($ || ($ = {}));
|
|
1241
1245
|
//deep.js.map
|
|
1242
1246
|
;
|
|
@@ -1378,6 +1382,10 @@ var $;
|
|
|
1378
1382
|
'format typed'() {
|
|
1379
1383
|
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1380
1384
|
},
|
|
1385
|
+
'comparison'() {
|
|
1386
|
+
const iso = 'P1Y1M1DT1h1m1s';
|
|
1387
|
+
$.$mol_assert_like(new $.$mol_time_duration(iso), new $.$mol_time_duration(iso));
|
|
1388
|
+
},
|
|
1381
1389
|
});
|
|
1382
1390
|
})($ || ($ = {}));
|
|
1383
1391
|
//duration.test.js.map
|
|
@@ -1433,7 +1441,11 @@ var $;
|
|
|
1433
1441
|
},
|
|
1434
1442
|
'change offset'() {
|
|
1435
1443
|
$.$mol_assert_equal(new $.$mol_time_moment('2021-04-10 +03:00').toOffset('Z').toString(), '2021-04-09T21:00:00+00:00');
|
|
1436
|
-
}
|
|
1444
|
+
},
|
|
1445
|
+
'comparison'() {
|
|
1446
|
+
const iso = '2021-01-02T03:04:05.678+09:10';
|
|
1447
|
+
$.$mol_assert_like(new $.$mol_time_moment(iso), new $.$mol_time_moment(iso));
|
|
1448
|
+
},
|
|
1437
1449
|
});
|
|
1438
1450
|
})($ || ($ = {}));
|
|
1439
1451
|
//moment.test.js.map
|
|
@@ -1446,7 +1458,11 @@ var $;
|
|
|
1446
1458
|
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/P1M').end.toString(), '2015-02-01');
|
|
1447
1459
|
$.$mol_assert_equal(new $.$mol_time_interval('P1M/2015-02-01').start.toString(), '2015-01-01');
|
|
1448
1460
|
$.$mol_assert_equal(new $.$mol_time_interval('2015-01-01/2015-02-01').duration.toString(), 'PT2678400S');
|
|
1449
|
-
}
|
|
1461
|
+
},
|
|
1462
|
+
'comparison'() {
|
|
1463
|
+
const iso = '2021-01-02/2022-03-04';
|
|
1464
|
+
$.$mol_assert_like(new $.$mol_time_interval(iso), new $.$mol_time_interval(iso));
|
|
1465
|
+
},
|
|
1450
1466
|
});
|
|
1451
1467
|
})($ || ($ = {}));
|
|
1452
1468
|
//interval.test.js.map
|
|
@@ -2204,91 +2220,5 @@ var $;
|
|
|
2204
2220
|
;
|
|
2205
2221
|
"use strict";
|
|
2206
2222
|
//equals.js.map
|
|
2207
|
-
;
|
|
2208
|
-
"use strict";
|
|
2209
|
-
var $;
|
|
2210
|
-
(function ($) {
|
|
2211
|
-
$.$mol_test({
|
|
2212
|
-
'equal paths'() {
|
|
2213
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
2214
|
-
$.$mol_assert_like(diff, {
|
|
2215
|
-
prefix: [1, 2, 3, 4],
|
|
2216
|
-
suffix: [[], [], []],
|
|
2217
|
-
});
|
|
2218
|
-
},
|
|
2219
|
-
'different suffix'() {
|
|
2220
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
2221
|
-
$.$mol_assert_like(diff, {
|
|
2222
|
-
prefix: [1, 2],
|
|
2223
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
2224
|
-
});
|
|
2225
|
-
},
|
|
2226
|
-
'one contains other'() {
|
|
2227
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
2228
|
-
$.$mol_assert_like(diff, {
|
|
2229
|
-
prefix: [1, 2],
|
|
2230
|
-
suffix: [[3, 4], [], [3]],
|
|
2231
|
-
});
|
|
2232
|
-
},
|
|
2233
|
-
'fully different'() {
|
|
2234
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
2235
|
-
$.$mol_assert_like(diff, {
|
|
2236
|
-
prefix: [],
|
|
2237
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
2238
|
-
});
|
|
2239
|
-
},
|
|
2240
|
-
});
|
|
2241
|
-
})($ || ($ = {}));
|
|
2242
|
-
//path.test.js.map
|
|
2243
|
-
;
|
|
2244
|
-
"use strict";
|
|
2245
|
-
var $;
|
|
2246
|
-
(function ($) {
|
|
2247
|
-
function $mol_diff_path(...paths) {
|
|
2248
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
2249
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
2250
|
-
const first = paths[0][i];
|
|
2251
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
2252
|
-
if (paths[j][i] !== first)
|
|
2253
|
-
break lookup;
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
return {
|
|
2257
|
-
prefix: paths[0].slice(0, i),
|
|
2258
|
-
suffix: paths.map(path => path.slice(i)),
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
2262
|
-
})($ || ($ = {}));
|
|
2263
|
-
//path.js.map
|
|
2264
|
-
;
|
|
2265
|
-
"use strict";
|
|
2266
|
-
var $;
|
|
2267
|
-
(function ($) {
|
|
2268
|
-
class $mol_error_mix extends Error {
|
|
2269
|
-
errors;
|
|
2270
|
-
constructor(message, ...errors) {
|
|
2271
|
-
super(message);
|
|
2272
|
-
this.errors = errors;
|
|
2273
|
-
if (errors.length) {
|
|
2274
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
2275
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
2276
|
-
if (!stack)
|
|
2277
|
-
return [];
|
|
2278
|
-
return stack.split('\n').reverse();
|
|
2279
|
-
}));
|
|
2280
|
-
const head = diff.prefix.reverse().join('\n');
|
|
2281
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
2282
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
2283
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
toJSON() {
|
|
2287
|
-
return this.message;
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
2291
|
-
})($ || ($ = {}));
|
|
2292
|
-
//mix.js.map
|
|
2293
2223
|
|
|
2294
2224
|
//# sourceMappingURL=node.test.js.map
|