MCPcopy Create free account
hub / github.com/adobe/react-spectrum / cached

Function cached

packages/@react-aria/test-utils/src/utils.ts:24–36  ·  view source on GitHub ↗
(fn: () => boolean)

Source from the content-addressed store, hash-verified

22}
23
24function cached(fn: () => boolean) {
25 if (process.env.NODE_ENV === 'test') {
26 return fn;
27 }
28
29 let res: boolean | null = null;
30 return () => {
31 if (res == null) {
32 res = fn();
33 }
34 return res;
35 };
36}
37
38const isMac = cached(function () {
39 return testPlatform(/^Mac/i);

Callers 1

utils.tsFile · 0.70

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected