Tutorial by Examples

Blocking Operation Example let loop = (i, max) => { while (i < max) i++ return i } // This operation will block Node.js // Because, it's CPU-bound // You should be careful about this kind of code loop(0, 1e+12) Non-Blocking IO Operation Example let i = 0 const step = max =...
Basics require('http').globalAgent.maxSockets = 25 // You can change 25 to Infinity or to a different value by experimenting Node.js by default is using maxSockets = Infinity at the same time (since v0.12.0). Until Node v0.12.0, the default was maxSockets = 5 (see v0.11.0). So, after more tha...
const http = require('http') const fs = require('fs') const zlib = require('zlib') http.createServer((request, response) => { const stream = fs.createReadStream('index.html') const acceptsEncoding = request.headers['accept-encoding'] let encoder = { hasEncoder ...

Page 1 of 1