This file contains hidden or 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
| ################ | |
| # Fix encoding # | |
| ################ | |
| $OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() | |
| ##################### | |
| # Environement vars # | |
| ##################### |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 parseHeader(letters: string): number { | |
| function letterValue(letter: string): number { | |
| return parseInt(letter, 36) - 9 | |
| } | |
| let result = 0 | |
| let factor = 1 | |
| if (letters.length === 1) { | |
| result = letterValue(letters[0]) |
This file contains hidden or 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.iter = function iter(array) { | |
| var copy = array.slice(); | |
| var i = 0; | |
| var max = copy.length - 1; | |
| var next = function next() { | |
| var index = i | |
| i += 1 | |
| if (index > max) { |
This file contains hidden or 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
| // Sometimes you'll need a value type; for representing a point, or other values | |
| // which are fully defined after construction. If we take the example of a point: | |
| class Point { | |
| constructor(public x: number, public y: number) { | |
| return Object.freeze(this); | |
| } | |
| } | |
| let p = new Point(3, 4); |
This file contains hidden or 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 hidden or 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 hidden or 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; | |
| }; | |
| }; |
NewerOlder