remove rethrows and seemingly uneeded configure

pull/1189/head
Ryan Tharp 5 years ago
parent 3d7b36aa57
commit f6525862d4

@ -1,12 +1,7 @@
/* global clearTimeout */
/* global clearTimeout, log */
// was timeoutDelay
const sleepFor = ms => new Promise(resolve => setTimeout(resolve, ms));
let log;
function configure(options = {}) {
({ log } = options);
}
// Taken from https://stackoverflow.com/questions/51160260/clean-way-to-wait-for-first-true-returned-by-promise
// The promise returned by this function will resolve true when the first promise
// in ps resolves true *or* it will resolve false when all of ps resolve false
@ -73,17 +68,7 @@ async function allowOnlyOneAtATime(name, process, timeout) {
}
let outerRetval;
// handle any timeouts
try {
outerRetval = await snodeGlobalLocks[name];
} catch (e) {
// we will throw for each time allowOnlyOneAtATime has been called in parallel
log.error(
'loki_primitives:::allowOnlyOneAtATime - error',
e.code,
e.message
);
throw e;
}
outerRetval = await snodeGlobalLocks[name];
return outerRetval;
}
@ -110,15 +95,8 @@ function abortableIterator(array, iterator) {
let item = destructableList.pop();
while (item && !abortIteration) {
if (serially) {
try {
// eslint-disable-next-line no-await-in-loop
accum.push(await iterator(item));
} catch (e) {
log.error(
`loki_primitives:::abortableIterator - error ${e.code} ${e.message}`
);
throw e;
}
// eslint-disable-next-line no-await-in-loop
accum.push(await iterator(item));
} else {
accum.push(iterator(item));
}
@ -127,18 +105,12 @@ function abortableIterator(array, iterator) {
return accum;
},
stop: () => {
/*
log.debug('loki_primitives:::abortableIterator - Stopping',
destructableList.length, '+', accum.length, '=', array.length,
'aborted?', abortIteration);
*/
controlResolveFunctor();
},
};
}
module.exports = {
configure,
sleepFor,
allowOnlyOneAtATime,
abortableIterator,

Loading…
Cancel
Save