UNPKG

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