Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
class-wrapper
Advanced tools
Set of wrappers for easier definition of different kind of classes. Currently there are three kinds of wrappers:
ClassBuilder
- the main wrapper that realize the inheritance and data encapsulation. It requires a function that defines how the instances will be created. It returns the clone of defined instance builder function with special features and properties.Class
- it has predefined instance builder function for ClassBuilder
, that calls all parent's constructors before calling the constructor of a new classSingletonClass
- it has predefined instance builder function for ClassBuilder
, that by any new
always returns the same instance. The first instance will be created in the same way as Class
Each wrapper accepts:
Defined class properties are treated as default values for a new instance and they are isolated between instances. For example if some class has an object in properties then each instance will have its own copy of that default object. Only methods are shared.
If this library is planned to be used in some legacy environment then please add required plyfills. Here is a good resource: https://github.com/es-shims/es5-shim
Via NPM (Node Package Manager)
$ npm install class-wrapper --save
Available library files:
dest/class-wrapper.js
- not minified library packagedest/class-wrapper.min.js
- minified library packageThe destination library files are surrounded with the universal module definition. So it can be loaded
"class-wapper"
// Define a Figure class:
var Figure = Class(function() {
console.log('Figure::initialize()');
}, {
// abstract function for a calculating a suqare of a figure
calcArea: function() {}
});
// Define Rectangle class derived from a Figure class:
var Rectangle = Class(Figure, function(width, height) {
console.log('Rectangle::initialize()');
this._width = width;
this._height = height;
}, {
_width: 0,
_height: 0,
calcArea: function() {
return this._width * this._height;
}
});
// Define Square class as a special case of Rectangle:
var Square = Class(Rectangle, function(length) {
console.log('Square::initialize()');
this._height = length;
});
// Create a rectangle with width 2 and height 4
var someRect = new Rectangle(2, 4);
// the following lines will be logged in console:
// Figure::initialize()
// Rectangle::initialize()
console.log(someRect.calcArea()); // the area is: 8
// Create a square with an edge length 5
var someSqrt = new Square(5);
// the following lines will be logged in console:
// Figure::initialize()
// Rectangle::initialize()
// Square::initialize()
console.log(someSqrt.calcArea()); // the area is: 25
FAQs
Set of wrappers to define a class like in C++ and few utility functions
The npm package class-wrapper receives a total of 45 weekly downloads. As such, class-wrapper popularity was classified as not popular.
We found that class-wrapper 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.