diff options
| author | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
|---|---|---|
| committer | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
| commit | 7a52ddeba2a68388b544f529d2d92104420f77b0 (patch) | |
| tree | 15ddd47457a2cb4a96060747437d36474e4f6b4e /node_modules/a-sync-waterfall/test.js | |
| parent | 53d6ae2b5568437afa5e4995580a3fb679b7b91b (diff) | |
Changed from static to 11ty!
Diffstat (limited to 'node_modules/a-sync-waterfall/test.js')
| -rw-r--r-- | node_modules/a-sync-waterfall/test.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/node_modules/a-sync-waterfall/test.js b/node_modules/a-sync-waterfall/test.js new file mode 100644 index 0000000..ebb5883 --- /dev/null +++ b/node_modules/a-sync-waterfall/test.js @@ -0,0 +1,77 @@ +"use strict"; +const waterfall = require('./index'); + +var generateSyncTask = function(index) { + return function (x){ + return function(cb){ + console.log(x); + cb(null); + }; + }(index); +}; + + +var generateAsyncTask = function(index) { + return function (x){ + return function(cb){ + setTimeout(function(){ + console.log(x); + cb(null); + }, 0); + }; + }(index); +}; + +var generateSyncTasks = function(count){ + var tasks = []; + for(var i=0; i<count; i++) { + tasks.push(generateSyncTask(i)); + } + return tasks; +} + +var generateAsyncTasks = function(count){ + var tasks = []; + for(var i=0; i<count; i++) { + tasks.push(generateAsyncTask(i)); + } + return tasks; +} + + +var generateRandomTasks = function(count){ + var tasks = []; + for(var i=0; i<count; i++) { + Math.random() > .5 ? tasks.push(generateAsyncTask(i)) : tasks.push(generateSyncTask(i)) + } + return tasks; +} + +var done = function(){ + console.log('done'); +} + +var testSync = function(){ + waterfall(generateSyncTasks(10), done); + console.log('this text should be after waterfall'); + +}; + +var testAsync = function(){ + waterfall(generateAsyncTasks(5), done); + console.log('this text should be before waterfall'); +}; + +var testMixed = function(){ + waterfall(generateRandomTasks(20), done); +}; + + +console.log('testSync:'); +testSync(); + +// console.log('\ntestAsync: '); +// testAsync(); + +console.log('\ntestMixed: '); +testMixed();
\ No newline at end of file |
