(str)
| 9 | forbiddenIdentifiers.add(''); |
| 10 | |
| 11 | const makeLegalIdentifier: MakeLegalIdentifier = function makeLegalIdentifier(str) { |
| 12 | let identifier = str |
| 13 | .replace(/-(\w)/g, (_, letter) => letter.toUpperCase()) |
| 14 | .replace(/[^$_a-zA-Z0-9]/g, '_'); |
| 15 | |
| 16 | if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) { |
| 17 | identifier = `_${identifier}`; |
| 18 | } |
| 19 | |
| 20 | return identifier || '_'; |
| 21 | }; |
| 22 | |
| 23 | export { makeLegalIdentifier as default }; |
no test coverage detected