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 ...
随机推荐
- PAT 1014 福尔摩斯的约会 (20)(代码+思路)
1014 福尔摩斯的约会 (20)(20 分) 大侦探福尔摩斯接到一张奇怪的字条:"我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfd ...
- The 10 Best Choices On The Market Review 2018
Looking to buy a scan tool or considering one of Autel Scanner impressive product line?. The company ...
- 深入研究 UCenter API For .NET
康盛旗下产品的搭建 来自http://www.dozer.cc/2011/02/ucenter-api-in-depth-4th/ 1.UCenter 这个当然是最基本的东西,安装起来也很简单,官方就 ...
- qt小程序
hello: #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApp ...
- 服务程序 -st
Windows 服务由三部分组成:1.一个服务可执行文件:2.一个服务控制程序(SCP):3.服务控制管理器(SCM),负责在 HKLM\SYSTEM\CurrentControlSet\Servic ...
- 社交类APP原型模板分享——QQ
QQ是一款社交类的APP应用——聊天软件,支持多人群聊以及丰富有趣的娱乐功能. 此模板交互效果很丰富,主要有抽屉侧拉效果,滚动内容界面.标签组切换.选择组件触发按钮状态变化.点击下拉展开列表.点击弹出 ...
- nginx设置代理配置
server { listen 8086; resolver 8.8.8.8; location /{ ...
- 使用crf++
在example文件夹下存在4个使用crf的实例 1.在命令行执行 进入路径:./example/seg 执行:sh exec.sh 2. 在python中执行 进入路径:./python 执行:(1 ...
- hdu--6178(多校
题意:要在一棵 n 个点的树上放 k 只猴子,然后删掉尽量多的边,使得删边后,每只猴子都至少和另外一只猴子相连,问最后剩下的边数. 思路:其实dfs遍历一次看有多少个点-边-点就好了,比赛的时候就觉得 ...
- vue组件实现查看大图效果
使用的index.vue代码 <template> <img :src="imgUrl" @click="clickImg($event)"& ...