mol_wire_dom 0.0.1637 → 0.0.1639

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
@@ -1614,6 +1614,30 @@ var $;
1614
1614
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1615
1615
  })($ || ($ = {}));
1616
1616
 
1617
+ ;
1618
+ "use strict";
1619
+ var $;
1620
+ (function ($) {
1621
+ function $mol_array_chunks(array, rule) {
1622
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1623
+ let chunk = [];
1624
+ const chunks = [];
1625
+ for (let i = 0; i < array.length; ++i) {
1626
+ const item = array[i];
1627
+ if (br(item, i)) {
1628
+ if (chunk.length)
1629
+ chunks.push(chunk);
1630
+ chunk = [];
1631
+ }
1632
+ chunk.push(item);
1633
+ }
1634
+ if (chunk.length)
1635
+ chunks.push(chunk);
1636
+ return chunks;
1637
+ }
1638
+ $.$mol_array_chunks = $mol_array_chunks;
1639
+ })($ || ($ = {}));
1640
+
1617
1641
  ;
1618
1642
  "use strict";
1619
1643
  var $;
@@ -1634,7 +1658,9 @@ var $;
1634
1658
  }
1635
1659
  if (ArrayBuffer.isView(json)) {
1636
1660
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1637
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1661
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1662
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1663
+ return $mol_tree2.data(str, [], span);
1638
1664
  }
1639
1665
  if (json instanceof Date) {
1640
1666
  return new $mol_tree2('', json.toISOString(), [], span);
package/node.test.js CHANGED
@@ -1605,6 +1605,30 @@ var $;
1605
1605
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1606
1606
  })($ || ($ = {}));
1607
1607
 
1608
+ ;
1609
+ "use strict";
1610
+ var $;
1611
+ (function ($) {
1612
+ function $mol_array_chunks(array, rule) {
1613
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1614
+ let chunk = [];
1615
+ const chunks = [];
1616
+ for (let i = 0; i < array.length; ++i) {
1617
+ const item = array[i];
1618
+ if (br(item, i)) {
1619
+ if (chunk.length)
1620
+ chunks.push(chunk);
1621
+ chunk = [];
1622
+ }
1623
+ chunk.push(item);
1624
+ }
1625
+ if (chunk.length)
1626
+ chunks.push(chunk);
1627
+ return chunks;
1628
+ }
1629
+ $.$mol_array_chunks = $mol_array_chunks;
1630
+ })($ || ($ = {}));
1631
+
1608
1632
  ;
1609
1633
  "use strict";
1610
1634
  var $;
@@ -1625,7 +1649,9 @@ var $;
1625
1649
  }
1626
1650
  if (ArrayBuffer.isView(json)) {
1627
1651
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1628
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1652
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1653
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1654
+ return $mol_tree2.data(str, [], span);
1629
1655
  }
1630
1656
  if (json instanceof Date) {
1631
1657
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -3883,6 +3909,29 @@ var $;
3883
3909
  });
3884
3910
  })($ || ($ = {}));
3885
3911
 
3912
+ ;
3913
+ "use strict";
3914
+ var $;
3915
+ (function ($) {
3916
+ $mol_test({
3917
+ 'empty array'() {
3918
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
3919
+ },
3920
+ 'one chunk'() {
3921
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
3922
+ },
3923
+ 'fixed size chunk'() {
3924
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
3925
+ },
3926
+ 'first empty chunk'() {
3927
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
3928
+ },
3929
+ 'chunk for every item'() {
3930
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
3931
+ },
3932
+ });
3933
+ })($ || ($ = {}));
3934
+
3886
3935
  ;
3887
3936
  "use strict";
3888
3937
  var $;
@@ -3962,7 +4011,7 @@ var $;
3962
4011
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
3963
4012
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
3964
4013
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
3965
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
4014
+ $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 255, 256, 65535])).toString(), '\\01 00 0A 00 FF 00 00 01\n\\FF FF\n');
3966
4015
  $mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
3967
4016
  $mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
3968
4017
  },