Elide fournit l’espace de noms standard node:os, notamment :
- les informations sur la plateforme :
arch,platform,type,endianness,machine,releaseetversion - les chemins et données de l’hôte :
tmpdir,homedir,hostname,userInfoetnetworkInterfaces - les données sur les ressources :
availableParallelism,cpus,freemem,totalmem,uptime,loadavg,getPriorityetsetPriority EOL,devNulletconstants
import os from "node:os";
console.log(os.platform(), os.arch());
console.log(os.userInfo().username);
console.log(os.tmpdir());userInfo({ encoding: "buffer" }) renvoie des valeurs Buffer pour le nom
d’utilisateur, le répertoire personnel et le shell. networkInterfaces()
renvoie des enregistrements comprenant l’adresse, le masque de réseau, la
famille, l’adresse MAC, l’état de boucle locale, le CIDR et l’identifiant de
portée IPv6.
Les enregistrements de CPU indiquent le modèle et la vitesse de chaque cœur ;
leurs champs times valent zéro.
Consultez la documentation os de Node.js pour les formes de retour standard.
Reference
Status: Full · Not measured · since 1.1.0
Exports
| Export | Kind | Status | Notes |
|---|---|---|---|
arch() | function | Full | Returns the CPU architecture of the process (e.g. “x64”, “arm64”) |
cpus() | function | Full | Returns an array of objects describing each logical CPU core |
endianness() | function | Full | Returns the endianness of the CPU: “BE” (big-endian) or “LE” (little-endian) |
freemem() | function | Full | Returns the amount of free system memory in bytes |
homedir() | function | Full | Returns the current user’s home directory path |
hostname() | function | Full | Returns the host name of the operating system |
loadavg() | function | Full | Returns the 1, 5, and 15-minute system load averages |
networkInterfaces() | function | Full | Returns an object mapping interface names to their address entries |
platform() | function | Full | Returns the operating system platform (e.g. “linux”, “darwin”, “win32”) |
release() | function | Full | Returns the OS release version string |
tmpdir() | function | Full | Returns the operating system’s default directory for temporary files |
totalmem() | function | Full | Returns the total amount of system memory in bytes |
type() | function | Full | Returns the OS name (e.g. “Linux”, “Darwin”, “Windows_NT”) |
uptime() | function | Full | Returns the system uptime in seconds |
userInfo() | function | Full | Returns information about the currently effective user |
machine() | function | Full | Returns the machine type as a string, such as “arm64”, “x86_64”, etc |
version() | function | Full | Returns the operating system kernel version string |
availableParallelism() | function | Full | Returns an estimate of the default amount of parallelism a program should use, respecting cgroups and CPU… |
getPriority() | function | Full | Returns the scheduling priority for the process specified by pid |
setPriority() | function | Full | Sets the scheduling priority for the process specified by pid |
EOL | property | Full | The operating system end-of-line character sequence (\n on POSIX, \r\n on Windows) |
devNull | property | Full | The null device path (/dev/null on POSIX, \\.\nul on Windows) |
constants | property | Full | Object containing signal, errno, dlopen, and priority constants |
os.constants.signals | constant | Full | SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT and 27 more |
os.constants.errno | constant | Full | EPERM, ENOENT, ESRCH, EINTR, EIO, ENXIO and 81 more |
os.constants.dlopen | constant | Full | RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_DEEPBIND |
os.constants.priority | constant | Full | PRIORITY_LOW, PRIORITY_BELOW_NORMAL, PRIORITY_NORMAL, PRIORITY_ABOVE_NORMAL, PRIORITY_HIGH, PRIORITY_HIGHEST |
os.constants | constant | Full | UV_UDP_REUSEADDR |