SlideShare a Scribd company logo
Introduction to 
{ node.js } 
Ran Mizrahi (@ranm8) 
Founder and CEO, CoCycles
About { Me } 
• Founder and CEO of CoCycles. 
• Former Open Source Dpt. Leader of CodeOasis. 
• Architected and lead the development of the Wix App Market. 
• Full-stack and hands-on software engineer.
What is { node.js } 
• Server-side JavaScript development platform. 
! 
• Built on top of Chrome’s JavaScript runtime engine V8. 
! 
• Aims for easy development of scalable, non-blocking I/O, real 
time and network applications. 
! 
• Written in C/C++ and JavaScript. 
! 
• CommonJS module system. 
! 
• node.js is single-threaded and uses event-loop. 
! 
!
What is { V8 } 
• V8 is Google Chrome's JavaScript runtime engine. 
! 
• Implements ECMAScript specification (5th edition). 
! 
• Standalone and can be embedded to any C++ application. 
! 
• Compiles JavaScript to native machine code before executing it 
instead of interpreting. 
! 
• Open sourced under the new BSD license. 
! 
!
We All Love { Burgers }
{ Thread per Connection } Burgers Restaurant
Something is { WRONG }, we 
must 
do it { BETTER }!!!
Event-Driven { Burgers Restaurant }
{ Apache } vs. { NGINX } vs Performance 
Requests per second:
{ Apache } vs. { NGINX } vs Performance 
Memory usage:
{ Apache } vs. { NGINX } vs Performance 
So, what is the big difference between Apache and Nginx? 
• Apache uses one thread per connection. 
• Hard to scale. 
• Resource expensive. 
! 
• NGINX is single-threaded and uses event-loop for handling 
requests. 
• Easy to scale. 
• Lower resources consumption.
{ Blocking } I/O 
What is the software doing while it queries to the DB?!? 
var response = db.query('select * form users'); 
// use the result 
In most cases, nothing (/: 
• Better software should handle I/O differently! It should 
multitask. 
! 
• Other tasks should be performed while waiting.. 
! 
! 
!
{ Non-Blocking } I/O 
Non-blocking code: 
db.query('select * form users', function(result){ 
This is how I/O should be handled in concurrency, when the 
DB will respond, the given function will be executed. 
! 
! 
// Use the result 
}); 
! 
console.log(logSomething);
So Why Everyone Aren’t Using { Non-Blocking I/O } 
This what we learn: 
puts('Enter you name:'); 
var name = gets(); 
puts('Hello ' + name); 
Considered too complicated (:/ 
puts('Enter you name here:'); 
gets(function(name) { 
puts('Hello ' + name); 
});
But Why { JavaScript } ? 
JavaScript is designed specifically to be used with an event-loop: 
! 
• Anonymous functions, closures. 
! 
• Executes one callback at a time. 
! 
• Tested over years with I/O through DOM event callbacks. 
! 
• Web developers already know JavaScript (decreases the 
learning curve dramatically).
The { node.js } Project 
• Provides purely event-driven, non-blocking infrastructure to 
write high concurrency applications. 
! 
• Uses JavaScript for easy development of asynchronies apps. 
! 
• Open source and extendable module system. 
https://github.com/popular/starred
Some { Examples }
Hello { JavaScript Israel } 
setTimeout(function() { 
console.log(‘JavaScript Israel!'); 
}, 2000); 
! 
console.log('Hello'); 
• The program outputs “Hello”, then waits two seconds and 
outputs “JavaScript Israel!”. 
! 
• While waiting for the timeout to complete, node.js will keep 
performing other tasks. 
• Node exits automatically when nothing is left to do.
Streaming { HTTP Server } 
var http = require('http'); 
! 
var server = http.createServer(function(request, response) { 
response.writeHead(200, { 'Content-Type': 'text/plain' }); 
! 
setTimeout(function() { 
response.end(‘JavaScript Israel!n'); 
}, 2000); 
! 
response.write('Hellon'); 
}); 
! 
server.listen(8000); 
Let’s benchmark that... and see the results.. 
20 secs, with single thread is the result of non-blocking structure.
DNS { Resolver } 
var dns = require('dns'); 
! 
console.log('resolving google.com...'); 
! 
dns.resolve('google.com', function(error, addresses) { 
if (error) throw error; 
console.log('found: ' + addresses.join(', ')); 
}); 
Resolves “google.com” and outputs the result.
Common { Frameworks and 
Tools }
NPM { Node Package Manager } 
npm usage: 
Installs package in the current local directory: 
$ npm install express 
Installs package globally 
$ npm install express -g
{ Express } 
Express is a minimal and flexible node.js web framework, 
providing robust set of features for building web applications. 
Taken from http://expressjs.com 
Some of express features: 
• Robust routing. 
! 
• HTTP helpers (caching, redirection, etc.) 
! 
• Focuses on high performance. 
! 
• Simplified API for working in request/response environment. 
• Large community support. 
! 
! 
!
{ Express } 
Web Server example: 
var express = require(‘express’), 
app = express(); 
! 
app.get(‘/api/me', function(request, response) { 
// Return JSON encoded response 
response.json(200,{ 
code: 200, 
message: 'OK', 
payload: null 
}); 
}); 
• Creates new express HTTP server with route for path GET 
“/api/me”. 
! 
• Returns JSON formatted response.
{ Socket.IO (1.0) } By Automattic 
Socket.IO aims to make real-time apps possible in every browser 
and mobile device, blurring the differences between transport 
mechanisms. 
Taken from http://socket.io 
Some of socket.io main features: 
• Runs on top of Engine.IO as cross-browser/device bi-directional 
communication layer (XHR-polling, long-polling, 
WebSockets, Flash, etc.). 
! 
• Binary Support. 
! 
• Disconnections detection through heartbeats. 
! 
• Reconnection support with buffering. 
! 
!
{ Socket.IO } Notifications Example 
Server: 
var io = require('socket.io')(server); 
! 
io.on('connection', function(socket) { 
var notification = { body: 'Hello Exelate!' }; 
socket.emit('notification', notification, function(response) { 
console.log(response); 
}); 
}); 
Client: 
var socket = io('http://localhost'); 
socket.on('notification', function(data, callback) { 
console.log(data.body); 
callback('Hello to you too!'); 
});
{ Mongoose } 
Mongoose aims to provide elegant MongoDB object modeling 
(ODM) for node.js. 
Some of mongoose main features: 
• Allows creating DB schemas. 
! 
• Virtuals, Getters and Setters. 
! 
• Easy validation of DB objects. 
! 
• Extend easily! 
! 
! 
!
{ Mongoose } 
Mongoose cat document example: 
var mongoose = require('mongoose'); 
mongoose.connect('localhost', ‘my-db'); 
! 
var CatSchema = mongoose.Schema({ 
name: { 
type: String, 
required: true, 
default: 'My cat' 
} 
}); 
! 
var Cat = mongoose.model('Cat', CatSchema); 
! 
var kitty = new Cat({ name: 'Kati' }); 
kitty.save(function(err) { 
if (err) throw err; 
console.log('Saved!') 
});
{ TDD/BDD } using Mocha and Expect.js 
Mocha 
Mocha is a feature-rich JavaScript test frameworks running on 
node and the browser, making asynchronies tests easy. 
Main features: 
• Supports both TDD and BDD styles. 
! 
• Both browser and node support. 
! 
• Proper exit status for CI support. 
! 
• Really easy async tests. 
! 
• node.js debugger support. 
! 
• Highly flexible, choose and join the pieces yourself (spy library, 
assertion library, etc.).
{ TDD/BDD } using Mocha and Chai 
Chai 
Chai is a BDD/TDD assertion library for node and the browser 
that can be easily paired with any JavaScript testing framework. 
Main features: 
• BDD style. 
! 
• Compatible with all test frameworks. 
! 
• Both node.js and browser compatible. 
! 
• Standalone assertion library. 
• Extend easily!
{ TDD/BDD } using Mocha and Chai 
“Normal” test: 
var expect = require(‘chai').expect; 
! 
describe('Array', function() { 
describe('#indexOf()', function() { 
it('Expect -1 when the value is not present', function() { 
var array = [1, 2, 3]; 
expect(array.indexOf(4)).to.be(-1); 
}); 
}); 
}); 
Run it.. 
$ mocha --reporter spec 
Array 
#indexOf() 
✓ Expect -1 when the value is not present 
! 
! 
1 test complete (5 ms)
{ TDD/BDD } using Mocha and Expect.js 
“Async” test: 
var expect = require(‘chai').expect; 
! 
function asyncCall(val ,callback) { 
var prefix = ' - '; 
! 
setTimeout(function() { 
var newString = val + prefix + 'OK'; 
! 
callback(newString); 
}, 500); 
} 
! 
describe('asyncCall', function() { 
it('Add suffix that prefixed with - to the given string', function(done) { 
var testVal = 'Foo'; 
! 
asyncCall(testVal, function(response) { 
expect(response).to.contain(testVal + ' - OK'); 
done(); 
}); 
}); 
}); 
Let’s run it...
{ Use Cases } 
FXP.co.il 
• Real-time notifications, forum threads and posts. 
! 
• 30,000 concurrency connections! 
! 
• We started with version 0.4 )-:.. 
! 
• Today, runs on one web server for serving all those concurrent 
connections.. 
! 
My Contributions… 
! 
• Requestify - Simplified HTTP 
• winston-newrelic - Winston transporter for New Relic 
! 
!
Thank you! 
Questions?

More Related Content

PDF
How AngularJS Embraced Traditional Design Patterns
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
PDF
Intro to JavaScript Testing
PDF
Introduction to node.js by Ran Mizrahi @ Reversim Summit
PDF
Dependency Injection @ AngularJS
PDF
JavaScript 101
PDF
JavaScript Library Overview
PDF
Intro to JavaScript
How AngularJS Embraced Traditional Design Patterns
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro to JavaScript Testing
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Dependency Injection @ AngularJS
JavaScript 101
JavaScript Library Overview
Intro to JavaScript

What's hot (20)

PDF
Javascript Best Practices
PDF
JavaScript - Chapter 7 - Advanced Functions
PDF
Survive JavaScript - Strategies and Tricks
PPTX
JS Event Loop
PPTX
Lecture 5 javascript
PDF
React Development with the MERN Stack
PDF
Workshop 12: AngularJS Parte I
PDF
Dart for Java Developers
PDF
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
PPTX
Node.js Patterns for Discerning Developers
PPTX
Testing Ext JS and Sencha Touch
PDF
Workshop 16: EmberJS Parte I
PDF
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
KEY
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
KEY
Agile JavaScript Testing
PDF
JavaScript Good Practices
PPT
JavaScript Misunderstood
PDF
Ember.js - A JavaScript framework for creating ambitious web applications
PPTX
Workshop Intro: FrontEnd General Overview
Javascript Best Practices
JavaScript - Chapter 7 - Advanced Functions
Survive JavaScript - Strategies and Tricks
JS Event Loop
Lecture 5 javascript
React Development with the MERN Stack
Workshop 12: AngularJS Parte I
Dart for Java Developers
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
Node.js Patterns for Discerning Developers
Testing Ext JS and Sencha Touch
Workshop 16: EmberJS Parte I
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Agile JavaScript Testing
JavaScript Good Practices
JavaScript Misunderstood
Ember.js - A JavaScript framework for creating ambitious web applications
Workshop Intro: FrontEnd General Overview
Ad

Viewers also liked (20)

PPT
PDF
Diadrastikoi a theoritiko plaisio
PPT
Mappeoppgave 2 2003
PPT
Project54 Research Areas
PPT
P2 Tour
PPT
PPT
ChiefStrategyOfficer_preso_rev0
PPT
PPT
Umk Eng 2 4 Nov.Ppt8
PPT
PPT
FM update by Mundie Salm
PPTX
Studying at UNH: Education and Research Opportunities
PPTX
Budapest exchange program for UNH ECE students
PPT
Merkatu ikerketa-Irutxuloko Hitza
PPT
PPT
PPT
My e-Portfolio
PPT
What You Didnt Know You Dont Know About Compliance Mar 29 07a
PPTX
Om at være MOOC'er -at finde og skabe sine egne læringsstier
PPT
Diadrastikoi a theoritiko plaisio
Mappeoppgave 2 2003
Project54 Research Areas
P2 Tour
ChiefStrategyOfficer_preso_rev0
Umk Eng 2 4 Nov.Ppt8
FM update by Mundie Salm
Studying at UNH: Education and Research Opportunities
Budapest exchange program for UNH ECE students
Merkatu ikerketa-Irutxuloko Hitza
My e-Portfolio
What You Didnt Know You Dont Know About Compliance Mar 29 07a
Om at være MOOC'er -at finde og skabe sine egne læringsstier
Ad

Similar to Intro to node.js - Ran Mizrahi (28/8/14) (20)

PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
PPTX
Introduction to Node.js
KEY
Playing With Fire - An Introduction to Node.js
PDF
Introduction to Node.js: What, why and how?
PDF
Nodejs - A quick tour (v5)
ODP
Introduce about Nodejs - duyetdev.com
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PPTX
Building and Scaling Node.js Applications
PDF
Introduction to Node.js
PDF
Nodejs - A quick tour (v6)
PDF
Nodejs - A quick tour (v4)
PPTX
introduction to node.js
PDF
Nodejs - A-quick-tour-v3
PPTX
PDF
Introduction to Node.js
PDF
Hello world - intro to node js
PPTX
KEY
Node.js - A practical introduction (v2)
PDF
Node.js
PDF
Developing realtime apps with Drupal and NodeJS
GeekCampSG - Nodejs , Websockets and Realtime Web
Introduction to Node.js
Playing With Fire - An Introduction to Node.js
Introduction to Node.js: What, why and how?
Nodejs - A quick tour (v5)
Introduce about Nodejs - duyetdev.com
Workshop 4: NodeJS. Express Framework & MongoDB.
Building and Scaling Node.js Applications
Introduction to Node.js
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v4)
introduction to node.js
Nodejs - A-quick-tour-v3
Introduction to Node.js
Hello world - intro to node js
Node.js - A practical introduction (v2)
Node.js
Developing realtime apps with Drupal and NodeJS

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
Teaching material agriculture food technology
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Empathic Computing: Creating Shared Understanding
PDF
Modernizing your data center with Dell and AMD
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Teaching material agriculture food technology
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Empathic Computing: Creating Shared Understanding
Modernizing your data center with Dell and AMD
Dropbox Q2 2025 Financial Results & Investor Presentation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Machine learning based COVID-19 study performance prediction

Intro to node.js - Ran Mizrahi (28/8/14)

  • 1. Introduction to { node.js } Ran Mizrahi (@ranm8) Founder and CEO, CoCycles
  • 2. About { Me } • Founder and CEO of CoCycles. • Former Open Source Dpt. Leader of CodeOasis. • Architected and lead the development of the Wix App Market. • Full-stack and hands-on software engineer.
  • 3. What is { node.js } • Server-side JavaScript development platform. ! • Built on top of Chrome’s JavaScript runtime engine V8. ! • Aims for easy development of scalable, non-blocking I/O, real time and network applications. ! • Written in C/C++ and JavaScript. ! • CommonJS module system. ! • node.js is single-threaded and uses event-loop. ! !
  • 4. What is { V8 } • V8 is Google Chrome's JavaScript runtime engine. ! • Implements ECMAScript specification (5th edition). ! • Standalone and can be embedded to any C++ application. ! • Compiles JavaScript to native machine code before executing it instead of interpreting. ! • Open sourced under the new BSD license. ! !
  • 5. We All Love { Burgers }
  • 6. { Thread per Connection } Burgers Restaurant
  • 7. Something is { WRONG }, we must do it { BETTER }!!!
  • 8. Event-Driven { Burgers Restaurant }
  • 9. { Apache } vs. { NGINX } vs Performance Requests per second:
  • 10. { Apache } vs. { NGINX } vs Performance Memory usage:
  • 11. { Apache } vs. { NGINX } vs Performance So, what is the big difference between Apache and Nginx? • Apache uses one thread per connection. • Hard to scale. • Resource expensive. ! • NGINX is single-threaded and uses event-loop for handling requests. • Easy to scale. • Lower resources consumption.
  • 12. { Blocking } I/O What is the software doing while it queries to the DB?!? var response = db.query('select * form users'); // use the result In most cases, nothing (/: • Better software should handle I/O differently! It should multitask. ! • Other tasks should be performed while waiting.. ! ! !
  • 13. { Non-Blocking } I/O Non-blocking code: db.query('select * form users', function(result){ This is how I/O should be handled in concurrency, when the DB will respond, the given function will be executed. ! ! // Use the result }); ! console.log(logSomething);
  • 14. So Why Everyone Aren’t Using { Non-Blocking I/O } This what we learn: puts('Enter you name:'); var name = gets(); puts('Hello ' + name); Considered too complicated (:/ puts('Enter you name here:'); gets(function(name) { puts('Hello ' + name); });
  • 15. But Why { JavaScript } ? JavaScript is designed specifically to be used with an event-loop: ! • Anonymous functions, closures. ! • Executes one callback at a time. ! • Tested over years with I/O through DOM event callbacks. ! • Web developers already know JavaScript (decreases the learning curve dramatically).
  • 16. The { node.js } Project • Provides purely event-driven, non-blocking infrastructure to write high concurrency applications. ! • Uses JavaScript for easy development of asynchronies apps. ! • Open source and extendable module system. https://github.com/popular/starred
  • 18. Hello { JavaScript Israel } setTimeout(function() { console.log(‘JavaScript Israel!'); }, 2000); ! console.log('Hello'); • The program outputs “Hello”, then waits two seconds and outputs “JavaScript Israel!”. ! • While waiting for the timeout to complete, node.js will keep performing other tasks. • Node exits automatically when nothing is left to do.
  • 19. Streaming { HTTP Server } var http = require('http'); ! var server = http.createServer(function(request, response) { response.writeHead(200, { 'Content-Type': 'text/plain' }); ! setTimeout(function() { response.end(‘JavaScript Israel!n'); }, 2000); ! response.write('Hellon'); }); ! server.listen(8000); Let’s benchmark that... and see the results.. 20 secs, with single thread is the result of non-blocking structure.
  • 20. DNS { Resolver } var dns = require('dns'); ! console.log('resolving google.com...'); ! dns.resolve('google.com', function(error, addresses) { if (error) throw error; console.log('found: ' + addresses.join(', ')); }); Resolves “google.com” and outputs the result.
  • 21. Common { Frameworks and Tools }
  • 22. NPM { Node Package Manager } npm usage: Installs package in the current local directory: $ npm install express Installs package globally $ npm install express -g
  • 23. { Express } Express is a minimal and flexible node.js web framework, providing robust set of features for building web applications. Taken from http://expressjs.com Some of express features: • Robust routing. ! • HTTP helpers (caching, redirection, etc.) ! • Focuses on high performance. ! • Simplified API for working in request/response environment. • Large community support. ! ! !
  • 24. { Express } Web Server example: var express = require(‘express’), app = express(); ! app.get(‘/api/me', function(request, response) { // Return JSON encoded response response.json(200,{ code: 200, message: 'OK', payload: null }); }); • Creates new express HTTP server with route for path GET “/api/me”. ! • Returns JSON formatted response.
  • 25. { Socket.IO (1.0) } By Automattic Socket.IO aims to make real-time apps possible in every browser and mobile device, blurring the differences between transport mechanisms. Taken from http://socket.io Some of socket.io main features: • Runs on top of Engine.IO as cross-browser/device bi-directional communication layer (XHR-polling, long-polling, WebSockets, Flash, etc.). ! • Binary Support. ! • Disconnections detection through heartbeats. ! • Reconnection support with buffering. ! !
  • 26. { Socket.IO } Notifications Example Server: var io = require('socket.io')(server); ! io.on('connection', function(socket) { var notification = { body: 'Hello Exelate!' }; socket.emit('notification', notification, function(response) { console.log(response); }); }); Client: var socket = io('http://localhost'); socket.on('notification', function(data, callback) { console.log(data.body); callback('Hello to you too!'); });
  • 27. { Mongoose } Mongoose aims to provide elegant MongoDB object modeling (ODM) for node.js. Some of mongoose main features: • Allows creating DB schemas. ! • Virtuals, Getters and Setters. ! • Easy validation of DB objects. ! • Extend easily! ! ! !
  • 28. { Mongoose } Mongoose cat document example: var mongoose = require('mongoose'); mongoose.connect('localhost', ‘my-db'); ! var CatSchema = mongoose.Schema({ name: { type: String, required: true, default: 'My cat' } }); ! var Cat = mongoose.model('Cat', CatSchema); ! var kitty = new Cat({ name: 'Kati' }); kitty.save(function(err) { if (err) throw err; console.log('Saved!') });
  • 29. { TDD/BDD } using Mocha and Expect.js Mocha Mocha is a feature-rich JavaScript test frameworks running on node and the browser, making asynchronies tests easy. Main features: • Supports both TDD and BDD styles. ! • Both browser and node support. ! • Proper exit status for CI support. ! • Really easy async tests. ! • node.js debugger support. ! • Highly flexible, choose and join the pieces yourself (spy library, assertion library, etc.).
  • 30. { TDD/BDD } using Mocha and Chai Chai Chai is a BDD/TDD assertion library for node and the browser that can be easily paired with any JavaScript testing framework. Main features: • BDD style. ! • Compatible with all test frameworks. ! • Both node.js and browser compatible. ! • Standalone assertion library. • Extend easily!
  • 31. { TDD/BDD } using Mocha and Chai “Normal” test: var expect = require(‘chai').expect; ! describe('Array', function() { describe('#indexOf()', function() { it('Expect -1 when the value is not present', function() { var array = [1, 2, 3]; expect(array.indexOf(4)).to.be(-1); }); }); }); Run it.. $ mocha --reporter spec Array #indexOf() ✓ Expect -1 when the value is not present ! ! 1 test complete (5 ms)
  • 32. { TDD/BDD } using Mocha and Expect.js “Async” test: var expect = require(‘chai').expect; ! function asyncCall(val ,callback) { var prefix = ' - '; ! setTimeout(function() { var newString = val + prefix + 'OK'; ! callback(newString); }, 500); } ! describe('asyncCall', function() { it('Add suffix that prefixed with - to the given string', function(done) { var testVal = 'Foo'; ! asyncCall(testVal, function(response) { expect(response).to.contain(testVal + ' - OK'); done(); }); }); }); Let’s run it...
  • 33. { Use Cases } FXP.co.il • Real-time notifications, forum threads and posts. ! • 30,000 concurrency connections! ! • We started with version 0.4 )-:.. ! • Today, runs on one web server for serving all those concurrent connections.. ! My Contributions… ! • Requestify - Simplified HTTP • winston-newrelic - Winston transporter for New Relic ! !