proto-star

Proxy-based Self-and-Slate-inspired slow-as-fuck multiple-delegation for ECMAScript6-aka-JavaScript

Proto*

Proxy-based Self-and-Slate-inspired slow-as-fuck multiple-delegation for ECMAScript6-aka-JavaScript

var Proto = require('proto-star')
 
var Healthy = Proto.cloneWith({
  movefunction(direction) {
    this.x += direction * 2;
  }
})
 
var Hurt = Proto.cloneWith({
  movefunction(direction) {
    this.x += direction
  }
})
 
var Shark = Proto.cloneWith({
  leftfunction() {
    this.move(-1)
    return this
  }
, rightfunction(){
    this.move(1)
    return this
  }
})
 
var bob = Shark.cloneWith({ x: 10 })
bob.addDelegation(Healthy)
bob.left() // { x: 8 } 
bob.addDelegation(Hurt)
bob.left() // { x: 7 } 
bob.removeDelegation(Hurt)
bob.left() // { x: 5 } 
$ npm install proto-star

You'll need Node 0.11+ and run stuff with the --harmony flag.

Copyright (c) 2013 Quildreen Motta.

Released under the MIT licence.