Oracle Magazine, July/August 2017

Database Developer OPEN SOURCE module Node js has asynchronous APIs for many different types of operations including timers disk and network I O and CPU intensive tasks such as encryption and compression These operations should all be done asynchronously Heres an example of asynchronous code that uses a simple timer ORACLE MAGAZINE JULY AUGUST 2017 54 setTimeout function console log hello 3000 console log world Save the script to a file named async js and run it with Node js as you ran the sync js script before You should see world appear immediately and hello appear three seconds later node async js world hello Surprising no The setTimeout function is an asynchronous API that takes two parameters a callback function and the number of milliseconds to wait before running the function setTimeout was implemented as an asynchronous API because pausing on the main thread would prevent all JavaScript code from running for the specified length of time When setTimeout has finished doing its work just waiting in this case it places the callback function in a queue to be executed ASAP

View the Covers and the Table of Contents pages from every issue of this publication, all gathered together for easy browsing. Just flip pages and zoom as you normally do to see each issue's Cover and Table of Contents, then follow links directly to interesting content.