/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
build-system/tasks/visual-diff/helpers.js
35 строк
689 B
Daniel Rozenberg
🏗 Add dev-mode for `amp visual-diff` and split code into modules (#36673)
02 ноя 2021, 23:43
Не верифицирован
02 ноя 2021, 23:43
7a44c3f
Код
Авторство
О чём код?
'use strict'; const HTML_ESCAPE_CHARS = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '`': '`', }; const HTML_ESCAPE_REGEX = /(&|<|>|"|'|`)/g; /** * Escapes a string of HTML elements to HTML entities. * * @param {string} html HTML as string to escape. * @return {string} */ function escapeHtml(html) { return html.replace(HTML_ESCAPE_REGEX, (c) => HTML_ESCAPE_CHARS[c]); } /** * Returns a Promise that resolves after the specified number of milliseconds. * @param {number} ms * @return {Promise<void>} */ async function sleep(ms) { return new Promise((res) => setTimeout(res, ms)); } module.exports = { escapeHtml, sleep, };