mol_vary 0.0.1

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/.nojekyll ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # $mol_vary
2
+
3
+ > VaryPack - simple fast compact data binarization format.
4
+
5
+ ## Key Features
6
+
7
+ - **Total deduplication**: equal strucrures are stored as links to first entry.
8
+ - **Intergated schema**: schema always stored with data.
9
+ - **Structural typing**: data mapped to classes by schema.
10
+ - **Direct Acyclic Graph model**: same strucures may have different placements without cost.
11
+
12
+ ## Comparison
13
+
14
+ | | VaryPack | MsgPack | CBOR2 | JSON
15
+ |-------------|----------|---------|-------|--------
16
+ | Language | TS | JS | TS | Native
17
+ | Performance | 5x | 10x | 1x | 15x
18
+ | Size | 1x | 2x | 2x | 4x
19
+
20
+ ## API
21
+
22
+ ```ts
23
+ import { $mol_vary } from 'mol_vary'
24
+ ```
25
+
26
+ ### Binarization
27
+
28
+ ```ts
29
+ const buffer = $mol_vary.pack( any_data )
30
+ ```
31
+
32
+ ### Pasing
33
+
34
+ ```ts
35
+ const data = $mol_vary.take( buffer )
36
+ ```
37
+
38
+ ### Register custom types
39
+
40
+ ```ts
41
+ class Foo {
42
+
43
+ constructor(
44
+ readonly a: number,
45
+ readonly b: number,
46
+ ) {}
47
+
48
+ }
49
+
50
+ $mol_vary.register(
51
+ ( a = 0, b = 0 )=> new Foo( a, b ),
52
+ foo => [
53
+ [ 'a', 'b' ],
54
+ [ foo.a, foo.b ],
55
+ ],
56
+ )
57
+ ```
package/node.audit.js ADDED
@@ -0,0 +1,2 @@
1
+ console.info( `%cplace: $mol_build
2
+ message: Audit passed`, 'color:forestgreen; font-weight:bolder' )
package/node.d.ts ADDED
@@ -0,0 +1,94 @@
1
+ declare let _$_: {
2
+ new (): {};
3
+ } & typeof globalThis;
4
+ declare class $ extends _$_ {
5
+ }
6
+ declare namespace $ {
7
+ export type $ = typeof $$;
8
+ export class $$ extends $ {
9
+ static $: $;
10
+ }
11
+ namespace $$ {
12
+ type $$ = $;
13
+ }
14
+ export {};
15
+ }
16
+
17
+ declare namespace $ {
18
+ function $mol_fail(error: any): never;
19
+ }
20
+
21
+ declare namespace $ {
22
+ function $mol_hash_numbers(buff: ArrayLike<number>, seed?: number): number;
23
+ }
24
+
25
+ declare namespace $ {
26
+ function $mol_bigint_encode(num: bigint): Uint8Array<ArrayBuffer>;
27
+ }
28
+
29
+ declare namespace $ {
30
+ function $mol_hash_string(str: string, seed?: number): number;
31
+ }
32
+
33
+ declare namespace $ {
34
+ function $mol_charset_encode(str: string): Uint8Array<ArrayBuffer>;
35
+ function $mol_charset_encode_to(str: string, buf: Uint8Array<ArrayBuffer>, from?: number): number;
36
+ function $mol_charset_encode_size(str: string): number;
37
+ }
38
+
39
+ declare namespace $ {
40
+ type $mol_charset_encoding = 'utf8' | 'utf-16le' | 'utf-16be' | 'ibm866' | 'iso-8859-2' | 'iso-8859-3' | 'iso-8859-4' | 'iso-8859-5' | 'iso-8859-6' | 'iso-8859-7' | 'iso-8859-8' | 'iso-8859-8i' | 'iso-8859-10' | 'iso-8859-13' | 'iso-8859-14' | 'iso-8859-15' | 'iso-8859-16' | 'koi8-r' | 'koi8-u' | 'koi8-r' | 'macintosh' | 'windows-874' | 'windows-1250' | 'windows-1251' | 'windows-1252' | 'windows-1253' | 'windows-1254' | 'windows-1255' | 'windows-1256' | 'windows-1257' | 'windows-1258' | 'x-mac-cyrillic' | 'gbk' | 'gb18030' | 'hz-gb-2312' | 'big5' | 'euc-jp' | 'iso-2022-jp' | 'shift-jis' | 'euc-kr' | 'iso-2022-kr';
41
+ }
42
+
43
+ declare namespace $ {
44
+ function $mol_charset_decode(buffer: AllowSharedBufferSource, encoding?: $mol_charset_encoding): string;
45
+ }
46
+
47
+ declare namespace $ {
48
+ enum $mol_vary_tip {
49
+ uint = 0,
50
+ link = 32,
51
+ spec = 64,
52
+ list = 96,
53
+ text = 128,
54
+ blob = 160,
55
+ tupl = 192,
56
+ sint = 224
57
+ }
58
+ const $mol_vary_len: {
59
+ readonly 1: 28;
60
+ readonly 2: 29;
61
+ readonly 4: 30;
62
+ readonly 8: 31;
63
+ };
64
+ enum $mol_vary_spec {
65
+ none,
66
+ true,
67
+ fake,
68
+ both,
69
+ fp16 = 93,
70
+ fp32 = 94,
71
+ fp64 = 95
72
+ }
73
+ class $mol_vary extends DataView<ArrayBuffer> {
74
+ static pack(data: unknown): Uint8Array<ArrayBuffer>;
75
+ static take(buf: Uint8Array<ArrayBuffer>): unknown;
76
+ tlen(pos: number, tip: keyof typeof $mol_vary_tip, len: number): number;
77
+ tnat(pos: number, tip: keyof typeof $mol_vary_tip, num: number | bigint): number;
78
+ tint(pos: number, tip: keyof typeof $mol_vary_tip, num: number | bigint): number;
79
+ tfp(pos: number, tip: keyof typeof $mol_vary_tip, num: number): number;
80
+ tip(pos: number): keyof typeof $mol_vary_tip;
81
+ ulen(pos: number): 0 | 1 | 2 | 8 | 4;
82
+ slen(pos: number): 0 | 1 | 2 | 8 | 4;
83
+ unum(pos: number): number | bigint;
84
+ snum(pos: number): number | bigint;
85
+ static rich(keys: any[], vals: any[]): object;
86
+ static lean(val: object): readonly [keys: readonly any[], vals: readonly any[]];
87
+ static leanes: Map<object, (val: any) => readonly [keys: readonly any[], vals: readonly any[]]>;
88
+ static riches: Map<string, (...vals: readonly any[]) => object>;
89
+ static register<const Instance extends object, const Keys extends readonly any[], const Vals extends readonly any[]>(rich: ((...vals: Vals) => Instance) | (() => Instance), lean: (obj: Instance) => readonly [Keys, Vals]): void;
90
+ }
91
+ }
92
+
93
+ export = $;
94
+ //# sourceMappingURL=node.d.ts.map
package/node.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../mam.d.ts","../../fail/fail.d.ts","../../hash/numbers/number.d.ts","../../bigint/encode/encode.d.ts","../../hash/string/string.d.ts","../../charset/encode/encode.d.ts","../../charset/encoding/encoding.d.ts","../../charset/decode/decode.d.ts","../vary.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;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null,null,null,null,null,null,null]}
package/node.deps.json ADDED
@@ -0,0 +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/fail/fail.ts","mol/hash/numbers/number.ts","mol/bigint/encode/encode.ts","mol/hash/string/string.ts","mol/charset/encode/encode.ts","mol/charset/encoding/encoding.ts","mol/charset/decode/decode.ts","mol/vary/vary.ts","mol/vary/readme.md"],"mods":{},"deps_in":{"mol":{"mol/vary":-999,"mol/fail":-999,"mol/hash":-999,"mol/bigint":-999,"mol/charset":-999},"":{"mol":-999},"mol/fail":{"mol/vary":-3},"mol/hash/numbers":{"mol/vary":-6,"mol/hash/string":-2},"mol/hash":{"mol/hash/numbers":-999,"mol/hash/string":-999},"mol/bigint/encode":{"mol/vary":-6},"mol/bigint":{"mol/bigint/encode":-999},"mol/hash/string":{"mol/vary":-6},"mol/charset/encode":{"mol/vary":-6},"mol/charset":{"mol/charset/encode":-999,"mol/charset/decode":-999,"mol/charset/encoding":-999},"mol/charset/decode":{"mol/vary":-4},"mol/charset/encoding":{"mol/charset/decode":-1}},"deps_out":{"mol/vary":{"mol":-999,"mol/fail":-3,"mol/hash/numbers":-6,"mol/bigint/encode":-6,"mol/hash/string":-6,"mol/charset/encode":-6,"mol/charset/decode":-4},"mol":{"":-999},"mol/fail":{"mol":-999},"mol/hash/numbers":{"mol/hash":-999},"mol/hash":{"mol":-999},"mol/bigint/encode":{"mol/bigint":-999},"mol/bigint":{"mol":-999},"mol/hash/string":{"mol/hash":-999,"mol/hash/numbers":-2},"mol/charset/encode":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol/charset/decode":{"mol/charset":-999,"mol/charset/encoding":-1},"mol/charset/encoding":{"mol/charset":-999}},"sloc":{"ts":666,"LICENSE":113,"md":506,"js":9,"json":82,"tree":41,"CNAME":1},"deps":{"mol/vary":{"..":-999,"/mol/vary/tip":-1,"/mol/vary/len":-1,"/mol/vary/spec":-1,"/mol/vary/tip/spec":-2,"/mol/fail":-3,"/mol/vary":-1,"/mol/hash/numbers":-6,"/mol/bigint/encode":-6,"/mol/vary/tip/sint":-5,"/mol/hash/string":-6,"/mol/vary/tip/text":-6,"/mol/vary/spec/none":-6,"/mol/vary/tip/blob":-6,"/mol/vary/tip/list":-6,"/mol/vary/tip/tupl":-7,"/mol/charset/encode/size":-6,"/mol/vary/spec/both":-6,"/mol/vary/spec/true":-6,"/mol/vary/spec/fake":-6,"/mol/charset/encode/to":-6,"/mol/vary/spec/fp32":-5,"/mol/vary/spec/fp64":-5,"/mol/charset/decode":-4,"/mol/vary/tip/uint":-5,"/mol/vary/register":-1},"mol":{"..":-999},"":{},"mol/fail":{"..":-999,"/mol/fail":-1},"mol/hash/numbers":{"..":-999,"/mol/hash/numbers":-1},"mol/hash":{"..":-999},"mol/bigint/encode":{"..":-999,"/mol/bigint/encode":-1},"mol/bigint":{"..":-999},"mol/hash/string":{"..":-999,"/mol/hash/string":-1,"/mol/hash/numbers":-2},"mol/charset/encode":{"..":-999,"/mol/charset/encode":-1,"/mol/charset/encode/to":-1,"/mol/charset/encode/size":-1},"mol/charset":{"..":-999},"mol/charset/decode":{"..":-999,"/mol/charset/encoding":-1,"/mol/charset/decode":-1},"mol/charset/encoding":{"..":-999,"/mol/charset/encoding":-1}}}