es.regexp.flags.js 734 B

123456789101112131415161718
  1. var DESCRIPTORS = require('../internals/descriptors');
  2. var objectDefinePropertyModule = require('../internals/object-define-property');
  3. var regExpFlags = require('../internals/regexp-flags');
  4. var fails = require('../internals/fails');
  5. var RegExpPrototype = RegExp.prototype;
  6. var FORCED = DESCRIPTORS && fails(function () {
  7. // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
  8. return Object.getOwnPropertyDescriptor(RegExpPrototype, 'flags').get.call({ dotAll: true, sticky: true }) !== 'sy';
  9. });
  10. // `RegExp.prototype.flags` getter
  11. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  12. if (FORCED) objectDefinePropertyModule.f(RegExpPrototype, 'flags', {
  13. configurable: true,
  14. get: regExpFlags
  15. });