Skip to content

use encoding of underlying levelup - #3

Open
mvayngrib wants to merge 1 commit into
mafintosh:masterfrom
mvayngrib:proxyEncoding
Open

use encoding of underlying levelup#3
mvayngrib wants to merge 1 commit into
mafintosh:masterfrom
mvayngrib:proxyEncoding

Conversation

@mvayngrib

Copy link
Copy Markdown
Collaborator

so you can do

var db = level('blah.db', { valueEncoding: 'json' })
var feed = changes(db)
feed.append({ hey: 'ho' })
feed.createReadStream()
  .on('data', console.log) 
// { change: 1, value: { hey: 'ho' } }

this would mean for binary, you'd have to explicitly specify level('path', { valueEncoding: 'binary' })

Comment thread index.js
var feed = {}
var lock = mutexify()

var valueEncoding = db.options.valueEncoding || 'binary'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add an options argument to module.exports and do options.valueEncoding || db.options.valueEncoding || 'binary'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can valueEncoding passed in to options be different from db.options.valueEncoding? Seems like that would cause problems

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea. db.options.valueEncoding is just a default value. utf-8, json, binary, anEncoderObject is always accepted

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, so maybe db.options.valueEncoding || options.valueEncoding || 'binary' would be better

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.options.valueEncoding is always set to my knowledge (defaults to utf8) so that wouldn't work afaik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants