/
vasya2
/
var
Обзор
Документация
Войти
/
vasya2
/
var
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tools/client-plugins/browser-scripts/utils/format.js
22 строки
696 B
Oliver Eyton-Williams
refactor(client): allow TS worker to initialize itself and have the client check readiness (#57055)
11 ноя 2024, 19:18
Не верифицирован
11 ноя 2024, 19:18
c7936b4
Код
Авторство
О чём код?
// TODO: this is a straight up copy of the format function from the client. // Figure out a way to share it. import { inspect } from 'util/util.js'; export function format(x) { // we're trying to mimic console.log, so we avoid wrapping strings in quotes: if (typeof x === 'string') return x; else if (x instanceof Set) { return `Set(${x.size}) {${Array.from(x).join(', ')}}`; } else if (x instanceof Map) { return `Map(${x.size}) {${Array.from( x.entries(), ([k, v]) => `${k} => ${v}` ).join(', ')}})`; } else if (typeof x === 'bigint') { return x.toString() + 'n'; } else if (typeof x === 'symbol') { return x.toString(); } return inspect(x); }