-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow load as Map for Hashes + Omit encoding for Strings while dumping
- Loading branch information
Nuri Yuri
committed
Dec 23, 2023
1 parent
9613fc5
commit 3d530a7
Showing
13 changed files
with
177 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export type MarshalLoadConfig = { | ||
hashToJS: 'legacy' | 'map'; | ||
}; | ||
|
||
export type MarshalDumpConfig = { | ||
/* Omit encoding for RMXP compatibility */ | ||
omitStringEncoding: boolean; | ||
}; | ||
|
||
export type MarshalConfig = Readonly<{ | ||
load: Readonly<MarshalLoadConfig>; | ||
dump: Readonly<MarshalDumpConfig>; | ||
}>; | ||
|
||
let config: MarshalConfig = { | ||
load: { | ||
hashToJS: 'legacy', | ||
}, | ||
dump: { | ||
omitStringEncoding: false, | ||
}, | ||
}; | ||
|
||
export const getMarshalConfig = () => config; | ||
export const getMarshalDumpConfig = () => config.dump; | ||
export const getMarshalLoadConfig = () => config.load; | ||
|
||
export const setMarshalConfig = (newConfig: { load: MarshalLoadConfig; dump: MarshalDumpConfig }) => { | ||
config = JSON.parse(JSON.stringify(newConfig)); | ||
}; | ||
|
||
export const setMarshalDumpConfig = (newConfig: MarshalDumpConfig) => { | ||
config = { | ||
...config, | ||
dump: JSON.parse(JSON.stringify(newConfig)), | ||
}; | ||
}; | ||
|
||
export const setMarshalLoadConfig = (newConfig: MarshalLoadConfig) => { | ||
config = { | ||
...config, | ||
load: JSON.parse(JSON.stringify(newConfig)), | ||
}; | ||
}; | ||
|
||
export const mergeConfig = (config: Partial<MarshalConfig>): MarshalConfig => { | ||
return { | ||
...getMarshalConfig(), | ||
...JSON.parse(JSON.stringify(config)), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters