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

chrome-os

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

chrome-os - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

CONTRIBUTING.md

30

chrome.js

@@ -0,1 +1,11 @@

var platformMap = {
'mac': 'darwin',
'win': 'win32',
'android': 'android',
'cros': 'cros',
'linux': 'linux',
'openbsd': 'openbsd',
'notsupported': 'Not Supported'
}
exports.endianness = function () { return 'LE' }

@@ -23,3 +33,9 @@

exports.cpus = function () { return [] }
exports.cpus = function (cb) {
if (typeof cb !== 'function') {
console.warn('The Synchronious cpu call is not supported on Browserify CPA. Consider the Async call by passing a function')
return 'Not Supported'
}
chrome.system.cpu.getInfo(cb) // eslint-disable-line
}

@@ -39,5 +55,13 @@ exports.type = function () { return 'Chrome Packaged Application' }

exports.arch = function () { return 'javascript' }
exports.arch = function () { return 'Not Supported' }
exports.platform = function () { return 'browser' }
exports.platform = function (cb) {
if (typeof cb !== 'function') {
console.warn('The Synchronious platform call is not supported on Browserify CPA. Consider the Async call by passing a function')
return platformMap['notsupported']
}
chrome.runtime.getPlatformInfo(function (info) { // eslint-disable-line
cb(platformMap[info.os])
})
}

@@ -44,0 +68,0 @@ exports.tmpdir = exports.tmpDir = function () {

9

package.json
{
"name": "chrome-os",
"version": "1.0.0",
"version": "2.0.0",
"description": "Use the Node `os` API in Chrome Apps",

@@ -8,3 +8,3 @@ "main": "main.js",

"scripts": {
"test": "standard && tape test/*.js"
"test": "standard && browserify test/chrome-app/index.js -o test/chrome-app/bundle.js && tape test/*.js"
},

@@ -23,3 +23,6 @@ "repository": {

},
"homepage": "https://github.com/No9/chrome-os"
"homepage": "https://github.com/No9/chrome-os",
"devDependencies": {
"tape": "^4.0.0"
}
}
# chrome-os
Use the Node `os` API in Chrome Apps
## Usage
This library can be used directly with your browserify builds with targeting Chrome Packaged Apps.
```
$ npm install chrome-os --save
$ browserify -r chrome-os:os index.js -o bundle.js
```
## Test
```
$ npm test
```
This will load the folder `test/chrome-app` as an unpacked extension in chrome.
Test currently designed for windows and Mac Canary support for others accepted
## Permissions
The following permissions need to be added to your chrome packaged app for this module.
```
"permissions": [
"system.memory",
"system.cpu"
]
```
## Mapping
The chrome apis do not support sync calls for some of the corresponding features so the calls have been made async.
Currently these are
1. cpus(callback(cpuinfo))
2. platform(callback(platform))
The platform string maps to the expected node value.
There is currently a console warning and 'Not Supported' is returned if these functions are called without a callback.
It should be noted that browserify doesn't fully support these either only returning placeholders.
If users are interested in full cross platform support then an async-os implementation could be implemented.
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