Skip to content

Commit

Permalink
fix: save circular dependency JSON.stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
n-peugnet committed Apr 7, 2020
1 parent 345f9df commit 5bb751a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/p5.image-map-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type ToolLabel = {
export type View = { scale: number, transX: number, transY: number, };
export type Zoom = { min: number, max: number, sensativity: number, };

export class Save {
constructor (public version: string, public map: ImageMap) {}
}

/**
*/
export class imageMapCreator {
Expand Down Expand Up @@ -575,9 +579,11 @@ export class imageMapCreator {
}

exportMap(): string {
return JSON.stringify({
version: version,
map: this.map
return JSON.stringify(new Save(version, this.map), function (key, value) {
if (value instanceof ImageMap && !(this instanceof Save)) {
return value.getName();
}
return value;
});
}

Expand Down

0 comments on commit 5bb751a

Please sign in to comment.