-
Notifications
You must be signed in to change notification settings - Fork 13
/
playground.html
45 lines (44 loc) · 1.57 KB
/
playground.html
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
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Iterator.range</title>
<style>
body {
font-family: "Comic Sans MS", "Comic Sans", cursive;
font-size: xx-large;
}
</style>
</head>
<body>
Open your console and Iterator.range is available.
<script src="./iterator-helper.js"></script>
<script src="./polyfill.js"></script>
<script>
globalThis.a = Iterator.range(0, 10, 1)
console.log("globalThis.a", a)
function display(f) {
const stringify = f
.toString()
.replace(/^\(\) =>/, "")
.replace(/^\s+/gm, "")
.split("\n")
.map((x, i) => (i > 0 ? " " + x : x))
.join("\n")
console.log(stringify, stringify.includes("\n") ? "\n" : "", f())
}
display(() => Iterator.range(-2, 8).toArray())
display(() => Iterator.range(-2n, 8n).toArray())
display(() => Iterator.range(2, -2, -1).toArray())
display(() => Iterator.range(0, 5, { step: 1.5 }).toArray())
display(() =>
Iterator.range(1, 10)
.take(4)
.map((x) => x ** x)
.toArray()
)
</script>
</body>
</html>