How to extend q.promise in node.js?

I need to extent q.promise with my own functions, I tried:

defer = q.defer();
defer.promise.prototype.funcName = function () {
    // my function
}

witch returns following error:

TypeError: Cannot set property 'funcName' of undefined

How should I properly extend q.promise?


This is my actual problem: I need an alias for .then() witch gets name of an operation as argument (instead of a function), and executes that operation according to a internal library of functions.

Leave a Reply

Your email address will not be published. Required fields are marked *