Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
weepy committed Nov 28, 2011
1 parent afd94a6 commit 6ffd79a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions browser/brequire.js
Expand Up @@ -74,6 +74,19 @@
}
for(var i in sync_require) require[i] = sync_require[i]

require.async = function(path, callback, deps) {
deps = deps || []
var our_mod
(function run(path) {
load(path, function(mod, new_deps) {
our_mod || (our_mod = mod) // we want the first one
deps = new_deps.concat(deps)
var dep = deps.shift()
if(!dep) return callback(our_mod)
run(dep)
})
})(path)
}

function load(path, callback) {
var mod, l
Expand Down Expand Up @@ -103,19 +116,6 @@

load.loaders = {}

require.async = function(path, callback, deps) {
deps = deps || []
var our_mod
(function run(path) {
load(path, function(mod, new_deps) {
our_mod || (our_mod = mod) // we want the first one
deps = new_deps.concat(deps)
var dep = deps.shift()
if(!dep) return callback(our_mod)
run(dep)
})
})(path)
}

function extract_dependencies(text) {
var requires = text.match(/require\s*\('\s*([^'])*'\s*\)|require\s*\("\s*([^"])*"\s*\)/g)
Expand Down

0 comments on commit 6ffd79a

Please sign in to comment.