Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created January 27, 2016 05:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanflorence/c3b7347d6814fdb3574f to your computer and use it in GitHub Desktop.
Save ryanflorence/c3b7347d6814fdb3574f to your computer and use it in GitHub Desktop.
export default function(cb) {
let counters = 0
if (typeof Promise === 'undefined') {
counters++
require.ensure([], (require) => {
require('imports?this=>window!es6-promise')
decrementCounter()
})
}
if (typeof fetch === 'undefined') {
counters++
require.ensure([], (require) => {
require('imports?self=>window!whatwg-fetch')
decrementCounter()
})
}
maybeFinish()
function maybeFinish() {
if (counters === 0) cb()
}
function decrementCounter() {
counters--
maybeCallback()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment