11/// <reference types="node" resolution-mode="require"/>
2- declare module 'prismarine-nbt' {
2+ declare module 'prismarine-nbt' {
33 // @ts -expect-error - protodef is untyped
44 import type { Compiler , Interpreter } from "protodef" ;
55
66 export type Byte = { type : `${TagType . Byte } `, value : number } ;
7-
87 export type Short = { type : `${TagType . Short } `, value : number } ;
9-
108 export type Int = { type : `${TagType . Int } `, value : number } ;
11-
129 export type Long = { type : `${TagType . Long } `, value : [ number , number ] } ;
13-
1410 export type Float = { type : `${TagType . Float } `, value : number } ;
15-
1611 export type Double = { type : `${TagType . Double } `, value : number } ;
17-
1812 export type String = { type : `${TagType . String } `, value : string } ;
19-
2013 export type List < T extends TagType > = {
2114 type : `${TagType . List } `,
2215 value : { type : Tags [ T ] [ 'type' ] , value : Tags [ T ] [ 'value' ] [ ] }
2316 } ;
24-
2517 export type Compound = { type : `${TagType . Compound } `, value : Record < string , undefined | Tags [ TagType ] > } ;
26-
2718 export type ByteArray = { type : `${TagType . ByteArray } `, value : Byte [ "value" ] [ ] } ;
28-
2919 export type ShortArray = { type : `${TagType . ShortArray } `, value : Short [ "value" ] [ ] } ;
30-
3120 export type IntArray = { type : `${TagType . IntArray } `, value : Int [ "value" ] [ ] } ;
32-
3321 export type LongArray = { type : `${TagType . LongArray } `, value : Long [ "value" ] [ ] } ;
3422
3523 export enum TagType {
@@ -70,7 +58,7 @@ declare module 'prismarine-nbt'{
7058
7159 export type NBTFormat = 'big' | 'little' | 'littleVarint'
7260
73- export type NBT = Tags [ 'compound' ] & { name : string } ;
61+ export type NBT = Tags [ 'compound' ] & { name : string } ;
7462 export type Metadata = {
7563 // The decompressed buffer
7664 buffer : Buffer
@@ -79,9 +67,9 @@ declare module 'prismarine-nbt'{
7967 }
8068 export function writeUncompressed ( value : NBT , format ?: NBTFormat ) : Buffer ;
8169 export function parseUncompressed ( value : Buffer , format ?: NBTFormat , options ?: ParseOptions ) : NBT ;
82- export function parseAs ( value : Buffer , type : NBTFormat , options ?: ParseOptions ) : Promise < { parsed : NBT , type : NBTFormat , metadata : Metadata } > ;
83-
84- export function parse ( data : Buffer , nbtType ?: NBTFormat ) : Promise < { parsed : NBT , type : NBTFormat , metadata : Metadata } > ;
70+ export function parseAs ( value : Buffer , type : NBTFormat , options ?: ParseOptions ) : Promise < { parsed : NBT , type : NBTFormat , metadata : Metadata } > ;
71+
72+ export function parse ( data : Buffer | ArrayBuffer , nbtType ?: NBTFormat ) : Promise < { parsed : NBT , type : NBTFormat , metadata : Metadata } > ;
8573 export function simplify ( data : Tags [ TagType ] ) : any
8674 export function equal ( nbt1 : Tags [ TagType ] , nbt2 : Tags [ TagType ] ) : boolean
8775 // ProtoDef compiled protocols
@@ -106,22 +94,23 @@ declare module 'prismarine-nbt'{
10694 /** @deprecated */
10795 export function parse ( data : Buffer , callback : ( err : Error | null , value : NBT ) => any ) : void ;
10896
109- export function bool ( val : number ) : { type : `${TagType . Short } `, value : number }
110- export function short ( val : number ) : { type : `${TagType . Short } `, value : number }
111- export function byte < T extends number > ( val : number ) : { type : `${TagType . Byte } `, value : number }
112- export function string < T extends string | string [ ] > ( val : T ) : { type : `${TagType . String } `, value : T }
113- export function comp < T extends object | object [ ] > ( val : T , name ?: string ) : { type : `${TagType . Compound } `, name ?: string , value : T }
114- export function int < T extends number | number [ ] > ( val : T ) : { type : `${TagType . Int } `, value : T }
115- export function list < T extends string , K extends { type : T } > ( value : K ) : { type : `${TagType . List } `; value : { type : T | 'end' , value : K } }
116- export function float < T extends number | number [ ] > ( value : T ) : { type : `${TagType . Float } `, value : T }
117- export function double < T extends number | number [ ] > ( value : T ) : { type : `${TagType . Double } `, value : T }
97+ // Builder methods
98+ export function bool < T extends number | number [ ] > ( val : T ) : { type : `${TagType . Short } `, value : T }
99+ export function short < T extends number | number [ ] > ( val : T ) : { type : `${TagType . Short } `, value : T }
100+ export function byte < T extends number | number [ ] > ( val : T ) : { type : `${TagType . Byte } `, value : T }
101+ export function string < T extends string | string [ ] > ( val : T ) : { type : `${TagType . String } `, value : T }
102+ export function comp < T extends object | object [ ] > ( val : T , name ?: string ) : { type : `${TagType . Compound } `, name ?: string , value : T }
103+ export function int < T extends number | number [ ] > ( val : T ) : { type : `${TagType . Int } `, value : T }
104+ export function list < T extends string , K extends { type : T } > ( value : K ) : { type : `${TagType . List } `; value : { type : T | 'end' , value : K } }
105+ export function float < T extends number | number [ ] > ( value : T ) : { type : `${TagType . Float } `, value : T }
106+ export function double < T extends number | number [ ] > ( value : T ) : { type : `${TagType . Double } `, value : T }
118107 /**
119108 * @param value Takes a BigInt or an array of two 32-bit integers
120109 */
121- export function long < T extends number | number [ ] | BigInt > ( value : T ) : { type : `${TagType . Long } `, value : T }
110+ export function long < T extends number | number [ ] | BigInt > ( value : T ) : { type : `${TagType . Long } `, value : T }
122111 // Arrays
123- export function byteArray ( value : number [ ] ) : { type : `${TagType . ByteArray } `, value : number [ ] }
124- export function shortArray ( value : number [ ] ) : { type : `${TagType . ShortArray } `, value : number [ ] }
125- export function intArray ( value : number [ ] ) : { type : `${TagType . ByteArray } `, value : number [ ] }
126- export function longArray < T extends number [ ] | BigInt [ ] > ( value : T ) : { type : `${TagType . LongArray } `, value : T }
112+ export function byteArray ( value : number [ ] ) : { type : `${TagType . ByteArray } `, value : number [ ] }
113+ export function shortArray ( value : number [ ] ) : { type : `${TagType . ShortArray } `, value : number [ ] }
114+ export function intArray ( value : number [ ] ) : { type : `${TagType . ByteArray } `, value : number [ ] }
115+ export function longArray < T extends number [ ] | BigInt [ ] > ( value : T ) : { type : `${TagType . LongArray } `, value : T }
127116}
0 commit comments