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

Function encodeLabel

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

Source from the content-addressed store, hash-verified

33121 return out;
33122 }
33123 function encodeLabel(key, value, options) {
33124 let out = "";
33125 const pairs = (options === null || options === void 0 ? void 0 : options.explode) ? explode(key, value) : [[key, value]];
33126 const encodeString = (v5) => {
33127 return (options === null || options === void 0 ? void 0 : options.charEncoding) === "percent" ? encodeURIComponent(v5) : v5;
33128 };
33129 const encodeValue = (v5) => encodeString(serializeValue(v5));
33130 pairs.forEach(([pk, pv]) => {
33131 let encValue = "";
33132 if (pv === void 0) {
33133 return;
33134 } else if (Array.isArray(pv)) {
33135 encValue = mapDefined(pv, (v5) => `${encodeValue(v5)}`).join(".");
33136 } else if ((0, is_plain_object_js_1.isPlainObject)(pv)) {
33137 encValue = mapDefinedEntries(Object.entries(pv), ([k7, v5]) => {
33138 return `.${encodeString(k7)}.${encodeValue(v5)}`;
33139 }).join("");
33140 encValue = encValue.slice(1);
33141 } else {
33142 const k7 = (options === null || options === void 0 ? void 0 : options.explode) && (0, is_plain_object_js_1.isPlainObject)(value) ? `${encodeString(pk)}=` : "";
33143 encValue = `${k7}${encodeValue(pv)}`;
33144 }
33145 out += `.${encValue}`;
33146 });
33147 return out;
33148 }
33149 function formEncoder(sep) {
33150 return (key, value, options) => {
33151 let out = "";

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…