Urara-Blog/node_modules/.pnpm-store/v3/files/63/1f714f177cb50aebf1686a216374a09cb3896ee5a89426c199e718d62c1895b910cea06f095f627faa1145145b4e5b9da9ebe7b8bdb3ec3205b0cf0d1b74af
2022-08-14 01:14:53 +08:00

26 lines
779 B
Text

'use strict';
var supportsDescriptors = require('define-properties').supportsDescriptors;
var getPolyfill = require('./polyfill');
var gOPD = Object.getOwnPropertyDescriptor;
var defineProperty = Object.defineProperty;
var TypeErr = TypeError;
var getProto = Object.getPrototypeOf;
var regex = /a/;
module.exports = function shimFlags() {
if (!supportsDescriptors || !getProto) {
throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
}
var polyfill = getPolyfill();
var proto = getProto(regex);
var descriptor = gOPD(proto, 'flags');
if (!descriptor || descriptor.get !== polyfill) {
defineProperty(proto, 'flags', {
configurable: true,
enumerable: false,
get: polyfill
});
}
return polyfill;
};