1.0.2 • Published 2 years ago
react-native-ram v1.0.2
react-native-ram
A react-native module to get device RAM
Installation
Using npm:
npm install react-native-ram
or using yarn:
yarn add react-native-ram
Usage
import { getAllRamInfo } from "react-native-ram";
React.useEffect(()=>{
getAllRamInfo().then(( ramInfo )=> console.log(ramInfo))
},[])
#### OR use async/await
const getRam=async()=>{
const ramInfo = await getAllRamInfo();
console.log(ramInfo)
}
// ...result example in MB and %
{
"appUsedMemory": 12.637718200683594,
"percentageUsed": 48.736824388734746,
"usedMemory": 2726.0390625,
"availableMemory": 2867.34765625,
"totalMemory": 5593.38671875,
"percentageAvailable": 51.263175611265254
}
API
Method | Return Type | iOS | Android |
---|---|---|---|
getAllRamInfo() | Promise<RamState> | ✅ | ✅ |
getTotalRam() | Promise<number> | ✅ | ✅ |
getUsedRam() | Promise<number> | ✅ | ✅ |
getAvailableRam() | Promise<number> | ✅ | ✅ |
getPercentageUsed() | Promise<number> | ✅ | ✅ |
getPercentageAvailable() | Promise<number> | ✅ | ✅ |
getAppRamUsed() | Promise<number> | ❌ | ✅ |
Type
interface RamState {
percentageAvailable: number;
percentageUsed: number;
totalMemory: number;
availableMemory: number;
usedMemory: number;
appUsedMemory?: number;
}
License
MIT