API/api.medcify.app/node_modules/culvert/consume.js

16 lines
329 B
JavaScript
Raw Normal View History

2022-09-26 06:11:44 +00:00
"use strict";
module.exports = consume;
function consume(channel, emit) {
return function (callback) {
channel.take(onItem);
function onItem(err, item) {
if (item === undefined) return callback(err);
try { emit(item); }
catch (err) { return callback(err); }
channel.take(onItem);
}
};
}