es.regexp.flags.js 621 B

1234567891011121314
  1. var DESCRIPTORS = require('../internals/descriptors');
  2. var objectDefinePropertyModule = require('../internals/object-define-property');
  3. var regExpFlags = require('../internals/regexp-flags');
  4. var UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;
  5. // `RegExp.prototype.flags` getter
  6. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  7. // eslint-disable-next-line es/no-regexp-prototype-flags -- required for testing
  8. if (DESCRIPTORS && (/./g.flags != 'g' || UNSUPPORTED_Y)) {
  9. objectDefinePropertyModule.f(RegExp.prototype, 'flags', {
  10. configurable: true,
  11. get: regExpFlags
  12. });
  13. }