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

Function decode

out/cli.cjs:2221–2293  ·  view source on GitHub ↗
(str2)

Source from the content-addressed store, hash-verified

2219 };
2220 var dotSplit = (str2) => str2.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map((part) => part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, ""));
2221 var decode = (str2) => {
2222 const out = /* @__PURE__ */ Object.create(null);
2223 let p4 = out;
2224 let section = null;
2225 const re3 = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
2226 const lines = str2.split(/[\r\n]+/g);
2227 for (const line of lines) {
2228 if (!line || line.match(/^\s*[;#]/)) {
2229 continue;
2230 }
2231 const match = line.match(re3);
2232 if (!match) {
2233 continue;
2234 }
2235 if (match[1] !== void 0) {
2236 section = unsafe(match[1]);
2237 if (section === "__proto__") {
2238 p4 = /* @__PURE__ */ Object.create(null);
2239 continue;
2240 }
2241 p4 = out[section] = out[section] || /* @__PURE__ */ Object.create(null);
2242 continue;
2243 }
2244 const keyRaw = unsafe(match[2]);
2245 const isArray2 = keyRaw.length > 2 && keyRaw.slice(-2) === "[]";
2246 const key = isArray2 ? keyRaw.slice(0, -2) : keyRaw;
2247 if (key === "__proto__") {
2248 continue;
2249 }
2250 const valueRaw = match[3] ? unsafe(match[4]) : true;
2251 const value = valueRaw === "true" || valueRaw === "false" || valueRaw === "null" ? JSON.parse(valueRaw) : valueRaw;
2252 if (isArray2) {
2253 if (!hasOwnProperty2.call(p4, key)) {
2254 p4[key] = [];
2255 } else if (!Array.isArray(p4[key])) {
2256 p4[key] = [p4[key]];
2257 }
2258 }
2259 if (Array.isArray(p4[key])) {
2260 p4[key].push(value);
2261 } else {
2262 p4[key] = value;
2263 }
2264 }
2265 const remove = [];
2266 for (const k7 of Object.keys(out)) {
2267 if (!hasOwnProperty2.call(out, k7) || typeof out[k7] !== "object" || Array.isArray(out[k7])) {
2268 continue;
2269 }
2270 const parts = dotSplit(k7);
2271 p4 = out;
2272 const l3 = parts.pop();
2273 const nl = l3.replace(/\\\./g, ".");
2274 for (const part of parts) {
2275 if (part === "__proto__") {
2276 continue;
2277 }
2278 if (!hasOwnProperty2.call(p4, part) || typeof p4[part] !== "object") {

Callers 2

toUnicodeFunction · 0.85
packageDataFunction · 0.85

Calls 14

unsafeFunction · 0.85
dotSplitFunction · 0.85
errorFunction · 0.85
basicToDigitFunction · 0.85
adaptFunction · 0.85
combineByteSequencesFunction · 0.85
BOMSniffingFunction · 0.85
createMethod · 0.45
matchMethod · 0.45
sliceMethod · 0.45
parseMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…