diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-14 21:44:29 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-14 21:44:29 -0400 |
| commit | 7669c49a00a75c711b0f23bea09e3532f3af5e32 (patch) | |
| tree | bd595a7b55ca07aebcacdb2e9139ca21bd4dc6f7 /docs/bqn.js | |
| parent | 2848ab60f54af09abee64d541677358a5445c4eb (diff) | |
Reorganize •Show and add •Out on Node.js
Diffstat (limited to 'docs/bqn.js')
| -rwxr-xr-x | docs/bqn.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index 007e22a1..20b76b0c 100755 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -358,16 +358,19 @@ if (typeof process!=='undefined') { }); } -if (typeof module!=='undefined') { +if (typeof module!=='undefined') { // Node.js bqn.fmt=fmt; bqn.fmtErr=fmtErr; bqn.compile=compile; bqn.run=run; module.exports=bqn; + + let show = x => console.log(fmt(x)); + sysvals.show = (x,w) => { show(x); return x; }; + sysvals.out = (x,w) => { req1str("•Out",x,w);console.log(x.join("")); return x; }; + if (!module.parent) { let args = process.argv.slice(2); args.map(a=>{ try { - let out=[]; sysvals.show = (x,w) => { out.push(x); return x; } - out.push(bqn(a)); - console.log(out.map(fmt).join('\n')); + show(bqn(a)); } catch(e) { console.error('[31m'+fmtErr(Array.from(a),e)+'[39m'); } |
