es.regexp.dot-all.js 998 B

12345678910111213141516171819202122232425
  1. var DESCRIPTORS = require('../internals/descriptors');
  2. var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all');
  3. var classof = require('../internals/classof-raw');
  4. var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
  5. var getInternalState = require('../internals/internal-state').get;
  6. var RegExpPrototype = RegExp.prototype;
  7. var $TypeError = TypeError;
  8. // `RegExp.prototype.dotAll` getter
  9. // https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall
  10. if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) {
  11. defineBuiltInAccessor(RegExpPrototype, 'dotAll', {
  12. configurable: true,
  13. get: function dotAll() {
  14. if (this === RegExpPrototype) return undefined;
  15. // We can't use InternalStateModule.getterFor because
  16. // we don't add metadata for regexps created by a literal.
  17. if (classof(this) === 'RegExp') {
  18. return !!getInternalState(this).dotAll;
  19. }
  20. throw $TypeError('Incompatible receiver, RegExp required');
  21. }
  22. });
  23. }