This commit is contained in:
47
node_modules/core-js/internals/regexp-flags-detection.js
generated
vendored
Normal file
47
node_modules/core-js/internals/regexp-flags-detection.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
var globalThis = require('../internals/global-this');
|
||||
var fails = require('../internals/fails');
|
||||
|
||||
// babel-minify and Closure Compiler transpiles RegExp('.', 'd') -> /./d and it causes SyntaxError
|
||||
var RegExp = globalThis.RegExp;
|
||||
|
||||
var FLAGS_GETTER_IS_CORRECT = !fails(function () {
|
||||
var INDICES_SUPPORT = true;
|
||||
try {
|
||||
RegExp('.', 'd');
|
||||
} catch (error) {
|
||||
INDICES_SUPPORT = false;
|
||||
}
|
||||
|
||||
var O = {};
|
||||
// modern V8 bug
|
||||
var calls = '';
|
||||
var expected = INDICES_SUPPORT ? 'dgimsy' : 'gimsy';
|
||||
|
||||
var addGetter = function (key, chr) {
|
||||
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
||||
Object.defineProperty(O, key, { get: function () {
|
||||
calls += chr;
|
||||
return true;
|
||||
} });
|
||||
};
|
||||
|
||||
var pairs = {
|
||||
dotAll: 's',
|
||||
global: 'g',
|
||||
ignoreCase: 'i',
|
||||
multiline: 'm',
|
||||
sticky: 'y'
|
||||
};
|
||||
|
||||
if (INDICES_SUPPORT) pairs.hasIndices = 'd';
|
||||
|
||||
for (var key in pairs) addGetter(key, pairs[key]);
|
||||
|
||||
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
||||
var result = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get.call(O);
|
||||
|
||||
return result !== expected || calls !== expected;
|
||||
});
|
||||
|
||||
module.exports = { correct: FLAGS_GETTER_IS_CORRECT };
|
||||
Reference in New Issue
Block a user