mol_charset_ucf_lib 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -11,6 +11,17 @@ bin = $mol_charset_ucf_encode( text )
11
11
  text = $mol_charset_ucf_decode( bin )
12
12
  ```
13
13
 
14
+ ## From NPM
15
+
16
+ `npm install` [mol_charset_ucf_lib](https://www.npmjs.com/package/mol_charset_ucf_lib)
17
+
18
+ ```ts
19
+ import {
20
+ $mol_charset_ucf_encode,
21
+ $mol_charset_ucf_decode
22
+ } from '$mol_charset_ucf_lib'
23
+ ```
24
+
14
25
  # Benchmarks
15
26
 
16
27
  ## Encoding perf
package/node.d.ts CHANGED
@@ -14,5 +14,17 @@ declare namespace $ {
14
14
  export {};
15
15
  }
16
16
 
17
+ declare namespace $ {
18
+ function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
19
+ }
20
+
21
+ declare namespace $ {
22
+ function $mol_charset_ucf_encode(str: string): Uint8Array<ArrayBuffer>;
23
+ }
24
+
25
+ declare namespace $ {
26
+ function $mol_charset_ucf_decode(buffer: Uint8Array<ArrayBuffer>, mode?: number): string;
27
+ }
28
+
17
29
  export = $;
18
30
  //# sourceMappingURL=node.d.ts.map
package/node.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../mam.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null]}
1
+ {"version":3,"sources":["../../../../../mam.d.ts","../../../buffer/buffer.d.ts","../../encode/encode.d.ts","../../decode/decode.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA","sourcesContent":[null,null,null,null]}
package/node.deps.json CHANGED
@@ -1 +1 @@
1
- {"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/charset/ucf/readme.md"],"mods":{},"deps_in":{"mol/charset/ucf":{"mol/charset/ucf/lib":-999},"mol/charset":{"mol/charset/ucf":-999},"mol":{"mol/charset":-999},"":{"mol":-999}},"deps_out":{"mol/charset/ucf/lib":{"mol/charset/ucf":-999},"mol/charset/ucf":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol":{"":-999}},"sloc":{"ts":13,"LICENSE":113,"md":478,"js":9,"json":82,"tree":41,"CNAME":1},"deps":{"mol/charset/ucf/lib":{"..":-999},"mol/charset/ucf":{"..":-999},"mol/charset":{"..":-999},"mol":{"..":-999},"":{}}}
1
+ {"files":["mam.ts","LICENSE","README.md","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/charset/ucf/readme.md","mol/charset/buffer/buffer.ts","mol/charset/ucf/encode/encode.ts","mol/charset/ucf/decode/decode.ts","mol/charset/ucf/lib/lib.meta.tree"],"mods":{},"deps_in":{"mol/charset/ucf":{"mol/charset/ucf/lib":-999,"mol/charset/ucf/encode":-999,"mol/charset/ucf/decode":-999},"mol/charset":{"mol/charset/ucf":-999,"mol/charset/buffer":-999},"mol":{"mol/charset":-999},"":{"mol":-999},"mol/charset/ucf/encode":{"mol/charset/ucf/lib":-999},"mol/charset/buffer":{"mol/charset/ucf/encode":-2},"mol/charset/ucf/decode":{"mol/charset/ucf/lib":-999}},"deps_out":{"mol/charset/ucf/lib":{"mol/charset/ucf":-999,"mol/charset/ucf/encode":-999,"mol/charset/ucf/decode":-999},"mol/charset/ucf":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol":{"":-999},"mol/charset/ucf/encode":{"mol/charset/ucf":-999,"mol/charset/buffer":-2},"mol/charset/buffer":{"mol/charset":-999},"mol/charset/ucf/decode":{"mol/charset/ucf":-999}},"sloc":{"ts":97,"LICENSE":113,"md":486,"js":9,"json":82,"tree":43,"CNAME":1},"deps":{"mol/charset/ucf/lib":{"..":-999,"/mol/charset/ucf/encode":-999,"/mol/charset/ucf/decode":-999},"mol/charset/ucf":{"..":-999},"mol/charset":{"..":-999},"mol":{"..":-999},"":{},"mol/charset/ucf/encode":{"..":-999,"/mol/charset/ucf/encode":-1,"/mol/charset/buffer":-2,"/mol/charset/ucf/encode/to":-1},"mol/charset/buffer":{"..":-999,"/mol/charset/buffer":-1},"mol/charset/ucf/decode":{"..":-999,"/mol/charset/ucf/decode":-1}}}
package/node.js CHANGED
@@ -28,5 +28,119 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
28
28
  var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
29
29
  $.$$ = $
30
30
 
31
+ ;
32
+ "use strict";
33
+ var $;
34
+ (function ($) {
35
+ let buf = new Uint8Array(2 ** 12);
36
+ function $mol_charset_buffer(size) {
37
+ if (buf.byteLength < size)
38
+ buf = new Uint8Array(size);
39
+ return buf;
40
+ }
41
+ $.$mol_charset_buffer = $mol_charset_buffer;
42
+ })($ || ($ = {}));
43
+
44
+ ;
45
+ "use strict";
46
+ var $;
47
+ (function ($) {
48
+ let buf = new Uint8Array(2 ** 12);
49
+ function $mol_charset_ucf_encode(str) {
50
+ const buf = $mol_charset_buffer(str.length * 3);
51
+ return buf.slice(0, $mol_charset_ucf_encode_to(str, buf));
52
+ }
53
+ $.$mol_charset_ucf_encode = $mol_charset_ucf_encode;
54
+ function $mol_charset_ucf_encode_to(str, buf, from = 0) {
55
+ let pos = from;
56
+ let mode = 0xF;
57
+ for (let i = 0; i < str.length; i++) {
58
+ let code = str.charCodeAt(i);
59
+ if (code >= 0xd800 && code < 0xe000)
60
+ code = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
61
+ if (code < 0x20) {
62
+ if (code > 0x08 && code < 0x0E) {
63
+ buf[pos++] = code;
64
+ }
65
+ else {
66
+ if (mode !== 0x0E)
67
+ buf[pos++] = mode = 0x0E;
68
+ buf[pos++] = code | 0x80;
69
+ }
70
+ }
71
+ else {
72
+ if (code < 0xFF) {
73
+ buf[pos++] = code;
74
+ }
75
+ else if (code < 0x09_00) {
76
+ const page = (code >> 7) + 0x0E;
77
+ if (mode !== page)
78
+ buf[pos++] = mode = page;
79
+ buf[pos++] = (code & 0x7F) | 0x80;
80
+ }
81
+ else if (code < 0x04_00_00) {
82
+ const page = code >> 15;
83
+ if (mode !== page)
84
+ buf[pos++] = mode = page;
85
+ buf[pos++] = (code & 0x7F) | 0x80;
86
+ buf[pos++] = code >> 7;
87
+ }
88
+ else {
89
+ if (mode !== 0x08)
90
+ buf[pos++] = mode = 0x08;
91
+ buf[pos++] = (code & 0x7F) | 0x80;
92
+ buf[pos++] = code >> 7;
93
+ buf[pos++] = code >> 15;
94
+ }
95
+ }
96
+ }
97
+ return pos - from;
98
+ }
99
+ })($ || ($ = {}));
100
+
101
+ ;
102
+ "use strict";
103
+ var $;
104
+ (function ($) {
105
+ function $mol_charset_ucf_decode(buffer, mode = 0x0F) {
106
+ let text = '';
107
+ let pos = 0;
108
+ let page_offset = 0;
109
+ while (pos < buffer.length) {
110
+ let code = buffer[pos++];
111
+ if (code < 0x20) {
112
+ if (code >= 0x0E) {
113
+ mode = code;
114
+ page_offset = (mode - 0x0E) << 7;
115
+ }
116
+ else if (code > 0x08) {
117
+ text += String.fromCodePoint(code);
118
+ }
119
+ else if (code === 0x08) {
120
+ mode = 0x08;
121
+ page_offset = 0;
122
+ }
123
+ else {
124
+ mode = code;
125
+ page_offset = mode << 15;
126
+ }
127
+ }
128
+ else if (code < 0x80) {
129
+ text += String.fromCodePoint(code);
130
+ }
131
+ else {
132
+ code &= 0x7F;
133
+ if (mode <= 0x08)
134
+ code |= buffer[pos++] << 7;
135
+ if (mode === 0x08)
136
+ code |= buffer[pos++] << 15;
137
+ text += String.fromCodePoint(page_offset | code);
138
+ }
139
+ }
140
+ return text;
141
+ }
142
+ $.$mol_charset_ucf_decode = $mol_charset_ucf_decode;
143
+ })($ || ($ = {}));
144
+
31
145
 
32
146
  //# sourceMappingURL=node.js.map
package/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["-","../../../../../mam.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n"]}
1
+ {"version":3,"sources":["-","../../../../../mam.ts","../../../../../mol/charset/buffer/buffer.ts","../../../../../mol/charset/ucf/encode/encode.ts","../../../../../mol/charset/ucf/decode/decode.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;;;AEFA,IAAU,CAAC,CAUV;AAVD,WAAU,CAAC;IAEV,IAAI,GAAG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ACzB,CAAC;YAEF,CAAC;iBAAM,IAAI,IAAI,GAAG,IAAI,EAAG,CAAC;gBAEzB,IAAI,IAAI,MAAM,CAAC,aAAa,CAAE,IAAI,CAAE,CAAA;YAErC,CAAC;iBAAM,CAAC;gBAEP,IAAI,IAAI,IAAI,CAAA;gBACZ,IAAI,IAAI,IAAI,IAAI;oBAAG,IAAI,IAAI,MAAM,CAAE,GAAG,EAAG,CAAE,IAAI,CAAC,CAAA;gBAChD,IAAI,IAAI,KAAK,IAAI;oBAAG,IAAI,IAAI,MAAM,CAAE,GAAG,EAAG,CAAE,IAAI,EAAE,CAAA;gBAClD,IAAI,IAAI,MAAM,CAAC,aAAa,CAAE,WAAW,GAAG,IAAI,CAAE,CAAA;YAEnD,CAAC;QAEF,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAzCe,yBAAuB,0BAyCtC,CAAA;AAEF,CAAC,EA9CS,CAAC,KAAD,CAAC,QA8CV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\tlet buf = new Uint8Array( 2**12 ) // 4KB Mem Page\n\t\n\t/** Temporary buffer. Recursive usage isn't supported. */\n\texport function $mol_charset_buffer( size: number ) {\n\t\tif( buf.byteLength < size ) buf = new Uint8Array( size )\n\t\treturn buf\n\t}\n\t\n}\n","namespace $ {\n\t\n\tlet buf = new Uint8Array( 2**12 ) // 4KB Mem Page\n\n\t/** Encode text to Unicode Compact Format. */\n\texport function $mol_charset_ucf_encode( str: string ) {\n\t\tconst buf = $mol_charset_buffer( str.length * 3 )\n\t\treturn buf.slice( 0, $mol_charset_ucf_encode_to( str, buf ) )\n\t}\n\n\tfunction $mol_charset_ucf_encode_to( str: string, buf: Uint8Array< ArrayBuffer >, from = 0 ) {\n\n\t\tlet pos = from\n\t\tlet mode = 0xF\n\n\t\tfor( let i = 0; i < str.length; i++ ) {\n\t\t\t\n\t\t\tlet code = str.charCodeAt( i )\n\t\t\tif( code >= 0xd800 && code < 0xe000 ) code = ( ( code - 0xd800 ) << 10 ) + str.charCodeAt( ++ i ) + 0x2400\n\t\t\t\n\t\t\tif( code < 0x20 ) {\n\t\t\t\t\n\t\t\t\tif( code > 0x08 && code < 0x0E ) { // ASCII Printable\n\t\t\t\t\tbuf[ pos ++ ] = code\n\t\t\t\t} else { // ASCII Invisible\n\t\t\t\t\tif( mode !== 0x0E ) buf[ pos ++ ] = mode = 0x0E\n\t\t\t\t\tbuf[ pos ++ ] = code | 0x80\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tif( code < 0xFF ) { // ASCII Latin\n\t\t\t\t\tbuf[ pos ++ ] = code\n\t\t\t\t} else if( code < 0x09_00 ) { // Tiny\n\t\t\t\t\tconst page = ( code >> 7 ) + 0x0E\n\t\t\t\t\tif( mode !== page ) buf[ pos ++ ] = mode = page\n\t\t\t\t\tbuf[ pos ++ ] = ( code & 0x7F ) | 0x80\n\t\t\t\t} else if( code < 0x04_00_00 ) { // Wide\n\t\t\t\t\tconst page = code >> 15\n\t\t\t\t\tif( mode !== page ) buf[ pos ++ ] = mode = page\n\t\t\t\t\tbuf[ pos ++ ] = ( code & 0x7F ) | 0x80\n\t\t\t\t\tbuf[ pos ++ ] = code >> 7\n\t\t\t\t} else { // Full\n\t\t\t\t\tif( mode !== 0x08 ) buf[ pos ++ ] = mode = 0x08\n\t\t\t\t\tbuf[ pos ++ ] = ( code & 0x7F ) | 0x80\n\t\t\t\t\tbuf[ pos ++ ] = code >> 7\n\t\t\t\t\tbuf[ pos ++ ] = code >> 15\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\n\t\t}\n\n\t\treturn pos - from\n\t}\n\t\n}\n","namespace $ {\n\n\t/** Decode text from Unicode Compact Format. */\n\texport function $mol_charset_ucf_decode( buffer: Uint8Array< ArrayBuffer >, mode = 0x0F ) {\n\t\t\n\t\tlet text = ''\n\t\tlet pos = 0\n\t\tlet page_offset = 0\n\t\t\n\t\twhile( pos < buffer.length ) {\n\t\t\t\n\t\t\tlet code = buffer[ pos ++ ]\n\t\t\t\n\t\t\tif( code < 0x20 ) {\n\t\t\t\t\n\t\t\t\tif( code >= 0x0E ) {\n\t\t\t\t\tmode = code\n\t\t\t\t\tpage_offset = ( mode - 0x0E ) << 7\n\t\t\t\t} else if( code > 0x08 ) {\n\t\t\t\t\ttext += String.fromCodePoint( code )\n\t\t\t\t} else if( code === 0x08 ) {\n\t\t\t\t\tmode = 0x08\n\t\t\t\t\tpage_offset = 0\n\t\t\t\t} else {\n\t\t\t\t\tmode = code\n\t\t\t\t\tpage_offset = mode << 15\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if( code < 0x80 ) {\n\t\t\t\t\n\t\t\t\ttext += String.fromCodePoint( code )\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tcode &= 0x7F\n\t\t\t\tif( mode <= 0x08 ) code |= buffer[ pos ++ ] << 7\n\t\t\t\tif( mode === 0x08 ) code |= buffer[ pos ++ ] << 15\n\t\t\t\ttext += String.fromCodePoint( page_offset | code )\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\treturn text\n\t}\n\n}\n"]}
package/node.meta.tree CHANGED
@@ -19,3 +19,6 @@
19
19
  pack mws git \https://github.com/reatailret/milkywaystd_mol.git
20
20
  \/mol
21
21
  pack icon git \https://github.com/nin-jin/mol_icon.git
22
+ \/mol/charset/ucf/lib
23
+ include \/mol/charset/ucf/encode
24
+ include \/mol/charset/ucf/decode
package/node.mjs CHANGED
@@ -28,6 +28,120 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
28
28
  var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
29
29
  $.$$ = $
30
30
 
31
+ ;
32
+ "use strict";
33
+ var $;
34
+ (function ($) {
35
+ let buf = new Uint8Array(2 ** 12);
36
+ function $mol_charset_buffer(size) {
37
+ if (buf.byteLength < size)
38
+ buf = new Uint8Array(size);
39
+ return buf;
40
+ }
41
+ $.$mol_charset_buffer = $mol_charset_buffer;
42
+ })($ || ($ = {}));
43
+
44
+ ;
45
+ "use strict";
46
+ var $;
47
+ (function ($) {
48
+ let buf = new Uint8Array(2 ** 12);
49
+ function $mol_charset_ucf_encode(str) {
50
+ const buf = $mol_charset_buffer(str.length * 3);
51
+ return buf.slice(0, $mol_charset_ucf_encode_to(str, buf));
52
+ }
53
+ $.$mol_charset_ucf_encode = $mol_charset_ucf_encode;
54
+ function $mol_charset_ucf_encode_to(str, buf, from = 0) {
55
+ let pos = from;
56
+ let mode = 0xF;
57
+ for (let i = 0; i < str.length; i++) {
58
+ let code = str.charCodeAt(i);
59
+ if (code >= 0xd800 && code < 0xe000)
60
+ code = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
61
+ if (code < 0x20) {
62
+ if (code > 0x08 && code < 0x0E) {
63
+ buf[pos++] = code;
64
+ }
65
+ else {
66
+ if (mode !== 0x0E)
67
+ buf[pos++] = mode = 0x0E;
68
+ buf[pos++] = code | 0x80;
69
+ }
70
+ }
71
+ else {
72
+ if (code < 0xFF) {
73
+ buf[pos++] = code;
74
+ }
75
+ else if (code < 0x09_00) {
76
+ const page = (code >> 7) + 0x0E;
77
+ if (mode !== page)
78
+ buf[pos++] = mode = page;
79
+ buf[pos++] = (code & 0x7F) | 0x80;
80
+ }
81
+ else if (code < 0x04_00_00) {
82
+ const page = code >> 15;
83
+ if (mode !== page)
84
+ buf[pos++] = mode = page;
85
+ buf[pos++] = (code & 0x7F) | 0x80;
86
+ buf[pos++] = code >> 7;
87
+ }
88
+ else {
89
+ if (mode !== 0x08)
90
+ buf[pos++] = mode = 0x08;
91
+ buf[pos++] = (code & 0x7F) | 0x80;
92
+ buf[pos++] = code >> 7;
93
+ buf[pos++] = code >> 15;
94
+ }
95
+ }
96
+ }
97
+ return pos - from;
98
+ }
99
+ })($ || ($ = {}));
100
+
101
+ ;
102
+ "use strict";
103
+ var $;
104
+ (function ($) {
105
+ function $mol_charset_ucf_decode(buffer, mode = 0x0F) {
106
+ let text = '';
107
+ let pos = 0;
108
+ let page_offset = 0;
109
+ while (pos < buffer.length) {
110
+ let code = buffer[pos++];
111
+ if (code < 0x20) {
112
+ if (code >= 0x0E) {
113
+ mode = code;
114
+ page_offset = (mode - 0x0E) << 7;
115
+ }
116
+ else if (code > 0x08) {
117
+ text += String.fromCodePoint(code);
118
+ }
119
+ else if (code === 0x08) {
120
+ mode = 0x08;
121
+ page_offset = 0;
122
+ }
123
+ else {
124
+ mode = code;
125
+ page_offset = mode << 15;
126
+ }
127
+ }
128
+ else if (code < 0x80) {
129
+ text += String.fromCodePoint(code);
130
+ }
131
+ else {
132
+ code &= 0x7F;
133
+ if (mode <= 0x08)
134
+ code |= buffer[pos++] << 7;
135
+ if (mode === 0x08)
136
+ code |= buffer[pos++] << 15;
137
+ text += String.fromCodePoint(page_offset | code);
138
+ }
139
+ }
140
+ return text;
141
+ }
142
+ $.$mol_charset_ucf_decode = $mol_charset_ucf_decode;
143
+ })($ || ($ = {}));
144
+
31
145
 
32
146
  export default $
33
147
  //# sourceMappingURL=node.js.map