IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

二十七、Node.js OS 模块

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

文章永久连接:https://tech.souyunku.com/?p=5470

Node.js os 模块提供了一些基本的系统操作函数

引入该模块

var os = require("os")

os 模块方法

方法 描述
os.tmpdir() 返回操作系统的默认临时文件夹
os.endianness() 返回 CPU 的字节序,可能的是 “BE” 或 “LE”
os.hostname() 返回操作系统的主机名
os.type() 返回操作系统名
os.platform() 返回操作系统名
os.arch() 返回操作系统 CPU 架构,可能的值有 “x64″、”arm” 和 “ia32”
os.release() 返回操作系统的发行版本
os.uptime() 返回操作系统运行的时间,以秒为单位
os.loadavg() 返回一个包含 1、5、15 分钟平均负载的数组
os.totalmem() 返回系统内存总量,单位为字节
os.freemem() 返回操作系统空闲内存量,单位是字节
os.cpus() 返回一个对象数组,包含所安装的每个 CPU/内核的信息:型号、速度(单位 MHz)、时间(一个包含 user、nice、sys、idle 和 irq 所使用 CPU/内核毫秒数的对象)
os.networkInterfaces() 获得网络接口列表

os 模块属性

属性 描述
os.EOL 定义了操作系统的行尾符的常量

范例

main.js

/*
 * filename: main.js
 * author: 搜云库技术团队(tech.souyunku.com)
 * Copyright © 2015-2065 tech.souyunku.com. All rights reserved.
*/

var os = require("os");

// CPU 的字节序
console.log('endianness : ' + os.endianness());
// 操作系统名
console.log('type : ' + os.type());
// 操作系统名
console.log('platform : ' + os.platform());
// 系统内存总量
console.log('total memory : ' + os.totalmem() + " bytes.");
// 操作系统空闲内存量
console.log('free memory : ' + os.freemem() + " bytes.");

运行以上 Node.js 脚本,输出结果如下

$ node main.js
endianness : LE
type : Darwin
platform : darwin
total memory : 4294967296 bytes.
free memory : 41181184 bytes.

干货推荐

本站推荐:精选优质专栏

附录:Node.js 教程:系列文章


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(95) 打赏



未经允许不得转载:搜云库技术团队 » 二十七、Node.js OS 模块

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367