X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FdynamicExample.js;fp=examples%2FdynamicExample.js;h=4003c53462878652804fb8a051feeb792553c051;hb=583a27ce13d67cc33ded52f46fe1665c64a8fec7;hp=22b4f19c4b7394c92b1b91b7d8ffad432e810e4c;hpb=f87ff2d2996929c8fa315c97a3a9b314c5341412;p=poolifier.git diff --git a/examples/dynamicExample.js b/examples/dynamicExample.js index 22b4f19c..4003c534 100644 --- a/examples/dynamicExample.js +++ b/examples/dynamicExample.js @@ -10,11 +10,15 @@ pool.emitter.on('FullPool', () => maxReached++) const start = Date.now() const iterations = 1000 for (let i = 0; i <= iterations; i++) { - pool.execute({}).then(res => { - resolved++ - if (resolved === iterations) { - console.log('Time take is ' + (Date.now() - start)) - console.log('The pool was full for ' + maxReached + ' times') - } - }) + pool + .execute({}) + .then(res => { + resolved++ + if (resolved === iterations) { + console.log('Time take is ' + (Date.now() - start)) + return console.log('The pool was full for ' + maxReached + ' times') + } + return null + }) + .catch(err => console.error(err)) }