
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
appolo-class
Advanced tools
Simple and powerful class system for node js
npm install appolo-class --save
var Rectangle = Class.define({
area: function () {
return 25;
}
});
var rectangle = new Rectangle();
creating class with constractor
var Rectangle = Class.define({
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
var rectangle = new Rectangle(5, 5);
console.log(rectangle.area()) // 25
var Rectangle = Class.define({
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
var Square = Class.define({
$config: {
extends: Rectangle
},
constructor: function (side) {
this.callParent(this, side, side);
}
});
var square = new Square(6);
console.log(square.area()) // 36
you can also use Class.define
fucntion
var Rectangle = Class.define({
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
var Square = Rectangle.define({
constructor: function (side) {
this.callParent(side, side);
}
});
var square = new Square(6);
console.log(square.area()) // 36
use this.callParent
function to call the parent method
var Rectangle = Class.define({
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
var Square = Rectangle.define({
constructor: function (side) {
this.callParent(side, side);
}
});
var Cube = Square.define({
constructor: function (side) {
this.callParent(side);
this.side = side;
},
area: function () {
return 6 * this.callParent()
},
volume: function () {
return Math.pow(this.side,3);
}
});
var cube = new Cube(5);
console.log(cube.area()) //150;
console.log(cube.volume()) //125;
var Rectangle = Class.define({
$config: {
statics: {
MIN_SIDE: 1,
MAX_SIDE: 150
}
},
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
console.log(Rectangle.MIN_SIDE) //1;
var rectangle = new Rectangle(5, 5);
console.log(rectangle.MIN_SIDE.should.equal(1)) //1;
used to add protoype functions from other classes
var Events = Class.define({
bind: function (event, fn) {
return true;
},
unbind: function (event, fn) {
return true;
}
});
var Rectangle = Class.define({
$config: {
mixins: [Events]
},
constructor: function (width, height) {
this.height = height;
this.width = width;
},
area: function () {
return this.width * this.height;
}
});
var rectangle = new Rectangle(5, 5);
rectangle.bind('test',function(){})
rectangle.unbind('test',function(){})
create class on the global scope
Class.define('Test.Position.Base', {
constructor: function (symbol, amount, side) {
this.symbol = symbol;
this.amount = amount;
this.side = side;
}
});
Position.define('Test.Position.Long', {
constructor: function (symbol, amount) {
this.callParent( symbol, amount, 2);
}
});
Position.define("Test.Position.Short", {
constructor: function (symbol, amount) {
this.callParent(symbol, amount, 2);
}
});
var short = new Test.Position.Short();
var long = new Test.Position.Long();
you can define the class name
var Position = Class.define({
constructor: function (symbol, amount, side) {
this.symbol = symbol;
this.amount = amount;
this.side = side;
}
});
var Long = Position.define({
$config: {
name: "long"
},
constructor: function (symbol, amount) {
this.callParent( symbol, amount, 2);
}
});
var Short = Position.define({
$config: {
name: "short"
},
constructor: function (symbol, amount) {
this.callParent(symbol, amount, 2);
}
});
var short = new Short();
var long = new Long();
consloe.log(short.constructor.name) // short
console.log(long.constructor.name) //long;
define properties with getter and setter functions. if a property in defined to be a member and a getter or setter is not implemented then erro will be trown
var Rectangle = Class.define({
$config: {
members: ['area','name']
},
constructor: function (width, height) {
this.height = height;
this.width = width;
},
getArea: function () {
return this.width * this.height;
},
getName:function(){
return this._name;
},
setName:function(value){
this._name = value;
}
});
var rectangle = new Rectangle(5, 5);
console.log(rectangle.area) //25;
rectangle.area = 10 // error not implemented
you can your custom plugins to the class system by adding callback function
the function will be called with 3 arguments
config
- config object of the classklass
- class referanceparent
- parent class referanceClass.addPlugin(function(config,klass,parent){
//do something
});
grunt test
The appolo class
library is released under the MIT license. So feel free to modify and distribute it as you wish.
FAQs
simple and powerful class system for node js
The npm package appolo-class receives a total of 1 weekly downloads. As such, appolo-class popularity was classified as not popular.
We found that appolo-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.