Behave like CommonJS module in CommonJS context

redux
David Majda 14 years ago
parent 77ec4f7162
commit 2120de36af

@ -1,4 +1,4 @@
(function(global) {
(function() {
var undefined;
@ -32,6 +32,10 @@ PEG.GrammarError.prototype = Error.prototype;
// @include "parser.js"
// @include "compiler.js"
global.PEG = PEG;
if (typeof exports !== "undefined") { // Looks like we're in CommonJS environment.
extend(exports, PEG);
} else { // Okay, assume this is a browser.
window.PEG = PEG;
}
})(this);
})();

@ -1,3 +1,9 @@
function extend(target, source) {
for (var key in source) {
target[key] = source[key];
}
}
function contains(array, value) {
/*
* Stupid IE does not have Array.prototype.indexOf, otherwise this function

Loading…
Cancel
Save