Instead of using parallel threads, JavaScript relies on asynchronous I/O to handle operations with apossible long timeout: whenever a long I/O call needs to be performed, it is only triggered and butthen the code execution flow is terminated. The JavaScript engine is therefore free to handle otherpending tasks, such as UI. Whenever the pending I/O call is completed, the system invokes acallback function with the result of the I/O call to resume execution of the original execution flow.When used with plain callback functions, as pervasive in Node.js libraries, asynchronous I/O tend toproduce code with poor readability, as the execution flow is broken into many disconnected callbackfunctions. Fortunately, new methods have emerged recently to improve that situation. In particular,the use of Promise objects to abstract and work with asynchronous tasks helps a lot. Any functionthat makes a long I/O operation can return a Promise, which can be used by the caller to chainsubsequent operations in the same flow. Promises are part of EcmaScript 2015 standard.Promise objects are good, but what makes them even better is the new async / await keywords tohandle asynchronous I/O:• a function declared async will automatically encapsulate its result as a Promise• within an async function, any function call prefixed with by await will chain the Promisereturned by the function with a promise to resume execution of the caller• any exception during the execution of an async function will automatically invoke the Promisefailure continuationLong story made short, async and await make it possible to write EcmaScript code with all benefits ofasynchronous I/O, but without breaking the code flow. It is almost like multi-threaded execution,except that control switch between pending tasks only happens at places where the await keywordappears.We have therefore chosen to write our new EcmaScript library using Promises and async functions,so that you can use the friendly await syntax. To keep it easy to remember, all public methods ofthe EcmaScript library are async, i.e. return a Promise object, except:• GetTickCount(), because returning a time stamp asynchronously does not make sense...• FindModule(), FirstModule(), nextModule(), ... because device detection andenumeration always work on internal device lists handled in background, and does not requireimmediate asynchronous I/O.7.2. Using Yoctopuce library for JavaScript / EcmaScript 2017JavaScript is one of those languages which do not generally allow you to directly access thehardware layers of your computer. Therefore the library can only be used to access network-enableddevices (connected through a YoctoHub), or USB devices accessible through Yoctopuce TCP/IP toUSB gateway, named VirtualHub.Go to the Yoctopuce web site and download the following items:• The Javascript / EcmaScript 2017 programming library1• The VirtualHub software2 for Windows, Mac OS X or Linux, depending on your OSExtract the library files in a folder of your choice, you will find many of examples in it. Connect yourmodules and start the VirtualHub software. You do not need to install any driver.Using the official Yoctopuce library for node.jsStart by installing the latest Node.js version (v7.6 or later) on your system. It is very easy. You candownload it from the official web site: http://nodejs.org. Make sure to install it fully, including npm, andadd it to the system path.1 www.yoctopuce.com/EN/libraries.php2 www.yoctopuce.com/EN/virtualhub.php7. Using Yocto-GPS with JavaScript / EcmaScript38 www.yoctopuce.com