mol_wire_lib 1.0.185 → 1.0.188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node.test.js CHANGED
@@ -1185,6 +1185,8 @@ var $;
1185
1185
  var $;
1186
1186
  (function ($) {
1187
1187
  function $mol_wire_async(obj) {
1188
+ let fiber;
1189
+ const temp = $mol_wire_task.getter(obj);
1188
1190
  return new Proxy(obj, {
1189
1191
  get(obj, field) {
1190
1192
  const val = obj[field];
@@ -1199,8 +1201,8 @@ var $;
1199
1201
  };
1200
1202
  },
1201
1203
  apply(obj, self, args) {
1202
- const temp = $mol_wire_task.getter(obj);
1203
- const fiber = temp(self, args);
1204
+ fiber?.destructor();
1205
+ fiber = temp(self, args);
1204
1206
  return fiber.async();
1205
1207
  },
1206
1208
  });
@@ -2906,42 +2908,6 @@ var $;
2906
2908
  ;
2907
2909
  "use strict";
2908
2910
  var $;
2909
- (function ($_1) {
2910
- $mol_test({
2911
- async 'Latest Calls Wins on Concurrency'($) {
2912
- class NameLogger extends $mol_object2 {
2913
- static $ = $;
2914
- static first = [];
2915
- static last = [];
2916
- static send(next) {
2917
- $mol_wire_sync(this.first).push(next);
2918
- this.$.$mol_wait_timeout(0);
2919
- this.last.push(next);
2920
- }
2921
- }
2922
- const name = $mol_wire_async(NameLogger).send;
2923
- name('john');
2924
- const promise = name('jin');
2925
- $.$mol_after_mock_warp();
2926
- await promise;
2927
- $mol_assert_like(NameLogger.first, ['john', 'jin']);
2928
- $mol_assert_like(NameLogger.last, ['jin']);
2929
- },
2930
- async 'Wrap function'($) {
2931
- const name = $mol_wire_async(function (name) {
2932
- $.$mol_wait_timeout(0);
2933
- return name;
2934
- });
2935
- const promise = name('jin');
2936
- $.$mol_after_mock_warp();
2937
- $mol_assert_like(await promise, 'jin');
2938
- },
2939
- });
2940
- })($ || ($ = {}));
2941
- //mol/wire/async/async.test.ts
2942
- ;
2943
- "use strict";
2944
- var $;
2945
2911
  (function ($_1) {
2946
2912
  $mol_test_mocks.push($ => {
2947
2913
  $.$mol_after_frame = $mol_after_mock_commmon;
@@ -3033,6 +2999,49 @@ var $;
3033
2999
  ;
3034
3000
  "use strict";
3035
3001
  var $;
3002
+ (function ($_1) {
3003
+ $mol_test({
3004
+ async 'Latest method calls wins'($) {
3005
+ class NameLogger extends $mol_object2 {
3006
+ static $ = $;
3007
+ static first = [];
3008
+ static last = [];
3009
+ static send(next) {
3010
+ $mol_wire_sync(this.first).push(next);
3011
+ this.$.$mol_wait_timeout(0);
3012
+ this.last.push(next);
3013
+ }
3014
+ }
3015
+ const name = $mol_wire_async(NameLogger).send;
3016
+ name('john');
3017
+ const promise = name('jin');
3018
+ $.$mol_after_mock_warp();
3019
+ await promise;
3020
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
3021
+ $mol_assert_like(NameLogger.last, ['jin']);
3022
+ },
3023
+ async 'Latest function calls wins'($) {
3024
+ const first = [];
3025
+ const last = [];
3026
+ function send_name(next) {
3027
+ $mol_wire_sync(first).push(next);
3028
+ $.$mol_wait_timeout(0);
3029
+ last.push(next);
3030
+ }
3031
+ const name = $mol_wire_async(send_name);
3032
+ name('john');
3033
+ const promise = name('jin');
3034
+ $.$mol_after_mock_warp();
3035
+ await promise;
3036
+ $mol_assert_like(first, ['john', 'jin']);
3037
+ $mol_assert_like(last, ['jin']);
3038
+ },
3039
+ });
3040
+ })($ || ($ = {}));
3041
+ //mol/wire/async/async.test.ts
3042
+ ;
3043
+ "use strict";
3044
+ var $;
3036
3045
  (function ($_1) {
3037
3046
  $mol_test({
3038
3047
  'Cached channel'($) {