|
|
|
@ -1,28 +1,11 @@
|
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
|
|
|
|
/*
|
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
|
* DS101: Remove unnecessary use of Array.from
|
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
* DS202: Simplify dynamic range loops
|
|
|
|
|
* DS206: Consider reworking classes to avoid initClass
|
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
|
|
|
*/
|
|
|
|
|
(function () {
|
|
|
|
|
let NORMALIZE_VERSION_RGX = undefined;
|
|
|
|
|
let NORMALIZE_VERSION_SUB = undefined;
|
|
|
|
|
let CONCURRENCY = undefined;
|
|
|
|
|
app.collections.Docs = class Docs extends app.Collection {
|
|
|
|
|
static initClass() {
|
|
|
|
|
this.model = "Doc";
|
|
|
|
|
|
|
|
|
|
NORMALIZE_VERSION_RGX = /\.(\d)$/;
|
|
|
|
|
NORMALIZE_VERSION_SUB = ".0$1";
|
|
|
|
|
app.collections.Docs = class Docs extends app.Collection {
|
|
|
|
|
static model = "Doc";
|
|
|
|
|
static NORMALIZE_VERSION_RGX = /\.(\d)$/;
|
|
|
|
|
static NORMALIZE_VERSION_SUB = ".0$1";
|
|
|
|
|
|
|
|
|
|
// Load models concurrently.
|
|
|
|
|
// It's not pretty but I didn't want to import a promise library only for this.
|
|
|
|
|
CONCURRENCY = 3;
|
|
|
|
|
}
|
|
|
|
|
static CONCURRENCY = 3;
|
|
|
|
|
|
|
|
|
|
findBySlug(slug) {
|
|
|
|
|
return (
|
|
|
|
@ -34,8 +17,14 @@
|
|
|
|
|
if (a.name === b.name) {
|
|
|
|
|
if (
|
|
|
|
|
!a.version ||
|
|
|
|
|
a.version.replace(NORMALIZE_VERSION_RGX, NORMALIZE_VERSION_SUB) >
|
|
|
|
|
b.version.replace(NORMALIZE_VERSION_RGX, NORMALIZE_VERSION_SUB)
|
|
|
|
|
a.version.replace(
|
|
|
|
|
Docs.NORMALIZE_VERSION_RGX,
|
|
|
|
|
Docs.NORMALIZE_VERSION_SUB,
|
|
|
|
|
) >
|
|
|
|
|
b.version.replace(
|
|
|
|
|
Docs.NORMALIZE_VERSION_RGX,
|
|
|
|
|
Docs.NORMALIZE_VERSION_SUB,
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
@ -54,7 +43,7 @@
|
|
|
|
|
var next = () => {
|
|
|
|
|
if (i < this.models.length) {
|
|
|
|
|
this.models[i].load(next, fail, options);
|
|
|
|
|
} else if (i === this.models.length + CONCURRENCY - 1) {
|
|
|
|
|
} else if (i === this.models.length + Docs.CONCURRENCY - 1) {
|
|
|
|
|
onComplete();
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
@ -62,23 +51,19 @@
|
|
|
|
|
|
|
|
|
|
var fail = function (...args) {
|
|
|
|
|
if (onError) {
|
|
|
|
|
onError(...Array.from(args || []));
|
|
|
|
|
onError(args);
|
|
|
|
|
onError = null;
|
|
|
|
|
}
|
|
|
|
|
next();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (
|
|
|
|
|
let j = 0, end = CONCURRENCY, asc = 0 <= end;
|
|
|
|
|
asc ? j < end : j > end;
|
|
|
|
|
asc ? j++ : j--
|
|
|
|
|
) {
|
|
|
|
|
for (let j = 0, end = Docs.CONCURRENCY; j < end; j++) {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearCache() {
|
|
|
|
|
for (var doc of Array.from(this.models)) {
|
|
|
|
|
for (var doc of this.models) {
|
|
|
|
|
doc.clearCache();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -136,7 +121,4 @@
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
app.collections.Docs.initClass();
|
|
|
|
|
return app.collections.Docs;
|
|
|
|
|
})();
|
|
|
|
|
};
|
|
|
|
|