npm.io
1.0.3 • Published 8 years ago

farnsworth-attach

Licence
ISC
Version
1.0.3
Deps
0
Size
3 kB
Vulns
0
Weekly
0

attach()

Syntactical sugar to make it a bit nicer to attach functions to classes

The attach method allows classes define an API with method signatures but no bodies.

Implementation methods are attached in the constructor using top level methods from the module file.

Kind: global function
Example

// example.js
let attach = require('farnsworth-attach')

// document your class...
class Foo {
    // document your method...
    bar() {}

    // document your constructor...
    constructor() {
        attach(this, bar)
    } 
}

function bar() {
   console.log('I was attached') 
}

let foo = new Foo()
foo.bar()