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
const { readFileSync, writeFileSync } = require("fs"); | |
const { resolve } = require("path"); | |
const FlippedBit = 0b1000_0000; | |
const ScourgedBit = 0b0100_0000; | |
const VariationBitMask = 0b0011_1111; | |
function check(condition, message = "assertion failed") { | |
if (!condition) { | |
console.error(message); |
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
export interface InstanceConstructor< | |
/**Enum */ E, | |
/**Shared properties */ S, | |
/**Unique properties */ T | |
> { | |
/**Create new instance */ | |
(diffs?: S & T): S & T; | |
/**Type guard for destructuring */ | |
typecheck(object: {}): object is S & T; | |
/**For introspection, and to make IntelliSense work */ |
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 setKeyValue(object, path, value) { | |
var prop_cont_pair = path.split('.'); | |
var prop = prop_cont_pair[0]; | |
var cont = prop_cont_pair.slice(1).join('.'); | |
if (cont === '') { | |
object[prop] = value; | |
} else { | |
if(typeof object[prop] === 'undefined') { | |
object[prop] = {}; |
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 getKeyValue(object, path, default_value){ | |
"use strict" | |
if (typeof object === 'undefined') { | |
return default_value; | |
} | |
let prop_cont_pair = path.split('.'); | |
let prop = prop_cont_pair[0]; | |
let cont = prop_cont_pair.slice(1).join('.'); | |
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
const $1 = new Proxy({}, { | |
get(target, key) { | |
return x => x[key]; | |
} | |
}); |
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
Object.defineProperty(Object.prototype, 'extend', {value: function (proto_props) { | |
var child = proto_props.hasOwnProperty('constructor') ? | |
proto_props.constructor : | |
function () {child.__super__.constructor.apply(this, arguments);}; | |
child.prototype = Object.create(this.prototype); | |
child.prototype.constructor = child; | |
Object.keys(proto_props).forEach(function (key) { |
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 method(obj, func) { | |
if (func.name !== "" && func.name !== 'anonymous') { | |
obj.prototype[func.name] = func; | |
}; | |
}; |
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
CustomEventTarget = (function () { | |
function CustomEventTarget() { | |
if (!(this instanceof CustomEventTarget)) { | |
return new CustomEventTarget(); | |
}; | |
Object.defineProperty(this, '_listeners_', { | |
value: {} | |
}); | |
}; | |
method(CustomEventTarget, 'addEventListener', function (type, func) { |
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 __module(base, name, func) { | |
if (typeof base[name] === 'undefined') { | |
base[name] = {}; | |
} | |
func(base[name]); | |
} | |
//usage: | |
// __module(window.MyModule, 'namespace', function (exports) { | |
// exports.sayHello = function () { |
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
window.call_super = function call_super(obj, name) { | |
var super_class = Object.getPrototypeOf(Object.getPrototypeOf(obj)); | |
return (function () { | |
super_class[name].apply(obj, arguments); | |
}) | |
} |
NewerOlder