This repository has been archived by the owner on Feb 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
128 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,122 +1,9 @@ | |||
# Sslac: The somewhat backwards Class functionality added to JavaScript | # Sslac is now retired! | ||
## But we have options for you :) | |||
|
|
||
"I now see my early attempts to support the classical model in JavaScript as a mistake." - Douglas Crockford | Looking for an awesome class based library? Here's some options... | ||
|
|
||
"Wow, let's do that again!" - Donkey from Shrek | * Fiber.js - https://github.com/linkedin/Fiber - the Fiber library is a great option when you're looking for performance. It's faster than Sslac, and smaller in file size. | ||
* JSFace - https://github.com/tnhu/jsface - the JSFace library is similar to Sslac in spirit, but works beyond just in browsers (also node.js friendly) and has support for polymorphic functions. If you're looking for classical OOP in JS, it's pretty hard to beat. | |||
|
|
||
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. | Thanks to everyone who's been so supportive of the library. This will remain as a reference implementation. | ||
|
|||
Sslac is MIT Licensed | |||
|
|||
What you're getting: | |||
|
|||
* Inheritance through object prototypes | |||
* Automatic namespacing for complex deployments | |||
* Support for mixing in static declarations onto instance objects | |||
* Declaration for Functions (sugar) | |||
* Runtime modification of methods | |||
|
|||
# Sslac Basics: Declaring Classes | |||
|
|||
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"); | |||
|
|||
* **.Class()** Declare a class. This is also the start of the chained methods... | |||
* **.Extends()** (optional) Extend an existing class | |||
* **.Implements()** (optional) Require this object implements a list of methods | |||
* **.Constructor()** (optional) Declare a constructor for this object | |||
* **.Method()** (optional) Add a method to the object's prototype | |||
|
|||
Static Classes: | |||
|
|||
Sslac.Static("YourStatic.Class") | |||
.Static("staticMethod", functon staticMethod(paramOne, paramTwo) { | |||
}); | |||
// ... | |||
YourStatic.Class.staticMethod("one", "two"); | |||
|
|||
* **.Static()** Declare a static object. This also starts the chained methods... | |||
* **.Static()** (optional) Adds a static method to the static object | |||
* **.Implements()** (optional) Require this object implements a list of methods | |||
|
|||
Declaring Functions: | |||
|
|||
Sslac.Function("YourFunction.In.A.Namespace", function funcName() { | |||
}); | |||
// ... | |||
YourFunction.In.A.Namespace(); | |||
|
|||
* **.Function()** Declare a function object. This does not chain. | |||
|
|||
Calling Parent Methods: | |||
|
|||
// ... | |||
.Method("subClassMethod", function subClassMethod(paramOne) { | |||
this.Parent(paramOne); | |||
}) | |||
// ... | |||
|
|||
* **this.Parent()** Call the parent method from within the subclassed method | |||
|
|||
# Sslac Advanced: Redefining Classes at Runtime | |||
|
|||
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 | |||
}); | |||
|
|||
* **.definitionOf()** Get the definition of a Sslac Namespaced Item. Restarts the chaining (see Instance/Static Classes) | |||
* **.getMethod()** Get the method of the specified name | |||
* **.getStatic()** Get the method of the specified name | |||
* **.getConstructor()** Get the constructor for the defined object | |||
|
|||
# Sslac in node.js | |||
|
|||
npm install Sslac | |||
|
|||
var Sslac = require("sslac"); | |||
|
|||
# Building Sslac on your own | |||
You'll need: | |||
|
|||
* Node: https://github.com/joyent/node/wiki/Installation | |||
* Node Package Manager: http://npmjs.org/ | |||
|
|||
You'll then run: | |||
|
|||
* git clone git@github.com:Jakobo/Sslac.git | |||
* cd Sslac | |||
* make requires | |||
* make | |||
|
|||
Or if you've got NPM and just want it: | |||
|
|||
* npm install Sslac | |||
|
|||
# Directory Guide | |||
|
|||
* **artifacts/** (built using make) contains minified versions of the code all shiny and compiled | |||
* **config/** contains configs used in building such as the smoosh manifest | |||
* **src/** contains the Sslac source | |||
* **tests/** contains the Sslac source | |||
|
|||
# Additional Licenses | |||
Sections of this code may include licenses that go beyond the MIT license. Those licenses may be found in the src/licenses directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,122 @@ | |||
# Sslac: The somewhat backwards Class functionality added to JavaScript | |||
|
|||
"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: | |||
|
|||
* Inheritance through object prototypes | |||
* Automatic namespacing for complex deployments | |||
* Support for mixing in static declarations onto instance objects | |||
* Declaration for Functions (sugar) | |||
* Runtime modification of methods | |||
|
|||
# Sslac Basics: Declaring Classes | |||
|
|||
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"); | |||
|
|||
* **.Class()** Declare a class. This is also the start of the chained methods... | |||
* **.Extends()** (optional) Extend an existing class | |||
* **.Implements()** (optional) Require this object implements a list of methods | |||
* **.Constructor()** (optional) Declare a constructor for this object | |||
* **.Method()** (optional) Add a method to the object's prototype | |||
|
|||
Static Classes: | |||
|
|||
Sslac.Static("YourStatic.Class") | |||
.Static("staticMethod", functon staticMethod(paramOne, paramTwo) { | |||
}); | |||
// ... | |||
YourStatic.Class.staticMethod("one", "two"); | |||
|
|||
* **.Static()** Declare a static object. This also starts the chained methods... | |||
* **.Static()** (optional) Adds a static method to the static object | |||
* **.Implements()** (optional) Require this object implements a list of methods | |||
|
|||
Declaring Functions: | |||
|
|||
Sslac.Function("YourFunction.In.A.Namespace", function funcName() { | |||
}); | |||
// ... | |||
YourFunction.In.A.Namespace(); | |||
|
|||
* **.Function()** Declare a function object. This does not chain. | |||
|
|||
Calling Parent Methods: | |||
|
|||
// ... | |||
.Method("subClassMethod", function subClassMethod(paramOne) { | |||
this.Parent(paramOne); | |||
}) | |||
// ... | |||
|
|||
* **this.Parent()** Call the parent method from within the subclassed method | |||
|
|||
# Sslac Advanced: Redefining Classes at Runtime | |||
|
|||
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 | |||
}); | |||
|
|||
* **.definitionOf()** Get the definition of a Sslac Namespaced Item. Restarts the chaining (see Instance/Static Classes) | |||
* **.getMethod()** Get the method of the specified name | |||
* **.getStatic()** Get the method of the specified name | |||
* **.getConstructor()** Get the constructor for the defined object | |||
|
|||
# Sslac in node.js | |||
|
|||
npm install Sslac | |||
|
|||
var Sslac = require("sslac"); | |||
|
|||
# Building Sslac on your own | |||
You'll need: | |||
|
|||
* Node: https://github.com/joyent/node/wiki/Installation | |||
* Node Package Manager: http://npmjs.org/ | |||
|
|||
You'll then run: | |||
|
|||
* git clone git@github.com:Jakobo/Sslac.git | |||
* cd Sslac | |||
* make requires | |||
* make | |||
|
|||
Or if you've got NPM and just want it: | |||
|
|||
* npm install Sslac | |||
|
|||
# Directory Guide | |||
|
|||
* **artifacts/** (built using make) contains minified versions of the code all shiny and compiled | |||
* **config/** contains configs used in building such as the smoosh manifest | |||
* **src/** contains the Sslac source | |||
* **tests/** contains the Sslac source | |||
|
|||
# Additional Licenses | |||
Sections of this code may include licenses that go beyond the MIT license. Those licenses may be found in the src/licenses directory. |