Permalink
Browse files

first commit

  • Loading branch information...
bu committed Feb 6, 2013
0 parents commit 2e86fcae53652901d8d745c5080eb142a78c8efe
Showing with 69 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +7 −0 async.waterfall.js
  3. +17 −0 callback.js
  4. +37 −0 q.promise.js
  5. +7 −0 test
  6. 0 test_module.js
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,7 @@
+var async = require("async");
+
+async.waterfall([
+
+], function (err, result) {
+ // result now equals 'done'
+});
@@ -0,0 +1,17 @@
+
+loadLanguage(function(err, lang) {
+ if(err) {
+ console.log(err);
+ }
+
+ loadLanguage(function(err, lang) {
+ if(err) {
+ console.log(err);
+ }
+
+ loadLanguage(function(err, lang) {
+ if(err) {
+ console.log(err);
+ }
+
+});
@@ -0,0 +1,37 @@
+var q = require("q");
+var fs = require("fs");
+
+q.fcall(cleanupRoom)
+ .then(buySomthing)
+ .then(payTheBill, function(err) {
+ console.log(err);
+ })
+ .then(function() {
+ console.log("Yeah!");
+ });
+
+function cleanupRoom() {
+ console.log("1");
+ return true;
+}
+
+function buySomthing(cleanup_Result) {
+ console.log(cleanup_Result);
+
+ var deferred = q.defer();
+
+ fs.writeFile("bu.txt", "bu", function(err) {
+ if(err) {
+ return deferred.reject(err);
+ }
+ console.log("2");
+ deferred.resolve(true);
+ });
+
+ return deferred.promise;
+}
+
+function payTheBill() {
+ console.log("3");
+ return true;
+}
7 test
@@ -0,0 +1,7 @@
+// this file will assert something
+// we use this file as unit testing
+
+module.exports = function() {
+
+
+};
No changes.

0 comments on commit 2e86fca

Please sign in to comment.