Download packages/agent-core-v2/src/app/config/sectionDiff.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/config/sectionDiff.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/app/config/sectionDiff.ts
-
curl -L -o sectionDiff.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/config/sectionDiff.ts
1.38 kB
| export interface RecordDiff { | |
| readonly added: readonly string[]; | |
| readonly removed: readonly string[]; | |
| readonly changed: readonly string[]; | |
| } | |
| export function diffRecords<T>( | |
| previous: Readonly<Record<string, T>> | undefined, | |
| current: Readonly<Record<string, T>> | undefined, | |
| ): RecordDiff { | |
| const prev = previous ?? {}; | |
| const curr = current ?? {}; | |
| const added: string[] = []; | |
| const removed: string[] = []; | |
| const changed: string[] = []; | |
| for (const key of Object.keys(curr)) { | |
| if (!(key in prev)) { | |
| added.push(key); | |
| } else if (!deepEqual(prev[key], curr[key])) { | |
| changed.push(key); | |
| } | |
| } | |
| for (const key of Object.keys(prev)) { | |
| if (!(key in curr)) { | |
| removed.push(key); | |
| } | |
| } | |
| return { added, removed, changed }; | |
| } | |
| export function deepEqual(a: unknown, b: unknown): boolean { | |
| if (Object.is(a, b)) return true; | |
| if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false; | |
| if (Array.isArray(a) !== Array.isArray(b)) return false; | |
| const aKeys = Object.keys(a); | |
| const bKeys = Object.keys(b); | |
| if (aKeys.length !== bKeys.length) return false; | |
| for (const key of aKeys) { | |
| if (!Object.prototype.hasOwnProperty.call(b, key)) return false; | |
| if (!deepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |