You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB
TypeScript

export namespace main {
export class Project {
name: string;
last_directory: string;
last_directory_path: string;
// Go type: time
last_directory_time: any;
static createFrom(source: any = {}) {
return new Project(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.name = source["name"];
this.last_directory = source["last_directory"];
this.last_directory_path = source["last_directory_path"];
this.last_directory_time = this.convertValues(source["last_directory_time"], null);
}
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;
}
}
}