mol_plot_all 1.2.1174 → 1.2.1176

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/web.test.js CHANGED
@@ -1197,14 +1197,76 @@ var $;
1197
1197
  });
1198
1198
  })($ || ($ = {}));
1199
1199
 
1200
+ ;
1201
+ "use strict";
1202
+ var $;
1203
+ (function ($_1) {
1204
+ $mol_test({
1205
+ 'test types'($) {
1206
+ class A {
1207
+ static a() {
1208
+ return '';
1209
+ }
1210
+ static b() {
1211
+ return $mol_wire_async(this).a();
1212
+ }
1213
+ }
1214
+ },
1215
+ async 'Latest method calls wins'($) {
1216
+ class NameLogger extends $mol_object2 {
1217
+ static $ = $;
1218
+ static first = [];
1219
+ static last = [];
1220
+ static send(next) {
1221
+ $mol_wire_sync(this.first).push(next);
1222
+ this.$.$mol_wait_timeout(0);
1223
+ this.last.push(next);
1224
+ }
1225
+ }
1226
+ const name = $mol_wire_async(NameLogger).send;
1227
+ name('john');
1228
+ const promise = name('jin');
1229
+ $.$mol_after_mock_warp();
1230
+ await promise;
1231
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
1232
+ $mol_assert_like(NameLogger.last, ['jin']);
1233
+ },
1234
+ async 'Latest function calls wins'($) {
1235
+ const first = [];
1236
+ const last = [];
1237
+ function send_name(next) {
1238
+ $mol_wire_sync(first).push(next);
1239
+ $.$mol_wait_timeout(0);
1240
+ last.push(next);
1241
+ }
1242
+ const name = $mol_wire_async(send_name);
1243
+ name('john');
1244
+ const promise = name('jin');
1245
+ $.$mol_after_mock_warp();
1246
+ await promise;
1247
+ $mol_assert_like(first, ['john', 'jin']);
1248
+ $mol_assert_like(last, ['jin']);
1249
+ },
1250
+ });
1251
+ })($ || ($ = {}));
1252
+
1200
1253
  ;
1201
1254
  "use strict";
1202
1255
  var $;
1203
1256
  (function ($) {
1257
+ const factories = new WeakMap();
1258
+ function factory(val) {
1259
+ let make = factories.get(val);
1260
+ if (make)
1261
+ return make;
1262
+ make = $mol_func_name_from((...args) => new val(...args), val);
1263
+ factories.set(val, make);
1264
+ return make;
1265
+ }
1204
1266
  function $mol_wire_sync(obj) {
1205
1267
  return new Proxy(obj, {
1206
1268
  get(obj, field) {
1207
- const val = obj[field];
1269
+ let val = obj[field];
1208
1270
  if (typeof val !== 'function')
1209
1271
  return val;
1210
1272
  const temp = $mol_wire_task.getter(val);
@@ -1213,10 +1275,13 @@ var $;
1213
1275
  return fiber.sync();
1214
1276
  };
1215
1277
  },
1278
+ construct(obj, args) {
1279
+ const temp = $mol_wire_task.getter(factory(obj));
1280
+ return temp(obj, args).sync();
1281
+ },
1216
1282
  apply(obj, self, args) {
1217
1283
  const temp = $mol_wire_task.getter(obj);
1218
- const fiber = temp(self, args);
1219
- return fiber.sync();
1284
+ return temp(self, args).sync();
1220
1285
  },
1221
1286
  });
1222
1287
  }
@@ -1238,6 +1303,41 @@ var $;
1238
1303
  }
1239
1304
  }
1240
1305
  },
1306
+ async 'test method from host'($) {
1307
+ let count = 0;
1308
+ class A {
1309
+ static a() {
1310
+ return $mol_wire_sync(this).b();
1311
+ }
1312
+ static b() { return Promise.resolve(++count); }
1313
+ }
1314
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1315
+ },
1316
+ async 'test function'($) {
1317
+ let count = 0;
1318
+ class A {
1319
+ static a() {
1320
+ return $mol_wire_sync(this.b)();
1321
+ }
1322
+ static b() { return Promise.resolve(++count); }
1323
+ }
1324
+ $mol_assert_equal(await $mol_wire_async(A).a(), 1, count);
1325
+ },
1326
+ async 'test construct itself'($) {
1327
+ class A {
1328
+ static instances = [];
1329
+ static a() {
1330
+ const a = new ($mol_wire_sync(A))();
1331
+ this.instances.push(a);
1332
+ $mol_wire_sync(this).b();
1333
+ }
1334
+ static b() { return Promise.resolve(); }
1335
+ }
1336
+ await $mol_wire_async(A).a();
1337
+ $mol_assert_equal(A.instances.length, 2);
1338
+ $mol_assert_equal(A.instances[0] instanceof A);
1339
+ $mol_assert_equal(A.instances[0], A.instances[1]);
1340
+ }
1241
1341
  });
1242
1342
  })($ || ($ = {}));
1243
1343
 
@@ -1259,59 +1359,6 @@ var $;
1259
1359
  $.$mol_wait_timeout = $mol_wait_timeout;
1260
1360
  })($ || ($ = {}));
1261
1361
 
1262
- ;
1263
- "use strict";
1264
- var $;
1265
- (function ($_1) {
1266
- $mol_test({
1267
- 'test types'($) {
1268
- class A {
1269
- static a() {
1270
- return '';
1271
- }
1272
- static b() {
1273
- return $mol_wire_async(this).a();
1274
- }
1275
- }
1276
- },
1277
- async 'Latest method calls wins'($) {
1278
- class NameLogger extends $mol_object2 {
1279
- static $ = $;
1280
- static first = [];
1281
- static last = [];
1282
- static send(next) {
1283
- $mol_wire_sync(this.first).push(next);
1284
- this.$.$mol_wait_timeout(0);
1285
- this.last.push(next);
1286
- }
1287
- }
1288
- const name = $mol_wire_async(NameLogger).send;
1289
- name('john');
1290
- const promise = name('jin');
1291
- $.$mol_after_mock_warp();
1292
- await promise;
1293
- $mol_assert_like(NameLogger.first, ['john', 'jin']);
1294
- $mol_assert_like(NameLogger.last, ['jin']);
1295
- },
1296
- async 'Latest function calls wins'($) {
1297
- const first = [];
1298
- const last = [];
1299
- function send_name(next) {
1300
- $mol_wire_sync(first).push(next);
1301
- $.$mol_wait_timeout(0);
1302
- last.push(next);
1303
- }
1304
- const name = $mol_wire_async(send_name);
1305
- name('john');
1306
- const promise = name('jin');
1307
- $.$mol_after_mock_warp();
1308
- await promise;
1309
- $mol_assert_like(first, ['john', 'jin']);
1310
- $mol_assert_like(last, ['jin']);
1311
- },
1312
- });
1313
- })($ || ($ = {}));
1314
-
1315
1362
  ;
1316
1363
  "use strict";
1317
1364
  var $;