Skip to content
Browse files

Added parallel example

  • Loading branch information...
1 parent 52d6bc7 commit 764fec8ba75fa8685e2e0842dac7fe1efb140a2e @davglass davglass committed Nov 19, 2010
Showing with 26 additions and 0 deletions.
  1. +26 −0 examples/parallel.js
View
26 examples/parallel.js
@@ -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.
Something went wrong with that request. Please try again.