1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<script>
const sleep = t => new Promise(r => setTimeout(r, t))
Array.prototype.each = Array.prototype.forEach
Array.prototype.shuffle = function() {
for (let i = this.length; i >= 0; --i) {
let j = Math.floor(Math.random() * (i + 1))
;[this[i], this[j]] = [this[j], this[i]]
}
return this
}
Object.defineProperty(Array.prototype, -1, {
get() { return this[this.length-1] },
set(x) { this[this.length-1] = x },
})
Object.prototype.ǀ = function(f) { f(this); return this }
Object.prototype.in_p = function(coll) { return coll.includes(this) }
const fi = ss => x => x[ss[0]]
const ff = ss => (x, ...a) => x[ss[0]](...a)
const ė = (name, props, ...children) =>
Object.assign(document.createElement(name), props)
.ǀ(e => e.append(...children))
const Œ = Object.assign
const Æ = (size, fill) => Array(size).fill(fill)
const 𝑓 = (ss, ...ii) => (
ss = ss.flatMap((s, i) => [s, ii[i] ? `arguments[${ii[i]-1}]` : ""]),
new Function("", `return (${ss.join("")})`)
)
const ı = i => Æ(i).map(𝑓`${2}`)
const Enum = ss =>
Object.fromEntries(ss[0]
.trim()
.split(/\s*,\s*/)
.filter(fi`length`)
.map(Array))
</script>
|