UNPKG

1.4 kBTypeScriptView Raw
1// Type definitions for chardet 0.8
2// Project: https://github.com/runk/node-chardet
3// Definitions by: Hauke Oldsen <https://github.com/Gebatzens>
4// Sam Hinshaw <https://github.com/samhinshaw>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
7/// <reference types="node" />
8
9export interface Confidence {
10 name: string;
11 confidence: number;
12 lang?: string | undefined;
13}
14
15export interface Options {
16 returnAllMatches?: boolean | undefined;
17 sampleSize?: number | undefined;
18}
19
20// As of v0.6, these fns return the highest-confidence result
21export function detect(buf: Buffer, opts?: Options): string | null;
22
23export function detectFile(path: string, cb: (err: any, result: string | null) => void): void;
24export function detectFile(path: string, opts: Options, cb: (err: any, result: string | null) => void): void;
25
26export function detectFileSync(path: string, opts?: Options): string | null;
27
28// These fns were introduced in v0.6 to return an array of confidences.
29export function detectAll(buf: Buffer, opts?: Options): Confidence[] | null;
30
31export function detectFileAll(path: string, cb: (err: any, result: Confidence[] | null) => void): void;
32export function detectFileAll(path: string, opts: Options, cb: (err: any, result: Confidence[] | null) => void): void;
33
34export function detectFileAllSync(path: string, opts?: Options): Confidence[] | null;