Metamethod | 5.1 | 5.2 | 5.3 | Syntax | Notes |
---|---|---|---|---|---|
__add |
✔️ | ✔️ | ✔️ | a + b |
|
__sub |
✔️ | ✔️ | ✔️ | a - b |
|
__mul |
✔️ | ✔️ | ✔️ | a * b |
|
__div |
✔️ | ✔️ | ✔️ | a / b |
|
__mod |
✔️ | ✔️ | ✔️ | a % b |
|
__pow |
✔️ | ✔️ | ✔️ | a ^ b |
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
// Don't ask about this one. I have no idea what this magic is. | |
// Copied from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-724542300. | |
type UnionToIntersection<U> = | |
(U extends any ? (arg: U) => any : never) extends (arg: infer I) => void | |
? I | |
: never; | |
// Continuation of above. | |
type UnionToTuple<T> = | |
UnionToIntersection<(T extends any ? (t: T) => T : never)> extends (_: any) => infer W |
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
console.delayLog = function(delayMs, message) { | |
var style = | |
"color: rgb(249, 162, 34);" + | |
"font-size: 60px;" + | |
"font-weight: bold;" + | |
"text-shadow: 1px 1px 5px rgb(249, 162, 34);" + | |
"filter: dropshadow(color=rgb(249, 162, 34), offx=1, offy=1);"; | |
setTimeout(function() { | |
console.log(message, style); | |
}, delayMs); |
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
- | |
var base = 2, | |
exp = 8, | |
listEnts = false; | |
div.main | |
div.footer | |
div.bubbles | |
- | |
for (var i = 0; i < Math.pow(base, exp); i++) //Small numbers looks nice too |
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
// ==UserScript== | |
// @name GM_download emulation | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description emulate GM_download functionality | |
// @require https://github.com/eligrey/FileSaver.js/blob/master/dist/FileSaver.min.js | |
// @grant GM_xmlhttpRequest | |
// @copyright 2014, Jan Biniok | |
// ==/UserScript== |
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
// ==UserScript== | |
// @name Old Reddit, Forever | |
// @namespace gitlab.com/disk0/userscript/reddit/old | |
// @version 0.1.0 | |
// @author disk0 | |
// @include /^https?:\/\/((?!old)[a-z][a-z\d_]*\.)?reddit\.com.*/ | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== |
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 class wraps an iterator/iterable and allows the map/filter/reduce methods | |
* to be used without being forced to make intermediate temporary arrays. | |
* I've also implemented the flatten and flatmap functions for convenience | |
*/ | |
class FunctionalIterator { | |
constructor(source) { | |
// Get iterator from source, if present. Otherwise, assume that the source is an iterator | |
this.source = source[Symbol.iterator] ? source[Symbol.iterator]() : source; | |
} |
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
class Base | |
{ | |
first = { v: 1 }; | |
second = this.first; | |
} | |
class Derived extends Base | |
{ | |
first = { v: 2 }; | |
} |
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
class Base | |
{ | |
first = { v: 1 }; | |
second = () => this.first; | |
} | |
class Derived extends Base | |
{ | |
first = { v: 2 }; | |
} |
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
class VirtHandler | |
{ | |
target: any; | |
get( t: any, p: PropertyKey, r: any): any | |
{ | |
return this.target[p]; | |
} | |
} |