juliangruber / level-list

Map lists of data stored in a LevelDB to DOM elements.
7 stars 1 forks source link

Sometimes List only adds a single element #4

Open morganrallen opened 10 years ago

morganrallen commented 10 years ago

Working on a reduced test case.

morganrallen commented 10 years ago

The problem appears to be handling of binary keys. When stream-serializer decodes the in coming rows when it encounters the base64 encoded key it is decoded to Uint8Array. Back in level-list when tracking the rows the id always ends up as "[object Uint8Array]"

juliangruber commented 10 years ago

we can't use typed arrays as array keys, just casting to strings should help

morganrallen commented 10 years ago

I'm trying a couple of things. First I was thinking maybe using bytewise to encode the key or just change 26 to

var id = Array.prototype.join.call(change.key, "");

Quick look it handles binary and non-binary with no problems.

juliangruber commented 10 years ago

i prefer latter, bytewise shouldn't be a dependency of level-list

morganrallen commented 10 years ago

So there is still a problem here. Numbers join to "". In better news, I'm writing unit tests for you. Ok with that? Going with tape/testling. I'll make a more robust id check and submit it shortly.

juliangruber commented 10 years ago

ah yeah, I never had that problem as I always use string encoding for keys. That's awesome!