mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
add xml-escape typings (#35449)
This commit is contained in:
parent
7594a53576
commit
216d877abf
13
types/xml-escape/index.d.ts
vendored
Normal file
13
types/xml-escape/index.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Type definitions for xml-escape 1.1
|
||||
// Project: https://github.com/miketheprogrammer/xml-escape
|
||||
// Definitions by: Charles Kenney <https://github.com/charliekenney23>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Escape an XML string
|
||||
*
|
||||
* @param string String of XML to escape
|
||||
* @param ignore Characters to ignore
|
||||
*/
|
||||
declare function escape(string: string, ignore?: string): string;
|
||||
export = escape;
|
||||
16
types/xml-escape/tsconfig.json
Normal file
16
types/xml-escape/tsconfig.json
Normal file
@ -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", "xml-escape-tests.ts"]
|
||||
}
|
||||
3
types/xml-escape/tslint.json
Normal file
3
types/xml-escape/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
20
types/xml-escape/xml-escape-tests.ts
Normal file
20
types/xml-escape/xml-escape-tests.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import xmlEscape = require("xml-escape");
|
||||
|
||||
const xml = `
|
||||
<message>
|
||||
<to>Barack Obama</to>
|
||||
<from>Joe Biden</from>
|
||||
<subject>Cats</subject>
|
||||
<content>I freakin' love cats!!&!</content
|
||||
</message>
|
||||
`;
|
||||
|
||||
const fullEscaped = xmlEscape(xml); // $ExpectType string
|
||||
const preservingApostrophe = xmlEscape(xml, "&"); // $ExpectType string
|
||||
|
||||
console.info({
|
||||
fullEscaped,
|
||||
preservingApostrophe
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user