⬅️ Back to Table of Contents
📄 index.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
1 |
📦 Imports |
4 |
📐 Interfaces |
2 |
📑 Type Aliases |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/core/useMemory/index.ts
📦 Imports
Name |
Source |
UseIntervalFnOptions |
@vueuse/shared |
useIntervalFn |
@vueuse/shared |
deepRef |
vue |
useSupported |
../useSupported |
Functions
useMemory(options: UseMemoryOptions): { isSupported: any; memory: any; }
Code
export function useMemory(options: UseMemoryOptions = {}) {
const memory = deepRef<MemoryInfo>()
const isSupported = useSupported(() => typeof performance !== 'undefined' && 'memory' in performance)
if (isSupported.value) {
const { interval = 1000 } = options
useIntervalFn(() => {
memory.value = (performance as PerformanceMemory).memory
}, interval, { immediate: options.immediate, immediateCallback: options.immediateCallback })
}
return { isSupported, memory }
}
-
JSDoc:
/**
* Reactive Memory Info.
*
* @see https://vueuse.org/useMemory
* @param options
*/
-
Parameters:
options: UseMemoryOptions
- Return Type:
{ isSupported: any; memory: any; }
- Calls:
deepRef (from vue)
useSupported (from ../useSupported)
useIntervalFn (from @vueuse/shared)
Interfaces
MemoryInfo
Interface Code
export interface MemoryInfo {
/**
* The maximum size of the heap, in bytes, that is available to the context.
*/
readonly jsHeapSizeLimit: number
/**
* The total allocated heap size, in bytes.
*/
readonly totalJSHeapSize: number
/**
* The currently active segment of JS heap, in bytes.
*/
readonly usedJSHeapSize: number
[Symbol.toStringTag]: 'MemoryInfo'
}
Properties
Name |
Type |
Optional |
Description |
jsHeapSizeLimit |
number |
✗ |
|
totalJSHeapSize |
number |
✗ |
|
usedJSHeapSize |
number |
✗ |
|
[Symbol.toStringTag] |
'MemoryInfo' |
✗ |
|
UseMemoryOptions
Interface Code
export interface UseMemoryOptions extends UseIntervalFnOptions {
interval?: number
}
Properties
Name |
Type |
Optional |
Description |
interval |
number |
✓ |
|
Type Aliases
type PerformanceMemory = Performance & {
memory: MemoryInfo
};
UseMemoryReturn
type UseMemoryReturn = ReturnType<typeof useMemory>;