lygaret/dropbox-js — pull request #1 by lygaret (2014-08-01 07:49:43+00:00)
Title: Improve handling of JS environment detection under Browserify and browse...

...r add-ons

Depending on the environment under which Dropbox-js is used,
there will be different ways to:

- Access web APIs like XMLHttpRequest, base64 encoding, typed arrays
etc.
- Export Dropbox functionality for use by other code - eg. via
module.exports or a property on `window` or `self`
- Import functionality for use by Dropbox-js - eg. via require()

Previously there was an assumption that Dropbox-js was running
under one of three main types of environment - a browser, Node.js
or a web worker. The code first detected one of these types of
environment and set all of the above facets accordingly.

This broke apps in hybrid environments like Browserify which provide
both the `window` object but also a Node.js-like module environment for
example.

This commit refactors environment setup to deal with each of the facets
of the environment (web API access, module export, module import)
separately.