Comparing version 0.9.3 to 0.9.4
@@ -32,6 +32,4 @@ /* | ||
},{}],4:[function(require,module,exports){ | ||
"use strict";var ASTQuery=function(){};module.exports=ASTQuery; | ||
},{}],5:[function(require,module,exports){ | ||
"use strict";var _inherits=function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(e.__proto__=r)},ASTYBase=require("./asty-base.js"),ASTYDump=require("./asty-dump.js"),ASTYQuery=require("./asty-query.js"),mixins=require("./asty-mixins.js"),ASTY=function(e){function r(){if(this instanceof r)return this.init.apply(this,arguments);var e=new r("");return e.init.apply(e,arguments)}return _inherits(r,e),r}(mixins(ASTYBase,ASTYDump,ASTYQuery));module.exports=ASTY; | ||
},{"./asty-base.js":1,"./asty-dump.js":2,"./asty-mixins.js":3,"./asty-query.js":4}]},{},[1,2,3,4,5])(5) | ||
"use strict";var _inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},ASTYBase=require("./asty-base.js"),ASTYDump=require("./asty-dump.js"),mixins=require("./asty-mixins.js"),ASTY=function(e){function t(){if(this instanceof t)return this.init.apply(this,arguments);var e=new t("");return e.init.apply(e,arguments)}return _inherits(t,e),t}(mixins(ASTYBase,ASTYDump));ASTY.extend=function(e){for(var t in e)ASTY.prototype[t]=e[t]},module.exports=ASTY; | ||
},{"./asty-base.js":1,"./asty-dump.js":2,"./asty-mixins.js":3}]},{},[1,2,3,4])(4) | ||
}); | ||
@@ -38,0 +36,0 @@ |
{ | ||
"name": "asty", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Generic Abstract Syntax Tree (AST)", | ||
@@ -5,0 +5,0 @@ "keywords": [ "ast", "abstract", "syntax", "tree" ], |
@@ -48,2 +48,7 @@ | ||
- `ASTY.extend(object: { [methodName: String]: [methodFunc: Function] }): Void`:<br/> | ||
Extend the ASTY class with additional methods which are then available on each | ||
AST node during instanciation. This actually extends the ASTY prototype and | ||
should be used by extension modules only. | ||
- `new ASTY(type: String, attrs?: {[name: String]: [value: Object]}, childs?: ASTY[]): ASTY`:<br/> | ||
@@ -50,0 +55,0 @@ Create a new ASTY node and optionally already set attributes and add child nodes. |
@@ -25,8 +25,9 @@ /* | ||
var ASTYBase = require("./asty-base.js"); | ||
var ASTYDump = require("./asty-dump.js"); | ||
var ASTYQuery = require("./asty-query.js"); | ||
var mixins = require("./asty-mixins.js"); | ||
var ASTYBase = require("./asty-base.js"); | ||
var ASTYDump = require("./asty-dump.js"); | ||
var mixins = require("./asty-mixins.js"); | ||
var ASTY = class ASTY extends mixins(ASTYBase, ASTYDump, ASTYQuery) { | ||
/* the base class */ | ||
var ASTY = class ASTY extends mixins(ASTYBase, ASTYDump) { | ||
/* the constructor mainly passes control to the init function */ | ||
constructor () { | ||
@@ -42,3 +43,9 @@ if (!(this instanceof ASTY)) { | ||
/* static function for extending the class */ | ||
ASTY.extend = (methods) => { | ||
for (var method in methods) | ||
ASTY.prototype[method] = methods[method] | ||
} | ||
module.exports = ASTY | ||
@@ -35,3 +35,15 @@ /* | ||
}) | ||
it("extension functionality", function () { | ||
var ASTy = require("../lib/asty.js"); | ||
ASTy.extend({ | ||
foo: function (arg) { | ||
return "<" + arg + ">" | ||
} | ||
}) | ||
var ast = new ASTy("foo"); | ||
expect(ast).to.be.a("object") | ||
expect(ast).to.respondTo("foo") | ||
expect(ast.foo("bar")).to.be.equal("<bar>"); | ||
}) | ||
}) | ||
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
130
53633
15
577