on master help sign in
javascript: better print function
3c62143raichoo
js/Runtime.js+12−4
@@ -37,10 +37,18 @@ __IDRRT__.tailcall = function(f) {
37 }
37 }
38};
38};
39
39
40−__IDRRT__.print = function(s){
40+__IDRRT__.print = (function(){
41− var m = s.match(/(.*)\n$/);
41+ if (require) {
42+ var util = require('util');
43+ return function(s) {
44+ util.print(s);
45+ };
46+ } else {
47+ return function(s) {
42− console.log(m ? m[1] : s);
48+ console.log(s);
49+ };
43−};
50+ }
51+})();
44
52
45/*
53/*
46 BigInteger Javascript code taken from:
54 BigInteger Javascript code taken from: