mol_charset_ucf 0.0.13 → 0.0.15
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 +51 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
package/node.test.js
CHANGED
|
@@ -845,6 +845,53 @@ var $;
|
|
|
845
845
|
});
|
|
846
846
|
})($ || ($ = {}));
|
|
847
847
|
|
|
848
|
+
;
|
|
849
|
+
"use strict";
|
|
850
|
+
var $;
|
|
851
|
+
(function ($) {
|
|
852
|
+
function $mol_array_chunks(array, rule) {
|
|
853
|
+
const br = typeof rule === 'number' ? (_, i) => i % rule === 0 : rule;
|
|
854
|
+
let chunk = [];
|
|
855
|
+
const chunks = [];
|
|
856
|
+
for (let i = 0; i < array.length; ++i) {
|
|
857
|
+
const item = array[i];
|
|
858
|
+
if (br(item, i)) {
|
|
859
|
+
if (chunk.length)
|
|
860
|
+
chunks.push(chunk);
|
|
861
|
+
chunk = [];
|
|
862
|
+
}
|
|
863
|
+
chunk.push(item);
|
|
864
|
+
}
|
|
865
|
+
if (chunk.length)
|
|
866
|
+
chunks.push(chunk);
|
|
867
|
+
return chunks;
|
|
868
|
+
}
|
|
869
|
+
$.$mol_array_chunks = $mol_array_chunks;
|
|
870
|
+
})($ || ($ = {}));
|
|
871
|
+
|
|
872
|
+
;
|
|
873
|
+
"use strict";
|
|
874
|
+
var $;
|
|
875
|
+
(function ($) {
|
|
876
|
+
$mol_test({
|
|
877
|
+
'empty array'() {
|
|
878
|
+
$mol_assert_equal($mol_array_chunks([], () => true), []);
|
|
879
|
+
},
|
|
880
|
+
'one chunk'() {
|
|
881
|
+
$mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => false), [[1, 2, 3, 4, 5]]);
|
|
882
|
+
},
|
|
883
|
+
'fixed size chunk'() {
|
|
884
|
+
$mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], 3), [[1, 2, 3], [4, 5]]);
|
|
885
|
+
},
|
|
886
|
+
'first empty chunk'() {
|
|
887
|
+
$mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], (_, i) => i === 0), [[1, 2, 3, 4, 5]]);
|
|
888
|
+
},
|
|
889
|
+
'chunk for every item'() {
|
|
890
|
+
$mol_assert_equal($mol_array_chunks([1, 2, 3, 4, 5], () => true), [[1], [2], [3], [4], [5]]);
|
|
891
|
+
},
|
|
892
|
+
});
|
|
893
|
+
})($ || ($ = {}));
|
|
894
|
+
|
|
848
895
|
;
|
|
849
896
|
"use strict";
|
|
850
897
|
var $;
|
|
@@ -1362,7 +1409,9 @@ var $;
|
|
|
1362
1409
|
}
|
|
1363
1410
|
if (ArrayBuffer.isView(json)) {
|
|
1364
1411
|
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1365
|
-
|
|
1412
|
+
const codes = [...buf].map(b => b.toString(16).toUpperCase().padStart(2, '0'));
|
|
1413
|
+
const str = $mol_array_chunks(codes, 8).map(c => c.join(' ')).join('\n');
|
|
1414
|
+
return $mol_tree2.data(str, [], span);
|
|
1366
1415
|
}
|
|
1367
1416
|
if (json instanceof Date) {
|
|
1368
1417
|
return new $mol_tree2('', json.toISOString(), [], span);
|
|
@@ -1401,7 +1450,7 @@ var $;
|
|
|
1401
1450
|
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
|
1402
1451
|
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1403
1452
|
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1404
|
-
$mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '
|
|
1453
|
+
$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');
|
|
1405
1454
|
$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');
|
|
1406
1455
|
$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');
|
|
1407
1456
|
},
|