DailyJS

Node Roundup: 0.8.12, Node CSV, Memoize

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

functional node modules csv

Node Roundup: 0.8.12, Node CSV, Memoize

Posted by Alex R. Young on .
Featured

functional node modules csv

Node Roundup: 0.8.12, Node CSV, Memoize

Posted by Alex R. Young on .
You can send in your Node projects for review through our contact form or @dailyjs.

Node 0.8.12

Node 0.8.12 is out, which has some fixes for Windows, the Buffer and HTTP modules, and the REPL. I upgraded as soon as this release came out, and it's running all of my stuff fine as far as I can tell.

Node CSV

Node CSV (GitHub: wdavidw / node-csv-parser, License: New BSD, npm: csv) by David Worms is a streaming CSV parser. By implementing stream readers and writers, this module can parse CSV with less memory overheads when compared to reading the entire file into memory.

It can be used with fs.createReadStream like this:

fs.createReadStream('./in')  
  .pipe(csv())
  .pipe(fs.createWriteStream('./out'));

Alternatively, David has added a more convenient property-based API:

csv()  
  .from.path('./in')
  .to.string(function(data) { console.log(data); });

To set options, from.options({ option: 'value' }) can be used. This supports the usual CSV parser settings, like field delimiters and quoting. The project has Mocha tests, and there's a growing list of contributors.

Memoize

Memoize (License: MIT, npm: memoize) by Mariusz Nowak is a memoize module that implements pretty much everything related to memoization that I can think of. It works in both Node and browsers, works with function arguments without serialising arguments, supports asynchronous functions, and has cache management features.

The "primitive mode" is interesting because it's optimised for large amounts of data. In fact, it made me think back to Map and WeakMap from Monday's article on ES6 for Node. It seems like caching would get a boost from these ES6 features.