MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / parseKittyImageHeader

Function parseKittyImageHeader

packages/pi-tui/src/tui.ts:35–58  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

33}
34
35function parseKittyImageHeader(line: string): KittyImageHeader | undefined {
36 const sequenceStart = line.indexOf(KITTY_SEQUENCE_PREFIX);
37 if (sequenceStart === -1) return undefined;
38
39 const paramsStart = sequenceStart + KITTY_SEQUENCE_PREFIX.length;
40 const paramsEnd = line.indexOf(";", paramsStart);
41 if (paramsEnd === -1) return undefined;
42
43 const ids: number[] = [];
44 let rows = 1;
45 const params = line.slice(paramsStart, paramsEnd);
46 for (const param of params.split(",")) {
47 const [key, value] = param.split("=", 2);
48 if (value === undefined) continue;
49 const numberValue = Number(value);
50 if (!Number.isInteger(numberValue) || numberValue <= 0 || numberValue > 0xffffffff) continue;
51 if (key === "i") {
52 ids.push(numberValue);
53 } else if (key === "r") {
54 rows = numberValue;
55 }
56 }
57 return { ids, rows };
58}
59
60function extractKittyImageIds(line: string): number[] {
61 return parseKittyImageHeader(line)?.ids ?? [];

Callers 2

extractKittyImageIdsFunction · 0.85
extractKittyImageRowsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected