From 0e03b5f45dd9ec48e5bc5d191a8b1c74cd65b88d Mon Sep 17 00:00:00 2001 From: York Yao Date: Thu, 4 Jan 2018 08:06:05 +0800 Subject: [PATCH] add types of pangu (#22643) * add types of pangu * remove default export and unused namespace --- types/pangu/index.d.ts | 21 +++++++++++++++++++++ types/pangu/pangu-tests.ts | 17 +++++++++++++++++ types/pangu/tsconfig.json | 23 +++++++++++++++++++++++ types/pangu/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 types/pangu/index.d.ts create mode 100644 types/pangu/pangu-tests.ts create mode 100644 types/pangu/tsconfig.json create mode 100644 types/pangu/tslint.json diff --git a/types/pangu/index.d.ts b/types/pangu/index.d.ts new file mode 100644 index 0000000000..b7beb1e32a --- /dev/null +++ b/types/pangu/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for pangu 3.3 +// Project: https://github.com/vinta/pangu.js +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function spacing(text: string): string; + +export function spacingFile(path: string, callback: (error: Error, data: string) => void): void; +export function spacingFile(path: string): Promise; + +export function spacingFileSync(path: string): string; + +export function spacingText(text: string, callback: (error: Error, data: string) => void): void; +export function spacingText(text: string): Promise; + +export function spacingPage(): void; +export function spacingElementById(id: string): void; +export function spacingElementByClassName(className: string): void; +export function spacingElementByTagName(tagName: string): void; + +export as namespace pangu; diff --git a/types/pangu/pangu-tests.ts b/types/pangu/pangu-tests.ts new file mode 100644 index 0000000000..7e708d6fdc --- /dev/null +++ b/types/pangu/pangu-tests.ts @@ -0,0 +1,17 @@ +import pangu = require('pangu'); + +pangu.spacing('Sephiroth見他這等神情,也是悚然一驚:不知我這Ultimate Destructive Magic是否對付得了?'); +// output: Sephiroth 見他這等神情, 也是悚然一驚: 不知我這 Ultimate Destructive Magic 是否對付得了? + +pangu.spacingFile('/path/to/text.txt', (err, data) => { +}); + +pangu.spacingFile('/path/to/text.txt').then(data => { +}); + +const data = pangu.spacingFileSync('/path/to/text.txt'); + +pangu.spacingPage(); +pangu.spacingElementById('main'); +pangu.spacingElementByClassName('comment'); +pangu.spacingElementByTagName('p'); diff --git a/types/pangu/tsconfig.json b/types/pangu/tsconfig.json new file mode 100644 index 0000000000..a1084b5b06 --- /dev/null +++ b/types/pangu/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", + "pangu-tests.ts" + ] +} diff --git a/types/pangu/tslint.json b/types/pangu/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pangu/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }