(fn: () => boolean)
| 29 | } |
| 30 | |
| 31 | function 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 | |
| 45 | export const isMac: () => boolean = cached(function () { |
| 46 | return testPlatform(/^Mac/i); |