Skip to content

Instantly share code, notes, and snippets.

@danigb
Last active September 24, 2018 14:53
Show Gist options
  • Save danigb/9a61f3bea652aea1a12d2414ba4da9e7 to your computer and use it in GitHub Desktop.
Save danigb/9a61f3bea652aea1a12d2414ba4da9e7 to your computer and use it in GitHub Desktop.
Cyclic dependencies

Run: node a.js

Result:

A from C {}
C from B This is C
B from A This is B
const b = require("./b");
console.log("B from A", b);
module.exports = "This is A";
const c = require("./c");
console.log("C from B", c);
module.exports = "This is B";
const a = require("./a");
console.log("A from C", a);
module.exports = "This is C";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment