Allows to create constructor functions ("classes") that returns callable instances
Allows to create constructor functions ("classes") that returns callable instances.
npm install callable-klass.
callable = require 'callable-klass'Foo = callable: -> 1: -> 2: -> @a + @b# the `callable` function returns a new constructor that delegates to the original one# and adds some magic. Foo still works as expected - its `prototype` is set to the original# prototype, and the function's properties are still accessible.foo =# `foo` also works as expected, `foo.a()` and `foo.b()` works, but you can also call# `foo()` directly, which delegates to the `callable` methodfoo # same as foo.callable(), returns 3