1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | var _endianness;
|
26 | export function endianness() {
|
27 | if (typeof _endianness === 'undefined') {
|
28 | var a = new ArrayBuffer(2);
|
29 | var b = new Uint8Array(a);
|
30 | var c = new Uint16Array(a);
|
31 | b[0] = 1;
|
32 | b[1] = 2;
|
33 | if (c[0] === 258) {
|
34 | _endianness = 'BE';
|
35 | } else if (c[0] === 513){
|
36 | _endianness = 'LE';
|
37 | } else {
|
38 | throw new Error('unable to figure out endianess');
|
39 | }
|
40 | }
|
41 | return _endianness;
|
42 | }
|
43 |
|
44 | export function hostname() {
|
45 | if (typeof global.location !== 'undefined') {
|
46 | return global.location.hostname
|
47 | } else return '';
|
48 | }
|
49 |
|
50 | export function loadavg() {
|
51 | return [];
|
52 | }
|
53 |
|
54 | export function uptime() {
|
55 | return 0;
|
56 | }
|
57 |
|
58 | export function freemem() {
|
59 | return Number.MAX_VALUE;
|
60 | }
|
61 |
|
62 | export function totalmem() {
|
63 | return Number.MAX_VALUE;
|
64 | }
|
65 |
|
66 | export function cpus() {
|
67 | return [];
|
68 | }
|
69 |
|
70 | export function type() {
|
71 | return 'Browser';
|
72 | }
|
73 |
|
74 | export function release () {
|
75 | if (typeof global.navigator !== 'undefined') {
|
76 | return global.navigator.appVersion;
|
77 | }
|
78 | return '';
|
79 | }
|
80 |
|
81 | export function networkInterfaces(){}
|
82 | export function getNetworkInterfaces(){}
|
83 |
|
84 | export function arch() {
|
85 | return 'javascript';
|
86 | }
|
87 |
|
88 | export function platform() {
|
89 | return 'browser';
|
90 | }
|
91 |
|
92 | export function tmpDir() {
|
93 | return '/tmp';
|
94 | }
|
95 | export var tmpdir = tmpDir;
|
96 |
|
97 | export var EOL = '\n';
|
98 | export default {
|
99 | EOL: EOL,
|
100 | tmpdir: tmpdir,
|
101 | tmpDir: tmpDir,
|
102 | networkInterfaces:networkInterfaces,
|
103 | getNetworkInterfaces: getNetworkInterfaces,
|
104 | release: release,
|
105 | type: type,
|
106 | cpus: cpus,
|
107 | totalmem: totalmem,
|
108 | freemem: freemem,
|
109 | uptime: uptime,
|
110 | loadavg: loadavg,
|
111 | hostname: hostname,
|
112 | endianness: endianness,
|
113 | }
|