Update typings for 1.5.0 (#42096)

- Add 64-bit integer function definitions [u]int64{le, be}
- Bump required TS version to 3.2 due to bigint usage
- Add seek (skip alias)
This commit is contained in:
John Mark Gabriel Caguicla 2020-02-06 01:16:32 +08:00 committed by GitHub
parent 66386e9f82
commit 9d2652f706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View File

@ -118,3 +118,17 @@ const result = parser6.parse(Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05]));
result.nested.points[0].x;
result.nested.points[1].y;
result.optional.number;
const parser7 = new Parser()
// Signed 64-bit integer
.int64('a')
// Unsigned 64-bit integer
.uint64('b')
// Signed 64-bit integer (little endian)
.int64le('c')
// Signed 64-bit integer (big endian)
.int64be('d')
// Unsigned 64-bit integer (little endian)
.uint64le('e')
// Unsigned 64-bit integer (big endian)
.uint64be('f');

View File

@ -1,10 +1,11 @@
// Type definitions for binary-parser 1.3
// Type definitions for binary-parser 1.5
// Project: https://github.com/keichi/binary-parser
// Definitions by: Benjamin Riggs <https://github.com/riggs>,
// Dolan Miu <https://github.com/dolanmiu>,
// Yu Shimura <https://github.com/yuhr>
// Yu Shimura <https://github.com/yuhr>,
// John Mark Gabriel Caguicla <https://github.com/caguiclajmg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 3.2
/// <reference types="node" />
@ -30,6 +31,13 @@ export interface Parser<O extends object | undefined = undefined> {
uint32le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
uint32be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
int64<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
uint64<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
int64le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
int64be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
uint64le<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
uint64be<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, bigint>;
bit1<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit2<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
bit3<N extends string>(name: N, options?: Parser.Options): Parser.Next<O, N, number>;
@ -109,6 +117,8 @@ export interface Parser<O extends object | undefined = undefined> {
skip(length: number): Parser<O>;
seek(length: number): Parser<O>;
endianess(endianess: Parser.Endianness): Parser<O>; /* [sic] */
namely(alias: string): Parser<O>;