githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

os.d.ts (16685B)


      1 /**
      2  * The `os` module provides operating system-related utility methods and
      3  * properties. It can be accessed using:
      4  *
      5  * ```js
      6  * import os from 'node:os';
      7  * ```
      8  * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/os.js)
      9  */
     10 declare module "os" {
     11     interface CpuInfo {
     12         model: string;
     13         speed: number;
     14         times: {
     15             user: number;
     16             nice: number;
     17             sys: number;
     18             idle: number;
     19             irq: number;
     20         };
     21     }
     22     interface NetworkInterfaceBase {
     23         address: string;
     24         netmask: string;
     25         mac: string;
     26         internal: boolean;
     27         cidr: string | null;
     28     }
     29     interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
     30         family: "IPv4";
     31     }
     32     interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
     33         family: "IPv6";
     34         scopeid: number;
     35     }
     36     interface UserInfo<T> {
     37         username: T;
     38         uid: number;
     39         gid: number;
     40         shell: T | null;
     41         homedir: T;
     42     }
     43     type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
     44     /**
     45      * Returns the host name of the operating system as a string.
     46      * @since v0.3.3
     47      */
     48     function hostname(): string;
     49     /**
     50      * Returns an array containing the 1, 5, and 15 minute load averages.
     51      *
     52      * The load average is a measure of system activity calculated by the operating
     53      * system and expressed as a fractional number.
     54      *
     55      * The load average is a Unix-specific concept. On Windows, the return value is
     56      * always `[0, 0, 0]`.
     57      * @since v0.3.3
     58      */
     59     function loadavg(): number[];
     60     /**
     61      * Returns the system uptime in number of seconds.
     62      * @since v0.3.3
     63      */
     64     function uptime(): number;
     65     /**
     66      * Returns the amount of free system memory in bytes as an integer.
     67      * @since v0.3.3
     68      */
     69     function freemem(): number;
     70     /**
     71      * Returns the total amount of system memory in bytes as an integer.
     72      * @since v0.3.3
     73      */
     74     function totalmem(): number;
     75     /**
     76      * Returns an array of objects containing information about each logical CPU core.
     77      *
     78      * The properties included on each object include:
     79      *
     80      * ```js
     81      * [
     82      *   {
     83      *     model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
     84      *     speed: 2926,
     85      *     times: {
     86      *       user: 252020,
     87      *       nice: 0,
     88      *       sys: 30340,
     89      *       idle: 1070356870,
     90      *       irq: 0
     91      *     }
     92      *   },
     93      *   {
     94      *     model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
     95      *     speed: 2926,
     96      *     times: {
     97      *       user: 306960,
     98      *       nice: 0,
     99      *       sys: 26980,
    100      *       idle: 1071569080,
    101      *       irq: 0
    102      *     }
    103      *   },
    104      *   {
    105      *     model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
    106      *     speed: 2926,
    107      *     times: {
    108      *       user: 248450,
    109      *       nice: 0,
    110      *       sys: 21750,
    111      *       idle: 1070919370,
    112      *       irq: 0
    113      *     }
    114      *   },
    115      *   {
    116      *     model: 'Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz',
    117      *     speed: 2926,
    118      *     times: {
    119      *       user: 256880,
    120      *       nice: 0,
    121      *       sys: 19430,
    122      *       idle: 1070905480,
    123      *       irq: 20
    124      *     }
    125      *   },
    126      * ]
    127      * ```
    128      *
    129      * `nice` values are POSIX-only. On Windows, the `nice` values of all processors
    130      * are always 0.
    131      * @since v0.3.3
    132      */
    133     function cpus(): CpuInfo[];
    134     /**
    135      * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
    136      * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
    137      *
    138      * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
    139      * about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
    140      * @since v0.3.3
    141      */
    142     function type(): string;
    143     /**
    144      * Returns the operating system as a string.
    145      *
    146      * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See
    147      * [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
    148      * @since v0.3.3
    149      */
    150     function release(): string;
    151     /**
    152      * Returns an object containing network interfaces that have been assigned a
    153      * network address.
    154      *
    155      * Each key on the returned object identifies a network interface. The associated
    156      * value is an array of objects that each describe an assigned network address.
    157      *
    158      * The properties available on the assigned network address object include:
    159      *
    160      * ```js
    161      * {
    162      *   lo: [
    163      *     {
    164      *       address: '127.0.0.1',
    165      *       netmask: '255.0.0.0',
    166      *       family: 'IPv4',
    167      *       mac: '00:00:00:00:00:00',
    168      *       internal: true,
    169      *       cidr: '127.0.0.1/8'
    170      *     },
    171      *     {
    172      *       address: '::1',
    173      *       netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
    174      *       family: 'IPv6',
    175      *       mac: '00:00:00:00:00:00',
    176      *       scopeid: 0,
    177      *       internal: true,
    178      *       cidr: '::1/128'
    179      *     }
    180      *   ],
    181      *   eth0: [
    182      *     {
    183      *       address: '192.168.1.108',
    184      *       netmask: '255.255.255.0',
    185      *       family: 'IPv4',
    186      *       mac: '01:02:03:0a:0b:0c',
    187      *       internal: false,
    188      *       cidr: '192.168.1.108/24'
    189      *     },
    190      *     {
    191      *       address: 'fe80::a00:27ff:fe4e:66a1',
    192      *       netmask: 'ffff:ffff:ffff:ffff::',
    193      *       family: 'IPv6',
    194      *       mac: '01:02:03:0a:0b:0c',
    195      *       scopeid: 1,
    196      *       internal: false,
    197      *       cidr: 'fe80::a00:27ff:fe4e:66a1/64'
    198      *     }
    199      *   ]
    200      * }
    201      * ```
    202      * @since v0.6.0
    203      */
    204     function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
    205     /**
    206      * Returns the string path of the current user's home directory.
    207      *
    208      * On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
    209      * uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
    210      *
    211      * On Windows, it uses the `USERPROFILE` environment variable if defined.
    212      * Otherwise it uses the path to the profile directory of the current user.
    213      * @since v2.3.0
    214      */
    215     function homedir(): string;
    216     /**
    217      * Returns information about the currently effective user. On POSIX platforms,
    218      * this is typically a subset of the password file. The returned object includes
    219      * the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and `gid` fields are `-1`, and `shell` is `null`.
    220      *
    221      * The value of `homedir` returned by `os.userInfo()` is provided by the operating
    222      * system. This differs from the result of `os.homedir()`, which queries
    223      * environment variables for the home directory before falling back to the
    224      * operating system response.
    225      *
    226      * Throws a `SystemError` if a user has no `username` or `homedir`.
    227      * @since v6.0.0
    228      */
    229     function userInfo(options: { encoding: "buffer" }): UserInfo<Buffer>;
    230     function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
    231     type SignalConstants = {
    232         [key in NodeJS.Signals]: number;
    233     };
    234     namespace constants {
    235         const UV_UDP_REUSEADDR: number;
    236         namespace signals {}
    237         const signals: SignalConstants;
    238         namespace errno {
    239             const E2BIG: number;
    240             const EACCES: number;
    241             const EADDRINUSE: number;
    242             const EADDRNOTAVAIL: number;
    243             const EAFNOSUPPORT: number;
    244             const EAGAIN: number;
    245             const EALREADY: number;
    246             const EBADF: number;
    247             const EBADMSG: number;
    248             const EBUSY: number;
    249             const ECANCELED: number;
    250             const ECHILD: number;
    251             const ECONNABORTED: number;
    252             const ECONNREFUSED: number;
    253             const ECONNRESET: number;
    254             const EDEADLK: number;
    255             const EDESTADDRREQ: number;
    256             const EDOM: number;
    257             const EDQUOT: number;
    258             const EEXIST: number;
    259             const EFAULT: number;
    260             const EFBIG: number;
    261             const EHOSTUNREACH: number;
    262             const EIDRM: number;
    263             const EILSEQ: number;
    264             const EINPROGRESS: number;
    265             const EINTR: number;
    266             const EINVAL: number;
    267             const EIO: number;
    268             const EISCONN: number;
    269             const EISDIR: number;
    270             const ELOOP: number;
    271             const EMFILE: number;
    272             const EMLINK: number;
    273             const EMSGSIZE: number;
    274             const EMULTIHOP: number;
    275             const ENAMETOOLONG: number;
    276             const ENETDOWN: number;
    277             const ENETRESET: number;
    278             const ENETUNREACH: number;
    279             const ENFILE: number;
    280             const ENOBUFS: number;
    281             const ENODATA: number;
    282             const ENODEV: number;
    283             const ENOENT: number;
    284             const ENOEXEC: number;
    285             const ENOLCK: number;
    286             const ENOLINK: number;
    287             const ENOMEM: number;
    288             const ENOMSG: number;
    289             const ENOPROTOOPT: number;
    290             const ENOSPC: number;
    291             const ENOSR: number;
    292             const ENOSTR: number;
    293             const ENOSYS: number;
    294             const ENOTCONN: number;
    295             const ENOTDIR: number;
    296             const ENOTEMPTY: number;
    297             const ENOTSOCK: number;
    298             const ENOTSUP: number;
    299             const ENOTTY: number;
    300             const ENXIO: number;
    301             const EOPNOTSUPP: number;
    302             const EOVERFLOW: number;
    303             const EPERM: number;
    304             const EPIPE: number;
    305             const EPROTO: number;
    306             const EPROTONOSUPPORT: number;
    307             const EPROTOTYPE: number;
    308             const ERANGE: number;
    309             const EROFS: number;
    310             const ESPIPE: number;
    311             const ESRCH: number;
    312             const ESTALE: number;
    313             const ETIME: number;
    314             const ETIMEDOUT: number;
    315             const ETXTBSY: number;
    316             const EWOULDBLOCK: number;
    317             const EXDEV: number;
    318             const WSAEINTR: number;
    319             const WSAEBADF: number;
    320             const WSAEACCES: number;
    321             const WSAEFAULT: number;
    322             const WSAEINVAL: number;
    323             const WSAEMFILE: number;
    324             const WSAEWOULDBLOCK: number;
    325             const WSAEINPROGRESS: number;
    326             const WSAEALREADY: number;
    327             const WSAENOTSOCK: number;
    328             const WSAEDESTADDRREQ: number;
    329             const WSAEMSGSIZE: number;
    330             const WSAEPROTOTYPE: number;
    331             const WSAENOPROTOOPT: number;
    332             const WSAEPROTONOSUPPORT: number;
    333             const WSAESOCKTNOSUPPORT: number;
    334             const WSAEOPNOTSUPP: number;
    335             const WSAEPFNOSUPPORT: number;
    336             const WSAEAFNOSUPPORT: number;
    337             const WSAEADDRINUSE: number;
    338             const WSAEADDRNOTAVAIL: number;
    339             const WSAENETDOWN: number;
    340             const WSAENETUNREACH: number;
    341             const WSAENETRESET: number;
    342             const WSAECONNABORTED: number;
    343             const WSAECONNRESET: number;
    344             const WSAENOBUFS: number;
    345             const WSAEISCONN: number;
    346             const WSAENOTCONN: number;
    347             const WSAESHUTDOWN: number;
    348             const WSAETOOMANYREFS: number;
    349             const WSAETIMEDOUT: number;
    350             const WSAECONNREFUSED: number;
    351             const WSAELOOP: number;
    352             const WSAENAMETOOLONG: number;
    353             const WSAEHOSTDOWN: number;
    354             const WSAEHOSTUNREACH: number;
    355             const WSAENOTEMPTY: number;
    356             const WSAEPROCLIM: number;
    357             const WSAEUSERS: number;
    358             const WSAEDQUOT: number;
    359             const WSAESTALE: number;
    360             const WSAEREMOTE: number;
    361             const WSASYSNOTREADY: number;
    362             const WSAVERNOTSUPPORTED: number;
    363             const WSANOTINITIALISED: number;
    364             const WSAEDISCON: number;
    365             const WSAENOMORE: number;
    366             const WSAECANCELLED: number;
    367             const WSAEINVALIDPROCTABLE: number;
    368             const WSAEINVALIDPROVIDER: number;
    369             const WSAEPROVIDERFAILEDINIT: number;
    370             const WSASYSCALLFAILURE: number;
    371             const WSASERVICE_NOT_FOUND: number;
    372             const WSATYPE_NOT_FOUND: number;
    373             const WSA_E_NO_MORE: number;
    374             const WSA_E_CANCELLED: number;
    375             const WSAEREFUSED: number;
    376         }
    377         namespace priority {
    378             const PRIORITY_LOW: number;
    379             const PRIORITY_BELOW_NORMAL: number;
    380             const PRIORITY_NORMAL: number;
    381             const PRIORITY_ABOVE_NORMAL: number;
    382             const PRIORITY_HIGH: number;
    383             const PRIORITY_HIGHEST: number;
    384         }
    385     }
    386     const devNull: string;
    387     const EOL: string;
    388     /**
    389      * Returns the operating system CPU architecture for which the Node.js binary was
    390      * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
    391      *
    392      * The return value is equivalent to `process.arch`.
    393      * @since v0.5.0
    394      */
    395     function arch(): string;
    396     /**
    397      * Returns a string identifying the kernel version.
    398      *
    399      * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
    400      * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
    401      * @since v13.11.0, v12.17.0
    402      */
    403     function version(): string;
    404     /**
    405      * Returns a string identifying the operating system platform. The value is set
    406      * at compile time. Possible values are `'aix'`, `'darwin'`, `'freebsd'`, `'linux'`, `'openbsd'`, `'sunos'`, and `'win32'`.
    407      *
    408      * The return value is equivalent to `process.platform`.
    409      *
    410      * The value `'android'` may also be returned if Node.js is built on the Android
    411      * operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
    412      * @since v0.5.0
    413      */
    414     function platform(): NodeJS.Platform;
    415     /**
    416      * Returns the operating system's default directory for temporary files as a
    417      * string.
    418      * @since v0.9.9
    419      */
    420     function tmpdir(): string;
    421     /**
    422      * Returns a string identifying the endianness of the CPU for which the Node.js
    423      * binary was compiled.
    424      *
    425      * Possible values are `'BE'` for big endian and `'LE'` for little endian.
    426      * @since v0.9.4
    427      */
    428     function endianness(): "BE" | "LE";
    429     /**
    430      * Returns the scheduling priority for the process specified by `pid`. If `pid` is
    431      * not provided or is `0`, the priority of the current process is returned.
    432      * @since v10.10.0
    433      * @param [pid=0] The process ID to retrieve scheduling priority for.
    434      */
    435     function getPriority(pid?: number): number;
    436     /**
    437      * Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used.
    438      *
    439      * The `priority` input must be an integer between `-20` (high priority) and `19` (low priority). Due to differences between Unix priority levels and Windows
    440      * priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range
    441      * mapping may cause the return value to be slightly different on Windows. To avoid
    442      * confusion, set `priority` to one of the priority constants.
    443      *
    444      * On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
    445      * privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`.
    446      * @since v10.10.0
    447      * @param [pid=0] The process ID to set scheduling priority for.
    448      * @param priority The scheduling priority to assign to the process.
    449      */
    450     function setPriority(priority: number): void;
    451     function setPriority(pid: number, priority: number): void;
    452 }
    453 declare module "node:os" {
    454     export * from "os";
    455 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror