beautifyCode.ts 330 B

12345678910111213
  1. /**
  2. * Adds some spaces between some language constructions
  3. *
  4. * @param {string} code
  5. * @returns {string}
  6. */
  7. export function beautifyCode (code: string): string {
  8. return code
  9. .replace(/function\(\){/g, 'function () {')
  10. .replace(/(!?=+)/g, ' $1 ')
  11. .replace(/,/g, ', ')
  12. .replace(/;/g, '; ');
  13. }