Skip to content

Commit e54536c

Browse files
committedJun 8, 2020
Add getEncoder/getDecoder to typescript definitions. Fixes #229
1 parent eed6018 commit e54536c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎lib/index.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,36 @@
66
*--------------------------------------------------------------------------------------------*/
77

88
declare module 'iconv-lite' {
9+
// Basic API
910
export function decode(buffer: Buffer, encoding: string, options?: Options): string;
1011

1112
export function encode(content: string, encoding: string, options?: Options): Buffer;
1213

1314
export function encodingExists(encoding: string): boolean;
1415

16+
// Stream API
1517
export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
1618

1719
export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
20+
21+
// Low-level stream APIs
22+
export function getEncoder(encoding: string, options?: Options): EncoderStream;
23+
24+
export function getDecoder(encoding: string, options?: Options): DecoderStream;
1825
}
1926

2027
export interface Options {
2128
stripBOM?: boolean;
2229
addBOM?: boolean;
2330
defaultEncoding?: string;
2431
}
32+
33+
export interface EncoderStream {
34+
write(str: string): Buffer;
35+
end(): Buffer | undefined;
36+
}
37+
38+
export interface DecoderStream {
39+
write(buf: Buffer): string;
40+
end(): string | undefined;
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.