• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

variablesoftware / mock-kv / 15423235867

03 Jun 2025 04:55PM UTC coverage: 100.0%. Remained the same
15423235867

push

github

web-flow
Merge pull request #19 from variablesoftware/dependabot/npm_and_yarn/variablesoftware/logface-0.5.2

81 of 81 branches covered (100.0%)

Branch coverage included in aggregate %.

188 of 188 relevant lines covered (100.0%)

337.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/mockKVNamespace/methods/getWithMetadata.ts
1
import type { KVMap } from "../../types/MockKVNamespace";
2
import logface from "@variablesoftware/logface";
1✔
3

4
export function getWithMetadataHandler(data: KVMap) {
1✔
5
  return async (
623✔
6
    key: string,
51✔
7
    opts?: { type?: "text" | "json" }
51✔
8
  ): Promise<{ value: string | Record<string, unknown> | unknown[] | null, metadata: unknown } | null> => {
51✔
9
    const entry = data[key];
51✔
10
    const now = Date.now();
51✔
11
    logface.debug('getWithMetadata("%s") → checking entry', key);
51✔
12
    if (!entry || (entry.expiresAt !== undefined && entry.expiresAt < now)) {
51✔
13
      logface.debug('getWithMetadata("%s") → expired or missing', key);
3✔
14
      delete data[key];
3✔
15
      return null;
3✔
16
    }
3✔
17
    const raw = entry.value;
48✔
18
    let value: string | Record<string, unknown> | unknown[] | null = raw;
48✔
19
    if (opts?.type === "json") {
51✔
20
      try {
2✔
21
        value = JSON.parse(raw);
2✔
22
        logface.debug('getWithMetadata("%s") → parsed JSON', key);
2✔
23
      } catch {
2✔
24
        logface.warn('getWithMetadata("%s") → invalid JSON', key);
1✔
25
        value = null;
1✔
26
      }
1✔
27
    }
2✔
28
    return { value, metadata: entry.metadata ?? null };
51✔
29
  };
51✔
30
}
623✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc