Skip to content

Commit

Permalink
+ core: add helper method to create raw js string.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Nov 19, 2024
1 parent dc99119 commit 53d7345
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/core/src/helpers/raw-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ export function parseRawData<T = unknown>(data: string, ...args: unknown[]): T {

return JSON.parse(data);
}

export function jsRaw(data: unknown): string {
return JSON.stringify(data, (_, value) => {
if (typeof value === 'function') {
return `RAWJS<${value.toString().split('"').join('<RAWJS_QUOTE>').split('\n').join('<RAWJS_LINE>')}>RAWJS`;
}
});
}

0 comments on commit 53d7345

Please sign in to comment.