mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 00:04:22 +02:00
CODEBASE: Add Jsonable Map and Set types, move player.sourceFiles to a map (#473)
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
/* Generic Reviver, toJSON, and fromJSON functions used for saving and loading objects */
|
||||
|
||||
import { ObjectValidator, validateObject } from "./Validator";
|
||||
import { JSONMap, JSONSet } from "../Types/Jsonable";
|
||||
|
||||
type JsonableClass = (new () => { toJSON: () => IReviverValue }) & {
|
||||
fromJSON: (value: IReviverValue) => any;
|
||||
validationData?: ObjectValidator<any>;
|
||||
};
|
||||
|
||||
export interface IReviverValue {
|
||||
ctor: string;
|
||||
@@ -38,15 +43,7 @@ export function Reviver(_key: string, value: unknown): any {
|
||||
return obj;
|
||||
}
|
||||
|
||||
export const constructorsForReviver: Partial<
|
||||
Record<
|
||||
string,
|
||||
(new () => object) & {
|
||||
fromJSON: (value: IReviverValue) => any;
|
||||
validationData?: ObjectValidator<any>;
|
||||
}
|
||||
>
|
||||
> = {};
|
||||
export const constructorsForReviver: Partial<Record<string, JsonableClass>> = { JSONSet, JSONMap };
|
||||
|
||||
/**
|
||||
* A generic "toJSON" function that creates the data expected by Reviver.
|
||||
|
||||
Reference in New Issue
Block a user