.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.regexp.test.js
1 'use strict';
2 // TODO: Remove from `core-js@4` since it's moved to entry points
3 require('../modules/es.regexp.exec');
4 var $ = require('../internals/export');
5 var isObject = require('../internals/is-object');
6
7 var DELEGATES_TO_EXEC = function () {
8   var execCalled = false;
9   var re = /[ac]/;
10   re.exec = function () {
11     execCalled = true;
12     return /./.exec.apply(this, arguments);
13   };
14   return re.test('abc') === true && execCalled;
15 }();
16
17 var nativeTest = /./.test;
18
19 // `RegExp.prototype.test` method
20 // https://tc39.es/ecma262/#sec-regexp.prototype.test
21 $({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {
22   test: function (str) {
23     if (typeof this.exec !== 'function') {
24       return nativeTest.call(this, str);
25     }
26     var result = this.exec(str);
27     if (result !== null && !isObject(result)) {
28       throw new Error('RegExp exec method returned something other than an Object or null');
29     }
30     return !!result;
31   }
32 });