Instantly share code, notes, and snippets.

What would you like to do?
Code that manages queues for River5, for review. See the blog post linked to in the first comment. (Revision to earlier gist.)
function readRiverFile (relpath, afterReadCallback, callback) {
var f = config.dataFolder + relpath;
if (riverQueues [f] === undefined) {
riverQueues [f] = [callback];
fs.readFile (f, function (err, jsontext) {
var jstruct = undefined;
if (!err) {
try {
jstruct = JSON.parse (jsontext);
catch (err) {
jstruct = afterReadCallback (jstruct);
var theQueue = riverQueues [f];
delete riverQueues [f];
for (var i = 0; i < theQueue.length; i++) {
theQueue [i] (jstruct);
else {
riverQueues [f].push (callback);

This comment has been minimized.

Copy link

scripting commented Jan 14, 2018

Here's the blog post that explains --


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment