mol_wire_lib 1.0.69 → 1.0.72
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 +35 -0
- package/node.deps.json +1 -1
- package/node.esm.js +136 -0
- package/node.esm.js.map +1 -1
- package/node.js +136 -0
- package/node.js.map +1 -1
- package/node.test.js +360 -0
- package/node.test.js.map +1 -1
- package/package.json +3 -1
- package/web.d.ts +35 -0
- package/web.deps.json +1 -1
- package/web.esm.js +136 -0
- package/web.esm.js.map +1 -1
- package/web.js +136 -0
- package/web.js.map +1 -1
- package/web.test.js +224 -0
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1231,6 +1231,142 @@ var $;
|
|
|
1231
1231
|
;
|
|
1232
1232
|
"use strict";
|
|
1233
1233
|
var $;
|
|
1234
|
+
(function ($) {
|
|
1235
|
+
class $mol_wire_set extends Set {
|
|
1236
|
+
pub = new $mol_wire_pub;
|
|
1237
|
+
has(value) {
|
|
1238
|
+
this.pub.promote();
|
|
1239
|
+
return super.has(value);
|
|
1240
|
+
}
|
|
1241
|
+
entries() {
|
|
1242
|
+
this.pub.promote();
|
|
1243
|
+
return super.entries();
|
|
1244
|
+
}
|
|
1245
|
+
keys() {
|
|
1246
|
+
this.pub.promote();
|
|
1247
|
+
return super.keys();
|
|
1248
|
+
}
|
|
1249
|
+
values() {
|
|
1250
|
+
this.pub.promote();
|
|
1251
|
+
return super.values();
|
|
1252
|
+
}
|
|
1253
|
+
forEach(task, self) {
|
|
1254
|
+
this.pub.promote();
|
|
1255
|
+
super.forEach(task, self);
|
|
1256
|
+
}
|
|
1257
|
+
[Symbol.iterator]() {
|
|
1258
|
+
this.pub.promote();
|
|
1259
|
+
return super[Symbol.iterator]();
|
|
1260
|
+
}
|
|
1261
|
+
get size() {
|
|
1262
|
+
this.pub.promote();
|
|
1263
|
+
return super.size;
|
|
1264
|
+
}
|
|
1265
|
+
add(value) {
|
|
1266
|
+
if (super.has(value))
|
|
1267
|
+
return this;
|
|
1268
|
+
super.add(value);
|
|
1269
|
+
this.pub.emit();
|
|
1270
|
+
return this;
|
|
1271
|
+
}
|
|
1272
|
+
delete(value) {
|
|
1273
|
+
const res = super.delete(value);
|
|
1274
|
+
if (res)
|
|
1275
|
+
this.pub.emit();
|
|
1276
|
+
return res;
|
|
1277
|
+
}
|
|
1278
|
+
clear() {
|
|
1279
|
+
if (!super.size)
|
|
1280
|
+
return;
|
|
1281
|
+
super.clear();
|
|
1282
|
+
this.pub.emit();
|
|
1283
|
+
}
|
|
1284
|
+
item(val, next) {
|
|
1285
|
+
if (next === undefined)
|
|
1286
|
+
return this.has(val);
|
|
1287
|
+
if (next)
|
|
1288
|
+
this.add(val);
|
|
1289
|
+
else
|
|
1290
|
+
this.delete(val);
|
|
1291
|
+
return next;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
$.$mol_wire_set = $mol_wire_set;
|
|
1295
|
+
})($ || ($ = {}));
|
|
1296
|
+
//mol/wire/set/set.ts
|
|
1297
|
+
;
|
|
1298
|
+
"use strict";
|
|
1299
|
+
var $;
|
|
1300
|
+
(function ($) {
|
|
1301
|
+
class $mol_wire_dict extends Map {
|
|
1302
|
+
pub = new $mol_wire_pub;
|
|
1303
|
+
has(key) {
|
|
1304
|
+
this.pub.promote();
|
|
1305
|
+
return super.has(key);
|
|
1306
|
+
}
|
|
1307
|
+
get(key) {
|
|
1308
|
+
this.pub.promote();
|
|
1309
|
+
return super.get(key);
|
|
1310
|
+
}
|
|
1311
|
+
entries() {
|
|
1312
|
+
this.pub.promote();
|
|
1313
|
+
return super.entries();
|
|
1314
|
+
}
|
|
1315
|
+
keys() {
|
|
1316
|
+
this.pub.promote();
|
|
1317
|
+
return super.keys();
|
|
1318
|
+
}
|
|
1319
|
+
values() {
|
|
1320
|
+
this.pub.promote();
|
|
1321
|
+
return super.values();
|
|
1322
|
+
}
|
|
1323
|
+
forEach(task, self) {
|
|
1324
|
+
this.pub.promote();
|
|
1325
|
+
super.forEach(task, self);
|
|
1326
|
+
}
|
|
1327
|
+
[Symbol.iterator]() {
|
|
1328
|
+
this.pub.promote();
|
|
1329
|
+
return super[Symbol.iterator]();
|
|
1330
|
+
}
|
|
1331
|
+
get size() {
|
|
1332
|
+
this.pub.promote();
|
|
1333
|
+
return super.size;
|
|
1334
|
+
}
|
|
1335
|
+
set(key, value) {
|
|
1336
|
+
if (super.get(key) === value)
|
|
1337
|
+
return this;
|
|
1338
|
+
super.set(key, value);
|
|
1339
|
+
this.pub.emit();
|
|
1340
|
+
return this;
|
|
1341
|
+
}
|
|
1342
|
+
delete(key) {
|
|
1343
|
+
const res = super.delete(key);
|
|
1344
|
+
if (res)
|
|
1345
|
+
this.pub.emit();
|
|
1346
|
+
return res;
|
|
1347
|
+
}
|
|
1348
|
+
clear() {
|
|
1349
|
+
if (!super.size)
|
|
1350
|
+
return;
|
|
1351
|
+
super.clear();
|
|
1352
|
+
this.pub.emit();
|
|
1353
|
+
}
|
|
1354
|
+
item(key, next) {
|
|
1355
|
+
if (next === undefined)
|
|
1356
|
+
return this.get(key) ?? null;
|
|
1357
|
+
if (next === null)
|
|
1358
|
+
this.delete(key);
|
|
1359
|
+
else
|
|
1360
|
+
this.set(key, next);
|
|
1361
|
+
return next;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
$.$mol_wire_dict = $mol_wire_dict;
|
|
1365
|
+
})($ || ($ = {}));
|
|
1366
|
+
//mol/wire/dict/dict.ts
|
|
1367
|
+
;
|
|
1368
|
+
"use strict";
|
|
1369
|
+
var $;
|
|
1234
1370
|
(function ($) {
|
|
1235
1371
|
function $mol_promise() {
|
|
1236
1372
|
let done;
|
|
@@ -3003,6 +3139,230 @@ var $;
|
|
|
3003
3139
|
;
|
|
3004
3140
|
"use strict";
|
|
3005
3141
|
var $;
|
|
3142
|
+
(function ($_1) {
|
|
3143
|
+
$mol_test({
|
|
3144
|
+
'Watch one value'($) {
|
|
3145
|
+
class App extends $mol_object2 {
|
|
3146
|
+
static $ = $;
|
|
3147
|
+
static set = new $mol_wire_set();
|
|
3148
|
+
static lucky() {
|
|
3149
|
+
return this.set.has(777);
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
__decorate([
|
|
3153
|
+
$mol_wire_mem(0)
|
|
3154
|
+
], App, "lucky", null);
|
|
3155
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3156
|
+
App.set.add(666);
|
|
3157
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3158
|
+
App.set.add(777);
|
|
3159
|
+
$mol_assert_equal(App.lucky(), true);
|
|
3160
|
+
App.set.delete(777);
|
|
3161
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3162
|
+
},
|
|
3163
|
+
'Watch item channel'($) {
|
|
3164
|
+
class App extends $mol_object2 {
|
|
3165
|
+
static $ = $;
|
|
3166
|
+
static set = new $mol_wire_set();
|
|
3167
|
+
static lucky() {
|
|
3168
|
+
return this.set.item(777);
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
__decorate([
|
|
3172
|
+
$mol_wire_mem(0)
|
|
3173
|
+
], App, "lucky", null);
|
|
3174
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3175
|
+
App.set.item(666, true);
|
|
3176
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3177
|
+
App.set.item(777, true);
|
|
3178
|
+
$mol_assert_equal(App.lucky(), true);
|
|
3179
|
+
App.set.item(777, false);
|
|
3180
|
+
$mol_assert_equal(App.lucky(), false);
|
|
3181
|
+
},
|
|
3182
|
+
'Watch size'($) {
|
|
3183
|
+
class App extends $mol_object2 {
|
|
3184
|
+
static $ = $;
|
|
3185
|
+
static set = new $mol_wire_set();
|
|
3186
|
+
static size() {
|
|
3187
|
+
return this.set.size;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
__decorate([
|
|
3191
|
+
$mol_wire_mem(0)
|
|
3192
|
+
], App, "size", null);
|
|
3193
|
+
$mol_assert_equal(App.size(), 0);
|
|
3194
|
+
App.set.add(666);
|
|
3195
|
+
$mol_assert_equal(App.size(), 1);
|
|
3196
|
+
App.set.add(777);
|
|
3197
|
+
$mol_assert_equal(App.size(), 2);
|
|
3198
|
+
App.set.delete(777);
|
|
3199
|
+
$mol_assert_equal(App.size(), 1);
|
|
3200
|
+
},
|
|
3201
|
+
'Watch for-of'($) {
|
|
3202
|
+
class App extends $mol_object2 {
|
|
3203
|
+
static $ = $;
|
|
3204
|
+
static set = new $mol_wire_set();
|
|
3205
|
+
static sum() {
|
|
3206
|
+
let res = 0;
|
|
3207
|
+
for (const val of this.set) {
|
|
3208
|
+
res += val;
|
|
3209
|
+
}
|
|
3210
|
+
return res;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
__decorate([
|
|
3214
|
+
$mol_wire_mem(0)
|
|
3215
|
+
], App, "sum", null);
|
|
3216
|
+
$mol_assert_equal(App.sum(), 0);
|
|
3217
|
+
App.set.add(111);
|
|
3218
|
+
$mol_assert_equal(App.sum(), 111);
|
|
3219
|
+
App.set.add(222);
|
|
3220
|
+
$mol_assert_equal(App.sum(), 333);
|
|
3221
|
+
App.set.delete(111);
|
|
3222
|
+
$mol_assert_equal(App.sum(), 222);
|
|
3223
|
+
},
|
|
3224
|
+
'Watch forEach'($) {
|
|
3225
|
+
class App extends $mol_object2 {
|
|
3226
|
+
static $ = $;
|
|
3227
|
+
static set = new $mol_wire_set();
|
|
3228
|
+
static sum() {
|
|
3229
|
+
let res = 0;
|
|
3230
|
+
this.set.forEach(val => res += val);
|
|
3231
|
+
return res;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
__decorate([
|
|
3235
|
+
$mol_wire_mem(0)
|
|
3236
|
+
], App, "sum", null);
|
|
3237
|
+
$mol_assert_equal(App.sum(), 0);
|
|
3238
|
+
App.set.add(111);
|
|
3239
|
+
$mol_assert_equal(App.sum(), 111);
|
|
3240
|
+
App.set.add(222);
|
|
3241
|
+
$mol_assert_equal(App.sum(), 333);
|
|
3242
|
+
App.set.delete(111);
|
|
3243
|
+
$mol_assert_equal(App.sum(), 222);
|
|
3244
|
+
},
|
|
3245
|
+
});
|
|
3246
|
+
})($ || ($ = {}));
|
|
3247
|
+
//mol/wire/set/set.test.ts
|
|
3248
|
+
;
|
|
3249
|
+
"use strict";
|
|
3250
|
+
var $;
|
|
3251
|
+
(function ($_1) {
|
|
3252
|
+
$mol_test({
|
|
3253
|
+
'Watch one value'($) {
|
|
3254
|
+
class App extends $mol_object2 {
|
|
3255
|
+
static $ = $;
|
|
3256
|
+
static dict = new $mol_wire_dict();
|
|
3257
|
+
static lucky() {
|
|
3258
|
+
return this.dict.get(777);
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
__decorate([
|
|
3262
|
+
$mol_wire_mem(0)
|
|
3263
|
+
], App, "lucky", null);
|
|
3264
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3265
|
+
App.dict.set(666, 6666);
|
|
3266
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3267
|
+
App.dict.set(777, 7777);
|
|
3268
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
3269
|
+
App.dict.delete(777);
|
|
3270
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
3271
|
+
},
|
|
3272
|
+
'Watch item channel'($) {
|
|
3273
|
+
class App extends $mol_object2 {
|
|
3274
|
+
static $ = $;
|
|
3275
|
+
static dict = new $mol_wire_dict();
|
|
3276
|
+
static lucky() {
|
|
3277
|
+
return this.dict.item(777);
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
__decorate([
|
|
3281
|
+
$mol_wire_mem(0)
|
|
3282
|
+
], App, "lucky", null);
|
|
3283
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3284
|
+
App.dict.item(666, 6666);
|
|
3285
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3286
|
+
App.dict.item(777, 7777);
|
|
3287
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
3288
|
+
App.dict.item(777, null);
|
|
3289
|
+
$mol_assert_equal(App.lucky(), null);
|
|
3290
|
+
},
|
|
3291
|
+
'Watch size'($) {
|
|
3292
|
+
class App extends $mol_object2 {
|
|
3293
|
+
static $ = $;
|
|
3294
|
+
static dict = new $mol_wire_dict();
|
|
3295
|
+
static size() {
|
|
3296
|
+
return this.dict.size;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
__decorate([
|
|
3300
|
+
$mol_wire_mem(0)
|
|
3301
|
+
], App, "size", null);
|
|
3302
|
+
$mol_assert_equal(App.size(), 0);
|
|
3303
|
+
App.dict.set(666, 6666);
|
|
3304
|
+
$mol_assert_equal(App.size(), 1);
|
|
3305
|
+
App.dict.set(777, 7777);
|
|
3306
|
+
$mol_assert_equal(App.size(), 2);
|
|
3307
|
+
App.dict.delete(777);
|
|
3308
|
+
$mol_assert_equal(App.size(), 1);
|
|
3309
|
+
},
|
|
3310
|
+
'Watch for-of'($) {
|
|
3311
|
+
class App extends $mol_object2 {
|
|
3312
|
+
static $ = $;
|
|
3313
|
+
static dict = new $mol_wire_dict();
|
|
3314
|
+
static sum() {
|
|
3315
|
+
let keys = 0;
|
|
3316
|
+
let vals = 0;
|
|
3317
|
+
for (const [key, val] of this.dict) {
|
|
3318
|
+
keys += key;
|
|
3319
|
+
vals += val;
|
|
3320
|
+
}
|
|
3321
|
+
return [keys, vals];
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
__decorate([
|
|
3325
|
+
$mol_wire_mem(0)
|
|
3326
|
+
], App, "sum", null);
|
|
3327
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
3328
|
+
App.dict.set(111, 1111);
|
|
3329
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3330
|
+
App.dict.set(222, 2222);
|
|
3331
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3332
|
+
App.dict.delete(111);
|
|
3333
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3334
|
+
},
|
|
3335
|
+
'Watch forEach'($) {
|
|
3336
|
+
class App extends $mol_object2 {
|
|
3337
|
+
static $ = $;
|
|
3338
|
+
static dict = new $mol_wire_dict();
|
|
3339
|
+
static sum() {
|
|
3340
|
+
let keys = 0;
|
|
3341
|
+
let vals = 0;
|
|
3342
|
+
this.dict.forEach((val, key) => {
|
|
3343
|
+
keys += key;
|
|
3344
|
+
vals += val;
|
|
3345
|
+
});
|
|
3346
|
+
return [keys, vals];
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
__decorate([
|
|
3350
|
+
$mol_wire_mem(0)
|
|
3351
|
+
], App, "sum", null);
|
|
3352
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
3353
|
+
App.dict.set(111, 1111);
|
|
3354
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
3355
|
+
App.dict.set(222, 2222);
|
|
3356
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
3357
|
+
App.dict.delete(111);
|
|
3358
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
3359
|
+
},
|
|
3360
|
+
});
|
|
3361
|
+
})($ || ($ = {}));
|
|
3362
|
+
//mol/wire/dict/dict.test.ts
|
|
3363
|
+
;
|
|
3364
|
+
"use strict";
|
|
3365
|
+
var $;
|
|
3006
3366
|
(function ($) {
|
|
3007
3367
|
function $mol_env() {
|
|
3008
3368
|
return {};
|