MCPcopy Create free account
hub / github.com/code-pushup/cli / stringCodec

Function stringCodec

packages/utils/src/lib/wal.ts:287–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

285};
286
287export const stringCodec = <
288 T extends string | object = string,
289>(): Codec<T> => ({
290 encode: v => (typeof v === 'string' ? v : JSON.stringify(v)),
291 decode: v => {
292 try {
293 return JSON.parse(v) as T;
294 } catch {
295 return v as T;
296 }
297 },
298});
299
300/**
301 * Parses a partial WalFormat configuration and returns a complete WalFormat object.

Callers 6

wal.int.test.tsFile · 0.85
parseWalFormatFunction · 0.85
walFunction · 0.85
wal.unit.test.tsFile · 0.85
makeMockFormatFunction · 0.85

Calls

no outgoing calls

Tested by 2

walFunction · 0.68
makeMockFormatFunction · 0.68