Created
July 2, 2014 07:00
-
-
Save jussi-kalliokoski/50cc79951a59945c17a2 to your computer and use it in GitHub Desktop.
Circular dependencies in CJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = function (module, oddModule) { | |
module.exports = function even (n) { | |
return n == 0 || oddModule.exports(n - 1); | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var oddModule = {}; | |
var evenModule = {}; | |
require("./odd.js")(oddModule, evenModule); | |
require("./even.js")(evenModule, oddModule); | |
module.exports.odd = oddModule.exports; | |
module.exports.even = evenModule.exports; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = function (module, evenModule) { | |
module.exports = function odd (n) { | |
return n != 0 && evenModule.exports(n - 1); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment