Sanity-check decaffeinate app.models.Entry

pull/1441/head
Simon Legner 1 year ago
parent 0585d8300d
commit 35b38b796f

@ -1,35 +1,23 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//= require app/searcher //= require app/searcher
(function () {
let applyAliases = undefined;
app.models.Entry = class Entry extends app.Model { app.models.Entry = class Entry extends app.Model {
static initClass() { static applyAliases(string) {
let ALIASES; if (Entry.ALIASES.hasOwnProperty(string)) {
applyAliases = function (string) { return [string, Entry.ALIASES[string]];
if (ALIASES.hasOwnProperty(string)) {
return [string, ALIASES[string]];
} else { } else {
const words = string.split("."); const words = string.split(".");
for (let i = 0; i < words.length; i++) { for (let i = 0; i < words.length; i++) {
var word = words[i]; var word = words[i];
if (ALIASES.hasOwnProperty(word)) { if (Entry.ALIASES.hasOwnProperty(word)) {
words[i] = ALIASES[word]; words[i] = Entry.ALIASES[word];
return [string, words.join(".")]; return [string, words.join(".")];
} }
} }
} }
return string; return string;
}; }
this.ALIASES = ALIASES = { static ALIASES = {
angular: "ng", angular: "ng",
"angular.js": "ng", "angular.js": "ng",
"backbone.js": "bb", "backbone.js": "bb",
@ -64,16 +52,15 @@
typescript: "ts", typescript: "ts",
"underscore.js": "_", "underscore.js": "_",
}; };
}
// Attributes: name, type, path // Attributes: name, type, path
constructor() { constructor() {
super(...arguments); super(...arguments);
this.text = applyAliases(app.Searcher.normalizeString(this.name)); this.text = Entry.applyAliases(app.Searcher.normalizeString(this.name));
} }
addAlias(name) { addAlias(name) {
const text = applyAliases(app.Searcher.normalizeString(name)); const text = Entry.applyAliases(app.Searcher.normalizeString(name));
if (!Array.isArray(this.text)) { if (!Array.isArray(this.text)) {
this.text = [this.text]; this.text = [this.text];
} }
@ -116,6 +103,3 @@
return app.db.load(this, onSuccess, onError); return app.db.load(this, onSuccess, onError);
} }
}; };
app.models.Entry.initClass();
return app.models.Entry;
})();

Loading…
Cancel
Save