Skip to content

Commit

Permalink
Merge ; commit 'cd666079a6ca5720f65f00382794010c0f906834'
Browse files Browse the repository at this point in the history
  • Loading branch information
SherfeyInv committed Jan 3, 2025
2 parents f2c1c12 + cd66607 commit 876158a
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 53 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"name": "Jest Debug Current File",
"type": "node",
"request": "launch",
"runtimeArgs": [ "--experimental-vm-modules" ],
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
Expand Down
8 changes: 6 additions & 2 deletions lib/json-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ export function fromJSON<T>(input: string): T {
}

export function toJSON<T>(input: T): string {
return stringify(input);
const result = stringify(input);
if (typeof result !== "string") throw new Error(`Could not convert ${input} to JSON`);
return result;
}

export function toPrettyJSON<T>(input: T): string {
return stringify(input, { space: 4 });
const result = stringify(input, { space: 4 });
if (typeof result !== "string") throw new Error(`Could not convert ${input} to JSON`);
return result;
}
Loading

0 comments on commit 876158a

Please # to comment.