maryrosecook/coquette — pull request #21 by eric-brechemier (2013-10-15 08:20:30+00:00)
Title: Simplify the declaration of modules compatible with both Node.js and the browser

In this pull request, I propose to simplify the declaration of modules by wrapping module declarations in within().

[within](http://github.com/eric-brechemier/within) is a JavaScript library that I have developed to share data and events between modules. Symbols set in the shared space get accessible in any module, both in Node.js and the browser.

within("coquette.maryrosecook.com", function() {
function Constructor() {
// ...
}

// export Constructor symbol to shared space
this.Constructor = Constructor;
});

The diff is a little confusing because the code got an extra level of indent once wrapped in within(), but the changes are otherwise limited.

The public API of Coquette is not affected by the change. However, the constructors (Collider, Entities, ...) are no longer accessible on `this.Coquette` (I remembered that you did not wish users to access these constructors directly).

The use of within() is currently limited to the declaration of modules. It also features a pub/sub mechanism which could be used to simplify the communication between modules at some point in the future.