aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/es6.regexp.split.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-04-20 03:09:25 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-04-24 16:14:29 +0200
commit82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch)
tree965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/core-js/modules/es6.regexp.split.js
parente6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff)
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules into one file (plus commons chunks) for every entry point. This results in a much smaller extension size (almost half). Furthermore we use yarn/npm even for extension run-time dependencies. This relieves us from manually vendoring and building dependencies. It's also easier to understand for new developers familiar with node.
Diffstat (limited to 'node_modules/core-js/modules/es6.regexp.split.js')
-rw-r--r--node_modules/core-js/modules/es6.regexp.split.js72
1 files changed, 7 insertions, 65 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..0607fb064 100644
--- a/node_modules/core-js/modules/es6.regexp.split.js
+++ b/node_modules/core-js/modules/es6.regexp.split.js
@@ -1,70 +1,12 @@
// @@split logic
-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(
- '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){
- var string = String(this);
- if(separator === undefined && limit === 0)return [];
- // If `separator` is not a regex, use native split
- if(!isRegExp(separator))return _split.call(string, separator, limit);
- var output = [];
- var flags = (separator.ignoreCase ? 'i' : '') +
- (separator.multiline ? 'm' : '') +
- (separator.unicode ? 'u' : '') +
- (separator.sticky ? 'y' : '');
- var lastLastIndex = 0;
- var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
- // Make `global` and avoid `lastIndex` issues by working with a copy
- 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)){
- // `separatorCopy.lastIndex` is not reliable cross-browser
- lastIndex = match.index + match[0][LENGTH];
- 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;
- });
- 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(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
- }
- 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){
- return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
- };
- }
+require('./$.fix-re-wks')('split', 2, function(defined, SPLIT, $split){
// 21.1.3.17 String.prototype.split(separator, limit)
- return [function split(separator, limit){
+ return function split(separator, limit){
+ 'use strict';
var O = defined(this)
, fn = separator == undefined ? undefined : separator[SPLIT];
- return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
- }, $split];
+ return fn !== undefined
+ ? fn.call(separator, O, limit)
+ : $split.call(String(O), separator, limit);
+ };
}); \ No newline at end of file