UNPKG

appium-uiautomator2-driver

Version:
26 lines 1.02 kB
"use strict"; // TODO(appium server 3.4.1+): Replace local `memoize` with imports from `appium/support` // once this driver declares that minimum server version. Object.defineProperty(exports, "__esModule", { value: true }); exports.memoize = memoize; /** * Creates a memoized version of a function. * * @param fn - Function to memoize * @param resolver - Optional cache key resolver. If omitted, the first argument is used as the cache key. * @returns Memoized function with a mutable `.cache` map (compatible with lodash-style cache resets in tests). */ function memoize(fn, resolver) { const memoizedFn = function (...args) { const key = resolver ? resolver.apply(this, args) : args[0]; if (memoizedFn.cache.has(key)) { return memoizedFn.cache.get(key); } const result = fn.apply(this, args); memoizedFn.cache.set(key, result); return result; }; memoizedFn.cache = new Map(); return memoizedFn; } //# sourceMappingURL=memoize.js.map