(#3228) - refactor idb

I would like to start refactoring the adapters for a couple reasons:

1. The code is pretty gnarly when it's just a single file (1641 lines)
2. Supposedly performance is better when you don't have functions-within-functions and you use prototypes instead. I will try to find a source and some proof.

Perf difference (I'll try IE as well):

Firefox before

```
Starting test: basic-inserts with 1 assertions and 10000 iterations... done in 86099ms
Starting test: bulk-inserts with 1 assertions and 1000 iterations... done in 191617ms
```

Firefox after


```
Starting test: basic-inserts with 1 assertions and 10000 iterations... done in 78036ms
Starting test: bulk-inserts with 1 assertions and 1000 iterations... done in 128859ms
```

Chrome before

```
Starting test: basic-inserts with 1 assertions and 10000 iterations... done in 29065ms
Starting test: bulk-inserts with 1 assertions and 1000 iterations... done in 50866ms
```

Chrome after

```
Starting test: basic-inserts with 1 assertions and 10000 iterations... done in 28982ms
Starting test: bulk-inserts with 1 assertions and 1000 iterations... done in 48268ms
```