index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License.
  4. * REQUIREMENT: This definition is dependent on the @types/node definition.
  5. * Install with `npm install @types/node --save-dev`
  6. *--------------------------------------------------------------------------------------------*/
  7. declare module 'iconv-lite' {
  8. // Basic API
  9. export function decode(buffer: Buffer, encoding: string, options?: Options): string;
  10. export function encode(content: string, encoding: string, options?: Options): Buffer;
  11. export function encodingExists(encoding: string): boolean;
  12. // Stream API
  13. export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
  14. export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
  15. // Low-level stream APIs
  16. export function getEncoder(encoding: string, options?: Options): EncoderStream;
  17. export function getDecoder(encoding: string, options?: Options): DecoderStream;
  18. }
  19. export interface Options {
  20. stripBOM?: boolean;
  21. addBOM?: boolean;
  22. defaultEncoding?: string;
  23. }
  24. export interface EncoderStream {
  25. write(str: string): Buffer;
  26. end(): Buffer | undefined;
  27. }
  28. export interface DecoderStream {
  29. write(buf: Buffer): string;
  30. end(): string | undefined;
  31. }