(data: any, replacer: (this: any, key: string, value: any) => any = null, space: number = null)
| 80 | } |
| 81 | |
| 82 | export function stringifyCircularAutoChunks(data: any, replacer: (this: any, key: string, value: any) => any = null, space: number = null) { |
| 83 | let result |
| 84 | try { |
| 85 | result = arguments.length === 1 |
| 86 | ? JSON.stringify(data) |
| 87 | : JSON.stringify(data, replacer, space) |
| 88 | } |
| 89 | catch (e) { |
| 90 | result = stringifyStrictCircularAutoChunks(data, replacer, space) |
| 91 | } |
| 92 | if (result.length > MAX_SERIALIZED_SIZE) { |
| 93 | const chunkCount = Math.ceil(result.length / MAX_SERIALIZED_SIZE) |
| 94 | const chunks = [] |
| 95 | for (let i = 0; i < chunkCount; i++) { |
| 96 | chunks.push(result.slice(i * MAX_SERIALIZED_SIZE, (i + 1) * MAX_SERIALIZED_SIZE)) |
| 97 | } |
| 98 | return chunks |
| 99 | } |
| 100 | return result |
| 101 | } |
| 102 | |
| 103 | export function parseCircularAutoChunks(data: any, reviver: (this: any, key: string, value: any) => any = null) { |
| 104 | if (Array.isArray(data)) { |
no test coverage detected