From 7669c49a00a75c711b0f23bea09e3532f3af5e32 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 14 Apr 2021 21:44:29 -0400 Subject: =?UTF-8?q?Reorganize=20=E2=80=A2Show=20and=20add=20=E2=80=A2Out?= =?UTF-8?q?=20on=20Node.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bqn.js | 11 +++++++---- 1 file 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(''+fmtErr(Array.from(a),e)+''); } -- cgit v1.2.3