Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanwimmer128/classify128
Write JavaScript classes easily https://www.npmjs.com/package/classify128
https://github.com/stefanwimmer128/classify128
Last synced: 2 days ago
JSON representation
Write JavaScript classes easily https://www.npmjs.com/package/classify128
- Host: GitHub
- URL: https://github.com/stefanwimmer128/classify128
- Owner: stefanwimmer128
- License: isc
- Created: 2016-07-04T15:51:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-05T14:10:47.000Z (over 8 years ago)
- Last Synced: 2024-12-31T12:09:07.061Z (7 days ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Classify
Write JavaScript classes easily
## How to use Classify
### Use with Node.js / RequireJS
``` bash
npm i -S classify128
`````` javascript
const Classify = require("classify128");const Logger = Classify({
prototype: {
log: function ()
{
console.log.apply(console, arguments);
}
}
});const HasName = Classify({
constructor: function (_super, name)
{
_super();
this.name = name;
},
extends: Logger,
prototype: {
logName: function ()
{
this.log(this.name);
}
}
});const Me = Classify({
constructor: function (_super)
{
_super("Stefan Wimmer");
},
extends: HasName,
prototype: {
logTwice: function ()
{
this.logName();
this.logName();
}
},
static: {
instance: function ()
{
return new Me();
}
}
});Me.instance().logTwice();
```### Use in browser
``` html
```
``` javascript
var Logger = Classify({
prototype: {
log: function ()
{
console.log.apply(console, arguments);
}
}
});var HasName = Classify({
constructor: function (_super, name)
{
_super();
this.name = name;
},
extends: Logger,
prototype: {
logName: function ()
{
this.log(this.name);
}
}
});var Me = Classify({
constructor: function (_super)
{
_super("Stefan Wimmer");
},
extends: HasName,
prototype: {
logTwice: function ()
{
this.logName();
this.logName();
}
},
static: {
instance: function ()
{
return new Me();
}
}
});Me.instance().logTwice();
```