This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(a){function c(e,f){var g=Object.create(this);if(e instanceof Array){if(f instanceof Array)for(var h in e)g[e[h]]=f[h];else for(var h in e)g[e[h]]=f;}else if(e instanceof Object)for(var j in e)g[j]=e[j];else g[e]=f;return g=Object.create(g),Object.freeze(g),g}function*d(){for(let e in this)yield this[e]}a.Subzero=function(e){var f=this;return f[Symbol.iterator]=d,Object.defineProperty(f,"set",{value:c}),Object.freeze(f),f.set(e)}})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is implementing a iterable WeakMap | |
// It has the same methods as WeakMap and in addition: | |
// It's keys and values are readable properties. | |
// It can be iterated by map and reduce, Arguments: key, value | |
class IterableWeakMap{ | |
constructor(){ | |
Object.defineProperties(this,{ | |
keys:{ | |
enumerable: false, | |
writable: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// subClass returns a constructor wrapper function that has all the methods in the subclass Prototype, | |
// while keeping the original return type's prototype | |
// when to use? augmenting objects generated by classes with methods. | |
// since it is a wrapper also native classes like Array, String, Number can safely be extended | |
// adding methods to returned objects is also reasonably fast this way, because only the Prototype needs to be set | |
function subClass(constructor, returnType, methods) { | |
function collector() {} | |
methods = methods ? methods instanceof Array ? methods : [methods] : []; | |
const subConstructor = function() { | |
const obj = constructor(...arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global) { | |
// Instead of looping trough all possibilities a object property lookup is used | |
// The object construction is in addition memoized, since it's relatively expensive | |
var hashFindHash = {}; | |
function hashFind(str, hash, delimiter) { | |
delimiter = delimiter || ";"; | |
if (hashFindHash.hasOwnProperty(hash)) { | |
return hashFindHash[hash].hasOwnProperty(str); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global) { | |
var PARENT = "[[__PARENT__]]"; | |
function Immutable(obj) { | |
if (obj instanceof Object) { | |
for (var keys = Object.keys(obj), i = 0; i < keys.length; i++) { | |
this[keys[i]] = obj[keys[i]]; | |
} | |
} | |
if (obj !== false) Object.freeze(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://mozilla.github.io/server-side-tls/ssl-config-generator/ | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response. | |
return 301 https://$host$request_uri; | |
} | |
server { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serialize(form){ | |
if (!form || form.nodeName !== "FORM") return; | |
var el, op, obj = {}, name, type, value, node; | |
for (el of form.elements) { | |
name=el.name; | |
if (name === "") continue; | |
type=el.type; | |
value=el.value; | |
node=el.nodeName; | |
if(/INPUT/.exec(node) && (/text|hidden|password|button|reset|submit/.exec(type) || /checkbox|radio/.exec(type)&&el.checked) || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function roundN(n,m){ | |
return Math.round(n*Math.pow(10,m)+72e-16)/Math.pow(10,m); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.font-smoothing { | |
/* Adjust font size */ | |
font-size: 100%; | |
-webkit-text-size-adjust: 100%; | |
/* Font varient */ | |
font-variant-ligatures: none; | |
-webkit-font-variant-ligatures: none; | |
/* Smoothing */ | |
font-smooth: always; | |
text-rendering: optimizeLegibility; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>compare</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |