UNPKG

fast-check

Version:

Property based testing framework for JavaScript (like QuickCheck)

21 lines (20 loc) 582 B
const depthContextCache = new Map(); export function getDepthContextFor(contextMeta) { if (contextMeta === undefined) { return { depth: 0 }; } if (typeof contextMeta !== 'string') { return contextMeta; } const cachedContext = depthContextCache.get(contextMeta); if (cachedContext !== undefined) { return cachedContext; } const context = { depth: 0 }; depthContextCache.set(contextMeta, context); return context; } export function createDepthIdentifier() { const identifier = { depth: 0 }; return identifier; }