-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from facebook/opt-into-strict-mode
Allow the runtime to be required as a module, and make it strict-mode-compliant.
- Loading branch information
Showing
2 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This method of obtaining a reference to the global object needs to be | ||
// kept identical to the way it is obtained in runtime.js | ||
var g = | ||
typeof global === "object" ? global : | ||
typeof window === "object" ? window : this; | ||
|
||
var hasOwn = Object.prototype.hasOwnProperty; | ||
var hadRuntime = hasOwn.call(g, "regeneratorRuntime"); | ||
var oldRuntime = hadRuntime && g.regeneratorRuntime; | ||
delete g.regeneratorRuntime; // Force reevalutation of runtime.js. | ||
|
||
module.exports = require("./runtime"); | ||
|
||
if (hadRuntime) { | ||
// Restore the original runtime. | ||
g.regeneratorRuntime = oldRuntime; | ||
} else { | ||
// Remove the global property added by runtime.js. | ||
delete g.regeneratorRuntime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters