Permalink
Browse files

syntax tuning

  • Loading branch information...
1 parent e7db765 commit f24a71a18ac06e0650d72b9cbe147f377e6d6a4f @ben-lin ben-lin committed Jan 15, 2012
Showing with 52 additions and 61 deletions.
  1. +15 −15 Readme.md
  2. +6 −6 examples/mongoose/run.js
  3. +5 −9 examples/mongoose/setup.js
  4. +8 −10 examples/node.packer/run.js
  5. +1 −1 index.js
  6. +17 −20 lib/flow.js
View
@@ -13,14 +13,14 @@ With node.flow you can set a work flow doing things one by one or in parallel, w
// setup db schema and connection
require( './setup' );
- var Flow = require( '../../lib/flow' ),
- mongoose = require( 'mongoose' ),
- User = mongoose.model( 'User' ),
- data = require( './data' );
+ var Flow = require( '../../lib/flow' );
+ var mongoose = require( 'mongoose' );
+ var User = mongoose.model( 'User' );
+ var data = require( './data' );
// start a new flow
- var flow = new Flow,
- users = {};
+ var flow = new Flow;
+ var users = {};
// delete all users before start
flow.series( function ( next ){
@@ -120,8 +120,8 @@ Add series task to the flow stack.
#### Example code
- var Flow = require( 'node.flow' ),
- flow = new Flow();
+ var Flow = require( 'node.flow' );
+ var flow = new Flow();
// Add a task function, the last argument in the task callback
// is always the next task
@@ -158,8 +158,8 @@ Add parallel task to the flow stack.
#### Example code
- var Flow = require( 'node.flow' ),
- flow = new Flow();
+ var Flow = require( 'node.flow' );
+ var flow = new Flow();
flow.parallel( function( name, sort, ready ){
User.find({
@@ -177,8 +177,8 @@ Set an end point for a group of parallel tasks.
#### Example code
- var Flow = require( 'node.flow' ),
- flow = new Flow();
+ var Flow = require( 'node.flow' );
+ var flow = new Flow();
flow.parallel( function( name, sort, ready ){
User.find({
@@ -210,9 +210,9 @@ Call the tasks one after another in the stack.
#### Example code
- var Flow = require( 'node.flow' ),
- flow = new Flow(),
- users = {};
+ var Flow = require( 'node.flow' );
+ var flow = new Flow();
+ var users = {};
// find users with the given names
[ 'fifi', 'jenny', 'steffi' ].forEach( function ( name ){
View
@@ -1,13 +1,13 @@
// setup db schema and connection
require( './setup' );
-var Flow = require( '../../lib/flow' ),
- mongoose = require( 'mongoose' ),
- User = mongoose.model( 'User' ),
- data = require( './data' );
+var Flow = require( '../../lib/flow' );
+var mongoose = require( 'mongoose' );
+var User = mongoose.model( 'User' );
+var data = require( './data' );
-var flow = new Flow,
- users = {};
+var flow = new Flow;
+var users = {};
// delete all users before start
flow.series( function ( next ){
View
@@ -1,15 +1,11 @@
-var mongoose, Schema, ObjectId, User;
+var mongoose = require( 'mongoose' );
+var Schema = mongoose.Schema;
+var ObjectId = Schema.ObjectId;
-mongoose = require( 'mongoose' );
-Schema = mongoose.Schema;
-ObjectId = Schema.ObjectId;
-
-
-
-User = new Schema({
+var User = new Schema({
name : { type : String, required : true, index: true },
-
+
email : { type : String, required : true, index: true },
created_at : { type : Date, 'default' : Date.now }
@@ -1,8 +1,8 @@
-var fs = require( 'fs' ),
- path = require( 'path' ),
- packer = require( 'node.packer' ),
- rmdir = require( 'rmdirr' ),
- Flow = require( '../../lib/flow' );
+var fs = require( 'fs' );
+var path = require( 'path' );
+var packer = require( 'node.packer' );
+var rmdir = require( 'rmdirr' );
+var Flow = require( '../../lib/flow' );
var css = {
lib : [ 'reset', 'reset-html5' ],
@@ -14,8 +14,8 @@ var js = {
app : [ 'models', 'views', 'actions' ]
};
-var target_dir = __dirname + '/assets/',
- src_dir = __dirname + '/src/';
+var target_dir = __dirname + '/assets/';
+var src_dir = __dirname + '/src/';
var build = function ( flow, packer, assets, type, target_dir, src_dir ){
var group, input;
@@ -50,10 +50,8 @@ var flow = new Flow({
uglify : false
});
-flow.
-
// check if the dir exist, if it does remove it
-series( function ( args, next ){
+flow.series( function ( args, next ){
if( path.existsSync( target_dir )){
rmdir( target_dir, function ( err, dirs, files ){
if( err ) throw err;
View
@@ -1 +1 @@
-module.exports = require('./lib/flow');
+module.exports = require( './lib/flow' );
View
@@ -13,8 +13,8 @@
* @private
* @function
*/
-var extend = require( 'node.extend' ),
- slice = [].slice;
+var extend = require( 'node.extend' );
+var slice = [].slice;
@@ -114,10 +114,9 @@ Flow.prototype = {
* @this {Flow}
*/
_run_parallel : function (){
- var self, args;
-
- self = this;
- args = this._parallel_args.shift();
+ var self = this;
+ var args = this._parallel_args.shift();
+
this._count = args.length;
this._parallel.shift().forEach( function ( task ){
@@ -170,11 +169,9 @@ Flow.prototype = {
* @param {Function} callback Callback function for this.series or this.parallel.
*/
_add : function ( args, next_type, callback ){
- var self, task, _args;
-
- self = this;
- task = [].shift.call( args );
- _args = extend( true, [], this._defaults );
+ var self = this;
+ var task = [].shift.call( args );
+ var _args = extend( true, [], this._defaults );
extend( true, _args, slice.call( args ));
_args.push( function (){
@@ -195,8 +192,8 @@ Flow.prototype = {
* @return {this} Return `this` to enable chaining.
* @example
*
- * var Flow = require( 'node.flow' ),
- * flow = new Flow(),
+ * var Flow = require( 'node.flow' );
+ * var flow = new Flow();
*
* flow.series( function( name, sort, next ){
* User.find({
@@ -228,8 +225,8 @@ Flow.prototype = {
* @return {this} Return `this` to enable chaining.
* @example
*
- * var Flow = require( 'node.flow' ),
- * flow = new Flow();
+ * var Flow = require( 'node.flow' );
+ * var flow = new Flow();
*
* flow.parallel( function( name, sort, ready ){
* User.find({
@@ -266,8 +263,8 @@ Flow.prototype = {
* @return {this} Return `this` to enable chaining.
* @example
*
- * var Flow = require( 'node.flow' ),
- * flow = new Flow();
+ * var Flow = require( 'node.flow' );
+ * var flow = new Flow();
*
* flow.parallel( function( name, sort, ready ){
* User.find({
@@ -302,9 +299,9 @@ Flow.prototype = {
* @return {this} Return `this` to enable chaining.
* @example
*
- * var Flow = require( 'node.flow' ),
- * flow = new Flow(),
- * users = {};
+ * var Flow = require( 'node.flow' );
+ * var flow = new Flow();
+ * var users = {};
*
* // find users with the given names
* [ 'fifi', 'jenny', 'steffi' ].forEach( function ( name ){

0 comments on commit f24a71a

Please sign in to comment.