mol_data_all 1.1.209 → 1.1.213
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 +0 -226
- package/node.deps.json +1 -1
- package/node.esm.js +70 -70
- package/node.esm.js.map +1 -1
- package/node.js +70 -70
- package/node.js.map +1 -1
- package/node.test.js +452 -446
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -226
- package/web.deps.json +1 -1
- package/web.esm.js +70 -70
- package/web.esm.js.map +1 -1
- package/web.js +70 -70
- package/web.js.map +1 -1
- package/web.test.js +306 -300
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -19,10 +19,10 @@ var $;
|
|
|
19
19
|
(function ($) {
|
|
20
20
|
})($ || ($ = {}));
|
|
21
21
|
module.exports = $;
|
|
22
|
-
//mam.
|
|
22
|
+
//mam.ts
|
|
23
23
|
;
|
|
24
24
|
"use strict";
|
|
25
|
-
//value.
|
|
25
|
+
//mol/data/value/value.ts
|
|
26
26
|
;
|
|
27
27
|
"use strict";
|
|
28
28
|
var $;
|
|
@@ -35,7 +35,7 @@ var $;
|
|
|
35
35
|
}
|
|
36
36
|
$.$mol_data_setup = $mol_data_setup;
|
|
37
37
|
})($ || ($ = {}));
|
|
38
|
-
//setup.
|
|
38
|
+
//mol/data/setup/setup.ts
|
|
39
39
|
;
|
|
40
40
|
"use strict";
|
|
41
41
|
var $;
|
|
@@ -45,7 +45,7 @@ var $;
|
|
|
45
45
|
}
|
|
46
46
|
$.$mol_fail = $mol_fail;
|
|
47
47
|
})($ || ($ = {}));
|
|
48
|
-
//fail.
|
|
48
|
+
//mol/fail/fail.ts
|
|
49
49
|
;
|
|
50
50
|
"use strict";
|
|
51
51
|
var $;
|
|
@@ -66,7 +66,7 @@ var $;
|
|
|
66
66
|
}
|
|
67
67
|
$.$mol_diff_path = $mol_diff_path;
|
|
68
68
|
})($ || ($ = {}));
|
|
69
|
-
//path.
|
|
69
|
+
//mol/diff/path/path.ts
|
|
70
70
|
;
|
|
71
71
|
"use strict";
|
|
72
72
|
var $;
|
|
@@ -78,7 +78,7 @@ var $;
|
|
|
78
78
|
this.errors = errors;
|
|
79
79
|
if (errors.length) {
|
|
80
80
|
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
81
|
-
const diff =
|
|
81
|
+
const diff = $mol_diff_path(...stacks.map(stack => {
|
|
82
82
|
if (!stack)
|
|
83
83
|
return [];
|
|
84
84
|
return stack.split('\n').reverse();
|
|
@@ -95,16 +95,16 @@ var $;
|
|
|
95
95
|
}
|
|
96
96
|
$.$mol_error_mix = $mol_error_mix;
|
|
97
97
|
})($ || ($ = {}));
|
|
98
|
-
//mix.
|
|
98
|
+
//mol/error/mix/mix.ts
|
|
99
99
|
;
|
|
100
100
|
"use strict";
|
|
101
101
|
var $;
|
|
102
102
|
(function ($) {
|
|
103
|
-
class $mol_data_error extends
|
|
103
|
+
class $mol_data_error extends $mol_error_mix {
|
|
104
104
|
}
|
|
105
105
|
$.$mol_data_error = $mol_data_error;
|
|
106
106
|
})($ || ($ = {}));
|
|
107
|
-
//error.
|
|
107
|
+
//mol/data/error/error.ts
|
|
108
108
|
;
|
|
109
109
|
"use strict";
|
|
110
110
|
var $;
|
|
@@ -114,31 +114,31 @@ var $;
|
|
|
114
114
|
}
|
|
115
115
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
116
116
|
})($ || ($ = {}));
|
|
117
|
-
//hidden.
|
|
117
|
+
//mol/fail/hidden/hidden.ts
|
|
118
118
|
;
|
|
119
119
|
"use strict";
|
|
120
120
|
var $;
|
|
121
121
|
(function ($) {
|
|
122
122
|
function $mol_data_array(sub) {
|
|
123
|
-
return
|
|
123
|
+
return $mol_data_setup((val) => {
|
|
124
124
|
if (!Array.isArray(val))
|
|
125
|
-
return
|
|
125
|
+
return $mol_fail(new $mol_data_error(`${val} is not an array`));
|
|
126
126
|
return val.map((item, index) => {
|
|
127
127
|
try {
|
|
128
128
|
return sub(item);
|
|
129
129
|
}
|
|
130
130
|
catch (error) {
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
131
|
+
if (error instanceof Promise)
|
|
132
|
+
return $mol_fail_hidden(error);
|
|
133
133
|
error.message = `[${index}] ${error.message}`;
|
|
134
|
-
return
|
|
134
|
+
return $mol_fail(error);
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
}, sub);
|
|
138
138
|
}
|
|
139
139
|
$.$mol_data_array = $mol_data_array;
|
|
140
140
|
})($ || ($ = {}));
|
|
141
|
-
//array.
|
|
141
|
+
//mol/data/array/array.ts
|
|
142
142
|
;
|
|
143
143
|
"use strict";
|
|
144
144
|
var $;
|
|
@@ -146,24 +146,24 @@ var $;
|
|
|
146
146
|
$.$mol_data_boolean = (val) => {
|
|
147
147
|
if (typeof val === 'boolean')
|
|
148
148
|
return val;
|
|
149
|
-
return
|
|
149
|
+
return $mol_fail(new $mol_data_error(`${val} is not a boolean`));
|
|
150
150
|
};
|
|
151
151
|
})($ || ($ = {}));
|
|
152
|
-
//boolean.
|
|
152
|
+
//mol/data/boolean/boolean.ts
|
|
153
153
|
;
|
|
154
154
|
"use strict";
|
|
155
155
|
var $;
|
|
156
156
|
(function ($) {
|
|
157
157
|
function $mol_data_const(ref) {
|
|
158
|
-
return
|
|
158
|
+
return $mol_data_setup((val) => {
|
|
159
159
|
if (Object.is(val, ref))
|
|
160
160
|
return ref;
|
|
161
|
-
return
|
|
161
|
+
return $mol_fail(new $mol_data_error(`${val} is not ${ref}`));
|
|
162
162
|
}, ref);
|
|
163
163
|
}
|
|
164
164
|
$.$mol_data_const = $mol_data_const;
|
|
165
165
|
})($ || ($ = {}));
|
|
166
|
-
//const.
|
|
166
|
+
//mol/data/const/const.ts
|
|
167
167
|
;
|
|
168
168
|
"use strict";
|
|
169
169
|
var $;
|
|
@@ -171,32 +171,32 @@ var $;
|
|
|
171
171
|
$.$mol_data_string = (val) => {
|
|
172
172
|
if (typeof val === 'string')
|
|
173
173
|
return val;
|
|
174
|
-
return
|
|
174
|
+
return $mol_fail(new $mol_data_error(`${val} is not a string`));
|
|
175
175
|
};
|
|
176
176
|
})($ || ($ = {}));
|
|
177
|
-
//string.
|
|
177
|
+
//mol/data/string/string.ts
|
|
178
178
|
;
|
|
179
179
|
"use strict";
|
|
180
180
|
var $;
|
|
181
181
|
(function ($) {
|
|
182
182
|
function $mol_data_pattern(pattern) {
|
|
183
|
-
return
|
|
184
|
-
const val2 =
|
|
183
|
+
return $mol_data_setup((val) => {
|
|
184
|
+
const val2 = $mol_data_string(val);
|
|
185
185
|
if (pattern.test(val2))
|
|
186
186
|
return val2;
|
|
187
|
-
return
|
|
187
|
+
return $mol_fail(new $mol_data_error(`${val} is not a ${pattern}`));
|
|
188
188
|
}, pattern);
|
|
189
189
|
}
|
|
190
190
|
$.$mol_data_pattern = $mol_data_pattern;
|
|
191
191
|
})($ || ($ = {}));
|
|
192
|
-
//pattern.
|
|
192
|
+
//mol/data/pattern/pattern.ts
|
|
193
193
|
;
|
|
194
194
|
"use strict";
|
|
195
195
|
var $;
|
|
196
196
|
(function ($) {
|
|
197
|
-
$.$mol_data_email =
|
|
197
|
+
$.$mol_data_email = $mol_data_pattern(/.+@.+/);
|
|
198
198
|
})($ || ($ = {}));
|
|
199
|
-
//email.
|
|
199
|
+
//mol/data/email/email.ts
|
|
200
200
|
;
|
|
201
201
|
"use strict";
|
|
202
202
|
var $;
|
|
@@ -208,30 +208,30 @@ var $;
|
|
|
208
208
|
index[dict[key]] = key;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
return
|
|
211
|
+
return $mol_data_setup((value) => {
|
|
212
212
|
if (typeof index[value] !== 'string') {
|
|
213
|
-
return
|
|
213
|
+
return $mol_fail(new $mol_data_error(`${value} is not value of ${name} enum`));
|
|
214
214
|
}
|
|
215
215
|
return value;
|
|
216
216
|
}, { name, dict });
|
|
217
217
|
}
|
|
218
218
|
$.$mol_data_enum = $mol_data_enum;
|
|
219
219
|
})($ || ($ = {}));
|
|
220
|
-
//enum.
|
|
220
|
+
//mol/data/enum/enum.ts
|
|
221
221
|
;
|
|
222
222
|
"use strict";
|
|
223
223
|
var $;
|
|
224
224
|
(function ($) {
|
|
225
225
|
function $mol_data_instance(Instance) {
|
|
226
|
-
return
|
|
226
|
+
return $mol_data_setup((val) => {
|
|
227
227
|
if (val instanceof Instance)
|
|
228
228
|
return val;
|
|
229
|
-
return
|
|
229
|
+
return $mol_fail(new $mol_data_error(`${val} is not a ${Instance.name}`));
|
|
230
230
|
}, Instance);
|
|
231
231
|
}
|
|
232
232
|
$.$mol_data_instance = $mol_data_instance;
|
|
233
233
|
})($ || ($ = {}));
|
|
234
|
-
//instance.
|
|
234
|
+
//mol/data/instance/instance.ts
|
|
235
235
|
;
|
|
236
236
|
"use strict";
|
|
237
237
|
var $;
|
|
@@ -239,23 +239,23 @@ var $;
|
|
|
239
239
|
$.$mol_data_number = (val) => {
|
|
240
240
|
if (typeof val === 'number')
|
|
241
241
|
return val;
|
|
242
|
-
return
|
|
242
|
+
return $mol_fail(new $mol_data_error(`${val} is not a number`));
|
|
243
243
|
};
|
|
244
244
|
})($ || ($ = {}));
|
|
245
|
-
//number.
|
|
245
|
+
//mol/data/number/number.ts
|
|
246
246
|
;
|
|
247
247
|
"use strict";
|
|
248
248
|
var $;
|
|
249
249
|
(function ($) {
|
|
250
250
|
function $mol_data_integer(val) {
|
|
251
|
-
const val2 =
|
|
251
|
+
const val2 = $mol_data_number(val);
|
|
252
252
|
if (Math.floor(val2) === val2)
|
|
253
253
|
return val2;
|
|
254
|
-
return
|
|
254
|
+
return $mol_fail(new $mol_data_error(`${val} is not an integer`));
|
|
255
255
|
}
|
|
256
256
|
$.$mol_data_integer = $mol_data_integer;
|
|
257
257
|
})($ || ($ = {}));
|
|
258
|
-
//integer.
|
|
258
|
+
//mol/data/integer/integer.ts
|
|
259
259
|
;
|
|
260
260
|
"use strict";
|
|
261
261
|
var $;
|
|
@@ -266,13 +266,13 @@ var $;
|
|
|
266
266
|
}
|
|
267
267
|
$.$mol_data_nominal = $mol_data_nominal;
|
|
268
268
|
})($ || ($ = {}));
|
|
269
|
-
//nominal.
|
|
269
|
+
//mol/data/nominal/nominal.ts
|
|
270
270
|
;
|
|
271
271
|
"use strict";
|
|
272
272
|
var $;
|
|
273
273
|
(function ($) {
|
|
274
274
|
function $mol_data_nullable(sub) {
|
|
275
|
-
return
|
|
275
|
+
return $mol_data_setup((val) => {
|
|
276
276
|
if (val === null)
|
|
277
277
|
return null;
|
|
278
278
|
return sub(val);
|
|
@@ -280,13 +280,13 @@ var $;
|
|
|
280
280
|
}
|
|
281
281
|
$.$mol_data_nullable = $mol_data_nullable;
|
|
282
282
|
})($ || ($ = {}));
|
|
283
|
-
//nullable.
|
|
283
|
+
//mol/data/nullable/nullable.ts
|
|
284
284
|
;
|
|
285
285
|
"use strict";
|
|
286
286
|
var $;
|
|
287
287
|
(function ($) {
|
|
288
288
|
function $mol_data_optional(sub, fallback) {
|
|
289
|
-
return
|
|
289
|
+
return $mol_data_setup((val) => {
|
|
290
290
|
if (val === undefined) {
|
|
291
291
|
return fallback?.();
|
|
292
292
|
}
|
|
@@ -295,32 +295,32 @@ var $;
|
|
|
295
295
|
}
|
|
296
296
|
$.$mol_data_optional = $mol_data_optional;
|
|
297
297
|
})($ || ($ = {}));
|
|
298
|
-
//optional.
|
|
298
|
+
//mol/data/optional/optional.ts
|
|
299
299
|
;
|
|
300
300
|
"use strict";
|
|
301
|
-
//equals.
|
|
301
|
+
//mol/type/equals/equals.ts
|
|
302
302
|
;
|
|
303
303
|
"use strict";
|
|
304
|
-
//merge.
|
|
304
|
+
//mol/type/merge/merge.ts
|
|
305
305
|
;
|
|
306
306
|
"use strict";
|
|
307
|
-
//undefined.
|
|
307
|
+
//mol/type/partial/undefined/undefined.ts
|
|
308
308
|
;
|
|
309
309
|
"use strict";
|
|
310
310
|
var $;
|
|
311
311
|
(function ($) {
|
|
312
312
|
function $mol_data_record(sub) {
|
|
313
|
-
return
|
|
313
|
+
return $mol_data_setup((val) => {
|
|
314
314
|
let res = {};
|
|
315
315
|
for (const field in sub) {
|
|
316
316
|
try {
|
|
317
317
|
res[field] = sub[field](val[field]);
|
|
318
318
|
}
|
|
319
319
|
catch (error) {
|
|
320
|
-
if (
|
|
321
|
-
return
|
|
320
|
+
if (error instanceof Promise)
|
|
321
|
+
return $mol_fail_hidden(error);
|
|
322
322
|
error.message = `[${JSON.stringify(field)}] ${error.message}`;
|
|
323
|
-
return
|
|
323
|
+
return $mol_fail(error);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
return res;
|
|
@@ -328,13 +328,13 @@ var $;
|
|
|
328
328
|
}
|
|
329
329
|
$.$mol_data_record = $mol_data_record;
|
|
330
330
|
})($ || ($ = {}));
|
|
331
|
-
//record.
|
|
331
|
+
//mol/data/record/record.ts
|
|
332
332
|
;
|
|
333
333
|
"use strict";
|
|
334
334
|
var $;
|
|
335
335
|
(function ($) {
|
|
336
336
|
function $mol_data_variant(...sub) {
|
|
337
|
-
return
|
|
337
|
+
return $mol_data_setup((val) => {
|
|
338
338
|
const errors = [];
|
|
339
339
|
for (const type of sub) {
|
|
340
340
|
let hidden = $.$mol_fail_hidden;
|
|
@@ -344,29 +344,29 @@ var $;
|
|
|
344
344
|
}
|
|
345
345
|
catch (error) {
|
|
346
346
|
$.$mol_fail = hidden;
|
|
347
|
-
if (error instanceof
|
|
347
|
+
if (error instanceof $mol_data_error) {
|
|
348
348
|
errors.push(error);
|
|
349
349
|
}
|
|
350
350
|
else {
|
|
351
|
-
return
|
|
351
|
+
return $mol_fail_hidden(error);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
return
|
|
355
|
+
return $mol_fail(new $mol_data_error(`${val} is not any of variants`, ...errors));
|
|
356
356
|
}, sub);
|
|
357
357
|
}
|
|
358
358
|
$.$mol_data_variant = $mol_data_variant;
|
|
359
359
|
})($ || ($ = {}));
|
|
360
|
-
//variant.
|
|
360
|
+
//mol/data/variant/variant.ts
|
|
361
361
|
;
|
|
362
362
|
"use strict";
|
|
363
|
-
//unary.
|
|
363
|
+
//mol/type/unary/unary.ts
|
|
364
364
|
;
|
|
365
365
|
"use strict";
|
|
366
|
-
//param.
|
|
366
|
+
//mol/type/param/param.ts
|
|
367
367
|
;
|
|
368
368
|
"use strict";
|
|
369
|
-
//tail.
|
|
369
|
+
//mol/type/tail/tail.ts
|
|
370
370
|
;
|
|
371
371
|
"use strict";
|
|
372
372
|
var $;
|
|
@@ -376,39 +376,39 @@ var $;
|
|
|
376
376
|
}
|
|
377
377
|
$.$mol_func_is_class = $mol_func_is_class;
|
|
378
378
|
})($ || ($ = {}));
|
|
379
|
-
//class.
|
|
379
|
+
//mol/func/is/class/class.ts
|
|
380
380
|
;
|
|
381
381
|
"use strict";
|
|
382
|
-
//result.
|
|
382
|
+
//mol/type/result/result.ts
|
|
383
383
|
;
|
|
384
384
|
"use strict";
|
|
385
|
-
//foot.
|
|
385
|
+
//mol/type/foot/foot.ts
|
|
386
386
|
;
|
|
387
387
|
"use strict";
|
|
388
388
|
var $;
|
|
389
389
|
(function ($) {
|
|
390
390
|
function $mol_data_pipe(...funcs) {
|
|
391
|
-
return
|
|
391
|
+
return $mol_data_setup(function (input) {
|
|
392
392
|
let value = input;
|
|
393
393
|
for (const func of funcs)
|
|
394
|
-
value =
|
|
394
|
+
value = $mol_func_is_class(func) ? new func(value) : func.call(this, value);
|
|
395
395
|
return value;
|
|
396
396
|
}, { funcs });
|
|
397
397
|
}
|
|
398
398
|
$.$mol_data_pipe = $mol_data_pipe;
|
|
399
399
|
})($ || ($ = {}));
|
|
400
|
-
//pipe.
|
|
400
|
+
//mol/data/pipe/pipe.ts
|
|
401
401
|
;
|
|
402
402
|
"use strict";
|
|
403
403
|
var $;
|
|
404
404
|
(function ($) {
|
|
405
405
|
function $mol_data_wrapper(pre, Obj) {
|
|
406
406
|
console.warn('$mol_data_wrapper is deparecated. Use $mol_data_pipe instead.');
|
|
407
|
-
return
|
|
407
|
+
return $mol_data_setup((val) => new Obj(pre(val)), { pre, Obj });
|
|
408
408
|
}
|
|
409
409
|
$.$mol_data_wrapper = $mol_data_wrapper;
|
|
410
410
|
})($ || ($ = {}));
|
|
411
|
-
//wrapper.
|
|
411
|
+
//mol/data/wrapper/wrapper.ts
|
|
412
412
|
;
|
|
413
413
|
"use strict";
|
|
414
414
|
var $;
|
|
@@ -418,7 +418,7 @@ var $;
|
|
|
418
418
|
}
|
|
419
419
|
$.$mol_test_complete = $mol_test_complete;
|
|
420
420
|
})($ || ($ = {}));
|
|
421
|
-
//test.node.test.
|
|
421
|
+
//mol/test/test.node.test.ts
|
|
422
422
|
;
|
|
423
423
|
"use strict";
|
|
424
424
|
var $;
|
|
@@ -436,12 +436,18 @@ var $;
|
|
|
436
436
|
$_1.$mol_test_all = [];
|
|
437
437
|
async function $mol_test_run() {
|
|
438
438
|
for (var test of $_1.$mol_test_all) {
|
|
439
|
-
let context = Object.create(
|
|
439
|
+
let context = Object.create($$);
|
|
440
440
|
for (let mock of $_1.$mol_test_mocks)
|
|
441
441
|
await mock(context);
|
|
442
|
-
|
|
442
|
+
const res = test(context);
|
|
443
|
+
if (res instanceof Promise) {
|
|
444
|
+
await new Promise((done, fail) => {
|
|
445
|
+
res.then(done, fail);
|
|
446
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
443
449
|
}
|
|
444
|
-
|
|
450
|
+
$$.$mol_log3_done({
|
|
445
451
|
place: '$mol_test',
|
|
446
452
|
message: 'All tests passed',
|
|
447
453
|
count: $_1.$mol_test_all.length,
|
|
@@ -459,7 +465,7 @@ var $;
|
|
|
459
465
|
await $mol_test_run();
|
|
460
466
|
}
|
|
461
467
|
finally {
|
|
462
|
-
|
|
468
|
+
$$.$mol_test_complete();
|
|
463
469
|
}
|
|
464
470
|
}, 0);
|
|
465
471
|
}
|
|
@@ -472,10 +478,10 @@ var $;
|
|
|
472
478
|
for (let api of forbidden) {
|
|
473
479
|
context[api] = new Proxy(function () { }, {
|
|
474
480
|
get() {
|
|
475
|
-
$
|
|
481
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
476
482
|
},
|
|
477
483
|
apply() {
|
|
478
|
-
$
|
|
484
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
479
485
|
},
|
|
480
486
|
});
|
|
481
487
|
}
|
|
@@ -503,16 +509,16 @@ var $;
|
|
|
503
509
|
},
|
|
504
510
|
});
|
|
505
511
|
})($ || ($ = {}));
|
|
506
|
-
//test.test.
|
|
512
|
+
//mol/test/test.test.ts
|
|
507
513
|
;
|
|
508
514
|
"use strict";
|
|
509
515
|
var $;
|
|
510
516
|
(function ($) {
|
|
511
517
|
})($ || ($ = {}));
|
|
512
|
-
//context.
|
|
518
|
+
//mol/dom/context/context.ts
|
|
513
519
|
;
|
|
514
520
|
"use strict";
|
|
515
|
-
//node.
|
|
521
|
+
//node/node.ts
|
|
516
522
|
;
|
|
517
523
|
"use strict";
|
|
518
524
|
var $node = new Proxy({ require }, {
|
|
@@ -551,14 +557,14 @@ var $node = new Proxy({ require }, {
|
|
|
551
557
|
require = (req => Object.assign(function require(name) {
|
|
552
558
|
return $node[name];
|
|
553
559
|
}, req))(require);
|
|
554
|
-
//node.node.
|
|
560
|
+
//node/node.node.ts
|
|
555
561
|
;
|
|
556
562
|
"use strict";
|
|
557
563
|
var $;
|
|
558
564
|
(function ($) {
|
|
559
565
|
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
560
566
|
})($ || ($ = {}));
|
|
561
|
-
//context.node.
|
|
567
|
+
//mol/dom/context/context.node.ts
|
|
562
568
|
;
|
|
563
569
|
"use strict";
|
|
564
570
|
var $;
|
|
@@ -569,7 +575,7 @@ var $;
|
|
|
569
575
|
for (let view of childNodes) {
|
|
570
576
|
if (view == null)
|
|
571
577
|
continue;
|
|
572
|
-
if (view instanceof
|
|
578
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
573
579
|
while (true) {
|
|
574
580
|
if (!nextNode) {
|
|
575
581
|
el.appendChild(view);
|
|
@@ -600,7 +606,7 @@ var $;
|
|
|
600
606
|
nextNode = nextNode.nextSibling;
|
|
601
607
|
}
|
|
602
608
|
else {
|
|
603
|
-
const textNode =
|
|
609
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
604
610
|
el.insertBefore(textNode, nextNode);
|
|
605
611
|
}
|
|
606
612
|
}
|
|
@@ -613,88 +619,88 @@ var $;
|
|
|
613
619
|
}
|
|
614
620
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
615
621
|
})($ || ($ = {}));
|
|
616
|
-
//children.
|
|
622
|
+
//mol/dom/render/children/children.ts
|
|
617
623
|
;
|
|
618
624
|
"use strict";
|
|
619
|
-
//error.
|
|
625
|
+
//mol/type/error/error.ts
|
|
620
626
|
;
|
|
621
627
|
"use strict";
|
|
622
|
-
//assert.test.
|
|
628
|
+
//mol/type/assert/assert.test.ts
|
|
623
629
|
;
|
|
624
630
|
"use strict";
|
|
625
|
-
//assert.
|
|
631
|
+
//mol/type/assert/assert.ts
|
|
626
632
|
;
|
|
627
633
|
"use strict";
|
|
628
|
-
//deep.test.
|
|
634
|
+
//mol/type/partial/deep/deep.test.ts
|
|
629
635
|
;
|
|
630
636
|
"use strict";
|
|
631
|
-
//deep.
|
|
637
|
+
//mol/type/partial/deep/deep.ts
|
|
632
638
|
;
|
|
633
639
|
"use strict";
|
|
634
640
|
var $;
|
|
635
641
|
(function ($) {
|
|
636
|
-
|
|
642
|
+
$mol_test({
|
|
637
643
|
'Make empty div'() {
|
|
638
|
-
|
|
644
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
639
645
|
},
|
|
640
646
|
'Define native field'() {
|
|
641
|
-
const dom =
|
|
642
|
-
|
|
643
|
-
|
|
647
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
648
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
649
|
+
$mol_assert_equal(dom.value, '123');
|
|
644
650
|
},
|
|
645
651
|
'Define classes'() {
|
|
646
|
-
const dom =
|
|
647
|
-
|
|
652
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
653
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
648
654
|
},
|
|
649
655
|
'Define styles'() {
|
|
650
|
-
const dom =
|
|
651
|
-
|
|
656
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
657
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
652
658
|
},
|
|
653
659
|
'Define dataset'() {
|
|
654
|
-
const dom =
|
|
655
|
-
|
|
660
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
661
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
656
662
|
},
|
|
657
663
|
'Define attributes'() {
|
|
658
|
-
const dom =
|
|
659
|
-
|
|
664
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
665
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
660
666
|
},
|
|
661
667
|
'Define child nodes'() {
|
|
662
|
-
const dom =
|
|
668
|
+
const dom = $mol_jsx("div", null,
|
|
663
669
|
"hello",
|
|
664
|
-
|
|
670
|
+
$mol_jsx("strong", null, "world"),
|
|
665
671
|
"!");
|
|
666
|
-
|
|
672
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
667
673
|
},
|
|
668
674
|
'Function as component'() {
|
|
669
675
|
const Button = ({ hint }, target) => {
|
|
670
|
-
return
|
|
676
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
671
677
|
};
|
|
672
|
-
const dom =
|
|
673
|
-
|
|
678
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
679
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
674
680
|
},
|
|
675
681
|
'Nested guid generation'() {
|
|
676
682
|
const Foo = () => {
|
|
677
|
-
return
|
|
678
|
-
|
|
679
|
-
|
|
683
|
+
return $mol_jsx("div", null,
|
|
684
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
685
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
680
686
|
};
|
|
681
687
|
const Bar = (props, icon) => {
|
|
682
|
-
return
|
|
688
|
+
return $mol_jsx("span", null, icon);
|
|
683
689
|
};
|
|
684
|
-
const dom =
|
|
685
|
-
|
|
690
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
691
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
686
692
|
},
|
|
687
693
|
'Fail on non unique ids'() {
|
|
688
694
|
const App = () => {
|
|
689
|
-
return
|
|
690
|
-
|
|
691
|
-
|
|
695
|
+
return $mol_jsx("div", null,
|
|
696
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
697
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
692
698
|
};
|
|
693
|
-
|
|
699
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
694
700
|
},
|
|
695
701
|
});
|
|
696
702
|
})($ || ($ = {}));
|
|
697
|
-
//jsx.test.
|
|
703
|
+
//mol/jsx/jsx.test.tsx
|
|
698
704
|
;
|
|
699
705
|
"use strict";
|
|
700
706
|
var $;
|
|
@@ -703,15 +709,15 @@ var $;
|
|
|
703
709
|
$.$mol_jsx_booked = null;
|
|
704
710
|
$.$mol_jsx_document = {
|
|
705
711
|
getElementById: () => null,
|
|
706
|
-
createElementNS: (space, name) =>
|
|
707
|
-
createDocumentFragment: () =>
|
|
712
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
713
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
708
714
|
};
|
|
709
715
|
$.$mol_jsx_frag = '';
|
|
710
716
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
711
717
|
const id = props && props.id || '';
|
|
712
718
|
if (Elem && $.$mol_jsx_booked) {
|
|
713
719
|
if ($.$mol_jsx_booked.has(id)) {
|
|
714
|
-
|
|
720
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
715
721
|
}
|
|
716
722
|
else {
|
|
717
723
|
$.$mol_jsx_booked.add(id);
|
|
@@ -750,7 +756,7 @@ var $;
|
|
|
750
756
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
751
757
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
752
758
|
}
|
|
753
|
-
|
|
759
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
754
760
|
if (!Elem)
|
|
755
761
|
return node;
|
|
756
762
|
for (const key in props) {
|
|
@@ -776,77 +782,77 @@ var $;
|
|
|
776
782
|
}
|
|
777
783
|
$.$mol_jsx = $mol_jsx;
|
|
778
784
|
})($ || ($ = {}));
|
|
779
|
-
//jsx.
|
|
785
|
+
//mol/jsx/jsx.ts
|
|
780
786
|
;
|
|
781
787
|
"use strict";
|
|
782
788
|
var $;
|
|
783
789
|
(function ($) {
|
|
784
|
-
|
|
790
|
+
$mol_test({
|
|
785
791
|
'nulls & undefineds'() {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
792
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
793
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
794
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
795
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
790
796
|
},
|
|
791
797
|
'number'() {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
798
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
799
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
800
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
801
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
802
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
797
803
|
},
|
|
798
804
|
'POJO'() {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
806
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
807
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
808
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
809
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
810
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
805
811
|
},
|
|
806
812
|
'Array'() {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
813
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
814
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
815
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
816
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
811
817
|
},
|
|
812
818
|
'Non POJO are different'() {
|
|
813
819
|
class Thing extends Object {
|
|
814
820
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
821
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
822
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
823
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
818
824
|
},
|
|
819
825
|
'same POJOs with cyclic reference'() {
|
|
820
826
|
const a = { foo: {} };
|
|
821
827
|
a['self'] = a;
|
|
822
828
|
const b = { foo: {} };
|
|
823
829
|
b['self'] = b;
|
|
824
|
-
|
|
830
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
825
831
|
},
|
|
826
832
|
'Date'() {
|
|
827
|
-
|
|
828
|
-
|
|
833
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
834
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
829
835
|
},
|
|
830
836
|
'RegExp'() {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
837
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
838
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
839
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
834
840
|
},
|
|
835
841
|
'Map'() {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
842
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
843
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
844
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
845
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
840
846
|
},
|
|
841
847
|
'Set'() {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
848
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
849
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
850
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
845
851
|
},
|
|
846
852
|
'Uint8Array'() {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
853
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
854
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
855
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
850
856
|
},
|
|
851
857
|
'Custom comparator'() {
|
|
852
858
|
class User {
|
|
@@ -860,17 +866,17 @@ var $;
|
|
|
860
866
|
return this.name;
|
|
861
867
|
}
|
|
862
868
|
}
|
|
863
|
-
|
|
864
|
-
|
|
869
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
870
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
865
871
|
},
|
|
866
872
|
});
|
|
867
873
|
})($ || ($ = {}));
|
|
868
|
-
//deep.test.
|
|
874
|
+
//mol/compare/deep/deep.test.tsx
|
|
869
875
|
;
|
|
870
876
|
"use strict";
|
|
871
877
|
var $;
|
|
872
878
|
(function ($) {
|
|
873
|
-
|
|
879
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
874
880
|
function $mol_compare_deep(left, right) {
|
|
875
881
|
if (Object.is(left, right))
|
|
876
882
|
return true;
|
|
@@ -896,7 +902,7 @@ var $;
|
|
|
896
902
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
897
903
|
if (left instanceof RegExp)
|
|
898
904
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
899
|
-
let left_cache =
|
|
905
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
900
906
|
if (left_cache) {
|
|
901
907
|
const right_cache = left_cache.get(right);
|
|
902
908
|
if (typeof right_cache === 'boolean')
|
|
@@ -904,7 +910,7 @@ var $;
|
|
|
904
910
|
}
|
|
905
911
|
else {
|
|
906
912
|
left_cache = new WeakMap([[right, true]]);
|
|
907
|
-
|
|
913
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
908
914
|
}
|
|
909
915
|
let result;
|
|
910
916
|
try {
|
|
@@ -988,50 +994,50 @@ var $;
|
|
|
988
994
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
989
995
|
}
|
|
990
996
|
})($ || ($ = {}));
|
|
991
|
-
//deep.
|
|
997
|
+
//mol/compare/deep/deep.ts
|
|
992
998
|
;
|
|
993
999
|
"use strict";
|
|
994
1000
|
var $;
|
|
995
1001
|
(function ($) {
|
|
996
1002
|
function $mol_dom_serialize(node) {
|
|
997
|
-
const serializer = new
|
|
1003
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
998
1004
|
return serializer.serializeToString(node);
|
|
999
1005
|
}
|
|
1000
1006
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
1001
1007
|
})($ || ($ = {}));
|
|
1002
|
-
//serialize.
|
|
1008
|
+
//mol/dom/serialize/serialize.ts
|
|
1003
1009
|
;
|
|
1004
1010
|
"use strict";
|
|
1005
1011
|
var $;
|
|
1006
1012
|
(function ($) {
|
|
1007
|
-
|
|
1013
|
+
$mol_test({
|
|
1008
1014
|
'must be false'() {
|
|
1009
|
-
|
|
1015
|
+
$mol_assert_not(0);
|
|
1010
1016
|
},
|
|
1011
1017
|
'must be true'() {
|
|
1012
|
-
|
|
1018
|
+
$mol_assert_ok(1);
|
|
1013
1019
|
},
|
|
1014
1020
|
'two must be equal'() {
|
|
1015
|
-
|
|
1021
|
+
$mol_assert_equal(2, 2);
|
|
1016
1022
|
},
|
|
1017
1023
|
'three must be equal'() {
|
|
1018
|
-
|
|
1024
|
+
$mol_assert_equal(2, 2, 2);
|
|
1019
1025
|
},
|
|
1020
1026
|
'two must be unique'() {
|
|
1021
|
-
|
|
1027
|
+
$mol_assert_unique([3], [3]);
|
|
1022
1028
|
},
|
|
1023
1029
|
'three must be unique'() {
|
|
1024
|
-
|
|
1030
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1025
1031
|
},
|
|
1026
1032
|
'two must be alike'() {
|
|
1027
|
-
|
|
1033
|
+
$mol_assert_like([3], [3]);
|
|
1028
1034
|
},
|
|
1029
1035
|
'three must be alike'() {
|
|
1030
|
-
|
|
1036
|
+
$mol_assert_like([3], [3], [3]);
|
|
1031
1037
|
},
|
|
1032
1038
|
});
|
|
1033
1039
|
})($ || ($ = {}));
|
|
1034
|
-
//assert.test.
|
|
1040
|
+
//mol/assert/assert.test.ts
|
|
1035
1041
|
;
|
|
1036
1042
|
"use strict";
|
|
1037
1043
|
var $;
|
|
@@ -1039,13 +1045,13 @@ var $;
|
|
|
1039
1045
|
function $mol_assert_ok(value) {
|
|
1040
1046
|
if (value)
|
|
1041
1047
|
return;
|
|
1042
|
-
|
|
1048
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
1043
1049
|
}
|
|
1044
1050
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
1045
1051
|
function $mol_assert_not(value) {
|
|
1046
1052
|
if (!value)
|
|
1047
1053
|
return;
|
|
1048
|
-
|
|
1054
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
1049
1055
|
}
|
|
1050
1056
|
$.$mol_assert_not = $mol_assert_not;
|
|
1051
1057
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -1069,7 +1075,7 @@ var $;
|
|
|
1069
1075
|
finally {
|
|
1070
1076
|
$.$mol_fail = fail;
|
|
1071
1077
|
}
|
|
1072
|
-
|
|
1078
|
+
$mol_fail(new Error('Not failed'));
|
|
1073
1079
|
}
|
|
1074
1080
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
1075
1081
|
function $mol_assert_equal(...args) {
|
|
@@ -1080,7 +1086,7 @@ var $;
|
|
|
1080
1086
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
1081
1087
|
continue;
|
|
1082
1088
|
if (args[i] !== args[j])
|
|
1083
|
-
|
|
1089
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
1084
1090
|
}
|
|
1085
1091
|
}
|
|
1086
1092
|
}
|
|
@@ -1091,7 +1097,7 @@ var $;
|
|
|
1091
1097
|
if (i === j)
|
|
1092
1098
|
continue;
|
|
1093
1099
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
1094
|
-
|
|
1100
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
1095
1101
|
}
|
|
1096
1102
|
}
|
|
1097
1103
|
}
|
|
@@ -1099,7 +1105,7 @@ var $;
|
|
|
1099
1105
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1100
1106
|
function $mol_assert_like(head, ...tail) {
|
|
1101
1107
|
for (let [index, value] of Object.entries(tail)) {
|
|
1102
|
-
if (
|
|
1108
|
+
if (!$mol_compare_deep(value, head)) {
|
|
1103
1109
|
const print = (val) => {
|
|
1104
1110
|
if (!val)
|
|
1105
1111
|
return val;
|
|
@@ -1115,217 +1121,217 @@ var $;
|
|
|
1115
1121
|
return val;
|
|
1116
1122
|
}
|
|
1117
1123
|
};
|
|
1118
|
-
return
|
|
1124
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
1119
1125
|
}
|
|
1120
1126
|
}
|
|
1121
1127
|
}
|
|
1122
1128
|
$.$mol_assert_like = $mol_assert_like;
|
|
1123
1129
|
function $mol_assert_dom(left, right) {
|
|
1124
|
-
$mol_assert_equal(
|
|
1130
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
1125
1131
|
}
|
|
1126
1132
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
1127
1133
|
})($ || ($ = {}));
|
|
1128
|
-
//assert.
|
|
1134
|
+
//mol/assert/assert.ts
|
|
1129
1135
|
;
|
|
1130
1136
|
"use strict";
|
|
1131
1137
|
var $;
|
|
1132
1138
|
(function ($) {
|
|
1133
|
-
|
|
1139
|
+
$mol_test({
|
|
1134
1140
|
'equal paths'() {
|
|
1135
|
-
const diff =
|
|
1136
|
-
|
|
1141
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
1142
|
+
$mol_assert_like(diff, {
|
|
1137
1143
|
prefix: [1, 2, 3, 4],
|
|
1138
1144
|
suffix: [[], [], []],
|
|
1139
1145
|
});
|
|
1140
1146
|
},
|
|
1141
1147
|
'different suffix'() {
|
|
1142
|
-
const diff =
|
|
1143
|
-
|
|
1148
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
1149
|
+
$mol_assert_like(diff, {
|
|
1144
1150
|
prefix: [1, 2],
|
|
1145
1151
|
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
1146
1152
|
});
|
|
1147
1153
|
},
|
|
1148
1154
|
'one contains other'() {
|
|
1149
|
-
const diff =
|
|
1150
|
-
|
|
1155
|
+
const diff = $mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
1156
|
+
$mol_assert_like(diff, {
|
|
1151
1157
|
prefix: [1, 2],
|
|
1152
1158
|
suffix: [[3, 4], [], [3]],
|
|
1153
1159
|
});
|
|
1154
1160
|
},
|
|
1155
1161
|
'fully different'() {
|
|
1156
|
-
const diff =
|
|
1157
|
-
|
|
1162
|
+
const diff = $mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
1163
|
+
$mol_assert_like(diff, {
|
|
1158
1164
|
prefix: [],
|
|
1159
1165
|
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
1160
1166
|
});
|
|
1161
1167
|
},
|
|
1162
1168
|
});
|
|
1163
1169
|
})($ || ($ = {}));
|
|
1164
|
-
//path.test.
|
|
1170
|
+
//mol/diff/path/path.test.ts
|
|
1165
1171
|
;
|
|
1166
1172
|
"use strict";
|
|
1167
1173
|
var $;
|
|
1168
1174
|
(function ($) {
|
|
1169
|
-
|
|
1175
|
+
$mol_test({
|
|
1170
1176
|
'Is number'() {
|
|
1171
|
-
|
|
1177
|
+
$mol_data_number(0);
|
|
1172
1178
|
},
|
|
1173
1179
|
'Is not number'() {
|
|
1174
|
-
|
|
1175
|
-
|
|
1180
|
+
$mol_assert_fail(() => {
|
|
1181
|
+
$mol_data_number('x');
|
|
1176
1182
|
}, 'x is not a number');
|
|
1177
1183
|
},
|
|
1178
1184
|
'Is object number'() {
|
|
1179
|
-
|
|
1180
|
-
|
|
1185
|
+
$mol_assert_fail(() => {
|
|
1186
|
+
$mol_data_number(new Number(''));
|
|
1181
1187
|
}, '0 is not a number');
|
|
1182
1188
|
},
|
|
1183
1189
|
});
|
|
1184
1190
|
})($ || ($ = {}));
|
|
1185
|
-
//number.test.
|
|
1191
|
+
//mol/data/number/number.test.ts
|
|
1186
1192
|
;
|
|
1187
1193
|
"use strict";
|
|
1188
1194
|
var $;
|
|
1189
1195
|
(function ($) {
|
|
1190
|
-
|
|
1196
|
+
$mol_test({
|
|
1191
1197
|
'config by value'() {
|
|
1192
|
-
const N =
|
|
1193
|
-
|
|
1198
|
+
const N = $mol_data_setup((a) => a, 5);
|
|
1199
|
+
$mol_assert_equal(N.config, 5);
|
|
1194
1200
|
},
|
|
1195
1201
|
});
|
|
1196
1202
|
})($ || ($ = {}));
|
|
1197
|
-
//setup.test.
|
|
1203
|
+
//mol/data/setup/setup.test.ts
|
|
1198
1204
|
;
|
|
1199
1205
|
"use strict";
|
|
1200
1206
|
var $;
|
|
1201
1207
|
(function ($) {
|
|
1202
|
-
|
|
1208
|
+
$mol_test({
|
|
1203
1209
|
'Is empty array'() {
|
|
1204
|
-
|
|
1210
|
+
$mol_data_array($mol_data_number)([]);
|
|
1205
1211
|
},
|
|
1206
1212
|
'Is array'() {
|
|
1207
|
-
|
|
1213
|
+
$mol_data_array($mol_data_number)([1, 2]);
|
|
1208
1214
|
},
|
|
1209
1215
|
'Is not array'() {
|
|
1210
|
-
|
|
1211
|
-
|
|
1216
|
+
$mol_assert_fail(() => {
|
|
1217
|
+
$mol_data_array($mol_data_number)({ [0]: 1, length: 1, map: () => { } });
|
|
1212
1218
|
}, '[object Object] is not an array');
|
|
1213
1219
|
},
|
|
1214
1220
|
'Has wrong item'() {
|
|
1215
|
-
|
|
1216
|
-
|
|
1221
|
+
$mol_assert_fail(() => {
|
|
1222
|
+
$mol_data_array($mol_data_number)([1, '1']);
|
|
1217
1223
|
}, '[1] 1 is not a number');
|
|
1218
1224
|
},
|
|
1219
1225
|
'Has wrong deep item'() {
|
|
1220
|
-
|
|
1221
|
-
|
|
1226
|
+
$mol_assert_fail(() => {
|
|
1227
|
+
$mol_data_array($mol_data_array($mol_data_number))([[], [0, 0, false]]);
|
|
1222
1228
|
}, '[1] [2] false is not a number');
|
|
1223
1229
|
},
|
|
1224
1230
|
});
|
|
1225
1231
|
})($ || ($ = {}));
|
|
1226
|
-
//array.test.
|
|
1232
|
+
//mol/data/array/array.test.ts
|
|
1227
1233
|
;
|
|
1228
1234
|
"use strict";
|
|
1229
1235
|
var $;
|
|
1230
1236
|
(function ($) {
|
|
1231
|
-
|
|
1237
|
+
$mol_test({
|
|
1232
1238
|
'Is boolean - true'() {
|
|
1233
|
-
|
|
1239
|
+
$mol_data_boolean(true);
|
|
1234
1240
|
},
|
|
1235
1241
|
'Is boolean - false'() {
|
|
1236
|
-
|
|
1242
|
+
$mol_data_boolean(false);
|
|
1237
1243
|
},
|
|
1238
1244
|
'Is not boolean'() {
|
|
1239
|
-
|
|
1240
|
-
|
|
1245
|
+
$mol_assert_fail(() => {
|
|
1246
|
+
$mol_data_boolean('x');
|
|
1241
1247
|
}, 'x is not a boolean');
|
|
1242
1248
|
},
|
|
1243
1249
|
'Is object boolean'() {
|
|
1244
|
-
|
|
1245
|
-
|
|
1250
|
+
$mol_assert_fail(() => {
|
|
1251
|
+
$mol_data_boolean(new Boolean(''));
|
|
1246
1252
|
}, 'false is not a boolean');
|
|
1247
1253
|
},
|
|
1248
1254
|
});
|
|
1249
1255
|
})($ || ($ = {}));
|
|
1250
|
-
//boolean.test.
|
|
1256
|
+
//mol/data/boolean/boolean.test.ts
|
|
1251
1257
|
;
|
|
1252
1258
|
"use strict";
|
|
1253
1259
|
var $;
|
|
1254
1260
|
(function ($) {
|
|
1255
|
-
|
|
1261
|
+
$mol_test({
|
|
1256
1262
|
'is same number'() {
|
|
1257
|
-
|
|
1263
|
+
$mol_data_const(Number.NaN)(Number.NaN);
|
|
1258
1264
|
},
|
|
1259
1265
|
'is different number'() {
|
|
1260
|
-
const Five =
|
|
1261
|
-
|
|
1266
|
+
const Five = $mol_data_const(5);
|
|
1267
|
+
$mol_assert_fail(() => Five(6), '6 is not 5');
|
|
1262
1268
|
},
|
|
1263
1269
|
});
|
|
1264
1270
|
})($ || ($ = {}));
|
|
1265
|
-
//const.test.
|
|
1271
|
+
//mol/data/const/const.test.ts
|
|
1266
1272
|
;
|
|
1267
1273
|
"use strict";
|
|
1268
1274
|
var $;
|
|
1269
1275
|
(function ($) {
|
|
1270
|
-
|
|
1276
|
+
$mol_test({
|
|
1271
1277
|
'Is string'() {
|
|
1272
|
-
|
|
1278
|
+
$mol_data_string('');
|
|
1273
1279
|
},
|
|
1274
1280
|
'Is not string'() {
|
|
1275
|
-
|
|
1276
|
-
|
|
1281
|
+
$mol_assert_fail(() => {
|
|
1282
|
+
$mol_data_string(0);
|
|
1277
1283
|
}, '0 is not a string');
|
|
1278
1284
|
},
|
|
1279
1285
|
'Is object string'() {
|
|
1280
|
-
|
|
1281
|
-
|
|
1286
|
+
$mol_assert_fail(() => {
|
|
1287
|
+
$mol_data_string(new String('x'));
|
|
1282
1288
|
}, 'x is not a string');
|
|
1283
1289
|
},
|
|
1284
1290
|
});
|
|
1285
1291
|
})($ || ($ = {}));
|
|
1286
|
-
//string.test.
|
|
1292
|
+
//mol/data/string/string.test.ts
|
|
1287
1293
|
;
|
|
1288
1294
|
"use strict";
|
|
1289
1295
|
var $;
|
|
1290
1296
|
(function ($) {
|
|
1291
|
-
|
|
1297
|
+
$mol_test({
|
|
1292
1298
|
'Is fit'() {
|
|
1293
|
-
|
|
1299
|
+
$mol_data_pattern(/^-$/)('-');
|
|
1294
1300
|
},
|
|
1295
1301
|
'Is not fit'() {
|
|
1296
|
-
|
|
1297
|
-
|
|
1302
|
+
$mol_assert_fail(() => {
|
|
1303
|
+
$mol_data_pattern(/^-$/)('+');
|
|
1298
1304
|
}, '+ is not a /^-$/');
|
|
1299
1305
|
},
|
|
1300
1306
|
});
|
|
1301
1307
|
})($ || ($ = {}));
|
|
1302
|
-
//pattern.test.
|
|
1308
|
+
//mol/data/pattern/pattern.test.ts
|
|
1303
1309
|
;
|
|
1304
1310
|
"use strict";
|
|
1305
1311
|
var $;
|
|
1306
1312
|
(function ($) {
|
|
1307
|
-
|
|
1313
|
+
$mol_test({
|
|
1308
1314
|
'Is email'() {
|
|
1309
|
-
|
|
1315
|
+
$mol_data_email('foo@bar');
|
|
1310
1316
|
},
|
|
1311
1317
|
'Has not host'() {
|
|
1312
|
-
|
|
1313
|
-
|
|
1318
|
+
$mol_assert_fail(() => {
|
|
1319
|
+
$mol_data_email('foo@');
|
|
1314
1320
|
}, 'foo@ is not a /.+@.+/');
|
|
1315
1321
|
},
|
|
1316
1322
|
'Has not name'() {
|
|
1317
|
-
|
|
1318
|
-
|
|
1323
|
+
$mol_assert_fail(() => {
|
|
1324
|
+
$mol_data_email('@bar');
|
|
1319
1325
|
}, '@bar is not a /.+@.+/');
|
|
1320
1326
|
},
|
|
1321
1327
|
'Has not @'() {
|
|
1322
|
-
|
|
1323
|
-
|
|
1328
|
+
$mol_assert_fail(() => {
|
|
1329
|
+
$mol_data_email('foo.bar');
|
|
1324
1330
|
}, 'foo.bar is not a /.+@.+/');
|
|
1325
1331
|
},
|
|
1326
1332
|
});
|
|
1327
1333
|
})($ || ($ = {}));
|
|
1328
|
-
//email.test.
|
|
1334
|
+
//mol/data/email/email.test.ts
|
|
1329
1335
|
;
|
|
1330
1336
|
"use strict";
|
|
1331
1337
|
var $;
|
|
@@ -1335,28 +1341,28 @@ var $;
|
|
|
1335
1341
|
sex[sex["male"] = 0] = "male";
|
|
1336
1342
|
sex[sex["female"] = 1] = "female";
|
|
1337
1343
|
})(sex || (sex = {}));
|
|
1338
|
-
const Sex =
|
|
1339
|
-
|
|
1344
|
+
const Sex = $mol_data_enum('sex', sex);
|
|
1345
|
+
$mol_test({
|
|
1340
1346
|
'config of enum'() {
|
|
1341
|
-
|
|
1347
|
+
$mol_assert_like(Sex.config, {
|
|
1342
1348
|
name: 'sex',
|
|
1343
1349
|
dict: sex,
|
|
1344
1350
|
});
|
|
1345
1351
|
},
|
|
1346
1352
|
'name of enum'() {
|
|
1347
|
-
|
|
1353
|
+
$mol_assert_equal(Sex.config.name, 'sex');
|
|
1348
1354
|
},
|
|
1349
1355
|
'Is right value of enum'() {
|
|
1350
|
-
|
|
1356
|
+
$mol_assert_equal(Sex(0), sex.male);
|
|
1351
1357
|
},
|
|
1352
1358
|
'Is wrong value of enum'() {
|
|
1353
|
-
|
|
1359
|
+
$mol_assert_fail(() => Sex(2), `2 is not value of sex enum`);
|
|
1354
1360
|
},
|
|
1355
1361
|
'Is name instead of value'() {
|
|
1356
|
-
|
|
1362
|
+
$mol_assert_fail(() => Sex('male'), `male is not value of sex enum`);
|
|
1357
1363
|
},
|
|
1358
1364
|
'Is common object field'() {
|
|
1359
|
-
|
|
1365
|
+
$mol_assert_fail(() => Sex('__proto__'), `__proto__ is not value of sex enum`);
|
|
1360
1366
|
},
|
|
1361
1367
|
});
|
|
1362
1368
|
let gender;
|
|
@@ -1364,187 +1370,187 @@ var $;
|
|
|
1364
1370
|
gender["bisexual"] = "bisexual";
|
|
1365
1371
|
gender["trans"] = "transgender";
|
|
1366
1372
|
})(gender || (gender = {}));
|
|
1367
|
-
const Gender =
|
|
1368
|
-
|
|
1373
|
+
const Gender = $mol_data_enum('gender', gender);
|
|
1374
|
+
$mol_test({
|
|
1369
1375
|
'config of enum'() {
|
|
1370
|
-
|
|
1376
|
+
$mol_assert_like(Gender.config, {
|
|
1371
1377
|
name: 'gender',
|
|
1372
1378
|
dict: gender,
|
|
1373
1379
|
});
|
|
1374
1380
|
},
|
|
1375
1381
|
'Is right value of enum'() {
|
|
1376
|
-
|
|
1382
|
+
$mol_assert_equal(Gender('transgender'), gender.trans);
|
|
1377
1383
|
},
|
|
1378
1384
|
'Is wrong value of enum'() {
|
|
1379
|
-
|
|
1385
|
+
$mol_assert_fail(() => Gender('xxx'), `xxx is not value of gender enum`);
|
|
1380
1386
|
},
|
|
1381
1387
|
'Is name instead of value'() {
|
|
1382
|
-
|
|
1388
|
+
$mol_assert_fail(() => Gender('trans'), `trans is not value of gender enum`);
|
|
1383
1389
|
},
|
|
1384
1390
|
'Is common object field'() {
|
|
1385
|
-
|
|
1391
|
+
$mol_assert_fail(() => Gender('__proto__'), `__proto__ is not value of gender enum`);
|
|
1386
1392
|
},
|
|
1387
1393
|
});
|
|
1388
1394
|
})($ || ($ = {}));
|
|
1389
|
-
//enum.test.
|
|
1395
|
+
//mol/data/enum/enum.test.ts
|
|
1390
1396
|
;
|
|
1391
1397
|
"use strict";
|
|
1392
1398
|
var $;
|
|
1393
1399
|
(function ($) {
|
|
1394
|
-
|
|
1400
|
+
$mol_test({
|
|
1395
1401
|
'Is same class'() {
|
|
1396
|
-
|
|
1402
|
+
$mol_data_instance(Date)(new Date);
|
|
1397
1403
|
},
|
|
1398
1404
|
'Is sub class'() {
|
|
1399
|
-
|
|
1405
|
+
$mol_data_instance(Object)(new Date);
|
|
1400
1406
|
},
|
|
1401
1407
|
'Is super class'() {
|
|
1402
|
-
|
|
1403
|
-
|
|
1408
|
+
$mol_assert_fail(() => {
|
|
1409
|
+
$mol_data_instance(Date)(new Object);
|
|
1404
1410
|
}, '[object Object] is not a Date');
|
|
1405
1411
|
},
|
|
1406
1412
|
'Is another class'() {
|
|
1407
|
-
|
|
1408
|
-
|
|
1413
|
+
$mol_assert_fail(() => {
|
|
1414
|
+
$mol_data_instance(Date)(new Array);
|
|
1409
1415
|
}, ' is not a Date');
|
|
1410
1416
|
},
|
|
1411
1417
|
'Is not object'() {
|
|
1412
|
-
|
|
1413
|
-
|
|
1418
|
+
$mol_assert_fail(() => {
|
|
1419
|
+
$mol_data_instance(Date)(null);
|
|
1414
1420
|
}, 'null is not a Date');
|
|
1415
1421
|
},
|
|
1416
1422
|
});
|
|
1417
1423
|
})($ || ($ = {}));
|
|
1418
|
-
//instance.test.
|
|
1424
|
+
//mol/data/instance/instance.test.ts
|
|
1419
1425
|
;
|
|
1420
1426
|
"use strict";
|
|
1421
1427
|
var $;
|
|
1422
1428
|
(function ($) {
|
|
1423
|
-
|
|
1429
|
+
$mol_test({
|
|
1424
1430
|
'Is integer'() {
|
|
1425
|
-
|
|
1431
|
+
$mol_data_integer(0);
|
|
1426
1432
|
},
|
|
1427
1433
|
'Is float'() {
|
|
1428
|
-
|
|
1429
|
-
|
|
1434
|
+
$mol_assert_fail(() => {
|
|
1435
|
+
$mol_data_integer(1.1);
|
|
1430
1436
|
}, '1.1 is not an integer');
|
|
1431
1437
|
},
|
|
1432
1438
|
});
|
|
1433
1439
|
})($ || ($ = {}));
|
|
1434
|
-
//integer.test.
|
|
1440
|
+
//mol/data/integer/integer.test.ts
|
|
1435
1441
|
;
|
|
1436
1442
|
"use strict";
|
|
1437
1443
|
var $;
|
|
1438
1444
|
(function ($) {
|
|
1439
|
-
|
|
1445
|
+
$mol_test({
|
|
1440
1446
|
'Nominal typing'() {
|
|
1441
|
-
const Weight =
|
|
1442
|
-
const Length =
|
|
1447
|
+
const Weight = $mol_data_nominal({ Weight: $mol_data_integer });
|
|
1448
|
+
const Length = $mol_data_nominal({ Length: $mol_data_integer });
|
|
1443
1449
|
let len = Length(10);
|
|
1444
1450
|
len = Length(20);
|
|
1445
1451
|
len = 20;
|
|
1446
1452
|
},
|
|
1447
1453
|
});
|
|
1448
1454
|
})($ || ($ = {}));
|
|
1449
|
-
//nominal.test.
|
|
1455
|
+
//mol/data/nominal/nominal.test.ts
|
|
1450
1456
|
;
|
|
1451
1457
|
"use strict";
|
|
1452
1458
|
var $;
|
|
1453
1459
|
(function ($) {
|
|
1454
|
-
|
|
1460
|
+
$mol_test({
|
|
1455
1461
|
'Is null'() {
|
|
1456
|
-
|
|
1462
|
+
$mol_data_nullable($mol_data_number)(null);
|
|
1457
1463
|
},
|
|
1458
1464
|
'Is not null'() {
|
|
1459
|
-
|
|
1465
|
+
$mol_data_nullable($mol_data_number)(0);
|
|
1460
1466
|
},
|
|
1461
1467
|
'Is undefined'() {
|
|
1462
|
-
|
|
1463
|
-
const Type =
|
|
1468
|
+
$mol_assert_fail(() => {
|
|
1469
|
+
const Type = $mol_data_nullable($mol_data_number);
|
|
1464
1470
|
Type(undefined);
|
|
1465
1471
|
}, 'undefined is not a number');
|
|
1466
1472
|
},
|
|
1467
1473
|
});
|
|
1468
1474
|
})($ || ($ = {}));
|
|
1469
|
-
//nullable.test.
|
|
1475
|
+
//mol/data/nullable/nullable.test.ts
|
|
1470
1476
|
;
|
|
1471
1477
|
"use strict";
|
|
1472
1478
|
var $;
|
|
1473
1479
|
(function ($) {
|
|
1474
|
-
const Age =
|
|
1475
|
-
const Age_or_zero =
|
|
1476
|
-
|
|
1480
|
+
const Age = $mol_data_optional($mol_data_number);
|
|
1481
|
+
const Age_or_zero = $mol_data_optional($mol_data_number, () => 0);
|
|
1482
|
+
$mol_test({
|
|
1477
1483
|
'Is not present'() {
|
|
1478
|
-
|
|
1484
|
+
$mol_assert_equal(Age(undefined), undefined);
|
|
1479
1485
|
},
|
|
1480
1486
|
'Is present'() {
|
|
1481
|
-
|
|
1487
|
+
$mol_assert_equal(Age(0), 0);
|
|
1482
1488
|
},
|
|
1483
1489
|
'Fallbacked'() {
|
|
1484
|
-
|
|
1490
|
+
$mol_assert_equal(Age_or_zero(undefined), 0);
|
|
1485
1491
|
},
|
|
1486
1492
|
'Is null'() {
|
|
1487
|
-
|
|
1493
|
+
$mol_assert_fail(() => Age(null), 'null is not a number');
|
|
1488
1494
|
},
|
|
1489
1495
|
});
|
|
1490
1496
|
})($ || ($ = {}));
|
|
1491
|
-
//optional.test.
|
|
1497
|
+
//mol/data/optional/optional.test.ts
|
|
1492
1498
|
;
|
|
1493
1499
|
"use strict";
|
|
1494
|
-
//equals.test.
|
|
1500
|
+
//mol/type/equals/equals.test.ts
|
|
1495
1501
|
;
|
|
1496
1502
|
"use strict";
|
|
1497
|
-
//merge.test.
|
|
1503
|
+
//mol/type/merge/merge.test.ts
|
|
1498
1504
|
;
|
|
1499
1505
|
"use strict";
|
|
1500
|
-
//undefined.test.
|
|
1506
|
+
//mol/type/partial/undefined/undefined.test.ts
|
|
1501
1507
|
;
|
|
1502
1508
|
"use strict";
|
|
1503
1509
|
var $;
|
|
1504
1510
|
(function ($) {
|
|
1505
|
-
|
|
1511
|
+
$mol_test({
|
|
1506
1512
|
'Fit to record'() {
|
|
1507
|
-
const User =
|
|
1513
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
1508
1514
|
User({ age: 0 });
|
|
1509
1515
|
},
|
|
1510
1516
|
'Extends record'() {
|
|
1511
|
-
const User =
|
|
1517
|
+
const User = $mol_data_record({ age: $mol_data_number });
|
|
1512
1518
|
User({ age: 0, name: 'Jin' });
|
|
1513
1519
|
},
|
|
1514
1520
|
'Shrinks record'() {
|
|
1515
|
-
|
|
1516
|
-
const User =
|
|
1521
|
+
$mol_assert_fail(() => {
|
|
1522
|
+
const User = $mol_data_record({ age: $mol_data_number, name: $mol_data_string });
|
|
1517
1523
|
User({ age: 0 });
|
|
1518
1524
|
}, '["name"] undefined is not a string');
|
|
1519
1525
|
},
|
|
1520
1526
|
'Shrinks deep record'() {
|
|
1521
|
-
|
|
1522
|
-
const User =
|
|
1527
|
+
$mol_assert_fail(() => {
|
|
1528
|
+
const User = $mol_data_record({ wife: $mol_data_record({ age: $mol_data_number }) });
|
|
1523
1529
|
User({ wife: {} });
|
|
1524
1530
|
}, '["wife"] ["age"] undefined is not a number');
|
|
1525
1531
|
},
|
|
1526
1532
|
});
|
|
1527
1533
|
})($ || ($ = {}));
|
|
1528
|
-
//record.test.
|
|
1534
|
+
//mol/data/record/record.test.ts
|
|
1529
1535
|
;
|
|
1530
1536
|
"use strict";
|
|
1531
1537
|
var $;
|
|
1532
1538
|
(function ($) {
|
|
1533
|
-
|
|
1539
|
+
$mol_test({
|
|
1534
1540
|
'Is first'() {
|
|
1535
|
-
|
|
1541
|
+
$mol_data_variant($mol_data_number, $mol_data_string)(0);
|
|
1536
1542
|
},
|
|
1537
1543
|
'Is second'() {
|
|
1538
|
-
|
|
1544
|
+
$mol_data_variant($mol_data_number, $mol_data_string)('');
|
|
1539
1545
|
},
|
|
1540
1546
|
'Is false'() {
|
|
1541
|
-
|
|
1542
|
-
|
|
1547
|
+
$mol_assert_fail(() => {
|
|
1548
|
+
$mol_data_variant($mol_data_number, $mol_data_string)(false);
|
|
1543
1549
|
}, 'false is not any of variants\nfalse is not a number\nfalse is not a string');
|
|
1544
1550
|
},
|
|
1545
1551
|
});
|
|
1546
1552
|
})($ || ($ = {}));
|
|
1547
|
-
//variant.test.
|
|
1553
|
+
//mol/data/variant/variant.test.ts
|
|
1548
1554
|
;
|
|
1549
1555
|
"use strict";
|
|
1550
1556
|
var $;
|
|
@@ -1579,36 +1585,36 @@ var $;
|
|
|
1579
1585
|
}
|
|
1580
1586
|
$.$mol_time_base = $mol_time_base;
|
|
1581
1587
|
})($ || ($ = {}));
|
|
1582
|
-
//base.
|
|
1588
|
+
//mol/time/base/base.ts
|
|
1583
1589
|
;
|
|
1584
1590
|
"use strict";
|
|
1585
1591
|
var $;
|
|
1586
1592
|
(function ($) {
|
|
1587
|
-
|
|
1593
|
+
$mol_test({
|
|
1588
1594
|
'parse and serial'() {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1595
|
+
$mol_assert_equal(new $mol_time_duration('P42.1Y').toString(), 'P42.1YT');
|
|
1596
|
+
$mol_assert_equal(new $mol_time_duration('P42.1M').toString(), 'P42.1MT');
|
|
1597
|
+
$mol_assert_equal(new $mol_time_duration('P42.1D').toString(), 'P42.1DT');
|
|
1598
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1h').toString(), 'PT42.1H');
|
|
1599
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1m').toString(), 'PT42.1M');
|
|
1600
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1s').toString(), 'PT42.1S');
|
|
1601
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6.7s').toString(), 'P1Y2M3DT4H5M6.7S');
|
|
1596
1602
|
},
|
|
1597
1603
|
'format typed'() {
|
|
1598
|
-
|
|
1604
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1599
1605
|
},
|
|
1600
1606
|
'comparison'() {
|
|
1601
1607
|
const iso = 'P1Y1M1DT1h1m1s';
|
|
1602
|
-
|
|
1608
|
+
$mol_assert_like(new $mol_time_duration(iso), new $mol_time_duration(iso));
|
|
1603
1609
|
},
|
|
1604
1610
|
});
|
|
1605
1611
|
})($ || ($ = {}));
|
|
1606
|
-
//duration.test.
|
|
1612
|
+
//mol/time/duration/duration.test.ts
|
|
1607
1613
|
;
|
|
1608
1614
|
"use strict";
|
|
1609
1615
|
var $;
|
|
1610
1616
|
(function ($) {
|
|
1611
|
-
class $mol_time_duration extends
|
|
1617
|
+
class $mol_time_duration extends $mol_time_base {
|
|
1612
1618
|
constructor(config = 0) {
|
|
1613
1619
|
super();
|
|
1614
1620
|
if (typeof config === 'number') {
|
|
@@ -1738,64 +1744,64 @@ var $;
|
|
|
1738
1744
|
}
|
|
1739
1745
|
$.$mol_time_duration = $mol_time_duration;
|
|
1740
1746
|
})($ || ($ = {}));
|
|
1741
|
-
//duration.
|
|
1747
|
+
//mol/time/duration/duration.ts
|
|
1742
1748
|
;
|
|
1743
1749
|
"use strict";
|
|
1744
|
-
//param.test.
|
|
1750
|
+
//mol/type/param/param.test.ts
|
|
1745
1751
|
;
|
|
1746
1752
|
"use strict";
|
|
1747
|
-
//tail.test.
|
|
1753
|
+
//mol/type/tail/tail.test.ts
|
|
1748
1754
|
;
|
|
1749
1755
|
"use strict";
|
|
1750
1756
|
var $;
|
|
1751
1757
|
(function ($) {
|
|
1752
|
-
|
|
1758
|
+
$mol_test({
|
|
1753
1759
|
'function'() {
|
|
1754
|
-
|
|
1760
|
+
$mol_assert_not($mol_func_is_class(function () { }));
|
|
1755
1761
|
},
|
|
1756
1762
|
'generator'() {
|
|
1757
|
-
|
|
1763
|
+
$mol_assert_not($mol_func_is_class(function* () { }));
|
|
1758
1764
|
},
|
|
1759
1765
|
'async'() {
|
|
1760
|
-
|
|
1766
|
+
$mol_assert_not($mol_func_is_class(async function () { }));
|
|
1761
1767
|
},
|
|
1762
1768
|
'arrow'() {
|
|
1763
|
-
|
|
1769
|
+
$mol_assert_not($mol_func_is_class(() => null));
|
|
1764
1770
|
},
|
|
1765
1771
|
'named class'() {
|
|
1766
|
-
|
|
1772
|
+
$mol_assert_ok($mol_func_is_class(class Foo {
|
|
1767
1773
|
}));
|
|
1768
1774
|
},
|
|
1769
1775
|
'unnamed class'() {
|
|
1770
|
-
|
|
1776
|
+
$mol_assert_ok($mol_func_is_class(class {
|
|
1771
1777
|
}));
|
|
1772
1778
|
},
|
|
1773
1779
|
});
|
|
1774
1780
|
})($ || ($ = {}));
|
|
1775
|
-
//class.test.
|
|
1781
|
+
//mol/func/is/class/class.test.ts
|
|
1776
1782
|
;
|
|
1777
1783
|
"use strict";
|
|
1778
|
-
//result.test.
|
|
1784
|
+
//mol/type/result/result.test.ts
|
|
1779
1785
|
;
|
|
1780
1786
|
"use strict";
|
|
1781
|
-
//foot.test.
|
|
1787
|
+
//mol/type/foot/foot.test.ts
|
|
1782
1788
|
;
|
|
1783
1789
|
"use strict";
|
|
1784
1790
|
var $;
|
|
1785
1791
|
(function ($) {
|
|
1786
|
-
|
|
1792
|
+
$mol_test({
|
|
1787
1793
|
'single function'() {
|
|
1788
|
-
const stringify =
|
|
1789
|
-
|
|
1794
|
+
const stringify = $mol_data_pipe((input) => input.toString());
|
|
1795
|
+
$mol_assert_equal(stringify(5), '5');
|
|
1790
1796
|
},
|
|
1791
1797
|
'two functions'() {
|
|
1792
|
-
const isLong =
|
|
1793
|
-
|
|
1794
|
-
|
|
1798
|
+
const isLong = $mol_data_pipe((input) => input.toString(), (input) => input.length > 2);
|
|
1799
|
+
$mol_assert_equal(isLong(5.0), false);
|
|
1800
|
+
$mol_assert_equal(isLong(5.1), true);
|
|
1795
1801
|
},
|
|
1796
1802
|
'three functions'() {
|
|
1797
|
-
const pattern =
|
|
1798
|
-
|
|
1803
|
+
const pattern = $mol_data_pipe((input) => input.toString(), (input) => new RegExp(input), (input) => input.toString());
|
|
1804
|
+
$mol_assert_equal(pattern(5), '/5/');
|
|
1799
1805
|
},
|
|
1800
1806
|
'classes'() {
|
|
1801
1807
|
class Box {
|
|
@@ -1804,26 +1810,26 @@ var $;
|
|
|
1804
1810
|
this.value = value;
|
|
1805
1811
|
}
|
|
1806
1812
|
}
|
|
1807
|
-
const boxify =
|
|
1808
|
-
|
|
1809
|
-
|
|
1813
|
+
const boxify = $mol_data_pipe((input) => input.toString(), Box);
|
|
1814
|
+
$mol_assert_ok(boxify(5) instanceof Box);
|
|
1815
|
+
$mol_assert_like(boxify(5).value, '5');
|
|
1810
1816
|
},
|
|
1811
1817
|
});
|
|
1812
1818
|
})($ || ($ = {}));
|
|
1813
|
-
//pipe.test.
|
|
1819
|
+
//mol/data/pipe/pipe.test.ts
|
|
1814
1820
|
;
|
|
1815
1821
|
"use strict";
|
|
1816
1822
|
var $;
|
|
1817
1823
|
(function ($) {
|
|
1818
|
-
|
|
1824
|
+
$mol_test({
|
|
1819
1825
|
'(De)Serialization'() {
|
|
1820
|
-
const Duration =
|
|
1821
|
-
|
|
1822
|
-
|
|
1826
|
+
const Duration = $mol_data_wrapper($mol_data_variant($mol_data_string, $mol_data_integer), $mol_time_duration);
|
|
1827
|
+
$mol_assert_equal(JSON.stringify(Duration('P1D')), '"P1DT"');
|
|
1828
|
+
$mol_assert_equal(JSON.stringify(Duration(1000)), '"PT1S"');
|
|
1823
1829
|
},
|
|
1824
1830
|
});
|
|
1825
1831
|
})($ || ($ = {}));
|
|
1826
|
-
//wrapper.test.
|
|
1832
|
+
//mol/data/wrapper/wrapper.test.ts
|
|
1827
1833
|
;
|
|
1828
1834
|
"use strict";
|
|
1829
1835
|
var $;
|
|
@@ -1847,7 +1853,7 @@ var $;
|
|
|
1847
1853
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1848
1854
|
$.$mol_log3_stack = [];
|
|
1849
1855
|
})($ || ($ = {}));
|
|
1850
|
-
//log3.
|
|
1856
|
+
//mol/log3/log3.ts
|
|
1851
1857
|
;
|
|
1852
1858
|
"use strict";
|
|
1853
1859
|
var $;
|
|
@@ -1875,12 +1881,12 @@ var $;
|
|
|
1875
1881
|
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1876
1882
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1877
1883
|
})($ || ($ = {}));
|
|
1878
|
-
//log3.node.
|
|
1884
|
+
//mol/log3/log3.node.ts
|
|
1879
1885
|
;
|
|
1880
1886
|
"use strict";
|
|
1881
1887
|
var $;
|
|
1882
1888
|
(function ($_1) {
|
|
1883
|
-
$
|
|
1889
|
+
$mol_test_mocks.push($ => {
|
|
1884
1890
|
$.$mol_log3_come = () => { };
|
|
1885
1891
|
$.$mol_log3_done = () => { };
|
|
1886
1892
|
$.$mol_log3_fail = () => { };
|
|
@@ -1889,7 +1895,7 @@ var $;
|
|
|
1889
1895
|
$.$mol_log3_area = () => () => { };
|
|
1890
1896
|
});
|
|
1891
1897
|
})($ || ($ = {}));
|
|
1892
|
-
//log3.test.
|
|
1898
|
+
//mol/log3/log3.test.ts
|
|
1893
1899
|
;
|
|
1894
1900
|
"use strict";
|
|
1895
1901
|
var $;
|
|
@@ -1899,7 +1905,7 @@ var $;
|
|
|
1899
1905
|
}
|
|
1900
1906
|
$.$mol_env = $mol_env;
|
|
1901
1907
|
})($ || ($ = {}));
|
|
1902
|
-
//env.
|
|
1908
|
+
//mol/env/env.ts
|
|
1903
1909
|
;
|
|
1904
1910
|
"use strict";
|
|
1905
1911
|
var $;
|
|
@@ -1908,7 +1914,7 @@ var $;
|
|
|
1908
1914
|
return this.process.env;
|
|
1909
1915
|
};
|
|
1910
1916
|
})($ || ($ = {}));
|
|
1911
|
-
//env.node.
|
|
1917
|
+
//mol/env/env.node.ts
|
|
1912
1918
|
;
|
|
1913
1919
|
"use strict";
|
|
1914
1920
|
var $;
|
|
@@ -1928,14 +1934,14 @@ var $;
|
|
|
1928
1934
|
env: this.$mol_env(),
|
|
1929
1935
|
});
|
|
1930
1936
|
if (res.status || res.error)
|
|
1931
|
-
return
|
|
1937
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1932
1938
|
if (!res.stdout)
|
|
1933
1939
|
res.stdout = Buffer.from([]);
|
|
1934
1940
|
return res;
|
|
1935
1941
|
}
|
|
1936
1942
|
$.$mol_exec = $mol_exec;
|
|
1937
1943
|
})($ || ($ = {}));
|
|
1938
|
-
//exec.node.
|
|
1944
|
+
//mol/exec/exec.node.ts
|
|
1939
1945
|
;
|
|
1940
1946
|
"use strict";
|
|
1941
1947
|
var $;
|
|
@@ -1946,29 +1952,29 @@ var $;
|
|
|
1946
1952
|
}
|
|
1947
1953
|
$.$mol_ambient = $mol_ambient;
|
|
1948
1954
|
})($ || ($ = {}));
|
|
1949
|
-
//ambient.
|
|
1955
|
+
//mol/ambient/ambient.ts
|
|
1950
1956
|
;
|
|
1951
1957
|
"use strict";
|
|
1952
1958
|
var $;
|
|
1953
1959
|
(function ($) {
|
|
1954
|
-
|
|
1960
|
+
$mol_test({
|
|
1955
1961
|
'get'() {
|
|
1956
|
-
const proxy =
|
|
1957
|
-
|
|
1962
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1963
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1958
1964
|
},
|
|
1959
1965
|
'has'() {
|
|
1960
|
-
const proxy =
|
|
1961
|
-
|
|
1966
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1967
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1962
1968
|
},
|
|
1963
1969
|
'set'() {
|
|
1964
1970
|
const target = { foo: 777 };
|
|
1965
|
-
const proxy =
|
|
1971
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1966
1972
|
proxy.foo = 123;
|
|
1967
|
-
|
|
1973
|
+
$mol_assert_equal(target.foo, 123);
|
|
1968
1974
|
},
|
|
1969
1975
|
'getOwnPropertyDescriptor'() {
|
|
1970
|
-
const proxy =
|
|
1971
|
-
|
|
1976
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1977
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1972
1978
|
value: 777,
|
|
1973
1979
|
writable: true,
|
|
1974
1980
|
enumerable: true,
|
|
@@ -1976,40 +1982,40 @@ var $;
|
|
|
1976
1982
|
});
|
|
1977
1983
|
},
|
|
1978
1984
|
'ownKeys'() {
|
|
1979
|
-
const proxy =
|
|
1980
|
-
|
|
1985
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1986
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1981
1987
|
},
|
|
1982
1988
|
'getPrototypeOf'() {
|
|
1983
1989
|
class Foo {
|
|
1984
1990
|
}
|
|
1985
|
-
const proxy =
|
|
1986
|
-
|
|
1991
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1992
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1987
1993
|
},
|
|
1988
1994
|
'setPrototypeOf'() {
|
|
1989
1995
|
class Foo {
|
|
1990
1996
|
}
|
|
1991
1997
|
const target = {};
|
|
1992
|
-
const proxy =
|
|
1998
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1993
1999
|
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1994
|
-
|
|
2000
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1995
2001
|
},
|
|
1996
2002
|
'instanceof'() {
|
|
1997
2003
|
class Foo {
|
|
1998
2004
|
}
|
|
1999
|
-
const proxy =
|
|
2000
|
-
|
|
2001
|
-
|
|
2005
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
2006
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
2007
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
2002
2008
|
},
|
|
2003
2009
|
'autobind'() {
|
|
2004
2010
|
class Foo {
|
|
2005
2011
|
}
|
|
2006
|
-
const proxy =
|
|
2007
|
-
|
|
2008
|
-
|
|
2012
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
2013
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
2014
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
2009
2015
|
},
|
|
2010
2016
|
});
|
|
2011
2017
|
})($ || ($ = {}));
|
|
2012
|
-
//delegate.test.
|
|
2018
|
+
//mol/delegate/delegate.test.ts
|
|
2013
2019
|
;
|
|
2014
2020
|
"use strict";
|
|
2015
2021
|
var $;
|
|
@@ -2046,7 +2052,7 @@ var $;
|
|
|
2046
2052
|
value: (obj) => instances.has(obj),
|
|
2047
2053
|
});
|
|
2048
2054
|
})($ || ($ = {}));
|
|
2049
|
-
//delegate.
|
|
2055
|
+
//mol/delegate/delegate.ts
|
|
2050
2056
|
;
|
|
2051
2057
|
"use strict";
|
|
2052
2058
|
var $;
|
|
@@ -2058,7 +2064,7 @@ var $;
|
|
|
2058
2064
|
return false;
|
|
2059
2065
|
if (typeof having !== 'object')
|
|
2060
2066
|
return false;
|
|
2061
|
-
if (having instanceof
|
|
2067
|
+
if (having instanceof $mol_delegate)
|
|
2062
2068
|
return false;
|
|
2063
2069
|
if (typeof having['destructor'] !== 'function')
|
|
2064
2070
|
return false;
|
|
@@ -2102,30 +2108,30 @@ var $;
|
|
|
2102
2108
|
}
|
|
2103
2109
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
2104
2110
|
})($ || ($ = {}));
|
|
2105
|
-
//owning.
|
|
2111
|
+
//mol/owning/owning.ts
|
|
2106
2112
|
;
|
|
2107
2113
|
"use strict";
|
|
2108
|
-
//writable.test.
|
|
2114
|
+
//mol/type/writable/writable.test.ts
|
|
2109
2115
|
;
|
|
2110
2116
|
"use strict";
|
|
2111
|
-
//writable.
|
|
2117
|
+
//mol/type/writable/writable.ts
|
|
2112
2118
|
;
|
|
2113
2119
|
"use strict";
|
|
2114
2120
|
var $;
|
|
2115
2121
|
(function ($) {
|
|
2116
2122
|
class $mol_object2 {
|
|
2117
2123
|
static $ = $;
|
|
2118
|
-
[
|
|
2124
|
+
[$mol_ambient_ref] = null;
|
|
2119
2125
|
get $() {
|
|
2120
|
-
if (this[
|
|
2121
|
-
return this[
|
|
2122
|
-
const owner =
|
|
2123
|
-
return this[
|
|
2126
|
+
if (this[$mol_ambient_ref])
|
|
2127
|
+
return this[$mol_ambient_ref];
|
|
2128
|
+
const owner = $mol_owning_get(this);
|
|
2129
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
2124
2130
|
}
|
|
2125
2131
|
set $(next) {
|
|
2126
|
-
if (this[
|
|
2127
|
-
|
|
2128
|
-
this[
|
|
2132
|
+
if (this[$mol_ambient_ref])
|
|
2133
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
2134
|
+
this[$mol_ambient_ref] = next;
|
|
2129
2135
|
}
|
|
2130
2136
|
static create(init) {
|
|
2131
2137
|
const obj = new this;
|
|
@@ -2151,7 +2157,7 @@ var $;
|
|
|
2151
2157
|
}
|
|
2152
2158
|
$.$mol_object2 = $mol_object2;
|
|
2153
2159
|
})($ || ($ = {}));
|
|
2154
|
-
//object2.
|
|
2160
|
+
//mol/object2/object2.ts
|
|
2155
2161
|
;
|
|
2156
2162
|
"use strict";
|
|
2157
2163
|
var $;
|
|
@@ -2162,7 +2168,7 @@ var $;
|
|
|
2162
2168
|
let warned = false;
|
|
2163
2169
|
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
2164
2170
|
if (!warned) {
|
|
2165
|
-
|
|
2171
|
+
$$.$mol_log3_warn({
|
|
2166
2172
|
place: `${host.constructor.name}::${field}`,
|
|
2167
2173
|
message: `Deprecated`,
|
|
2168
2174
|
hint: message,
|
|
@@ -2175,54 +2181,54 @@ var $;
|
|
|
2175
2181
|
}
|
|
2176
2182
|
$.$mol_deprecated = $mol_deprecated;
|
|
2177
2183
|
})($ || ($ = {}));
|
|
2178
|
-
//deprecated.
|
|
2184
|
+
//mol/deprecated/deprecated.ts
|
|
2179
2185
|
;
|
|
2180
2186
|
"use strict";
|
|
2181
2187
|
var $;
|
|
2182
2188
|
(function ($_1) {
|
|
2183
|
-
$
|
|
2189
|
+
$mol_test({
|
|
2184
2190
|
'tree parsing'() {
|
|
2185
|
-
$
|
|
2186
|
-
$
|
|
2187
|
-
$
|
|
2188
|
-
$
|
|
2189
|
-
$
|
|
2190
|
-
$
|
|
2191
|
-
$
|
|
2192
|
-
$
|
|
2191
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
2192
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
2193
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
2194
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
2195
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
2196
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
2197
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
2198
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2193
2199
|
},
|
|
2194
2200
|
'inserting'() {
|
|
2195
|
-
$
|
|
2196
|
-
$
|
|
2197
|
-
$
|
|
2198
|
-
$
|
|
2199
|
-
$
|
|
2200
|
-
$
|
|
2201
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
2202
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
2203
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
2204
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
2205
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
2206
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
2201
2207
|
},
|
|
2202
2208
|
'fromJSON'() {
|
|
2203
|
-
$
|
|
2204
|
-
$
|
|
2205
|
-
$
|
|
2206
|
-
$
|
|
2207
|
-
$
|
|
2209
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
2210
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2211
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2212
|
+
$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');
|
|
2213
|
+
$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');
|
|
2208
2214
|
},
|
|
2209
2215
|
'toJSON'() {
|
|
2210
|
-
$
|
|
2211
|
-
$
|
|
2212
|
-
$
|
|
2213
|
-
$
|
|
2214
|
-
$
|
|
2216
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
2217
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
2218
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
2219
|
+
$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"]');
|
|
2220
|
+
$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"}');
|
|
2215
2221
|
},
|
|
2216
2222
|
'hack'() {
|
|
2217
|
-
const res = $
|
|
2223
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
2218
2224
|
'': (tree, context) => [tree.hack(context)],
|
|
2219
2225
|
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
2220
2226
|
});
|
|
2221
|
-
$
|
|
2227
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
2222
2228
|
},
|
|
2223
2229
|
'errors handling'($) {
|
|
2224
2230
|
const errors = [];
|
|
2225
|
-
class Tree extends $
|
|
2231
|
+
class Tree extends $mol_tree {
|
|
2226
2232
|
static $ = $.$mol_ambient({
|
|
2227
2233
|
$mol_fail: error => errors.push(error.message)
|
|
2228
2234
|
});
|
|
@@ -2231,17 +2237,17 @@ var $;
|
|
|
2231
2237
|
\t \tfoo
|
|
2232
2238
|
bar \\data
|
|
2233
2239
|
`, 'test');
|
|
2234
|
-
$
|
|
2240
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
2235
2241
|
},
|
|
2236
2242
|
});
|
|
2237
2243
|
})($ || ($ = {}));
|
|
2238
|
-
//tree.test.
|
|
2244
|
+
//mol/tree/tree.test.ts
|
|
2239
2245
|
;
|
|
2240
2246
|
"use strict";
|
|
2241
2247
|
var $;
|
|
2242
2248
|
(function ($) {
|
|
2243
2249
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
2244
|
-
class $mol_tree extends
|
|
2250
|
+
class $mol_tree extends $mol_object2 {
|
|
2245
2251
|
type;
|
|
2246
2252
|
data;
|
|
2247
2253
|
sub;
|
|
@@ -2554,7 +2560,7 @@ var $;
|
|
|
2554
2560
|
const sub = [].concat(...this.sub.map(child => {
|
|
2555
2561
|
const handle = context[child.type] || context[''];
|
|
2556
2562
|
if (!handle)
|
|
2557
|
-
|
|
2563
|
+
$mol_fail(child.error('Handler not defined'));
|
|
2558
2564
|
return handle(child, context);
|
|
2559
2565
|
}));
|
|
2560
2566
|
return this.clone({ sub });
|
|
@@ -2564,10 +2570,10 @@ var $;
|
|
|
2564
2570
|
}
|
|
2565
2571
|
}
|
|
2566
2572
|
__decorate([
|
|
2567
|
-
|
|
2573
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
2568
2574
|
], $mol_tree.prototype, "transform", null);
|
|
2569
2575
|
$.$mol_tree = $mol_tree;
|
|
2570
2576
|
})($ || ($ = {}));
|
|
2571
|
-
//tree.
|
|
2577
|
+
//mol/tree/tree.ts
|
|
2572
2578
|
|
|
2573
2579
|
//# sourceMappingURL=node.test.js.map
|