New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pc

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pc

Get general information regarding computer status such as memory utilization, hardd drive space, number of core, etc

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-94.12%
Maintainers
1
Weekly downloads
 
Created
Source

PC

An application that provides information about a computer. Such as available memory, installed application, drives spaces, etc. It is only supporting Windows right now but Linux and Mac support are coming soon.

##Install

    npm install pc

Information Available

  • Memory
  • CPU
  • Hostname
  • Uptime
  • NetworkInterfaces
  • Temporary Directory
  • Public IP
  • Drives
  • Users
  • MAC
  • Programs
  • Share
  • More coming soon

Methods

Memory Return computer's available memory

  var pc = require('pc');

  pc.memory(); //return  { free: number, total: number }

Hostname Return the computer's hostname

  pc.hostname(); //return { name: 'string' }

Uptime Return the system uptime in seconds

  pc.uptime() //return { time: 'string' }

tmpDir Returns the operating system's default directory for temp files.

pc.tmpDir() //return { location: 'string' }

NetworkInterfaces Get a list of network interfaces

  pc.networkInterfaces();
  /*
    { lo0:
    [ { address: '::1', family: 'IPv6', internal: true },
    { address: 'fe80::1', family: 'IPv6', internal: true },
    { address: '127.0.0.1', family: 'IPv4', internal: true } ],
    en1:
    [ { address: 'fe80::cabc:c8ff:feef:f996', family: 'IPv6',
    internal: false },
    { address: '10.0.1.123', family: 'IPv4', internal: false } ],
    vmnet1: [ { address: '10.99.99.254', family: 'IPv4', internal: false } ],
    vmnet8: [ { address: '10.88.88.1', family: 'IPv4', internal: false } ],
    ppp0: [ { address: '10.2.0.231', family: 'IPv4', internal: false } ] }
  */

###The rest of the api return promises I like to define an error handler function to deal with my promises errors,

  var errorHandler = function(err){ console.log(err); throw err; };

cpu Returns an objects containing information about each CPU/core installed.

  pc.cpu().then(function(cpu){
    console.log(cpu);
  }, errorHandler);
  /*return {
      deviceId: 'string',
      status: number,
      currentClockSpeed: number,
      currentVoltage: number,
      loadPercentage: number,
      maxClockSpeed: number,
      name: 'string',
      numberOfCores: number,
      processorId: 'string'
    }*/

Public IP Return the public IP of the computer. Internet connection is required to call this method.

  pc.publicIP().then(function(ipInfo){
    console.log(ipInfo); //return { ip: ipaddress }
  }, errorHandler);

Drives Return an array of object with drive information.

  pc.drives().then(function(drives){
    console.log(drives);
    /*
      [{
        name: 'string',
        description: 'string',
        fileSystem: 'string',
        freeSpace: number,
        size: number,
        volumeName: 'string'
    }]
    */
  }, errorHandler);

Users Return an array of existing users in the computer.

  pc.users().then(function(users){
    console.log(users);
    /*
      [{
        name: 'string',
        accountType: number,
        domain: 'string',
        fullName: 'string',
        description: 'string',
        passwordChangeable: boolean,
        passwordExpires: boolean,
        passwordRequired: boolean,
        sid: 'string',
        status: 'string'
      }]
    */
  }, errorHandler);

Mac Return an array of nic info.

pc.mac().then(function(list){
  console.log(list);
  /*
  [{
    interfaceIndex: number,
    name: 'string',
    macAddress: 'macaddress',
    manufacturer: 'string',
    timeOfLastReset: time
  }]
  */
}, errorHandler);

Programs Return an array with all the applications installed in the computer.

pc.programs().then(function(list){
  console.log(list); // [{ name: 'string' }]
}, errorHandler);

Programs Return an array with all shares in the computer.

pc.share().then(function(list){
  console.log(list);
  /*
  [{
    name: 'string',
    caption: 'string',
    path: 'string',
    type: number
  }]
  */
}, errorHandler);

Useful Methods

getAll Retrieve all the information from the computer

  pc.getAll().then(function(everything){
    console.log(everything)
  }, errorHandler);

get Get an object with selected attributes

  pc.get(['mac, publicIP, users']).then(function(results){
    console.log(results); //{ mac: [{object}], publicIP: 'ipaddress', users: [{object}] }
  }, errorHandler)

Keywords

FAQs

Package last updated on 20 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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