Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Circular dependencies in CJS
"use strict";
module.exports = function (module, oddModule) {
module.exports = function even (n) {
return n == 0 || oddModule.exports(n - 1);
};
};
"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;
"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
You can’t perform that action at this time.