From 4433953d686733eb83762b1d3832744fe0084c0f Mon Sep 17 00:00:00 2001 From: Jeff Dyer Date: Mon, 7 Dec 2015 09:40:56 -0800 Subject: [PATCH] Fix Node regression --- lib/model.js | 2 +- lib/model.min.js | 4 ++-- src/backward.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/model.js b/lib/model.js index b5afdf2..d7ccf70 100644 --- a/lib/model.js +++ b/lib/model.js @@ -244,7 +244,7 @@ var create = function create(o) { }; // From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON -if (!window.JSON) { +if (typeof window === "object" && !window.JSON) { window.JSON = { parse: function(sJSON) { return eval('(' + sJSON + ')'); }, stringify: (function () { diff --git a/lib/model.min.js b/lib/model.min.js index 2b448b2..3ab3ba7 100644 --- a/lib/model.min.js +++ b/lib/model.min.js @@ -4,8 +4,8 @@ d,f){if(Array.prototype.some)return b.some(d,f);var p=toObject(b);b=splitString& var g=0;2f.last});assert(p,"Conflicting request for error code range");Assert.reservedCodes.push({first:b, +"object"!==typeof window||window.JSON||(window.JSON={parse:function(b){return eval("("+b+")")},stringify:function(){var b=Object.prototype.toString,d=Array.isArray||function(g){return"[object Array]"===b.call(g)},f={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},p=function(b){return f[b]||"\\u"+(b.charCodeAt(0)+65536).toString(16).substr(1)},q=/[\\"\u0000-\u001F\u2028\u2029]/g;return function a(c){if(null==c)return"null";if("number"===typeof c)return isFinite(c)?c.toString(): +"null";if("boolean"===typeof c)return c.toString();if("object"===typeof c){if("function"===typeof c.toJSON)return a(c.toJSON());if(d(c)){for(var f="[",r=0;rf.last});assert(p,"Conflicting request for error code range");Assert.reservedCodes.push({first:b, last:d,name:f})},setLocation=function(b){Assert.location=b},clearLocation=function(){Assert.location=null},setCounter=function(b,d){Assert.count=b;Assert.countMessage=d?d:"ERROR count exceeded"},checkCounter=function(){var b=Assert.count;"number"!==typeof b||isNaN(b)?assert(!1,"ERROR counter not set"):assert(Assert.count--,Assert.countMessage)},Assert={assert:assert,message:message,messages:{},reserveCodeRange:reserveCodeRange,reservedCodes:[],setLocation:setLocation,clearLocation:clearLocation,setCounter:setCounter, checkCounter:checkCounter};var TRACE=!1,global=this,trace=function(){return TRACE?function(b){if(global.console&&global.console.log)console.log(b);else if(global.print)print(b);else throw"No trace function defined!";}:function(){}}();var Ast=function(){function b(){}function d(b){void 0===b&&(b=this);return b.op&&b.args}var f=["unused"],p={};b.clearPool=function(){f=["unused"];p={}};b.prototype.create=function g(b,c){var d=g(this);"string"===typeof b?(d.op=b,d.args=c instanceof Array?c:[]):null!==b&&"object"===typeof b&&forEach(keys(b),function(c,g){d[c]=b[c]});return d};b.prototype.arg=function(b){if(!d(this))throw"Malformed node";this.args.push(b);return this};b.prototype.argN=function(b,a){if(!d(this))throw"Malformed node"; if(void 0===a)return this.args[b];this.args[b]=a;return this};b.prototype.args=function(b){if(!d(this))throw"Malformed node";if(void 0===b)return this.args;this.args=b;return this};b.prototype.isNode=d;b.intern=b.prototype.intern=function a(c){this instanceof b&&void 0===c&&d(this)&&(c=this);assert("object"===typeof c,"node not an object");for(var G=c.op,r=c.args.length,ba="",M=[],A=0;A