]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Minimal console.log() polyfill | |
3 | */ | |
4 | ||
5 | if (typeof console === 'undefined') { | |
6 | Object.defineProperty(this, 'console', { | |
7 | value: {}, writable: true, enumerable: false, configurable: true | |
8 | }); | |
9 | } | |
10 | if (typeof console.log === 'undefined') { | |
11 | (function () { | |
12 | var origPrint = print; // capture in closure in case changed later | |
13 | Object.defineProperty(this.console, 'log', { | |
14 | value: function () { | |
15 | var strArgs = Array.prototype.map.call(arguments, function (v) { return String(v); }); | |
16 | origPrint(Array.prototype.join.call(strArgs, ' ')); | |
17 | }, writable: true, enumerable: false, configurable: true | |
18 | }); | |
19 | })(); | |
20 | } |