/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/src/modules/utils/extractTemplates.ts
20 строк
703 B
Siriwat K
[docs] Improve Joy template UX (#33159)
17 июн 2022, 05:46
Не верифицирован
17 июн 2022, 05:46
043a096
Код
Авторство
О чём код?
export default function extractTemplates(record: Record<string, string>) { const result: Record<string, { files: Record<string, string>; codeVariant: 'JS' | 'TS' }> = {}; Object.entries(record).forEach((data) => { const match = /\/(?<name>[^/]+)\/(?<filePath>.*)/.exec(data[0]); if (match) { const name = match.groups?.name; const filePath = match.groups?.filePath; if (name && filePath) { if (!result[name]) { result[name] = { files: {}, codeVariant: 'JS' }; } if (filePath.match(/\.(ts|tsx)$/)) { result[name].codeVariant = 'TS'; } result[name].files[filePath] = data[1]; } } }); return result; }