index.d.ts 918 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Strip literal using Acorn's tokenizer.
  3. *
  4. * Will throw error if the input is not valid JavaScript.
  5. */
  6. declare function stripLiteralAcorn(code: string): string;
  7. /**
  8. * Returns a function that returns whether the position is
  9. * in a literal using Acorn's tokenizer.
  10. *
  11. * Will throw error if the input is not valid JavaScript.
  12. */
  13. declare function createIsLiteralPositionAcorn(code: string): (position: number) => boolean;
  14. /**
  15. * Strip literal using RegExp.
  16. *
  17. * This will be faster and can work on non-JavaScript input.
  18. * But will have some caveats on distinguish strings and comments.
  19. */
  20. declare function stripLiteralRegex(code: string): string;
  21. /**
  22. * Strip literal from code.
  23. *
  24. * Using Acorn's tokenizer first, and fallback to Regex if Acorn fails.
  25. */
  26. declare function stripLiteral(code: string): string;
  27. export { createIsLiteralPositionAcorn, stripLiteral, stripLiteralAcorn, stripLiteralRegex };