porffor 0.14.0-86ac87fa4 → 0.14.0-a3af2f547
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +9 -3
- package/asur/index.js +1 -1
- package/bf_bun +0 -0
- package/bf_deno +0 -0
- package/bf_porf +0 -0
- package/bf_porf_fast +0 -0
- package/bf_porf_lto +0 -0
- package/compiler/2c.js +65 -2
- package/compiler/assemble.js +14 -0
- package/compiler/builtins/annexb_string.ts +1 -0
- package/compiler/builtins/array.ts +84 -4
- package/compiler/builtins/base64.ts +1 -0
- package/compiler/builtins/boolean.ts +2 -0
- package/compiler/builtins/crypto.ts +1 -0
- package/compiler/builtins/date.ts +2 -0
- package/compiler/builtins/error.js +22 -0
- package/compiler/builtins/escape.ts +1 -2
- package/compiler/builtins/function.ts +2 -0
- package/compiler/builtins/int.ts +2 -0
- package/compiler/builtins/math.ts +410 -0
- package/compiler/builtins/number.ts +2 -0
- package/compiler/builtins/object.ts +2 -0
- package/compiler/builtins/set.ts +7 -6
- package/compiler/builtins/string.ts +1 -0
- package/compiler/builtins/symbol.ts +3 -1
- package/compiler/builtins.js +33 -6
- package/compiler/codegen.js +490 -258
- package/compiler/generated_builtins.js +491 -60
- package/compiler/index.js +1 -1
- package/compiler/parse.js +1 -1
- package/compiler/precompile.js +5 -4
- package/compiler/prefs.js +1 -1
- package/compiler/prototype.js +180 -157
- package/compiler/wrap.js +66 -37
- package/demos/bf/hello.bf +1 -0
- package/demos/bf/mandelbrot.bf +1 -0
- package/demos/bf/node.js +56 -0
- package/demos/bf/porf.js +57 -0
- package/demos/bf/porf.ts +59 -0
- package/demos/cat/porf.js +6 -0
- package/package.json +1 -1
- package/runner/index.js +5 -4
- package/runner/repl.js +18 -2
- package/w.js +1 -0
package/compiler/wrap.js
CHANGED
@@ -41,9 +41,22 @@ const porfToJSValue = ({ memory, funcs, pages }, value, type) => {
|
|
41
41
|
case TYPES.array: {
|
42
42
|
const length = (new Int32Array(memory.buffer, value, 1))[0];
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
const out = [];
|
45
|
+
for (let i = 0; i < length; i++) {
|
46
|
+
const offset = value + 4 + (i * 9);
|
47
|
+
|
48
|
+
// have to slice because of memory alignment (?)
|
49
|
+
const v = (new Float64Array(memory.buffer.slice(offset, offset + 8), 0, 1))[0];
|
50
|
+
const t = (new Uint8Array(memory.buffer, offset + 8, 1))[0];
|
51
|
+
|
52
|
+
// console.log(`reading value at index ${i}...`)
|
53
|
+
// console.log(' memory:', Array.from(new Uint8Array(memory.buffer, offset, 9)).map(x => x.toString(16).padStart(2, '0')).join(' '));
|
54
|
+
// console.log(' read:', { value: v, type: t }, '\n');
|
55
|
+
|
56
|
+
out.push(porfToJSValue({ memory, funcs, pages }, v, t));
|
57
|
+
}
|
58
|
+
|
59
|
+
return out;
|
47
60
|
}
|
48
61
|
|
49
62
|
case TYPES.date: {
|
@@ -103,40 +116,12 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
103
116
|
times.push(performance.now() - t1);
|
104
117
|
if (Prefs.profileCompiler) console.log(bold(`compiled in ${times[0].toFixed(2)}ms`));
|
105
118
|
|
106
|
-
const
|
107
|
-
|
108
|
-
let instance;
|
109
|
-
try {
|
110
|
-
let wasmEngine = WebAssembly;
|
111
|
-
if (Prefs.asur) {
|
112
|
-
log.warning('wrap', 'using our !experimental! asur wasm engine instead of host to run');
|
113
|
-
wasmEngine = await import('../asur/index.js');
|
114
|
-
}
|
115
|
-
|
116
|
-
0, { instance } = await wasmEngine.instantiate(wasm, {
|
117
|
-
'': {
|
118
|
-
p: valtype === 'i64' ? i => print(Number(i).toString()) : i => print(i.toString()),
|
119
|
-
c: valtype === 'i64' ? i => print(String.fromCharCode(Number(i))) : i => print(String.fromCharCode(i)),
|
120
|
-
t: () => performance.now(),
|
121
|
-
u: () => performance.timeOrigin,
|
122
|
-
y: () => {},
|
123
|
-
z: () => {},
|
124
|
-
...customImports
|
125
|
-
}
|
126
|
-
});
|
127
|
-
} catch (e) {
|
128
|
-
// only backtrace for runner, not test262/etc
|
129
|
-
if (!process.argv[1].includes('/runner')) throw e;
|
130
|
-
|
131
|
-
const funcInd = parseInt(e.message.match(/function #([0-9]+) /)?.[1]);
|
132
|
-
const blobOffset = parseInt(e.message.split('@')?.[1]);
|
133
|
-
|
134
|
-
if (!funcInd) throw e;
|
119
|
+
const backtrace = (funcInd, blobOffset) => {
|
120
|
+
if (funcInd == null || blobOffset == null) return false;
|
135
121
|
|
136
122
|
// convert blob offset -> function wasm offset.
|
137
123
|
// this is not good code and is somewhat duplicated
|
138
124
|
// I just want it to work for debugging, I don't care about perf/yes
|
139
|
-
|
140
125
|
const func = funcs.find(x => x.index === funcInd);
|
141
126
|
const locals = Object.values(func.locals).sort((a, b) => a.idx - b.idx).slice(func.params.length).sort((a, b) => a.idx - b.idx);
|
142
127
|
|
@@ -154,7 +139,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
154
139
|
|
155
140
|
if (typeCount !== 0) localDecl.push(encodeLocal(typeCount, lastType));
|
156
141
|
|
157
|
-
const toFind = encodeVector(localDecl).concat(func.wasm.flat().filter(x => x != null && x <= 0xff).slice(0,
|
142
|
+
const toFind = encodeVector(localDecl).concat(func.wasm.flat().filter(x => x != null && x <= 0xff).slice(0, 60));
|
158
143
|
|
159
144
|
let i = 0;
|
160
145
|
for (; i < wasm.length; i++) {
|
@@ -169,7 +154,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
169
154
|
if (!mismatch) break;
|
170
155
|
}
|
171
156
|
|
172
|
-
if (i === wasm.length)
|
157
|
+
if (i === wasm.length) return false;
|
173
158
|
|
174
159
|
const offset = (blobOffset - i) + encodeVector(localDecl).length;
|
175
160
|
|
@@ -180,7 +165,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
180
165
|
if (cumLen === offset) break;
|
181
166
|
}
|
182
167
|
|
183
|
-
if (cumLen !== offset)
|
168
|
+
if (cumLen !== offset) return false;
|
184
169
|
|
185
170
|
i -= 1;
|
186
171
|
|
@@ -205,6 +190,38 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
205
190
|
console.log(decomp.join('\n'));
|
206
191
|
console.log('\x1B[90m...\x1B[0m\n');
|
207
192
|
|
193
|
+
return true;
|
194
|
+
};
|
195
|
+
|
196
|
+
const t2 = performance.now();
|
197
|
+
|
198
|
+
let instance;
|
199
|
+
try {
|
200
|
+
let wasmEngine = WebAssembly;
|
201
|
+
if (Prefs.asur) {
|
202
|
+
log.warning('wrap', 'using our !experimental! asur wasm engine instead of host to run');
|
203
|
+
wasmEngine = await import('../asur/index.js');
|
204
|
+
}
|
205
|
+
|
206
|
+
0, { instance } = await wasmEngine.instantiate(wasm, {
|
207
|
+
'': {
|
208
|
+
p: valtype === 'i64' ? i => print(Number(i).toString()) : i => print(i.toString()),
|
209
|
+
c: valtype === 'i64' ? i => print(String.fromCharCode(Number(i))) : i => print(String.fromCharCode(i)),
|
210
|
+
t: () => performance.now(),
|
211
|
+
u: () => performance.timeOrigin,
|
212
|
+
y: () => {},
|
213
|
+
z: () => {},
|
214
|
+
...customImports
|
215
|
+
}
|
216
|
+
});
|
217
|
+
} catch (e) {
|
218
|
+
// only backtrace for runner, not test262/etc
|
219
|
+
if (!process.argv[1].includes('/runner')) throw e;
|
220
|
+
|
221
|
+
const funcInd = parseInt(e.message.match(/function #([0-9]+) /)?.[1]);
|
222
|
+
const blobOffset = parseInt(e.message.split('@')?.[1]);
|
223
|
+
|
224
|
+
backtrace(funcInd, blobOffset);
|
208
225
|
throw e;
|
209
226
|
}
|
210
227
|
|
@@ -212,6 +229,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
212
229
|
if (Prefs.profileCompiler) console.log(`instantiated in ${times[1].toFixed(2)}ms`);
|
213
230
|
|
214
231
|
const exports = {};
|
232
|
+
const rawValues = process.argv.includes('-i');
|
215
233
|
|
216
234
|
const exceptTag = instance.exports['0'], memory = instance.exports['$'];
|
217
235
|
for (const x in instance.exports) {
|
@@ -232,7 +250,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
232
250
|
const ret = exp.apply(this, arguments);
|
233
251
|
if (ret == null) return undefined;
|
234
252
|
|
235
|
-
if (
|
253
|
+
if (rawValues) return { value: ret[0], type: ret[1], js: porfToJSValue({ memory, funcs, pages }, ret[0], ret[1]) };
|
236
254
|
|
237
255
|
return porfToJSValue({ memory, funcs, pages }, ret[0], ret[1]);
|
238
256
|
} catch (e) {
|
@@ -249,6 +267,17 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
249
267
|
throw new constructor(exception.message);
|
250
268
|
}
|
251
269
|
|
270
|
+
if (e instanceof WebAssembly.RuntimeError) {
|
271
|
+
// only backtrace for runner, not test262/etc
|
272
|
+
if (!process.argv[1].includes('/runner')) throw e;
|
273
|
+
|
274
|
+
const match = e.stack.match(/wasm-function\[([0-9]+)\]:([0-9a-z]+)/) ?? [];
|
275
|
+
const funcInd = parseInt(match[1]);
|
276
|
+
const blobOffset = parseInt(match[2]);
|
277
|
+
|
278
|
+
backtrace(funcInd, blobOffset);
|
279
|
+
}
|
280
|
+
|
252
281
|
throw e;
|
253
282
|
}
|
254
283
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
|
@@ -0,0 +1 @@
|
|
1
|
+
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<[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>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+<<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<<<<<<]]>>>]
|
package/demos/bf/node.js
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
import process from 'node:process';
|
2
|
+
import fs from 'node:fs';
|
3
|
+
const printChar = i => process.stdout.write(String.fromCharCode(i));
|
4
|
+
|
5
|
+
const interpret = str => {
|
6
|
+
let ptr = 0;
|
7
|
+
let memory = new Array(8000);
|
8
|
+
memory.fill(0);
|
9
|
+
|
10
|
+
let starts = [];
|
11
|
+
|
12
|
+
for (let i = 0; i < str.length; i++) {
|
13
|
+
const c = str.charCodeAt(i);
|
14
|
+
|
15
|
+
if (c == 62) ptr++;
|
16
|
+
if (c == 60) ptr--;
|
17
|
+
|
18
|
+
if (c == 43) memory[ptr] += 1;
|
19
|
+
if (c == 45) memory[ptr] -= 1;
|
20
|
+
|
21
|
+
if (c == 46) printChar(memory[ptr]);
|
22
|
+
|
23
|
+
if (c == 91) {
|
24
|
+
starts.push(i);
|
25
|
+
if (!memory[ptr]) {
|
26
|
+
let depth = 1;
|
27
|
+
while (depth != 0) {
|
28
|
+
const c2 = str.charCodeAt(++i);
|
29
|
+
if (c2 == 91) depth++;
|
30
|
+
if (c2 == 93) depth--;
|
31
|
+
}
|
32
|
+
|
33
|
+
i--;
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
if (c == 93) {
|
39
|
+
if (!memory[ptr]) {
|
40
|
+
starts.pop();
|
41
|
+
continue;
|
42
|
+
}
|
43
|
+
|
44
|
+
i = starts[starts.length - 1];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
// const t = performance.now();
|
50
|
+
|
51
|
+
let file = process.argv[2];
|
52
|
+
let contents = fs.readFileSync(file, 'utf8');
|
53
|
+
interpret(contents);
|
54
|
+
|
55
|
+
// printChar(10);
|
56
|
+
// console.log(performance.now() - t);
|
package/demos/bf/porf.js
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
// const printChar = i => process.stdout.write(String.fromCharCode(i || 0));
|
2
|
+
|
3
|
+
const interpret = str => {
|
4
|
+
let ptr = 0;
|
5
|
+
let memory = new Array(8000);
|
6
|
+
memory.fill(0);
|
7
|
+
|
8
|
+
let starts = [];
|
9
|
+
|
10
|
+
for (let i = 0; i < str.length; i++) {
|
11
|
+
const c = str.charCodeAt(i);
|
12
|
+
|
13
|
+
if (c == 62) ptr++;
|
14
|
+
if (c == 60) ptr--;
|
15
|
+
|
16
|
+
if (c == 43) memory[ptr] += 1;
|
17
|
+
if (c == 45) memory[ptr] -= 1;
|
18
|
+
|
19
|
+
if (c == 46) printChar(memory[ptr]);
|
20
|
+
|
21
|
+
if (c == 91) {
|
22
|
+
starts.push(i);
|
23
|
+
if (!memory[ptr]) {
|
24
|
+
let depth = 1;
|
25
|
+
while (depth != 0) {
|
26
|
+
const c2 = str.charCodeAt(++i);
|
27
|
+
if (c2 == 91) depth++;
|
28
|
+
if (c2 == 93) depth--;
|
29
|
+
}
|
30
|
+
|
31
|
+
i--;
|
32
|
+
continue;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
if (c == 93) {
|
37
|
+
if (!memory[ptr]) {
|
38
|
+
starts.pop();
|
39
|
+
continue;
|
40
|
+
}
|
41
|
+
|
42
|
+
i = starts[starts.length - 1];
|
43
|
+
}
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
// const t = performance.now();
|
48
|
+
|
49
|
+
let file = '';
|
50
|
+
Porffor.readArgv(1, file);
|
51
|
+
|
52
|
+
let contents = '';
|
53
|
+
Porffor.readFile(file, contents);
|
54
|
+
interpret(contents);
|
55
|
+
|
56
|
+
// printChar(10);
|
57
|
+
// console.log(performance.now() - t);
|
package/demos/bf/porf.ts
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
// const printChar = i => process.stdout.write(String.fromCharCode(i || 0));
|
2
|
+
type i32 = number;
|
3
|
+
type bytestring = string;
|
4
|
+
|
5
|
+
const interpret = (str: bytestring) => {
|
6
|
+
let ptr: i32 = 0;
|
7
|
+
let memory: i32[] = new Array(8000);
|
8
|
+
memory.fill(0);
|
9
|
+
|
10
|
+
let starts: i32[] = [];
|
11
|
+
|
12
|
+
for (let i: i32 = 0; i < str.length; i++) {
|
13
|
+
const c: i32 = str.charCodeAt(i);
|
14
|
+
|
15
|
+
if (c == 62) ptr++;
|
16
|
+
if (c == 60) ptr--;
|
17
|
+
|
18
|
+
if (c == 43) memory[ptr] += 1;
|
19
|
+
if (c == 45) memory[ptr] -= 1;
|
20
|
+
|
21
|
+
if (c == 46) printChar(memory[ptr]);
|
22
|
+
|
23
|
+
if (c == 91) {
|
24
|
+
starts.push(i);
|
25
|
+
if (!memory[ptr]) {
|
26
|
+
let depth: i32 = 1;
|
27
|
+
while (depth != 0) {
|
28
|
+
const c2: i32 = str.charCodeAt(++i);
|
29
|
+
if (c2 == 91) depth++;
|
30
|
+
if (c2 == 93) depth--;
|
31
|
+
}
|
32
|
+
|
33
|
+
i--;
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
if (c == 93) {
|
39
|
+
if (!memory[ptr]) {
|
40
|
+
starts.pop();
|
41
|
+
continue;
|
42
|
+
}
|
43
|
+
|
44
|
+
i = starts[starts.length - 1];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
// const t: number = performance.now();
|
50
|
+
|
51
|
+
let file: bytestring = '';
|
52
|
+
Porffor.readArgv(1, file);
|
53
|
+
|
54
|
+
let contents: bytestring = '';
|
55
|
+
Porffor.readFile(file, contents);
|
56
|
+
interpret(contents);
|
57
|
+
|
58
|
+
// printChar(10);
|
59
|
+
// console.log(performance.now() - t);
|
package/package.json
CHANGED
package/runner/index.js
CHANGED
@@ -25,7 +25,7 @@ if (process.argv.includes('--help')) {
|
|
25
25
|
console.log(`Usage: \x1B[1mporf [command] path/to/script.js [...prefs] [...args]\x1B[0m`);
|
26
26
|
|
27
27
|
// commands
|
28
|
-
console.log(`\n\
|
28
|
+
console.log(`\n\x1B[1mCommands:\x1B[0m`);
|
29
29
|
for (const [ cmd, [ color, desc ] ] of Object.entries({
|
30
30
|
run: [ 34, 'Run a JS file' ],
|
31
31
|
wasm: [ 34, 'Compile a JS file to a Wasm binary\n' ],
|
@@ -60,8 +60,10 @@ if (process.argv.includes('--help')) {
|
|
60
60
|
|
61
61
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
62
62
|
if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
63
|
+
// remove this arg
|
64
|
+
process.argv.splice(process.argv.indexOf(file), 1);
|
65
|
+
|
63
66
|
if (file === 'profile') {
|
64
|
-
process.argv.splice(process.argv.indexOf(file), 1);
|
65
67
|
await import('./profiler.js');
|
66
68
|
await new Promise(() => {}); // do nothing for the rest of this file
|
67
69
|
}
|
@@ -75,12 +77,11 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
|
|
75
77
|
}
|
76
78
|
|
77
79
|
if (file === 'debug') {
|
78
|
-
process.argv.splice(process.argv.indexOf(file), 1);
|
79
80
|
await import('./debug.js');
|
80
81
|
await new Promise(() => {}); // do nothing for the rest of this file
|
81
82
|
}
|
82
83
|
|
83
|
-
file = process.argv.slice(
|
84
|
+
file = process.argv.slice(2).find(x => x[0] !== '-');
|
84
85
|
|
85
86
|
const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
|
86
87
|
if (nonOptOutFile) {
|
package/runner/repl.js
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
import { TYPE_NAMES } from '../compiler/types.js';
|
1
2
|
import compile from '../compiler/wrap.js';
|
2
3
|
import version from './version.js';
|
3
4
|
|
5
|
+
import util from 'node:util';
|
6
|
+
|
7
|
+
process.argv.push('--no-opt-unused');
|
8
|
+
|
4
9
|
let repl;
|
5
10
|
try {
|
6
11
|
// try importing node:repl
|
@@ -86,10 +91,21 @@ const run = async (source, _context, _filename, callback, run = true) => {
|
|
86
91
|
lastPages = [...pages.keys()];
|
87
92
|
}
|
88
93
|
|
89
|
-
|
90
|
-
|
94
|
+
let ret = run ? exports.main() : undefined;
|
95
|
+
let value, type;
|
96
|
+
if (ret?.type != null) {
|
97
|
+
value = ret.value;
|
98
|
+
type = ret.type;
|
99
|
+
ret = ret.js;
|
100
|
+
}
|
101
|
+
|
102
|
+
console.log(util.inspect(ret, false, 2, true), (value != null ? `\x1B[34m\x1B[3m(value: ${value}, type: ${TYPE_NAMES[type]})\x1B[0m` : ''));
|
103
|
+
|
104
|
+
// callback(null, ret);
|
91
105
|
|
92
106
|
prev = prev + ';\n' + source.trim();
|
107
|
+
|
108
|
+
callback();
|
93
109
|
};
|
94
110
|
|
95
111
|
const replServer = repl.start({ prompt: '> ', eval: run });
|
package/w.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
console.log(process.argv[2]);
|