انتقل إلى المحتوى

مرجع واجهة ⁦node:os⁩

معلومات المنصة والموارد والمستخدم وواجهات الشبكة

في هذه الصفحة
Open in ChatGPTOpen in Claude

يوفر ⁦Elide⁩ نطاق الأسماء القياسي ⁦node:os⁩، بما في ذلك:

  • معلومات المنصة: ⁦arch⁩ و⁦platform⁩ و⁦type⁩ و⁦endianness⁩ و⁦machine⁩ و⁦release⁩ و⁦version⁩
  • المسارات وبيانات المضيف: ⁦tmpdir⁩ و⁦homedir⁩ و⁦hostname⁩ و⁦userInfo⁩ و ⁦networkInterfaces⁩
  • بيانات الموارد: ⁦availableParallelism⁩ و⁦cpus⁩ و⁦freemem⁩ و⁦totalmem⁩ و⁦uptime⁩ و⁦loadavg⁩ و⁦getPriority⁩ و⁦setPriority⁩
  • ⁦EOL⁩ و⁦devNull⁩ و⁦constants⁩
import os from "node:os";

console.log(os.platform(), os.arch());
console.log(os.userInfo().username);
console.log(os.tmpdir());

يعيد ⁦userInfo({ encoding: "buffer" })⁩ قيم ⁦Buffer⁩ لاسم المستخدم و المجلد الرئيسي والصدفة. ويعيد ⁦networkInterfaces()⁩ سجلات تتضمن العنوان وقناع الشبكة والعائلة وعنوان ⁦MAC⁩ وحالة الواجهة المحلية و⁦CIDR⁩ ومعرّف نطاق ⁦IPv6⁩.

تُبلغ سجلات المعالج عن طراز كل نواة وسرعتها؛ وحقول ⁦times⁩ فيها صفر.

راجع توثيق ⁦os⁩ في ⁦Node.js⁩ لأشكال القيم المعادة القياسية.

Reference

Status: Full · Not measured · since 1.1.0

Exports

ExportKindStatusNotes
arch()functionFullReturns the CPU architecture of the process (e.g. “x64”, “arm64”)
cpus()functionFullReturns an array of objects describing each logical CPU core
endianness()functionFullReturns the endianness of the CPU: “BE” (big-endian) or “LE” (little-endian)
freemem()functionFullReturns the amount of free system memory in bytes
homedir()functionFullReturns the current user’s home directory path
hostname()functionFullReturns the host name of the operating system
loadavg()functionFullReturns the 1, 5, and 15-minute system load averages
networkInterfaces()functionFullReturns an object mapping interface names to their address entries
platform()functionFullReturns the operating system platform (e.g. “linux”, “darwin”, “win32”)
release()functionFullReturns the OS release version string
tmpdir()functionFullReturns the operating system’s default directory for temporary files
totalmem()functionFullReturns the total amount of system memory in bytes
type()functionFullReturns the OS name (e.g. “Linux”, “Darwin”, “Windows_NT”)
uptime()functionFullReturns the system uptime in seconds
userInfo()functionFullReturns information about the currently effective user
machine()functionFullReturns the machine type as a string, such as “arm64”, “x86_64”, etc
version()functionFullReturns the operating system kernel version string
availableParallelism()functionFullReturns an estimate of the default amount of parallelism a program should use, respecting cgroups and CPU…
getPriority()functionFullReturns the scheduling priority for the process specified by pid
setPriority()functionFullSets the scheduling priority for the process specified by pid
EOLpropertyFullThe operating system end-of-line character sequence (\n on POSIX, \r\n on Windows)
devNullpropertyFullThe null device path (/dev/null on POSIX, \\.\nul on Windows)
constantspropertyFullObject containing signal, errno, dlopen, and priority constants
os.constants.signalsconstantFullSIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT and 27 more
os.constants.errnoconstantFullEPERM, ENOENT, ESRCH, EINTR, EIO, ENXIO and 81 more
os.constants.dlopenconstantFullRTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_DEEPBIND
os.constants.priorityconstantFullPRIORITY_LOW, PRIORITY_BELOW_NORMAL, PRIORITY_NORMAL, PRIORITY_ABOVE_NORMAL, PRIORITY_HIGH, PRIORITY_HIGHEST
os.constantsconstantFullUV_UDP_REUSEADDR

هل كانت هذه الصفحة مفيدة؟