main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
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 call = require('../internals/function-call');
|
---|
6 | var isCallable = require('../internals/is-callable');
|
---|
7 | var anObject = require('../internals/an-object');
|
---|
8 | var toString = require('../internals/to-string');
|
---|
9 |
|
---|
10 | var DELEGATES_TO_EXEC = function () {
|
---|
11 | var execCalled = false;
|
---|
12 | var re = /[ac]/;
|
---|
13 | re.exec = function () {
|
---|
14 | execCalled = true;
|
---|
15 | return /./.exec.apply(this, arguments);
|
---|
16 | };
|
---|
17 | return re.test('abc') === true && execCalled;
|
---|
18 | }();
|
---|
19 |
|
---|
20 | var nativeTest = /./.test;
|
---|
21 |
|
---|
22 | // `RegExp.prototype.test` method
|
---|
23 | // https://tc39.es/ecma262/#sec-regexp.prototype.test
|
---|
24 | $({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, {
|
---|
25 | test: function (S) {
|
---|
26 | var R = anObject(this);
|
---|
27 | var string = toString(S);
|
---|
28 | var exec = R.exec;
|
---|
29 | if (!isCallable(exec)) return call(nativeTest, R, string);
|
---|
30 | var result = call(exec, R, string);
|
---|
31 | if (result === null) return false;
|
---|
32 | anObject(result);
|
---|
33 | return true;
|
---|
34 | }
|
---|
35 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.