Combining promises and chaining
问题 Is there a good design pattern for utilizing promises, while still supporting chaining? For example, let's say that we have something like: function Foobar() { this.foo = function() { console.log('foo'); return this; }; this.bar = function () { console.log('bar'); return this; }; } var foobar = new Foobar(); foobar.foo().bar(); If instead we change the methods to use promises, e.g. function Foobar() { this.foo = function() { var self = this; return new Promise(function (resolve, reject) {