Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

community-cordova-plugin-cpu

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

community-cordova-plugin-cpu - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "community-cordova-plugin-cpu",
"version": "1.0.0",
"version": "1.0.1",
"types": "./types/index.d.ts",

@@ -5,0 +5,0 @@ "readme": "README.md",

@@ -16,117 +16,67 @@ [![NPM version](https://img.shields.io/npm/v/community-cordova-plugin-cpu)](https://www.npmjs.com/package/community-cordova-plugin-cpu)

---
# Community Cordova Plugin CPU
## Overview
This Cordova plugin provides a way to access basic CPU information of the mobile device. It supports both Android and iOS platforms, offering different sets of information based on the platform due to their respective system limitations and capabilities.
The `CpuManager` is a TypeScript class designed to provide information about the CPU (Central Processing Unit) of a device. This README file aims to provide a detailed description of the code and its usage.
## Installation
To use the `CpuManager` class, you need to install it as a dependency in your project:
```bash
To install the plugin in your Cordova project, use the following command:
```
cordova plugin add community-cordova-plugin-cpu
```
* for now it's Android only
## Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [License](#license)
## Introduction
The `CpuManager` class exports methods to retrieve essential information about the device's CPU, such as architecture, core count, frequency, model, and more. It uses TypeScript and is intended for use in Node.js or other JavaScript environments.
## Usage
To use the plugin, call the `getCpuInfo` method. This method is asynchronous and returns a Promise that resolves with the CPU information.
To utilize the `CpuManager` class in your project, follow these steps:
```javascript
document.addEventListener('deviceready', onDeviceReady, false);
1. Import the `CpuManager` class into your TypeScript/JavaScript file:
```typescript
import CpuManager from 'community-cordova-plugin-cpu';
function onDeviceReady() {
CpuManager.getCpuInfo().then(function(info) {
console.log('CPU Information:', info);
}).catch(function(error) {
console.error('Error getting CPU information:', error);
});
}
```
2. Create an instance of the `CpuManager` class:
### API
```typescript
declare var CpuPlugin: CpuManager;
```
#### getCpuInfo()
Returns a Promise that resolves with an object containing CPU information. The structure of the returned object varies between Android and iOS:
3. Use the `getCpuInfo` method to retrieve CPU information asynchronously:
#### Android
The response object includes:
```javascript
cpuManager.getCpuInfo()
.then((cpuInfo) => {
console.log('CPU Information:', cpuInfo);
})
.catch((error) => {
console.error('Error fetching CPU information:', error);
});
```
or
```javascript
var cpuObj = await CpuPlugin.getCpuInfo();
```
- `cpuArchitecture`: The architecture of the CPU (e.g., ARMv7, ARMv8).
- `cpuCores`: The number of CPU cores available on the device.
- `cpuFrequencyMax`: The maximum CPU frequency (in MHz).
- `cpuFrequencyMin`: The minimum CPU frequency (in MHz).
- `cpuModel`: The model or identifier of the CPU.
- `primaryABI`: The primary Application Binary Interface (ABI) of the device.
- `secondaryABI`: The secondary ABI of the device, if available.
- `cpuFrequencyInfo`: An array containing information about each CPU core, including core index and current frequency.
## API Reference
#### iOS
Due to iOS restrictions, the response object includes a limited set of information:
### `CpuManager`
- `cpuArchitecture`: The architecture of the CPU (e.g., ARM64, x86_64).
- `cpuCores`: The number of active CPU cores.
- `primaryABI`: The primary ABI based on the CPU architecture.
#### `getCpuInfo(): Promise<ICpu>`
**Note**: iOS does not allow access to certain details like CPU frequency or the exact CPU model.
Retrieves detailed information about the device's CPU.
## Platform Specifics
- **Android**: Provides comprehensive CPU information, including architecture, core count, frequency, model, and ABIs.
- **iOS**: Limited to providing CPU architecture, core count, and primary ABI due to iOS system restrictions.
- Returns: A Promise that resolves to an `ICpu` object containing the following properties:
- `cpuArchitecture`: A string representing the CPU architecture (e.g., ARMv7, ARMv8, x86, x86_64, etc.).
- `cpuCores`: The number of CPU cores available on the device.
- `cpuFrequencyMax`: The maximum CPU frequency in MHz.
- `cpuFrequencyMin`: The minimum CPU frequency in MHz.
- `cpuModel`: The CPU model or identifier (number).
- `primaryABI`: The primary ABI (Application Binary Interface) used by the CPU.
- `secondaryABI`: The secondary ABI (Application Binary Interface) if available.
- `cpuFrequencyInfo`: An array of objects containing CPU core-specific information, each with the following properties:
- `coreIndex`: The core index or identifier (number).
- `currentFrequency`: The current CPU frequency for the core in MHz.
### Interfaces
#### `ICpu`
An interface describing the CPU information structure:
- `cpuArchitecture` (string): CPU architecture, e.g., ARMv7, ARMv8, x86, x86_64, etc.
- `cpuCores` (number): Number of CPU cores available on the device.
- `cpuFrequencyMax` (string): Maximum CPU frequency in MHz.
- `cpuFrequencyMin` (string): Minimum CPU frequency in MHz.
- `cpuModel` (number): CPU model or identifier.
- `primaryABI` (string): Primary ABI (Application Binary Interface).
- `secondaryABI` (string): Secondary ABI (Application Binary Interface) if available.
- `cpuFrequencyInfo` (ICpuCores[]): Array of CPU core-specific information.
#### `ICpuCores`
An interface describing CPU core-specific information:
- `coreIndex` (number): Core index or identifier.
- `currentFrequency` (string): Current CPU frequency for the core in MHz.
## Contributing
Contributions to the plugin are welcome. Please ensure to follow the coding standards and submit your pull requests for review.
Contributions to this project are welcome. If you encounter issues, have suggestions, or want to contribute improvements, please feel free to open an issue or submit a pull request.
## License
This project is licensed under the MIT License.
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
---
Feel free to use the `CpuManager` class in your projects to retrieve and utilize CPU information effectively. If you have any questions or need assistance, please refer to the [Issues](https://github.com/EYALIN/community-cordova-plugin-cpu/issues) section of the GitHub repository for this project.
[community_plugins]: https://github.com/EYALIN?tab=repositories&q=community&type=&language=&sort=

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc