regexp-sticky-helpers.js 832 B

123456789101112131415161718192021222324252627282930
  1. var fails = require('../internals/fails');
  2. var global = require('../internals/global');
  3. // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  4. var $RegExp = global.RegExp;
  5. var UNSUPPORTED_Y = fails(function () {
  6. var re = $RegExp('a', 'y');
  7. re.lastIndex = 2;
  8. return re.exec('abcd') != null;
  9. });
  10. // UC Browser bug
  11. // https://github.com/zloirock/core-js/issues/1008
  12. var MISSED_STICKY = UNSUPPORTED_Y || fails(function () {
  13. return !$RegExp('a', 'y').sticky;
  14. });
  15. var BROKEN_CARET = UNSUPPORTED_Y || fails(function () {
  16. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  17. var re = $RegExp('^r', 'gy');
  18. re.lastIndex = 2;
  19. return re.exec('str') != null;
  20. });
  21. module.exports = {
  22. BROKEN_CARET: BROKEN_CARET,
  23. MISSED_STICKY: MISSED_STICKY,
  24. UNSUPPORTED_Y: UNSUPPORTED_Y
  25. };