UNPKG

1.12 kBTypeScriptView Raw
1/// <reference types="node" />
2
3export interface Confidence {
4 name: string;
5 confidence: number;
6 lang?: string | undefined;
7}
8
9export interface Options {
10 returnAllMatches?: boolean | undefined;
11 sampleSize?: number | undefined;
12}
13
14// As of v0.6, these fns return the highest-confidence result
15export function detect(buf: Buffer, opts?: Options): string | null;
16
17export function detectFile(path: string, cb: (err: any, result: string | null) => void): void;
18export function detectFile(path: string, opts: Options, cb: (err: any, result: string | null) => void): void;
19
20export function detectFileSync(path: string, opts?: Options): string | null;
21
22// These fns were introduced in v0.6 to return an array of confidences.
23export function detectAll(buf: Buffer, opts?: Options): Confidence[] | null;
24
25export function detectFileAll(path: string, cb: (err: any, result: Confidence[] | null) => void): void;
26export function detectFileAll(path: string, opts: Options, cb: (err: any, result: Confidence[] | null) => void): void;
27
28export function detectFileAllSync(path: string, opts?: Options): Confidence[] | null;