UNPKG

7.79 kBTypeScriptView Raw
1declare module "os" {
2 interface CpuInfo {
3 model: string;
4 speed: number;
5 times: {
6 user: number;
7 nice: number;
8 sys: number;
9 idle: number;
10 irq: number;
11 };
12 }
13
14 interface NetworkInterfaceBase {
15 address: string;
16 netmask: string;
17 mac: string;
18 internal: boolean;
19 cidr: string | null;
20 }
21
22 interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
23 family: "IPv4";
24 }
25
26 interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
27 family: "IPv6";
28 scopeid: number;
29 }
30
31 interface UserInfo<T> {
32 username: T;
33 uid: number;
34 gid: number;
35 shell: T;
36 homedir: T;
37 }
38
39 type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
40
41 function hostname(): string;
42 function loadavg(): number[];
43 function uptime(): number;
44 function freemem(): number;
45 function totalmem(): number;
46 function cpus(): CpuInfo[];
47 function type(): string;
48 function release(): string;
49 function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
50 function homedir(): string;
51 function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
52 function userInfo(options?: { encoding: string }): UserInfo<string>;
53
54 type SignalConstants = {
55 [key in NodeJS.Signals]: number;
56 };
57
58 namespace constants {
59 const UV_UDP_REUSEADDR: number;
60 namespace signals {}
61 const signals: SignalConstants;
62 namespace errno {
63 const E2BIG: number;
64 const EACCES: number;
65 const EADDRINUSE: number;
66 const EADDRNOTAVAIL: number;
67 const EAFNOSUPPORT: number;
68 const EAGAIN: number;
69 const EALREADY: number;
70 const EBADF: number;
71 const EBADMSG: number;
72 const EBUSY: number;
73 const ECANCELED: number;
74 const ECHILD: number;
75 const ECONNABORTED: number;
76 const ECONNREFUSED: number;
77 const ECONNRESET: number;
78 const EDEADLK: number;
79 const EDESTADDRREQ: number;
80 const EDOM: number;
81 const EDQUOT: number;
82 const EEXIST: number;
83 const EFAULT: number;
84 const EFBIG: number;
85 const EHOSTUNREACH: number;
86 const EIDRM: number;
87 const EILSEQ: number;
88 const EINPROGRESS: number;
89 const EINTR: number;
90 const EINVAL: number;
91 const EIO: number;
92 const EISCONN: number;
93 const EISDIR: number;
94 const ELOOP: number;
95 const EMFILE: number;
96 const EMLINK: number;
97 const EMSGSIZE: number;
98 const EMULTIHOP: number;
99 const ENAMETOOLONG: number;
100 const ENETDOWN: number;
101 const ENETRESET: number;
102 const ENETUNREACH: number;
103 const ENFILE: number;
104 const ENOBUFS: number;
105 const ENODATA: number;
106 const ENODEV: number;
107 const ENOENT: number;
108 const ENOEXEC: number;
109 const ENOLCK: number;
110 const ENOLINK: number;
111 const ENOMEM: number;
112 const ENOMSG: number;
113 const ENOPROTOOPT: number;
114 const ENOSPC: number;
115 const ENOSR: number;
116 const ENOSTR: number;
117 const ENOSYS: number;
118 const ENOTCONN: number;
119 const ENOTDIR: number;
120 const ENOTEMPTY: number;
121 const ENOTSOCK: number;
122 const ENOTSUP: number;
123 const ENOTTY: number;
124 const ENXIO: number;
125 const EOPNOTSUPP: number;
126 const EOVERFLOW: number;
127 const EPERM: number;
128 const EPIPE: number;
129 const EPROTO: number;
130 const EPROTONOSUPPORT: number;
131 const EPROTOTYPE: number;
132 const ERANGE: number;
133 const EROFS: number;
134 const ESPIPE: number;
135 const ESRCH: number;
136 const ESTALE: number;
137 const ETIME: number;
138 const ETIMEDOUT: number;
139 const ETXTBSY: number;
140 const EWOULDBLOCK: number;
141 const EXDEV: number;
142 const WSAEINTR: number;
143 const WSAEBADF: number;
144 const WSAEACCES: number;
145 const WSAEFAULT: number;
146 const WSAEINVAL: number;
147 const WSAEMFILE: number;
148 const WSAEWOULDBLOCK: number;
149 const WSAEINPROGRESS: number;
150 const WSAEALREADY: number;
151 const WSAENOTSOCK: number;
152 const WSAEDESTADDRREQ: number;
153 const WSAEMSGSIZE: number;
154 const WSAEPROTOTYPE: number;
155 const WSAENOPROTOOPT: number;
156 const WSAEPROTONOSUPPORT: number;
157 const WSAESOCKTNOSUPPORT: number;
158 const WSAEOPNOTSUPP: number;
159 const WSAEPFNOSUPPORT: number;
160 const WSAEAFNOSUPPORT: number;
161 const WSAEADDRINUSE: number;
162 const WSAEADDRNOTAVAIL: number;
163 const WSAENETDOWN: number;
164 const WSAENETUNREACH: number;
165 const WSAENETRESET: number;
166 const WSAECONNABORTED: number;
167 const WSAECONNRESET: number;
168 const WSAENOBUFS: number;
169 const WSAEISCONN: number;
170 const WSAENOTCONN: number;
171 const WSAESHUTDOWN: number;
172 const WSAETOOMANYREFS: number;
173 const WSAETIMEDOUT: number;
174 const WSAECONNREFUSED: number;
175 const WSAELOOP: number;
176 const WSAENAMETOOLONG: number;
177 const WSAEHOSTDOWN: number;
178 const WSAEHOSTUNREACH: number;
179 const WSAENOTEMPTY: number;
180 const WSAEPROCLIM: number;
181 const WSAEUSERS: number;
182 const WSAEDQUOT: number;
183 const WSAESTALE: number;
184 const WSAEREMOTE: number;
185 const WSASYSNOTREADY: number;
186 const WSAVERNOTSUPPORTED: number;
187 const WSANOTINITIALISED: number;
188 const WSAEDISCON: number;
189 const WSAENOMORE: number;
190 const WSAECANCELLED: number;
191 const WSAEINVALIDPROCTABLE: number;
192 const WSAEINVALIDPROVIDER: number;
193 const WSAEPROVIDERFAILEDINIT: number;
194 const WSASYSCALLFAILURE: number;
195 const WSASERVICE_NOT_FOUND: number;
196 const WSATYPE_NOT_FOUND: number;
197 const WSA_E_NO_MORE: number;
198 const WSA_E_CANCELLED: number;
199 const WSAEREFUSED: number;
200 }
201 namespace priority {
202 const PRIORITY_LOW: number;
203 const PRIORITY_BELOW_NORMAL: number;
204 const PRIORITY_NORMAL: number;
205 const PRIORITY_ABOVE_NORMAL: number;
206 const PRIORITY_HIGH: number;
207 const PRIORITY_HIGHEST: number;
208 }
209 }
210
211 function arch(): string;
212 function platform(): NodeJS.Platform;
213 function tmpdir(): string;
214 const EOL: string;
215 function endianness(): "BE" | "LE";
216 /**
217 * Gets the priority of a process.
218 * Defaults to current process.
219 */
220 function getPriority(pid?: number): number;
221 /**
222 * Sets the priority of the current process.
223 * @param priority Must be in range of -20 to 19
224 */
225 function setPriority(priority: number): void;
226 /**
227 * Sets the priority of the process specified process.
228 * @param priority Must be in range of -20 to 19
229 */
230 function setPriority(pid: number, priority: number): void;
231}