index.d.ts 1.3 KB

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