1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 19:23:18 +00:00
musix-oss/node_modules/core-js/modules/es.regexp.test.js
2020-03-03 22:30:50 +02:00

31 lines
863 B
JavaScript

'use strict';
// TODO: Remove from `core-js@4` since it's moved to entry points
require('../modules/es.regexp.exec');
var $ = require('../internals/export');
var isObject = require('../internals/is-object');
var DELEGATES_TO_EXEC = function () {
var execCalled = false;
var re = /[ac]/;
re.exec = function () {
execCalled = true;
return /./.exec.apply(this, arguments);
};
return re.test('abc') === true && execCalled;
}();
var nativeTest = /./.test;
$({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {
test: function (str) {
if (typeof this.exec !== 'function') {
return nativeTest.call(this, str);
}
var result = this.exec(str);
if (result !== null && !isObject(result)) {
throw new Error('RegExp exec method returned something other than an Object or null');
}
return !!result;
}
});