mol_crypto_lib 0.1.1660 → 0.1.1661
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 +3 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +38 -4
- package/node.js.map +1 -1
- package/node.mjs +38 -4
- package/node.test.js +55 -8
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +3 -3
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +38 -11
- package/web.js.map +1 -1
- package/web.mjs +38 -11
- package/web.test.js +17 -4
- package/web.test.js.map +1 -1
package/web.mjs
CHANGED
|
@@ -259,6 +259,11 @@ var $;
|
|
|
259
259
|
return this.setBigUint64(offset, next, true), next;
|
|
260
260
|
$mol_fail(new Error(`Wrong uint64 value ${next}`));
|
|
261
261
|
}
|
|
262
|
+
float16(offset, next) {
|
|
263
|
+
if (next !== undefined)
|
|
264
|
+
this.setFloat16(offset, next, true);
|
|
265
|
+
return this.getFloat16(offset, true);
|
|
266
|
+
}
|
|
262
267
|
float32(offset, next) {
|
|
263
268
|
if (next !== undefined)
|
|
264
269
|
this.setFloat32(offset, next, true);
|
|
@@ -695,23 +700,45 @@ var $;
|
|
|
695
700
|
$.$mol_crypto_sacred_id_get = $mol_crypto_sacred_id_get;
|
|
696
701
|
})($ || ($ = {}));
|
|
697
702
|
|
|
698
|
-
;
|
|
699
|
-
"use strict";
|
|
700
|
-
|
|
701
|
-
;
|
|
702
|
-
"use strict";
|
|
703
|
-
var $node = $node || {};
|
|
704
|
-
|
|
705
703
|
;
|
|
706
704
|
"use strict";
|
|
707
705
|
var $;
|
|
708
706
|
(function ($) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
707
|
+
let buf = new Uint8Array(2 ** 12);
|
|
708
|
+
function $mol_charset_encode(str) {
|
|
709
|
+
const capacity = str.length * 3;
|
|
710
|
+
if (buf.byteLength < capacity)
|
|
711
|
+
buf = new Uint8Array(capacity);
|
|
712
|
+
return buf.slice(0, $mol_charset_encode_to(str, buf));
|
|
713
713
|
}
|
|
714
714
|
$.$mol_charset_encode = $mol_charset_encode;
|
|
715
|
+
function $mol_charset_encode_to(str, buf, from = 0) {
|
|
716
|
+
let pos = from;
|
|
717
|
+
for (let i = 0; i < str.length; i++) {
|
|
718
|
+
let code = str.charCodeAt(i);
|
|
719
|
+
if (code < 0x80) {
|
|
720
|
+
buf[pos++] = code;
|
|
721
|
+
}
|
|
722
|
+
else if (code < 0x800) {
|
|
723
|
+
buf[pos++] = 0xc0 | (code >> 6);
|
|
724
|
+
buf[pos++] = 0x80 | (code & 0x3f);
|
|
725
|
+
}
|
|
726
|
+
else if (code < 0xd800 || code >= 0xe000) {
|
|
727
|
+
buf[pos++] = 0xe0 | (code >> 12);
|
|
728
|
+
buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
|
|
729
|
+
buf[pos++] = 0x80 | (code & 0x3f);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
733
|
+
buf[pos++] = 0xf0 | (point >> 18);
|
|
734
|
+
buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
|
|
735
|
+
buf[pos++] = 0x80 | ((point >> 6) & 0x3f);
|
|
736
|
+
buf[pos++] = 0x80 | (point & 0x3f);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return pos - from;
|
|
740
|
+
}
|
|
741
|
+
$.$mol_charset_encode_to = $mol_charset_encode_to;
|
|
715
742
|
})($ || ($ = {}));
|
|
716
743
|
|
|
717
744
|
;
|
package/web.test.js
CHANGED
|
@@ -1294,10 +1294,23 @@ var $;
|
|
|
1294
1294
|
var $;
|
|
1295
1295
|
(function ($) {
|
|
1296
1296
|
$mol_test({
|
|
1297
|
-
'encode
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1297
|
+
'encode empty'() {
|
|
1298
|
+
$mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
|
|
1299
|
+
},
|
|
1300
|
+
'encode 1 octet'() {
|
|
1301
|
+
$mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
|
|
1302
|
+
},
|
|
1303
|
+
'encode 2 octet'() {
|
|
1304
|
+
$mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
|
|
1305
|
+
},
|
|
1306
|
+
'encode 3 octet'() {
|
|
1307
|
+
$mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
|
|
1308
|
+
},
|
|
1309
|
+
'encode 4 octet'() {
|
|
1310
|
+
$mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
|
|
1311
|
+
},
|
|
1312
|
+
'encode surrogate pair'() {
|
|
1313
|
+
$mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
|
|
1301
1314
|
},
|
|
1302
1315
|
});
|
|
1303
1316
|
})($ || ($ = {}));
|