@@ -70,17 +70,15 @@ function resolveRef (location, ref) {
7070 return { schema, schemaId, jsonPointer }
7171}
7272
73- const arrayItemsReferenceSerializersMap = new Map ( )
74- const objectReferenceSerializersMap = new Map ( )
73+ const contextFunctionsNamesBySchema = new Map ( )
7574
7675let rootSchemaId = null
7776let refResolver = null
7877let validator = null
7978let contextFunctions = null
8079
8180function build ( schema , options ) {
82- arrayItemsReferenceSerializersMap . clear ( )
83- objectReferenceSerializersMap . clear ( )
81+ contextFunctionsNamesBySchema . clear ( )
8482
8583 contextFunctions = [ ]
8684 options = options || { }
@@ -168,8 +166,7 @@ function build (schema, options) {
168166 validator = null
169167 rootSchemaId = null
170168 contextFunctions = null
171- arrayItemsReferenceSerializersMap . clear ( )
172- objectReferenceSerializersMap . clear ( )
169+ contextFunctionsNamesBySchema . clear ( )
173170
174171 return stringifyFunc
175172}
@@ -542,12 +539,12 @@ function toJSON (variableName) {
542539function buildObject ( location ) {
543540 const schema = location . schema
544541
545- if ( objectReferenceSerializersMap . has ( schema ) ) {
546- return objectReferenceSerializersMap . get ( schema )
542+ if ( contextFunctionsNamesBySchema . has ( schema ) ) {
543+ return contextFunctionsNamesBySchema . get ( schema )
547544 }
548545
549546 const functionName = generateFuncName ( )
550- objectReferenceSerializersMap . set ( schema , functionName )
547+ contextFunctionsNamesBySchema . set ( schema , functionName )
551548
552549 const schemaId = location . schemaId === rootSchemaId ? '' : location . schemaId
553550 let functionCode = `
@@ -589,12 +586,12 @@ function buildArray (location) {
589586
590587 const itemsSchema = itemsLocation . schema
591588
592- if ( arrayItemsReferenceSerializersMap . has ( itemsSchema ) ) {
593- return arrayItemsReferenceSerializersMap . get ( itemsSchema )
589+ if ( contextFunctionsNamesBySchema . has ( schema ) ) {
590+ return contextFunctionsNamesBySchema . get ( schema )
594591 }
595592
596593 const functionName = generateFuncName ( )
597- arrayItemsReferenceSerializersMap . set ( itemsSchema , functionName )
594+ contextFunctionsNamesBySchema . set ( schema , functionName )
598595
599596 const schemaId = location . schemaId === rootSchemaId ? '' : location . schemaId
600597 let functionCode = `
0 commit comments