nativescript-dna-deviceinfo
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "nativescript-dna-deviceinfo", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "NativeScript plugin to acquire device information.", | ||
@@ -5,0 +5,0 @@ "main": "deviceinfo", |
@@ -114,4 +114,41 @@ | ||
## APIs in Action | ||
```javascript | ||
printDeviceInfo() { | ||
console.log("Free memory: ", formatBytes(DeviceInfo.freeMemory())); | ||
console.log("Total memory: ", formatBytes(DeviceInfo.totalMemory())); | ||
console.log("Total storage space: ", formatBytes(DeviceInfo.totalStorageSpace())); | ||
console.log("Free storage space: ",formatBytes(DeviceInfo.freeStorageSpace())); | ||
console.log("Device id: ", DeviceInfo.deviceId()); | ||
console.log("Device name: ", DeviceInfo.deviceName()); | ||
console.log("Device locale: ", DeviceInfo.deviceLocale()); | ||
console.log("Device country: ", DeviceInfo.deviceCountry()); | ||
console.log("Device timezone: ", DeviceInfo.timezone()); | ||
console.log("Device user agent: ", DeviceInfo.userAgent()); | ||
console.log("App name: ", DeviceInfo.appName()); | ||
console.log("App version: ", DeviceInfo.appVersion()); | ||
console.log("App bundle id: ", DeviceInfo.bundleId()); | ||
console.log("App bundle number: ", DeviceInfo.bundleNumber()); | ||
console.log("System manufacturer: ", DeviceInfo.systemManufacturer()); | ||
console.log("Is tablet: ", DeviceInfo.isTablet()); | ||
console.log("Is 24 hour: ", DeviceInfo.is24Hour()); | ||
console.log("Is emulator: ", DeviceInfo.isEmulator()); | ||
} | ||
formatBytes(bytes, decimals) { | ||
if (bytes === 0) return '0 GB' | ||
if (isNaN(parseInt(bytes))) return bytes | ||
if (typeof bytes === 'string') bytes = parseInt(bytes) | ||
if (bytes === 0) return '0'; | ||
const k = 1000; | ||
const dm = decimals + 1 || 3; | ||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | ||
const i = Math.floor(Math.log(bytes) / Math.log(k)); | ||
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; | ||
} | ||
``` | ||
## License | ||
MIT license (see LICENSE file) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30028
154