Comparing version 1.6.2 to 1.6.3
@@ -28,3 +28,3 @@ /* | ||
},{}],2:[function(_dereq_,module,exports){ | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),tree={mid:{unicode:String.fromCharCode(9500),ascii:"+"},last:{unicode:String.fromCharCode(9492),ascii:"+"},down:{unicode:String.fromCharCode(9474),ascii:"|"},left:{unicode:String.fromCharCode(9472),ascii:"-"}},ASTYDump=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"dump",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e,t){return t},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n="";return this.walk(function(o,a){if(!(a>e)){if(a>0){var i=function(e){var t=0,r=0;return null!==e.P&&(t=e.P.C.indexOf(e),r=e.P.C.length-1),{nth:t,max:r}},c=i(o),u=c.nth,l=c.max,f=" ";f=r?""+tree.left.unicode+tree.left.unicode+f:""+tree.left.ascii+tree.left.ascii+f,f=u<l?""+(r?tree.mid.unicode:tree.mid.ascii)+f:""+(r?tree.last.unicode:tree.last.ascii)+f;for(var s=o.P;null!==s;s=s.P)if(null!==s.P){var p=i(s),d=p.nth,g=p.max;f=d<g?(r?tree.down.unicode:tree.down.ascii)+" "+f:" "+f}n+=t("tree",f)}n+=t("type",o.T)+" ";var m=Object.keys(o.A);if(m.length>0){n+=t("parenthesis","(");var y=!0;m.forEach(function(e){y?y=!1:n+=t("comma",",")+" ",n+=t("key",e)+t("colon",":")+" ";var r=o.A[e];switch(void 0===r?"undefined":_typeof(r)){case"boolean":case"number":n+=t("value",r.toString());break;case"string":var a=function(e){return e.charCodeAt(0).toString(16).toUpperCase()};n+=t("value",'"'+r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(e){return"\\x0"+a(e)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(e){return"\\x"+a(e)}).replace(/[\u0100-\u0FFF]/g,function(e){return"\\u0"+a(e)}).replace(/[\u1000-\uFFFF]/g,function(e){return"\\u"+a(e)})+'"');break;case"object":r instanceof RegExp?n+=t("value","/"+r.source+"/"):n+=t("value",JSON.stringify(r));break;default:n+=t("value",JSON.stringify(r))}}),n+=t("parenthesis",")")+" "}n+=t("position",t("bracket","[")+t("line",o.L.L)+t("slash",",")+t("column",o.L.C)+t("bracket","]")),n+="\n"}},"downward"),n}}]),e}();exports.default=ASTYDump; | ||
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),tree={mid:{unicode:String.fromCharCode(9500),ascii:"+"},last:{unicode:String.fromCharCode(9492),ascii:"+"},down:{unicode:String.fromCharCode(9474),ascii:"|"},left:{unicode:String.fromCharCode(9472),ascii:"-"}},ASTYDump=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"dump",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e,t){return t},r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n="",o=this;return this.walk(function(a,i){if(!(i>e)){if(i>0){var c=function(e){var t=0,r=0;return null!==e.P&&(t=e.P.C.indexOf(e),r=e.P.C.length-1),{nth:t,max:r}},u=c(a),l=u.nth,f=u.max,s=" ";s=r?""+tree.left.unicode+tree.left.unicode+s:""+tree.left.ascii+tree.left.ascii+s,s=l<f?""+(r?tree.mid.unicode:tree.mid.ascii)+s:""+(r?tree.last.unicode:tree.last.ascii)+s;for(var p=a.P;null!==p&&p!==o;p=p.P)if(null!==p.P){var d=c(p),g=d.nth,m=d.max;s=g<m?(r?tree.down.unicode:tree.down.ascii)+" "+s:" "+s}n+=t("tree",s)}n+=t("type",a.T)+" ";var y=Object.keys(a.A);if(y.length>0){n+=t("parenthesis","(");var h=!0;y.forEach(function(e){h?h=!1:n+=t("comma",",")+" ",n+=t("key",e)+t("colon",":")+" ";var r=a.A[e];switch(void 0===r?"undefined":_typeof(r)){case"boolean":case"number":n+=t("value",r.toString());break;case"string":var o=function(e){return e.charCodeAt(0).toString(16).toUpperCase()};n+=t("value",'"'+r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(e){return"\\x0"+o(e)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(e){return"\\x"+o(e)}).replace(/[\u0100-\u0FFF]/g,function(e){return"\\u0"+o(e)}).replace(/[\u1000-\uFFFF]/g,function(e){return"\\u"+o(e)})+'"');break;case"object":r instanceof RegExp?n+=t("value","/"+r.source+"/"):n+=t("value",JSON.stringify(r));break;default:n+=t("value",JSON.stringify(r))}}),n+=t("parenthesis",")")+" "}n+=t("position",t("bracket","[")+t("line",a.L.L)+t("slash",",")+t("column",a.L.C)+t("bracket","]")),n+="\n"}},"downward"),n}}]),e}();exports.default=ASTYDump; | ||
},{}],3:[function(_dereq_,module,exports){ | ||
@@ -31,0 +31,0 @@ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),ASTYMerge=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"merge",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null===e)return this;if(!this.ctx.isA(e))throw new Error("merge: invalid AST node argument");if(r){var a=e.pos();this.pos(a.L,a.C,a.O)}return e.attrs().forEach(function(r){var a=void 0!==n[r]?n[r]:r;null!==a&&t.set(a,e.get(r))}),e.childs().forEach(function(e){t.add(e)}),this}}]),e}();exports.default=ASTYMerge; |
@@ -373,2 +373,3 @@ /* | ||
var out = ""; | ||
var self = this; | ||
this.walk(function (node, depth /*, parent, when */) { | ||
@@ -397,3 +398,3 @@ /* short-circuit processing at a certain depth */ | ||
if (nth < max) prefix = "" + (unicode ? tree.mid.unicode : tree.mid.ascii) + prefix;else prefix = "" + (unicode ? tree.last.unicode : tree.last.ascii) + prefix; | ||
for (var parent = node.P; parent !== null; parent = parent.P) { | ||
for (var parent = node.P; parent !== null && parent !== self; parent = parent.P) { | ||
if (parent.P !== null) { | ||
@@ -400,0 +401,0 @@ var _nodeIndex2 = nodeIndex(parent), |
{ | ||
"name": "asty", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "Abstract Syntax Tree (AST) Data Structure", | ||
@@ -5,0 +5,0 @@ "keywords": [ "ast", "abstract", "syntax", "tree", "data", "structure" ], |
@@ -36,2 +36,3 @@ /* | ||
let out = "" | ||
let self = this | ||
this.walk((node, depth /*, parent, when */) => { | ||
@@ -63,3 +64,3 @@ /* short-circuit processing at a certain depth */ | ||
prefix = `${unicode ? tree.last.unicode : tree.last.ascii}${prefix}` | ||
for (let parent = node.P; parent !== null; parent = parent.P) { | ||
for (let parent = node.P; parent !== null && parent !== self; parent = parent.P) { | ||
if (parent.P !== null) { | ||
@@ -66,0 +67,0 @@ let { nth, max } = nodeIndex(parent) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163732
1998