MCPcopy Index your code
hub / github.com/fastify/fast-json-stringify / buildConstSerializer

Function buildConstSerializer

index.js:1061–1086  ·  view source on GitHub ↗
(location, input)

Source from the content-addressed store, hash-verified

1059}
1060
1061function buildConstSerializer (location, input) {
1062 const schema = location.schema
1063 const type = schema.type
1064
1065 const hasNullType = Array.isArray(type) && type.includes('null')
1066
1067 let code = ''
1068
1069 if (hasNullType) {
1070 code += `
1071 if (${input} === null) {
1072 json += JSON_STR_NULL
1073 } else {
1074 `
1075 }
1076
1077 code += `json += '${JSON.stringify(schema.const).replace(SINGLE_TICK, "\\'")}'`
1078
1079 if (hasNullType) {
1080 code += `
1081 }
1082 `
1083 }
1084
1085 return code
1086}
1087
1088function buildAllOf (context, location, input) {
1089 const schema = location.schema

Callers 1

buildValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…