Guest User

Untitled

a guest
Jan 3rd, 2013
1,253
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var http = require('http');
  2. var fs = require('fs');
  3. var async = require('async');
  4.  
  5. //downloadModule("functionChecker.js");
  6. async.series({
  7. functionChecker: function(callback){
  8. downloadModule('javascript-modules.googlecode.com/svn/functionChecker.js', callback); //this gets
  9. },
  10. //stuff: function(callback){
  11. //downloadModule("stuff.js", callback); //this gets
  12. //}
  13. },
  14. function(err, results){
  15. results.functionChecker.checkAllFunctions(__filename);
  16. });
  17.  
  18. function getHostName(theString){
  19. return theString.substring(0, theString.indexOf("/"));
  20. }
  21.  
  22. function getPath(theString){
  23. return theString.substring(getHostName(theString).length, theString.length);
  24. }
  25.  
  26. function getFileName(theString){
  27. return theString.substring(theString.lastIndexOf("/"), theString.length);
  28. }
  29.  
  30. function downloadModule(filename, callback) {
  31. http.get({
  32. hostname: getHostName(filename),
  33. path: getPath(filename)
  34. }, function(res){
  35. var out = fs.createWriteStream(__dirname + "/downloadedModules/" + getFileName(filename));
  36. out.on('close', function(){
  37. //this is where you use the module that was downloaded
  38. var returnThis = require(__dirname + "/downloadedModules/" + getFileName(filename));
  39. callback(null, returnThis); //"return" returnThis so that it can be used in the final callback of async.series
  40. });
  41. res.pipe(out);
  42. });
  43. }
  44.  
  45. //function name: blahblah
  46. //requires functions: false
  47. //is defined: false
  48. //description: blah
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×