MCPcopy
hub / github.com/sveltejs/kit / stringify_remote_arg

Function stringify_remote_arg

packages/kit/src/runtime/shared.js:38–50  ·  view source on GitHub ↗
(value, transport)

Source from the content-addressed store, hash-verified

36 * @param {Transport} transport
37 */
38export function stringify_remote_arg(value, transport) {
39 if (value === undefined) return '';
40
41 // If people hit file/url size limits, we can look into using something like compress_and_encode_text from svelte.dev beyond a certain size
42 const json_string = stringify(value, transport);
43
44 // Convert to UTF-8 bytes, then base64 - handles all Unicode properly (btoa would fail on exotic characters)
45 const utf8_bytes = new TextEncoder().encode(json_string);
46 return btoa(String.fromCharCode(...utf8_bytes))
47 .replace(/=/g, '')
48 .replace(/\+/g, '-')
49 .replace(/\//g, '_');
50}
51
52/**
53 * Parses the argument (if any) for a remote function

Callers 6

prerenderFunction · 0.90
create_remote_functionFunction · 0.90
commandFunction · 0.90
wrapperFunction · 0.90
wrapperFunction · 0.90
get_responseFunction · 0.90

Calls 1

stringifyFunction · 0.85

Tested by

no test coverage detected