Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asty

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asty - npm Package Compare versions

Comparing version 1.7.16 to 1.8.0

8

Gruntfile.js

@@ -55,5 +55,5 @@ /*

presets: [
[ "env", {
[ "@babel/preset-env", {
"targets": {
"browser": [ "last 8 versions", "> 1%", "ie 9" ]
"browsers": "last 8 versions, > 1%, ie 11"
}

@@ -89,5 +89,5 @@ } ]

presets: [
[ "env", {
[ "@babel/preset-env", {
"targets": {
"node": [ "4.0.0" ]
"node": "8.0.0"
}

@@ -94,0 +94,0 @@ } ]

@@ -26,16 +26,16 @@ /*

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ASTY = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
"use strict";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 n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var ASTYBase=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"init",value:function(e,t,n,r){if(arguments.length<2)throw new Error("init: invalid number of arguments");if(this.ctx=e,this.ASTy=!0,this.T=t,this.L={L:0,C:0,O:0},this.A={},this.C=[],this.P=null,"object"===(void 0===n?"undefined":_typeof(n)))for(var i in n)n.hasOwnProperty(i)&&this.set(i,n[i]);return"object"===(void 0===r?"undefined":_typeof(r))&&r instanceof Array&&this.add(r),this}},{key:"create",value:function(e,t,n){return this.ctx.create(e,t,n)}},{key:"type",value:function(e){if(0===arguments.length)return this.T;if(1===arguments.length)return this.T=e,this;throw new Error("type: invalid number of arguments")}},{key:"pos",value:function(e,t,n){if(0===arguments.length)return{line:this.L.L,column:this.L.C,offset:this.L.O};if(arguments.length<=3)return this.L.L=e||0,this.L.C=t||0,this.L.O=n||0,this;throw new Error("pos: invalid number of arguments")}},{key:"set",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0]))Object.keys(n[0]).forEach(function(t){void 0!==n[0][t]?e.A[t]=n[0][t]:delete e.A[t]});else{if(2!==n.length)throw new Error("set: invalid number of arguments");void 0!==n[1]?this.A[n[0]]=n[1]:delete this.A[n[0]]}return this}},{key:"unset",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0])&&n[0]instanceof Array)n[0].forEach(function(t){delete e.A[t]});else{if(1!==n.length)throw new Error("unset: invalid number of arguments");delete this.A[n[0]]}return this}},{key:"get",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1!==n.length)throw new Error("get: invalid number of arguments");if("object"===_typeof(n[0])&&n[0]instanceof Array)return n[0].map(function(t){if("string"!=typeof t)throw new Error("get: invalid key argument");return e.A[t]});var i=n[0];if("string"!=typeof i)throw new Error("get: invalid key argument");return this.A[i]}},{key:"attrs",value:function(){return Object.keys(this.A)}},{key:"nth",value:function(){if(null===this.P)return 1;var e=this.P.C.indexOf(this);if(e<0)throw new Error("nth: internal error -- node not in childs of its parent");return e}},{key:"ins",value:function(e){for(var t=this,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(0===r.length)throw new Error("ins: invalid number of arguments");if(e<0&&(e=this.C.length+1-e),!(e>=0&&e<=this.C.length))throw new Error("ins: invalid position");var o=function(n){if(!t.ctx.isA(n))throw new Error("ins: invalid AST node argument");t.C.splice(e++,0,n),n.P=t};return r.forEach(function(e){"object"===(void 0===e?"undefined":_typeof(e))&&e instanceof Array?e.forEach(function(e){o(e)}):null!==e&&o(e)}),this}},{key:"add",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(0===n.length)throw new Error("add: invalid number of arguments");var i=function(t){if(!e.ctx.isA(t))throw new Error("add: invalid AST node argument");e.C.push(t),t.P=e};return n.forEach(function(e){"object"===(void 0===e?"undefined":_typeof(e))&&e instanceof Array?e.forEach(function(e){i(e)}):null!==e&&i(e)}),this}},{key:"del",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(0===n.length)throw new Error("del: invalid number of arguments");return n.forEach(function(t){if(!e.ctx.isA(t))throw new Error("del: invalid AST node argument");for(var n=!1,r=0;r<e.C.length;r++)if(e.C[r]===t){e.C.splice(r,1),t.P=null,n=!0;break}if(!n)throw new Error("del: AST node not found in childs")}),this}},{key:"childs",value:function(){if(arguments.length>2)throw new Error("childs: invalid number of arguments");if(2===arguments.length&&"number"==typeof(arguments.length<=0?void 0:arguments[0])&&"number"==typeof(arguments.length<=1?void 0:arguments[1]))return this.C.slice(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]);if(1===arguments.length&&"number"==typeof(arguments.length<=0?void 0:arguments[0]))return this.C.slice(arguments.length<=0?void 0:arguments[0]);if(0===arguments.length)return this.C;throw new Error("childs: invalid type of arguments")}},{key:"child",value:function(e){if("number"!=typeof e)throw new Error("child: invalid argument");return e<this.C.length?this.C[e]:null}},{key:"parent",value:function(){return this.P}},{key:"serialize",value:function(){return this.ctx.__serialize(this)}}]),e}();exports.default=ASTYBase;
"use strict";function _typeof(e){return(_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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var ASTYBase=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"init",value:function(e,t,n,r){if(arguments.length<2)throw new Error("init: invalid number of arguments");if(this.ctx=e,this.ASTy=!0,this.T=t,this.L={L:0,C:0,O:0},this.A={},this.C=[],this.P=null,"object"===_typeof(n))for(var i in n)n.hasOwnProperty(i)&&this.set(i,n[i]);return"object"===_typeof(r)&&r instanceof Array&&this.add(r),this}},{key:"create",value:function(e,t,n){return this.ctx.create(e,t,n)}},{key:"type",value:function(e){if(0===arguments.length)return this.T;if(1===arguments.length)return this.T=e,this;throw new Error("type: invalid number of arguments")}},{key:"pos",value:function(e,t,n){if(0===arguments.length)return{line:this.L.L,column:this.L.C,offset:this.L.O};if(arguments.length<=3)return this.L.L=e||0,this.L.C=t||0,this.L.O=n||0,this;throw new Error("pos: invalid number of arguments")}},{key:"set",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0]))Object.keys(n[0]).forEach(function(t){void 0!==n[0][t]?e.A[t]=n[0][t]:delete e.A[t]});else{if(2!==n.length)throw new Error("set: invalid number of arguments");void 0!==n[1]?this.A[n[0]]=n[1]:delete this.A[n[0]]}return this}},{key:"unset",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0])&&n[0]instanceof Array)n[0].forEach(function(t){delete e.A[t]});else{if(1!==n.length)throw new Error("unset: invalid number of arguments");delete this.A[n[0]]}return this}},{key:"get",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(1!==n.length)throw new Error("get: invalid number of arguments");if("object"===_typeof(n[0])&&n[0]instanceof Array)return n[0].map(function(t){if("string"!=typeof t)throw new Error("get: invalid key argument");return e.A[t]});var i=n[0];if("string"!=typeof i)throw new Error("get: invalid key argument");return this.A[i]}},{key:"attrs",value:function(){return Object.keys(this.A)}},{key:"nth",value:function(){if(null===this.P)return 1;var e=this.P.C.indexOf(this);if(e<0)throw new Error("nth: internal error -- node not in childs of its parent");return e}},{key:"ins",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(0===r.length)throw new Error("ins: invalid number of arguments");if(e<0&&(e=this.C.length+1-e),!(e>=0&&e<=this.C.length))throw new Error("ins: invalid position");var o=function(n){if(!t.ctx.isA(n))throw new Error("ins: invalid AST node argument");t.C.splice(e++,0,n),n.P=t};return r.forEach(function(e){"object"===_typeof(e)&&e instanceof Array?e.forEach(function(e){o(e)}):null!==e&&o(e)}),this}},{key:"add",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(0===n.length)throw new Error("add: invalid number of arguments");var i=function(t){if(!e.ctx.isA(t))throw new Error("add: invalid AST node argument");e.C.push(t),t.P=e};return n.forEach(function(e){"object"===_typeof(e)&&e instanceof Array?e.forEach(function(e){i(e)}):null!==e&&i(e)}),this}},{key:"del",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(0===n.length)throw new Error("del: invalid number of arguments");return n.forEach(function(t){if(!e.ctx.isA(t))throw new Error("del: invalid AST node argument");for(var n=!1,r=0;r<e.C.length;r++)if(e.C[r]===t){e.C.splice(r,1),t.P=null,n=!0;break}if(!n)throw new Error("del: AST node not found in childs")}),this}},{key:"childs",value:function(){if(arguments.length>2)throw new Error("childs: invalid number of arguments");if(2===arguments.length&&"number"==typeof(arguments.length<=0?void 0:arguments[0])&&"number"==typeof(arguments.length<=1?void 0:arguments[1]))return this.C.slice(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]);if(1===arguments.length&&"number"==typeof(arguments.length<=0?void 0:arguments[0]))return this.C.slice(arguments.length<=0?void 0:arguments[0]);if(0===arguments.length)return this.C;throw new Error("childs: invalid type of arguments")}},{key:"child",value:function(e){if("number"!=typeof e)throw new Error("child: invalid argument");return e<this.C.length?this.C[e]:null}},{key:"parent",value:function(){return this.P}},{key:"serialize",value:function(){return this.ctx.__serialize(this)}}]),e}();exports.default=ASTYBase;
},{}],2:[function(_dereq_,module,exports){
"use strict";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}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var 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);s=d.nth<d.max?(r?tree.down.unicode:tree.down.ascii)+" "+s:" "+s}n+=t("tree",s)}n+=t("type",a.T)+" ";var g=Object.keys(a.A);if(g.length>0){n+=t("parenthesis","(");var m=!0;g.forEach(function(e){m?m=!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;
"use strict";function _typeof(e){return(_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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var 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},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r="",o=this;return this.walk(function(c,a){if(!(a>e)){if(a>0){var i=function(e){var t=0,n=0;return null!==e.P&&(t=e.P.C.indexOf(e),n=e.P.C.length-1),{nth:t,max:n}},u=i(c),l=u.nth,f=u.max,s=" ";s=n?"".concat(tree.left.unicode).concat(tree.left.unicode).concat(s):"".concat(tree.left.ascii).concat(tree.left.ascii).concat(s),s=l<f?"".concat(n?tree.mid.unicode:tree.mid.ascii).concat(s):"".concat(n?tree.last.unicode:tree.last.ascii).concat(s);for(var p=c.P;null!==p&&p!==o;p=p.P)if(null!==p.P){var d=i(p);s=d.nth<d.max?"".concat(n?tree.down.unicode:tree.down.ascii," ").concat(s):" ".concat(s)}r+=t("tree",s)}r+=t("type",c.T)+" ";var g=Object.keys(c.A);if(g.length>0){r+=t("parenthesis","(");var y=!0;g.forEach(function(e){y?y=!1:r+=t("comma",",")+" ",r+=t("key",e)+t("colon",":")+" ";var n=c.A[e];switch(_typeof(n)){case"boolean":case"number":r+=t("value",n.toString());break;case"string":var o=function(e){return e.charCodeAt(0).toString(16).toUpperCase()};r+=t("value",'"'+n.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":n instanceof RegExp?r+=t("value","/"+n.source+"/"):r+=t("value",JSON.stringify(n));break;default:r+=t("value",JSON.stringify(n))}}),r+=t("parenthesis",")")+" "}r+=t("position",t("bracket","[")+t("line",c.L.L)+t("slash",",")+t("column",c.L.C)+t("bracket","]")),r+="\n"}},"downward"),r}}]),e}();exports.default=ASTYDump;
},{}],3:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}();function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var ASTYMerge=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"merge",value:function(e){var r=this,t=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(t){var a=e.pos();this.pos(a.line,a.column,a.offset)}e.attrs().forEach(function(t){var a=void 0!==n[t]?n[t]:t;null!==a&&r.set(a,e.get(t))}),e.childs().forEach(function(t){e.del(t),r.add(t)});var i=e.parent();return null!==i&&i.del(e),this}}]),e}();exports.default=ASTYMerge;
"use strict";function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var ASTYMerge=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"merge",value:function(e){var r=this,t=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(t){var i=e.pos();this.pos(i.line,i.column,i.offset)}e.attrs().forEach(function(t){var i=void 0!==n[t]?n[t]:t;null!==i&&r.set(i,e.get(t))}),e.childs().forEach(function(t){e.del(t),r.add(t)});var o=e.parent();return null!==o&&o.del(e),this}}]),e}();exports.default=ASTYMerge;
},{}],4:[function(_dereq_,module,exports){
"use strict";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 n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var ASTYSerialize=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"serialize",value:function(e,t){if(!e.isA(t))throw new Error("serialize: not an ASTy node");return JSON.stringify({ASTy:function e(t){var n={T:t.T,L:{L:t.L.L,C:t.L.C,O:t.L.O}},r=Object.keys(t.A);return r.length>0&&(n.A={},r.forEach(function(e){var r=t.A[e];switch(void 0===r?"undefined":_typeof(r)){case"boolean":case"number":case"string":n.A[e]=r;break;default:n.A[e]=JSON.parse(JSON.stringify(r))}})),t.C.length>0&&(n.C=t.C.map(function(t){return e(t)})),n}(t)})}},{key:"unserialize",value:function(e,t){var n=JSON.parse(t);if("object"!==(void 0===n?"undefined":_typeof(n))||"object"!==_typeof(n.ASTy))throw new Error("unserialize: not an ASTy JSON export");return function t(n){var r=e.create(n.T);return r.pos(n.L.L,n.L.C,n.L.O),"object"===_typeof(n.A)&&Object.keys(n.A).forEach(function(e){var t=n.A[e];switch(void 0===t?"undefined":_typeof(t)){case"boolean":case"number":case"string":r.set(e,t);break;default:r.set(e,JSON.parse(JSON.stringify(t)))}}),"object"===_typeof(n.C)&&n.C instanceof Array&&r.add(n.C.map(function(e){return t(e)})),r}(n.ASTy)}}]),e}();exports.default=ASTYSerialize;
"use strict";function _typeof(e){return(_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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var ASTYSerialize=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"serialize",value:function(e,t){if(!e.isA(t))throw new Error("serialize: not an ASTy node");return JSON.stringify({ASTy:function e(t){var r={T:t.T,L:{L:t.L.L,C:t.L.C,O:t.L.O}},n=Object.keys(t.A);return n.length>0&&(r.A={},n.forEach(function(e){var n=t.A[e];switch(_typeof(n)){case"boolean":case"number":case"string":r.A[e]=n;break;default:r.A[e]=JSON.parse(JSON.stringify(n))}})),t.C.length>0&&(r.C=t.C.map(function(t){return e(t)})),r}(t)})}},{key:"unserialize",value:function(e,t){var r=JSON.parse(t);if("object"!==_typeof(r)||"object"!==_typeof(r.ASTy))throw new Error("unserialize: not an ASTy JSON export");return function t(r){var n=e.create(r.T);return n.pos(r.L.L,r.L.C,r.L.O),"object"===_typeof(r.A)&&Object.keys(r.A).forEach(function(e){var t=r.A[e];switch(_typeof(t)){case"boolean":case"number":case"string":n.set(e,t);break;default:n.set(e,JSON.parse(JSON.stringify(t)))}}),"object"===_typeof(r.C)&&r.C instanceof Array&&n.add(r.C.map(function(e){return t(e)})),n}(r.ASTy)}}]),e}();exports.default=ASTYSerialize;
},{}],5:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:1,minor:7,micro:14,date:20180623};exports.default=version;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var version={major:1,minor:7,micro:14,date:20180623},_default=version;exports.default=_default;
},{}],6:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(n,r,t){return r&&e(n.prototype,r),t&&e(n,t),n}}();function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var ASTYWalk=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"walk",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"downward";return function r(t,a,o){"downward"!==n&&"both"!==n||e(t,a,o,"downward"),t.C.forEach(function(e){r(e,a+1,t)}),"upward"!==n&&"both"!==n||e(t,a,o,"upward")}(this,0,null),this}}]),e}();exports.default=ASTYWalk;
"use strict";function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){return r&&_defineProperties(e.prototype,r),n&&_defineProperties(e,n),e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var ASTYWalk=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"walk",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"downward";return function n(t,a,o){"downward"!==r&&"both"!==r||e(t,a,o,"downward"),t.C.forEach(function(e){n(e,a+1,t)}),"upward"!==r&&"both"!==r||e(t,a,o,"upward")}(this,0,null),this}}]),e}();exports.default=ASTYWalk;
},{}],7:[function(_dereq_,module,exports){
"use strict";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 a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),_astyBase=_dereq_("./asty-base.js"),_astyBase2=_interopRequireDefault(_astyBase),_astyMerge=_dereq_("./asty-merge.js"),_astyMerge2=_interopRequireDefault(_astyMerge),_astyWalk=_dereq_("./asty-walk.js"),_astyWalk2=_interopRequireDefault(_astyWalk),_astyDump=_dereq_("./asty-dump.js"),_astyDump2=_interopRequireDefault(_astyDump),_astySerialize=_dereq_("./asty-serialize.js"),_astySerialize2=_interopRequireDefault(_astySerialize),_astyVersion=_dereq_("./asty-version.js"),_astyVersion2=_interopRequireDefault(_astyVersion);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var ASTYCtx=function(){function e(){var t=this;return _classCallCheck(this,e),this.ASTYNode=function(){},[[_astyBase2.default,"init","create","type","pos","set","unset","get","attrs","nth","ins","add","del","childs","child","parent","serialize"],[_astyMerge2.default,"merge"],[_astyWalk2.default,"walk"],[_astyDump2.default,"dump"]].forEach(function(e){var r=e[0].prototype;e.slice(1).forEach(function(e){t.ASTYNode.prototype[e]=r[e]})}),this}return _createClass(e,[{key:"version",value:function(){return _astyVersion2.default}},{key:"extend",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(this.ASTYNode.prototype[t]=e[t]);return this}},{key:"create",value:function(e,t,r){return(new this.ASTYNode).init(this,e,t,r)}},{key:"isA",value:function(e){return"object"===(void 0===e?"undefined":_typeof(e))&&e instanceof this.ASTYNode&&"boolean"==typeof e.ASTy&&!0===e.ASTy}},{key:"__serialize",value:function(t){return e.serialize(t)}}],[{key:"serialize",value:function(e){return _astySerialize2.default.serialize(e.ctx,e)}},{key:"unserialize",value:function(e){return _astySerialize2.default.unserialize(new this,e)}}]),e}();module.exports=ASTYCtx;
"use strict";var _astyBase=_interopRequireDefault(_dereq_("./asty-base.js")),_astyMerge=_interopRequireDefault(_dereq_("./asty-merge.js")),_astyWalk=_interopRequireDefault(_dereq_("./asty-walk.js")),_astyDump=_interopRequireDefault(_dereq_("./asty-dump.js")),_astySerialize=_interopRequireDefault(_dereq_("./asty-serialize.js")),_astyVersion=_interopRequireDefault(_dereq_("./asty-version.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}var ASTYCtx=function(){function e(){var t=this;return _classCallCheck(this,e),this.ASTYNode=function e(){_classCallCheck(this,e)},[[_astyBase.default,"init","create","type","pos","set","unset","get","attrs","nth","ins","add","del","childs","child","parent","serialize"],[_astyMerge.default,"merge"],[_astyWalk.default,"walk"],[_astyDump.default,"dump"]].forEach(function(e){var r=e[0].prototype;e.slice(1).forEach(function(e){t.ASTYNode.prototype[e]=r[e]})}),this}return _createClass(e,[{key:"version",value:function(){return _astyVersion.default}},{key:"extend",value:function(e){for(var t in e)e.hasOwnProperty(t)&&(this.ASTYNode.prototype[t]=e[t]);return this}},{key:"create",value:function(e,t,r){return(new this.ASTYNode).init(this,e,t,r)}},{key:"isA",value:function(e){return"object"===_typeof(e)&&e instanceof this.ASTYNode&&"boolean"==typeof e.ASTy&&!0===e.ASTy}},{key:"__serialize",value:function(t){return e.serialize(t)}}],[{key:"serialize",value:function(e){return _astySerialize.default.serialize(e.ctx,e)}},{key:"unserialize",value:function(e){return _astySerialize.default.unserialize(new this,e)}}]),e}();module.exports=ASTYCtx;
},{"./asty-base.js":1,"./asty-dump.js":2,"./asty-merge.js":3,"./asty-serialize.js":4,"./asty-version.js":5,"./asty-walk.js":6}]},{},[1,2,3,4,5,6,7])(7)
});

@@ -29,9 +29,6 @@ /*

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*

@@ -60,267 +57,204 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

*/
class ASTYBase {
/* AST node initialization */
init(ctx, T, A, C) {
if (arguments.length < 2) throw new Error("init: invalid number of arguments");
this.ctx = ctx;
this.ASTy = true;
this.T = T;
this.L = {
L: 0,
C: 0,
O: 0
};
this.A = {};
this.C = [];
this.P = null;
var ASTYBase = function () {
function ASTYBase() {
_classCallCheck(this, ASTYBase);
if (typeof A === "object") {
for (let name in A) if (A.hasOwnProperty(name)) this.set(name, A[name]);
}
_createClass(ASTYBase, [{
key: "init",
if (typeof C === "object" && C instanceof Array) this.add(C);
return this;
}
/* create new AST node */
/* AST node initialization */
value: function init(ctx, T, A, C) {
if (arguments.length < 2) throw new Error("init: invalid number of arguments");
this.ctx = ctx;
this.ASTy = true;
this.T = T;
this.L = { L: 0, C: 0, O: 0 };
this.A = {};
this.C = [];
this.P = null;
if (typeof A === "object") {
for (var name in A) {
if (A.hasOwnProperty(name)) this.set(name, A[name]);
}
}
if (typeof C === "object" && C instanceof Array) this.add(C);
return this;
}
/* create new AST node */
create(T, A, C) {
return this.ctx.create(T, A, C);
}
/* check the type of an AST node */
}, {
key: "create",
value: function create(T, A, C) {
return this.ctx.create(T, A, C);
}
/* check the type of an AST node */
type(T) {
if (arguments.length === 0) return this.T;else if (arguments.length === 1) {
this.T = T;
return this;
} else throw new Error("type: invalid number of arguments");
}
/* set the parsing position */
}, {
key: "type",
value: function type(T) {
if (arguments.length === 0) return this.T;else if (arguments.length === 1) {
this.T = T;
return this;
} else throw new Error("type: invalid number of arguments");
}
/* set the parsing position */
pos(line, column, offset) {
if (arguments.length === 0) return {
line: this.L.L,
column: this.L.C,
offset: this.L.O
};else if (arguments.length <= 3) {
this.L.L = line || 0;
this.L.C = column || 0;
this.L.O = offset || 0;
return this;
} else throw new Error("pos: invalid number of arguments");
}
/* set AST node attributes */
}, {
key: "pos",
value: function pos(line, column, offset) {
if (arguments.length === 0) return {
line: this.L.L,
column: this.L.C,
offset: this.L.O
};else if (arguments.length <= 3) {
this.L.L = line || 0;
this.L.C = column || 0;
this.L.O = offset || 0;
return this;
} else throw new Error("pos: invalid number of arguments");
}
/* set AST node attributes */
set(...args) {
if (args.length === 1 && typeof args[0] === "object") {
Object.keys(args[0]).forEach(key => {
if (args[0][key] !== undefined) this.A[key] = args[0][key];else delete this.A[key];
});
} else if (args.length === 2) {
if (args[1] !== undefined) this.A[args[0]] = args[1];else delete this.A[args[0]];
} else throw new Error("set: invalid number of arguments");
}, {
key: "set",
value: function set() {
var _this = this;
return this;
}
/* unset AST node attributes */
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args.length === 1 && typeof args[0] === "object") {
Object.keys(args[0]).forEach(function (key) {
if (args[0][key] !== undefined) _this.A[key] = args[0][key];else delete _this.A[key];
});
} else if (args.length === 2) {
if (args[1] !== undefined) this.A[args[0]] = args[1];else delete this.A[args[0]];
} else throw new Error("set: invalid number of arguments");
return this;
}
unset(...args) {
if (args.length === 1 && typeof args[0] === "object" && args[0] instanceof Array) {
args[0].forEach(key => {
delete this.A[key];
});
} else if (args.length === 1) delete this.A[args[0]];else throw new Error("unset: invalid number of arguments");
/* unset AST node attributes */
return this;
}
/* get AST node attributes */
}, {
key: "unset",
value: function unset() {
var _this2 = this;
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
get(...args) {
if (args.length !== 1) throw new Error("get: invalid number of arguments");
if (args.length === 1 && typeof args[0] === "object" && args[0] instanceof Array) {
args[0].forEach(function (key) {
delete _this2.A[key];
});
} else if (args.length === 1) delete this.A[args[0]];else throw new Error("unset: invalid number of arguments");
return this;
}
if (typeof args[0] === "object" && args[0] instanceof Array) {
return args[0].map(key => {
if (typeof key !== "string") throw new Error("get: invalid key argument");
return this.A[key];
});
} else {
let key = args[0];
if (typeof key !== "string") throw new Error("get: invalid key argument");
return this.A[key];
}
}
/* get names of all AST node attributes */
/* get AST node attributes */
}, {
key: "get",
value: function get() {
var _this3 = this;
attrs() {
return Object.keys(this.A);
}
/* return current sibling position */
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (args.length !== 1) throw new Error("get: invalid number of arguments");
if (typeof args[0] === "object" && args[0] instanceof Array) {
return args[0].map(function (key) {
if (typeof key !== "string") throw new Error("get: invalid key argument");
return _this3.A[key];
});
} else {
var key = args[0];
if (typeof key !== "string") throw new Error("get: invalid key argument");
return this.A[key];
}
}
nth() {
if (this.P === null) return 1;
let idx = this.P.C.indexOf(this);
if (idx < 0) throw new Error("nth: internal error -- node not in childs of its parent");
return idx;
}
/* insert child AST node(s) */
/* get names of all AST node attributes */
}, {
key: "attrs",
value: function attrs() {
return Object.keys(this.A);
}
ins(pos, ...args) {
if (args.length === 0) throw new Error("ins: invalid number of arguments");
if (pos < 0) pos = this.C.length + 1 - pos;
if (!(pos >= 0 && pos <= this.C.length)) throw new Error("ins: invalid position");
/* return current sibling position */
let _ins = node => {
if (!this.ctx.isA(node)) throw new Error("ins: invalid AST node argument");
this.C.splice(pos++, 0, node);
node.P = this;
};
}, {
key: "nth",
value: function nth() {
if (this.P === null) return 1;
var idx = this.P.C.indexOf(this);
if (idx < 0) throw new Error("nth: internal error -- node not in childs of its parent");
return idx;
}
args.forEach(arg => {
if (typeof arg === "object" && arg instanceof Array) arg.forEach(arg => {
_ins(arg);
});else if (arg !== null) _ins(arg);
});
return this;
}
/* add child AST node(s) */
/* insert child AST node(s) */
}, {
key: "ins",
value: function ins(pos) {
var _this4 = this;
add(...args) {
if (args.length === 0) throw new Error("add: invalid number of arguments");
for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
let _add = node => {
if (!this.ctx.isA(node)) throw new Error("add: invalid AST node argument");
this.C.push(node);
node.P = this;
};
if (args.length === 0) throw new Error("ins: invalid number of arguments");
if (pos < 0) pos = this.C.length + 1 - pos;
if (!(pos >= 0 && pos <= this.C.length)) throw new Error("ins: invalid position");
var _ins = function _ins(node) {
if (!_this4.ctx.isA(node)) throw new Error("ins: invalid AST node argument");
_this4.C.splice(pos++, 0, node);
node.P = _this4;
};
args.forEach(function (arg) {
if (typeof arg === "object" && arg instanceof Array) arg.forEach(function (arg) {
_ins(arg);
});else if (arg !== null) _ins(arg);
});
return this;
}
args.forEach(arg => {
if (typeof arg === "object" && arg instanceof Array) arg.forEach(arg => {
_add(arg);
});else if (arg !== null) _add(arg);
});
return this;
}
/* delete child AST node(s) */
/* add child AST node(s) */
}, {
key: "add",
value: function add() {
var _this5 = this;
del(...args) {
if (args.length === 0) throw new Error("del: invalid number of arguments");
args.forEach(node => {
if (!this.ctx.isA(node)) throw new Error("del: invalid AST node argument");
let found = false;
for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
if (args.length === 0) throw new Error("add: invalid number of arguments");
var _add = function _add(node) {
if (!_this5.ctx.isA(node)) throw new Error("add: invalid AST node argument");
_this5.C.push(node);
node.P = _this5;
};
args.forEach(function (arg) {
if (typeof arg === "object" && arg instanceof Array) arg.forEach(function (arg) {
_add(arg);
});else if (arg !== null) _add(arg);
});
return this;
for (let j = 0; j < this.C.length; j++) {
if (this.C[j] === node) {
this.C.splice(j, 1);
node.P = null;
found = true;
break;
}
}
/* delete child AST node(s) */
if (!found) throw new Error("del: AST node not found in childs");
});
return this;
}
/* get all or some child AST nodes */
}, {
key: "del",
value: function del() {
var _this6 = this;
for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
childs(...args) {
if (args.length > 2) throw new Error("childs: invalid number of arguments");
if (args.length === 2 && typeof args[0] === "number" && typeof args[1] === "number") return this.C.slice(args[0], args[1]);else if (args.length === 1 && typeof args[0] === "number") return this.C.slice(args[0]);else if (args.length === 0) return this.C;else throw new Error("childs: invalid type of arguments");
}
/* get one child AST node */
if (args.length === 0) throw new Error("del: invalid number of arguments");
args.forEach(function (node) {
if (!_this6.ctx.isA(node)) throw new Error("del: invalid AST node argument");
var found = false;
for (var j = 0; j < _this6.C.length; j++) {
if (_this6.C[j] === node) {
_this6.C.splice(j, 1);
node.P = null;
found = true;
break;
}
}
if (!found) throw new Error("del: AST node not found in childs");
});
return this;
}
/* get all or some child AST nodes */
child(pos) {
if (typeof pos !== "number") throw new Error("child: invalid argument");
return pos < this.C.length ? this.C[pos] : null;
}
/* get parent AST node */
}, {
key: "childs",
value: function childs() {
if (arguments.length > 2) throw new Error("childs: invalid number of arguments");
if (arguments.length === 2 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === "number" && typeof (arguments.length <= 1 ? undefined : arguments[1]) === "number") return this.C.slice(arguments.length <= 0 ? undefined : arguments[0], arguments.length <= 1 ? undefined : arguments[1]);else if (arguments.length === 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === "number") return this.C.slice(arguments.length <= 0 ? undefined : arguments[0]);else if (arguments.length === 0) return this.C;else throw new Error("childs: invalid type of arguments");
}
/* get one child AST node */
parent() {
return this.P;
}
/* serialize AST node recursively */
}, {
key: "child",
value: function child(pos) {
if (typeof pos !== "number") throw new Error("child: invalid argument");
return pos < this.C.length ? this.C[pos] : null;
}
/* get parent AST node */
serialize() {
return this.ctx.__serialize(this);
}
}, {
key: "parent",
value: function parent() {
return this.P;
}
}
/* serialize AST node recursively */
}, {
key: "serialize",
value: function serialize() {
return this.ctx.__serialize(this);
}
}]);
return ASTYBase;
}();
exports.default = ASTYBase;

@@ -332,9 +266,6 @@

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*

@@ -363,120 +294,123 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

*/
var 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: "-" }
const 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: "-"
}
};
var ASTYDump = function () {
function ASTYDump() {
_classCallCheck(this, ASTYDump);
}
class ASTYDump {
/* dump the AST recursively */
dump(maxDepth = Infinity, colorize = (type, txt) => txt, unicode = true) {
let out = "";
let self = this;
this.walk((node, depth
/*, parent, when */
) => {
/* short-circuit processing at a certain depth */
if (depth > maxDepth) return;
/* draw tree structure */
_createClass(ASTYDump, [{
key: "dump",
if (depth > 0) {
const nodeIndex = node => {
let nth = 0;
let max = 0;
/* dump the AST recursively */
value: function dump() {
var maxDepth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Infinity;
var colorize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (type, txt) {
return txt;
};
var unicode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
if (node.P !== null) {
nth = node.P.C.indexOf(node);
max = node.P.C.length - 1;
}
var out = "";
var self = this;
this.walk(function (node, depth /*, parent, when */) {
/* short-circuit processing at a certain depth */
if (depth > maxDepth) return;
return {
nth,
max
};
};
/* draw tree structure */
if (depth > 0) {
var nodeIndex = function nodeIndex(node) {
var nth = 0;
var max = 0;
if (node.P !== null) {
nth = node.P.C.indexOf(node);
max = node.P.C.length - 1;
}
return { nth, max };
};
let {
nth,
max
} = nodeIndex(node);
let prefix = " ";
if (unicode) prefix = `${tree.left.unicode}${tree.left.unicode}${prefix}`;else prefix = `${tree.left.ascii}${tree.left.ascii}${prefix}`;
if (nth < max) prefix = `${unicode ? tree.mid.unicode : tree.mid.ascii}${prefix}`;else prefix = `${unicode ? tree.last.unicode : tree.last.ascii}${prefix}`;
var _nodeIndex = nodeIndex(node),
nth = _nodeIndex.nth,
max = _nodeIndex.max;
for (let parent = node.P; parent !== null && parent !== self; parent = parent.P) {
if (parent.P !== null) {
let {
nth,
max
} = nodeIndex(parent);
if (nth < max) prefix = `${unicode ? tree.down.unicode : tree.down.ascii} ${prefix}`;else prefix = ` ${prefix}`;
}
}
var prefix = " ";
if (unicode) prefix = `${tree.left.unicode}${tree.left.unicode}${prefix}`;else prefix = `${tree.left.ascii}${tree.left.ascii}${prefix}`;
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 !== self; parent = parent.P) {
if (parent.P !== null) {
var _nodeIndex2 = nodeIndex(parent),
_nth = _nodeIndex2.nth,
_max = _nodeIndex2.max;
out += colorize("tree", prefix);
}
/* draw node type */
if (_nth < _max) prefix = `${unicode ? tree.down.unicode : tree.down.ascii} ${prefix}`;else prefix = ` ${prefix}`;
}
}
out += colorize("tree", prefix);
}
/* draw node type */
out += colorize("type", node.T) + " ";
out += colorize("type", node.T) + " ";
/* draw node attributes */
/* draw node attributes */
var keys = Object.keys(node.A);
if (keys.length > 0) {
out += colorize("parenthesis", "(");
var first = true;
keys.forEach(function (key) {
if (!first) out += colorize("comma", ",") + " ";else first = false;
out += colorize("key", key) + colorize("colon", ":") + " ";
var value = node.A[key];
switch (typeof value) {
case "boolean":
case "number":
out += colorize("value", value.toString());
break;
case "string":
{
var hex = function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
};
/* eslint no-control-regex: off */
out += colorize("value", "\"" + value.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 (ch) {
return "\\x0" + hex(ch);
}).replace(/[\x10-\x1F\x80-\xFF]/g, function (ch) {
return "\\x" + hex(ch);
}).replace(/[\u0100-\u0FFF]/g, function (ch) {
return "\\u0" + hex(ch);
}).replace(/[\u1000-\uFFFF]/g, function (ch) {
return "\\u" + hex(ch);
}) + "\"");
break;
}
case "object":
if (value instanceof RegExp) out += colorize("value", "/" + value.source + "/");else out += colorize("value", JSON.stringify(value));
break;
default:
out += colorize("value", JSON.stringify(value));
break;
}
});
out += colorize("parenthesis", ")") + " ";
}
let keys = Object.keys(node.A);
/* draw node position */
out += colorize("position", colorize("bracket", "[") + colorize("line", node.L.L) + colorize("slash", ",") + colorize("column", node.L.C) + colorize("bracket", "]"));
if (keys.length > 0) {
out += colorize("parenthesis", "(");
let first = true;
keys.forEach(key => {
if (!first) out += colorize("comma", ",") + " ";else first = false;
out += colorize("key", key) + colorize("colon", ":") + " ";
let value = node.A[key];
out += "\n";
}, "downward");
return out;
}
}]);
switch (typeof value) {
case "boolean":
case "number":
out += colorize("value", value.toString());
break;
return ASTYDump;
}();
case "string":
{
let hex = ch => ch.charCodeAt(0).toString(16).toUpperCase();
/* eslint no-control-regex: off */
out += colorize("value", "\"" + value.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, ch => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x80-\xFF]/g, ch => "\\x" + hex(ch)).replace(/[\u0100-\u0FFF]/g, ch => "\\u0" + hex(ch)).replace(/[\u1000-\uFFFF]/g, ch => "\\u" + hex(ch)) + "\"");
break;
}
case "object":
if (value instanceof RegExp) out += colorize("value", "/" + value.source + "/");else out += colorize("value", JSON.stringify(value));
break;
default:
out += colorize("value", JSON.stringify(value));
break;
}
});
out += colorize("parenthesis", ")") + " ";
}
/* draw node position */
out += colorize("position", colorize("bracket", "[") + colorize("line", node.L.L) + colorize("slash", ",") + colorize("column", node.L.C) + colorize("bracket", "]"));
out += "\n";
}, "downward");
return out;
}
}
exports.default = ASTYDump;

@@ -488,9 +422,6 @@

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*

@@ -519,41 +450,28 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

*/
class ASTYMerge {
/* merge attributes and childs of an AST node */
merge(node, takePos = false, attrMap = {}) {
if (node === null) return this;
if (!this.ctx.isA(node)) throw new Error("merge: invalid AST node argument");
var ASTYMerge = function () {
function ASTYMerge() {
_classCallCheck(this, ASTYMerge);
if (takePos) {
let pos = node.pos();
this.pos(pos.line, pos.column, pos.offset);
}
_createClass(ASTYMerge, [{
key: "merge",
node.attrs().forEach(attrSource => {
let attrTarget = typeof attrMap[attrSource] !== "undefined" ? attrMap[attrSource] : attrSource;
if (attrTarget !== null) this.set(attrTarget, node.get(attrSource));
});
node.childs().forEach(child => {
node.del(child);
this.add(child);
});
let parent = node.parent();
if (parent !== null) parent.del(node);
return this;
}
/* merge attributes and childs of an AST node */
value: function merge(node) {
var _this = this;
}
var takePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var attrMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (node === null) return this;
if (!this.ctx.isA(node)) throw new Error("merge: invalid AST node argument");
if (takePos) {
var pos = node.pos();
this.pos(pos.line, pos.column, pos.offset);
}
node.attrs().forEach(function (attrSource) {
var attrTarget = typeof attrMap[attrSource] !== "undefined" ? attrMap[attrSource] : attrSource;
if (attrTarget !== null) _this.set(attrTarget, node.get(attrSource));
});
node.childs().forEach(function (child) {
node.del(child);
_this.add(child);
});
var parent = node.parent();
if (parent !== null) parent.del(node);
return this;
}
}]);
return ASTYMerge;
}();
exports.default = ASTYMerge;

@@ -565,9 +483,6 @@

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*

@@ -596,83 +511,83 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

*/
class ASTYSerialize {
/* recursively serialize AST nodes into JSON string */
static serialize(asty, node) {
const serializeNode = node => {
let clone = {
T: node.T,
L: {
L: node.L.L,
C: node.L.C,
O: node.L.O
}
};
let keys = Object.keys(node.A);
var ASTYSerialize = function () {
function ASTYSerialize() {
_classCallCheck(this, ASTYSerialize);
}
if (keys.length > 0) {
clone.A = {};
keys.forEach(key => {
let value = node.A[key];
_createClass(ASTYSerialize, null, [{
key: "serialize",
switch (typeof value) {
case "boolean":
case "number":
case "string":
clone.A[key] = value;
break;
/* recursively serialize AST nodes into JSON string */
value: function serialize(asty, node) {
var serializeNode = function serializeNode(node) {
var clone = {
T: node.T,
L: { L: node.L.L, C: node.L.C, O: node.L.O }
};
var keys = Object.keys(node.A);
if (keys.length > 0) {
clone.A = {};
keys.forEach(function (key) {
var value = node.A[key];
switch (typeof value) {
case "boolean":
case "number":
case "string":
clone.A[key] = value;
break;
default:
/* use the slow approach only for non-atomic attributes */
clone.A[key] = JSON.parse(JSON.stringify(value));
break;
}
});
}
if (node.C.length > 0) clone.C = node.C.map(function (C) {
return serializeNode(C);
});
return clone;
};
if (!asty.isA(node)) throw new Error("serialize: not an ASTy node");
return JSON.stringify({ ASTy: serializeNode(node) });
}
default:
/* use the slow approach only for non-atomic attributes */
clone.A[key] = JSON.parse(JSON.stringify(value));
break;
}
});
}
/* recursively unserialize JSON string into AST nodes */
if (node.C.length > 0) clone.C = node.C.map(C => serializeNode(C));
return clone;
};
}, {
key: "unserialize",
value: function unserialize(asty, json) {
var unserializeNode = function unserializeNode(clone) {
var node = asty.create(clone.T);
node.pos(clone.L.L, clone.L.C, clone.L.O);
if (typeof clone.A === "object") {
Object.keys(clone.A).forEach(function (key) {
var value = clone.A[key];
switch (typeof value) {
case "boolean":
case "number":
case "string":
node.set(key, value);
break;
default:
/* use the slow approach only for non-atomic attributes */
node.set(key, JSON.parse(JSON.stringify(value)));
break;
}
});
}
if (typeof clone.C === "object" && clone.C instanceof Array) node.add(clone.C.map(function (C) {
return unserializeNode(C);
}));
return node;
};
var obj = JSON.parse(json);
if (typeof obj !== "object" || typeof obj.ASTy !== "object") throw new Error("unserialize: not an ASTy JSON export");
return unserializeNode(obj.ASTy);
}
}]);
if (!asty.isA(node)) throw new Error("serialize: not an ASTy node");
return JSON.stringify({
ASTy: serializeNode(node)
});
}
/* recursively unserialize JSON string into AST nodes */
return ASTYSerialize;
}();
static unserialize(asty, json) {
const unserializeNode = clone => {
let node = asty.create(clone.T);
node.pos(clone.L.L, clone.L.C, clone.L.O);
if (typeof clone.A === "object") {
Object.keys(clone.A).forEach(key => {
let value = clone.A[key];
switch (typeof value) {
case "boolean":
case "number":
case "string":
node.set(key, value);
break;
default:
/* use the slow approach only for non-atomic attributes */
node.set(key, JSON.parse(JSON.stringify(value)));
break;
}
});
}
if (typeof clone.C === "object" && clone.C instanceof Array) node.add(clone.C.map(C => unserializeNode(C)));
return node;
};
let obj = JSON.parse(json);
if (typeof obj !== "object" || typeof obj.ASTy !== "object") throw new Error("unserialize: not an ASTy JSON export");
return unserializeNode(obj.ASTy);
}
}
exports.default = ASTYSerialize;

@@ -684,4 +599,6 @@

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
/*

@@ -712,15 +629,17 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

/* global 1: false */
/* global 7: false */
/* global 14: false */
/* global 20180623: false */
var version = {
major: 1,
minor: 7,
micro: 14,
date: 20180623
const version = {
major: 1,
minor: 7,
micro: 14,
date: 20180623
};
var _default = version;
exports.default = _default;
exports.default = version;
},{}],6:[function(_dereq_,module,exports){

@@ -730,9 +649,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*

@@ -761,30 +677,20 @@ ** ASTy -- Abstract Syntax Tree (AST) Data Structure

*/
class ASTYWalk {
/* walk the AST recursively */
walk(cb, when = "downward") {
let _walk = (node, depth, parent) => {
if (when === "downward" || when === "both") cb(node, depth, parent, "downward");
node.C.forEach(child => {
_walk(child, depth + 1, node);
});
if (when === "upward" || when === "both") cb(node, depth, parent, "upward");
};
var ASTYWalk = function () {
function ASTYWalk() {
_classCallCheck(this, ASTYWalk);
}
_walk(this, 0, null);
_createClass(ASTYWalk, [{
key: "walk",
return this;
}
/* walk the AST recursively */
value: function walk(cb) {
var when = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "downward";
}
var _walk = function _walk(node, depth, parent) {
if (when === "downward" || when === "both") cb(node, depth, parent, "downward");
node.C.forEach(function (child) {
_walk(child, depth + 1, node);
});
if (when === "upward" || when === "both") cb(node, depth, parent, "upward");
};
_walk(this, 0, null);
return this;
}
}]);
return ASTYWalk;
}();
exports.default = ASTYWalk;

@@ -795,114 +701,84 @@

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /*
** ASTy -- Abstract Syntax Tree (AST) Data Structure
** Copyright (c) 2014-2018 Ralf S. Engelschall <rse@engelschall.com>
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var _astyBase = _interopRequireDefault(_dereq_("./asty-base.js"));
var _astyBase = _dereq_("./asty-base.js");
var _astyMerge = _interopRequireDefault(_dereq_("./asty-merge.js"));
var _astyBase2 = _interopRequireDefault(_astyBase);
var _astyWalk = _interopRequireDefault(_dereq_("./asty-walk.js"));
var _astyMerge = _dereq_("./asty-merge.js");
var _astyDump = _interopRequireDefault(_dereq_("./asty-dump.js"));
var _astyMerge2 = _interopRequireDefault(_astyMerge);
var _astySerialize = _interopRequireDefault(_dereq_("./asty-serialize.js"));
var _astyWalk = _dereq_("./asty-walk.js");
var _astyVersion = _interopRequireDefault(_dereq_("./asty-version.js"));
var _astyWalk2 = _interopRequireDefault(_astyWalk);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _astyDump = _dereq_("./asty-dump.js");
/*
** ASTy -- Abstract Syntax Tree (AST) Data Structure
** Copyright (c) 2014-2018 Ralf S. Engelschall <rse@engelschall.com>
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
class ASTYCtx {
constructor() {
this.ASTYNode = class ASTYNode {};
let mixins = [[_astyBase.default, "init", "create", "type", "pos", "set", "unset", "get", "attrs", "nth", "ins", "add", "del", "childs", "child", "parent", "serialize"], [_astyMerge.default, "merge"], [_astyWalk.default, "walk"], [_astyDump.default, "dump"]];
mixins.forEach(mixin => {
let proto = mixin[0].prototype;
mixin.slice(1).forEach(method => {
this.ASTYNode.prototype[method] = proto[method];
});
});
return this;
}
var _astyDump2 = _interopRequireDefault(_astyDump);
version() {
return _astyVersion.default;
}
var _astySerialize = _dereq_("./asty-serialize.js");
extend(mixin) {
for (let method in mixin) if (mixin.hasOwnProperty(method)) this.ASTYNode.prototype[method] = mixin[method];
var _astySerialize2 = _interopRequireDefault(_astySerialize);
return this;
}
var _astyVersion = _dereq_("./asty-version.js");
create(type, attrs, childs) {
return new this.ASTYNode().init(this, type, attrs, childs);
}
var _astyVersion2 = _interopRequireDefault(_astyVersion);
isA(node) {
return typeof node === "object" && node instanceof this.ASTYNode && typeof node.ASTy === "boolean" && node.ASTy === true;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
__serialize(node) {
return ASTYCtx.serialize(node);
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
static serialize(node) {
return _astySerialize.default.serialize(node.ctx, node);
}
var ASTYCtx = function () {
function ASTYCtx() {
var _this = this;
static unserialize(json) {
let Ctx = this;
return _astySerialize.default.unserialize(new Ctx(), json);
}
_classCallCheck(this, ASTYCtx);
this.ASTYNode = function () {};
var mixins = [[_astyBase2.default, "init", "create", "type", "pos", "set", "unset", "get", "attrs", "nth", "ins", "add", "del", "childs", "child", "parent", "serialize"], [_astyMerge2.default, "merge"], [_astyWalk2.default, "walk"], [_astyDump2.default, "dump"]];
mixins.forEach(function (mixin) {
var proto = mixin[0].prototype;
mixin.slice(1).forEach(function (method) {
_this.ASTYNode.prototype[method] = proto[method];
});
});
return this;
}
_createClass(ASTYCtx, [{
key: "version",
value: function version() {
return _astyVersion2.default;
}
}, {
key: "extend",
value: function extend(mixin) {
for (var method in mixin) {
if (mixin.hasOwnProperty(method)) this.ASTYNode.prototype[method] = mixin[method];
}return this;
}
}, {
key: "create",
value: function create(type, attrs, childs) {
return new this.ASTYNode().init(this, type, attrs, childs);
}
}, {
key: "isA",
value: function isA(node) {
return typeof node === "object" && node instanceof this.ASTYNode && typeof node.ASTy === "boolean" && node.ASTy === true;
}
}, {
key: "__serialize",
value: function __serialize(node) {
return ASTYCtx.serialize(node);
}
}], [{
key: "serialize",
value: function serialize(node) {
return _astySerialize2.default.serialize(node.ctx, node);
}
}, {
key: "unserialize",
value: function unserialize(json) {
var Ctx = this;
return _astySerialize2.default.unserialize(new Ctx(), json);
}
}]);
return ASTYCtx;
}();
}
/* export the traditional way for interoperability reasons

@@ -909,0 +785,0 @@ (as Babel would export an object with a 'default' field) */

{
"name": "asty",
"version": "1.7.16",
"version": "1.8.0",
"description": "Abstract Syntax Tree (AST) Data Structure",

@@ -22,19 +22,19 @@ "keywords": [ "ast", "abstract", "syntax", "tree", "data", "structure" ],

"grunt": "1.0.3",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "1.1.0",
"grunt-cli": "1.3.2",
"grunt-contrib-clean": "2.0.0",
"grunt-browserify": "5.3.0",
"grunt-mocha-test": "0.13.3",
"grunt-eslint": "21.0.0",
"babel-eslint": "8.2.6",
"babel-core": "6.26.3",
"eslint": "5.3.0",
"eslint-config-standard": "11.0.0",
"eslint-plugin-standard": "3.1.0",
"eslint-plugin-promise": "3.8.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-node": "7.0.1",
"babel-eslint": "10.0.1",
"@babel/core": "7.2.2",
"eslint": "5.10.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-standard": "4.0.0",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "8.0.0",
"mocha": "5.2.0",
"chai": "4.1.2",
"babelify": "8.0.0",
"babel-preset-env": "1.7.0",
"chai": "4.2.0",
"babelify": "10.0.0",
"@babel/preset-env": "7.2.3",
"uglifyify": "5.0.1",

@@ -46,3 +46,3 @@ "browserify-header": "0.9.4",

"engines": {
"node": ">=4.0.0"
"node": ">=8.0.0"
},

@@ -49,0 +49,0 @@ "scripts": {

@@ -34,3 +34,3 @@ /*

constructor () {
this.ASTYNode = () => {}
this.ASTYNode = class ASTYNode {}
let mixins = [

@@ -37,0 +37,0 @@ [ ASTYBase,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc