
nodejs
微机原理通识
偏爱前端
展开
-
HTTP服务器http-server
http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it’s simple and hackable enough to be used for testing, local development, and lea...原创 2018-04-18 14:02:39 · 1896 阅读 · 0 评论 -
服务器代理工具NProxy
1.安装 使用npm安装: npm install -g nproxy -V 查看版本号 -h 获取帮助信息 -l 定义替换规则文件 -p 定义代理监听端口,默认为8989 -t 定义请求超时时间 nproxy -t 5 module.exports = [ //1.单个文件替换(本地) { ...原创 2018-04-18 14:04:47 · 1032 阅读 · 0 评论 -
Nodejs文件的压缩与解压===使用管道实现
本文转载自:https://blog.youkuaiyun.com/u013127751/article/details/78537957 //所有的 Stream 对象都是 EventEmitter 的实例,所以可以使用EventEmitter类的方法 /* * 从流中读取数据 */ var fs = require("fs"); var data = ''; //创建可读流 var reade...转载 2018-08-17 15:03:40 · 1656 阅读 · 0 评论 -
npm的简单安装用法
npm node package manager http-server anywhere npm库 帮我们将我们的包上传到网上 第三方模块 我们下载的模块 不需要加./ 引得是 module.paths 安装 卸载 发布 安装前 npm init -y 初始化前先关心当前文件夹 不能有中文 特殊字符串 不能用要安装的模块来命名 初始化一个package.json 不能写注释 不能加标点 如果...原创 2018-11-29 00:15:08 · 643 阅读 · 0 评论 -
es6 -- promisify
promise的简单使用 (() => new Promise((resolve, reject) => setTimeout(() => resolve('jianyong'), 2000)))().then(data => console.log(data)) 上面一行恶心的代码等价于: function getName() { let p p = n...转载 2018-12-02 14:00:52 · 476 阅读 · 0 评论 -
es6 -- Buffer
通过长度创建buffer: let buffer = Buffer.alloc(100); console.log(buffer) 得到:<buffer 00 00 00 00 00 00 00 00···> 100个 比较消耗性能:先将100字节清空再分配 let buffer = Buffer.allocUnsafe(100); 不清空,可能还有上一次的内容 数组转bu...原创 2018-12-02 14:25:08 · 934 阅读 · 0 评论 -
node核心模块--Util
class child{} class parent{ constructor(){ } sleep(){console.log("i'm sleeping")} } //实现继承 let child = new child(); let parent = new parent(); //原生写法: child.prototype.__proto__ = parent.prototype...原创 2018-11-29 19:19:15 · 199 阅读 · 0 评论 -
node模块的引用过程
劲爆 自定义模块: class cal{ constructor(){ this.a = 'wo hen shuai' } static tittle(){ return '标题'; } calc((...args)=>{ return args.reduce((prev,next)=>{ return prev + next; }); }); } ...原创 2018-11-28 00:28:11 · 305 阅读 · 0 评论