mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add monkey patch for structured Clone
This commit is contained in:
21
public/lib/structured-clone/json.js
Normal file
21
public/lib/structured-clone/json.js
Normal file
@ -0,0 +1,21 @@
|
||||
/*! (c) Andrea Giammarchi - ISC */
|
||||
|
||||
import {deserialize} from './deserialize.js';
|
||||
import {serialize} from './serialize.js';
|
||||
|
||||
const {parse: $parse, stringify: $stringify} = JSON;
|
||||
const options = {json: true, lossy: true};
|
||||
|
||||
/**
|
||||
* Revive a previously stringified structured clone.
|
||||
* @param {string} str previously stringified data as string.
|
||||
* @returns {any} whatever was previously stringified as clone.
|
||||
*/
|
||||
export const parse = str => deserialize($parse(str));
|
||||
|
||||
/**
|
||||
* Represent a structured clone value as string.
|
||||
* @param {any} any some clone-able value to stringify.
|
||||
* @returns {string} the value stringified.
|
||||
*/
|
||||
export const stringify = any => $stringify(serialize(any, options));
|
Reference in New Issue
Block a user