Skip to content

Commit

Permalink
fix(useFps,useMemory): ssr support (vitest-dev#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz committed Feb 13, 2022
1 parent 8d190ae commit 0e1e211
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/core/useFps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface UseFpsOptions {

export function useFps(options?: UseFpsOptions): Ref<number> {
const fps = ref(0)
if (typeof performance === 'undefined')
return fps
const every = options?.every ?? 10

let last = performance.now()
Expand Down
2 changes: 1 addition & 1 deletion packages/core/useMemory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type PerformanceMemory = Performance & {
*/
export function useMemory(options: MemoryOptions = {}) {
const memory = ref<MemoryInfo>()
const isSupported = performance && 'memory' in performance
const isSupported = typeof performance !== 'undefined' && 'memory' in performance

if (isSupported) {
const { interval = 1000 } = options
Expand Down

0 comments on commit 0e1e211

Please sign in to comment.