Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teppeis/2911c795a56e8f82e95b62ce18219d55 to your computer and use it in GitHub Desktop.
Save teppeis/2911c795a56e8f82e95b62ce18219d55 to your computer and use it in GitHub Desktop.
closure compiler output: Set is subclassable
var $jscomp = {scope:{}, getGlobal:function(a) {
return "undefined" != typeof window && window === a ? a : "undefined" != typeof global ? global : a;
}};
$jscomp.global = $jscomp.getGlobal(this);
$jscomp.initSymbol = function() {
$jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol);
$jscomp.initSymbol = function() {
};
};
$jscomp.symbolCounter_ = 0;
$jscomp.Symbol = function(a) {
return "jscomp_symbol_" + a + $jscomp.symbolCounter_++;
};
$jscomp.initSymbolIterator = function() {
$jscomp.initSymbol();
$jscomp.global.Symbol.iterator || ($jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator"));
$jscomp.initSymbolIterator = function() {
};
};
$jscomp.makeIterator = function(a) {
$jscomp.initSymbolIterator();
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
var b = a[Symbol.iterator];
if (b) {
return b.call(a);
}
var c = 0;
return {next:function() {
return c < a.length ? {done:!1, value:a[c++]} : {done:!0};
}};
};
$jscomp.arrayFromIterator = function(a) {
for (var b, c = [];!(b = a.next()).done;) {
c.push(b.value);
}
return c;
};
$jscomp.arrayFromIterable = function(a) {
return a instanceof Array ? a : $jscomp.arrayFromIterator($jscomp.makeIterator(a));
};
$jscomp.inherits = function(a, b) {
function c() {
}
c.prototype = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
for (var d in b) {
if (Object.defineProperties) {
var e = Object.getOwnPropertyDescriptor(b, d);
e && Object.defineProperty(a, d, e);
} else {
a[d] = b[d];
}
}
};
$jscomp.array = $jscomp.array || {};
$jscomp.iteratorFromArray = function(a, b) {
$jscomp.initSymbolIterator();
a instanceof String && (a += "");
var c = 0, d = {next:function() {
if (c < a.length) {
var e = c++;
return {value:b(e, a[e]), done:!1};
}
d.next = function() {
return {done:!0, value:void 0};
};
return d.next();
}};
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
d[Symbol.iterator] = function() {
return d;
};
return d;
};
$jscomp.findInternal = function(a, b, c) {
a instanceof String && (a = String(a));
for (var d = a.length, e = 0;e < d;e++) {
var f = a[e];
if (b.call(c, f, e, a)) {
return {i:e, v:f};
}
}
return {i:-1, v:void 0};
};
$jscomp.array.from = function(a, b, c) {
$jscomp.initSymbolIterator();
b = null != b ? b : function(a) {
return a;
};
var d = [];
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
var e = a[Symbol.iterator];
"function" == typeof e && (a = e.call(a));
if ("function" == typeof a.next) {
for (;!(e = a.next()).done;) {
d.push(b.call(c, e.value));
}
} else {
for (var e = a.length, f = 0;f < e;f++) {
d.push(b.call(c, a[f]));
}
}
return d;
};
$jscomp.array.of = function(a) {
return $jscomp.array.from(arguments);
};
$jscomp.array.entries = function() {
return $jscomp.iteratorFromArray(this, function(a, b) {
return [a, b];
});
};
$jscomp.array.installHelper_ = function(a, b) {
!Array.prototype[a] && Object.defineProperties && Object.defineProperty && Object.defineProperty(Array.prototype, a, {configurable:!0, enumerable:!1, writable:!0, value:b});
};
$jscomp.array.entries$install = function() {
$jscomp.array.installHelper_("entries", $jscomp.array.entries);
};
$jscomp.array.keys = function() {
return $jscomp.iteratorFromArray(this, function(a) {
return a;
});
};
$jscomp.array.keys$install = function() {
$jscomp.array.installHelper_("keys", $jscomp.array.keys);
};
$jscomp.array.values = function() {
return $jscomp.iteratorFromArray(this, function(a, b) {
return b;
});
};
$jscomp.array.values$install = function() {
$jscomp.array.installHelper_("values", $jscomp.array.values);
};
$jscomp.array.copyWithin = function(a, b, c) {
var d = this.length;
a = Number(a);
b = Number(b);
c = Number(null != c ? c : d);
if (a < b) {
for (c = Math.min(c, d);b < c;) {
b in this ? this[a++] = this[b++] : (delete this[a++], b++);
}
} else {
for (c = Math.min(c, d + b - a), a += c - b;c > b;) {
--c in this ? this[--a] = this[c] : delete this[a];
}
}
return this;
};
$jscomp.array.copyWithin$install = function() {
$jscomp.array.installHelper_("copyWithin", $jscomp.array.copyWithin);
};
$jscomp.array.fill = function(a, b, c) {
var d = this.length || 0;
0 > b && (b = Math.max(0, d + b));
if (null == c || c > d) {
c = d;
}
c = Number(c);
0 > c && (c = Math.max(0, d + c));
for (b = Number(b || 0);b < c;b++) {
this[b] = a;
}
return this;
};
$jscomp.array.fill$install = function() {
$jscomp.array.installHelper_("fill", $jscomp.array.fill);
};
$jscomp.array.find = function(a, b) {
return $jscomp.findInternal(this, a, b).v;
};
$jscomp.array.find$install = function() {
$jscomp.array.installHelper_("find", $jscomp.array.find);
};
$jscomp.array.findIndex = function(a, b) {
return $jscomp.findInternal(this, a, b).i;
};
$jscomp.array.findIndex$install = function() {
$jscomp.array.installHelper_("findIndex", $jscomp.array.findIndex);
};
$jscomp.ASSUME_NO_NATIVE_MAP = !1;
$jscomp.Map$isConformant = function() {
if ($jscomp.ASSUME_NO_NATIVE_MAP) {
return !1;
}
var a = $jscomp.global.Map;
if (!a || !a.prototype.entries || "function" != typeof Object.seal) {
return !1;
}
try {
var b = Object.seal({x:4}), c = new a($jscomp.makeIterator([[b, "s"]]));
if ("s" != c.get(b) || 1 != c.size || c.get({x:4}) || c.set({x:4}, "t") != c || 2 != c.size) {
return !1;
}
var d = c.entries(), e = d.next();
if (e.done || e.value[0] != b || "s" != e.value[1]) {
return !1;
}
e = d.next();
return e.done || 4 != e.value[0].x || "t" != e.value[1] || !d.next().done ? !1 : !0;
} catch (f) {
return !1;
}
};
$jscomp.Map = function(a) {
this.data_ = {};
this.head_ = $jscomp.Map.createHead();
this.size = 0;
if (a) {
a = $jscomp.makeIterator(a);
for (var b;!(b = a.next()).done;) {
b = b.value, this.set(b[0], b[1]);
}
}
};
$jscomp.Map.prototype.set = function(a, b) {
var c = $jscomp.Map.maybeGetEntry(this, a);
c.list || (c.list = this.data_[c.id] = []);
c.entry ? c.entry.value = b : (c.entry = {next:this.head_, previous:this.head_.previous, head:this.head_, key:a, value:b}, c.list.push(c.entry), this.head_.previous.next = c.entry, this.head_.previous = c.entry, this.size++);
return this;
};
$jscomp.Map.prototype.delete = function(a) {
a = $jscomp.Map.maybeGetEntry(this, a);
return a.entry && a.list ? (a.list.splice(a.index, 1), a.list.length || delete this.data_[a.id], a.entry.previous.next = a.entry.next, a.entry.next.previous = a.entry.previous, a.entry.head = null, this.size--, !0) : !1;
};
$jscomp.Map.prototype.clear = function() {
this.data_ = {};
this.head_ = this.head_.previous = $jscomp.Map.createHead();
this.size = 0;
};
$jscomp.Map.prototype.has = function(a) {
return !!$jscomp.Map.maybeGetEntry(this, a).entry;
};
$jscomp.Map.prototype.get = function(a) {
return (a = $jscomp.Map.maybeGetEntry(this, a).entry) && a.value;
};
$jscomp.Map.prototype.entries = function() {
return $jscomp.Map.makeIterator_(this, function(a) {
return [a.key, a.value];
});
};
$jscomp.Map.prototype.keys = function() {
return $jscomp.Map.makeIterator_(this, function(a) {
return a.key;
});
};
$jscomp.Map.prototype.values = function() {
return $jscomp.Map.makeIterator_(this, function(a) {
return a.value;
});
};
$jscomp.Map.prototype.forEach = function(a, b) {
for (var c = this.entries(), d;!(d = c.next()).done;) {
d = d.value, a.call(b, d[1], d[0], this);
}
};
$jscomp.Map.maybeGetEntry = function(a, b) {
var c = $jscomp.Map.getId(b), d = a.data_[c];
if (d && Object.prototype.hasOwnProperty.call(a.data_, c)) {
for (a = 0;a < d.length;a++) {
var e = d[a];
if (b !== b && e.key !== e.key || b === e.key) {
return {id:c, list:d, index:a, entry:e};
}
}
}
return {id:c, list:d, index:-1, entry:void 0};
};
$jscomp.Map.makeIterator_ = function(a, b) {
var c = a.head_, d = {next:function() {
if (c) {
for (;c.head != a.head_;) {
c = c.previous;
}
for (;c.next != c.head;) {
return c = c.next, {done:!1, value:b(c)};
}
c = null;
}
return {done:!0, value:void 0};
}};
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
d[Symbol.iterator] = function() {
return d;
};
return d;
};
$jscomp.Map.mapIndex_ = 0;
$jscomp.Map.createHead = function() {
var a = {};
return a.previous = a.next = a.head = a;
};
$jscomp.Map.getId = function(a) {
if (!(a instanceof Object)) {
return "p_" + a;
}
if (!($jscomp.Map.idKey in a)) {
try {
$jscomp.Map.defineProperty(a, $jscomp.Map.idKey, {value:++$jscomp.Map.mapIndex_});
} catch (b) {
}
}
return $jscomp.Map.idKey in a ? a[$jscomp.Map.idKey] : "o_ " + a;
};
$jscomp.Map.defineProperty = Object.defineProperty ? function(a, b, c) {
Object.defineProperty(a, b, {value:String(c)});
} : function(a, b, c) {
a[b] = String(c);
};
$jscomp.Map.Entry = function() {
};
$jscomp.Map$install = function() {
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
$jscomp.Map$isConformant() ? $jscomp.Map = $jscomp.global.Map : ($jscomp.initSymbol(), $jscomp.initSymbolIterator(), $jscomp.Map.prototype[Symbol.iterator] = $jscomp.Map.prototype.entries, $jscomp.initSymbol(), $jscomp.Map.idKey = Symbol("map-id-key"), $jscomp.Map$install = function() {
});
};
$jscomp.math = $jscomp.math || {};
$jscomp.math.clz32 = function(a) {
a = Number(a) >>> 0;
if (0 === a) {
return 32;
}
var b = 0;
0 === (a & 4294901760) && (a <<= 16, b += 16);
0 === (a & 4278190080) && (a <<= 8, b += 8);
0 === (a & 4026531840) && (a <<= 4, b += 4);
0 === (a & 3221225472) && (a <<= 2, b += 2);
0 === (a & 2147483648) && b++;
return b;
};
$jscomp.math.imul = function(a, b) {
a = Number(a);
b = Number(b);
var c = a & 65535, d = b & 65535;
return c * d + ((a >>> 16 & 65535) * d + c * (b >>> 16 & 65535) << 16 >>> 0) | 0;
};
$jscomp.math.sign = function(a) {
a = Number(a);
return 0 === a || isNaN(a) ? a : 0 < a ? 1 : -1;
};
$jscomp.math.log10 = function(a) {
return Math.log(a) / Math.LN10;
};
$jscomp.math.log2 = function(a) {
return Math.log(a) / Math.LN2;
};
$jscomp.math.log1p = function(a) {
a = Number(a);
if (.25 > a && -.25 < a) {
for (var b = a, c = 1, d = a, e = 0, f = 1;e != d;) {
b *= a, f *= -1, d = (e = d) + f * b / ++c;
}
return d;
}
return Math.log(1 + a);
};
$jscomp.math.expm1 = function(a) {
a = Number(a);
if (.25 > a && -.25 < a) {
for (var b = a, c = 1, d = a, e = 0;e != d;) {
b *= a / ++c, d = (e = d) + b;
}
return d;
}
return Math.exp(a) - 1;
};
$jscomp.math.cosh = function(a) {
a = Number(a);
return (Math.exp(a) + Math.exp(-a)) / 2;
};
$jscomp.math.sinh = function(a) {
a = Number(a);
return 0 === a ? a : (Math.exp(a) - Math.exp(-a)) / 2;
};
$jscomp.math.tanh = function(a) {
a = Number(a);
if (0 === a) {
return a;
}
var b = Math.exp(-2 * Math.abs(a)), b = (1 - b) / (1 + b);
return 0 > a ? -b : b;
};
$jscomp.math.acosh = function(a) {
a = Number(a);
return Math.log(a + Math.sqrt(a * a - 1));
};
$jscomp.math.asinh = function(a) {
a = Number(a);
if (0 === a) {
return a;
}
var b = Math.log(Math.abs(a) + Math.sqrt(a * a + 1));
return 0 > a ? -b : b;
};
$jscomp.math.atanh = function(a) {
a = Number(a);
return ($jscomp.math.log1p(a) - $jscomp.math.log1p(-a)) / 2;
};
$jscomp.math.hypot = function(a, b, c) {
a = Number(a);
b = Number(b);
var d, e, f, g = Math.max(Math.abs(a), Math.abs(b));
for (d = 2;d < arguments.length;d++) {
g = Math.max(g, Math.abs(arguments[d]));
}
if (1E100 < g || 1E-100 > g) {
a /= g;
b /= g;
f = a * a + b * b;
for (d = 2;d < arguments.length;d++) {
e = Number(arguments[d]) / g, f += e * e;
}
return Math.sqrt(f) * g;
}
f = a * a + b * b;
for (d = 2;d < arguments.length;d++) {
e = Number(arguments[d]), f += e * e;
}
return Math.sqrt(f);
};
$jscomp.math.trunc = function(a) {
a = Number(a);
if (isNaN(a) || Infinity === a || -Infinity === a || 0 === a) {
return a;
}
var b = Math.floor(Math.abs(a));
return 0 > a ? -b : b;
};
$jscomp.math.cbrt = function(a) {
if (0 === a) {
return a;
}
a = Number(a);
var b = Math.pow(Math.abs(a), 1 / 3);
return 0 > a ? -b : b;
};
$jscomp.number = $jscomp.number || {};
$jscomp.number.isFinite = function(a) {
return "number" !== typeof a ? !1 : !isNaN(a) && Infinity !== a && -Infinity !== a;
};
$jscomp.number.isInteger = function(a) {
return $jscomp.number.isFinite(a) ? a === Math.floor(a) : !1;
};
$jscomp.number.isNaN = function(a) {
return "number" === typeof a && isNaN(a);
};
$jscomp.number.isSafeInteger = function(a) {
return $jscomp.number.isInteger(a) && Math.abs(a) <= $jscomp.number.MAX_SAFE_INTEGER;
};
$jscomp.number.EPSILON = function() {
return Math.pow(2, -52);
}();
$jscomp.number.MAX_SAFE_INTEGER = function() {
return 9007199254740991;
}();
$jscomp.number.MIN_SAFE_INTEGER = function() {
return -9007199254740991;
}();
$jscomp.object = $jscomp.object || {};
$jscomp.object.assign = function(a, b) {
for (var c = 1;c < arguments.length;c++) {
var d = arguments[c];
if (d) {
for (var e in d) {
Object.prototype.hasOwnProperty.call(d, e) && (a[e] = d[e]);
}
}
}
return a;
};
$jscomp.object.is = function(a, b) {
return a === b ? 0 !== a || 1 / a === 1 / b : a !== a && b !== b;
};
$jscomp.ASSUME_NO_NATIVE_SET = !1;
$jscomp.Set$isConformant = function() {
if ($jscomp.ASSUME_NO_NATIVE_SET) {
return !1;
}
var a = $jscomp.global.Set;
if (!a || !a.prototype.entries || "function" != typeof Object.seal) {
return !1;
}
try {
var b = Object.seal({x:4}), c = new a($jscomp.makeIterator([b]));
if (!c.has(b) || 1 != c.size || c.add(b) != c || 1 != c.size || c.add({x:4}) != c || 2 != c.size) {
return !1;
}
var d = c.entries(), e = d.next();
if (e.done || e.value[0] != b || e.value[1] != b) {
return !1;
}
e = d.next();
return e.done || e.value[0] == b || 4 != e.value[0].x || e.value[1] != e.value[0] ? !1 : d.next().done;
} catch (f) {
return !1;
}
};
$jscomp.Set = function(a) {
this.map_ = new $jscomp.Map;
if (a) {
a = $jscomp.makeIterator(a);
for (var b;!(b = a.next()).done;) {
this.add(b.value);
}
}
this.size = this.map_.size;
};
$jscomp.Set.prototype.add = function(a) {
this.map_.set(a, a);
this.size = this.map_.size;
return this;
};
$jscomp.Set.prototype.delete = function(a) {
a = this.map_.delete(a);
this.size = this.map_.size;
return a;
};
$jscomp.Set.prototype.clear = function() {
this.map_.clear();
this.size = 0;
};
$jscomp.Set.prototype.has = function(a) {
return this.map_.has(a);
};
$jscomp.Set.prototype.entries = function() {
return this.map_.entries();
};
$jscomp.Set.prototype.values = function() {
return this.map_.values();
};
$jscomp.Set.prototype.forEach = function(a, b) {
var c = this;
this.map_.forEach(function(d) {
return a.call(b, d, d, c);
});
};
$jscomp.Set$install = function() {
$jscomp.Map$install();
$jscomp.Set$isConformant() ? $jscomp.Set = $jscomp.global.Set : ($jscomp.initSymbol(), $jscomp.initSymbolIterator(), $jscomp.Set.prototype[Symbol.iterator] = $jscomp.Set.prototype.values, $jscomp.Set$install = function() {
});
};
$jscomp.string = $jscomp.string || {};
$jscomp.checkStringArgs = function(a, b, c) {
if (null == a) {
throw new TypeError("The 'this' value for String.prototype." + c + " must not be null or undefined");
}
if (b instanceof RegExp) {
throw new TypeError("First argument to String.prototype." + c + " must not be a regular expression");
}
return a + "";
};
$jscomp.string.fromCodePoint = function(a) {
for (var b = "", c = 0;c < arguments.length;c++) {
var d = Number(arguments[c]);
if (0 > d || 1114111 < d || d !== Math.floor(d)) {
throw new RangeError("invalid_code_point " + d);
}
65535 >= d ? b += String.fromCharCode(d) : (d -= 65536, b += String.fromCharCode(d >>> 10 & 1023 | 55296), b += String.fromCharCode(d & 1023 | 56320));
}
return b;
};
$jscomp.string.repeat = function(a) {
var b = $jscomp.checkStringArgs(this, null, "repeat");
if (0 > a || 1342177279 < a) {
throw new RangeError("Invalid count value");
}
a |= 0;
for (var c = "";a;) {
if (a & 1 && (c += b), a >>>= 1) {
b += b;
}
}
return c;
};
$jscomp.string.repeat$install = function() {
String.prototype.repeat || (String.prototype.repeat = $jscomp.string.repeat);
};
$jscomp.string.codePointAt = function(a) {
var b = $jscomp.checkStringArgs(this, null, "codePointAt"), c = b.length;
a = Number(a) || 0;
if (0 <= a && a < c) {
a |= 0;
var d = b.charCodeAt(a);
if (55296 > d || 56319 < d || a + 1 === c) {
return d;
}
a = b.charCodeAt(a + 1);
return 56320 > a || 57343 < a ? d : 1024 * (d - 55296) + a + 9216;
}
};
$jscomp.string.codePointAt$install = function() {
String.prototype.codePointAt || (String.prototype.codePointAt = $jscomp.string.codePointAt);
};
$jscomp.string.includes = function(a, b) {
return -1 !== $jscomp.checkStringArgs(this, a, "includes").indexOf(a, b || 0);
};
$jscomp.string.includes$install = function() {
String.prototype.includes || (String.prototype.includes = $jscomp.string.includes);
};
$jscomp.string.startsWith = function(a, b) {
var c = $jscomp.checkStringArgs(this, a, "startsWith");
a += "";
var d = c.length, e = a.length;
b = Math.max(0, Math.min(b | 0, c.length));
for (var f = 0;f < e && b < d;) {
if (c[b++] != a[f++]) {
return !1;
}
}
return f >= e;
};
$jscomp.string.startsWith$install = function() {
String.prototype.startsWith || (String.prototype.startsWith = $jscomp.string.startsWith);
};
$jscomp.string.endsWith = function(a, b) {
var c = $jscomp.checkStringArgs(this, a, "endsWith");
a += "";
void 0 === b && (b = c.length);
b = Math.max(0, Math.min(b | 0, c.length));
for (var d = a.length;0 < d && 0 < b;) {
if (c[--b] != a[--d]) {
return !1;
}
}
return 0 >= d;
};
$jscomp.string.endsWith$install = function() {
String.prototype.endsWith || (String.prototype.endsWith = $jscomp.string.endsWith);
};
$jscomp.Set$install();
$jscomp.string.endsWith$install();
$jscomp.string.startsWith$install();
$jscomp.string.includes$install();
$jscomp.string.codePointAt$install();
$jscomp.string.repeat$install();
$jscomp.array.values$install();
$jscomp.array.keys$install();
$jscomp.array.entries$install();
module.exports = function() {
var a = function(a) {
$jscomp.Set.apply(this, arguments);
};
$jscomp.inherits(a, $jscomp.Set);
var b = new a;
b.add(123);
b.add(123);
return b instanceof a && b.has(123);
};
@teppeis
Copy link
Author

teppeis commented Jul 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment