Export the PEG library in simpler and more robust way

redux
David Majda 13 years ago
parent 3e7d31559d
commit 13a3621e79

@ -1,4 +1,4 @@
(function(global) { (function() {
var undefined; var undefined;
@ -35,10 +35,12 @@ PEG.GrammarError.prototype = Error.prototype;
// @include "parser.js" // @include "parser.js"
// @include "compiler.js" // @include "compiler.js"
if (typeof exports !== "undefined") { // Looks like we're in CommonJS environment. if (typeof module === "object") {
extend(exports, PEG); module.exports = PEG;
} else { // Okay, assume this is a browser/Rhino. } else if (typeof window === "object") {
global.PEG = PEG; window.PEG = PEG;
} else {
throw new Error("Can't export PEG library (no \"module\" nor \"window\" object detected).");
} }
})(this); })();

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

Loading…
Cancel
Save