A standardized 'then' Symbol.
then is a module who's sole purpose is to provide a standardized way to reliably indicate something is thenable, even between separate libraries. It does this using a ES6
This is a forward-looking problem. That is: it will be awhile until ES6 Symbols are reliably available across different JS engines. Until that time, this library will is focused on environments with a centralized module system, like node.js.
ES6 introduces the concept of "Well Known Symbols". These are Symbols that are provided by the JS engine that are universal. The primary example for this is the @@iterator Symbol. An object which is iterable need only define a property using @@iterator as its key and then everyone knows how to get an iterator from that object (
As long as everyone uses the same universal then Symbol then we have an agreed upon way to designate something as a thenable.
Example of marking Q promises as thenable.
var then = require'symbol-then'symbol;var isThenable = require'symbol-then'isThenable;QmakePromiseprototypethen = QmakePromiseprototypethen;Q'hello world'thenconsole.logvalue; // 'hello world';console.logisThenableQ; // true