MCPcopy
hub / github.com/di-sukharev/opencommit / encodeSimple

Function encodeSimple

out/cli.cjs:33260–33288  ·  view source on GitHub ↗
(key, value, options)

Source from the content-addressed store, hash-verified

33258 return (options === null || options === void 0 ? void 0 : options.explode) ? encVal : `${encodeString(key)}=${encVal}`;
33259 }
33260 var encodeSimple = (key, value, options) => {
33261 let out = "";
33262 const pairs = (options === null || options === void 0 ? void 0 : options.explode) ? explode(key, value) : [[key, value]];
33263 const encodeString = (v5) => {
33264 return (options === null || options === void 0 ? void 0 : options.charEncoding) === "percent" ? encodeURIComponent(v5) : v5;
33265 };
33266 const encodeValue = (v5) => encodeString(serializeValue(v5));
33267 pairs.forEach(([pk, pv]) => {
33268 let tmp = "";
33269 if (pv === void 0) {
33270 return;
33271 } else if (Array.isArray(pv)) {
33272 tmp = mapDefined(pv, (v5) => `${encodeValue(v5)}`).join(",");
33273 } else if ((0, is_plain_object_js_1.isPlainObject)(pv)) {
33274 tmp = mapDefinedEntries(Object.entries(pv), ([k7, v5]) => {
33275 return `,${encodeString(k7)},${encodeValue(v5)}`;
33276 }).join("");
33277 tmp = tmp.slice(1);
33278 } else {
33279 const k7 = (options === null || options === void 0 ? void 0 : options.explode) && (0, is_plain_object_js_1.isPlainObject)(value) ? `${pk}=` : "";
33280 tmp = `${k7}${encodeValue(pv)}`;
33281 }
33282 if (!tmp) {
33283 return;
33284 }
33285 out += `,${tmp}`;
33286 });
33287 return out.slice(1);
33288 };
33289 exports2.encodeSimple = encodeSimple;
33290 function explode(key, value) {
33291 if (Array.isArray(value)) {

Callers

nothing calls this directly

Calls 8

explodeFunction · 0.85
mapDefinedFunction · 0.85
encodeValueFunction · 0.85
mapDefinedEntriesFunction · 0.85
encodeStringFunction · 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…