SlideShare a Scribd company logo
1 of 13
Download to read offline
PRESENTING:
SEQ
ABOUT ME
Who I am: Douglas Muth
How to contact me: dmuth@dmuth.org / @dmuth
What I do: Software Engineer ...mostly.
THE PROBLEM
Flow control in node.js.
Node.js is a callback-heavy language.
Often, it looks like this:
d.ur(SLC ..,fnto(ro,rsls {
bqey"EET ." ucinerr eut)
i (err {
f !ro)
d.ur(UDT ..,fnto(ro,rsls {
bqey"PAE ." ucinerr eut)
i (err {
f !ro)
d.ur(ISR ..,fnto(ro,rsls {
bqey"NET ." ucinerr eut)
/ O Gd wy
/ h o, h?
}
}
};
)
}
};
)

Also known as "boomerang code"!
SEQ 101
INSTALLATION
$nmisalsq
p ntl e

That was easy!
SEQ 101
USAGE
vrsq=rqie"e";
a e
eur(sq)
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
d.ur(UDT ..,ti)
bqey"PAE ." hs;
}.e(ucinrsls {
)sqfnto(eut)
d.ur(ISR ..,ti) / Pet set
bqey"NET ." hs; / rty we!
};
)

"this()" is the callback which goes to the next block of code
SEQ 101
WHEN THINGS GO WRONG
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
ti(e Err"hk tig u altl")
hsnw ro(Sae hns p
ite);
}.e(ucinrsls {
)sqfnto(eut)
/ Ti wl nvrrn
/ hs il ee u
d.ur(ISR ..,ti)
bqey"NET ." hs;
}.ac(ucinerr {
)cthfnto(ro)
/ Igtti!
/
o hs
};
)
HOW TO SEQ
IT'S A TRAP!
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
sq)sqfnto( {
e(.e(ucin)
/ D smtig
/ o oehn
}.e(ucin){
)sqfnto(
/ D smtiges
/ o oehn le
/ Ti wntg t teotrSq
/ hs o' o o h ue e
ti(;
hs)
}.e(ucin){
)sqfnto(
/ Ti gt cle b acdn
/ hs es ald y ciet
};
)
}.e(ucinrsls {
)sqfnto(eut)
/ Ti wl nvrrn
/ hs il ee u
d.ur(ISR ..,ti)
bqey"NET ." hs;
};
)
SEQ 101
SAFE NESTING OF SEQ
sq)sqfnto( {
e(.e(ucin)
d.ur(SLC ..,ti)
bqey"EET ." hs;
}.e(ucinrsls {
)sqfnto(eut)
vrc =ti;/ ti( b ayohrnm.
a b
hs / hs) y n te ae.
sq)sqfnto( {
e(.e(ucin)
/ D smtig
/ o oehn
}.e(ucin){
)sqfnto(
/ D smtiges
/ o oehn le
/ Ti wntg t teotrSq
/ hs o' o o h ue e
c(;
b)
}.e(ucin){
)sqfnto(
/ Ti nvrgt cle
/ hs ee es ald
};
)
}.e(ucinrsls {
)sqfnto(eut)
/ Ti gt cle
/ hs es ald
d.ur(ISR ..,ti)
bqey"NET ." hs;
};
)
ADVANCED SEQ
vrf =rqie's)
a s
eur(f';
vree =rqie'hl_rcs'.xc
a xc
eur(cidpoes)ee;
vrSq=rqie'e';
a e
eur(sq)
Sq)
e(
.e(ucinse1){
sqfnto tp(
ee(wom' ti)
xc'hai, hs
}
)
.a(ucinse2wo {
prfnto tp(h)
ee(gop '+wo ti)
xc'rus
h, hs;
}
)
.a(ucinse3wo {
prfnto tp(h)
f.edie_flnm,'si' ti)
sraFl(_ieae aci, hs;
}
)
.e(ucinse4gop,sc {
sqfnto tp(rus r)
cnoelg'rus '+gop.rm);
osl.o(Gop:
rusti()
cnoelg'hsfl hs'+sclnt +'bts)
osl.o(Ti ie a
r.egh
ye';
}
)
;

Order of execution is as follows:

step1()
step2() and step3() are executed in parallel
step4() ONLY when step2() and step3() complete
EVEN MORE SEQ
Process an array of elements:
forEach()
seqEach()
parEach()
Play around with "this":
this.stack
this.vars
this.into(key)
this.args
Not for the faint of heart, and WAY beyond the scope of this
presentation.
FURTHER READING
The Seq repo:
https://github.com/substack/node-seq/
ON THE WEB
https://github.com/dmuth/nodejs-presentations
Feel free to clone and add your own presentations based off of
template.html!
QUESTIONS?

More Related Content

What's hot

Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
Emmanuel Garcia
 
Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60
Felipe Ronchi Brigido
 

What's hot (19)

Clojure入門
Clojure入門Clojure入門
Clojure入門
 
File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?File-I/O -- ist doch ganz einfach, oder?
File-I/O -- ist doch ganz einfach, oder?
 
Yg byev2e
Yg byev2eYg byev2e
Yg byev2e
 
gemdiff
gemdiffgemdiff
gemdiff
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
New
NewNew
New
 
System adm
System admSystem adm
System adm
 
Dicas de SSH
Dicas de SSHDicas de SSH
Dicas de SSH
 
Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60Comunicação Bluetooth Entre Python e PyS60
Comunicação Bluetooth Entre Python e PyS60
 
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86)
 
it's only abuse if it crashes
it's only abuse if it crashesit's only abuse if it crashes
it's only abuse if it crashes
 
CentOS_slide_ver1.0
CentOS_slide_ver1.0CentOS_slide_ver1.0
CentOS_slide_ver1.0
 
3-in-1 YSlow
3-in-1 YSlow3-in-1 YSlow
3-in-1 YSlow
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
   מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה    מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
מודלים חישוביים - תרגול מס 2 - אוניברסיטת חיפה
 
strace for Perl Mongers
strace for Perl Mongersstrace for Perl Mongers
strace for Perl Mongers
 
Basics
BasicsBasics
Basics
 

Similar to Presenting Seq for Node.js

Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
Tony Fabeen
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
Tony Fabeen
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
Eugene Zharkov
 

Similar to Presenting Seq for Node.js (20)

2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java script
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
SecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play FrameworkSecureSocial - Authentication for Play Framework
SecureSocial - Authentication for Play Framework
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)
 
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
How to create a 3.2 billion dollar business in 20 minutes: combining AngularJ...
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
 
Hazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGridHazelcast - In-Memory DataGrid
Hazelcast - In-Memory DataGrid
 
JavaScript pitfalls
JavaScript pitfallsJavaScript pitfalls
JavaScript pitfalls
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
nescala 2013
nescala 2013nescala 2013
nescala 2013
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend Testing
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1
 
Ff to-fp
Ff to-fpFf to-fp
Ff to-fp
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Presenting Seq for Node.js

  • 2. ABOUT ME Who I am: Douglas Muth How to contact me: dmuth@dmuth.org / @dmuth What I do: Software Engineer ...mostly.
  • 3. THE PROBLEM Flow control in node.js. Node.js is a callback-heavy language. Often, it looks like this: d.ur(SLC ..,fnto(ro,rsls { bqey"EET ." ucinerr eut) i (err { f !ro) d.ur(UDT ..,fnto(ro,rsls { bqey"PAE ." ucinerr eut) i (err { f !ro) d.ur(ISR ..,fnto(ro,rsls { bqey"NET ." ucinerr eut) / O Gd wy / h o, h? } } }; ) } }; ) Also known as "boomerang code"!
  • 5. SEQ 101 USAGE vrsq=rqie"e"; a e eur(sq) sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) d.ur(UDT ..,ti) bqey"PAE ." hs; }.e(ucinrsls { )sqfnto(eut) d.ur(ISR ..,ti) / Pet set bqey"NET ." hs; / rty we! }; ) "this()" is the callback which goes to the next block of code
  • 6. SEQ 101 WHEN THINGS GO WRONG sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) ti(e Err"hk tig u altl") hsnw ro(Sae hns p ite); }.e(ucinrsls { )sqfnto(eut) / Ti wl nvrrn / hs il ee u d.ur(ISR ..,ti) bqey"NET ." hs; }.ac(ucinerr { )cthfnto(ro) / Igtti! / o hs }; )
  • 7. HOW TO SEQ IT'S A TRAP! sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) sq)sqfnto( { e(.e(ucin) / D smtig / o oehn }.e(ucin){ )sqfnto( / D smtiges / o oehn le / Ti wntg t teotrSq / hs o' o o h ue e ti(; hs) }.e(ucin){ )sqfnto( / Ti gt cle b acdn / hs es ald y ciet }; ) }.e(ucinrsls { )sqfnto(eut) / Ti wl nvrrn / hs il ee u d.ur(ISR ..,ti) bqey"NET ." hs; }; )
  • 8. SEQ 101 SAFE NESTING OF SEQ sq)sqfnto( { e(.e(ucin) d.ur(SLC ..,ti) bqey"EET ." hs; }.e(ucinrsls { )sqfnto(eut) vrc =ti;/ ti( b ayohrnm. a b hs / hs) y n te ae. sq)sqfnto( { e(.e(ucin) / D smtig / o oehn }.e(ucin){ )sqfnto( / D smtiges / o oehn le / Ti wntg t teotrSq / hs o' o o h ue e c(; b) }.e(ucin){ )sqfnto( / Ti nvrgt cle / hs ee es ald }; ) }.e(ucinrsls { )sqfnto(eut) / Ti gt cle / hs es ald d.ur(ISR ..,ti) bqey"NET ." hs; }; )
  • 9. ADVANCED SEQ vrf =rqie's) a s eur(f'; vree =rqie'hl_rcs'.xc a xc eur(cidpoes)ee; vrSq=rqie'e'; a e eur(sq) Sq) e( .e(ucinse1){ sqfnto tp( ee(wom' ti) xc'hai, hs } ) .a(ucinse2wo { prfnto tp(h) ee(gop '+wo ti) xc'rus h, hs; } ) .a(ucinse3wo { prfnto tp(h) f.edie_flnm,'si' ti) sraFl(_ieae aci, hs; } ) .e(ucinse4gop,sc { sqfnto tp(rus r) cnoelg'rus '+gop.rm); osl.o(Gop: rusti() cnoelg'hsfl hs'+sclnt +'bts) osl.o(Ti ie a r.egh ye'; } ) ; Order of execution is as follows: step1() step2() and step3() are executed in parallel step4() ONLY when step2() and step3() complete
  • 10. EVEN MORE SEQ Process an array of elements: forEach() seqEach() parEach() Play around with "this": this.stack this.vars this.into(key) this.args Not for the faint of heart, and WAY beyond the scope of this presentation.
  • 11. FURTHER READING The Seq repo: https://github.com/substack/node-seq/
  • 12. ON THE WEB https://github.com/dmuth/nodejs-presentations Feel free to clone and add your own presentations based off of template.html!