source: trip-planner-front/node_modules/regexp.prototype.flags/shim.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 779 bytes
Line 
1'use strict';
2
3var supportsDescriptors = require('define-properties').supportsDescriptors;
4var getPolyfill = require('./polyfill');
5var gOPD = Object.getOwnPropertyDescriptor;
6var defineProperty = Object.defineProperty;
7var TypeErr = TypeError;
8var getProto = Object.getPrototypeOf;
9var regex = /a/;
10
11module.exports = function shimFlags() {
12 if (!supportsDescriptors || !getProto) {
13 throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
14 }
15 var polyfill = getPolyfill();
16 var proto = getProto(regex);
17 var descriptor = gOPD(proto, 'flags');
18 if (!descriptor || descriptor.get !== polyfill) {
19 defineProperty(proto, 'flags', {
20 configurable: true,
21 enumerable: false,
22 get: polyfill
23 });
24 }
25 return polyfill;
26};
Note: See TracBrowser for help on using the repository browser.