source: imaps-frontend/node_modules/string.prototype.matchall/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: 1.3 KB
Line 
1'use strict';
2
3var define = require('define-properties');
4var hasSymbols = require('has-symbols')();
5var gOPD = require('gopd');
6
7var getPolyfill = require('./polyfill');
8var regexpMatchAllPolyfill = require('./polyfill-regexp-matchall');
9
10var defineP = Object.defineProperty;
11
12module.exports = function shimMatchAll() {
13 var polyfill = getPolyfill();
14 define(
15 String.prototype,
16 { matchAll: polyfill },
17 { matchAll: function () { return String.prototype.matchAll !== polyfill; } }
18 );
19 if (hasSymbols) {
20 // eslint-disable-next-line no-restricted-properties
21 var symbol = Symbol.matchAll || (Symbol['for'] ? Symbol['for']('Symbol.matchAll') : Symbol('Symbol.matchAll'));
22 define(
23 Symbol,
24 { matchAll: symbol },
25 { matchAll: function () { return Symbol.matchAll !== symbol; } }
26 );
27
28 if (defineP && gOPD) {
29 var desc = gOPD(Symbol, symbol);
30 if (!desc || desc.configurable) {
31 defineP(Symbol, symbol, {
32 configurable: false,
33 enumerable: false,
34 value: symbol,
35 writable: false
36 });
37 }
38 }
39
40 var regexpMatchAll = regexpMatchAllPolyfill();
41 var func = {};
42 func[symbol] = regexpMatchAll;
43 var predicate = {};
44 predicate[symbol] = function () {
45 return RegExp.prototype[symbol] !== regexpMatchAll;
46 };
47 define(RegExp.prototype, func, predicate);
48 }
49 return polyfill;
50};
Note: See TracBrowser for help on using the repository browser.