Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Brownman <beamneocube@gmail.com>2021-04-11 08:54:28 +0300
committerDanielle Adams <adamzdanielle@gmail.com>2021-05-08 19:44:45 +0300
commit505123c44b425cf227c3b2f4f930d1135268982c (patch)
treebed479155baf55b5b0ac39ef8611742a54338f7e /lib
parent546a28fe12078b169f2d2b579d9683cff48719b8 (diff)
typings: add JSDoc to os module functions
PR-URL: https://github.com/nodejs/node/pull/38197 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/os.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/os.js b/lib/os.js
index d03be051d09..d02a4ada5de 100644
--- a/lib/os.js
+++ b/lib/os.js
@@ -76,8 +76,17 @@ const [
const getHomeDirectory = getCheckedFunction(_getHomeDirectory);
const getHostname = getCheckedFunction(_getHostname);
const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses);
+/**
+ * @returns {string}
+ */
const getOSRelease = () => release;
+/**
+ * @returns {string}
+ */
const getOSType = () => type;
+/**
+ * @returns {string}
+ */
const getOSVersion = () => version;
getFreeMem[SymbolToPrimitive] = () => getFreeMem();
@@ -93,11 +102,30 @@ const kEndianness = isBigEndian ? 'BE' : 'LE';
const avgValues = new Float64Array(3);
+/**
+ * @returns {[number, number, number]}
+ */
function loadavg() {
getLoadAvg(avgValues);
return [avgValues[0], avgValues[1], avgValues[2]];
}
+/**
+ * Returns an array of objects containing information about each
+ * logical CPU core.
+ *
+ * @returns {Array<{
+ * model: string
+ * speed: number
+ * times: {
+ * user: number
+ * nice: number
+ * sys: number
+ * idle: number
+ * irq: number
+ * }
+ * }>}
+ */
function cpus() {
// [] is a bugfix for a regression introduced in 51cea61
const data = getCPUs() || [];
@@ -119,16 +147,25 @@ function cpus() {
return result;
}
+/**
+ * @returns {string}
+ */
function arch() {
return process.arch;
}
arch[SymbolToPrimitive] = () => process.arch;
+/**
+ * @returns {string}
+ */
function platform() {
return process.platform;
}
platform[SymbolToPrimitive] = () => process.platform;
+/**
+ * @returns {string}
+ */
function tmpdir() {
var path;
if (isWindows) {
@@ -150,6 +187,9 @@ function tmpdir() {
}
tmpdir[SymbolToPrimitive] = () => tmpdir();
+/**
+ * @returns {'BE' | 'LE'}
+ */
function endianness() {
return kEndianness;
}
@@ -199,6 +239,17 @@ function getCIDR(address, netmask, family) {
return `${address}/${ones}`;
}
+/**
+ * @returns {Record<string, Array<{
+ * address: string
+ * netmask: string
+ * family: 'IPv4' | 'IPv6'
+ * mac: string
+ * internal: boolean
+ * scopeid: number
+ * cidr: string | null
+ * }>>}
+ */
function networkInterfaces() {
const data = getInterfaceAddresses();
const result = {};
@@ -229,6 +280,11 @@ function networkInterfaces() {
return result;
}
+/**
+ * @param {number} pid
+ * @param {number} priority
+ * @returns {void}
+ */
function setPriority(pid, priority) {
if (priority === undefined) {
priority = pid;
@@ -244,6 +300,10 @@ function setPriority(pid, priority) {
throw new ERR_SYSTEM_ERROR(ctx);
}
+/**
+ * @param {number} pid
+ * @returns {number}
+ */
function getPriority(pid) {
if (pid === undefined)
pid = 0;
@@ -259,6 +319,18 @@ function getPriority(pid) {
return priority;
}
+/**
+ * @param {{ encoding?: string }} options If `encoding` is set to `'buffer'`,
+ * the `username`, `shell`, and `homedir` values will be `Buffer` instances.
+ * Default: `'utf8'`
+ * @returns {{
+ * uid: number
+ * gid: number
+ * username: string
+ * homedir: string
+ * shell: string | null
+ * }}
+ */
function userInfo(options) {
if (typeof options !== 'object')
options = null;