Hacker News new | ask | show | jobs
by quarterto 3841 days ago
If you don't mind setting the function on instances at construct time, you can use ES2016 class properties:

    class x {
      a = wrapFunction(function() {})
    }
This kind of use case is pretty well covered by ES2016 decorators as well (they're a bit more general as they act on property descriptors, not just values):

    class x {
      @functionWrapper
      a() {}
    }
1 comments

Neat, thanks! But we're working with the half-baked V8 ES6 support that is far from ES2016, unfortunately. However, it's interesting to see the support coming :-)