 ReadStream      = require '../lib/read-stream'
 consts          = require '../lib/consts'
 Memdown         = require 'memdown-sync'
-
+#LevelDown       = require 'leveldown-sync'
 
 FILTER_INCLUDED = consts.FILTER_INCLUDED
 FILTER_EXCLUDED = consts.FILTER_EXCLUDED
 FILTER_STOPPED  = consts.FILTER_STOPPED
 
+fillChar = (c, len=2) ->
+  result = ''
+  len++
+  while len -= 1
+    result += c
+  result
+toFixedInt = (value, digits=2)->
+  result = fillChar 0, digits
+  (result+value).slice(-digits)
+
+
 allData = {}
 for k in [0..99]
-  allData[("00"+k).slice(-2)] = Math.random().toString()
+  allData[toFixedInt(k, 2)] = Math.random().toString()
 initTestDB = ->
   db = Memdown()
+  #db = LevelDown('tempdb')
   db.open()
   for k,v of allData
     db.put(k, v)

    it "should be next/last", (done)->
      count = 0
      lastKey = null
      nextPage = (db, aLastKey, aPageSize, cb)->
        pageData = {}
        pageCount = 0
        ReadStream db,
          next: aLastKey
          limit: aPageSize

      stream.on "end", ()->
        keys = Object.keys(data)
        assert.equal keys.length, count
        assert.equal count, 11
        for k,v of data
          assert.ok k % 2 is 1, "key should be odd"
          assert.equal v, allData[k]
