Sanity-check decaffeinate app.collections.Docs

pull/1441/head
Simon Legner 1 year ago
parent 92144087a3
commit e5f852e7c0

@ -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 { app.collections.Docs = class Docs extends app.Collection {
static initClass() { static model = "Doc";
this.model = "Doc"; static NORMALIZE_VERSION_RGX = /\.(\d)$/;
static NORMALIZE_VERSION_SUB = ".0$1";
NORMALIZE_VERSION_RGX = /\.(\d)$/;
NORMALIZE_VERSION_SUB = ".0$1";
// Load models concurrently. // Load models concurrently.
// It's not pretty but I didn't want to import a promise library only for this. // It's not pretty but I didn't want to import a promise library only for this.
CONCURRENCY = 3; static CONCURRENCY = 3;
}
findBySlug(slug) { findBySlug(slug) {
return ( return (
@ -34,8 +17,14 @@
if (a.name === b.name) { if (a.name === b.name) {
if ( if (
!a.version || !a.version ||
a.version.replace(NORMALIZE_VERSION_RGX, NORMALIZE_VERSION_SUB) > a.version.replace(
b.version.replace(NORMALIZE_VERSION_RGX, NORMALIZE_VERSION_SUB) Docs.NORMALIZE_VERSION_RGX,
Docs.NORMALIZE_VERSION_SUB,
) >
b.version.replace(
Docs.NORMALIZE_VERSION_RGX,
Docs.NORMALIZE_VERSION_SUB,
)
) { ) {
return -1; return -1;
} else { } else {
@ -54,7 +43,7 @@
var next = () => { var next = () => {
if (i < this.models.length) { if (i < this.models.length) {
this.models[i].load(next, fail, options); 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(); onComplete();
} }
i++; i++;
@ -62,23 +51,19 @@
var fail = function (...args) { var fail = function (...args) {
if (onError) { if (onError) {
onError(...Array.from(args || [])); onError(args);
onError = null; onError = null;
} }
next(); next();
}; };
for ( for (let j = 0, end = Docs.CONCURRENCY; j < end; j++) {
let j = 0, end = CONCURRENCY, asc = 0 <= end;
asc ? j < end : j > end;
asc ? j++ : j--
) {
next(); next();
} }
} }
clearCache() { clearCache() {
for (var doc of Array.from(this.models)) { for (var doc of this.models) {
doc.clearCache(); doc.clearCache();
} }
} }
@ -137,6 +122,3 @@
}); });
} }
}; };
app.collections.Docs.initClass();
return app.collections.Docs;
})();

Loading…
Cancel
Save