cbor-web 8.0.2 → 9.0.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/dist/cbor.js +1 -1
- package/package.json +11 -10
- package/types/lib/cbor.d.ts +34 -0
- package/types/lib/commented.d.ts +111 -0
- package/types/lib/constants.d.ts +63 -0
- package/types/lib/decoder.d.ts +198 -0
- package/types/lib/diagnose.d.ts +91 -0
- package/types/lib/encoder.d.ts +483 -0
- package/types/lib/map.d.ts +81 -0
- package/types/lib/objectRecorder.d.ts +36 -0
- package/types/lib/sharedValueEncoder.d.ts +21 -0
- package/types/lib/simple.d.ts +47 -0
- package/types/lib/tagged.d.ts +78 -0
- package/types/lib/utils.d.ts +21 -0
- package/types/vendor/binary-parse-stream/index.d.ts +34 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export = Tagged;
|
|
2
|
+
/**
|
|
3
|
+
* A CBOR tagged item, where the tag does not have semantics specified at the
|
|
4
|
+
* moment, or those semantics threw an error during parsing. Typically this will
|
|
5
|
+
* be an extension point you're not yet expecting.
|
|
6
|
+
*/
|
|
7
|
+
declare class Tagged {
|
|
8
|
+
static set TAGS(arg: {
|
|
9
|
+
[x: string]: TagFunction;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* The current set of supported tags. May be modified by plugins.
|
|
13
|
+
*
|
|
14
|
+
* @type {TagMap}
|
|
15
|
+
* @static
|
|
16
|
+
*/
|
|
17
|
+
static get TAGS(): {
|
|
18
|
+
[x: string]: TagFunction;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Reset the supported tags to the original set, before any plugins modified
|
|
22
|
+
* the list.
|
|
23
|
+
*/
|
|
24
|
+
static reset(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of Tagged.
|
|
27
|
+
*
|
|
28
|
+
* @param {number} tag The number of the tag.
|
|
29
|
+
* @param {any} value The value inside the tag.
|
|
30
|
+
* @param {Error} [err] The error that was thrown parsing the tag, or null.
|
|
31
|
+
*/
|
|
32
|
+
constructor(tag: number, value: any, err?: Error);
|
|
33
|
+
tag: number;
|
|
34
|
+
value: any;
|
|
35
|
+
err: Error;
|
|
36
|
+
toJSON(): any;
|
|
37
|
+
/**
|
|
38
|
+
* Convert to a String.
|
|
39
|
+
*
|
|
40
|
+
* @returns {string} String of the form '1(2)'.
|
|
41
|
+
*/
|
|
42
|
+
toString(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Push the simple value onto the CBOR stream.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} gen The generator to push onto.
|
|
47
|
+
* @returns {boolean} True on success.
|
|
48
|
+
*/
|
|
49
|
+
encodeCBOR(gen: object): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* If we have a converter for this type, do the conversion. Some converters
|
|
52
|
+
* are built-in. Additional ones can be passed in. If you want to remove
|
|
53
|
+
* a built-in converter, pass a converter in whose value is 'null' instead
|
|
54
|
+
* of a function.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} converters Keys in the object are a tag number, the value
|
|
57
|
+
* is a function that takes the decoded CBOR and returns a JavaScript value
|
|
58
|
+
* of the appropriate type. Throw an exception in the function on errors.
|
|
59
|
+
* @returns {any} The converted item.
|
|
60
|
+
*/
|
|
61
|
+
convert(converters: object): any;
|
|
62
|
+
}
|
|
63
|
+
declare namespace Tagged {
|
|
64
|
+
export { INTERNAL_JSON, TagFunction, TagMap };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Convert a tagged value to a more interesting JavaScript type. Errors
|
|
68
|
+
* thrown in this function will be captured into the "err" property of the
|
|
69
|
+
* original Tagged instance.
|
|
70
|
+
*/
|
|
71
|
+
type TagFunction = (value: any, tag: Tagged) => any;
|
|
72
|
+
declare const INTERNAL_JSON: unique symbol;
|
|
73
|
+
/**
|
|
74
|
+
* A mapping from tag number to a tag decoding function.
|
|
75
|
+
*/
|
|
76
|
+
type TagMap = {
|
|
77
|
+
[x: string]: TagFunction;
|
|
78
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export function utf8(buf: any): string;
|
|
3
|
+
export namespace utf8 {
|
|
4
|
+
const checksUTF8: boolean;
|
|
5
|
+
}
|
|
6
|
+
export function isBufferish(b: any): boolean;
|
|
7
|
+
export function bufferishToBuffer(b: any): Buffer;
|
|
8
|
+
export function parseCBORint(ai: any, buf: any): any;
|
|
9
|
+
export function writeHalf(buf: any, half: any): boolean;
|
|
10
|
+
export function parseHalf(buf: any): number;
|
|
11
|
+
export function parseCBORfloat(buf: any): any;
|
|
12
|
+
export function hex(s: any): Buffer;
|
|
13
|
+
export function bin(s: any): Buffer;
|
|
14
|
+
export function arrayEqual(a: any, b: any): any;
|
|
15
|
+
export function bufferToBigInt(buf: any): bigint;
|
|
16
|
+
export function cborValueToString(val: any, float_bytes?: number): any;
|
|
17
|
+
export function guessEncoding(input: any, encoding: any): any;
|
|
18
|
+
export function base64url(buf: Buffer | Uint8Array | Uint8ClampedArray | ArrayBuffer | DataView): string;
|
|
19
|
+
export function base64(buf: Buffer | Uint8Array | Uint8ClampedArray | ArrayBuffer | DataView): string;
|
|
20
|
+
export function isBigEndian(): boolean;
|
|
21
|
+
import { Buffer } from "buffer";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export = BinaryParseStream;
|
|
2
|
+
/**
|
|
3
|
+
* BinaryParseStream is a TransformStream that consumes buffers and outputs
|
|
4
|
+
* objects on the other end. It expects your subclass to implement a `_parse`
|
|
5
|
+
* method that is a generator. When your generator yields a number, it'll be
|
|
6
|
+
* fed a buffer of that length from the input. When your generator returns,
|
|
7
|
+
* the return value will be pushed to the output side.
|
|
8
|
+
*
|
|
9
|
+
* @extends stream.Transform
|
|
10
|
+
*/
|
|
11
|
+
declare class BinaryParseStream extends stream.Transform {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of BinaryParseStream.
|
|
14
|
+
*
|
|
15
|
+
* @memberof BinaryParseStream
|
|
16
|
+
* @param {stream.TransformOptions} options Stream options.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options: stream.TransformOptions);
|
|
19
|
+
bs: NoFilter;
|
|
20
|
+
__fresh: boolean;
|
|
21
|
+
__needed: any;
|
|
22
|
+
/**
|
|
23
|
+
* Subclasses must override this to set their parsing behavior. Yield a
|
|
24
|
+
* number to receive a Buffer of that many bytes.
|
|
25
|
+
*
|
|
26
|
+
* @abstract
|
|
27
|
+
* @returns {Generator<number, any, Buffer>}
|
|
28
|
+
*/
|
|
29
|
+
_parse(): Generator<number, any, Buffer>;
|
|
30
|
+
__restart(): void;
|
|
31
|
+
__parser: Generator<number, any, Buffer>;
|
|
32
|
+
}
|
|
33
|
+
import stream = require("stream");
|
|
34
|
+
import NoFilter = require("nofilter");
|