/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-helpers/src/helpers/setFunctionName.ts
23 строки
651 B
liuxingbaoyu
[helpers TS conversion] New decorators (#16540)
21 июн 2024, 10:40
Не верифицирован
21 июн 2024, 10:40
8a87859
Код
Авторство
О чём код?
/* @minVersion 7.23.6 */ // https://tc39.es/ecma262/#sec-setfunctionname export default function setFunctionName<T extends Function>( fn: T, name: symbol | string, prefix?: string, ): T { if (typeof name === "symbol") { // Here `undefined` is possible, we check for it in the next line. name = name.description!; name = name ? "[" + name + "]" : ""; } // In some older browsers .name was non-configurable, here we catch any // errors thrown by defineProperty. try { Object.defineProperty(fn, "name", { configurable: true, value: prefix ? prefix + " " + name : name, }); } catch (_) {} return fn; }