mardi 28 mars 2017

Is there a name for a dependency graph that imitates a filesystem?

I find myself doing this when I write really big libraries in a dynamically-typed language and want to aggregate exported features near the root of the project. Doesn't have to be Node/JS, but here is an example filesystem for a Node project...

src/
    index.js -- imports A/index.js and B/index.js
    A/
        index.js -- imports X/index.js
        X/
            index.js -- imports foo.js and bar.js
            foo.js
            bar.js
        Y/
            index.js -- imports snafu.js and whatever.js
            snafu.js
            whatever.js
    B/
        index.js -- imports alpha.js and omega.js
        alpha.js
        omega.js

..where the exported library would imitate the filesystem:

const {
    A: {
        X: {
            foo,
            bar
        },
        Y: {
            snafu,
            whatever
        }
    },
    B: {
        alpha,
        omega
    }
} = require('lib');

Is there a name for this pattern?

Aucun commentaire:

Enregistrer un commentaire