O'Reilly logo

Node.js the Right Way by Jim R. Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Throttling Node.js

With our RDF parsing module in place and well tested, let’s turn our attention to getting all those thousands of records into the database.

But one word of caution before we proceed: the code in this section attempts to demonstrate performance-related problems and their solutions. The speed of your hardware and the settings of your operating system may make it easier or harder to see these effects.

Alright—to crawl the cache directory, we’ll use a module called file, which is available through npm.[25] Install and save it as usual, and we’ll begin:

 
$ ​npm install --save file

The file module has a convenient method called walk() that traverses a directory tree and calls a callback for each file it finds.

Naive File Parsing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required