(v: unknown)
| 245 | /^(?:"|\$ark\d*\.|(?:NaN|-?Infinity|-0|-?\d+n|undefined|Invalid Date|[+-]?\d{4,6}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z)$)/ |
| 246 | |
| 247 | export const defaultValueSerializer = (v: unknown): Json => { |
| 248 | if (typeof v === "string") |
| 249 | return ambiguousStringPattern.test(v) ? JSON.stringify(v) : v |
| 250 | if (typeof v === "boolean" || v === null) return v |
| 251 | |
| 252 | if (typeof v === "number") { |
| 253 | if (Number.isNaN(v)) return "NaN" |
| 254 | if (v === Number.POSITIVE_INFINITY) return "Infinity" |
| 255 | if (v === Number.NEGATIVE_INFINITY) return "-Infinity" |
| 256 | if (Object.is(v, -0)) return "-0" |
| 257 | return v |
| 258 | } |
| 259 | |
| 260 | // registering would keep the value alive, so only values compiled code reads are registered |
| 261 | return hasDomain(v, "object") || typeof v === "symbol" ? |
| 262 | namedReference(v) |
| 263 | : serializePrimitive(v as never) |
| 264 | } |
| 265 | |
| 266 | export const metaJsonOf = (meta: ArkEnv.meta): JsonObject => |
| 267 | flatMorph(meta, (k, v) => [ |
no test coverage detected