From bd65bb67e25a79b019d745b7262b2008ce2adb15 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 16 Nov 2016 01:59:39 +0100 Subject: incrementally verify denoms The denominations are not stored in a separate object store. --- node_modules/orchestrator/lib/runTask.js | 132 +++++++++++++++---------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'node_modules/orchestrator/lib') diff --git a/node_modules/orchestrator/lib/runTask.js b/node_modules/orchestrator/lib/runTask.js index 97dae22cb..41b28778b 100644 --- a/node_modules/orchestrator/lib/runTask.js +++ b/node_modules/orchestrator/lib/runTask.js @@ -1,66 +1,66 @@ -/*jshint node:true */ - -"use strict"; - -var eos = require('end-of-stream'); -var consume = require('stream-consume'); - -module.exports = function (task, done) { - var that = this, finish, cb, isDone = false, start, r; - - finish = function (err, runMethod) { - var hrDuration = process.hrtime(start); - - if (isDone && !err) { - err = new Error('task completion callback called too many times'); - } - isDone = true; - - var duration = hrDuration[0] + (hrDuration[1] / 1e9); // seconds - - done.call(that, err, { - duration: duration, // seconds - hrDuration: hrDuration, // [seconds,nanoseconds] - runMethod: runMethod - }); - }; - - cb = function (err) { - finish(err, 'callback'); - }; - - try { - start = process.hrtime(); - r = task(cb); - } catch (err) { - return finish(err, 'catch'); - } - - if (r && typeof r.then === 'function') { - // wait for promise to resolve - // FRAGILE: ASSUME: Promises/A+, see http://promises-aplus.github.io/promises-spec/ - r.then(function () { - finish(null, 'promise'); - }, function(err) { - finish(err, 'promise'); - }); - - } else if (r && typeof r.pipe === 'function') { - // wait for stream to end - - eos(r, { error: true, readable: r.readable, writable: r.writable && !r.readable }, function(err){ - finish(err, 'stream'); - }); - - // Ensure that the stream completes - consume(r); - - } else if (task.length === 0) { - // synchronous, function took in args.length parameters, and the callback was extra - finish(null, 'sync'); - - //} else { - // FRAGILE: ASSUME: callback - - } -}; +/*jshint node:true */ + +"use strict"; + +var eos = require('end-of-stream'); +var consume = require('stream-consume'); + +module.exports = function (task, done) { + var that = this, finish, cb, isDone = false, start, r; + + finish = function (err, runMethod) { + var hrDuration = process.hrtime(start); + + if (isDone && !err) { + err = new Error('task completion callback called too many times'); + } + isDone = true; + + var duration = hrDuration[0] + (hrDuration[1] / 1e9); // seconds + + done.call(that, err, { + duration: duration, // seconds + hrDuration: hrDuration, // [seconds,nanoseconds] + runMethod: runMethod + }); + }; + + cb = function (err) { + finish(err, 'callback'); + }; + + try { + start = process.hrtime(); + r = task(cb); + } catch (err) { + return finish(err, 'catch'); + } + + if (r && typeof r.then === 'function') { + // wait for promise to resolve + // FRAGILE: ASSUME: Promises/A+, see http://promises-aplus.github.io/promises-spec/ + r.then(function () { + finish(null, 'promise'); + }, function(err) { + finish(err, 'promise'); + }); + + } else if (r && typeof r.pipe === 'function') { + // wait for stream to end + + eos(r, { error: true, readable: r.readable, writable: r.writable && !r.readable }, function(err){ + finish(err, 'stream'); + }); + + // Ensure that the stream completes + consume(r); + + } else if (task.length === 0) { + // synchronous, function took in args.length parameters, and the callback was extra + finish(null, 'sync'); + + //} else { + // FRAGILE: ASSUME: callback + + } +}; -- cgit v1.2.3