mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Add types for chardet (#25308)
This commit is contained in:
7
types/chardet/chardet-tests.ts
Normal file
7
types/chardet/chardet-tests.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as chardet from "chardet";
|
||||
|
||||
chardet.detect(new Buffer('hello there!'));
|
||||
chardet.detectFile('/path/to/file', (err, encoding) => {});
|
||||
chardet.detectFileSync('/path/to/file');
|
||||
|
||||
chardet.detectFile('/path/to/file', { sampleSize: 32 }, (err, encoding) => {});
|
||||
26
types/chardet/index.d.ts
vendored
Normal file
26
types/chardet/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for chardet 0.5
|
||||
// Project: https://github.com/runk/node-chardet
|
||||
// Definitions by: Hauke Oldsen <https://github.com/Gebatzens>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Confidence {
|
||||
name: string;
|
||||
confidence: number;
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
returnAllMatches?: boolean;
|
||||
sampleSize?: number;
|
||||
}
|
||||
|
||||
export type Result = Confidence[] | string | null;
|
||||
|
||||
export function detect(buf: Buffer, opts?: Options): Result;
|
||||
|
||||
export function detectFile(path: string, cb: (err: any, result: Result) => void): void;
|
||||
export function detectFile(path: string, opts: Options, cb: (err: any, result: Result) => void): void;
|
||||
|
||||
export function detectFileSync(path: string, opts?: Options): Result;
|
||||
23
types/chardet/tsconfig.json
Normal file
23
types/chardet/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"chardet-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/chardet/tslint.json
Normal file
1
types/chardet/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user