(_, inputs)
| 381 | } |
| 382 | |
| 383 | toJSON(_, inputs) { |
| 384 | let fixed = {} |
| 385 | let emitInputs = inputs == null |
| 386 | inputs = inputs || new Map() |
| 387 | let inputsNextIndex = 0 |
| 388 | |
| 389 | for (let name in this) { |
| 390 | if (!Object.prototype.hasOwnProperty.call(this, name)) { |
| 391 | /* c8 ignore next 2 */ |
| 392 | continue |
| 393 | } |
| 394 | if (name === 'parent' || name === 'proxyCache') continue |
| 395 | let value = this[name] |
| 396 | |
| 397 | if (Array.isArray(value)) { |
| 398 | fixed[name] = value.map(i => { |
| 399 | if (typeof i === 'object' && i.toJSON) { |
| 400 | return i.toJSON(null, inputs) |
| 401 | } else { |
| 402 | return i |
| 403 | } |
| 404 | }) |
| 405 | } else if (typeof value === 'object' && value.toJSON) { |
| 406 | fixed[name] = value.toJSON(null, inputs) |
| 407 | } else if (name === 'source') { |
| 408 | if (value == null) continue |
| 409 | let inputId = inputs.get(value.input) |
| 410 | if (inputId == null) { |
| 411 | inputId = inputsNextIndex |
| 412 | inputs.set(value.input, inputsNextIndex) |
| 413 | inputsNextIndex++ |
| 414 | } |
| 415 | fixed[name] = { |
| 416 | end: value.end, |
| 417 | inputId, |
| 418 | start: value.start |
| 419 | } |
| 420 | } else { |
| 421 | fixed[name] = value |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | if (emitInputs) { |
| 426 | fixed.inputs = [...inputs.keys()].map(input => input.toJSON()) |
| 427 | } |
| 428 | |
| 429 | return fixed |
| 430 | } |
| 431 | |
| 432 | toProxy() { |
| 433 | if (!this.proxyCache) { |
no test coverage detected