UNPKG

e2ed

Version:

E2E testing framework over Playwright

22 lines (21 loc) 637 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getKeysCounter = void 0; const asserts_1 = require("./asserts"); /** * Returns a function that takes a key and returns * the number of function calls with that key. */ const getKeysCounter = () => { const cache = Object.create(null); return (key) => { if (!(key in cache)) { cache[key] = 0; } cache[key] += 1; const count = cache[key]; (0, asserts_1.assertValueIsDefined)(count, 'count is defined', { cache, key }); return count; }; }; exports.getKeysCounter = getKeysCounter;