mol_data_all 1.1.1702 → 1.1.1704

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
@@ -4058,6 +4058,53 @@ var $;
4058
4058
  });
4059
4059
  })($ || ($ = {}));
4060
4060
 
4061
+ ;
4062
+ "use strict";
4063
+ var $;
4064
+ (function ($) {
4065
+ function $mol_array_chunks(array, rule) {
4066
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
4067
+ let chunk = [];
4068
+ const chunks = [];
4069
+ for (let i = 0; i < array.length; ++i) {
4070
+ const item = array[i];
4071
+ if (br(item, i)) {
4072
+ if (chunk.length)
4073
+ chunks.push(chunk);
4074
+ chunk = [];
4075
+ }
4076
+ chunk.push(item);
4077
+ }
4078
+ if (chunk.length)
4079
+ chunks.push(chunk);
4080
+ return chunks;
4081
+ }
4082
+ $.$mol_array_chunks = $mol_array_chunks;
4083
+ })($ || ($ = {}));
4084
+
4085
+ ;
4086
+ "use strict";
4087
+ var $;
4088
+ (function ($) {
4089
+ $mol_test({
4090
+ 'empty array'() {
4091
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
4092
+ },
4093
+ 'one chunk'() {
4094
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
4095
+ },
4096
+ 'fixed size chunk'() {
4097
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
4098
+ },
4099
+ 'first empty chunk'() {
4100
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
4101
+ },
4102
+ 'chunk for every item'() {
4103
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
4104
+ },
4105
+ });
4106
+ })($ || ($ = {}));
4107
+
4061
4108
  ;
4062
4109
  "use strict";
4063
4110
  var $;
@@ -4255,7 +4302,9 @@ var $;
4255
4302
  }
4256
4303
  if (ArrayBuffer.isView(json)) {
4257
4304
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
4258
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
4305
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
4306
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
4307
+ return $mol_tree2.data(str, [], span);
4259
4308
  }
4260
4309
  if (json instanceof Date) {
4261
4310
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -4294,7 +4343,7 @@ var $;
4294
4343
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
4295
4344
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
4296
4345
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
4297
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
4346
+ $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');
4298
4347
  $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');
4299
4348
  $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');
4300
4349
  },