
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Tiny javaScript library to build your classes inheritance in a convenient way.
This library doesn't make sense anymore, as there are classes syntax in ES6.
Create your base class
var MagicAnimal = oopize({
say: function() {
return 'hey, dude!';
}
});
var a = new MagicAnimal();
console.log( a.say() ); // hey, dude!
Extend your class
var MagicDog = MagicAnimal.extend(function(parentProto) { return {
say: function() {
return parentProto.say.call(this)+' Ruf, ruf!';
}
}});
var d = new MagicDog();
console.log( d.say() ); // hey, dude! Ruf, ruf!
Extend some 3rd side (not oopized) class
var MagicArray = oopize.inherit(Array, {
add: function(el) {
return this.push(el);
},
size: function() {
return this.length;
}
});
var a = new MagicArray();
a.add(5);
console.log(a.size());
Create base class constructor (inherited from Object).
Extend your class. Every constructor, created by one of oopize methods, has method extend().
Extend 3rd side class.
Use method init() instead of constructor. This method will be called internally from returned constructor.
var Person = oopize({
init: function(name) {
this.name = name;
},
getName: function() {
return this.name;
}
});
var me = new Person('Roman');
console.log( me.getName() ); // Roman
There is constructor inheritance by default. Default method init() calls parent constructor. But if you define your own init() method, you could call it or not.
var Human = oopize({
// init method in base class
init: function(height) {
this.height = height || 175;
},
getHeight: function() {
return this.height;
}
});
// extend base class without init definition
var Programmer = Human.extend({});
var programmer = new Programmer();
console.log( programmer.getHeight() ); // 175
var Hobbit = Human.extend(function(parentProto) { return {
// child class init definition
init: function(height) {
// call init method of parent class
parentProto.init.call(this, height || 107);
}
}});
var hobbit = new Hobbit();
console.log( hobbit.getHeight() ); // 107
If instanceDescription param is an object, all its properties will be copied to your constructor prototype.
If instanceDescription param is a function, it will be called once immediately with arguments (parentProto, constructor). This function should return object with properties for your constructor prototype. In this way you have simple access to parent prototype and current constructor. Constructor of parent class is accessible as constructor.parent
classDescription param is similar. If it's an object, all its properties will be copied directly to constructor. If it's a function, it will be called with params (parentConstructor, constructor).
classDescription properties aren't inheritable
MIT
FAQs
Tiny javaScript library to build your classes inheritance in a convenient way.
We found that oopize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.