Skip to content

Instantly share code, notes, and snippets.

@blinksmith
Created February 28, 2016 17:57
Show Gist options
  • Save blinksmith/bf55f328758dfaada042 to your computer and use it in GitHub Desktop.
Save blinksmith/bf55f328758dfaada042 to your computer and use it in GitHub Desktop.
jscomp
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();
if (a[$jscomp.global.Symbol.iterator]) {
return a[$jscomp.global.Symbol.iterator]();
}
if (!(a instanceof Array || "string" == typeof a || a instanceof String)) {
throw new TypeError(a + " is not iterable");
}
var b = 0;
return {next:function() {
return b == a.length ? {done:!0} : {done:!1, value:a[b++]};
}};
};
$jscomp.arrayFromIterator = function(a) {
for (var b, d = [];!(b = a.next()).done;) {
d.push(b.value);
}
return d;
};
$jscomp.arrayFromIterable = function(a) {
return a instanceof Array ? a : $jscomp.arrayFromIterator($jscomp.makeIterator(a));
};
$jscomp.arrayFromArguments = function(a) {
for (var b = [], d = 0;d < a.length;d++) {
b.push(a[d]);
}
return b;
};
$jscomp.inherits = function(a, b) {
function d() {
}
d.prototype = b.prototype;
a.prototype = new d;
a.prototype.constructor = a;
for (var e in b) {
if ($jscomp.global.Object.defineProperties) {
var f = $jscomp.global.Object.getOwnPropertyDescriptor(b, e);
$jscomp.global.Object.defineProperty(a, e, f);
} else {
a[e] = b[e];
}
}
};
$jscomp.array = $jscomp.array || {};
$jscomp.array.done_ = function() {
return {done:!0, value:void 0};
};
$jscomp.array.arrayIterator_ = function(a, b) {
a instanceof String && (a = String(a));
var d = 0;
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
var e = {}, f = (e.next = function() {
if (d < a.length) {
var e = d++;
return {value:b(e, a[e]), done:!1};
}
f.next = $jscomp.array.done_;
return $jscomp.array.done_();
}, e[Symbol.iterator] = function() {
return f;
}, e);
return f;
};
$jscomp.array.findInternal_ = function(a, b, d) {
a instanceof String && (a = String(a));
for (var e = a.length, f = 0;f < e;f++) {
var g = a[f];
if (b.call(d, g, f, a)) {
return {i:f, v:g};
}
}
return {i:-1, v:void 0};
};
$jscomp.array.from = function(a, b, d) {
b = void 0 === b ? function(a) {
return a;
} : b;
var e = [];
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
if (a[Symbol.iterator]) {
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
a = a[Symbol.iterator]();
for (var f;!(f = a.next()).done;) {
e.push(b.call(d, f.value));
}
} else {
f = a.length;
for (var g = 0;g < f;g++) {
e.push(b.call(d, a[g]));
}
}
return e;
};
$jscomp.array.of = function(a) {
for (var b = [], d = 0;d < arguments.length;++d) {
b[d - 0] = arguments[d];
}
return $jscomp.array.from(b);
};
$jscomp.array.entries = function() {
return $jscomp.array.arrayIterator_(this, function(a, b) {
return [a, b];
});
};
$jscomp.array.entries$install = function() {
Array.prototype.entries || (Array.prototype.entries = $jscomp.array.entries);
};
$jscomp.array.keys = function() {
return $jscomp.array.arrayIterator_(this, function(a) {
return a;
});
};
$jscomp.array.keys$install = function() {
Array.prototype.keys || (Array.prototype.keys = $jscomp.array.keys);
};
$jscomp.array.values = function() {
return $jscomp.array.arrayIterator_(this, function(a, b) {
return b;
});
};
$jscomp.array.values$install = function() {
Array.prototype.values || (Array.prototype.values = $jscomp.array.values);
};
$jscomp.array.copyWithin = function(a, b, d) {
var e = this.length;
a = Number(a);
b = Number(b);
d = Number(null != d ? d : e);
if (a < b) {
for (d = Math.min(d, e);b < d;) {
b in this ? this[a++] = this[b++] : (delete this[a++], b++);
}
} else {
for (d = Math.min(d, e + b - a), a += d - b;d > b;) {
--d in this ? this[--a] = this[d] : delete this[a];
}
}
return this;
};
$jscomp.array.copyWithin$install = function() {
Array.prototype.copyWithin || (Array.prototype.copyWithin = $jscomp.array.copyWithin);
};
$jscomp.array.fill = function(a, b, d) {
null != d && a.length || (d = this.length || 0);
d = Number(d);
for (b = Number((void 0 === b ? 0 : b) || 0);b < d;b++) {
this[b] = a;
}
return this;
};
$jscomp.array.fill$install = function() {
Array.prototype.fill || (Array.prototype.fill = $jscomp.array.fill);
};
$jscomp.array.find = function(a, b) {
return $jscomp.array.findInternal_(this, a, b).v;
};
$jscomp.array.find$install = function() {
Array.prototype.find || (Array.prototype.find = $jscomp.array.find);
};
$jscomp.array.findIndex = function(a, b) {
return $jscomp.array.findInternal_(this, a, b).i;
};
$jscomp.array.findIndex$install = function() {
Array.prototype.findIndex || (Array.prototype.findIndex = $jscomp.array.findIndex);
};
$jscomp.Map = function(a) {
a = void 0 === a ? [] : a;
this.data_ = {};
this.head_ = $jscomp.Map.createHead_();
this.size = 0;
if (a) {
a = $jscomp.makeIterator(a);
for (var b = a.next();!b.done;b = a.next()) {
b = b.value, this.set(b[0], b[1]);
}
}
};
$jscomp.Map.checkBrowserConformance_ = function() {
var a = $jscomp.global.Map;
if (!a || !a.prototype.entries || !Object.seal) {
return !1;
}
try {
var b = Object.seal({x:4}), d = new a($jscomp.makeIterator([[b, "s"]]));
if ("s" != d.get(b) || 1 != d.size || d.get({x:4}) || d.set({x:4}, "t") != d || 2 != d.size) {
return !1;
}
var e = d.entries(), f = e.next();
if (f.done || f.value[0] != b || "s" != f.value[1]) {
return !1;
}
f = e.next();
return f.done || 4 != f.value[0].x || "t" != f.value[1] || !e.next().done ? !1 : !0;
} catch (g) {
return !1;
}
};
$jscomp.Map.createHead_ = function() {
var a = {};
return a.previous = a.next = a.head = a;
};
$jscomp.Map.getId_ = function(a) {
if (!(a instanceof Object)) {
return String(a);
}
$jscomp.Map.key_ in a || a instanceof Object && Object.isExtensible && Object.isExtensible(a) && $jscomp.Map.defineProperty_(a, $jscomp.Map.key_, ++$jscomp.Map.index_);
return $jscomp.Map.key_ in a ? a[$jscomp.Map.key_] : " " + a;
};
$jscomp.Map.prototype.set = function(a, b) {
var d = this.maybeGetEntry_(a), e = d.id, f = d.list, d = d.entry;
f || (f = this.data_[e] = []);
d ? d.value = b : (d = {next:this.head_, previous:this.head_.previous, head:this.head_, key:a, value:b}, f.push(d), this.head_.previous.next = d, this.head_.previous = d, this.size++);
return this;
};
$jscomp.Map.prototype["delete"] = function(a) {
var b = this.maybeGetEntry_(a);
a = b.id;
var d = b.list, e = b.index;
return (b = b.entry) && d ? (d.splice(e, 1), d.length || delete this.data_[a], b.previous.next = b.next, b.next.previous = b.previous, b.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 !!this.maybeGetEntry_(a).entry;
};
$jscomp.Map.prototype.get = function(a) {
return (a = this.maybeGetEntry_(a).entry) && a.value;
};
$jscomp.Map.prototype.maybeGetEntry_ = function(a) {
var b = $jscomp.Map.getId_(a), d = this.data_[b];
if (d) {
for (var e = 0;e < d.length;e++) {
var f = d[e];
if (a !== a && f.key !== f.key || a === f.key) {
return {id:b, list:d, index:e, entry:f};
}
}
}
return {id:b, list:d, index:-1, entry:void 0};
};
$jscomp.Map.prototype.entries = function() {
return this.iter_(function(a) {
return [a.key, a.value];
});
};
$jscomp.Map.prototype.keys = function() {
return this.iter_(function(a) {
return a.key;
});
};
$jscomp.Map.prototype.values = function() {
return this.iter_(function(a) {
return a.value;
});
};
$jscomp.Map.prototype.forEach = function(a, b) {
for (var d = $jscomp.makeIterator(this.entries()), e = d.next();!e.done;e = d.next()) {
e = e.value, a.call(b, e[1], e[0], this);
}
};
$jscomp.Map.prototype.iter_ = function(a) {
var b = this, d = this.head_;
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
var e = {};
return e.next = function() {
if (d) {
for (;d.head != b.head_;) {
d = d.previous;
}
for (;d.next != d.head;) {
return d = d.next, {done:!1, value:a(d)};
}
d = null;
}
return {done:!0, value:void 0};
}, e[Symbol.iterator] = function() {
return this;
}, e;
};
$jscomp.Map.index_ = 0;
$jscomp.Map.defineProperty_ = Object.defineProperty ? function(a, b, d) {
Object.defineProperty(a, b, {value:String(d)});
} : function(a, b, d) {
a[b] = String(d);
};
$jscomp.Map.Entry_ = function() {
};
$jscomp.Map.ASSUME_NO_NATIVE = !1;
$jscomp.Map$install = function() {
$jscomp.initSymbol();
$jscomp.initSymbolIterator();
!$jscomp.Map.ASSUME_NO_NATIVE && $jscomp.Map.checkBrowserConformance_() ? $jscomp.Map = $jscomp.global.Map : ($jscomp.initSymbol(), $jscomp.initSymbolIterator(), $jscomp.Map.prototype[Symbol.iterator] = $jscomp.Map.prototype.entries, $jscomp.initSymbol(), $jscomp.Map.key_ = 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 d = a & 65535, e = b & 65535;
return d * e + ((a >>> 16 & 65535) * e + d * (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, d = 1, e = a, f = 0, g = 1;f != e;) {
b *= a, g *= -1, e = (f = e) + g * b / ++d;
}
return e;
}
return Math.log(1 + a);
};
$jscomp.math.expm1 = function(a) {
a = Number(a);
if (.25 > a && -.25 < a) {
for (var b = a, d = 1, e = a, f = 0;f != e;) {
b *= a / ++d, e = (f = e) + b;
}
return e;
}
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, d) {
for (var e = [], f = 2;f < arguments.length;++f) {
e[f - 2] = arguments[f];
}
a = Number(a);
b = Number(b);
for (var g = Math.max(Math.abs(a), Math.abs(b)), h = $jscomp.makeIterator(e), f = h.next();!f.done;f = h.next()) {
g = Math.max(g, Math.abs(f.value));
}
if (1E100 < g || 1E-100 > g) {
a /= g;
b /= g;
h = a * a + b * b;
e = $jscomp.makeIterator(e);
for (f = e.next();!f.done;f = e.next()) {
f = f.value, f = Number(f) / g, h += f * f;
}
return Math.sqrt(h) * g;
}
g = a * a + b * b;
e = $jscomp.makeIterator(e);
for (f = e.next();!f.done;f = e.next()) {
f = f.value, g += f * f;
}
return Math.sqrt(g);
};
$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 = Math.pow(2, -52);
$jscomp.number.MAX_SAFE_INTEGER = 9007199254740991;
$jscomp.number.MIN_SAFE_INTEGER = -9007199254740991;
$jscomp.object = $jscomp.object || {};
$jscomp.object.assign = function(a, b) {
for (var d = [], e = 1;e < arguments.length;++e) {
d[e - 1] = arguments[e];
}
d = $jscomp.makeIterator(d);
for (e = d.next();!e.done;e = d.next()) {
var e = e.value, f;
for (f in e) {
Object.prototype.hasOwnProperty.call(e, f) && (a[f] = e[f]);
}
}
return a;
};
$jscomp.object.is = function(a, b) {
return a === b ? 0 !== a || 1 / a === 1 / b : a !== a && b !== b;
};
$jscomp.Set = function(a) {
a = void 0 === a ? [] : a;
this.map_ = new $jscomp.Map;
if (a) {
a = $jscomp.makeIterator(a);
for (var b = a.next();!b.done;b = a.next()) {
this.add(b.value);
}
}
this.size = this.map_.size;
};
$jscomp.Set.checkBrowserConformance_ = function() {
var a = $jscomp.global.Set;
if (!a || !a.prototype.entries || !Object.seal) {
return !1;
}
var b = Object.seal({x:4}), a = new a($jscomp.makeIterator([b]));
if (a.has(b) || 1 != a.size || a.add(b) != a || 1 != a.size || a.add({x:4}) != a || 2 != a.size) {
return !1;
}
var a = a.entries(), d = a.next();
if (d.done || d.value[0] != b || d.value[1] != b) {
return !1;
}
d = a.next();
return d.done || d.value[0] == b || 4 != d.value[0].x || d.value[1] != d.value[0] ? !1 : a.next().done;
};
$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 d = this;
this.map_.forEach(function(e) {
return a.call(b, e, e, d);
});
};
$jscomp.Set.ASSUME_NO_NATIVE = !1;
$jscomp.Set$install = function() {
!$jscomp.Set.ASSUME_NO_NATIVE && $jscomp.Set.checkBrowserConformance_() ? $jscomp.Set = $jscomp.global.Set : ($jscomp.Map$install(), $jscomp.initSymbol(), $jscomp.initSymbolIterator(), $jscomp.Set.prototype[Symbol.iterator] = $jscomp.Set.prototype.values);
$jscomp.Set$install = function() {
};
};
$jscomp.string = $jscomp.string || {};
$jscomp.string.noRegExp_ = function(a, b) {
if (a instanceof RegExp) {
throw new TypeError("First argument to String.prototype." + b + " must not be a regular expression");
}
};
$jscomp.string.fromCodePoint = function(a) {
for (var b = [], d = 0;d < arguments.length;++d) {
b[d - 0] = arguments[d];
}
for (var d = "", b = $jscomp.makeIterator(b), e = b.next();!e.done;e = b.next()) {
e = e.value;
e = +e;
if (0 > e || 1114111 < e || e !== Math.floor(e)) {
throw new RangeError("invalid_code_point " + e);
}
65535 >= e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(e >>> 10 & 1023 | 55296), d += String.fromCharCode(e & 1023 | 56320));
}
return d;
};
$jscomp.string.repeat = function(a) {
var b = this.toString();
if (0 > a || 1342177279 < a) {
throw new RangeError("Invalid count value");
}
a |= 0;
for (var d = "";a;) {
if (a & 1 && (d += b), a >>>= 1) {
b += b;
}
}
return d;
};
$jscomp.string.repeat$install = function() {
String.prototype.repeat || (String.prototype.repeat = $jscomp.string.repeat);
};
$jscomp.string.codePointAt = function(a) {
var b = this.toString(), d = b.length;
a = Number(a) || 0;
if (0 <= a && a < d) {
a |= 0;
var e = b.charCodeAt(a);
if (55296 > e || 56319 < e || a + 1 === d) {
return e;
}
a = b.charCodeAt(a + 1);
return 56320 > a || 57343 < a ? e : 1024 * (e - 55296) + a + 9216;
}
};
$jscomp.string.codePointAt$install = function() {
String.prototype.codePointAt || (String.prototype.codePointAt = $jscomp.string.codePointAt);
};
$jscomp.string.includes = function(a, b) {
b = void 0 === b ? 0 : b;
$jscomp.string.noRegExp_(a, "includes");
return -1 !== this.toString().indexOf(a, b);
};
$jscomp.string.includes$install = function() {
String.prototype.includes || (String.prototype.includes = $jscomp.string.includes);
};
$jscomp.string.startsWith = function(a, b) {
b = void 0 === b ? 0 : b;
$jscomp.string.noRegExp_(a, "startsWith");
var d = this.toString();
a += "";
for (var e = d.length, f = a.length, g = Math.max(0, Math.min(b | 0, d.length)), h = 0;h < f && g < e;) {
if (d[g++] != a[h++]) {
return !1;
}
}
return h >= f;
};
$jscomp.string.startsWith$install = function() {
String.prototype.startsWith || (String.prototype.startsWith = $jscomp.string.startsWith);
};
$jscomp.string.endsWith = function(a, b) {
$jscomp.string.noRegExp_(a, "endsWith");
var d = this.toString();
a += "";
void 0 === b && (b = d.length);
for (var e = Math.max(0, Math.min(b | 0, d.length)), f = a.length;0 < f && 0 < e;) {
if (d[--e] != a[--f]) {
return !1;
}
}
return 0 >= f;
};
$jscomp.string.endsWith$install = function() {
String.prototype.endsWith || (String.prototype.endsWith = $jscomp.string.endsWith);
};
function _instanceof(a, b) {
$jscomp.initSymbol();
return null != b && b[Symbol.hasInstance] ? ($jscomp.initSymbol(), b[Symbol.hasInstance](a)) : a instanceof b;
}
function _typeof(a) {
$jscomp.initSymbol();
return a && a.constructor === Symbol ? "symbol" : typeof a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment