MikkoH/jsOOP — pull request #7 by mattdesl (2013-09-30 04:59:32+00:00)
Title: Rework for NPM & browserify -- rough draft

I updated everything to use NPM and added a grunt file (build, test, uglify, yuidoc). I've also updated the tests to use nodeunit, since grunt-contrib-qunit was breaking due to `Function.prototype.bind`.

The index exports `Class`, `Interface` and `Enum`.

This pull request allows the user to choose between two options:

1. NodeJS approach. Example:
```javascript
var Class = require('jsOOP').Class;
var Interface = require('jsOOP').Interface;
```

2. UMD approach. If you are using RequireJS or another pattern, or no module pattern, you can use the browserified bundle at `dist/jsOOP.js`. If no module pattern is detected, the exports are placed on the window/global namespace `jsOOP`.
```javascript
//RequireJS example:
define(function(require) {
var Class = require('mylibs/jsOOP').Class;

return new Class({
...
});
});

//or, with no module pattern:
var MyClass = new jsOOP.Class({
...
});
```

A possible third option would be a separate browserify build that places the exports on the window/global object. This would only be useful for non-module users who want to avoid prefixing with the `jsOOP` namespace.

Also, it would be ideal if you could just `require('jsOOP/Class')`, but this is easier said than done with NodeJS.
http://blog.izs.me/post/44149270867/why-no-directories-lib-in-node-the-less-snarky

`require('jsOOP/lib/Class')` is another way -- this kind of stuff is common with internal code but most node modules don't force it upon the end-user.