Travis build: 600
This commit is contained in:
67
README.md
67
README.md
@ -216,6 +216,7 @@
|
||||
* [`capitalize`](#capitalize)
|
||||
* [`capitalizeEveryWord`](#capitalizeeveryword)
|
||||
* [`countVowels`](#countvowels)
|
||||
* [`escapeHTML`](#escapehtml)
|
||||
* [`escapeRegExp`](#escaperegexp)
|
||||
* [`fromCamelCase`](#fromcamelcase)
|
||||
* [`repeatString`](#repeatstring)
|
||||
@ -226,6 +227,7 @@
|
||||
* [`toKebabCase`](#tokebabcase)
|
||||
* [`toSnakeCase`](#tosnakecase)
|
||||
* [`truncateString`](#truncatestring)
|
||||
* [`unescapeHTML`](#unescapehtml)
|
||||
* [`words`](#words)
|
||||
|
||||
</details>
|
||||
@ -3276,6 +3278,39 @@ countVowels('gym'); // 0
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### escapeHTML
|
||||
|
||||
Escapes a string for use in HTML.
|
||||
|
||||
Use `String.replace()` with a regex that matches the characters that need to be escaped, using a callback function to replace each character instance with its associated escaped character using a dictionary (object).
|
||||
|
||||
```js
|
||||
const escapeHTML = str =>
|
||||
str.replace(
|
||||
/[&<>'"]/g,
|
||||
tag =>
|
||||
({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
"'": ''',
|
||||
'"': '"'
|
||||
}[tag] || tag)
|
||||
);
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
escapeHTML('<a href="#">Me & you</a>'); // '<a href="#">Me & you</a>'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### escapeRegExp
|
||||
|
||||
Escapes a string to use in a regular expression.
|
||||
@ -3551,6 +3586,38 @@ truncateString('boomerang', 7); // 'boom...'
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### unescapeHTML
|
||||
|
||||
Unescapes escaped HTML characters.
|
||||
|
||||
Use `String.replace()` with a regex that matches the characters that need to be escaped, using a callback function to replace each escaped character instance with its associated unescaped character using a dictionary (object).
|
||||
|
||||
```js
|
||||
const unescapeHTML = str =>
|
||||
str.replace(
|
||||
/&|<|>|'|"/g,
|
||||
tag =>
|
||||
({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
''': "'",
|
||||
'"': '"'
|
||||
}[tag] || tag)
|
||||
);
|
||||
```
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
unescapeHTML('<a href="#">Me & you</a>'); // '<a href="#">Me & you</a>'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### words
|
||||
|
||||
Converts a given string into an array of words.
|
||||
|
||||
Reference in New Issue
Block a user