ramp-resources
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -42,2 +42,40 @@ var _ = require("lodash"); | ||
function partition(n, xs) { | ||
if (n === 0) { | ||
throw new Error("n must be > 0") | ||
} | ||
var numFullGroups = Math.floor(xs.length / n); | ||
if (numFullGroups === 0) { | ||
return [xs]; | ||
} | ||
var res = []; | ||
for (var i = 0; i < numFullGroups; i++) { | ||
res.push(xs.slice(i * n, ((i + 1) * n))); | ||
} | ||
var tail = xs.slice(numFullGroups * n); | ||
if (tail.length > 0) { | ||
res.push(tail); | ||
} | ||
return res; | ||
} | ||
function whenSequenceConcatIter(promises, deferred, result) { | ||
if (promises.length === 0) { | ||
deferred.resolve(result); | ||
} else { | ||
promises[0]().then(function (xs) { | ||
whenSequenceConcatIter(promises.slice(1), deferred, result.concat(xs)); | ||
}, deferred.reject); | ||
} | ||
} | ||
function whenSequenceConcat(promises) { | ||
var deferred = when.defer(); | ||
whenSequenceConcatIter(promises, deferred, []); | ||
return deferred.promise; | ||
}; | ||
/** | ||
@@ -343,3 +381,8 @@ * Create new resource set, resolved from the provided rootPath, | ||
var s = serialize.bind(null, cached); | ||
when.all(this.map(s)).then(function (resources) { | ||
var groupedResources = partition(100, Array.prototype.slice.call(this)); | ||
whenSequenceConcat(groupedResources.map(function (resources) { | ||
return function () { | ||
return when.all(resources.map(s)); | ||
} | ||
})).then(function (resources) { | ||
d.resolver.resolve({ | ||
@@ -482,6 +525,10 @@ resources: resources, | ||
when.all(promises).then(function () { | ||
rs.loadPath.append(data.loadPath || []); | ||
d.resolver.resolve(rs); | ||
try { | ||
rs.loadPath.append(data.loadPath || []); | ||
d.resolver.resolve(rs); | ||
} catch (e) { | ||
d.reject(e.message); | ||
} | ||
}, d.reject); | ||
return d.promise; | ||
}; |
{ | ||
"name": "ramp-resources", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Virtual file systems for exposing files and other resources on e.g. web servers", | ||
@@ -5,0 +5,0 @@ "homepage": "http://busterjs.org/docs/resources", |
@@ -13,2 +13,6 @@ #ramp-resources | ||
**1.0.5** (08.08.2014) | ||
* fix for issue [#347 - Failed creating session: EMFILE, open 'some/file/path.js'](https://github.com/busterjs/buster/issues/347) | ||
**1.0.4** (12.05.2014) | ||
@@ -15,0 +19,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266938
4984
24