aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/es6.regexp.split.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/core-js/modules/es6.regexp.split.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/core-js/modules/es6.regexp.split.js')
-rw-r--r--node_modules/core-js/modules/es6.regexp.split.js57
1 files changed, 29 insertions, 28 deletions
diff --git a/node_modules/core-js/modules/es6.regexp.split.js b/node_modules/core-js/modules/es6.regexp.split.js
index a991a3fc9..ce796b384 100644
--- a/node_modules/core-js/modules/es6.regexp.split.js
+++ b/node_modules/core-js/modules/es6.regexp.split.js
@@ -1,27 +1,27 @@
// @@split logic
-require('./_fix-re-wks')('split', 2, function(defined, SPLIT, $split){
+require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split) {
'use strict';
- var isRegExp = require('./_is-regexp')
- , _split = $split
- , $push = [].push
- , $SPLIT = 'split'
- , LENGTH = 'length'
- , LAST_INDEX = 'lastIndex';
- if(
+ var isRegExp = require('./_is-regexp');
+ var _split = $split;
+ var $push = [].push;
+ var $SPLIT = 'split';
+ var LENGTH = 'length';
+ var LAST_INDEX = 'lastIndex';
+ if (
'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
'.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
'.'[$SPLIT](/()()/)[LENGTH] > 1 ||
''[$SPLIT](/.?/)[LENGTH]
- ){
+ ) {
var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
// based on es5-shim implementation, need to rework it
- $split = function(separator, limit){
+ $split = function (separator, limit) {
var string = String(this);
- if(separator === undefined && limit === 0)return [];
+ if (separator === undefined && limit === 0) return [];
// If `separator` is not a regex, use native split
- if(!isRegExp(separator))return _split.call(string, separator, limit);
+ if (!isRegExp(separator)) return _split.call(string, separator, limit);
var output = [];
var flags = (separator.ignoreCase ? 'i' : '') +
(separator.multiline ? 'm' : '') +
@@ -33,38 +33,39 @@ require('./_fix-re-wks')('split', 2, function(defined, SPLIT, $split){
var separatorCopy = new RegExp(separator.source, flags + 'g');
var separator2, match, lastIndex, lastLength, i;
// Doesn't need flags gy, but they don't hurt
- if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
- while(match = separatorCopy.exec(string)){
+ if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
+ while (match = separatorCopy.exec(string)) {
// `separatorCopy.lastIndex` is not reliable cross-browser
lastIndex = match.index + match[0][LENGTH];
- if(lastIndex > lastLastIndex){
+ if (lastIndex > lastLastIndex) {
output.push(string.slice(lastLastIndex, match.index));
// Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
- if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
- for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
+ // eslint-disable-next-line no-loop-func
+ if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () {
+ for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined;
});
- if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
+ if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
lastLength = match[0][LENGTH];
lastLastIndex = lastIndex;
- if(output[LENGTH] >= splitLimit)break;
+ if (output[LENGTH] >= splitLimit) break;
}
- if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
+ if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
}
- if(lastLastIndex === string[LENGTH]){
- if(lastLength || !separatorCopy.test(''))output.push('');
+ if (lastLastIndex === string[LENGTH]) {
+ if (lastLength || !separatorCopy.test('')) output.push('');
} else output.push(string.slice(lastLastIndex));
return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
};
// Chakra, V8
- } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
- $split = function(separator, limit){
+ } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
+ $split = function (separator, limit) {
return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
};
}
// 21.1.3.17 String.prototype.split(separator, limit)
- return [function split(separator, limit){
- var O = defined(this)
- , fn = separator == undefined ? undefined : separator[SPLIT];
+ return [function split(separator, limit) {
+ var O = defined(this);
+ var fn = separator == undefined ? undefined : separator[SPLIT];
return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
}, $split];
-}); \ No newline at end of file
+});