MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / accumulateDelta

Method accumulateDelta

out/cli.cjs:83188–83220  ·  view source on GitHub ↗
(acc, delta)

Source from the content-addressed store, hash-verified

83186 for await (const event of stream4) {
83187 __classPrivateFieldGet12(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
83188 }
83189 if (stream4.controller.signal?.aborted) {
83190 throw new APIUserAbortError3();
83191 }
83192 return this._addRun(__classPrivateFieldGet12(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
83193 }
83194 static accumulateDelta(acc, delta) {
83195 for (const [key, deltaValue] of Object.entries(delta)) {
83196 if (!acc.hasOwnProperty(key)) {
83197 acc[key] = deltaValue;
83198 continue;
83199 }
83200 let accValue = acc[key];
83201 if (accValue === null || accValue === void 0) {
83202 acc[key] = deltaValue;
83203 continue;
83204 }
83205 if (key === "index" || key === "type") {
83206 acc[key] = deltaValue;
83207 continue;
83208 }
83209 if (typeof accValue === "string" && typeof deltaValue === "string") {
83210 accValue += deltaValue;
83211 } else if (typeof accValue === "number" && typeof deltaValue === "number") {
83212 accValue += deltaValue;
83213 } else if (isObj(accValue) && isObj(deltaValue)) {
83214 accValue = this.accumulateDelta(accValue, deltaValue);
83215 } else if (Array.isArray(accValue) && Array.isArray(deltaValue)) {
83216 if (accValue.every((x5) => typeof x5 === "string" || typeof x5 === "number")) {
83217 accValue.push(...deltaValue);
83218 continue;
83219 }
83220 } else {
83221 throw Error(`Unhandled record type: ${key}, deltaValue: ${deltaValue}, accValue: ${accValue}`);
83222 }
83223 acc[key] = accValue;

Callers 1

cli.cjsFile · 0.80

Calls 3

isObjFunction · 0.85
entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected