@makano/rew 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/coffeescript/browser.js +144 -139
- package/lib/coffeescript/cake.js +132 -133
- package/lib/coffeescript/coffeescript.js +437 -381
- package/lib/coffeescript/command.js +806 -724
- package/lib/coffeescript/grammar.js +1908 -2474
- package/lib/coffeescript/helpers.js +509 -473
- package/lib/coffeescript/index.js +228 -215
- package/lib/coffeescript/lexer.js +2282 -1909
- package/lib/coffeescript/nodes.js +9782 -9202
- package/lib/coffeescript/optparse.js +255 -227
- package/lib/coffeescript/parser.js +20305 -1265
- package/lib/coffeescript/register.js +107 -87
- package/lib/coffeescript/repl.js +307 -284
- package/lib/coffeescript/rewriter.js +1389 -1079
- package/lib/coffeescript/scope.js +176 -172
- package/lib/coffeescript/sourcemap.js +242 -227
- package/lib/rew/cli/cli.js +243 -202
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +248 -176
- package/lib/rew/const/config_path.js +2 -3
- package/lib/rew/const/default.js +38 -35
- package/lib/rew/const/files.js +9 -9
- package/lib/rew/const/opt.js +8 -8
- package/lib/rew/css/theme.css +2 -2
- package/lib/rew/functions/core.js +55 -57
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -21
- package/lib/rew/functions/export.js +18 -20
- package/lib/rew/functions/fs.js +55 -54
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +116 -110
- package/lib/rew/functions/map.js +13 -16
- package/lib/rew/functions/match.js +35 -26
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -33
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +20 -20
- package/lib/rew/functions/types.js +96 -95
- package/lib/rew/html/ui.html +12 -13
- package/lib/rew/html/ui.js +205 -168
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/findAppInfo.js +14 -14
- package/lib/rew/misc/findAppPath.js +16 -16
- package/lib/rew/misc/seededid.js +9 -11
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +228 -177
- package/lib/rew/modules/context.js +33 -21
- package/lib/rew/modules/fs.js +10 -10
- package/lib/rew/modules/runtime.js +17 -21
- package/lib/rew/modules/yaml.js +27 -30
- package/lib/rew/pkgs/conf.js +80 -80
- package/lib/rew/pkgs/data.js +12 -7
- package/lib/rew/pkgs/date.js +27 -28
- package/lib/rew/pkgs/env.js +6 -8
- package/lib/rew/pkgs/modules/data/bintree.js +52 -52
- package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
- package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
- package/lib/rew/pkgs/modules/data/queue.js +19 -20
- package/lib/rew/pkgs/modules/data/stack.js +19 -19
- package/lib/rew/pkgs/modules/threads/worker.js +36 -26
- package/lib/rew/pkgs/modules/ui/classes.js +182 -178
- package/lib/rew/pkgs/pkgs.js +9 -10
- package/lib/rew/pkgs/rune.js +391 -345
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/package.json +1 -1
@@ -1,66 +1,66 @@
|
|
1
1
|
class TreeNode {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.left = null;
|
5
|
+
this.right = null;
|
6
|
+
}
|
7
7
|
}
|
8
8
|
|
9
9
|
class BinaryTree {
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
constructor() {
|
11
|
+
this.root = null;
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
insert(value) {
|
15
|
+
const newNode = new TreeNode(value);
|
16
|
+
if (!this.root) {
|
17
|
+
this.root = newNode;
|
18
|
+
return;
|
19
|
+
}
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
const insertNode = (node) => {
|
22
|
+
if (value < node.value) {
|
23
|
+
if (!node.left) {
|
24
|
+
node.left = newNode;
|
25
|
+
} else {
|
26
|
+
insertNode(node.left);
|
27
|
+
}
|
28
|
+
} else {
|
29
|
+
if (!node.right) {
|
30
|
+
node.right = newNode;
|
31
|
+
} else {
|
32
|
+
insertNode(node.right);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
insertNode(this.root);
|
38
|
+
}
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
find(value) {
|
41
|
+
const findNode = (node) => {
|
42
|
+
if (!node) return null;
|
43
|
+
if (node.value === value) return node;
|
44
|
+
if (value < node.value) return findNode(node.left);
|
45
|
+
return findNode(node.right);
|
46
|
+
};
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
return findNode(this.root);
|
49
|
+
}
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
toArray() {
|
52
|
+
const elements = [];
|
53
|
+
const traverse = (node) => {
|
54
|
+
if (!node) return;
|
55
|
+
traverse(node.left);
|
56
|
+
elements.push(node.value);
|
57
|
+
traverse(node.right);
|
58
|
+
};
|
59
|
+
traverse(this.root);
|
60
|
+
return elements;
|
61
|
+
}
|
62
62
|
}
|
63
63
|
|
64
64
|
BinaryTree.Node = TreeNode;
|
65
65
|
|
66
|
-
module.exports = { BinaryTree };
|
66
|
+
module.exports = { BinaryTree };
|
@@ -1,100 +1,100 @@
|
|
1
1
|
class DoublyNode {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.next = null;
|
5
|
+
this.prev = null;
|
6
|
+
}
|
7
7
|
}
|
8
8
|
|
9
9
|
class DoublyLinkedList {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
constructor() {
|
11
|
+
this.head = null;
|
12
|
+
this.tail = null;
|
13
|
+
this.length = 0;
|
14
|
+
}
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
append(value) {
|
17
|
+
const newNode = new DoublyNode(value);
|
18
|
+
if (!this.head) {
|
19
|
+
this.head = newNode;
|
20
|
+
this.tail = newNode;
|
21
|
+
} else {
|
22
|
+
this.tail.next = newNode;
|
23
|
+
newNode.prev = this.tail;
|
24
|
+
this.tail = newNode;
|
25
|
+
}
|
26
|
+
this.length++;
|
27
|
+
}
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
prepend(value) {
|
30
|
+
const newNode = new DoublyNode(value);
|
31
|
+
if (!this.head) {
|
32
|
+
this.head = newNode;
|
33
|
+
this.tail = newNode;
|
34
|
+
} else {
|
35
|
+
newNode.next = this.head;
|
36
|
+
this.head.prev = newNode;
|
37
|
+
this.head = newNode;
|
38
|
+
}
|
39
|
+
this.length++;
|
40
|
+
}
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
find(value) {
|
43
|
+
let current = this.head;
|
44
|
+
while (current) {
|
45
|
+
if (current.value === value) {
|
46
|
+
return current;
|
47
|
+
}
|
48
|
+
current = current.next;
|
49
|
+
}
|
50
|
+
return null;
|
51
|
+
}
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
delete(value) {
|
54
|
+
if (!this.head) {
|
55
|
+
return null;
|
56
|
+
}
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
58
|
+
if (this.head.value === value) {
|
59
|
+
this.head = this.head.next;
|
60
|
+
if (this.head) {
|
61
|
+
this.head.prev = null;
|
62
|
+
} else {
|
63
|
+
this.tail = null;
|
64
|
+
}
|
65
|
+
this.length--;
|
66
|
+
return;
|
67
|
+
}
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
69
|
+
let current = this.head;
|
70
|
+
while (current) {
|
71
|
+
if (current.value === value) {
|
72
|
+
if (current.next) {
|
73
|
+
current.next.prev = current.prev;
|
74
|
+
} else {
|
75
|
+
this.tail = current.prev;
|
76
|
+
}
|
77
|
+
if (current.prev) {
|
78
|
+
current.prev.next = current.next;
|
79
|
+
}
|
80
|
+
this.length--;
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
current = current.next;
|
84
|
+
}
|
85
|
+
}
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
87
|
+
toArray() {
|
88
|
+
const elements = [];
|
89
|
+
let current = this.head;
|
90
|
+
while (current) {
|
91
|
+
elements.push(current.value);
|
92
|
+
current = current.next;
|
93
|
+
}
|
94
|
+
return elements;
|
95
|
+
}
|
96
96
|
}
|
97
97
|
|
98
98
|
DoublyLinkedList.Node = DoublyNode;
|
99
99
|
|
100
|
-
module.exports = { DoublyLinkedList };
|
100
|
+
module.exports = { DoublyLinkedList };
|
@@ -1,88 +1,88 @@
|
|
1
1
|
class Node {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.next = null;
|
5
|
+
}
|
6
6
|
}
|
7
7
|
|
8
8
|
class LinkedList {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
constructor() {
|
10
|
+
this.head = null;
|
11
|
+
this.tail = null;
|
12
|
+
this.length = 0;
|
13
|
+
}
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
append(value) {
|
16
|
+
const newNode = new Node(value);
|
17
|
+
if (!this.head) {
|
18
|
+
this.head = newNode;
|
19
|
+
this.tail = newNode;
|
20
|
+
} else {
|
21
|
+
this.tail.next = newNode;
|
22
|
+
this.tail = newNode;
|
23
|
+
}
|
24
|
+
this.length++;
|
25
|
+
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
prepend(value) {
|
28
|
+
const newNode = new Node(value);
|
29
|
+
if (!this.head) {
|
30
|
+
this.head = newNode;
|
31
|
+
this.tail = newNode;
|
32
|
+
} else {
|
33
|
+
newNode.next = this.head;
|
34
|
+
this.head = newNode;
|
35
|
+
}
|
36
|
+
this.length++;
|
37
|
+
}
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
find(value) {
|
40
|
+
let current = this.head;
|
41
|
+
while (current) {
|
42
|
+
if (current.value === value) {
|
43
|
+
return current;
|
44
|
+
}
|
45
|
+
current = current.next;
|
46
|
+
}
|
47
|
+
return null;
|
48
|
+
}
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
delete(value) {
|
51
|
+
if (!this.head) {
|
52
|
+
return null;
|
53
|
+
}
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
if (this.head.value === value) {
|
56
|
+
this.head = this.head.next;
|
57
|
+
this.length--;
|
58
|
+
return;
|
59
|
+
}
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
61
|
+
let current = this.head;
|
62
|
+
while (current.next) {
|
63
|
+
if (current.next.value === value) {
|
64
|
+
current.next = current.next.next;
|
65
|
+
if (current.next === null) {
|
66
|
+
this.tail = current;
|
67
|
+
}
|
68
|
+
this.length--;
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
current = current.next;
|
72
|
+
}
|
73
|
+
}
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
toArray() {
|
76
|
+
const elements = [];
|
77
|
+
let current = this.head;
|
78
|
+
while (current) {
|
79
|
+
elements.push(current.value);
|
80
|
+
current = current.next;
|
81
|
+
}
|
82
|
+
return elements;
|
83
|
+
}
|
84
84
|
}
|
85
85
|
|
86
86
|
LinkedList.Node = Node;
|
87
87
|
|
88
|
-
module.exports = { LinkedList };
|
88
|
+
module.exports = { LinkedList };
|
@@ -1,28 +1,27 @@
|
|
1
1
|
class Queue {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
constructor() {
|
3
|
+
this.items = [];
|
4
|
+
}
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
enqueue(item) {
|
7
|
+
this.items.push(item);
|
8
|
+
}
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
dequeue() {
|
11
|
+
return this.items.shift();
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
isEmpty() {
|
15
|
+
return this.items.length === 0;
|
16
|
+
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
peek() {
|
19
|
+
return this.items[0];
|
20
|
+
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
toArray() {
|
23
|
+
return this.items.slice();
|
24
|
+
}
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
module.exports = { Queue };
|
27
|
+
module.exports = { Queue };
|
@@ -1,27 +1,27 @@
|
|
1
1
|
class Stack {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
constructor() {
|
3
|
+
this.items = [];
|
4
|
+
}
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
push(item) {
|
7
|
+
this.items.push(item);
|
8
|
+
}
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
pop() {
|
11
|
+
return this.items.pop();
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
isEmpty() {
|
15
|
+
return this.items.length === 0;
|
16
|
+
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
peek() {
|
19
|
+
return this.items[this.items.length - 1];
|
20
|
+
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
toArray() {
|
23
|
+
return this.items.slice();
|
24
|
+
}
|
25
25
|
}
|
26
26
|
|
27
|
-
module.exports = { Stack };
|
27
|
+
module.exports = { Stack };
|
@@ -4,34 +4,44 @@ const { exec } = require('../../../modules/runtime');
|
|
4
4
|
const target = {};
|
5
5
|
target.events = [];
|
6
6
|
target.on = (e, cb) => {
|
7
|
-
|
8
|
-
}
|
7
|
+
target.events.push({ e, cb });
|
8
|
+
};
|
9
9
|
target.off = (e) => {
|
10
|
-
|
11
|
-
}
|
10
|
+
target.events = target.events.filter((i) => i.e !== e);
|
11
|
+
};
|
12
12
|
target.emit = (e, data) => {
|
13
|
-
|
14
|
-
}
|
13
|
+
target.events.filter((i) => i.e == e).forEach((i) => i.cb(data));
|
14
|
+
};
|
15
15
|
|
16
16
|
parentPort.on('message', (data) => {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
if (data.type === 'event') {
|
18
|
+
target.emit(data.event, data.data);
|
19
|
+
} else if (data.type === 'start') {
|
20
|
+
(async () => {
|
21
|
+
try {
|
22
|
+
exec(`(${workerData.cb}).call({ process }, context)`, {
|
23
|
+
print: (...a) => console.log(...a),
|
24
|
+
process: {
|
25
|
+
on: (e, cb) => {
|
26
|
+
target.on(e, cb);
|
27
|
+
},
|
28
|
+
off: (e) => {
|
29
|
+
target.off(e);
|
30
|
+
},
|
31
|
+
emit: (e, data) => {
|
32
|
+
parentPort.postMessage({ type: 'event', event: e, data });
|
33
|
+
},
|
34
|
+
exit: (code) => process.exit(code),
|
35
|
+
finish: (data) => {
|
36
|
+
parentPort.postMessage({ type: 'result', result: data });
|
37
|
+
process.exit(0);
|
38
|
+
},
|
39
|
+
},
|
40
|
+
context: workerData.context,
|
41
|
+
});
|
42
|
+
} catch (e) {
|
43
|
+
parentPort.postMessage({ type: 'error', error: e.message });
|
44
|
+
}
|
45
|
+
})();
|
46
|
+
}
|
37
47
|
});
|