/
githubmirror
/
jest
Обзор
Документация
Войти
/
githubmirror
/
jest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/jest-diff/src/escapeControlCharacters.ts
26 строк
728 B
Seong Min Park
feat: Show non-printable control characters to diff output (#15696)
25 июн 2025, 04:09
Не верифицирован
25 июн 2025, 04:09
2c2586d
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // Escape control characters to make them visible in diffs export const escapeControlCharacters = (str: string): string => str.replaceAll( /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, (match: string) => { switch (match) { case '\b': return '\\b'; case '\f': return '\\f'; case '\v': return '\\v'; default: { const code = match.codePointAt(0); return `\\x${code!.toString(16).padStart(2, '0')}`; } } }, );