Home

Awesome

lexicographic-integer-encoding

Lexicographically ordered integers for level(up). Wraps lexicographic-integer.

npm status node Travis build status AppVeyor build status JavaScript Style Guide Dependency status

usage with level

const level = require('level')
const lexint = require('lexicographic-integer-encoding')('hex')

const db = level('./db', { keyEncoding: lexint })

db.put(2, 'example', (err) => {
  db.put(10, 'example', (err) => {
    // Without our encoding, the keys would sort as 10, 2.
    db.createKeyStream().on('data', console.log) // 2, 10
  })
})

usage with levelup

const levelup = require('levelup')
const encode = require('encoding-down')
const leveldown = require('leveldown')
const lexint = require('lexicographic-integer-encoding')('hex')

const db = levelup(encode(leveldown('./db'), { keyEncoding: lexint }))

api

lexint = require('lexicographic-integer-encoding')(encoding, [options])

Returns a level-codec compliant encoding object.

see also

install

With npm do:

npm install lexicographic-integer-encoding

license

MIT © Vincent Weevers