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.5.5 to 1.5.6

2

bower.json
{
"name": "asty",
"version": "1.5.5",
"version": "1.5.6",
"description": "Abstract Syntax Tree (AST) Data Structure",

@@ -5,0 +5,0 @@ "main": "lib/asty.browser.js",

@@ -26,3 +26,3 @@ /*

(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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))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(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),ASTYBase=function(){function t(){_classCallCheck(this,t)}return _createClass(t,[{key:"init",value:function(t,e,n,r){if(arguments.length<2)throw new Error("init: invalid number of arguments");if(this.ctx=t,this.ASTy=!0,this.T=e,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:"type",value:function(t){if(0===arguments.length)return this.T;if(1===arguments.length)return this.T=t,this;throw new Error("type: invalid number of arguments")}},{key:"pos",value:function(t,e,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=t||0,this.L.C=e||0,this.L.O=n||0,this;throw new Error("pos: invalid number of arguments")}},{key:"set",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0]))Object.keys(n[0]).forEach(function(e){t.A[e]=n[0][e]});else{if(2!==n.length)throw new Error("set: invalid number of arguments");this.A[n[0]]=n[1]}return this}},{key:"unset",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0])&&n[0]instanceof Array)n[0].forEach(function(e){delete t.A[e]});else{if(1!==n.length)throw new Error("unset: invalid number of arguments");delete this.A[n[0]]}return this}},{key:"get",value:function(t){if(1!==arguments.length)throw new Error("get: invalid number of arguments");if("string"!=typeof t)throw new Error("get: invalid key argument");return this.A[t]}},{key:"attrs",value:function(){return Object.keys(this.A)}},{key:"nth",value:function(){if(null===this.P)return 1;var t=this.P.C.indexOf(this);if(t<0)throw new Error("nth: internal error -- node not in childs of its parent");return t}},{key:"ins",value:function(t){for(var e=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(t<0&&(t=this.C.length+1-t),!(0<=t&&t<=this.C.length))throw new Error("ins: invalid position");var o=function(n){if(!e.ctx.isA(n))throw new Error("ins: invalid AST node argument");e.C.splice(t++,0,n),n.P=e};return r.forEach(function(t){"object"===(void 0===t?"undefined":_typeof(t))&&t instanceof Array?t.forEach(function(t){o(t)}):null!==t&&o(t)}),this}},{key:"add",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(0===n.length)throw new Error("add: invalid number of arguments");var i=function(e){if(!t.ctx.isA(e))throw new Error("add: invalid AST node argument");t.C.push(e),e.P=t};return n.forEach(function(t){"object"===(void 0===t?"undefined":_typeof(t))&&t instanceof Array?t.forEach(function(t){i(t)}):null!==t&&i(t)}),this}},{key:"del",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(0===n.length)throw new Error("del: invalid number of argument");return n.forEach(function(e){if(!t.ctx.isA(e))throw new Error("del: invalid AST node argument");for(var n=!1,r=0;r<t.C.length;r++)if(t.C[r]===e){t.C.splice(r,1),e.P=null,n=!0;break}if(!n)throw new Error("del: AST node not found in childs")}),this}},{key:"childs",value:function(){return this.C}},{key:"parent",value:function(){return this.P}},{key:"serialize",value:function(){return this.ctx.serialize(this.ctx,this)}}]),t}();exports.default=ASTYBase;
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))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(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),ASTYBase=function(){function t(){_classCallCheck(this,t)}return _createClass(t,[{key:"init",value:function(t,e,n,r){if(arguments.length<2)throw new Error("init: invalid number of arguments");if(this.ctx=t,this.ASTy=!0,this.T=e,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:"type",value:function(t){if(0===arguments.length)return this.T;if(1===arguments.length)return this.T=t,this;throw new Error("type: invalid number of arguments")}},{key:"pos",value:function(t,e,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=t||0,this.L.C=e||0,this.L.O=n||0,this;throw new Error("pos: invalid number of arguments")}},{key:"set",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0]))Object.keys(n[0]).forEach(function(e){t.A[e]=n[0][e]});else{if(2!==n.length)throw new Error("set: invalid number of arguments");this.A[n[0]]=n[1]}return this}},{key:"unset",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(1===n.length&&"object"===_typeof(n[0])&&n[0]instanceof Array)n[0].forEach(function(e){delete t.A[e]});else{if(1!==n.length)throw new Error("unset: invalid number of arguments");delete this.A[n[0]]}return this}},{key:"get",value:function(t){if(1!==arguments.length)throw new Error("get: invalid number of arguments");if("string"!=typeof t)throw new Error("get: invalid key argument");return this.A[t]}},{key:"attrs",value:function(){return Object.keys(this.A)}},{key:"nth",value:function(){if(null===this.P)return 1;var t=this.P.C.indexOf(this);if(t<0)throw new Error("nth: internal error -- node not in childs of its parent");return t}},{key:"ins",value:function(t){for(var e=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(t<0&&(t=this.C.length+1-t),!(0<=t&&t<=this.C.length))throw new Error("ins: invalid position");var o=function(n){if(!e.ctx.isA(n))throw new Error("ins: invalid AST node argument");e.C.splice(t++,0,n),n.P=e};return r.forEach(function(t){"object"===(void 0===t?"undefined":_typeof(t))&&t instanceof Array?t.forEach(function(t){o(t)}):null!==t&&o(t)}),this}},{key:"add",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(0===n.length)throw new Error("add: invalid number of arguments");var i=function(e){if(!t.ctx.isA(e))throw new Error("add: invalid AST node argument");t.C.push(e),e.P=t};return n.forEach(function(t){"object"===(void 0===t?"undefined":_typeof(t))&&t instanceof Array?t.forEach(function(t){i(t)}):null!==t&&i(t)}),this}},{key:"del",value:function(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(0===n.length)throw new Error("del: invalid number of arguments");return n.forEach(function(e){if(!t.ctx.isA(e))throw new Error("del: invalid AST node argument");for(var n=!1,r=0;r<t.C.length;r++)if(t.C[r]===e){t.C.splice(r,1),e.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(t){if("number"!=typeof t)throw new Error("child: invalid argument");return t<this.C.length?this.C[t]:null}},{key:"parent",value:function(){return this.P}},{key:"serialize",value:function(){return this.ctx.serialize(this.ctx,this)}}]),t}();exports.default=ASTYBase;
},{}],2:[function(_dereq_,module,exports){

@@ -35,3 +35,3 @@ "use strict";function _classCallCheck(e,r){if(!(e instanceof r))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,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}}(),ASTYDump=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"dump",value:function(e){void 0===e&&(e=1/0);var r="";return this.walk(function(t,n){if(!(n>e)){for(var o=0;o<n;o++)r+=" ";r+=t.T+" ";var a=Object.keys(t.A);if(a.length>0){r+="(";var c=!0;a.forEach(function(e){c?c=!1:r+=", ",r+=e+": ";var n=t.A[e];switch(void 0===n?"undefined":_typeof(n)){case"boolean":case"number":r+=n.toString();break;case"string":var o=function(e){return e.charCodeAt(0).toString(16).toUpperCase()};r+='"'+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+=n.source:r+=JSON.stringify(n);break;default:r+=JSON.stringify(n)}}),r+=") "}r+="["+t.L.L+"/"+t.L.C+"]\n"}},"downward"),r}}]),e}();exports.default=ASTYDump;

},{}],5:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:1,minor:5,micro:5,date:20180311};exports.default=version;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:1,minor:5,micro:6,date:20180317};exports.default=version;
},{}],6:[function(_dereq_,module,exports){

@@ -38,0 +38,0 @@ "use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(n,a,t){return a&&e(n.prototype,a),t&&e(n,t),n}}(),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 a(t,r,l){"downward"!==n&&"both"!==n||e.call(null,t,r,l,"downward"),t.C.forEach(function(e){a(e,r+1,t)}),"upward"!==n&&"both"!==n||e.call(null,t,r,l,"upward")}(this,0,null),this}}]),e}();exports.default=ASTYWalk;

@@ -247,3 +247,3 @@ /*

if (args.length === 0) throw new Error("del: invalid number of argument");
if (args.length === 0) throw new Error("del: invalid number of arguments");
args.forEach(function (node) {

@@ -265,3 +265,3 @@ if (!_this5.ctx.isA(node)) throw new Error("del: invalid AST node argument");

/* get child AST nodes */
/* get all or some child AST nodes */

@@ -271,5 +271,15 @@ }, {

value: function childs() {
return this.C;
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 */
}, {
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 */

@@ -622,4 +632,4 @@

/* global 5: false */
/* global 5: false */
/* global 20180311: false */
/* global 6: false */
/* global 20180317: false */

@@ -629,4 +639,4 @@ var version = {

minor: 5,
micro: 5,
date: 20180311
micro: 6,
date: 20180317
};

@@ -633,0 +643,0 @@

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

@@ -5,0 +5,0 @@ "keywords": [ "ast", "abstract", "syntax", "tree", "data", "structure" ],

@@ -122,5 +122,10 @@

- `ASTYNode#childs(): ASTYNode[]`:<br/>
Get a nodes list of childs.
- `ASTYNode#childs(begin?: Number, end?: Number): ASTYNode[]`:<br/>
Get a nodes list of all or some childs. The `begin` and `end` parameters
are passed-through to `Array::slice`. If the range from `begin` to `end` is
out of range, an empty array is returned.
- `ASTYNode#child(pos: Number): ASTYNode`:<br/>
Get a particular child node. If `pos` is out of range, `null` is returned.
- `ASTYNode#parent(): ASTYNode`:<br/>

@@ -127,0 +132,0 @@ Get parent node.

@@ -177,3 +177,3 @@ /*

if (args.length === 0)
throw new Error("del: invalid number of argument")
throw new Error("del: invalid number of arguments")
args.forEach((node) => {

@@ -197,7 +197,23 @@ if (!this.ctx.isA(node))

/* get child AST nodes */
childs () {
return this.C
/* get all or some child AST nodes */
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 */
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 */

@@ -204,0 +220,0 @@ parent () {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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