Node way
- 13. CSS / JS / IMG
Java
HTML Template
猿题库
- 14. CSS /
JS / IMG
Java
HTML
Tmpl
主站
CSS /
JS / IMG
Java
HTML
Tmpl
公务员
CSS /
JS / IMG
Java
HTML
Tmpl
司法考试
CSS /
JS / IMG
Java
HTML
Tmpl
?高考
- 24. var agent = new http.Agent({
maxSockets: 2
});
!
req.request = request.defaults({
pool: agent
});
- 31. var val = 'hello world';
function outer() {
var val = 'bar';
return function inner() {
return val;
};
}
global.inner = outer();
- 32. var getUserData = (function () {
var cache = {};
return function (userId, callback) {
if (cache[id]) {
process.nextTick(function () {
callback(cache[id]);
});
return;
}
getUser(id, function (data) {
cache[id] = data;
callback(data);
});
};
}());
- 33. var getUserData = (function () {
var cache = new LRU({max: 100});
return function (userId, callback) {
if (cache.has(id)) {
var user = cache.get(‘id’);
process.nextTick(function () {
callback(user);
});
return;
}
getUser(id, function (data) {
cache.set(id, data);
callback(data);
});
};
}());
- 34. app.get(‘/users/:id’, function (req, res) {
getUser(function (req.param(‘id’), data) {
user = data;
getOrderByUser(user.id, function (order) {
res.render({
user: user,
order: order
});
});
});?
});
- 35. app.get(‘/users/:id’, function (req, res) {
getUser(function (req.param(‘id’), data) {
user = data;
getOrderByUser(user.id, function (order) {
res.render({
user: user,
order: order
});
});
});?
});
- 36. app.get(‘/users/:id’, function (req, res) {
getUser(function (req.param(‘id’), data) {
var user = data;
getOrderByUser(user.id, function (order) {
res.render({
user: user,
order: order
});
});
});?
});
- 37. app.get(‘/users/:id’, function (req, res) {
getUser(function (req.param(‘id’), data) {
var user = data;
getOrderByUser(user.id, function (order) {
res.render({
user: user,
order: order
});
});
});?
});
‘use strict’;
- 41. ? npm
? node inspector
? webkit-devtools-agent
? console.trace