mam 1.11.838 → 1.11.840

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
@@ -1531,6 +1531,30 @@ var $;
1531
1531
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1532
1532
  })($ || ($ = {}));
1533
1533
 
1534
+ ;
1535
+ "use strict";
1536
+ var $;
1537
+ (function ($) {
1538
+ function $mol_array_chunks(array, rule) {
1539
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1540
+ let chunk = [];
1541
+ const chunks = [];
1542
+ for (let i = 0; i < array.length; ++i) {
1543
+ const item = array[i];
1544
+ if (br(item, i)) {
1545
+ if (chunk.length)
1546
+ chunks.push(chunk);
1547
+ chunk = [];
1548
+ }
1549
+ chunk.push(item);
1550
+ }
1551
+ if (chunk.length)
1552
+ chunks.push(chunk);
1553
+ return chunks;
1554
+ }
1555
+ $.$mol_array_chunks = $mol_array_chunks;
1556
+ })($ || ($ = {}));
1557
+
1534
1558
  ;
1535
1559
  "use strict";
1536
1560
  var $;
@@ -1551,7 +1575,9 @@ var $;
1551
1575
  }
1552
1576
  if (ArrayBuffer.isView(json)) {
1553
1577
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1554
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1578
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1579
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1580
+ return $mol_tree2.data(str, [], span);
1555
1581
  }
1556
1582
  if (json instanceof Date) {
1557
1583
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -3175,6 +3201,8 @@ var $;
3175
3201
  if (this.$.$mol_fail_catch(error)) {
3176
3202
  if (error.code === 'ENOENT')
3177
3203
  return null;
3204
+ if (error.code === 'EPERM')
3205
+ return null;
3178
3206
  error.message += '\n' + path;
3179
3207
  this.$.$mol_fail_hidden(error);
3180
3208
  }
package/node.test.js CHANGED
@@ -1522,6 +1522,30 @@ var $;
1522
1522
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1523
1523
  })($ || ($ = {}));
1524
1524
 
1525
+ ;
1526
+ "use strict";
1527
+ var $;
1528
+ (function ($) {
1529
+ function $mol_array_chunks(array, rule) {
1530
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1531
+ let chunk = [];
1532
+ const chunks = [];
1533
+ for (let i = 0; i < array.length; ++i) {
1534
+ const item = array[i];
1535
+ if (br(item, i)) {
1536
+ if (chunk.length)
1537
+ chunks.push(chunk);
1538
+ chunk = [];
1539
+ }
1540
+ chunk.push(item);
1541
+ }
1542
+ if (chunk.length)
1543
+ chunks.push(chunk);
1544
+ return chunks;
1545
+ }
1546
+ $.$mol_array_chunks = $mol_array_chunks;
1547
+ })($ || ($ = {}));
1548
+
1525
1549
  ;
1526
1550
  "use strict";
1527
1551
  var $;
@@ -1542,7 +1566,9 @@ var $;
1542
1566
  }
1543
1567
  if (ArrayBuffer.isView(json)) {
1544
1568
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1545
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1569
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1570
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1571
+ return $mol_tree2.data(str, [], span);
1546
1572
  }
1547
1573
  if (json instanceof Date) {
1548
1574
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -3166,6 +3192,8 @@ var $;
3166
3192
  if (this.$.$mol_fail_catch(error)) {
3167
3193
  if (error.code === 'ENOENT')
3168
3194
  return null;
3195
+ if (error.code === 'EPERM')
3196
+ return null;
3169
3197
  error.message += '\n' + path;
3170
3198
  this.$.$mol_fail_hidden(error);
3171
3199
  }
@@ -9233,6 +9261,29 @@ var $;
9233
9261
  });
9234
9262
  })($ || ($ = {}));
9235
9263
 
9264
+ ;
9265
+ "use strict";
9266
+ var $;
9267
+ (function ($) {
9268
+ $mol_test({
9269
+ 'empty array'() {
9270
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
9271
+ },
9272
+ 'one chunk'() {
9273
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
9274
+ },
9275
+ 'fixed size chunk'() {
9276
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
9277
+ },
9278
+ 'first empty chunk'() {
9279
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
9280
+ },
9281
+ 'chunk for every item'() {
9282
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
9283
+ },
9284
+ });
9285
+ })($ || ($ = {}));
9286
+
9236
9287
  ;
9237
9288
  "use strict";
9238
9289
  var $;
@@ -9312,7 +9363,7 @@ var $;
9312
9363
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
9313
9364
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
9314
9365
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
9315
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
9366
+ $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');
9316
9367
  $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');
9317
9368
  $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');
9318
9369
  },