add types of pangu (#22643)

* add types of pangu

* remove default export and unused namespace
This commit is contained in:
York Yao
2018-01-04 08:06:05 +08:00
committed by Mohamed Hegazy
parent abb6cbad16
commit 0e03b5f45d
4 changed files with 62 additions and 0 deletions

21
types/pangu/index.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
// Type definitions for pangu 3.3
// Project: https://github.com/vinta/pangu.js
// Definitions by: York Yao <https://github.com/plantain-00>
// 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<string>;
export function spacingFileSync(path: string): string;
export function spacingText(text: string, callback: (error: Error, data: string) => void): void;
export function spacingText(text: string): Promise<string>;
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;

View File

@@ -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');

23
types/pangu/tsconfig.json Normal file
View 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",
"pangu-tests.ts"
]
}

1
types/pangu/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }