December 2015
Intermediate to advanced
232 pages
5h 8m
English
As you know, Node.js is built around events. The whole process is a big event machine juggling different flows. Since our main process is single threaded, any function that takes a while to execute should be done in an evented manner to avoid locking up the entire application.
If you’re used to working in other programming languages, this is a tricky concept to get accustomed with. Let’s look at an example, where we implement a recursive Fibonacci calculation and a server to allow access to it:
| | 'use strict'; |
| | |
| | var express = require('express'); |
| | var app = express(); |
| | |
| | // Calculating fibonacci number recursively |
| | function fibonacci(n) { |
| | if(n < 3) { |
| | return |
Read now
Unlock full access