Skip to content

Commit

Permalink
fix(types): address type incompatibilities, regen types
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Dec 4, 2024
1 parent 98bddb9 commit e9b9260
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions lib/json/encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const defaultEncodeOptions = { addBreakTokens: true, mapSorter }
*/
function encode (data, options) {
options = Object.assign({}, defaultEncodeOptions, options)
// @ts-ignore TokenTypeEncoder[] requires compareTokens() on each encoder, we don't use them here
return encodeCustom(data, new JSONEncoder(), options)
}

Expand Down
2 changes: 1 addition & 1 deletion types/lib/bin.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/lib/bl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export class Bl {
/**
* @param {number} [chunkSize]
*/
constructor(chunkSize?: number | undefined);
constructor(chunkSize?: number);
chunkSize: number;
/** @type {number} */
cursor: number;
Expand All @@ -21,6 +21,6 @@ export class Bl {
* @param {boolean} [reset]
* @returns {Uint8Array}
*/
toBytes(reset?: boolean | undefined): Uint8Array;
toBytes(reset?: boolean): Uint8Array;
}
//# sourceMappingURL=bl.d.ts.map
2 changes: 1 addition & 1 deletion types/lib/bl.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/lib/byte-utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export const useBuffer: boolean;
* @param {number} end
*/
export function toString(bytes: Uint8Array, start: number, end: number): string;
export const fromString: ((string: string) => number[] | Buffer) | ((string: string) => Uint8Array | number[]);
export const fromString: ((string: string) => number[] | Buffer<ArrayBuffer>) | ((string: string) => Uint8Array<ArrayBufferLike> | number[]);
export function fromArray(arr: number[]): Uint8Array;
/**
* @param {Uint8Array} bytes
* @param {number} start
* @param {number} end
*/
export function slice(bytes: Uint8Array, start: number, end: number): Uint8Array;
export function slice(bytes: Uint8Array, start: number, end: number): Uint8Array<ArrayBuffer>;
/**
* @param {Uint8Array[]} chunks
* @param {number} length
Expand Down
2 changes: 1 addition & 1 deletion types/lib/byte-utils.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/common.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions types/lib/decode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class Tokeniser implements DecodeTokenizer {
*/
constructor(data: Uint8Array, options?: DecodeOptions);
_pos: number;
data: Uint8Array;
data: Uint8Array<ArrayBufferLike>;
options: import("../interface").DecodeOptions;
pos(): number;
done(): boolean;
Expand All @@ -28,13 +28,13 @@ export function tokensToObject(tokeniser: DecodeTokenizer, options: DecodeOption
* @param {DecodeOptions} [options]
* @returns {any}
*/
export function decode(data: Uint8Array, options?: import("../interface").DecodeOptions | undefined): any;
export function decode(data: Uint8Array, options?: DecodeOptions): any;
/**
* @param {Uint8Array} data
* @param {DecodeOptions} [options]
* @returns {[any, Uint8Array]}
*/
export function decodeFirst(data: Uint8Array, options?: import("../interface").DecodeOptions | undefined): [any, Uint8Array];
export function decodeFirst(data: Uint8Array, options?: DecodeOptions): [any, Uint8Array];
declare const BREAK: unique symbol;
declare const DONE: unique symbol;
export {};
Expand Down
2 changes: 1 addition & 1 deletion types/lib/decode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/diagnostic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {Uint8Array} inp
* @param {number} [width]
*/
export function tokensToDiagnostic(inp: Uint8Array, width?: number | undefined): Generator<string, void, unknown>;
export function tokensToDiagnostic(inp: Uint8Array, width?: number): Generator<string, void, unknown>;
/**
* Convert an input string formatted as CBOR diagnostic output into binary CBOR form.
* @param {string} input
Expand Down
2 changes: 1 addition & 1 deletion types/lib/diagnostic.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/lib/encode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export type TokenOrNestedTokens = import("../interface").TokenOrNestedTokens;
* @param {Reference} [refStack]
* @returns {TokenOrNestedTokens}
*/
export function objectToTokens(obj: any, options?: import("../interface").EncodeOptions | undefined, refStack?: import("../interface").Reference | undefined): TokenOrNestedTokens;
export function objectToTokens(obj: any, options?: EncodeOptions, refStack?: Reference): TokenOrNestedTokens;
/**
* @param {any} data
* @param {EncodeOptions} [options]
* @returns {Uint8Array}
*/
export function encode(data: any, options?: import("../interface").EncodeOptions | undefined): Uint8Array;
export function encode(data: any, options?: EncodeOptions): Uint8Array;
/**
* @param {any} data
* @param {TokenTypeEncoder[]} encoders
Expand Down
2 changes: 1 addition & 1 deletion types/lib/encode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions types/lib/json/decode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export type DecodeTokenizer = import("../../interface").DecodeTokenizer;
* @param {DecodeOptions} [options]
* @returns {any}
*/
export function decode(data: Uint8Array, options?: import("../../interface").DecodeOptions | undefined): any;
export function decode(data: Uint8Array, options?: DecodeOptions): any;
/**
* @param {Uint8Array} data
* @param {DecodeOptions} [options]
* @returns {[any, Uint8Array]}
*/
export function decodeFirst(data: Uint8Array, options?: import("../../interface").DecodeOptions | undefined): [any, Uint8Array];
export function decodeFirst(data: Uint8Array, options?: DecodeOptions): [any, Uint8Array];
/**
* @typedef {import('../../interface').DecodeOptions} DecodeOptions
* @typedef {import('../../interface').DecodeTokenizer} DecodeTokenizer
Expand All @@ -26,7 +26,7 @@ export class Tokenizer implements DecodeTokenizer {
*/
constructor(data: Uint8Array, options?: DecodeOptions);
_pos: number;
data: Uint8Array;
data: Uint8Array<ArrayBufferLike>;
options: import("../../interface").DecodeOptions;
/** @type {string[]} */
modeStack: string[];
Expand Down
2 changes: 1 addition & 1 deletion types/lib/json/decode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/json/encode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export type Bl = import("../bl").Bl;
* @param {EncodeOptions} [options]
* @returns {Uint8Array}
*/
export function encode(data: any, options?: import("../../interface").EncodeOptions | undefined): Uint8Array;
export function encode(data: any, options?: EncodeOptions): Uint8Array;
//# sourceMappingURL=encode.d.ts.map
2 changes: 1 addition & 1 deletion types/lib/json/encode.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/lib/length.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @param {EncodeOptions} [options]
* @returns {number}
*/
export function encodedLength(data: any, options?: import("../interface").EncodeOptions | undefined): number;
export function encodedLength(data: any, options?: EncodeOptions): number;
/**
* Calculate the byte length of the data as represented by the given tokens when
* encoded as CBOR with the options provided.
Expand All @@ -20,7 +20,7 @@ export function encodedLength(data: any, options?: import("../interface").Encode
* @param {TokenTypeEncoder[]} [encoders]
* @param {EncodeOptions} [options]
*/
export function tokensToLength(tokens: TokenOrNestedTokens, encoders?: import("../interface").TokenTypeEncoder[] | undefined, options?: import("../interface").EncodeOptions | undefined): number;
export function tokensToLength(tokens: TokenOrNestedTokens, encoders?: TokenTypeEncoder[], options?: EncodeOptions): number;
export type EncodeOptions = import("../interface").EncodeOptions;
export type TokenTypeEncoder = import("../interface").TokenTypeEncoder;
export type TokenOrNestedTokens = import("../interface").TokenOrNestedTokens;
Expand Down
2 changes: 1 addition & 1 deletion types/lib/length.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/lib/token.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Token {
* @param {any} [value]
* @param {number} [encodedLength]
*/
constructor(type: Type, value?: any, encodedLength?: number | undefined);
constructor(type: Type, value?: any, encodedLength?: number);
type: Type;
value: any;
encodedLength: number | undefined;
Expand Down
2 changes: 1 addition & 1 deletion types/lib/token.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9b9260

Please sign in to comment.