diff --git a/types/entities/entities-tests.ts b/types/entities/entities-tests.ts new file mode 100644 index 0000000000..df4a72479a --- /dev/null +++ b/types/entities/entities-tests.ts @@ -0,0 +1,9 @@ +import * as entities from 'entities'; + +// encoding +entities.encodeXML(`&`); // `&` +entities.encodeHTML(`&`); // `&` + +// decoding +entities.decodeXML(`asdf & ÿ ü '`); // `asdf & ÿ ü '` +entities.decodeHTML(`asdf & ÿ ü '`); // `asdf & ÿ ü '` diff --git a/types/entities/index.d.ts b/types/entities/index.d.ts new file mode 100644 index 0000000000..46f7c11116 --- /dev/null +++ b/types/entities/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for entities 1.1 +// Project: https://github.com/fb55/node-entities +// Definitions by: Alice Klipper +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function decode(data: string, level?: number): string; +export function decodeStrict(data: string, level?: number): string; +export function encode(data: string, level?: number): string; + +export function decodeXML(str: string): string; +export function decodeXMLStrict(str: string): string; +export function encodeXML(data: string): string; + +export function decodeHTML(str: string): string; +export function decodeHTMLStrict(str: string): string; +export function encodeHTML(data: string): string; + +export function decodeHTML4(str: string): string; +export function decodeHTML4Strict(str: string): string; +export function encodeHTML4(data: string): string; + +export function decodeHTML5(str: string): string; +export function decodeHTML5Strict(str: string): string; +export function encodeHTML5(data: string): string; + +export function escape(data: string): string; diff --git a/types/entities/tsconfig.json b/types/entities/tsconfig.json new file mode 100644 index 0000000000..7a68bc361b --- /dev/null +++ b/types/entities/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "entities-tests.ts" + ] +} diff --git a/types/entities/tslint.json b/types/entities/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/entities/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }