Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/snaps-utils/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ export function parseJson<Type extends Json = Json>(json: string) {
*
* This may sometimes be preferred over `getJsonSize` for performance reasons.
*
* Note: This function does not encode the string to bytes, thus the input may
* be about 4x larger in practice. Use this function with caution.
*
* @param value - The JSON value to get the size of.
* @returns The size of the JSON value in bytes.
*/
export function getJsonSizeUnsafe(value: Json): number {
const json = JSON.stringify(value);
return new TextEncoder().encode(json).byteLength;
return json.length;
}
Loading