Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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();
```