Skip to content

Commit

Permalink
Removes unecessary process.nextTick
Browse files Browse the repository at this point in the history
  • Loading branch information
willfrew committed Mar 23, 2015
1 parent 995c12f commit 6772da2
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,25 @@ var create = function(options, prefetch) {
// stream into the resource queue.
var fetchResource = function(key, callback) {
var messages = createMessages(request, query[key]);
process.nextTick(function() {
prefetch(request, messages.request, function(prevent) {
if (prevent) return callback();

var resource = fetch(messages.request, messages.response);
var task = {
resource: resource,
request: messages.request,
response: messages.response,
key: key
};

app(messages.request, messages.response, function() {
resourceQueue.kill();
json.destroy();
});

// Callback is called once the stream for this resource has
// been fully piped out to the client.
resourceQueue.push(task, callback);
prefetch(request, messages.request, function(prevent) {
if (prevent) return callback();

var resource = fetch(messages.request, messages.response);
var task = {
resource: resource,
request: messages.request,
response: messages.response,
key: key
};

app(messages.request, messages.response, function() {
resourceQueue.kill();
json.destroy();
});

// Callback is called once the stream for this resource has
// been fully piped out to the client.
resourceQueue.push(task, callback);
});
};

Expand Down

0 comments on commit 6772da2

Please sign in to comment.