source: frontend/node_modules/core-js/internals/set-method-accept-set-like.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.4 KB
Line 
1'use strict';
2var getBuiltIn = require('../internals/get-built-in');
3
4var createSetLike = function (size) {
5 return {
6 size: size,
7 has: function () {
8 return false;
9 },
10 keys: function () {
11 return {
12 next: function () {
13 return { done: true };
14 }
15 };
16 }
17 };
18};
19
20var createSetLikeWithInfinitySize = function (size) {
21 return {
22 size: size,
23 has: function () {
24 return true;
25 },
26 keys: function () {
27 throw new Error('e');
28 }
29 };
30};
31
32module.exports = function (name, callback) {
33 var Set = getBuiltIn('Set');
34 try {
35 new Set()[name](createSetLike(0));
36 try {
37 // late spec change, early WebKit ~ Safari 17 implementation does not pass it
38 // https://github.com/tc39/proposal-set-methods/pull/88
39 // also covered engines with
40 // https://bugs.webkit.org/show_bug.cgi?id=272679
41 new Set()[name](createSetLike(-1));
42 return false;
43 } catch (error2) {
44 if (!callback) return true;
45 // early V8 implementation bug
46 // https://issues.chromium.org/issues/351332634
47 try {
48 new Set()[name](createSetLikeWithInfinitySize(-Infinity));
49 return false;
50 } catch (error) {
51 var set = new Set([1, 2]);
52 return callback(set[name](createSetLikeWithInfinitySize(Infinity)));
53 }
54 }
55 } catch (error) {
56 return false;
57 }
58};
Note: See TracBrowser for help on using the repository browser.