Created
February 1, 2012 16:16
-
-
Save nakamura-to/1717789 to your computer and use it in GitHub Desktop.
nue v0.0.2 sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nue = require('nue'); | |
var serial = nue.serial; | |
var serialEach = nue.serialEach; | |
var parallel = nue.parallel; | |
var parallelEach = nue.parallelEach; | |
var start = nue.start; | |
start(serial( | |
function () { console.log('a'); this.next(); }, | |
function () { console.log('b'); this.next(); }, | |
function () { console.log('c'); this.next(); }, | |
parallel( | |
function () { this.fork('f', 'e', 'd'); }, | |
[ | |
function (arg) { var self = this; setTimeout(function() { console.log(arg); self.join();}, 30); }, | |
function (arg) { var self = this; setTimeout(function() { console.log(arg); self.join();}, 20); }, | |
function (arg) { var self = this; setTimeout(function() { console.log(arg); self.join();}, 10); } | |
], | |
function () { console.log('g'); this.next(); } | |
), | |
function () { console.log('h'); this.next()}, | |
parallelEach( | |
function () { this.begin('i', 'j', 'k'); }, | |
function (arg) { console.log(arg); this.join(); }, | |
function () { console.log('l'); this.next(); } | |
), | |
serialEach( | |
function () { this.begin('m', 'n', 'o'); }, | |
function (arg) { console.log(arg); this.next(); }, | |
function () { console.log('p'); this.next(); } | |
), | |
function () { console.log('q');} | |
)); | |
/* RESULT | |
a | |
b | |
c | |
d | |
e | |
f | |
g | |
h | |
i | |
j | |
k | |
l | |
m | |
n | |
o | |
p | |
q | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment