mol_view_tree2_lib 1.0.37 → 1.0.38
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.d.ts +2 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +33 -4
- package/node.js.map +1 -1
- package/node.mjs +33 -4
- package/node.test.js +50 -8
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +2 -3
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +33 -11
- package/web.js.map +1 -1
- package/web.mjs +33 -11
- package/web.test.js +17 -4
- package/web.test.js.map +1 -1
package/web.mjs
CHANGED
|
@@ -4083,23 +4083,45 @@ var $;
|
|
|
4083
4083
|
$.$mol_charset_decode = $mol_charset_decode;
|
|
4084
4084
|
})($ || ($ = {}));
|
|
4085
4085
|
|
|
4086
|
-
;
|
|
4087
|
-
"use strict";
|
|
4088
|
-
|
|
4089
|
-
;
|
|
4090
|
-
"use strict";
|
|
4091
|
-
var $node = $node || {};
|
|
4092
|
-
|
|
4093
4086
|
;
|
|
4094
4087
|
"use strict";
|
|
4095
4088
|
var $;
|
|
4096
4089
|
(function ($) {
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4090
|
+
let buf = new Uint8Array(2 ** 12);
|
|
4091
|
+
function $mol_charset_encode(str) {
|
|
4092
|
+
const capacity = str.length * 3;
|
|
4093
|
+
if (buf.byteLength < capacity)
|
|
4094
|
+
buf = new Uint8Array(capacity);
|
|
4095
|
+
return buf.slice(0, $mol_charset_encode_to(str, buf));
|
|
4101
4096
|
}
|
|
4102
4097
|
$.$mol_charset_encode = $mol_charset_encode;
|
|
4098
|
+
function $mol_charset_encode_to(str, buf, from = 0) {
|
|
4099
|
+
let pos = from;
|
|
4100
|
+
for (let i = 0; i < str.length; i++) {
|
|
4101
|
+
let code = str.charCodeAt(i);
|
|
4102
|
+
if (code < 0x80) {
|
|
4103
|
+
buf[pos++] = code;
|
|
4104
|
+
}
|
|
4105
|
+
else if (code < 0x800) {
|
|
4106
|
+
buf[pos++] = 0xc0 | (code >> 6);
|
|
4107
|
+
buf[pos++] = 0x80 | (code & 0x3f);
|
|
4108
|
+
}
|
|
4109
|
+
else if (code < 0xd800 || code >= 0xe000) {
|
|
4110
|
+
buf[pos++] = 0xe0 | (code >> 12);
|
|
4111
|
+
buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
|
|
4112
|
+
buf[pos++] = 0x80 | (code & 0x3f);
|
|
4113
|
+
}
|
|
4114
|
+
else {
|
|
4115
|
+
const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
4116
|
+
buf[pos++] = 0xf0 | (point >> 18);
|
|
4117
|
+
buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
|
|
4118
|
+
buf[pos++] = 0x80 | ((point >> 6) & 0x3f);
|
|
4119
|
+
buf[pos++] = 0x80 | (point & 0x3f);
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
return pos - from;
|
|
4123
|
+
}
|
|
4124
|
+
$.$mol_charset_encode_to = $mol_charset_encode_to;
|
|
4103
4125
|
})($ || ($ = {}));
|
|
4104
4126
|
|
|
4105
4127
|
;
|
package/web.test.js
CHANGED
|
@@ -5994,10 +5994,23 @@ var $;
|
|
|
5994
5994
|
var $;
|
|
5995
5995
|
(function ($) {
|
|
5996
5996
|
$mol_test({
|
|
5997
|
-
'encode
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
5997
|
+
'encode empty'() {
|
|
5998
|
+
$mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
|
|
5999
|
+
},
|
|
6000
|
+
'encode 1 octet'() {
|
|
6001
|
+
$mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
|
|
6002
|
+
},
|
|
6003
|
+
'encode 2 octet'() {
|
|
6004
|
+
$mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
|
|
6005
|
+
},
|
|
6006
|
+
'encode 3 octet'() {
|
|
6007
|
+
$mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
|
|
6008
|
+
},
|
|
6009
|
+
'encode 4 octet'() {
|
|
6010
|
+
$mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
|
|
6011
|
+
},
|
|
6012
|
+
'encode surrogate pair'() {
|
|
6013
|
+
$mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
|
|
6001
6014
|
},
|
|
6002
6015
|
});
|
|
6003
6016
|
})($ || ($ = {}));
|