Socket
Socket
Sign inDemoInstall

lexicographic-integer-encoding

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lexicographic-integer-encoding

Lexicographically ordered integers for level(up)


Version published
Maintainers
1
Created
Source

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])

  • encoding (string, required): 'hex' or 'buffer'
  • options.strict (boolean): opt-in to type-checking input. If true, encode will throw:
    • A TypeError if input is not a number or if NaN
    • A RangeError if input is < 0 or > Number.MAX_SAFE_INTEGER

Returns a level-codec compliant encoding object.

see also

install

With npm do:

npm install lexicographic-integer-encoding

license

MIT © Vincent Weevers

Keywords

FAQs

Package last updated on 24 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc