MCPcopy
hub / github.com/adobe/react-spectrum / cached

Function cached

packages/react-aria/src/utils/platform.ts:31–43  ·  view source on GitHub ↗
(fn: () => boolean)

Source from the content-addressed store, hash-verified

29}
30
31function cached(fn: () => boolean) {
32 if (process.env.NODE_ENV === 'test') {
33 return fn;
34 }
35
36 let res: boolean | null = null;
37 return () => {
38 if (res == null) {
39 res = fn();
40 }
41 return res;
42 };
43}
44
45export const isMac: () => boolean = cached(function () {
46 return testPlatform(/^Mac/i);

Callers 1

platform.tsFile · 0.70

Calls 1

fnFunction · 0.85

Tested by

no test coverage detected