my8bird/node-leveldb — pull request #1 by justmoon (2011-12-10 00:12:49+00:00)
Title: Segfault fixes, LevelDB update, Node.js 0.6 compatibility

So here is my overhauled version of node-leveldb.

Lot's of segfaults fixed, with respect to using invalid iterators, using iterators after the DB has been closed, when WriteBatch is garbage collected prematurely and some incorrect handling of parameters in some of the async functions.

Added some features for binary-safe usage, such as the get() asBuffer parameter. These should be backwards compatible.

Changed the behavior for non-existent database rows to return `undefined` instead of raising a `NotFound` exception. This is a not backwards compatible, but there are very good reasons to do it:

1. Exceptions are very expensive in the context of a high performance database library as they capture the stack on instantiation.
2. Returning `undefined` is what most other database drivers for Node.js do.
3. A row not existing is a matter of the data, not a failure of the software, so an exception is the wrong metaphor. We had a database use case whose entire purpose was to check whether certain rows exist or not. It makes no sense for it to be internally raising Exceptions all the time.

A backwards compatible option/hack would have been to create a NotFoundException that does not capture a stack. But I feel like it's reasonable to bite the bullet and go with the cleaner solution.

I also updated LevelDB to the latest release. Along with that I've updated the build system.

Finally, I made the necessary compatibility changes to make the module work with Node.js 0.5 and 0.6. These are backwards compatible, I've tested the build procedure with Node.js 0.4 as well.