mol_regexp 0.0.1752 → 0.0.1754

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
@@ -4002,6 +4002,53 @@ var $;
4002
4002
  });
4003
4003
  })($ || ($ = {}));
4004
4004
 
4005
+ ;
4006
+ "use strict";
4007
+ var $;
4008
+ (function ($) {
4009
+ function $mol_array_chunks(array, rule) {
4010
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
4011
+ let chunk = [];
4012
+ const chunks = [];
4013
+ for (let i = 0; i < array.length; ++i) {
4014
+ const item = array[i];
4015
+ if (br(item, i)) {
4016
+ if (chunk.length)
4017
+ chunks.push(chunk);
4018
+ chunk = [];
4019
+ }
4020
+ chunk.push(item);
4021
+ }
4022
+ if (chunk.length)
4023
+ chunks.push(chunk);
4024
+ return chunks;
4025
+ }
4026
+ $.$mol_array_chunks = $mol_array_chunks;
4027
+ })($ || ($ = {}));
4028
+
4029
+ ;
4030
+ "use strict";
4031
+ var $;
4032
+ (function ($) {
4033
+ $mol_test({
4034
+ 'empty array'() {
4035
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
4036
+ },
4037
+ 'one chunk'() {
4038
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
4039
+ },
4040
+ 'fixed size chunk'() {
4041
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
4042
+ },
4043
+ 'first empty chunk'() {
4044
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
4045
+ },
4046
+ 'chunk for every item'() {
4047
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
4048
+ },
4049
+ });
4050
+ })($ || ($ = {}));
4051
+
4005
4052
  ;
4006
4053
  "use strict";
4007
4054
  var $;
@@ -4199,7 +4246,9 @@ var $;
4199
4246
  }
4200
4247
  if (ArrayBuffer.isView(json)) {
4201
4248
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
4202
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
4249
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
4250
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
4251
+ return $mol_tree2.data(str, [], span);
4203
4252
  }
4204
4253
  if (json instanceof Date) {
4205
4254
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -4238,7 +4287,7 @@ var $;
4238
4287
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
4239
4288
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
4240
4289
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
4241
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
4290
+ $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');
4242
4291
  $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');
4243
4292
  $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');
4244
4293
  },