0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Allow FileSystem's writeJson spacing to have more options (#1071)

Does as it says, essentially allows users to fully customize how they
want their JSON files written.
This commit is contained in:
Chomp 2025-01-13 09:53:42 +00:00 committed by GitHub
commit 67affbfaa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -167,11 +167,11 @@ export class FileSystem {
* *
* @param file The file path to write to. * @param file The file path to write to.
* @param jsonObject The object to write to the file. * @param jsonObject The object to write to the file.
* @param indentationSpaces The number of spaces to use for indentation. * @param spacing The number of spaces or string used for spacing of the JSON file.
* @returns A promise that resolves when the write operation is complete. * @returns A promise that resolves when the write operation is complete.
*/ */
public async writeJson(file: string, jsonObject: object, indentationSpaces?: 4): Promise<void> { public async writeJson(file: string, jsonObject: object, spacing: string | number = 4): Promise<void> {
const jsonString = JSON.stringify(jsonObject, null, indentationSpaces); const jsonString = JSON.stringify(jsonObject, null, spacing);
return this.write(file, jsonString); return this.write(file, jsonString);
} }

View File

@ -165,11 +165,11 @@ export class FileSystemSync {
* *
* @param file The file path to write to. * @param file The file path to write to.
* @param jsonObject The object to write to the file. * @param jsonObject The object to write to the file.
* @param indentationSpaces The number of spaces to use for indentation. * @param spacing The number of spaces or string used for spacing of the JSON file.
* @returns void * @returns void
*/ */
public writeJson(file: string, jsonObject: object, indentationSpaces?: 4): void { public writeJson(file: string, jsonObject: object, spacing: string | number = 4): void {
const jsonString = JSON.stringify(jsonObject, null, indentationSpaces); const jsonString = JSON.stringify(jsonObject, null, spacing);
this.write(file, jsonString); this.write(file, jsonString);
} }