
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Yet another Backbone-like class extender
var Base = require('extend-me').Base;
var Parabola = Base.extend({
initialize: function (a, b) {
this.a = a;
this.b = b;
},
calculate: function(x) {
return this.a * Math.pow(x, 2) + (this.b * x);
}
});
var ParabolaWithIntercept = Parabola.extend({
initialize: function(a, b, c) {
this.c = c;
},
calculate: function(x) {
var y = Parabola.prototype.calculate.apply(this, arguments);
return y + this.c;
}
});
var parabola = new ParabolaWithIntercept(3, 2, 1),
y = ParabolaWithIntercept(-3); // yields 22
The initialize
methods at each level of inheritance are the constructors.
Instantiating a derived class will automatically call initialize
on all ancestor
classes that implement it, starting with the most distant ancestor all the way to
and including the derived class in question. Each initialize
method is called
with the same parameters passed to the constructor.
If you intend to instantiate the base class (Parabola
in the above) directly
(i.e., it is not "abstract"), include the following in the constructor:
function Parabola() {
this.initialize.apply(this, arguments);
}
To add initialization code to be executed before or after this chain of initialize
calls, you an define methods preInitialize
and postInitialize
.
Detailed API docs can be found here.
jsdoc-template
See the note Regarding submodules for important information on cloning this repo or re-purposing its build template.
FAQs
A class extender
We found that extend-me 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.