27 lines · 660 B · TypeScript
RawDownload
export function stringifyJsonUtf8(value: unknown, context: string): string {	try {		const encoded = JSON.stringify(value);		if (encoded === undefined) {			throw new Error(`${context} must be JSON-serializable`);		}		return encoded;	} catch (error) {		throw new Error(			`${context} must be JSON-serializable: ${				error instanceof Error ? error.message : String(error)			}`,		);	}} export function parseJsonUtf8(value: string, context: string): unknown {	try {		return JSON.parse(value);	} catch (error) {		throw new Error(			`invalid ${context} JSON payload: ${				error instanceof Error ? error.message : String(error)			}`,		);	}}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t