UNPKG

1.89 kBTypeScriptView Raw
1/// <reference types="node" />
2import { BinaryBuffer, BinaryBufferReadableStream, BinaryBufferReadable } from './buffer';
3import { UTF8_with_bom, UTF16be, UTF16le } from './encodings';
4import { ReadableStream, Readable } from './stream';
5export interface ResourceEncoding {
6 encoding: string;
7 hasBOM: boolean;
8}
9export interface DetectedEncoding {
10 encoding?: string;
11 seemsBinary?: boolean;
12}
13export interface DecodeStreamOptions {
14 guessEncoding?: boolean;
15 minBytesRequiredForDetection?: number;
16 overwriteEncoding(detectedEncoding: string | undefined): Promise<string>;
17}
18export interface DecodeStreamResult {
19 stream: ReadableStream<string>;
20 detected: DetectedEncoding;
21}
22export declare class EncodingService {
23 encode(value: string, options?: ResourceEncoding): BinaryBuffer;
24 decode(value: BinaryBuffer, encoding?: string): string;
25 exists(encoding: string): boolean;
26 toIconvEncoding(encoding?: string): string;
27 toResourceEncoding(encoding: string, options: {
28 overwriteEncoding?: boolean;
29 read: (length: number) => Promise<Uint8Array>;
30 }): Promise<ResourceEncoding>;
31 detectEncoding(data: BinaryBuffer, autoGuessEncoding?: boolean): Promise<DetectedEncoding>;
32 protected detectEncodingByBOMFromBuffer(buffer: Buffer, bytesRead: number): typeof UTF8_with_bom | typeof UTF16le | typeof UTF16be | undefined;
33 protected guessEncodingByBuffer(buffer: Buffer): Promise<string | undefined>;
34 decodeStream(source: BinaryBufferReadableStream, options: DecodeStreamOptions): Promise<DecodeStreamResult>;
35 encodeStream(value: string | Readable<string>, options?: ResourceEncoding): Promise<BinaryBuffer | BinaryBufferReadable>;
36 encodeStream(value?: string | Readable<string>, options?: ResourceEncoding): Promise<BinaryBuffer | BinaryBufferReadable | undefined>;
37}
38//# sourceMappingURL=encoding-service.d.ts.map
\No newline at end of file