Files
base/node_modules/.vite/deps/devalue.js
T
eewing ec317eb17c
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m11s
INIT
2026-02-18 15:17:47 -06:00

918 lines
28 KiB
JavaScript

import "./chunk-X4VJQ2O3.js";
// node_modules/devalue/src/utils.js
var escaped = {
"<": "\\u003C",
"\\": "\\\\",
"\b": "\\b",
"\f": "\\f",
"\n": "\\n",
"\r": "\\r",
" ": "\\t",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
};
var DevalueError = class extends Error {
/**
* @param {string} message
* @param {string[]} keys
* @param {any} [value] - The value that failed to be serialized
* @param {any} [root] - The root value being serialized
*/
constructor(message, keys, value, root) {
super(message);
this.name = "DevalueError";
this.path = keys.join("");
this.value = value;
this.root = root;
}
};
function is_primitive(thing) {
return Object(thing) !== thing;
}
var object_proto_names = Object.getOwnPropertyNames(
Object.prototype
).sort().join("\0");
function is_plain_object(thing) {
const proto = Object.getPrototypeOf(thing);
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
}
function get_type(thing) {
return Object.prototype.toString.call(thing).slice(8, -1);
}
function get_escaped_char(char) {
switch (char) {
case '"':
return '\\"';
case "<":
return "\\u003C";
case "\\":
return "\\\\";
case "\n":
return "\\n";
case "\r":
return "\\r";
case " ":
return "\\t";
case "\b":
return "\\b";
case "\f":
return "\\f";
case "\u2028":
return "\\u2028";
case "\u2029":
return "\\u2029";
default:
return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
}
}
function stringify_string(str) {
let result = "";
let last_pos = 0;
const len = str.length;
for (let i = 0; i < len; i += 1) {
const char = str[i];
const replacement = get_escaped_char(char);
if (replacement) {
result += str.slice(last_pos, i) + replacement;
last_pos = i + 1;
}
}
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
}
function enumerable_symbols(object) {
return Object.getOwnPropertySymbols(object).filter(
(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
);
}
var is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
function stringify_key(key) {
return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
}
function is_valid_array_index(s) {
if (s.length === 0) return false;
if (s.length > 1 && s.charCodeAt(0) === 48) return false;
for (let i = 0; i < s.length; i++) {
const c = s.charCodeAt(i);
if (c < 48 || c > 57) return false;
}
const n = +s;
if (n >= 2 ** 32 - 1) return false;
if (n < 0) return false;
return true;
}
function valid_array_indices(array) {
const keys = Object.keys(array);
for (var i = keys.length - 1; i >= 0; i--) {
if (is_valid_array_index(keys[i])) {
break;
}
}
keys.length = i + 1;
return keys;
}
// node_modules/devalue/src/uneval.js
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
var unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
function uneval(value, replacer) {
const counts = /* @__PURE__ */ new Map();
const keys = [];
const custom = /* @__PURE__ */ new Map();
function walk(thing) {
if (!is_primitive(thing)) {
if (counts.has(thing)) {
counts.set(thing, counts.get(thing) + 1);
return;
}
counts.set(thing, 1);
if (replacer) {
const str2 = replacer(thing, (value2) => uneval(value2, replacer));
if (typeof str2 === "string") {
custom.set(thing, str2);
return;
}
}
if (typeof thing === "function") {
throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
}
const type = get_type(thing);
switch (type) {
case "Number":
case "BigInt":
case "String":
case "Boolean":
case "Date":
case "RegExp":
case "URL":
case "URLSearchParams":
return;
case "Array":
thing.forEach((value2, i) => {
keys.push(`[${i}]`);
walk(value2);
keys.pop();
});
break;
case "Set":
Array.from(thing).forEach(walk);
break;
case "Map":
for (const [key, value2] of thing) {
keys.push(
`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
);
walk(value2);
keys.pop();
}
break;
case "Int8Array":
case "Uint8Array":
case "Uint8ClampedArray":
case "Int16Array":
case "Uint16Array":
case "Int32Array":
case "Uint32Array":
case "Float32Array":
case "Float64Array":
case "BigInt64Array":
case "BigUint64Array":
walk(thing.buffer);
return;
case "ArrayBuffer":
return;
case "Temporal.Duration":
case "Temporal.Instant":
case "Temporal.PlainDate":
case "Temporal.PlainTime":
case "Temporal.PlainDateTime":
case "Temporal.PlainMonthDay":
case "Temporal.PlainYearMonth":
case "Temporal.ZonedDateTime":
return;
default:
if (!is_plain_object(thing)) {
throw new DevalueError(
`Cannot stringify arbitrary non-POJOs`,
keys,
thing,
value
);
}
if (enumerable_symbols(thing).length > 0) {
throw new DevalueError(
`Cannot stringify POJOs with symbolic keys`,
keys,
thing,
value
);
}
for (const key of Object.keys(thing)) {
if (key === "__proto__") {
throw new DevalueError(
`Cannot stringify objects with __proto__ keys`,
keys,
thing,
value
);
}
keys.push(stringify_key(key));
walk(thing[key]);
keys.pop();
}
}
}
}
walk(value);
const names = /* @__PURE__ */ new Map();
Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
names.set(entry[0], get_name(i));
});
function stringify2(thing) {
if (names.has(thing)) {
return names.get(thing);
}
if (is_primitive(thing)) {
return stringify_primitive(thing);
}
if (custom.has(thing)) {
return custom.get(thing);
}
const type = get_type(thing);
switch (type) {
case "Number":
case "String":
case "Boolean":
return `Object(${stringify2(thing.valueOf())})`;
case "RegExp":
return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`;
case "Date":
return `new Date(${thing.getTime()})`;
case "URL":
return `new URL(${stringify_string(thing.toString())})`;
case "URLSearchParams":
return `new URLSearchParams(${stringify_string(thing.toString())})`;
case "Array": {
let has_holes = false;
let result = "[";
for (let i = 0; i < thing.length; i += 1) {
if (i > 0) result += ",";
if (Object.hasOwn(thing, i)) {
result += stringify2(thing[i]);
} else if (!has_holes) {
const populated_keys = valid_array_indices(
/** @type {any[]} */
thing
);
const population = populated_keys.length;
const d = String(thing.length).length;
const hole_cost = thing.length + 2;
const sparse_cost = 25 + d + population * (d + 2);
if (hole_cost > sparse_cost) {
const entries = populated_keys.map((k) => `${k}:${stringify2(thing[k])}`).join(",");
return `Object.assign(Array(${thing.length}),{${entries}})`;
}
has_holes = true;
i -= 1;
}
}
const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
return result + tail + "]";
}
case "Set":
case "Map":
return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`;
case "Int8Array":
case "Uint8Array":
case "Uint8ClampedArray":
case "Int16Array":
case "Uint16Array":
case "Int32Array":
case "Uint32Array":
case "Float32Array":
case "Float64Array":
case "BigInt64Array":
case "BigUint64Array": {
let str2 = `new ${type}`;
if (counts.get(thing.buffer) === 1) {
const array = new thing.constructor(thing.buffer);
str2 += `([${array}])`;
} else {
str2 += `([${stringify2(thing.buffer)}])`;
}
const a = thing.byteOffset;
const b = a + thing.byteLength;
if (a > 0 || b !== thing.buffer.byteLength) {
const m = +/(\d+)/.exec(type)[1] / 8;
str2 += `.subarray(${a / m},${b / m})`;
}
return str2;
}
case "ArrayBuffer": {
const ui8 = new Uint8Array(thing);
return `new Uint8Array([${ui8.toString()}]).buffer`;
}
case "Temporal.Duration":
case "Temporal.Instant":
case "Temporal.PlainDate":
case "Temporal.PlainTime":
case "Temporal.PlainDateTime":
case "Temporal.PlainMonthDay":
case "Temporal.PlainYearMonth":
case "Temporal.ZonedDateTime":
return `${type}.from(${stringify_string(thing.toString())})`;
default:
const keys2 = Object.keys(thing);
const obj = keys2.map((key) => `${safe_key(key)}:${stringify2(thing[key])}`).join(",");
const proto = Object.getPrototypeOf(thing);
if (proto === null) {
return keys2.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
}
return `{${obj}}`;
}
}
const str = stringify2(value);
if (names.size) {
const params = [];
const statements = [];
const values = [];
names.forEach((name, thing) => {
params.push(name);
if (custom.has(thing)) {
values.push(
/** @type {string} */
custom.get(thing)
);
return;
}
if (is_primitive(thing)) {
values.push(stringify_primitive(thing));
return;
}
const type = get_type(thing);
switch (type) {
case "Number":
case "String":
case "Boolean":
values.push(`Object(${stringify2(thing.valueOf())})`);
break;
case "RegExp":
values.push(thing.toString());
break;
case "Date":
values.push(`new Date(${thing.getTime()})`);
break;
case "Array":
values.push(`Array(${thing.length})`);
thing.forEach((v, i) => {
statements.push(`${name}[${i}]=${stringify2(v)}`);
});
break;
case "Set":
values.push(`new Set`);
statements.push(
`${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}`
);
break;
case "Map":
values.push(`new Map`);
statements.push(
`${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}`
);
break;
case "ArrayBuffer":
values.push(
`new Uint8Array([${new Uint8Array(thing).join(",")}]).buffer`
);
break;
default:
values.push(
Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}"
);
Object.keys(thing).forEach((key) => {
statements.push(
`${name}${safe_prop(key)}=${stringify2(thing[key])}`
);
});
}
});
statements.push(`return ${str}`);
return `(function(${params.join(",")}){${statements.join(
";"
)}}(${values.join(",")}))`;
} else {
return str;
}
}
function get_name(num) {
let name = "";
do {
name = chars[num % chars.length] + name;
num = ~~(num / chars.length) - 1;
} while (num >= 0);
return reserved.test(name) ? `${name}0` : name;
}
function escape_unsafe_char(c) {
return escaped[c] || c;
}
function escape_unsafe_chars(str) {
return str.replace(unsafe_chars, escape_unsafe_char);
}
function safe_key(key) {
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
}
function safe_prop(key) {
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
}
function stringify_primitive(thing) {
if (typeof thing === "string") return stringify_string(thing);
if (thing === void 0) return "void 0";
if (thing === 0 && 1 / thing < 0) return "-0";
const str = String(thing);
if (typeof thing === "number") return str.replace(/^(-)?0\./, "$1.");
if (typeof thing === "bigint") return thing + "n";
return str;
}
// node_modules/devalue/src/base64.js
function encode64(arraybuffer) {
const dv = new DataView(arraybuffer);
let binaryString = "";
for (let i = 0; i < arraybuffer.byteLength; i++) {
binaryString += String.fromCharCode(dv.getUint8(i));
}
return binaryToAscii(binaryString);
}
function decode64(string) {
const binaryString = asciiToBinary(string);
const arraybuffer = new ArrayBuffer(binaryString.length);
const dv = new DataView(arraybuffer);
for (let i = 0; i < arraybuffer.byteLength; i++) {
dv.setUint8(i, binaryString.charCodeAt(i));
}
return arraybuffer;
}
var KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
function asciiToBinary(data) {
if (data.length % 4 === 0) {
data = data.replace(/==?$/, "");
}
let output = "";
let buffer = 0;
let accumulatedBits = 0;
for (let i = 0; i < data.length; i++) {
buffer <<= 6;
buffer |= KEY_STRING.indexOf(data[i]);
accumulatedBits += 6;
if (accumulatedBits === 24) {
output += String.fromCharCode((buffer & 16711680) >> 16);
output += String.fromCharCode((buffer & 65280) >> 8);
output += String.fromCharCode(buffer & 255);
buffer = accumulatedBits = 0;
}
}
if (accumulatedBits === 12) {
buffer >>= 4;
output += String.fromCharCode(buffer);
} else if (accumulatedBits === 18) {
buffer >>= 2;
output += String.fromCharCode((buffer & 65280) >> 8);
output += String.fromCharCode(buffer & 255);
}
return output;
}
function binaryToAscii(str) {
let out = "";
for (let i = 0; i < str.length; i += 3) {
const groupsOfSix = [void 0, void 0, void 0, void 0];
groupsOfSix[0] = str.charCodeAt(i) >> 2;
groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
if (str.length > i + 1) {
groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
}
if (str.length > i + 2) {
groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
}
for (let j = 0; j < groupsOfSix.length; j++) {
if (typeof groupsOfSix[j] === "undefined") {
out += "=";
} else {
out += KEY_STRING[groupsOfSix[j]];
}
}
}
return out;
}
// node_modules/devalue/src/constants.js
var UNDEFINED = -1;
var HOLE = -2;
var NAN = -3;
var POSITIVE_INFINITY = -4;
var NEGATIVE_INFINITY = -5;
var NEGATIVE_ZERO = -6;
var SPARSE = -7;
// node_modules/devalue/src/parse.js
function parse(serialized, revivers) {
return unflatten(JSON.parse(serialized), revivers);
}
function unflatten(parsed, revivers) {
if (typeof parsed === "number") return hydrate(parsed, true);
if (!Array.isArray(parsed) || parsed.length === 0) {
throw new Error("Invalid input");
}
const values = (
/** @type {any[]} */
parsed
);
const hydrated = Array(values.length);
let hydrating = null;
function hydrate(index, standalone = false) {
if (index === UNDEFINED) return void 0;
if (index === NAN) return NaN;
if (index === POSITIVE_INFINITY) return Infinity;
if (index === NEGATIVE_INFINITY) return -Infinity;
if (index === NEGATIVE_ZERO) return -0;
if (standalone || typeof index !== "number") {
throw new Error(`Invalid input`);
}
if (index in hydrated) return hydrated[index];
const value = values[index];
if (!value || typeof value !== "object") {
hydrated[index] = value;
} else if (Array.isArray(value)) {
if (typeof value[0] === "string") {
const type = value[0];
const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
if (reviver) {
let i = value[1];
if (typeof i !== "number") {
i = values.push(value[1]) - 1;
}
hydrating ?? (hydrating = /* @__PURE__ */ new Set());
if (hydrating.has(i)) {
throw new Error("Invalid circular reference");
}
hydrating.add(i);
hydrated[index] = reviver(hydrate(i));
hydrating.delete(i);
return hydrated[index];
}
switch (type) {
case "Date":
hydrated[index] = new Date(value[1]);
break;
case "Set":
const set = /* @__PURE__ */ new Set();
hydrated[index] = set;
for (let i = 1; i < value.length; i += 1) {
set.add(hydrate(value[i]));
}
break;
case "Map":
const map = /* @__PURE__ */ new Map();
hydrated[index] = map;
for (let i = 1; i < value.length; i += 2) {
map.set(hydrate(value[i]), hydrate(value[i + 1]));
}
break;
case "RegExp":
hydrated[index] = new RegExp(value[1], value[2]);
break;
case "Object":
hydrated[index] = Object(value[1]);
break;
case "BigInt":
hydrated[index] = BigInt(value[1]);
break;
case "null":
const obj = /* @__PURE__ */ Object.create(null);
hydrated[index] = obj;
for (let i = 1; i < value.length; i += 2) {
obj[value[i]] = hydrate(value[i + 1]);
}
break;
case "Int8Array":
case "Uint8Array":
case "Uint8ClampedArray":
case "Int16Array":
case "Uint16Array":
case "Int32Array":
case "Uint32Array":
case "Float32Array":
case "Float64Array":
case "BigInt64Array":
case "BigUint64Array": {
if (values[value[1]][0] !== "ArrayBuffer") {
throw new Error("Invalid data");
}
const TypedArrayConstructor = globalThis[type];
const buffer = hydrate(value[1]);
const typedArray = new TypedArrayConstructor(buffer);
hydrated[index] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
break;
}
case "ArrayBuffer": {
const base64 = value[1];
if (typeof base64 !== "string") {
throw new Error("Invalid ArrayBuffer encoding");
}
const arraybuffer = decode64(base64);
hydrated[index] = arraybuffer;
break;
}
case "Temporal.Duration":
case "Temporal.Instant":
case "Temporal.PlainDate":
case "Temporal.PlainTime":
case "Temporal.PlainDateTime":
case "Temporal.PlainMonthDay":
case "Temporal.PlainYearMonth":
case "Temporal.ZonedDateTime": {
const temporalName = type.slice(9);
hydrated[index] = Temporal[temporalName].from(value[1]);
break;
}
case "URL": {
const url = new URL(value[1]);
hydrated[index] = url;
break;
}
case "URLSearchParams": {
const url = new URLSearchParams(value[1]);
hydrated[index] = url;
break;
}
default:
throw new Error(`Unknown type ${type}`);
}
} else if (value[0] === SPARSE) {
const len = value[1];
const array = new Array(len);
hydrated[index] = array;
for (let i = 2; i < value.length; i += 2) {
const idx = value[i];
array[idx] = hydrate(value[i + 1]);
}
} else {
const array = new Array(value.length);
hydrated[index] = array;
for (let i = 0; i < value.length; i += 1) {
const n = value[i];
if (n === HOLE) continue;
array[i] = hydrate(n);
}
}
} else {
const object = {};
hydrated[index] = object;
for (const key of Object.keys(value)) {
if (key === "__proto__") {
throw new Error("Cannot parse an object with a `__proto__` property");
}
const n = value[key];
object[key] = hydrate(n);
}
}
return hydrated[index];
}
return hydrate(0);
}
// node_modules/devalue/src/stringify.js
function stringify(value, reducers) {
const stringified = [];
const indexes = /* @__PURE__ */ new Map();
const custom = [];
if (reducers) {
for (const key of Object.getOwnPropertyNames(reducers)) {
custom.push({ key, fn: reducers[key] });
}
}
const keys = [];
let p = 0;
function flatten(thing) {
if (thing === void 0) return UNDEFINED;
if (Number.isNaN(thing)) return NAN;
if (thing === Infinity) return POSITIVE_INFINITY;
if (thing === -Infinity) return NEGATIVE_INFINITY;
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
if (indexes.has(thing)) return indexes.get(thing);
const index2 = p++;
indexes.set(thing, index2);
for (const { key, fn } of custom) {
const value2 = fn(thing);
if (value2) {
stringified[index2] = `["${key}",${flatten(value2)}]`;
return index2;
}
}
if (typeof thing === "function") {
throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
}
let str = "";
if (is_primitive(thing)) {
str = stringify_primitive2(thing);
} else {
const type = get_type(thing);
switch (type) {
case "Number":
case "String":
case "Boolean":
str = `["Object",${stringify_primitive2(thing)}]`;
break;
case "BigInt":
str = `["BigInt",${thing}]`;
break;
case "Date":
const valid = !isNaN(thing.getDate());
str = `["Date","${valid ? thing.toISOString() : ""}"]`;
break;
case "URL":
str = `["URL",${stringify_string(thing.toString())}]`;
break;
case "URLSearchParams":
str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
break;
case "RegExp":
const { source, flags } = thing;
str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
break;
case "Array": {
let mostly_dense = false;
str = "[";
for (let i = 0; i < thing.length; i += 1) {
if (i > 0) str += ",";
if (Object.hasOwn(thing, i)) {
keys.push(`[${i}]`);
str += flatten(thing[i]);
keys.pop();
} else if (mostly_dense) {
str += HOLE;
} else {
const populated_keys = valid_array_indices(
/** @type {any[]} */
thing
);
const population = populated_keys.length;
const d = String(thing.length).length;
const hole_cost = (thing.length - population) * 3;
const sparse_cost = 4 + d + population * (d + 1);
if (hole_cost > sparse_cost) {
str = "[" + SPARSE + "," + thing.length;
for (let j = 0; j < populated_keys.length; j++) {
const key = populated_keys[j];
keys.push(`[${key}]`);
str += "," + key + "," + flatten(thing[key]);
keys.pop();
}
break;
} else {
mostly_dense = true;
str += HOLE;
}
}
}
str += "]";
break;
}
case "Set":
str = '["Set"';
for (const value2 of thing) {
str += `,${flatten(value2)}`;
}
str += "]";
break;
case "Map":
str = '["Map"';
for (const [key, value2] of thing) {
keys.push(
`.get(${is_primitive(key) ? stringify_primitive2(key) : "..."})`
);
str += `,${flatten(key)},${flatten(value2)}`;
keys.pop();
}
str += "]";
break;
case "Int8Array":
case "Uint8Array":
case "Uint8ClampedArray":
case "Int16Array":
case "Uint16Array":
case "Int32Array":
case "Uint32Array":
case "Float32Array":
case "Float64Array":
case "BigInt64Array":
case "BigUint64Array": {
const typedArray = thing;
str = '["' + type + '",' + flatten(typedArray.buffer);
const a = thing.byteOffset;
const b = a + thing.byteLength;
if (a > 0 || b !== typedArray.buffer.byteLength) {
const m = +/(\d+)/.exec(type)[1] / 8;
str += `,${a / m},${b / m}`;
}
str += "]";
break;
}
case "ArrayBuffer": {
const arraybuffer = thing;
const base64 = encode64(arraybuffer);
str = `["ArrayBuffer","${base64}"]`;
break;
}
case "Temporal.Duration":
case "Temporal.Instant":
case "Temporal.PlainDate":
case "Temporal.PlainTime":
case "Temporal.PlainDateTime":
case "Temporal.PlainMonthDay":
case "Temporal.PlainYearMonth":
case "Temporal.ZonedDateTime":
str = `["${type}",${stringify_string(thing.toString())}]`;
break;
default:
if (!is_plain_object(thing)) {
throw new DevalueError(
`Cannot stringify arbitrary non-POJOs`,
keys,
thing,
value
);
}
if (enumerable_symbols(thing).length > 0) {
throw new DevalueError(
`Cannot stringify POJOs with symbolic keys`,
keys,
thing,
value
);
}
if (Object.getPrototypeOf(thing) === null) {
str = '["null"';
for (const key of Object.keys(thing)) {
if (key === "__proto__") {
throw new DevalueError(
`Cannot stringify objects with __proto__ keys`,
keys,
thing,
value
);
}
keys.push(stringify_key(key));
str += `,${stringify_string(key)},${flatten(thing[key])}`;
keys.pop();
}
str += "]";
} else {
str = "{";
let started = false;
for (const key of Object.keys(thing)) {
if (key === "__proto__") {
throw new DevalueError(
`Cannot stringify objects with __proto__ keys`,
keys,
thing,
value
);
}
if (started) str += ",";
started = true;
keys.push(stringify_key(key));
str += `${stringify_string(key)}:${flatten(thing[key])}`;
keys.pop();
}
str += "}";
}
}
}
stringified[index2] = str;
return index2;
}
const index = flatten(value);
if (index < 0) return `${index}`;
return `[${stringified.join(",")}]`;
}
function stringify_primitive2(thing) {
const type = typeof thing;
if (type === "string") return stringify_string(thing);
if (thing instanceof String) return stringify_string(thing.toString());
if (thing === void 0) return UNDEFINED.toString();
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
if (type === "bigint") return `["BigInt","${thing}"]`;
return String(thing);
}
export {
DevalueError,
parse,
stringify,
uneval,
unflatten
};
//# sourceMappingURL=devalue.js.map