mol_conform 0.0.180 → 0.0.181

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
@@ -3805,6 +3805,53 @@ var $;
3805
3805
  });
3806
3806
  })($ || ($ = {}));
3807
3807
 
3808
+ ;
3809
+ "use strict";
3810
+ var $;
3811
+ (function ($) {
3812
+ function $mol_array_chunks(array, rule) {
3813
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
3814
+ let chunk = [];
3815
+ const chunks = [];
3816
+ for (let i = 0; i < array.length; ++i) {
3817
+ const item = array[i];
3818
+ if (br(item, i)) {
3819
+ if (chunk.length)
3820
+ chunks.push(chunk);
3821
+ chunk = [];
3822
+ }
3823
+ chunk.push(item);
3824
+ }
3825
+ if (chunk.length)
3826
+ chunks.push(chunk);
3827
+ return chunks;
3828
+ }
3829
+ $.$mol_array_chunks = $mol_array_chunks;
3830
+ })($ || ($ = {}));
3831
+
3832
+ ;
3833
+ "use strict";
3834
+ var $;
3835
+ (function ($) {
3836
+ $mol_test({
3837
+ 'empty array'() {
3838
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
3839
+ },
3840
+ 'one chunk'() {
3841
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
3842
+ },
3843
+ 'fixed size chunk'() {
3844
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
3845
+ },
3846
+ 'first empty chunk'() {
3847
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
3848
+ },
3849
+ 'chunk for every item'() {
3850
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
3851
+ },
3852
+ });
3853
+ })($ || ($ = {}));
3854
+
3808
3855
  ;
3809
3856
  "use strict";
3810
3857
  var $;
@@ -4002,7 +4049,9 @@ var $;
4002
4049
  }
4003
4050
  if (ArrayBuffer.isView(json)) {
4004
4051
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
4005
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
4052
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
4053
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
4054
+ return $mol_tree2.data(str, [], span);
4006
4055
  }
4007
4056
  if (json instanceof Date) {
4008
4057
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -4041,7 +4090,7 @@ var $;
4041
4090
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
4042
4091
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
4043
4092
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
4044
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
4093
+ $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');
4045
4094
  $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');
4046
4095
  $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');
4047
4096
  },