mol_dump_lib 0.0.943 → 0.0.945

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
@@ -1739,6 +1739,30 @@ var $;
1739
1739
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1740
1740
  })($ || ($ = {}));
1741
1741
 
1742
+ ;
1743
+ "use strict";
1744
+ var $;
1745
+ (function ($) {
1746
+ function $mol_array_chunks(array, rule) {
1747
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1748
+ let chunk = [];
1749
+ const chunks = [];
1750
+ for (let i = 0; i < array.length; ++i) {
1751
+ const item = array[i];
1752
+ if (br(item, i)) {
1753
+ if (chunk.length)
1754
+ chunks.push(chunk);
1755
+ chunk = [];
1756
+ }
1757
+ chunk.push(item);
1758
+ }
1759
+ if (chunk.length)
1760
+ chunks.push(chunk);
1761
+ return chunks;
1762
+ }
1763
+ $.$mol_array_chunks = $mol_array_chunks;
1764
+ })($ || ($ = {}));
1765
+
1742
1766
  ;
1743
1767
  "use strict";
1744
1768
  var $;
@@ -1759,7 +1783,9 @@ var $;
1759
1783
  }
1760
1784
  if (ArrayBuffer.isView(json)) {
1761
1785
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1762
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1786
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1787
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1788
+ return $mol_tree2.data(str, [], span);
1763
1789
  }
1764
1790
  if (json instanceof Date) {
1765
1791
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -3651,6 +3677,8 @@ var $;
3651
3677
  if (this.$.$mol_fail_catch(error)) {
3652
3678
  if (error.code === 'ENOENT')
3653
3679
  return null;
3680
+ if (error.code === 'EPERM')
3681
+ return null;
3654
3682
  error.message += '\n' + path;
3655
3683
  this.$.$mol_fail_hidden(error);
3656
3684
  }
@@ -7116,6 +7144,34 @@ var $;
7116
7144
  ($mol_mem(($.$mol_check.prototype), "Title"));
7117
7145
 
7118
7146
 
7147
+ ;
7148
+ "use strict";
7149
+ var $;
7150
+ (function ($) {
7151
+ class $mol_dom_event extends $mol_object {
7152
+ native;
7153
+ constructor(native) {
7154
+ super();
7155
+ this.native = native;
7156
+ }
7157
+ prevented(next) {
7158
+ if (next)
7159
+ this.native.preventDefault();
7160
+ return this.native.defaultPrevented;
7161
+ }
7162
+ static wrap(event) {
7163
+ return new this.$.$mol_dom_event(event);
7164
+ }
7165
+ }
7166
+ __decorate([
7167
+ $mol_action
7168
+ ], $mol_dom_event.prototype, "prevented", null);
7169
+ __decorate([
7170
+ $mol_action
7171
+ ], $mol_dom_event, "wrap", null);
7172
+ $.$mol_dom_event = $mol_dom_event;
7173
+ })($ || ($ = {}));
7174
+
7119
7175
  ;
7120
7176
  "use strict";
7121
7177
  var $;
@@ -7134,11 +7190,11 @@ var $;
7134
7190
  (function ($$) {
7135
7191
  class $mol_check extends $.$mol_check {
7136
7192
  click(next) {
7137
- if (next?.defaultPrevented)
7193
+ const event = next ? $mol_dom_event.wrap(next) : null;
7194
+ if (event?.prevented())
7138
7195
  return;
7196
+ event?.prevented(true);
7139
7197
  this.checked(!this.checked());
7140
- if (next)
7141
- next.preventDefault();
7142
7198
  }
7143
7199
  sub() {
7144
7200
  return [
package/node.test.js CHANGED
@@ -1730,6 +1730,30 @@ var $;
1730
1730
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1731
1731
  })($ || ($ = {}));
1732
1732
 
1733
+ ;
1734
+ "use strict";
1735
+ var $;
1736
+ (function ($) {
1737
+ function $mol_array_chunks(array, rule) {
1738
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1739
+ let chunk = [];
1740
+ const chunks = [];
1741
+ for (let i = 0; i < array.length; ++i) {
1742
+ const item = array[i];
1743
+ if (br(item, i)) {
1744
+ if (chunk.length)
1745
+ chunks.push(chunk);
1746
+ chunk = [];
1747
+ }
1748
+ chunk.push(item);
1749
+ }
1750
+ if (chunk.length)
1751
+ chunks.push(chunk);
1752
+ return chunks;
1753
+ }
1754
+ $.$mol_array_chunks = $mol_array_chunks;
1755
+ })($ || ($ = {}));
1756
+
1733
1757
  ;
1734
1758
  "use strict";
1735
1759
  var $;
@@ -1750,7 +1774,9 @@ var $;
1750
1774
  }
1751
1775
  if (ArrayBuffer.isView(json)) {
1752
1776
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1753
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1777
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1778
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1779
+ return $mol_tree2.data(str, [], span);
1754
1780
  }
1755
1781
  if (json instanceof Date) {
1756
1782
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -3642,6 +3668,8 @@ var $;
3642
3668
  if (this.$.$mol_fail_catch(error)) {
3643
3669
  if (error.code === 'ENOENT')
3644
3670
  return null;
3671
+ if (error.code === 'EPERM')
3672
+ return null;
3645
3673
  error.message += '\n' + path;
3646
3674
  this.$.$mol_fail_hidden(error);
3647
3675
  }
@@ -7107,6 +7135,34 @@ var $;
7107
7135
  ($mol_mem(($.$mol_check.prototype), "Title"));
7108
7136
 
7109
7137
 
7138
+ ;
7139
+ "use strict";
7140
+ var $;
7141
+ (function ($) {
7142
+ class $mol_dom_event extends $mol_object {
7143
+ native;
7144
+ constructor(native) {
7145
+ super();
7146
+ this.native = native;
7147
+ }
7148
+ prevented(next) {
7149
+ if (next)
7150
+ this.native.preventDefault();
7151
+ return this.native.defaultPrevented;
7152
+ }
7153
+ static wrap(event) {
7154
+ return new this.$.$mol_dom_event(event);
7155
+ }
7156
+ }
7157
+ __decorate([
7158
+ $mol_action
7159
+ ], $mol_dom_event.prototype, "prevented", null);
7160
+ __decorate([
7161
+ $mol_action
7162
+ ], $mol_dom_event, "wrap", null);
7163
+ $.$mol_dom_event = $mol_dom_event;
7164
+ })($ || ($ = {}));
7165
+
7110
7166
  ;
7111
7167
  "use strict";
7112
7168
  var $;
@@ -7125,11 +7181,11 @@ var $;
7125
7181
  (function ($$) {
7126
7182
  class $mol_check extends $.$mol_check {
7127
7183
  click(next) {
7128
- if (next?.defaultPrevented)
7184
+ const event = next ? $mol_dom_event.wrap(next) : null;
7185
+ if (event?.prevented())
7129
7186
  return;
7187
+ event?.prevented(true);
7130
7188
  this.checked(!this.checked());
7131
- if (next)
7132
- next.preventDefault();
7133
7189
  }
7134
7190
  sub() {
7135
7191
  return [
@@ -8108,6 +8164,29 @@ var $;
8108
8164
  });
8109
8165
  })($ || ($ = {}));
8110
8166
 
8167
+ ;
8168
+ "use strict";
8169
+ var $;
8170
+ (function ($) {
8171
+ $mol_test({
8172
+ 'empty array'() {
8173
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
8174
+ },
8175
+ 'one chunk'() {
8176
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
8177
+ },
8178
+ 'fixed size chunk'() {
8179
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
8180
+ },
8181
+ 'first empty chunk'() {
8182
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
8183
+ },
8184
+ 'chunk for every item'() {
8185
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
8186
+ },
8187
+ });
8188
+ })($ || ($ = {}));
8189
+
8111
8190
  ;
8112
8191
  "use strict";
8113
8192
  var $;
@@ -8187,7 +8266,7 @@ var $;
8187
8266
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
8188
8267
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
8189
8268
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
8190
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
8269
+ $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');
8191
8270
  $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');
8192
8271
  $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');
8193
8272
  },