@nil-/xit 0.1.26 → 0.1.27
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/index.d.ts +4 -4
- package/index.js +3 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type Values = {
|
|
|
16
16
|
number: (t: string, v: number) => Writable<number>;
|
|
17
17
|
string: (t: string, v: string) => Writable<string>;
|
|
18
18
|
buffer: (t: string, v: Uint8Array) => Writable<Uint8Array>;
|
|
19
|
-
json: <T
|
|
19
|
+
json: <T, C extends CoDec<T>>(t: string, v: T, codec: C) => Writable<T>;
|
|
20
20
|
};
|
|
21
21
|
export type Signals = {
|
|
22
22
|
none: (t: string) => () => void;
|
|
@@ -25,7 +25,7 @@ export type Signals = {
|
|
|
25
25
|
number: (t: string) => (v: number) => void;
|
|
26
26
|
string: (t: string) => (v: string) => void;
|
|
27
27
|
buffer: (t: string) => (v: Uint8Array) => void;
|
|
28
|
-
json: <T
|
|
28
|
+
json: <T, E extends CoDec<T>["encode"]>(t: string, encoder: E) => (v: T) => void;
|
|
29
29
|
};
|
|
30
30
|
export type Frame = {
|
|
31
31
|
values: Values;
|
|
@@ -43,8 +43,8 @@ export type Context = {
|
|
|
43
43
|
id: string;
|
|
44
44
|
tag: string | null;
|
|
45
45
|
};
|
|
46
|
-
export declare const json_string:
|
|
47
|
-
encode: (o:
|
|
46
|
+
export declare const json_string: {
|
|
47
|
+
encode: (o: any) => Uint8Array;
|
|
48
48
|
decode: (o: Uint8Array) => any;
|
|
49
49
|
};
|
|
50
50
|
export declare const xit: () => Context;
|
package/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { getContext } from "svelte";
|
|
2
|
-
export const json_string =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
decode: (o) => JSON.parse(new TextDecoder().decode(o))
|
|
6
|
-
};
|
|
2
|
+
export const json_string = {
|
|
3
|
+
encode: (o) => new TextEncoder().encode(JSON.stringify(o)),
|
|
4
|
+
decode: (o) => JSON.parse(new TextDecoder().decode(o))
|
|
7
5
|
};
|
|
8
6
|
export const xit = () => {
|
|
9
7
|
return getContext("nil.xit");
|