Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

The style of the Node.js core API

Earlier in this chapter, we learned how the reactor pattern and the non-blocking I/O model are two of the most fundamental characteristics of Node.js. This should help us to understand why callbacks are used so extensively in the entire Node.js core API. As we can imagine, the core API has a direct impact on all the other modules. As a result, the entire Node.js ecosystem uses callbacks extensively.

Node.js not only uses callbacks extensively, but it also uses them in a very consistent way:

  • Callbacks in Node.js are always the last argument of a function
  • Callbacks in Node.js always take an error as the first argument

The following code snippet uses the filesystem API to read a text file. The readFile function ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content