node-lessons
教程:https://github.com/alsotang/node-lessons
0
nvm 的全称是 Node Version Manager,之所以需要这个工具,是因为 Node.js 的各种特性都没有稳定下来,所以我们经常由于老项目或尝新的原因,需要切换各种版本。
安装:$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.2/install.sh | bash
安装node:nvm install 0.12
查看:nvm ls
1
查看该项目安装的模块
ls node_modules
或者npm list,这是全局的,有一定的结构
2
npm init初始化,会生成一份简单地package.json
npm install express utility --save 可以一次安装两个模块,--才是保存
utility包含了很多辅助方法,而crypto只是单独做加密的;
3爬虫
superagent:http 方面的库,可以发起 get 或 post 请求
好好看看 superagent 的 API,它把链式调用的风格玩到了极致
4并发
eventproxy 没接触过
5async
async demo:https://github.com/alsotang/async_demo
可以控制并发数:mapLimit; queue
这节写的真好。
5测试
require.main === module: // 如果是直接执行 main.js,则进入此处 // 如果 main.js 被其他文件 require,则此处不会执行。
mian.text 不能引入 main? 同级的话require('./main');
执行测试:mocha main.test
var main = require('./main');
var should = require('should');
describe('main.test.js', function(){
it('should equal 55 when n === 10', function(){
main.fibonacci(10).should.equal(55);
})
})
describe 中的字符串,用来描述你要测的主体是什么;it 当中,描述具体的 case 内容。
mocha 测试库
should 断言库
expect 断言库
这就是传说中的测试驱动开发:先把要达到的目的都描述清楚,然后让现有的程序跑不过 case,再修补程序,让 case 通过。
istanbul 覆盖率
打开看看:open coverage/lcov-report/index.html 也可以直接打开页面
makefile:http://blog.csdn.net/haoel/article/details/2886
10 benchmark
nodejs的性能测试,和jsPerf结合使用
https://github.com/bestiejs/benchmark.js
http://jsperf.com
11 闭包
node 有一个全局对象global;浏览器全局对象window
sublimelinter没有正常使用
闭包:内部函数可以访问定义在外部函数中的变量。现在学习主要是为了使用,所以看一个知识点,一定要知道有什么用
var adder = function (x) {
var base = x;
return function (n) {
return n + base;
};
};
var add10 = adder(10);
console.log(add10(5));
var add20 = adder(20);
console.log(add20(5));
闭包的坑:不是每一种for循环的代码,都会碰到这个坑,而是里面的代码如果是异步或过一会才执行的话,就需要(idx)(i)了
14 最佳实践
在 js 中,务必使用 === 三个等于号来比较对象,或者自定义方法来比较,不要使用 ==。
我最近做一个项目,从数据库中取出的数据,虽然应该是字符型的,但有时它们是 String 的表示,有时是 Number 的表示。为了省事,会有人直接用 == 来对它们进行比较。这种时候,建议在比较时,把它们都转成 String 类型,然后用 === 来比较。
比如 var x = 31243; var y = '31243',比较时,这么做:String(x) === String(y)
lodash:https://lodash.com/docs js的工具库 http://www.cnblogs.com/Leo_wl/p/4418781.html
node-lessons的更多相关文章
- babeljs源码
babel.min.js!function(e,t){"object"==typeof exports&&"object"==typeof mo ...
- 如何搭建 node,react 开发环境
项目相关内容:Sublime + Node + React --注意:在 windows 操作系统中,如果把 node 安装在系统盘(一般是C盘),会导致 node 没有操作文件的权限的问题,如无法新 ...
- [Whole Web] [Node.js] Using npm run to launch local scripts
npm run allows you to configure scripts inside of your package.json file which can access locally in ...
- [Node.js] Using npm link to use node modules that are "in progress"
It is some times convenient, even necessary, to make use of a module that you are working on before ...
- [Server Running] [Node.js, PM2] Using PM2 To Keep Your Node Apps Alive
PM2 is a production process manager for Node.js applications with a built-in load balancer. It allow ...
- Codeforces 915E Physical Education Lessons
原题传送门 我承认,比赛的时候在C题上卡了好久(最后也不会),15min水掉D后(最后还FST了..),看到E时已经只剩15min了.尽管一眼看出是离散化+线段树的裸题,但是没有时间写,实在尴尬. 赛 ...
- 【题解】Luogu CF915E Physical Education Lessons
原题传送门:CF915E Physical Education Lessons 前置芝士:珂朵莉树 窝博客里对珂朵莉树的介绍 没什么好说的自己看看吧 这道题很简单啊 每个操作就是区间赋值,顺带把总和修 ...
- Codeforces 915 E Physical Education Lessons
题目描述 This year Alex has finished school, and now he is a first-year student of Berland State Univers ...
- How do I get started with Node.js
From: http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js Tutorials NodeSch ...
- [AngularFire2] Build a Custom Node Backend Using Firebase Queue
In this lesson we are going to learn how to build a custom Node process for batch processing of Fire ...
随机推荐
- javascript 高级程序设计 十
理解JS对象(2)创建对象 JS中创建对象的方式有很多,我们把他们统称为模式. 工厂模式: 优点:解决了创建多个相似对象的问题. 缺点:没有解决对象识别问题.(不知道一个实例对象的类型) func ...
- POJ2230 Watchcow
原题链接 类欧拉回路,要求每条边被正反各经过一次,且从\(1\)出发并回到\(1\). 只需每次搜索该点的边时,将该点的边对应的邻接表头及时修改为下一条即可,因为邻接表恰好储存了正反方向的边,所以及时 ...
- Windows下的PHP 5.3.x安装 Zend Guard Loader
PHP5.3之后不再使用Zend Optimizer而是由Zend Guard Loader替换,而Zend Guard Loader安装比前者方便了很多,只有一个dll: 址:http://down ...
- [最新原创电子书]lazarus开发者入门及中级教程
目前市面上没有任何一本完整的书,介绍Lazarus,Firebird这两个优秀的开发工具,同时还有一个作为他们之间桥梁的开发套件ZeosDBO,也没有任何完整的中文开发指南,本书以这三种开发套件为主线 ...
- 在 Ubuntu 上使用微信客户端
原文地址: http://www.myzaker.com/article/5979115d1bc8e08c30000071/ 在这个快速信息交互时代,无论是工作还是生活,都需要频繁的网络社交,而在中国 ...
- websocket activemq
websocket:应用与服务端保持长连接 不停通信 activemq:偶发通信 心跳机制
- NotificationMangerService处理显示通知
设置——>应用——>点击“已下载”列表中的任一APP,如图: 代码位置:Settings\src\com\android\settings\applications\InstalledA ...
- 在WebGrid中做 批量删除操作
一般的MVC WebGrid都是在每一行中加入 Edit Detail Delete 这些Link 去对每条记录去单独操作. 稍微研究了一下总结一个 做批量删除的办法. 1. 首先是在WebGrid中 ...
- hdu--6178(多校
题意:要在一棵 n 个点的树上放 k 只猴子,然后删掉尽量多的边,使得删边后,每只猴子都至少和另外一只猴子相连,问最后剩下的边数. 思路:其实dfs遍历一次看有多少个点-边-点就好了,比赛的时候就觉得 ...
- jquery 特效
http://demo.howtoexe.com/instagram-gravity-gallery/index.html