parameterize.js 925 B

123456789101112131415161718
  1. /**
  2. * Tagged template function which returns paramaterized representation of the message
  3. * For example: parameterize`This is a log statement with ${x} and ${y} params`, would return:
  4. * "__sentry_template_string__": 'This is a log statement with %s and %s params',
  5. * "__sentry_template_values__": ['first', 'second']
  6. * @param strings An array of string values splitted between expressions
  7. * @param values Expressions extracted from template string
  8. * @returns String with template information in __sentry_template_string__ and __sentry_template_values__ properties
  9. */
  10. function parameterize(strings, ...values) {
  11. const formatted = new String(String.raw(strings, ...values)) ;
  12. formatted.__sentry_template_string__ = strings.join('\x00').replace(/%/g, '%%').replace(/\0/g, '%s');
  13. formatted.__sentry_template_values__ = values;
  14. return formatted;
  15. }
  16. export { parameterize };
  17. //# sourceMappingURL=parameterize.js.map