@@ -73,6 +73,7 @@ function build (schema, options) {
73
73
74
74
const context = {
75
75
functions : [ ] ,
76
+ functionsCounter : 0 ,
76
77
functionsNamesBySchema : new Map ( ) ,
77
78
options,
78
79
refResolver : new RefResolver ( ) ,
@@ -180,7 +181,6 @@ function build (schema, options) {
180
181
const contextFunc = new Function ( 'validator' , 'serializer' , contextFunctionCode )
181
182
const stringifyFunc = contextFunc ( validator , serializer )
182
183
183
- genFuncNameCounter = 0
184
184
return stringifyFunc
185
185
}
186
186
@@ -498,7 +498,7 @@ function buildObject (context, location) {
498
498
return context . functionsNamesBySchema . get ( schema )
499
499
}
500
500
501
- const functionName = generateFuncName ( )
501
+ const functionName = generateFuncName ( context )
502
502
context . functionsNamesBySchema . set ( schema , functionName )
503
503
504
504
let schemaRef = location . getSchemaRef ( )
@@ -543,7 +543,7 @@ function buildArray (context, location) {
543
543
return context . functionsNamesBySchema . get ( schema )
544
544
}
545
545
546
- const functionName = generateFuncName ( )
546
+ const functionName = generateFuncName ( context )
547
547
context . functionsNamesBySchema . set ( schema , functionName )
548
548
549
549
let schemaRef = location . getSchemaRef ( )
@@ -670,9 +670,8 @@ function buildArrayTypeCondition (type, accessor) {
670
670
return condition
671
671
}
672
672
673
- let genFuncNameCounter = 0
674
- function generateFuncName ( ) {
675
- return 'anonymous' + genFuncNameCounter ++
673
+ function generateFuncName ( context ) {
674
+ return 'anonymous' + context . functionsCounter ++
676
675
}
677
676
678
677
function buildMultiTypeSerializer ( context , location , input ) {
0 commit comments