@@ -70,17 +70,15 @@ function resolveRef (location, ref) {
70
70
return { schema, schemaId, jsonPointer }
71
71
}
72
72
73
- const arrayItemsReferenceSerializersMap = new Map ( )
74
- const objectReferenceSerializersMap = new Map ( )
73
+ const contextFunctionsNamesBySchema = new Map ( )
75
74
76
75
let rootSchemaId = null
77
76
let refResolver = null
78
77
let validator = null
79
78
let contextFunctions = null
80
79
81
80
function build ( schema , options ) {
82
- arrayItemsReferenceSerializersMap . clear ( )
83
- objectReferenceSerializersMap . clear ( )
81
+ contextFunctionsNamesBySchema . clear ( )
84
82
85
83
contextFunctions = [ ]
86
84
options = options || { }
@@ -168,8 +166,7 @@ function build (schema, options) {
168
166
validator = null
169
167
rootSchemaId = null
170
168
contextFunctions = null
171
- arrayItemsReferenceSerializersMap . clear ( )
172
- objectReferenceSerializersMap . clear ( )
169
+ contextFunctionsNamesBySchema . clear ( )
173
170
174
171
return stringifyFunc
175
172
}
@@ -542,12 +539,12 @@ function toJSON (variableName) {
542
539
function buildObject ( location ) {
543
540
const schema = location . schema
544
541
545
- if ( objectReferenceSerializersMap . has ( schema ) ) {
546
- return objectReferenceSerializersMap . get ( schema )
542
+ if ( contextFunctionsNamesBySchema . has ( schema ) ) {
543
+ return contextFunctionsNamesBySchema . get ( schema )
547
544
}
548
545
549
546
const functionName = generateFuncName ( )
550
- objectReferenceSerializersMap . set ( schema , functionName )
547
+ contextFunctionsNamesBySchema . set ( schema , functionName )
551
548
552
549
const schemaId = location . schemaId === rootSchemaId ? '' : location . schemaId
553
550
let functionCode = `
@@ -589,12 +586,12 @@ function buildArray (location) {
589
586
590
587
const itemsSchema = itemsLocation . schema
591
588
592
- if ( arrayItemsReferenceSerializersMap . has ( itemsSchema ) ) {
593
- return arrayItemsReferenceSerializersMap . get ( itemsSchema )
589
+ if ( contextFunctionsNamesBySchema . has ( schema ) ) {
590
+ return contextFunctionsNamesBySchema . get ( schema )
594
591
}
595
592
596
593
const functionName = generateFuncName ( )
597
- arrayItemsReferenceSerializersMap . set ( itemsSchema , functionName )
594
+ contextFunctionsNamesBySchema . set ( schema , functionName )
598
595
599
596
const schemaId = location . schemaId === rootSchemaId ? '' : location . schemaId
600
597
let functionCode = `
0 commit comments