proto-star
Proxy-based Self-and-Slate-inspired slow-as-fuck multiple-delegation for ECMAScript6-aka-JavaScript
Last updated 7 years ago by killdream .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install proto-star 
SYNC missed versions from official npm registry.

Proto*

Build Status Dependencies Status NPM version experimental

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

Example

var Proto = require('proto-star')

var Healthy = Proto.cloneWith({
  move: function(direction) {
    this.x += direction * 2;
  }
})

var Hurt = Proto.cloneWith({
  move: function(direction) {
    this.x += direction
  }
})

var Shark = Proto.cloneWith({
  left: function() {
    this.move(-1)
    return this
  }
, right: function(){
    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 }

Installing

$ npm install proto-star

Platform support

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

Licence

Copyright (c) 2013 Quildreen Motta.

Released under the MIT licence.

Current Tags

  • 0.1.0                                ...           latest (7 years ago)

1 Versions

  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |