@gjsify/os 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # @gjsify/os [![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/ISC)
1
+ # @gjsify/os
2
2
 
3
- os core module for [gjs](https://gitlab.gnome.org/GNOME/gjs) forked from [@cgjs/os](https://github.com/cgjs/cgjs/tree/master/packages/os)
4
-
5
- <sup><sub>( currently available for Linux / macOS only )</sub></sup>
3
+ Node.js os module for Gjs
@@ -0,0 +1,141 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var constants_exports = {};
19
+ __export(constants_exports, {
20
+ default: () => constants_default
21
+ });
22
+ module.exports = __toCommonJS(constants_exports);
23
+ var constants_default = {
24
+ "UV_UDP_REUSEADDR": 4,
25
+ "errno": {
26
+ "E2BIG": 7,
27
+ "EACCES": 13,
28
+ "EADDRINUSE": 98,
29
+ "EADDRNOTAVAIL": 99,
30
+ "EAFNOSUPPORT": 97,
31
+ "EAGAIN": 11,
32
+ "EALREADY": 114,
33
+ "EBADF": 9,
34
+ "EBADMSG": 74,
35
+ "EBUSY": 16,
36
+ "ECANCELED": 125,
37
+ "ECHILD": 10,
38
+ "ECONNABORTED": 103,
39
+ "ECONNREFUSED": 111,
40
+ "ECONNRESET": 104,
41
+ "EDEADLK": 35,
42
+ "EDESTADDRREQ": 89,
43
+ "EDOM": 33,
44
+ "EDQUOT": 122,
45
+ "EEXIST": 17,
46
+ "EFAULT": 14,
47
+ "EFBIG": 27,
48
+ "EHOSTUNREACH": 113,
49
+ "EIDRM": 43,
50
+ "EILSEQ": 84,
51
+ "EINPROGRESS": 115,
52
+ "EINTR": 4,
53
+ "EINVAL": 22,
54
+ "EIO": 5,
55
+ "EISCONN": 106,
56
+ "EISDIR": 21,
57
+ "ELOOP": 40,
58
+ "EMFILE": 24,
59
+ "EMLINK": 31,
60
+ "EMSGSIZE": 90,
61
+ "EMULTIHOP": 72,
62
+ "ENAMETOOLONG": 36,
63
+ "ENETDOWN": 100,
64
+ "ENETRESET": 102,
65
+ "ENETUNREACH": 101,
66
+ "ENFILE": 23,
67
+ "ENOBUFS": 105,
68
+ "ENODATA": 61,
69
+ "ENODEV": 19,
70
+ "ENOENT": 2,
71
+ "ENOEXEC": 8,
72
+ "ENOLCK": 37,
73
+ "ENOLINK": 67,
74
+ "ENOMEM": 12,
75
+ "ENOMSG": 42,
76
+ "ENOPROTOOPT": 92,
77
+ "ENOSPC": 28,
78
+ "ENOSR": 63,
79
+ "ENOSTR": 60,
80
+ "ENOSYS": 38,
81
+ "ENOTCONN": 107,
82
+ "ENOTDIR": 20,
83
+ "ENOTEMPTY": 39,
84
+ "ENOTSOCK": 88,
85
+ "ENOTSUP": 95,
86
+ "ENOTTY": 25,
87
+ "ENXIO": 6,
88
+ "EOPNOTSUPP": 95,
89
+ "EOVERFLOW": 75,
90
+ "EPERM": 1,
91
+ "EPIPE": 32,
92
+ "EPROTO": 71,
93
+ "EPROTONOSUPPORT": 93,
94
+ "EPROTOTYPE": 91,
95
+ "ERANGE": 34,
96
+ "EROFS": 30,
97
+ "ESPIPE": 29,
98
+ "ESRCH": 3,
99
+ "ESTALE": 116,
100
+ "ETIME": 62,
101
+ "ETIMEDOUT": 110,
102
+ "ETXTBSY": 26,
103
+ "EWOULDBLOCK": 11,
104
+ "EXDEV": 18
105
+ },
106
+ "signals": {
107
+ "SIGHUP": 1,
108
+ "SIGINT": 2,
109
+ "SIGQUIT": 3,
110
+ "SIGILL": 4,
111
+ "SIGTRAP": 5,
112
+ "SIGABRT": 6,
113
+ "SIGIOT": 6,
114
+ "SIGBUS": 7,
115
+ "SIGFPE": 8,
116
+ "SIGKILL": 9,
117
+ "SIGUSR1": 10,
118
+ "SIGSEGV": 11,
119
+ "SIGUSR2": 12,
120
+ "SIGPIPE": 13,
121
+ "SIGALRM": 14,
122
+ "SIGTERM": 15,
123
+ "SIGCHLD": 17,
124
+ "SIGSTKFLT": 16,
125
+ "SIGCONT": 18,
126
+ "SIGSTOP": 19,
127
+ "SIGTSTP": 20,
128
+ "SIGTTIN": 21,
129
+ "SIGTTOU": 22,
130
+ "SIGURG": 23,
131
+ "SIGXCPU": 24,
132
+ "SIGXFSZ": 25,
133
+ "SIGVTALRM": 26,
134
+ "SIGPROF": 27,
135
+ "SIGWINCH": 28,
136
+ "SIGIO": 29,
137
+ "SIGPOLL": 29,
138
+ "SIGPWR": 30,
139
+ "SIGSYS": 31
140
+ }
141
+ };
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var createSubnet_exports = {};
19
+ __export(createSubnet_exports, {
20
+ createSubnet: () => createSubnet,
21
+ default: () => createSubnet_default
22
+ });
23
+ module.exports = __toCommonJS(createSubnet_exports);
24
+ function createSubnet(size, segment, base, sep) {
25
+ const empty = "0".repeat(size);
26
+ return (mask) => {
27
+ const str = ("1".repeat(parseInt(mask, 10)) + empty).slice(0, size);
28
+ const out = [];
29
+ for (let i = 0; i < size; i += segment) {
30
+ out.push(parseInt(str.substr(i, segment), 2).toString(base));
31
+ }
32
+ return out.join(sep);
33
+ };
34
+ }
35
+ ;
36
+ var createSubnet_default = { createSubnet };
@@ -0,0 +1,134 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var darwin_exports = {};
19
+ __export(darwin_exports, {
20
+ cpus: () => cpus,
21
+ endianness: () => endianness,
22
+ freemem: () => freemem,
23
+ loadavg: () => loadavg,
24
+ networkInterfaces: () => networkInterfaces,
25
+ totalmem: () => totalmem,
26
+ uptime: () => uptime
27
+ });
28
+ module.exports = __toCommonJS(darwin_exports);
29
+ var import_createSubnet = require("./createSubnet.js");
30
+ var import_utils = require("@gjsify/utils");
31
+ const EOL = /\r\n|\n/;
32
+ const NOMAC = "00:00:00:00:00:00";
33
+ const getIPv6Subnet = (0, import_createSubnet.createSubnet)(128, 16, 16, ":");
34
+ const parseInterfaces = function(info) {
35
+ info = info.trim();
36
+ if (info.length < 1 || !/\binet\b/.test(info))
37
+ return;
38
+ const lines = info.split("\n");
39
+ const iface = [];
40
+ const length = lines.length;
41
+ let mac = NOMAC;
42
+ for (let line, i = 0; i < length; i++) {
43
+ line = lines[i];
44
+ switch (true) {
45
+ case /ether\s+((?:\S{2}:)+\S{2})/.test(line):
46
+ mac = RegExp.$1;
47
+ break;
48
+ case /inet\s+(\d+\.\d+\.\d+\.\d+)\s+netmask\s+0x(.{2})(.{2})(.{2})(.{2})/.test(line):
49
+ iface.push({
50
+ address: RegExp.$1,
51
+ netmask: [
52
+ parseInt(RegExp.$2, 16),
53
+ parseInt(RegExp.$3, 16),
54
+ parseInt(RegExp.$4, 16),
55
+ parseInt(RegExp.$5, 16)
56
+ ].join("."),
57
+ family: "IPv4",
58
+ mac,
59
+ internal: RegExp.$1 === "127.0.0.1"
60
+ });
61
+ break;
62
+ case /inet6\s+((?:\S{0,4}:)+\S{1,4}).+?prefixlen\s+(\d+)/.test(line):
63
+ iface.push({
64
+ address: RegExp.$1,
65
+ netmask: getIPv6Subnet(RegExp.$2),
66
+ family: "IPv6",
67
+ mac,
68
+ internal: mac !== NOMAC
69
+ });
70
+ break;
71
+ }
72
+ }
73
+ this[info.slice(0, info.indexOf(":"))] = iface;
74
+ };
75
+ const cpus = () => {
76
+ let cores = parseFloat((0, import_utils.cli)("sysctl -n hw.ncpu"));
77
+ const cpus2 = [];
78
+ while (cores--) {
79
+ cpus2.push({
80
+ model: (0, import_utils.cli)("sysctl -n machdep.cpu.brand_string").replace(/\s+/g, " "),
81
+ speed: parseFloat((0, import_utils.cli)("sysctl -n hw.cpufrequency")) / 1e3 / 1e3,
82
+ get times() {
83
+ console.warn("cpus.times is not supported");
84
+ return {};
85
+ }
86
+ });
87
+ }
88
+ return cpus2;
89
+ };
90
+ const endianness = () => "LE";
91
+ const freemem = () => parseFloat((0, import_utils.cli)("sysctl -n hw.memsize")) - parseFloat((0, import_utils.cli)("sysctl -n hw.physmem"));
92
+ const loadavg = () => /load\s+averages:\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))/.test(
93
+ (0, import_utils.cli)("uptime")
94
+ ) && [
95
+ parseFloat(RegExp.$1),
96
+ parseFloat(RegExp.$2),
97
+ parseFloat(RegExp.$3)
98
+ ];
99
+ const networkInterfaces = () => {
100
+ const ifaces = {};
101
+ const groups = [];
102
+ const lines = (0, import_utils.cli)("ifconfig").split(EOL);
103
+ const length = lines.length;
104
+ for (let group = [], re = /^\S+?:/, i = 0; i < length; i++) {
105
+ if (re.test(lines[i])) {
106
+ group = [lines[i]];
107
+ while (++i < length && !re.test(lines[i])) {
108
+ group.push(lines[i]);
109
+ }
110
+ --i;
111
+ }
112
+ groups.push(group.join(EOL));
113
+ }
114
+ groups.forEach(parseInterfaces, ifaces);
115
+ return ifaces;
116
+ };
117
+ const totalmem = () => {
118
+ let I, mem = (0, import_utils.cli)("free -b").split(EOL);
119
+ mem[0].split(/\s+/).some((info, i) => info === "total" && (I = i));
120
+ return parseFloat(mem[1].split(/\s+/)[I + 1]);
121
+ };
122
+ const uptime = () => {
123
+ const uptime2 = (0, import_utils.cli)("uptime");
124
+ const up = /up\s+([^,]+)?,/.test(uptime2) && RegExp.$1;
125
+ switch (true) {
126
+ case /^(\d+):(\d+)$/.test(up):
127
+ return (parseInt(RegExp.$1, 10) * 60 + parseInt(RegExp.$2, 10)) * 60;
128
+ case /^(\d+)\s+mins?$/.test(up):
129
+ return parseInt(RegExp.$1, 10) * 60;
130
+ case /^(\d+)\s+days?$/.test(up):
131
+ return parseInt(RegExp.$1, 10) * 86400 + (/days?,\s+^(\d+):(\d+)$/.test(uptime2) && (parseInt(RegExp.$1, 10) * 60 + parseInt(RegExp.$2, 10)) * 60);
132
+ }
133
+ return up;
134
+ };
@@ -0,0 +1,121 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ EOL: () => EOL,
31
+ constants: () => import_constants.default,
32
+ cpus: () => cpus,
33
+ endianness: () => endianness,
34
+ freemem: () => freemem,
35
+ homedir: () => homedir,
36
+ hostname: () => hostname,
37
+ loadavg: () => loadavg,
38
+ networkInterfaces: () => networkInterfaces,
39
+ release: () => release,
40
+ tmpdir: () => tmpdir,
41
+ type: () => type,
42
+ userInfo: () => userInfo
43
+ });
44
+ module.exports = __toCommonJS(src_exports);
45
+ var import_utils = require("@gjsify/utils");
46
+ var linux = __toESM(require("./linux.js"), 1);
47
+ var darwin = __toESM(require("./darwin.js"), 1);
48
+ var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
49
+ var import_constants = __toESM(require("./constants.js"), 1);
50
+ const EOL = (0, import_utils.getPathSeparator)() === "/" ? "\n" : "\r\n";
51
+ const homedir = () => import_glib_2.default.get_home_dir();
52
+ const hostname = () => import_glib_2.default.get_host_name();
53
+ const release = () => (0, import_utils.cli)("uname -r");
54
+ const tmpdir = () => import_glib_2.default.get_tmp_dir();
55
+ const type = () => (0, import_utils.cli)("uname");
56
+ const userInfo = () => ({
57
+ uid: 1e3,
58
+ gid: 100,
59
+ username: import_glib_2.default.get_user_name(),
60
+ homedir: import_glib_2.default.get_home_dir()
61
+ });
62
+ const cpus = () => {
63
+ const _os = (0, import_utils.getOs)();
64
+ switch (_os) {
65
+ case "darwin":
66
+ return darwin.cpus();
67
+ case "linux":
68
+ return linux.cpus();
69
+ default:
70
+ console.warn(`${_os} is not supported!`);
71
+ break;
72
+ }
73
+ };
74
+ const endianness = () => {
75
+ const _os = (0, import_utils.getOs)();
76
+ switch (_os) {
77
+ case "darwin":
78
+ return darwin.endianness();
79
+ case "linux":
80
+ return linux.endianness();
81
+ default:
82
+ console.warn(`${_os} is not supported!`);
83
+ break;
84
+ }
85
+ };
86
+ const freemem = () => {
87
+ const _os = (0, import_utils.getOs)();
88
+ switch (_os) {
89
+ case "darwin":
90
+ return darwin.freemem();
91
+ case "linux":
92
+ return linux.freemem();
93
+ default:
94
+ console.warn(`${_os} is not supported!`);
95
+ break;
96
+ }
97
+ };
98
+ const loadavg = () => {
99
+ const _os = (0, import_utils.getOs)();
100
+ switch (_os) {
101
+ case "darwin":
102
+ return darwin.loadavg();
103
+ case "linux":
104
+ return linux.loadavg();
105
+ default:
106
+ console.warn(`${_os} is not supported!`);
107
+ break;
108
+ }
109
+ };
110
+ const networkInterfaces = () => {
111
+ const _os = (0, import_utils.getOs)();
112
+ switch (_os) {
113
+ case "darwin":
114
+ return darwin.networkInterfaces();
115
+ case "linux":
116
+ return linux.networkInterfaces();
117
+ default:
118
+ console.warn(`${_os} is not supported!`);
119
+ break;
120
+ }
121
+ };
@@ -0,0 +1,111 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var linux_exports = {};
19
+ __export(linux_exports, {
20
+ cpus: () => cpus,
21
+ endianness: () => endianness,
22
+ freemem: () => freemem,
23
+ loadavg: () => loadavg,
24
+ networkInterfaces: () => networkInterfaces,
25
+ totalmem: () => totalmem,
26
+ uptime: () => uptime
27
+ });
28
+ module.exports = __toCommonJS(linux_exports);
29
+ var import_createSubnet = require("./createSubnet.js");
30
+ var import_utils = require("@gjsify/utils");
31
+ const EOL = /\r\n|\n/;
32
+ const getIPv4Subnet = (0, import_createSubnet.createSubnet)(32, 8, 10, ".");
33
+ const getIPv6Subnet = (0, import_createSubnet.createSubnet)(128, 16, 16, ":");
34
+ function parseInterfaces(info) {
35
+ info = info.trim();
36
+ if (info.length < 1)
37
+ return;
38
+ let iface = [], mac;
39
+ for (let line, lines = info.split(EOL), i = 0; i < lines.length; i++) {
40
+ line = lines[i];
41
+ switch (true) {
42
+ case /link\/\S+\s+((?:\S{2}:)+\S{2})/.test(line):
43
+ mac = RegExp.$1;
44
+ break;
45
+ case /inet(\d*)\s+(\S+)/.test(line):
46
+ let ip = RegExp.$2.split("/"), v = RegExp.$1 || "4";
47
+ iface.push({
48
+ address: ip[0],
49
+ netmask: (v === "4" ? getIPv4Subnet : getIPv6Subnet)(ip[1]),
50
+ family: "IPv" + v,
51
+ mac,
52
+ internal: ip[0] === "127.0.0.1"
53
+ });
54
+ break;
55
+ }
56
+ }
57
+ if (mac)
58
+ this[info.slice(0, info.indexOf(":"))] = iface;
59
+ }
60
+ ;
61
+ const cpus = () => {
62
+ const PROCESSOR = /^processor\s*:\s*(\d+)/i;
63
+ const NAME = /^model[\s_]+name\s*:([^\r\n]+)/i;
64
+ const FREQ = /^cpu[\s_]+MHz\s*:\s*(\d+)/i;
65
+ const cpus2 = [];
66
+ let cpu;
67
+ (0, import_utils.cli)("cat /proc/cpuinfo").split(EOL).forEach((line) => {
68
+ switch (true) {
69
+ case PROCESSOR.test(line):
70
+ cpus2[RegExp.$1.trim()] = cpu = {
71
+ model: "",
72
+ speed: 0,
73
+ get times() {
74
+ return {};
75
+ }
76
+ };
77
+ break;
78
+ case NAME.test(line):
79
+ cpu.model = RegExp.$1.trim();
80
+ break;
81
+ case FREQ.test(line):
82
+ cpu.speed = parseFloat(RegExp.$1.trim());
83
+ break;
84
+ }
85
+ });
86
+ return cpus2;
87
+ };
88
+ const endianness = () => "LE";
89
+ const freemem = () => {
90
+ let I, mem = (0, import_utils.cli)("free -b").split(EOL);
91
+ mem[0].split(/\s+/).some((info, i) => info === "free" && (I = i));
92
+ return parseFloat(mem[1].split(/\s+/)[I + 1]);
93
+ };
94
+ const loadavg = () => /(\d+(?:\.\d+))\s+(\d+(?:\.\d+))\s+(\d+(?:\.\d+))/.test(
95
+ (0, import_utils.cli)("cat /proc/loadavg")
96
+ ) && [
97
+ parseFloat(RegExp.$1),
98
+ parseFloat(RegExp.$2),
99
+ parseFloat(RegExp.$3)
100
+ ];
101
+ const networkInterfaces = () => {
102
+ const ifaces = {};
103
+ (0, import_utils.cli)("ip addr").split(/^\d+:\s+/m).forEach(parseInterfaces, ifaces);
104
+ return ifaces;
105
+ };
106
+ const totalmem = () => {
107
+ let I, mem = (0, import_utils.cli)("free -b").split(EOL);
108
+ mem[0].split(/\s+/).some((info, i) => info === "total" && (I = i));
109
+ return parseFloat(mem[1].split(/\s+/)[I + 1]);
110
+ };
111
+ const uptime = () => (Date.now() - Date.parse((0, import_utils.cli)("uptime -s").replace(" ", "T"))) / 1e3;
@@ -0,0 +1 @@
1
+ console.warn("os core module is not fully supported here");
@@ -0,0 +1,122 @@
1
+ var constants_default = {
2
+ "UV_UDP_REUSEADDR": 4,
3
+ "errno": {
4
+ "E2BIG": 7,
5
+ "EACCES": 13,
6
+ "EADDRINUSE": 98,
7
+ "EADDRNOTAVAIL": 99,
8
+ "EAFNOSUPPORT": 97,
9
+ "EAGAIN": 11,
10
+ "EALREADY": 114,
11
+ "EBADF": 9,
12
+ "EBADMSG": 74,
13
+ "EBUSY": 16,
14
+ "ECANCELED": 125,
15
+ "ECHILD": 10,
16
+ "ECONNABORTED": 103,
17
+ "ECONNREFUSED": 111,
18
+ "ECONNRESET": 104,
19
+ "EDEADLK": 35,
20
+ "EDESTADDRREQ": 89,
21
+ "EDOM": 33,
22
+ "EDQUOT": 122,
23
+ "EEXIST": 17,
24
+ "EFAULT": 14,
25
+ "EFBIG": 27,
26
+ "EHOSTUNREACH": 113,
27
+ "EIDRM": 43,
28
+ "EILSEQ": 84,
29
+ "EINPROGRESS": 115,
30
+ "EINTR": 4,
31
+ "EINVAL": 22,
32
+ "EIO": 5,
33
+ "EISCONN": 106,
34
+ "EISDIR": 21,
35
+ "ELOOP": 40,
36
+ "EMFILE": 24,
37
+ "EMLINK": 31,
38
+ "EMSGSIZE": 90,
39
+ "EMULTIHOP": 72,
40
+ "ENAMETOOLONG": 36,
41
+ "ENETDOWN": 100,
42
+ "ENETRESET": 102,
43
+ "ENETUNREACH": 101,
44
+ "ENFILE": 23,
45
+ "ENOBUFS": 105,
46
+ "ENODATA": 61,
47
+ "ENODEV": 19,
48
+ "ENOENT": 2,
49
+ "ENOEXEC": 8,
50
+ "ENOLCK": 37,
51
+ "ENOLINK": 67,
52
+ "ENOMEM": 12,
53
+ "ENOMSG": 42,
54
+ "ENOPROTOOPT": 92,
55
+ "ENOSPC": 28,
56
+ "ENOSR": 63,
57
+ "ENOSTR": 60,
58
+ "ENOSYS": 38,
59
+ "ENOTCONN": 107,
60
+ "ENOTDIR": 20,
61
+ "ENOTEMPTY": 39,
62
+ "ENOTSOCK": 88,
63
+ "ENOTSUP": 95,
64
+ "ENOTTY": 25,
65
+ "ENXIO": 6,
66
+ "EOPNOTSUPP": 95,
67
+ "EOVERFLOW": 75,
68
+ "EPERM": 1,
69
+ "EPIPE": 32,
70
+ "EPROTO": 71,
71
+ "EPROTONOSUPPORT": 93,
72
+ "EPROTOTYPE": 91,
73
+ "ERANGE": 34,
74
+ "EROFS": 30,
75
+ "ESPIPE": 29,
76
+ "ESRCH": 3,
77
+ "ESTALE": 116,
78
+ "ETIME": 62,
79
+ "ETIMEDOUT": 110,
80
+ "ETXTBSY": 26,
81
+ "EWOULDBLOCK": 11,
82
+ "EXDEV": 18
83
+ },
84
+ "signals": {
85
+ "SIGHUP": 1,
86
+ "SIGINT": 2,
87
+ "SIGQUIT": 3,
88
+ "SIGILL": 4,
89
+ "SIGTRAP": 5,
90
+ "SIGABRT": 6,
91
+ "SIGIOT": 6,
92
+ "SIGBUS": 7,
93
+ "SIGFPE": 8,
94
+ "SIGKILL": 9,
95
+ "SIGUSR1": 10,
96
+ "SIGSEGV": 11,
97
+ "SIGUSR2": 12,
98
+ "SIGPIPE": 13,
99
+ "SIGALRM": 14,
100
+ "SIGTERM": 15,
101
+ "SIGCHLD": 17,
102
+ "SIGSTKFLT": 16,
103
+ "SIGCONT": 18,
104
+ "SIGSTOP": 19,
105
+ "SIGTSTP": 20,
106
+ "SIGTTIN": 21,
107
+ "SIGTTOU": 22,
108
+ "SIGURG": 23,
109
+ "SIGXCPU": 24,
110
+ "SIGXFSZ": 25,
111
+ "SIGVTALRM": 26,
112
+ "SIGPROF": 27,
113
+ "SIGWINCH": 28,
114
+ "SIGIO": 29,
115
+ "SIGPOLL": 29,
116
+ "SIGPWR": 30,
117
+ "SIGSYS": 31
118
+ }
119
+ };
120
+ export {
121
+ constants_default as default
122
+ };
@@ -0,0 +1,17 @@
1
+ function createSubnet(size, segment, base, sep) {
2
+ const empty = "0".repeat(size);
3
+ return (mask) => {
4
+ const str = ("1".repeat(parseInt(mask, 10)) + empty).slice(0, size);
5
+ const out = [];
6
+ for (let i = 0; i < size; i += segment) {
7
+ out.push(parseInt(str.substr(i, segment), 2).toString(base));
8
+ }
9
+ return out.join(sep);
10
+ };
11
+ }
12
+ ;
13
+ var createSubnet_default = { createSubnet };
14
+ export {
15
+ createSubnet,
16
+ createSubnet_default as default
17
+ };