0
0
mirror of https://github.com/Doodle3D/Doodle3D-API synced 2024-12-23 14:13:47 +01:00
Doodle3D-API/jspm_packages/npm/core-js@0.9.18/modules/es6.regexp.js
2015-07-15 15:06:18 +02:00

45 lines
1.4 KiB
JavaScript

/* */
var $ = require("./$"),
cof = require("./$.cof"),
$RegExp = $.g.RegExp,
Base = $RegExp,
proto = $RegExp.prototype,
re = /a/g,
CORRECT_NEW = new $RegExp(re) !== re,
ALLOWS_RE_WITH_FLAGS = function() {
try {
return $RegExp(re, 'i') == '/a/i';
} catch (e) {}
}();
if ($.FW && $.DESC) {
if (!CORRECT_NEW || !ALLOWS_RE_WITH_FLAGS) {
$RegExp = function RegExp(pattern, flags) {
var patternIsRegExp = cof(pattern) == 'RegExp',
flagsIsUndefined = flags === undefined;
if (!(this instanceof $RegExp) && patternIsRegExp && flagsIsUndefined)
return pattern;
return CORRECT_NEW ? new Base(patternIsRegExp && !flagsIsUndefined ? pattern.source : pattern, flags) : new Base(patternIsRegExp ? pattern.source : pattern, patternIsRegExp && flagsIsUndefined ? pattern.flags : flags);
};
$.each.call($.getNames(Base), function(key) {
key in $RegExp || $.setDesc($RegExp, key, {
configurable: true,
get: function() {
return Base[key];
},
set: function(it) {
Base[key] = it;
}
});
});
proto.constructor = $RegExp;
$RegExp.prototype = proto;
require("./$.redef")($.g, 'RegExp', $RegExp);
}
if (/./g.flags != 'g')
$.setDesc(proto, 'flags', {
configurable: true,
get: require("./$.replacer")(/^.*\/(\w*)$/, '$1')
});
}
require("./$.species")($RegExp);