maxogden/level-batcher — pull request #1 by thlorenz (2013-09-04 13:15:13+00:00)
Title: Fix to make sublevels work: stringifying key and value explicitly to determine object size

I was getting `[TypeError: Converting circular structure to JSON]` when using sublevels (due to `prefix` being a circular structure).

This fixes it, but still allows objects without `key` and `value` mainly in order to keep tests happy.
If this is for level only, we should probably only allow objects **with** key and value.

I also added a catch of any errors I can't foresee in which case the length is assumed to be the limit and the object will get flushed right away.

I added no tests for this, but think we'd need some more - wanted to discuss how to author them, i.e. just script with `asserts` or `tape/tap`.
Let me know.

However this fix is crucial, without it it does not work with sublevels.