mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-08 00:27:47 +02:00
CODEBASE: Add Jsonable Map and Set types, move player.sourceFiles to a map (#473)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { IReviverValue } from "../utils/JSONReviver";
|
||||
// Jsonable versions of builtin JS class objects
|
||||
export class JSONSet<T> extends Set<T> {
|
||||
toJSON(): IReviverValue {
|
||||
return { ctor: "JSONSet", data: Array.from(this) };
|
||||
}
|
||||
static fromJSON(value: IReviverValue): JSONSet<any> {
|
||||
return new JSONSet(value.data);
|
||||
}
|
||||
}
|
||||
|
||||
export class JSONMap<K, V> extends Map<K, V> {
|
||||
toJSON(): IReviverValue {
|
||||
return { ctor: "JSONMap", data: Array.from(this) };
|
||||
}
|
||||
|
||||
static fromJSON(value: IReviverValue): JSONMap<any, any> {
|
||||
return new JSONMap(value.data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user