(context, schema, schemaId)
| 512 | } |
| 513 | |
| 514 | function cloneOriginSchema (context, schema, schemaId) { |
| 515 | const clonedSchema = Array.isArray(schema) ? [] : {} |
| 516 | |
| 517 | if ( |
| 518 | schema.$id !== undefined && |
| 519 | schema.$id.charAt(0) !== '#' |
| 520 | ) { |
| 521 | schemaId = schema.$id |
| 522 | } |
| 523 | |
| 524 | const mergedSchemaRef = context.mergedSchemasIds.get(schema) |
| 525 | if (mergedSchemaRef) { |
| 526 | context.mergedSchemasIds.set(clonedSchema, mergedSchemaRef) |
| 527 | } |
| 528 | |
| 529 | for (const key in schema) { |
| 530 | let value = schema[key] |
| 531 | |
| 532 | if (key === '$ref' && typeof value === 'string' && value.charAt(0) === '#') { |
| 533 | value = schemaId + value |
| 534 | } |
| 535 | |
| 536 | if (typeof value === 'object' && value !== null) { |
| 537 | value = cloneOriginSchema(context, value, schemaId) |
| 538 | } |
| 539 | |
| 540 | clonedSchema[key] = value |
| 541 | } |
| 542 | |
| 543 | return clonedSchema |
| 544 | } |
| 545 | |
| 546 | function toJSON (variableName) { |
| 547 | return `(${variableName} && typeof ${variableName}.toJSON === 'function') |
no outgoing calls
no test coverage detected
searching dependent graphs…