From fe3dddb32ba1db5f3eb3f426e2ac463aeb704d1c Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 16 Aug 2013 21:00:47 -0700 Subject: [PATCH] Move cscript/rhino console support to separate file --- README.md | 5 +- basic.js | 139 +--------------------------------------------------- cbasic.js | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 140 deletions(-) create mode 100644 cbasic.js diff --git a/README.md b/README.md index e95f31e..e1bba85 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,9 @@ Notes & Known Issues * Commands that operate on the program itself (`LIST`, `RUN`, `DEL`, etc.) are not implemented. You can run your basic programs from the command line (with only basic text input and output, and no graphics or DOS commands): -* On Windows, download basic.js and run from a command prompt via: `cscript.exe basic.js your_basic_program.txt` -* On Mac/Linux, install Mozilla Rhino, download basic.js and run from the command prompt via: `java -jar PATH_TO/js.jar basic.js your_program.txt` +* Clone the repository locally +* On Windows, run from a command prompt via: `cscript.exe cbasic.js your_program.txt` +* On Mac/Linux, install Mozilla Rhino, run from the command prompt via: `java -jar PATH_TO/js.jar cbasic.js your_program.txt` To Do ----- diff --git a/basic.js b/basic.js index f8e8f2e..ac92a0e 100644 --- a/basic.js +++ b/basic.js @@ -43,17 +43,10 @@ // // driver will also be called after input is unblocked // // driver may want to yield via setTimeout() after N steps -// Functions from polyfill.js, via jsmin, for running via console -if(!Object.keys){Object.keys=function(o){if(o!==Object(o))throw new TypeError();var ret=[],p;for(p in o)if(Object.prototype.hasOwnProperty.call(o,p))ret.push(p);return ret;};} -if(!Array.prototype.forEach){Array.prototype.forEach=function(fun){if(this===void 0||this===null){throw new TypeError();}var t=Object(this);var len=t.length>>>0;if(typeof fun!=="function"){throw new TypeError();}var thisp=arguments[1],i;for(i=0;i>>0;if(typeof fun!=="function"){throw new TypeError();}var res=[];res.length=len;var thisp=arguments[1],i;for(i=0;i>>0;if(typeof fun!=="function"){throw new TypeError();}if(len===0&&arguments.length===1){throw new TypeError();}var k=0;var accumulator;if(arguments.length>=2){accumulator=arguments[1];}else{do{if(k in t){accumulator=t[k++];break;}if(++k>=len){throw new TypeError();}}while(true);}while(k>>0;if(typeof fun!=="function"){throw new TypeError();}var thisp=arguments[1],i;for(i=0;i>>0;if(typeof fun!=="function"){throw new TypeError();}var res=[];res.length=len;var thisp=arguments[1],i;for(i=0;i>>0;if(typeof fun!=="function"){throw new TypeError();}if(len===0&&arguments.length===1){throw new TypeError();}var k=0;var accumulator;if(arguments.length>=2){accumulator=arguments[1];}else{do{if(k in t){accumulator=t[k++];break;}if(++k>=len){throw new TypeError();}}while(true);}while(k