The gist is

```js
  if (checkForAMDFirst) {
    // amd define stuff
  }
  else if (freeExports && freeModule) {
    if (moduleExports) {
      // the reason you bolt `myFunc` onto `myFunc` is for consistent use in environments
     // without `module.exports`
      (freeModule.exports = myFunc).myFunc = ,myFunc;
    }
    else {
      freeExports.myFunc =myFunc;
    }
  }
  else {
    // in a browser or Rhino
    root.myFunc = myFunc;
  }
```