From 75eafa5a64bc327ae8715ac973824d600e563ccd Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 19 Nov 2018 22:36:14 +0100 Subject: [PATCH] Add types for detect-character-encoding --- .../detect-character-encoding-tests.ts | 10 ++++++++ types/detect-character-encoding/index.d.ts | 17 ++++++++++++++ types/detect-character-encoding/tsconfig.json | 23 +++++++++++++++++++ types/detect-character-encoding/tslint.json | 1 + 4 files changed, 51 insertions(+) create mode 100644 types/detect-character-encoding/detect-character-encoding-tests.ts create mode 100644 types/detect-character-encoding/index.d.ts create mode 100644 types/detect-character-encoding/tsconfig.json create mode 100644 types/detect-character-encoding/tslint.json diff --git a/types/detect-character-encoding/detect-character-encoding-tests.ts b/types/detect-character-encoding/detect-character-encoding-tests.ts new file mode 100644 index 0000000000..42f21a688e --- /dev/null +++ b/types/detect-character-encoding/detect-character-encoding-tests.ts @@ -0,0 +1,10 @@ +import detectCharacterEncoding = require("detect-character-encoding"); + +const buf: Buffer = null as any; + +const result: detectCharacterEncoding.Result | null = detectCharacterEncoding(buf); + +if (result) { + const str: string = result.encoding; + const num: number = result.confidence; +} diff --git a/types/detect-character-encoding/index.d.ts b/types/detect-character-encoding/index.d.ts new file mode 100644 index 0000000000..123a7659eb --- /dev/null +++ b/types/detect-character-encoding/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for detect-character-encoding 0.7 +// Project: https://github.com/sonicdoe/detect-character-encoding#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = detectCharacterEncoding; + +declare function detectCharacterEncoding(buf: Buffer): detectCharacterEncoding.Result | null; + +declare namespace detectCharacterEncoding { + interface Result { + encoding: string; + confidence: number; + } +} diff --git a/types/detect-character-encoding/tsconfig.json b/types/detect-character-encoding/tsconfig.json new file mode 100644 index 0000000000..e2adad72dd --- /dev/null +++ b/types/detect-character-encoding/tsconfig.json @@ -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", + "detect-character-encoding-tests.ts" + ] +} diff --git a/types/detect-character-encoding/tslint.json b/types/detect-character-encoding/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/detect-character-encoding/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }