Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Properly handle multiple ids in ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Aug 17, 2010
1 parent 8c16b19 commit 26917b1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lib/nodules.js
Expand Up @@ -259,9 +259,27 @@ function makeRequire(currentId){
uri = resolveUri(currentId, uri, getPackage(currentId).mappings);
return factories[uri];
}
require.ensure = function(id, callback){
var ensure = require.ensure = function(id, callback){
var require = makeRequire(uri);
if(id instanceof Array){
id.forEach();
waitingOn++;
try{
var results = id.map(ensure);
}finally{
waitingOn--;
}
if(waitingOn){
if(callback){
callbacks.unshift(callback);
}
}else{
if(callback){
var uri = resolveUri(currentId, id[0], getPackage(currentId).mappings),
require = makeRequire(uri);
callback(require);
}
}
return results;
}
var uri = resolveUri(currentId, id, getPackage(currentId).mappings),
require = makeRequire(uri),
Expand Down

0 comments on commit 26917b1

Please sign in to comment.