MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / formEncoder

Function formEncoder

out/cli.cjs:33149–33180  ·  view source on GitHub ↗
(sep)

Source from the content-addressed store, hash-verified

33147 return out;
33148 }
33149 function formEncoder(sep) {
33150 return (key, value, options) => {
33151 let out = "";
33152 const pairs = (options === null || options === void 0 ? void 0 : options.explode) ? explode(key, value) : [[key, value]];
33153 const encodeString = (v5) => {
33154 return (options === null || options === void 0 ? void 0 : options.charEncoding) === "percent" ? encodeURIComponent(v5) : v5;
33155 };
33156 const encodeValue = (v5) => encodeString(serializeValue(v5));
33157 const encodedSep = encodeString(sep);
33158 pairs.forEach(([pk, pv]) => {
33159 let tmp = "";
33160 let encValue = "";
33161 if (pv === void 0) {
33162 return;
33163 } else if (Array.isArray(pv)) {
33164 encValue = mapDefined(pv, (v5) => `${encodeValue(v5)}`).join(encodedSep);
33165 } else if ((0, is_plain_object_js_1.isPlainObject)(pv)) {
33166 encValue = mapDefinedEntries(Object.entries(pv), ([k7, v5]) => {
33167 return `${encodeString(k7)}${encodedSep}${encodeValue(v5)}`;
33168 }).join(encodedSep);
33169 } else {
33170 encValue = `${encodeValue(pv)}`;
33171 }
33172 tmp = `${encodeString(pk)}=${encValue}`;
33173 if (!tmp || tmp === "=") {
33174 return;
33175 }
33176 out += `&${tmp}`;
33177 });
33178 return out.slice(1);
33179 };
33180 }
33181 exports2.encodeForm = formEncoder(",");
33182 exports2.encodeSpaceDelimited = formEncoder(" ");
33183 exports2.encodePipeDelimited = formEncoder("|");

Calls 8

explodeFunction · 0.85
encodeStringFunction · 0.85
mapDefinedFunction · 0.85
encodeValueFunction · 0.85
mapDefinedEntriesFunction · 0.85
forEachMethod · 0.45
entriesMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…