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

Function encodeMatrix

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

Source from the content-addressed store, hash-verified

33087 };
33088 exports2.EncodingError = EncodingError;
33089 function encodeMatrix(key, value, options) {
33090 let out = "";
33091 const pairs = (options === null || options === void 0 ? void 0 : options.explode) ? explode(key, value) : [[key, value]];
33092 const encodeString = (v5) => {
33093 return (options === null || options === void 0 ? void 0 : options.charEncoding) === "percent" ? encodeURIComponent(v5) : v5;
33094 };
33095 const encodeValue = (v5) => encodeString(serializeValue(v5));
33096 pairs.forEach(([pk, pv]) => {
33097 let tmp = "";
33098 let encValue = "";
33099 if (pv === void 0) {
33100 return;
33101 } else if (Array.isArray(pv)) {
33102 encValue = mapDefined(pv, (v5) => `${encodeValue(v5)}`).join(",");
33103 } else if ((0, is_plain_object_js_1.isPlainObject)(pv)) {
33104 encValue = mapDefinedEntries(Object.entries(pv), ([k7, v5]) => {
33105 return `,${encodeString(k7)},${encodeValue(v5)}`;
33106 }).join("");
33107 encValue = encValue.slice(1);
33108 } else {
33109 encValue = `${encodeValue(pv)}`;
33110 }
33111 const keyPrefix = encodeString(pk);
33112 tmp = `${keyPrefix}=${encValue}`;
33113 if (tmp === `${keyPrefix}=`) {
33114 tmp = tmp.slice(0, -1);
33115 }
33116 if (!tmp) {
33117 return;
33118 }
33119 out += `;${tmp}`;
33120 });
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]];

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…