当前位置:网站首页>Nodejs (II) read files synchronously and asynchronously
Nodejs (II) read files synchronously and asynchronously
2022-04-23 07:47:00 【youth who behaves like an adult】
var fs = require("fs");
var data = fs.readFileSync('test.txt');
console.log(data.toString());
console.log("Program Ended 001");
fs.readFile('test.txt', function (err, data) {
if (err) return console.error(err);
console.log(data.toString());
});
console.log("Program Ended 002");
introduce fs modular , Synchronous read function readFileSync, Asynchronous read function readFile.
In general NodeJS Every one of API It's all asynchronous , As a single thread , It USES An asynchronous function Transfer to Maintenance concurrency .Node Using observer mode .Node The thread maintains an event loop , Whenever any task is completed, you get the result , It triggers the notification event listener function to execute the corresponding event .
版权声明
本文为[youth who behaves like an adult]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230626191138.html
边栏推荐
猜你喜欢
Dropping Pixels for Adversarial Robustness
Django uses MySQL database to solve error reporting
SAP SALV14 后台输出SALV数据可直接保存文件,发送Email(带排序、超链接、筛选格式)
Mongodb 启动警告信息处理
SVG中Path Data数据简化及文件夹所有文件批量导出为图片
基于NLP的软件安全研究(一)
Authorization+Token+JWT
SAP TRANSLATE使用数据对象掩码示例
Scrapy 修改爬虫结束时统计数据中的时间为当前系统时间
SAP ECC连接SAP PI系统配置
随机推荐
中间人环境mitmproxy搭建
数组扁平化
系统与软件安全研究(三)
颜色转换公式大全及转换表格(31种)
系统与软件安全研究(五)
定位、修饰样式
SAP PI/PO功能运行状态监控检查
7. sub query
反转链表练习
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
Common DOS commands
SAP PI/PO rfc2RESTful 發布rfc接口為RESTful示例(Proxy間接法)
9. Common functions
Use of typescript dictionary
MySQL storage engine
Django uses MySQL database to solve error reporting
js之作用域、作用域链、全局变量和局部变量
根据某一指定的表名、列名及列值来向前或向后N条查相关列值的SQL自定义标量值函数
js中对象的三种创建方式
防抖和节流