![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
extend-me
Advanced tools
Readme
Yet another Backbone-like class extender
Node.js / Browserify:
var Base = require('extend-me').Base;
Browsers:
_The client can download directly from the GitHub CDN with one or the other of the following <script>
tags:
<script src="http://joneit.github.io/extend-me/extend-me.js"></script>
<script src="http://joneit.github.io/extend-me/extend-me.min.js"></script>
Usage:
var MyClass = Base.extend({
initialize: function () { ... },
member1: ...,
member2: ...
};
var MyChildClass = MyClass.extend({
preInitialize: function () { ... }, // called before base class's initialize() */
initialize: function () { ... }, // called after base class's initialize() and before derived class's initialize() */
postInitialize: function () { ... }, // called after this class's initialize() */
member1: ..., // overrides base class's definition of member1
member3: ...
};
var a = new MyClass(), b = new MyChildClass();
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 = this.super.calculate.apply(this, arguments);
return y + this.c;
}
});
var parabola = new ParabolaWithIntercept(3, 2, 1),
y = parabola.calculate(-3); // yields 22
You may optionally supply an initialize
method to be called as your constructor.
It will be called on object instantiation with the same parameters as passed to the actual constructor.
There may be initialize
methods at each level of inheritance.
Instantiating a derived class will automatically call initialize
on all ancestor
classes that implement it, starting with the most distant ancestor all the way up to
and including the derived class in question. Each initialize
method is called
with the same parameters as passed to the constructor.
In the example above, on instantiation (var paraboloa = new ParabolaWithIntercept(3, 2, 1)
),
Parabola.prototype.initialize
is called first; then ParabolaWithIntercept.prototype.initialize
.
To add initialization code to be executed before and/or after this chain of initialize
calls, you an define methods preInitialize
and/or postInitialize
, respectively. These are not
part of the initialization chain. They are only called on the object being instantiated;
they are not called when a derived class is being instantiated.
For example, in the sample usage above, if MyClass
had had a preInitialize
method,
it would be called on a
's intantiation but not b
's.
You can reference the immediate ancestor in the prototype chain with the super
(a getter on Base
's prototype), as shown in the example above.
Detailed API docs can be found here.
A demo can be found here.
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.