(json: unknown)
| 331 | |
| 332 | // approximate, memoized per object |
| 333 | export const jsonLengthOf = (json: unknown): number => { |
| 334 | if (typeof json !== "object" || json === null) |
| 335 | return typeof json === "string" ? json.length + 2 : 5 |
| 336 | let length = jsonLengths.get(json) |
| 337 | if (length !== undefined) return length |
| 338 | length = 2 |
| 339 | let nests = false |
| 340 | for (const k in json) { |
| 341 | const v = (json as Dict)[k] |
| 342 | if (typeof v === "object" && v !== null) nests = true |
| 343 | length += k.length + 4 + jsonLengthOf(v) |
| 344 | } |
| 345 | if (nests) jsonLengths.set(json, length) |
| 346 | return length |
| 347 | } |
| 348 | |
| 349 | export const holdsSameChildren = (l: BaseNode, r: BaseNode): boolean => { |
| 350 | if (l.children.length !== r.children.length) return false |
no test coverage detected