anki-reader
Version:
A library for reading Anki apkg and collection files.
81 lines (80 loc) • 1.75 kB
JavaScript
export class Model {
id;
modelJson;
css;
flds;
latexPre;
latexPost;
name;
type;
tmpls;
constructor(id, modelJson) {
this.id = id;
this.modelJson = modelJson;
}
getId() {
return this.id;
}
getCss() {
if (this.css != null) {
return this.css;
}
this.css = this.modelJson.css ?? '';
return this.css ?? '';
}
getFields() {
if (this.flds != null) {
return [
...this.flds
];
}
this.flds = this.modelJson.flds ?? [];
return [
...this.flds ?? []
];
}
getLatexPre() {
if (this.latexPre != null) {
return this.latexPre;
}
this.latexPre = this.modelJson.latexPre ?? '';
return this.latexPre ?? '';
}
getLatexPost() {
if (this.latexPost != null) {
return this.latexPost;
}
this.latexPost = this.modelJson.latexPost ?? '';
return this.latexPost ?? '';
}
getName() {
if (this.name != null) {
return this.name;
}
this.name = this.modelJson.name ?? '';
return this.name ?? '';
}
getType() {
if (this.type != null) {
return this.type;
}
this.type = this.modelJson.type ?? 0;
return this.type ?? 0;
}
getTemplates() {
if (this.tmpls != null) {
return [
...this.tmpls
];
}
this.tmpls = this.modelJson.tmpls ?? [];
return [
...this.tmpls ?? []
];
}
getRawModel() {
return {
...this.modelJson
};
}
}