├── .gitignore ├── LICENSE ├── README.md ├── browser.js ├── main.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 CoderPuppy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # os-browserify 2 | 3 | The [os](https://nodejs.org/api/os.html) module from node.js, but for browsers. 4 | 5 | When you `require('os')` in [browserify](http://github.com/substack/node-browserify), this module will be loaded. 6 | -------------------------------------------------------------------------------- /browser.js: -------------------------------------------------------------------------------- 1 | exports.endianness = function () { return 'LE' }; 2 | 3 | exports.hostname = function () { 4 | if (typeof location !== 'undefined') { 5 | return location.hostname 6 | } 7 | else return ''; 8 | }; 9 | 10 | exports.loadavg = function () { return [] }; 11 | 12 | exports.uptime = function () { return 0 }; 13 | 14 | exports.freemem = function () { 15 | return Number.MAX_VALUE; 16 | }; 17 | 18 | exports.totalmem = function () { 19 | return Number.MAX_VALUE; 20 | }; 21 | 22 | exports.cpus = function () { return [] }; 23 | 24 | exports.type = function () { return 'Browser' }; 25 | 26 | exports.release = function () { 27 | if (typeof navigator !== 'undefined') { 28 | return navigator.appVersion; 29 | } 30 | return ''; 31 | }; 32 | 33 | exports.networkInterfaces 34 | = exports.getNetworkInterfaces 35 | = function () { return {} }; 36 | 37 | exports.arch = function () { return 'javascript' }; 38 | 39 | exports.platform = function () { return 'browser' }; 40 | 41 | exports.tmpdir = exports.tmpDir = function () { 42 | return '/tmp'; 43 | }; 44 | 45 | exports.EOL = '\n'; 46 | 47 | exports.homedir = function () { 48 | return '/' 49 | }; 50 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | module.exports = require('os'); 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "os-browserify", 3 | "version": "0.3.0", 4 | "author": "CoderPuppy ", 5 | "license": "MIT", 6 | "main": "main.js", 7 | "browser": "browser.js", 8 | "jspm": { 9 | "map": { 10 | "./main.js": { 11 | "node": "@node/os", 12 | "browser": "./browser.js" 13 | } 14 | } 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "http://github.com/CoderPuppy/os-browserify.git" 19 | } 20 | } 21 | --------------------------------------------------------------------------------