Tech Tuesday: jQuery DOM performance
imgur.com2 pointsby fruchtose0 comments
Q.fcall(someFunction).then(function(result) {
return functionThatReturnsAPromise();
}).then(function(secondResult) {
console.log(secondResult);
}).done();
Also, in a proper redesign, Q's denodeify function can change the whole flow of the execute function entirely: DbCommand.prototype.execute = function(query, onComplete) {
var self = this;
Q.denodeify(dbConnectionPool.acquire).then(function(connection) {
self.connection = connection;
return Q.denodeify(connection.query);
}).then(function(rows) {
return onComplete(rows);
}).finally(function() {
self.connection && dbConnectionPool.release(self.connection);
}).done();
};
Q's denodeify call works with Node.js callbacks which follow the convention that the error is the first argument, and the result all others. denodeify then converts the error into an argument for any calls to Q.fail. Any uncaught errors will be thrown after done() is called.
[0] https://www.nytimes.com/2023/01/23/technology/tech-interest-...