mol_vary 0.0.19 → 0.0.21
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 +16 -4
- package/node.deps.json +1 -1
- package/node.test.js +4 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.test.js +4 -2
- package/web.test.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# $mol_vary
|
|
2
2
|
|
|
3
|
-
> VaryPack - simple fast compact data binarization format.
|
|
3
|
+
> Reference implementation of VaryPack - simple fast compact data binarization format.
|
|
4
4
|
|
|
5
5
|
## Key Features
|
|
6
6
|
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
- **Intergated schema**: schema always stored with data. AKA "schema less".
|
|
9
9
|
- **Structural typing**: data mapped to classes by schema. Unique feature!
|
|
10
10
|
- **Decentralized extensibility**: custom types support without central registry. Unique feature!
|
|
11
|
+
- **Single-pass**: used auto-growable internal buffer.
|
|
12
|
+
- **Easy debug**: tiny ints are packed as is, special types are packed as char.
|
|
11
13
|
|
|
12
14
|
## Comparison
|
|
13
15
|
|
|
@@ -26,10 +28,20 @@
|
|
|
26
28
|
[Benchmark](https://perf.js.hyoo.ru/#!bench=j1peaq_k376h9) results:
|
|
27
29
|
|
|
28
30
|
### Chrome 142
|
|
29
|
-

|
|
30
32
|
|
|
31
33
|
## API
|
|
32
34
|
|
|
35
|
+
### Usage from NPM
|
|
36
|
+
|
|
37
|
+
Install [mol_vary](https://www.npmjs.com/package/mol_vary):
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install mol_vary
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Add import:
|
|
44
|
+
|
|
33
45
|
```ts
|
|
34
46
|
import { $mol_vary } from 'mol_vary'
|
|
35
47
|
```
|
|
@@ -37,7 +49,7 @@ import { $mol_vary } from 'mol_vary'
|
|
|
37
49
|
### Binarization
|
|
38
50
|
|
|
39
51
|
```ts
|
|
40
|
-
const buffer = $mol_vary.pack(
|
|
52
|
+
const buffer = $mol_vary.pack( data )
|
|
41
53
|
```
|
|
42
54
|
|
|
43
55
|
### Pasing
|
|
@@ -59,7 +71,7 @@ class Foo {
|
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
$mol_vary.type(
|
|
62
|
-
[ 'a', 'b' ], // keys
|
|
74
|
+
[ 'a', 'b' ], // keys as schema
|
|
63
75
|
( a = 0, b = 0 )=> new Foo( a, b ), // factory
|
|
64
76
|
foo => [ foo.a, foo.b ], // vals extractor
|
|
65
77
|
)
|
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/fail/fail.ts","mol/charset/encode/encode.ts","mol/charset/encoding/encoding.ts","mol/charset/decode/decode.ts","mol/charset/decode/from/from.ts","mol/vary/vary.ts","mol/vary/readme.md"],"mods":{},"deps_in":{"mol":{"mol/vary":-999,"mol/fail":-999,"mol/charset":-999},"":{"mol":-999},"mol/fail":{"mol/vary":-4},"mol/charset/encode":{"mol/vary":-4},"mol/charset":{"mol/charset/encode":-999,"mol/charset/decode":-999,"mol/charset/encoding":-999},"mol/charset/decode/from":{"mol/vary":-4},"mol/charset/decode":{"mol/charset/decode/from":-999},"mol/charset/encoding":{"mol/charset/decode":-1}},"deps_out":{"mol/vary":{"mol":-999,"mol/fail":-4,"mol/charset/encode":-4,"mol/charset/decode/from":-4},"mol":{"":-999},"mol/fail":{"mol":-999},"mol/charset/encode":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol/charset/decode/from":{"mol/charset/decode":-999},"mol/charset/decode":{"mol/charset":-999,"mol/charset/encoding":-1},"mol/charset/encoding":{"mol/charset":-999}},"sloc":{"ts":528,"LICENSE":113,"md":
|
|
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/charset/encode/encode.ts","mol/charset/encoding/encoding.ts","mol/charset/decode/decode.ts","mol/charset/decode/from/from.ts","mol/vary/vary.ts","mol/vary/readme.md"],"mods":{},"deps_in":{"mol":{"mol/vary":-999,"mol/fail":-999,"mol/charset":-999},"":{"mol":-999},"mol/fail":{"mol/vary":-4},"mol/charset/encode":{"mol/vary":-4},"mol/charset":{"mol/charset/encode":-999,"mol/charset/decode":-999,"mol/charset/encoding":-999},"mol/charset/decode/from":{"mol/vary":-4},"mol/charset/decode":{"mol/charset/decode/from":-999},"mol/charset/encoding":{"mol/charset/decode":-1}},"deps_out":{"mol/vary":{"mol":-999,"mol/fail":-4,"mol/charset/encode":-4,"mol/charset/decode/from":-4},"mol":{"":-999},"mol/fail":{"mol":-999},"mol/charset/encode":{"mol/charset":-999},"mol/charset":{"mol":-999},"mol/charset/decode/from":{"mol/charset/decode":-999},"mol/charset/decode":{"mol/charset":-999,"mol/charset/encoding":-1},"mol/charset/encoding":{"mol/charset":-999}},"sloc":{"ts":528,"LICENSE":113,"md":525,"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/vary":-1,"/mol/fail":-4,"/mol/vary/tip/link":-4,"/mol/vary/tip/text":-4,"/mol/charset/encode/to":-4,"/mol/vary/tip/blob":-4,"/mol/vary/tip/uint":-4,"/mol/vary/tip/sint":-4,"/mol/vary/spec/fp32":-4,"/mol/vary/spec/fp64":-4,"/mol/vary/tip/list":-4,"/mol/vary/tip/tupl":-4,"/mol/vary/spec/both":-5,"/mol/vary/spec/true":-5,"/mol/vary/spec/fake":-5,"/mol/vary/spec/none":-5,"/mol/charset/decode/from":-4,"/mol/vary/spec/fp16":-5,"/mol/vary/type":-1},"mol":{"..":-999},"":{},"mol/fail":{"..":-999,"/mol/fail":-1},"mol/charset/encode":{"..":-999,"/mol/charset/encode":-1,"/mol/charset/encode/to":-1,"/mol/charset/encode/size":-1},"mol/charset":{"..":-999},"mol/charset/decode/from":{"..":-999,"/mol/charset/decode/from":-1},"mol/charset/decode":{"..":-999,"/mol/charset/encoding":-1,"/mol/charset/decode":-1},"mol/charset/encoding":{"..":-999,"/mol/charset/encoding":-1}}}
|
package/node.test.js
CHANGED
|
@@ -4769,8 +4769,10 @@ var $;
|
|
|
4769
4769
|
check(new Set([7, 'foo']), [tupl | 1, text | 3, ...str('set'), list | 2, 7, text | 3, ...str('foo')]);
|
|
4770
4770
|
},
|
|
4771
4771
|
"vary pack Date"($) {
|
|
4772
|
-
const
|
|
4773
|
-
check(
|
|
4772
|
+
const date1 = new Date('2025-01-02T03:04:05');
|
|
4773
|
+
check(date1, [tupl | 1, text | 9, ...str('unix_time'), uint | l4, ...new Uint8Array(new Uint32Array([date1.valueOf() / 1000]).buffer)]);
|
|
4774
|
+
const date2 = new Date('2025-01-02T03:04:05.678');
|
|
4775
|
+
check(date2, [tupl | 1, text | 9, ...str('unix_time'), fp64, ...new Uint8Array(new Float64Array([date2.valueOf() / 1000]).buffer)]);
|
|
4774
4776
|
},
|
|
4775
4777
|
"vary pack custom class"($) {
|
|
4776
4778
|
class Foo {
|