wishthis/node_modules/async-settle/index.js
2022-01-21 09:28:41 +01:00

21 lines
375 B
JavaScript

'use strict';
var asyncDone = require('async-done');
function settle(fn, done) {
asyncDone(fn, function(error, result) {
var settled = {};
if (error != null) {
settled.state = 'error';
settled.value = error;
} else {
settled.state = 'success';
settled.value = result;
}
done(null, settled);
});
}
module.exports = settle;