mol_crypto_lib 0.1.1732 → 0.1.1734

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
@@ -1919,6 +1919,30 @@ var $;
1919
1919
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1920
1920
  })($ || ($ = {}));
1921
1921
 
1922
+ ;
1923
+ "use strict";
1924
+ var $;
1925
+ (function ($) {
1926
+ function $mol_array_chunks(array, rule) {
1927
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1928
+ let chunk = [];
1929
+ const chunks = [];
1930
+ for (let i = 0; i < array.length; ++i) {
1931
+ const item = array[i];
1932
+ if (br(item, i)) {
1933
+ if (chunk.length)
1934
+ chunks.push(chunk);
1935
+ chunk = [];
1936
+ }
1937
+ chunk.push(item);
1938
+ }
1939
+ if (chunk.length)
1940
+ chunks.push(chunk);
1941
+ return chunks;
1942
+ }
1943
+ $.$mol_array_chunks = $mol_array_chunks;
1944
+ })($ || ($ = {}));
1945
+
1922
1946
  ;
1923
1947
  "use strict";
1924
1948
  var $;
@@ -1939,7 +1963,9 @@ var $;
1939
1963
  }
1940
1964
  if (ArrayBuffer.isView(json)) {
1941
1965
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1942
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1966
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1967
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1968
+ return $mol_tree2.data(str, [], span);
1943
1969
  }
1944
1970
  if (json instanceof Date) {
1945
1971
  return new $mol_tree2('', json.toISOString(), [], span);
package/node.test.js CHANGED
@@ -1910,6 +1910,30 @@ var $;
1910
1910
  $.$mol_tree2_from_string = $mol_tree2_from_string;
1911
1911
  })($ || ($ = {}));
1912
1912
 
1913
+ ;
1914
+ "use strict";
1915
+ var $;
1916
+ (function ($) {
1917
+ function $mol_array_chunks(array, rule) {
1918
+ const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
1919
+ let chunk = [];
1920
+ const chunks = [];
1921
+ for (let i = 0; i < array.length; ++i) {
1922
+ const item = array[i];
1923
+ if (br(item, i)) {
1924
+ if (chunk.length)
1925
+ chunks.push(chunk);
1926
+ chunk = [];
1927
+ }
1928
+ chunk.push(item);
1929
+ }
1930
+ if (chunk.length)
1931
+ chunks.push(chunk);
1932
+ return chunks;
1933
+ }
1934
+ $.$mol_array_chunks = $mol_array_chunks;
1935
+ })($ || ($ = {}));
1936
+
1913
1937
  ;
1914
1938
  "use strict";
1915
1939
  var $;
@@ -1930,7 +1954,9 @@ var $;
1930
1954
  }
1931
1955
  if (ArrayBuffer.isView(json)) {
1932
1956
  const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1933
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1957
+ const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
1958
+ const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
1959
+ return $mol_tree2.data(str, [], span);
1934
1960
  }
1935
1961
  if (json instanceof Date) {
1936
1962
  return new $mol_tree2('', json.toISOString(), [], span);
@@ -4706,6 +4732,29 @@ var $;
4706
4732
  });
4707
4733
  })($ || ($ = {}));
4708
4734
 
4735
+ ;
4736
+ "use strict";
4737
+ var $;
4738
+ (function ($) {
4739
+ $mol_test({
4740
+ 'empty array'() {
4741
+ $mol_assert_equal($mol_array_chunks([], () => true), []);
4742
+ },
4743
+ 'one chunk'() {
4744
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
4745
+ },
4746
+ 'fixed size chunk'() {
4747
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
4748
+ },
4749
+ 'first empty chunk'() {
4750
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
4751
+ },
4752
+ 'chunk for every item'() {
4753
+ $mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
4754
+ },
4755
+ });
4756
+ })($ || ($ = {}));
4757
+
4709
4758
  ;
4710
4759
  "use strict";
4711
4760
  var $;
@@ -4785,7 +4834,7 @@ var $;
4785
4834
  $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
4786
4835
  $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
4787
4836
  $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
4788
- $mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
4837
+ $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');
4789
4838
  $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');
4790
4839
  $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');
4791
4840
  },