Spaces:
Configuration error
Configuration error
/* | |
The MIT License (MIT) | |
Copyright (c) 2016 CoderPuppy | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
*/ | |
var _endianness; | |
export function endianness() { | |
if (typeof _endianness === 'undefined') { | |
var a = new ArrayBuffer(2); | |
var b = new Uint8Array(a); | |
var c = new Uint16Array(a); | |
b[0] = 1; | |
b[1] = 2; | |
if (c[0] === 258) { | |
_endianness = 'BE'; | |
} else if (c[0] === 513){ | |
_endianness = 'LE'; | |
} else { | |
throw new Error('unable to figure out endianess'); | |
} | |
} | |
return _endianness; | |
} | |
export function hostname() { | |
if (typeof global.location !== 'undefined') { | |
return global.location.hostname | |
} else return ''; | |
} | |
export function loadavg() { | |
return []; | |
} | |
export function uptime() { | |
return 0; | |
} | |
export function freemem() { | |
return Number.MAX_VALUE; | |
} | |
export function totalmem() { | |
return Number.MAX_VALUE; | |
} | |
export function cpus() { | |
return []; | |
} | |
export function type() { | |
return 'Browser'; | |
} | |
export function release () { | |
if (typeof global.navigator !== 'undefined') { | |
return global.navigator.appVersion; | |
} | |
return ''; | |
} | |
export function networkInterfaces(){} | |
export function getNetworkInterfaces(){} | |
export function arch() { | |
return 'javascript'; | |
} | |
export function platform() { | |
return 'browser'; | |
} | |
export function tmpDir() { | |
return '/tmp'; | |
} | |
export var tmpdir = tmpDir; | |
export var EOL = '\n'; | |
export default { | |
EOL: EOL, | |
tmpdir: tmpdir, | |
tmpDir: tmpDir, | |
networkInterfaces:networkInterfaces, | |
getNetworkInterfaces: getNetworkInterfaces, | |
release: release, | |
type: type, | |
cpus: cpus, | |
totalmem: totalmem, | |
freemem: freemem, | |
uptime: uptime, | |
loadavg: loadavg, | |
hostname: hostname, | |
endianness: endianness, | |
} | |