diff --git a/types/franc/franc-tests.ts b/types/franc/franc-tests.ts new file mode 100644 index 0000000000..cb687e1001 --- /dev/null +++ b/types/franc/franc-tests.ts @@ -0,0 +1,14 @@ +import detect = require('franc'); + +const testText = 'This is an example sentence'; +const testOptions = { + minLength: 3, + whitelist: ['eng'], + blacklist: [], +}; + +detect(testText); +detect(testText, testOptions); + +detect.all(testText); +detect.all(testText, testOptions)[0]; diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts new file mode 100644 index 0000000000..613c46946f --- /dev/null +++ b/types/franc/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for franc 4.0 +// Project: https://github.com/wooorm/franc/ +// Definitions by: William LeGate +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) +type ISO6393 = string; + +// Range [0, 1] +type Confidence = number; + +interface Options { + minLength?: number; + whitelist?: ISO6393[]; + blacklist?: ISO6393[]; +} + +declare function detect(text: string, options?: Options): ISO6393; + +declare namespace detect { + function all(text: string, options?: Options): [ISO6393, number]; +} + +export = detect; diff --git a/types/franc/tsconfig.json b/types/franc/tsconfig.json new file mode 100644 index 0000000000..2fe0151ec5 --- /dev/null +++ b/types/franc/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "franc-tests.ts"] +} diff --git a/types/franc/tslint.json b/types/franc/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/franc/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/freedom/tsconfig.json b/types/freedom/tsconfig.json index dd0bd2e13c..adada163d4 100644 --- a/types/freedom/tsconfig.json +++ b/types/freedom/tsconfig.json @@ -1,24 +1,16 @@ { - "files": [ - "index.d.ts", - "freedom-tests.ts" - ], + "files": ["index.d.ts", "freedom-tests.ts"], "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom" - ], + "lib": ["es6", "dom"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +}