-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
index.d.ts
62 lines (46 loc) · 1.68 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
Escape a string for use in HTML.
Escapes the following characters in the given `string` argument: `&` `<` `>` `"` `'`.
@example
```
import {htmlEscape} from 'escape-goat';
htmlEscape('🦄 & 🐐');
//=> '🦄 & 🐐'
htmlEscape('Hello <em>World</em>');
//=> 'Hello <em>World</em>'
```
*/
export function htmlEscape(string: string): string;
/**
[Tagged template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) that escapes interpolated values.
@example
```
import {htmlEscape} from 'escape-goat';
const url = 'https://sindresorhus.com?x="🦄"';
htmlEscape`<a href="${url}">Unicorn</a>`;
//=> '<a href="https://sindresorhus.com?x="🦄"">Unicorn</a>'
```
*/
export function htmlEscape(template: TemplateStringsArray, ...substitutions: readonly unknown[]): string;
/**
Unescape an HTML string to use as a plain string.
Unescapes the following HTML entities in the given `htmlString` argument: `&` `<` `>` `"` `'`.
@example
```
import {htmlUnescape} from 'escape-goat';
htmlUnescape('🦄 & 🐐');
//=> '🦄 & 🐐'
```
*/
export function htmlUnescape(htmlString: string): string;
/**
[Tagged template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals) that unescapes interpolated values.
@example
```
import {htmlUnescape} from 'escape-goat';
const escapedUrl = 'https://sindresorhus.com?x="🦄"';
htmlUnescape`URL from HTML: ${url}`;
//=> 'URL from HTML: https://sindresorhus.com?x="🦄"'
```
*/
export function htmlUnescape(template: TemplateStringsArray, ...substitutions: readonly unknown[]): string;