index.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. import { Transform, type TransformCallback } from "node:stream";
  2. import type { SnifferOptions } from "./sniffer.js";
  3. /**
  4. * Sniff the encoding of a buffer, then decode it.
  5. *
  6. * @param buffer Buffer to be decoded
  7. * @param options Options for the sniffer
  8. * @returns The decoded buffer
  9. */
  10. export declare function decodeBuffer(buffer: Buffer, options?: SnifferOptions): string;
  11. /**
  12. * Decodes a stream of buffers into a stream of strings.
  13. *
  14. * Reads the first 1024 bytes and passes them to the sniffer. Once an encoding
  15. * has been determined, it passes all data to iconv-lite's stream and outputs
  16. * the results.
  17. */
  18. export declare class DecodeStream extends Transform {
  19. private readonly sniffer;
  20. private readonly buffers;
  21. /** The iconv decode stream. If it is set, we have read more than `options.maxBytes` bytes. */
  22. private iconv;
  23. private readonly maxBytes;
  24. private readBytes;
  25. constructor(options?: SnifferOptions);
  26. _transform(chunk: Uint8Array, _encoding: string, callback: TransformCallback): void;
  27. private getIconvStream;
  28. _flush(callback: TransformCallback): void;
  29. }
  30. export { type SnifferOptions, getEncoding } from "./sniffer.js";
  31. //# sourceMappingURL=index.d.ts.map