mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-12 05:31:41 +00:00
update
This commit is contained in:
40
node_modules/core-js/modules/es6.regexp.match.js
generated
vendored
Normal file
40
node_modules/core-js/modules/es6.regexp.match.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var anObject = require('./_an-object');
|
||||
var toLength = require('./_to-length');
|
||||
var advanceStringIndex = require('./_advance-string-index');
|
||||
var regExpExec = require('./_regexp-exec-abstract');
|
||||
|
||||
// @@match logic
|
||||
require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCallNative) {
|
||||
return [
|
||||
// `String.prototype.match` method
|
||||
// https://tc39.github.io/ecma262/#sec-string.prototype.match
|
||||
function match(regexp) {
|
||||
var O = defined(this);
|
||||
var fn = regexp == undefined ? undefined : regexp[MATCH];
|
||||
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
|
||||
},
|
||||
// `RegExp.prototype[@@match]` method
|
||||
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
|
||||
function (regexp) {
|
||||
var res = maybeCallNative($match, regexp, this);
|
||||
if (res.done) return res.value;
|
||||
var rx = anObject(regexp);
|
||||
var S = String(this);
|
||||
if (!rx.global) return regExpExec(rx, S);
|
||||
var fullUnicode = rx.unicode;
|
||||
rx.lastIndex = 0;
|
||||
var A = [];
|
||||
var n = 0;
|
||||
var result;
|
||||
while ((result = regExpExec(rx, S)) !== null) {
|
||||
var matchStr = String(result[0]);
|
||||
A[n] = matchStr;
|
||||
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
||||
n++;
|
||||
}
|
||||
return n === 0 ? null : A;
|
||||
}
|
||||
];
|
||||
});
|
Reference in New Issue
Block a user