dequoter/frontend/wailsjs/go/models.ts

54 lines
1.3 KiB
TypeScript
Executable file

export namespace main {
export class TextSpan {
text: string;
pos: number;
len: number;
static createFrom(source: any = {}) {
return new TextSpan(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.text = source["text"];
this.pos = source["pos"];
this.len = source["len"];
}
}
export class ProcessTextRequest {
action: string;
input: TextSpan[];
static createFrom(source: any = {}) {
return new ProcessTextRequest(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.action = source["action"];
this.input = this.convertValues(source["input"], TextSpan);
}
convertValues(a: any, classs: any, asMap: boolean = false): any {
if (!a) {
return a;
}
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
}
}