npm.io
1.0.2 • Published 9 years ago

binderify

Licence
MIT
Version
1.0.2
Deps
0
Vulns
0
Weekly
0

Works with classes and simple objects

class Node {
    constructor(data) {
        binderify(this);

        this.data = data;
    }

    report() {
        return this.data;
    }
}

const node = new Node(128);
const method = node.report;
assert.equal(method(), 128);
const obj = {
    val: 64,
    ret: function() {
        return this.val;
    },
};

binderify(obj);

const method = obj.ret;
assert.equal(method(), 64);