Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.regexp.flags.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. var globalThis = require('../internals/global-this');
  3. var DESCRIPTORS = require('../internals/descriptors');
  4. var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
  5. var regExpFlags = require('../internals/regexp-flags');
  6. var fails = require('../internals/fails');
  7. // babel-minify and Closure Compiler transpiles RegExp('.', 'd') -> /./d and it causes SyntaxError
  8. var RegExp = globalThis.RegExp;
  9. var RegExpPrototype = RegExp.prototype;
  10. var FORCED = DESCRIPTORS && fails(function () {
  11. var INDICES_SUPPORT = true;
  12. try {
  13. RegExp('.', 'd');
  14. } catch (error) {
  15. INDICES_SUPPORT = false;
  16. }
  17. var O = {};
  18. // modern V8 bug
  19. var calls = '';
  20. var expected = INDICES_SUPPORT ? 'dgimsy' : 'gimsy';
  21. var addGetter = function (key, chr) {
  22. // eslint-disable-next-line es/no-object-defineproperty -- safe
  23. Object.defineProperty(O, key, { get: function () {
  24. calls += chr;
  25. return true;
  26. } });
  27. };
  28. var pairs = {
  29. dotAll: 's',
  30. global: 'g',
  31. ignoreCase: 'i',
  32. multiline: 'm',
  33. sticky: 'y'
  34. };
  35. if (INDICES_SUPPORT) pairs.hasIndices = 'd';
  36. for (var key in pairs) addGetter(key, pairs[key]);
  37. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  38. var result = Object.getOwnPropertyDescriptor(RegExpPrototype, 'flags').get.call(O);
  39. return result !== expected || calls !== expected;
  40. });
  41. // `RegExp.prototype.flags` getter
  42. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  43. if (FORCED) defineBuiltInAccessor(RegExpPrototype, 'flags', {
  44. configurable: true,
  45. get: regExpFlags
  46. });