sliftutils 0.74.0 → 0.75.0
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 +8 -0
- package/misc/cborx.d.ts +4 -0
- package/misc/cborx.ts +11 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -20,6 +20,14 @@ declare module "sliftutils/misc/apiKeys" {
|
|
|
20
20
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
declare module "sliftutils/misc/cborx" {
|
|
24
|
+
/// <reference types="node" />
|
|
25
|
+
/// <reference types="node" />
|
|
26
|
+
export declare function cborEncode<T>(value: T): Buffer;
|
|
27
|
+
export declare function cborDecode<T>(buffer: Buffer): T;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
declare module "sliftutils/misc/environment" {
|
|
24
32
|
export declare function isInChromeExtension(): string | false;
|
|
25
33
|
export declare function isInChromeExtensionBackground(): boolean;
|
package/misc/cborx.d.ts
ADDED
package/misc/cborx.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import cborx from "cbor-x";
|
|
2
|
+
import { lazy } from "socket-function/src/caching";
|
|
3
|
+
const cborxInstance = lazy(() => new cborx.Encoder({
|
|
4
|
+
structuredClone: true,
|
|
5
|
+
}));
|
|
6
|
+
export function cborEncode<T>(value: T): Buffer {
|
|
7
|
+
return cborxInstance().encode(value);
|
|
8
|
+
}
|
|
9
|
+
export function cborDecode<T>(buffer: Buffer): T {
|
|
10
|
+
return cborxInstance().decode(buffer);
|
|
11
|
+
}
|