-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
polyfill.js
68 lines (59 loc) · 1.68 KB
/
polyfill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
var OrdinarySetPrototypeOf = require('es-abstract/2024/OrdinarySetPrototypeOf');
var define = require('define-properties');
var SLOT = require('internal-slot');
var implementation = require('./implementation');
var addIterableToSet = require('./lib/set-helpers').addIterableToSet;
var support = require('./lib/support');
var SetShim;
module.exports = function getPolyfill() {
if (
typeof Set === 'function'
&& !support.setCompliantConstructor()
&& support.setUsesSameValueZero()
) {
var OrigSet = Set;
if (
!SetShim
|| !(OrigSet === SetShim || SLOT.get(SetShim, '[[OrigSet]]') === OrigSet)
) {
var OrigSet$prototype = OrigSet.prototype;
SetShim = function Set() {
if (!(this instanceof SetShim)) {
throw new TypeError('Constructor Set requires "new"');
}
if (this && SLOT.has(this, '[[SetCompliantConstructorShim]]')) {
throw new TypeError('Bad construction');
}
var s = new OrigSet();
SLOT.set(s, '[[SetCompliantConstructorShim]]', true);
if (arguments.length > 0) {
addIterableToSet(s, arguments[0]);
}
delete s.constructor;
OrdinarySetPrototypeOf(s, SetShim.prototype);
return s;
};
SLOT.set(SetShim, '[[OrigSet]]', Set);
SetShim.prototype = OrigSet$prototype;
define(
SetShim.prototype,
{ constructor: SetShim },
{ constructor: function () { return true; } }
);
}
return SetShim;
}
if (
typeof Set !== 'function'
|| support.isGoogleTranslate()
|| support.setHasOldFirefoxInterface()
|| !support.setHasCorrectName()
|| !support.setKeysIsValues()
|| !support.setSupportsChaining()
|| !support.setUsesSameValueZero()
) {
return implementation;
}
return Set;
};