Skip to content

Commit

Permalink
Added parallel example
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Nov 20, 2010
1 parent 52d6bc7 commit 764fec8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/parallel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

var fs = require('fs');
var YUI = require("yui3").YUI;
require("assert").equal( global.YUI, undefined, "global yui created");


YUI({
filter: 'debug',
debug: true
}).use('parallel', function(Y) {

Y.log('Reading this directory and reading the contents of each file..');
var stack = new Y.Parallel();
fs.readdir(__dirname, stack.add(function(err, files) {
files.forEach(function(f) {
fs.readFile(__dirname + f, stack.add(function(err, data) {
//Do something here..
}));
});
}));
stack.done(function() {
Y.log('All callbacks have fired..');
});

});

0 comments on commit 764fec8

Please sign in to comment.