| 57 | } |
| 58 | |
| 59 | function transform(data) { |
| 60 | return Object.entries(data).reduce((acc, [label, lang]) => { |
| 61 | const { extensions = [], aliases = [], codemirror_mode, codemirror_mime_type } = lang; |
| 62 | if (codemirror_mode) { |
| 63 | const dotlessExtensions = extensions.map(ext => ext.slice(1)); |
| 64 | const identifiers = uniq( |
| 65 | [label.toLowerCase(), ...aliases, ...dotlessExtensions].filter(alias => { |
| 66 | if (!alias) { |
| 67 | return; |
| 68 | } |
| 69 | return !/[^a-zA-Z]/.test(alias); |
| 70 | }), |
| 71 | ); |
| 72 | acc.push({ label, identifiers, codemirror_mode, codemirror_mime_type }); |
| 73 | } |
| 74 | return acc; |
| 75 | }, []); |
| 76 | } |
| 77 | |
| 78 | async function process() { |
| 79 | const data = await fetchData(); |