Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 1st, 2013  |  syntax: None  |  size: 0.67 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // run.js
  2. var requirejs = require('requirejs');
  3.  
  4. requirejs.config({
  5.   baseUrl: __dirname,
  6.   nodeRequire: require
  7. });
  8.  
  9. requirejs(['A'], function(A) {
  10.   var a = new A.Go();
  11.   console.log(a.toon())
  12. });
  13.  
  14.  
  15. // A.js
  16. define(['B', 'exports'], function(B, exports) {
  17.  
  18.   exports.Go = function() {
  19.     var b = new require('B').Ho();
  20.     var toon = function() {
  21.       return 'me tarzan';
  22.     };
  23.  
  24.     return {
  25.       b: b,
  26.       toon: toon
  27.     }
  28.   };
  29. });
  30.  
  31.  
  32. // B.js
  33. define(['A', 'exports'], function(A, exports) {
  34.  
  35.   exports.Ho = function() {
  36.     var a = new require('A').Go();
  37.     var show = function() {
  38.       return 'you jane';
  39.     }
  40.  
  41.     return {
  42.       a: a,
  43.       show: show
  44.     }
  45.   };
  46. });
clone this paste RAW Paste Data