
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Augmented Object Oriented Programming This node module allow programmers to use some of Object Oriented tecniques on JavaScript (Prototype Oriented)
For install library is easy to install by cloning the repo. You can install trhought npm too: Local installation
npm install aoop
Global installation
npm install -g aoop
const aoop = require('aoop');
//aoop module contains this elements:
//{
// Mixin:[Function],
// Interface:[Function],
// Utils:{
// copyProto:[Function],
// copyAsProto: [Function],
// extend: [Function],
// getProto: [Function],
// isClass: [Function]
// }
//}
Mixin(class A,class B,[... classes])This function takes all methods from two or more classes (or constructor functions) and create another one that inherits all of them from the mixins classes. Remember that the hierarchy of inheritance goes from left to right
const { Mixin } = require('aoop');
//creating two classes A and B
//class A created as constructor function
function A(){}
A.prototype.foo = function(){console.log('foo');};
A.prototype.baz = function(){console.log('Baz from A!');};
//class B created as ES6 class
class B{
bar(){console.log('bar');}
baz(){console.log('Baz from B!');}
}
//USING MIXIN
//class C created as class
const C = new Mixin(A,B);
//class D created as ES6 class
class D extends Mixin(B,A){}
//TESTING INSTANCES
var c = new C();
var d = new D();
c.foo(); //foo
c.bar(); //bar
c.baz(); //Baz from A! (the Mixin(A,B) takes A > B hierachy)
d.foo(); //foo
d.bar(); //bar
d.baz(); //Baz from B! (the Mixin(B,A) takes B > A hierachy)
Interface(proto, constrain)This function constrain a constructor of a class (or a particular object) to have some methods defined in the proto argument. constrain argument tell the Interface to instanciate methods from his proto to the extended class.
You can create an object from an Interface too using default methods described in the Interface proto. The Interface's instance constructor take a force argument to tell the instance to use Interface's proto defaults methods.
const { Interface, Utils } = require('aoop');
//Creating Interface that must have "bye" method
var proto = {
bye(){console.log('good bye from Hello')}
};
const Hello = new Interface(proto);
//as Function without "bye" method
function A(){Hello.call(this);}
Utils.extend(A,Hello);
//as Function with "bye" method
function B(){Hello.call(this);}
Utils.extend(B,Hello);
B.prototype.bye = function(){console.log('good bye from B');};
//as Function with defaults methods (passing "force" argument to Hello Interface)
function C(){Hello.call(this,true);}
Utils.extend(C,Hello);
//as class without "bye" method
class D extends Hello{}
//as class with "bye" method
class E extends Hello{bye(){console.log('good bye from E');}}
//as class with Hello defaults methods (passing "force" argument to Hello Interface)
class F extends Hello{constructor(){super(true);}}
var a = new A(); //throw an InterfaceError becaues is missing "bye" method
var b = new B();
var c = new C();
var d = new D(); //throw an InterfaceError becaues is missing "bye" method
var e = new E();
var f = new F();
var h = new Hello(true); //generate an Interface instance by passing true as "force" argument
b.bye(); //good bye from B
c.bye(); //good bye from Hello
e.bye(); //good bye from E
f.bye(); //good bye from Hello
h.bye(); //good bye from Hello
Utils This object is a library of some tools for deal with functions.
copyProto(A,B): get and copy the prototype of B to A
copyAsProto(A,B): copy directly object B to A as prototype object
extend(A,B): extend the A function with prototype of B
getProto(A): return the correct proto of the function A
isClass(A): return true if the A function is an ES6 class object or false if it is a normal JavaScript function
If you like the project feel free to contact me on my .
Something gone wrong? Feel free to rise an issue!
Did you like this project and it was usefull? Help me improve my work:
FAQs
Augmented Object Oriented Programming
We found that aoop 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.