"I now see my early attempts to support the classical model in JavaScript as a mistake." - Douglas Crockford
"Wow, let's do that again!" - Donkey from Shrek
What you're holding is a slick way to do prototypical classes in JavaScript. Sslac supports the usual class related functionality, plus a few extras. A lot of the code has been inspired by the libraries that came before it, in hopes it might inspire the libraries that come after it. With boldly sidestepping the pros/cons of this kind of object model, if this is what you're looking for, here it is. It's certainly easier than monkeying with object prototypes directly.
Sslac is MIT Licensed
What you're getting:
Instance Classes:
Sslac.Class("Your.Class").Extends("Extends.Object").Implements("Implements.Object")
.Constructor(function Constructor(paramOne, paramTwo) {
})
.Method("methodName", function methodName(paramOne, paramTwo) {
});
// ...
var foo = new Your.Class("one", "two");
Static Classes:
Sslac.Static("YourStatic.Class")
.Static("staticMethod", functon staticMethod(paramOne, paramTwo) {
});
// ...
YourStatic.Class.staticMethod("one", "two");
Declaring Functions:
Sslac.Function("YourFunction.In.A.Namespace", function funcName() {
});
// ...
YourFunction.In.A.Namespace();
Calling Parent Methods:
// ...
.Method("subClassMethod", function subClassMethod(paramOne) {
this.Parent(paramOne);
})
// ...
Get an existing method from a definition:
var oldMethod = Sslac.definitionOf("Your.Namespaced.Object").getMethod("yourMethod");
Rewire:
Sslac.definitionOf("Your.Namespaced.Object")
.Method("yourMethod", function newYourMethod() {
// optionally call the old method
oldMethod.apply(this, arguments);
// do your own custom code at runtime
});
npm install Sslac
var Sslac = require("sslac");
You'll need:
You'll then run:
Or if you've got NPM and just want it:
Sections of this code may include licenses that go beyond the MIT license. Those licenses may be found in the src/licenses directory.