node-ejs-renderer/node_modules/@jsonjoy.com/util/lib/codegen/switch.js

16 lines
504 B
JavaScript
Raw Normal View History

2024-06-09 13:55:01 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSwitch = void 0;
const dynamicFunction_1 = require("./dynamicFunction");
const createSwitch = (fn, codegen) => {
let counter = 0;
const [proxy, set] = (0, dynamicFunction_1.dynamicFunction)((...args) => {
if (counter > 2)
set(codegen());
counter++;
return fn(...args);
});
return proxy;
};
exports.createSwitch = createSwitch;
//# sourceMappingURL=switch.js.map