structom 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "structom",
3
- "version": "0.0.2",
4
- "description": "new generation of reactivity and speed",
3
+ "version": "0.0.4",
4
+ "description": "efficient data format for all needs",
5
5
  "author": "aliibrahim123",
6
6
  "type": "module",
7
7
  "main": "./src/index.ts",
package/readme.md CHANGED
@@ -0,0 +1,53 @@
1
+ # structom javascript library
2
+ the official package for working with structom for the javascript language
3
+
4
+ ## structom
5
+ structom (StructuredAtoms) is a lightweight general data exchange format designed for universal applications, from small human readable object files to large scale data serialization.
6
+
7
+ structom has 3 different forms for data representation:
8
+ - object notation: consize human readable systax for data manipulated by humans.
9
+ - binary objects: effecient direct form for shcemaless data.
10
+ - serialized structs: flattern form for performant data serialization.
11
+
12
+ structom provide additional rich data structures (tagged unions), supports both schema and schemaless data, and provide support for user defined erased metadata for richer data representation.
13
+
14
+ structom is designed to be very versatile and expressive, while remaining efficient and performant, adapting for any need from high level rich data notation to low level effecient serialization.
15
+
16
+ read more about the structom format in its [specification](../spec/index.md).
17
+
18
+ ## `Value`
19
+ ```typescript
20
+ export interface UUID {
21
+ type: 'uuid',
22
+ value: Uint8Array
23
+ };
24
+ export interface Dur {
25
+ type: 'dur',
26
+ value: bigint
27
+ }
28
+ export type Value =
29
+ boolean | number | string | bigint | Date | UUID | Dur | Array<Value> | Map<Value, Value>;
30
+ ```
31
+ `Value`: a structom value, can be:
32
+ - `boolean`: represent a `bool` type.
33
+ - `number`: represent a `u8`, `u16`, `u32`, `i8`, `i16`, `i32`, `f32`, `f64` type.
34
+ - `bigint`: represent a `u64`, `i64`, `vuint`, `vint`, `bint` type.
35
+ - `string`: represent a `string` type.
36
+ - `Date`: represent a `inst`, `instN`, type.
37
+ - `UUID`: represent a `uuid` type, a 16 byte `Uint8Array` array.
38
+ - `Dur`: represent a `dur` type, a `bigint` nanosecond value.
39
+ - `Array`: represent a `arr` type.
40
+ - `Map`: represent a `map`, `struct`, `enum` type.
41
+
42
+ ## `encode` / `decode`
43
+ ```typescript
44
+ export function encode(value: Value): Uint8Array;
45
+ export function decode(data: ArrayBuffer): Value;
46
+ ```
47
+ `encode`: encode a given `Value` into its binary representation.
48
+ `decode`: decode a given binary data into a `Value`.
49
+
50
+ this functions expect / insert a header before the encoded data, specifing `any` type.
51
+
52
+ ## codegen support
53
+ this package also export a collection of encoding and decoding utilities used by the generated serialization code, not intended to be used directly.
package/src/index.ts CHANGED
@@ -36,5 +36,5 @@ export * from './rich.ts';
36
36
  export {
37
37
  decode_i8, decode_i16, decode_i32, decode_i64, decode_u8, decode_u16, decode_u32, decode_u64,
38
38
  decode_u8_arr, encode_i8, encode_i16, encode_i32, encode_i64, encode_u8, encode_u16, encode_u32,
39
- encode_u64, encode_u8_arr
39
+ encode_u64, encode_u8_arr, type Buffer, type Cursor
40
40
  } from './buf.ts';