mam 1.11.756 → 1.11.757

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.mjs CHANGED
@@ -2337,6 +2337,69 @@ var $;
2337
2337
  $.$mol_charset_decode = $mol_charset_decode;
2338
2338
  })($ || ($ = {}));
2339
2339
 
2340
+ ;
2341
+ "use strict";
2342
+ var $;
2343
+ (function ($) {
2344
+ let buf = new Uint8Array(2 ** 12);
2345
+ function $mol_charset_encode(str) {
2346
+ const capacity = str.length * 3;
2347
+ if (buf.byteLength < capacity)
2348
+ buf = new Uint8Array(capacity);
2349
+ return buf.slice(0, $mol_charset_encode_to(str, buf));
2350
+ }
2351
+ $.$mol_charset_encode = $mol_charset_encode;
2352
+ function $mol_charset_encode_to(str, buf, from = 0) {
2353
+ let pos = from;
2354
+ for (let i = 0; i < str.length; i++) {
2355
+ let code = str.charCodeAt(i);
2356
+ if (code < 0x80) {
2357
+ buf[pos++] = code;
2358
+ }
2359
+ else if (code < 0x800) {
2360
+ buf[pos++] = 0xc0 | (code >> 6);
2361
+ buf[pos++] = 0x80 | (code & 0x3f);
2362
+ }
2363
+ else if (code < 0xd800 || code >= 0xe000) {
2364
+ buf[pos++] = 0xe0 | (code >> 12);
2365
+ buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
2366
+ buf[pos++] = 0x80 | (code & 0x3f);
2367
+ }
2368
+ else {
2369
+ const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
2370
+ buf[pos++] = 0xf0 | (point >> 18);
2371
+ buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
2372
+ buf[pos++] = 0x80 | ((point >> 6) & 0x3f);
2373
+ buf[pos++] = 0x80 | (point & 0x3f);
2374
+ }
2375
+ }
2376
+ return pos - from;
2377
+ }
2378
+ $.$mol_charset_encode_to = $mol_charset_encode_to;
2379
+ })($ || ($ = {}));
2380
+
2381
+ ;
2382
+ "use strict";
2383
+ var $;
2384
+ (function ($) {
2385
+ class $mol_file_transaction extends $mol_object {
2386
+ path() { return ''; }
2387
+ modes() { return []; }
2388
+ write(options) {
2389
+ return 0;
2390
+ }
2391
+ read() {
2392
+ return new Uint8Array();
2393
+ }
2394
+ truncate(size) { }
2395
+ close() { }
2396
+ destructor() {
2397
+ this.close();
2398
+ }
2399
+ }
2400
+ $.$mol_file_transaction = $mol_file_transaction;
2401
+ })($ || ($ = {}));
2402
+
2340
2403
  ;
2341
2404
  "use strict";
2342
2405
 
@@ -2392,6 +2455,24 @@ require = (req => Object.assign(function require(name) {
2392
2455
  return $node[name];
2393
2456
  }, req))(require);
2394
2457
 
2458
+ ;
2459
+ "use strict";
2460
+ var $;
2461
+ (function ($) {
2462
+ function $mol_wire_solid() {
2463
+ let current = $mol_wire_auto();
2464
+ if (current.temp)
2465
+ current = current.host;
2466
+ if (current.reap !== nothing) {
2467
+ current?.sub_on(sub, sub.data.length);
2468
+ }
2469
+ current.reap = nothing;
2470
+ }
2471
+ $.$mol_wire_solid = $mol_wire_solid;
2472
+ const nothing = () => { };
2473
+ const sub = new $mol_wire_pub_sub;
2474
+ })($ || ($ = {}));
2475
+
2395
2476
  ;
2396
2477
  "use strict";
2397
2478
  var $;
@@ -2590,58 +2671,6 @@ var $;
2590
2671
  $.$mol_exec = $mol_exec;
2591
2672
  })($ || ($ = {}));
2592
2673
 
2593
- ;
2594
- "use strict";
2595
- var $;
2596
- (function ($) {
2597
- const TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder;
2598
- const encoder = new TextEncoder();
2599
- function $mol_charset_encode(value) {
2600
- return encoder.encode(value);
2601
- }
2602
- $.$mol_charset_encode = $mol_charset_encode;
2603
- })($ || ($ = {}));
2604
-
2605
- ;
2606
- "use strict";
2607
- var $;
2608
- (function ($) {
2609
- class $mol_file_transaction extends $mol_object {
2610
- path() { return ''; }
2611
- modes() { return []; }
2612
- write(options) {
2613
- return 0;
2614
- }
2615
- read() {
2616
- return new Uint8Array();
2617
- }
2618
- truncate(size) { }
2619
- close() { }
2620
- destructor() {
2621
- this.close();
2622
- }
2623
- }
2624
- $.$mol_file_transaction = $mol_file_transaction;
2625
- })($ || ($ = {}));
2626
-
2627
- ;
2628
- "use strict";
2629
- var $;
2630
- (function ($) {
2631
- function $mol_wire_solid() {
2632
- let current = $mol_wire_auto();
2633
- if (current.temp)
2634
- current = current.host;
2635
- if (current.reap !== nothing) {
2636
- current?.sub_on(sub, sub.data.length);
2637
- }
2638
- current.reap = nothing;
2639
- }
2640
- $.$mol_wire_solid = $mol_wire_solid;
2641
- const nothing = () => { };
2642
- const sub = new $mol_wire_pub_sub;
2643
- })($ || ($ = {}));
2644
-
2645
2674
  ;
2646
2675
  "use strict";
2647
2676
  var $;
package/node.test.js CHANGED
@@ -2328,6 +2328,69 @@ var $;
2328
2328
  $.$mol_charset_decode = $mol_charset_decode;
2329
2329
  })($ || ($ = {}));
2330
2330
 
2331
+ ;
2332
+ "use strict";
2333
+ var $;
2334
+ (function ($) {
2335
+ let buf = new Uint8Array(2 ** 12);
2336
+ function $mol_charset_encode(str) {
2337
+ const capacity = str.length * 3;
2338
+ if (buf.byteLength < capacity)
2339
+ buf = new Uint8Array(capacity);
2340
+ return buf.slice(0, $mol_charset_encode_to(str, buf));
2341
+ }
2342
+ $.$mol_charset_encode = $mol_charset_encode;
2343
+ function $mol_charset_encode_to(str, buf, from = 0) {
2344
+ let pos = from;
2345
+ for (let i = 0; i < str.length; i++) {
2346
+ let code = str.charCodeAt(i);
2347
+ if (code < 0x80) {
2348
+ buf[pos++] = code;
2349
+ }
2350
+ else if (code < 0x800) {
2351
+ buf[pos++] = 0xc0 | (code >> 6);
2352
+ buf[pos++] = 0x80 | (code & 0x3f);
2353
+ }
2354
+ else if (code < 0xd800 || code >= 0xe000) {
2355
+ buf[pos++] = 0xe0 | (code >> 12);
2356
+ buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
2357
+ buf[pos++] = 0x80 | (code & 0x3f);
2358
+ }
2359
+ else {
2360
+ const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
2361
+ buf[pos++] = 0xf0 | (point >> 18);
2362
+ buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
2363
+ buf[pos++] = 0x80 | ((point >> 6) & 0x3f);
2364
+ buf[pos++] = 0x80 | (point & 0x3f);
2365
+ }
2366
+ }
2367
+ return pos - from;
2368
+ }
2369
+ $.$mol_charset_encode_to = $mol_charset_encode_to;
2370
+ })($ || ($ = {}));
2371
+
2372
+ ;
2373
+ "use strict";
2374
+ var $;
2375
+ (function ($) {
2376
+ class $mol_file_transaction extends $mol_object {
2377
+ path() { return ''; }
2378
+ modes() { return []; }
2379
+ write(options) {
2380
+ return 0;
2381
+ }
2382
+ read() {
2383
+ return new Uint8Array();
2384
+ }
2385
+ truncate(size) { }
2386
+ close() { }
2387
+ destructor() {
2388
+ this.close();
2389
+ }
2390
+ }
2391
+ $.$mol_file_transaction = $mol_file_transaction;
2392
+ })($ || ($ = {}));
2393
+
2331
2394
  ;
2332
2395
  "use strict";
2333
2396
 
@@ -2383,6 +2446,24 @@ require = (req => Object.assign(function require(name) {
2383
2446
  return $node[name];
2384
2447
  }, req))(require);
2385
2448
 
2449
+ ;
2450
+ "use strict";
2451
+ var $;
2452
+ (function ($) {
2453
+ function $mol_wire_solid() {
2454
+ let current = $mol_wire_auto();
2455
+ if (current.temp)
2456
+ current = current.host;
2457
+ if (current.reap !== nothing) {
2458
+ current?.sub_on(sub, sub.data.length);
2459
+ }
2460
+ current.reap = nothing;
2461
+ }
2462
+ $.$mol_wire_solid = $mol_wire_solid;
2463
+ const nothing = () => { };
2464
+ const sub = new $mol_wire_pub_sub;
2465
+ })($ || ($ = {}));
2466
+
2386
2467
  ;
2387
2468
  "use strict";
2388
2469
  var $;
@@ -2581,58 +2662,6 @@ var $;
2581
2662
  $.$mol_exec = $mol_exec;
2582
2663
  })($ || ($ = {}));
2583
2664
 
2584
- ;
2585
- "use strict";
2586
- var $;
2587
- (function ($) {
2588
- const TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder;
2589
- const encoder = new TextEncoder();
2590
- function $mol_charset_encode(value) {
2591
- return encoder.encode(value);
2592
- }
2593
- $.$mol_charset_encode = $mol_charset_encode;
2594
- })($ || ($ = {}));
2595
-
2596
- ;
2597
- "use strict";
2598
- var $;
2599
- (function ($) {
2600
- class $mol_file_transaction extends $mol_object {
2601
- path() { return ''; }
2602
- modes() { return []; }
2603
- write(options) {
2604
- return 0;
2605
- }
2606
- read() {
2607
- return new Uint8Array();
2608
- }
2609
- truncate(size) { }
2610
- close() { }
2611
- destructor() {
2612
- this.close();
2613
- }
2614
- }
2615
- $.$mol_file_transaction = $mol_file_transaction;
2616
- })($ || ($ = {}));
2617
-
2618
- ;
2619
- "use strict";
2620
- var $;
2621
- (function ($) {
2622
- function $mol_wire_solid() {
2623
- let current = $mol_wire_auto();
2624
- if (current.temp)
2625
- current = current.host;
2626
- if (current.reap !== nothing) {
2627
- current?.sub_on(sub, sub.data.length);
2628
- }
2629
- current.reap = nothing;
2630
- }
2631
- $.$mol_wire_solid = $mol_wire_solid;
2632
- const nothing = () => { };
2633
- const sub = new $mol_wire_pub_sub;
2634
- })($ || ($ = {}));
2635
-
2636
2665
  ;
2637
2666
  "use strict";
2638
2667
  var $;
@@ -10291,10 +10320,23 @@ var $;
10291
10320
  var $;
10292
10321
  (function ($) {
10293
10322
  $mol_test({
10294
- 'encode utf8 string'() {
10295
- const str = 'Hello, ΧΨΩЫ';
10296
- const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
10297
- $mol_assert_like($mol_charset_encode(str), encoded);
10323
+ 'encode empty'() {
10324
+ $mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
10325
+ },
10326
+ 'encode 1 octet'() {
10327
+ $mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
10328
+ },
10329
+ 'encode 2 octet'() {
10330
+ $mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
10331
+ },
10332
+ 'encode 3 octet'() {
10333
+ $mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
10334
+ },
10335
+ 'encode 4 octet'() {
10336
+ $mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
10337
+ },
10338
+ 'encode surrogate pair'() {
10339
+ $mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
10298
10340
  },
10299
10341
  });
10300
10342
  })($ || ($ = {}));