more thenify in node/utils/*

This commit is contained in:
Ray Bellis 2019-01-22 17:30:33 +00:00
parent 584e481430
commit 5ef4a2d1d5
5 changed files with 26 additions and 21 deletions

View file

@ -1,6 +1,7 @@
var Changeset = require("../../static/js/Changeset");
var async = require("async");
var exportHtml = require('./ExportHtml');
const thenify = require("thenify").withCallback;
function PadDiff (pad, fromRev, toRev) {
// check parameters
@ -78,7 +79,7 @@ PadDiff.prototype._isClearAuthorship = function(changeset) {
return true;
};
PadDiff.prototype._createClearAuthorship = function(rev, callback) {
PadDiff.prototype._createClearAuthorship = thenify(function(rev, callback) {
var self = this;
this._pad.getInternalRevisionAText(rev, function(err, atext) {
if (err) {
@ -92,9 +93,9 @@ PadDiff.prototype._createClearAuthorship = function(rev, callback) {
callback(null, changeset);
});
};
});
PadDiff.prototype._createClearStartAtext = function(rev, callback) {
PadDiff.prototype._createClearStartAtext = thenify(function(rev, callback) {
var self = this;
// get the atext of this revision
@ -119,9 +120,9 @@ PadDiff.prototype._createClearStartAtext = function(rev, callback) {
callback(null, newAText);
});
});
};
});
PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
PadDiff.prototype._getChangesetsInBulk = thenify(function(startRev, count, callback) {
var self = this;
// find out which revisions we need
@ -150,7 +151,7 @@ PadDiff.prototype._getChangesetsInBulk = function(startRev, count, callback) {
function(err) {
callback(err, changesets, authors);
});
};
});
PadDiff.prototype._addAuthors = function(authors) {
var self = this;
@ -163,7 +164,7 @@ PadDiff.prototype._addAuthors = function(authors) {
});
};
PadDiff.prototype._createDiffAtext = function(callback) {
PadDiff.prototype._createDiffAtext = thenify(function(callback) {
var self = this;
var bulkSize = 100;
@ -237,9 +238,9 @@ PadDiff.prototype._createDiffAtext = function(callback) {
}
);
});
};
});
PadDiff.prototype.getHtml = function(callback) {
PadDiff.prototype.getHtml = thenify(function(callback) {
// cache the html
if (this._html != null) {
return callback(null, this._html);
@ -283,9 +284,9 @@ PadDiff.prototype.getHtml = function(callback) {
function(err) {
callback(err, html);
});
};
});
PadDiff.prototype.getAuthors = function(callback) {
PadDiff.prototype.getAuthors = thenify(function(callback) {
var self = this;
// check if html was already produced, if not produce it, this generates the author array at the same time
@ -300,7 +301,7 @@ PadDiff.prototype.getAuthors = function(callback) {
} else {
callback(null, self._authors);
}
};
});
PadDiff.prototype._extendChangesetWithAuthor = function(changeset, author, apool) {
// unpack