Subdomain Posts
None | 11 days ago
None | 11 days ago
None | 11 days ago
None | 11 days ago
JavaScript | 22 days ago
JavaScript | 26 days ago
JavaScript | 26 days ago
JavaScript | 26 days ago
None | 26 days ago
None | 34 days ago
Recent Posts
C | 33 sec ago
None | 1 min ago
None | 2 min ago
PHP | 4 min ago
None | 5 min ago
PHP | 5 min ago
None | 5 min ago
None | 6 min ago
XML | 7 min ago
None | 7 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By hns on the 8th of Dec 2009 06:01:58 PM Download | Raw | Embed | Report
  1.  
  2. exports.app = function myAsyncApp(request){
  3.   return function(responder){
  4.     responder.init(200, {});
  5.     var i = 0;
  6.     var intervalId = setInterval(function(){
  7.       responder.write("Every second another message");
  8.       if(i++ == 10){
  9.         responder.close();
  10.         clearInterval(intervalId);
  11.       }
  12.     }, 1000);
  13.   };
  14. }
  15.  
  16. function middleware(app) {
  17.   return function(request) {
  18.     var response = app(request);
  19.     if (typeof response === "function") {
  20.       return function(responder) {
  21.         // createResponderProxy is a utility function
  22.         var proxy = createResponderProxy(responder);
  23.         proxy.[init|write|close] = ...;
  24.         response.then(proxy)
  25.       };
  26.     } else {
  27.       // sync
  28.     }
  29.   }
  30. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: