MCPcopy Index your code
hub / github.com/dataease/SQLBot / formatKeyValue

Function formatKeyValue

frontend/public/swagger-ui-bundle.js:41538–41585  ·  view source on GitHub ↗
(s, o, i = !1)

Source from the content-addressed store, hash-verified

41536 }
41537 const ru = { form: ',', spaceDelimited: '%20', pipeDelimited: '|' },
41538 nu = { csv: ',', ssv: '%20', tsv: '%09', pipes: '|' }
41539 function formatKeyValue(s, o, i = !1) {
41540 const {
41541 collectionFormat: a,
41542 allowEmptyValue: u,
41543 serializationOption: _,
41544 encoding: w,
41545 } = o,
41546 x = 'object' != typeof o || Array.isArray(o) ? o : o.value,
41547 C = i ? (s) => s.toString() : (s) => encodeURIComponent(s),
41548 j = C(s)
41549 if (void 0 === x && u) return [[j, '']]
41550 if (isFile(x) || isArrayOfFile(x)) return [[j, x]]
41551 if (_) return formatKeyValueBySerializationOption(s, x, i, _)
41552 if (w) {
41553 if (
41554 [typeof w.style, typeof w.explode, typeof w.allowReserved].some(
41555 (s) => 'undefined' !== s
41556 )
41557 ) {
41558 const { style: o, explode: a, allowReserved: u } = w
41559 return formatKeyValueBySerializationOption(s, x, i, {
41560 style: o,
41561 explode: a,
41562 allowReserved: u,
41563 })
41564 }
41565 if ('string' == typeof w.contentType) {
41566 if (w.contentType.startsWith('application/json')) {
41567 const s = C('string' == typeof x ? x : JSON.stringify(x))
41568 return [[j, new FileWithData(s, 'blob', { type: w.contentType })]]
41569 }
41570 const s = C(String(x))
41571 return [[j, new FileWithData(s, 'blob', { type: w.contentType })]]
41572 }
41573 return 'object' != typeof x
41574 ? [[j, C(x)]]
41575 : Array.isArray(x) && x.every((s) => 'object' != typeof s)
41576 ? [[j, x.map(C).join(',')]]
41577 : [[j, C(JSON.stringify(x))]]
41578 }
41579 return 'object' != typeof x
41580 ? [[j, C(x)]]
41581 : Array.isArray(x)
41582 ? 'multi' === a
41583 ? [[j, x.map(C)]]
41584 : [[j, x.map(C).join(nu[a || 'csv'])]]
41585 : [[j, '']]
41586 }
41587 function formatKeyValueBySerializationOption(s, o, i, a) {
41588 const u = a.style || 'form',

Callers 2

encodeFormOrQueryFunction · 0.85
serializeRequestFunction · 0.85

Calls 8

isFileFunction · 0.85
isArrayOfFileFunction · 0.85
CFunction · 0.70
isArrayMethod · 0.45
toStringMethod · 0.45
someMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected