Node.js process.getgroups() 方法
process.getgroups() 方法是 Process 模块的内置应用程序编程接口,用于获取补充组 ID。
句法:
process.getgroups();
参数:此方法不接受任何参数。
返回:它返回一个指定补充组 ID 的整数数组。
注意:此函数仅适用于 POSIX 平台。在 windows 或 android 平台上不可用,因此会导致错误,即 TypeError, getgroups is not a 函数。
下面的例子说明了在 Node.js 中process.getgroups() 方法的使用:
示例 1:
// Allocating process module
const process = require('process');
// Printing the supplementary group IDs.
console.log(process.getgroups());
输出:
[0]
示例 2:
// Allocating process module
const process = require('process');
// Checking whether the method exists or not
if (process.getgroups) {
// Printing getgroups() values
console.log("The supplementary group IDs :"
+ process.getgroups());
}
输出:
The supplementary group IDs :[0]
参考: https://nodejs.org/api/process.html#process_process_getgroups