source: imaps-frontend/node_modules/regexp.prototype.flags/shim.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • 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.