
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
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.
The npm package oopize receives a total of 4 weekly downloads. As such, oopize popularity was classified as not popular.
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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.