/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e634e55 | Cube Dev Team */
//#region src/tasty/utils/cache-wrapper.ts
/**
* Create a function that caches the result up to the limit.
*/
function cacheWrapper(handler, limit = 1e3) {
	let cache = {};
	let count = 0;
	return ((firstArg, secondArg) => {
		const key = typeof firstArg === "string" && secondArg == null ? firstArg : JSON.stringify([firstArg, secondArg]);
		if (!cache[key]) {
			if (count > limit) {
				cache = {};
				count = 0;
			}
			count++;
			cache[key] = secondArg == null ? handler(firstArg) : handler(firstArg, secondArg);
		}
		return cache[key];
	});
}

//#endregion
export { cacheWrapper };
//# sourceMappingURL=cache-wrapper.js.map