es.regexp.dot-all.js 1016 B

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