摘要: 转自:http://www.runoob.com/nodejs/nodejs-module-system.html 为了让Node.js的文件可以相互调用,Node.js提供了一个简单的模块系统。 模块是Node.js 应用程序的基本组成部分,文件和模块是一一对应的。换言之,一个 Node.js 文 阅读全文
posted @ 2017-12-16 17:27 Sharpest 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-stream.html 链式是通过连接输出流到另外一个流并创建多个流操作链的机制。链式流一般用于管道操作。 接下来我们就是用管道和链式来压缩和解压文件。 创建 compress.js 文件, 代码如下: 代码执行结果如下: 阅读全文
posted @ 2017-12-16 16:16 Sharpest 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-stream.html 管道提供了一个输出流到输入流的机制。通常我们用于从一个流中获取数据并将数据传递到另外一个流中。 如上面的图片所示,我们把文件比作装水的桶,而水就是文件里的内容,我们用一根管子(pipe)连接两个桶使 阅读全文
posted @ 2017-12-16 16:02 Sharpest 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-stream.html Stream 是一个抽象接口,Node 中有很多对象实现了这个接口。例如,对http 服务器发起请求的request 对象就是一个 Stream,还有stdout(标准输出)。 Node.js,St 阅读全文
posted @ 2017-12-16 15:58 Sharpest 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 转自:https://blog.csdn.net/u011127019/article/details/52513109 阅读全文
posted @ 2017-12-16 14:28 Sharpest 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 转自:https://blog.csdn.net/u011127019/article/details/52512242 阅读全文
posted @ 2017-12-16 14:14 Sharpest 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 转自:https://blog.csdn.net/u011127019/article/details/52512242 阅读全文
posted @ 2017-12-16 11:23 Sharpest 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html EventEmitter 提供了多个属性,如 on 和 emit。on 函数用于绑定事件函数,emit 属性用于触发一个事件。接下来我们来具体看下 EventEmitter 的属性介绍。 移除指 阅读全文
posted @ 2017-12-16 10:24 Sharpest 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js 所有的异步 I/O 操作在完成时都会发送一个事件到事件队列。 Node.js里面的许多对象都会分发事件:一个net.Server对象会在每次有新连接时分发一个事件, 一个fs.r 阅读全文
posted @ 2017-12-16 10:13 Sharpest 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高。 Node.js 的每一个 API 都是异步的,并作为一个独立线程运行,使用异步函数调用,并处理并发。 Nod 阅读全文
posted @ 2017-12-16 09:55 Sharpest 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js 异步编程的直接体现就是回调。 异步编程依托于回调来实现,但不能说使用了回调后程序就异步化了。 回调函数在完成任务后就会被调用,Node 使用了大量的回调函数,Node 所有 AP 阅读全文
posted @ 2017-12-16 09:44 Sharpest 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html ctrl + c - 退出当前终端。 ctrl + c 按下两次 - 退出 Node REPL。 ctrl + d - 退出 Node REPL. 向上/向下 键 - 查看输入的历史命令 tab 阅读全文
posted @ 2017-12-16 09:39 Sharpest 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.runoob.com/nodejs/nodejs-tutorial.html Node.js REPL(Read Eval Print Loop:交互式解释器) 表示一个电脑的环境,类似 Window 系统的终端或 Unix/Linux shell,我们可以在终端中输入命 阅读全文
posted @ 2017-12-16 09:37 Sharpest 阅读(153) 评论(0) 推荐(0) 编辑