New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

levelup

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

levelup - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

0.11.0 @ Jul 17 2013
====================
* Remove all Function#bind calls for better browser compatibility (@juliangruber)
* Switch from direct Buffer access to bops for better browser compatibility (@juliangruber)
* WriteStream#end accepts `data` argument (@pgte)
* Added @pgte as contributor
0.10.0 @ Jun 14 2013

@@ -2,0 +9,0 @@ ===================

14

lib/levelup.js

@@ -89,6 +89,8 @@ /* Copyright (c) 2012-2013 LevelUP contributors

LevelUP.prototype.open = function (callback) {
var self = this
if (isOpen()) {
if (callback)
process.nextTick(callback.bind(null, null, this))
return this
if (callback) {
process.nextTick(function () { callback(null, self) })
}
return self
}

@@ -99,3 +101,3 @@

'open'
, callback.bind(null, null, this)
, function () { callback(null, self) }
)

@@ -107,3 +109,3 @@ }

status = 'opening'
this.db = deferred
self.db = deferred

@@ -461,2 +463,2 @@ var dbFactory = levelup.options.db || getLevelDOWN()

// DEPRECATED: prefer accessing LevelDOWN for this: require('leveldown').repair()
module.exports.repair = utilStatic('repair')
module.exports.repair = utilStatic('repair')

@@ -18,13 +18,13 @@ /* Copyright (c) 2012-2013 LevelUP contributors

, makeKeyValueData = function (key, value) {
, makeKeyValueData = function (key, keyEncoding, value, valueEncoding) {
return {
key: toEncoding[this._keyEncoding](key)
, value: toEncoding[this._valueEncoding](value)
key: toEncoding[keyEncoding](key)
, value: toEncoding[valueEncoding](value)
}
}
, makeKeyData = function (key) {
return toEncoding[this._keyEncoding](key)
, makeKeyData = function (key, keyEncoding) {
return toEncoding[keyEncoding](key)
}
, makeValueData = function (key, value) {
return toEncoding[this._valueEncoding](value)
, makeValueData = function (_, __, value, valueEncoding) {
return toEncoding[valueEncoding](value)
}

@@ -58,15 +58,15 @@ , makeNoData = function () { return null }

this._makeData = this._options.keys && this._options.values
? makeKeyValueData.bind(this) : this._options.keys
? makeKeyData.bind(this) : this._options.values
? makeValueData.bind(this) : makeNoData
? makeKeyValueData : this._options.keys
? makeKeyData : this._options.values
? makeValueData : makeNoData
var self = this
var ready = function () {
if (!this._state.canEmitData())
if (!self._state.canEmitData())
return
this._state.ready()
this._iterator = iteratorFactory(this._options)
this._read()
}.bind(this)
self._state.ready()
self._iterator = iteratorFactory(self._options)
self._read()
}

@@ -105,2 +105,3 @@ if (db.isOpen())

this._dataEvent = 'entry'
var self = this
this.on('entry', function (data) {

@@ -116,4 +117,4 @@ var entry = bufferStream(new Buffer(data.value))

if (dest.add(entry) === false)
this.pause()
}.bind(this))
self.pause()
})
}

@@ -124,7 +125,7 @@ return Stream.prototype.pipe.apply(this, arguments)

ReadStream.prototype._read = function () {
var that = this
var self = this
if (this._state.canRead()) {
this._state.read()
this._iterator.next(function(err, key, value) {
that._onData(err, key, value)
self._onData(err, key, value)
})

@@ -140,3 +141,3 @@ }

try {
value = this._makeData(key, value)
value = this._makeData(key, this._keyEncoding, value, this._valueEncoding)
} catch (e) {

@@ -161,6 +162,7 @@ return this.emit('error', new errors.EncodingError(e))

if (this._iterator) {
var self = this
this._iterator.end(function () {
this._iterator = null
this.emit('close')
}.bind(this))
self._iterator = null
self.emit('close')
})
} else

@@ -167,0 +169,0 @@ this.emit('close')

@@ -9,2 +9,3 @@ /* Copyright (c) 2012-2013 LevelUP contributors

, errors = require('./errors')
, bops = require('bops')

@@ -37,5 +38,5 @@ , encodings = [

, isBuffer = function (data) {
return data === undefined || data === null || Buffer.isBuffer(data)
return data === undefined || data === null || bops.is(data)
}
slicers.json = JSON.stringify.bind(JSON)
slicers.json = JSON.stringify
slicers.utf8 = function (data) {

@@ -47,3 +48,3 @@ return isBuffer(data) ? data : String(data)

slicers[enc] = function (data) {
return isBuffer(data) ? data : new Buffer(data, enc)
return isBuffer(data) ? data : bops.from(data, enc)
}

@@ -61,3 +62,3 @@ })

if (encoders[enc]) return
encoders[enc] = function (buffer) { return buffer.toString(enc) }
encoders[enc] = function (buffer) { return bops.to(buffer, enc) }
})

@@ -64,0 +65,0 @@ return encoders

@@ -28,9 +28,10 @@ /* Copyright (c) 2012-2013 LevelUP contributors

var self = this
var ready = function () {
if (!this.writable)
if (!self.writable)
return
this._status = 'ready'
this.emit('ready')
this._process()
}.bind(this)
self._status = 'ready'
self.emit('ready')
self._process()
}

@@ -59,10 +60,13 @@ if (db.isOpen())

WriteStream.prototype.end = function() {
WriteStream.prototype.end = function (data) {
var self = this
if (data)
this.write(data)
setImmediate(function () {
this._end = true
this._process()
}.bind(this))
self._end = true
self._process()
})
}
WriteStream.prototype.destroy = function() {
WriteStream.prototype.destroy = function () {
this.writable = false

@@ -72,7 +76,7 @@ this.end()

WriteStream.prototype.destroySoon = function() {
WriteStream.prototype.destroySoon = function () {
this.end()
}
WriteStream.prototype.add = function(entry) {
WriteStream.prototype.add = function (entry) {
if (!entry.props)

@@ -87,7 +91,10 @@ return

WriteStream.prototype._processDelayed = function() {
setImmediate(this._process.bind(this))
WriteStream.prototype._processDelayed = function () {
var self = this
setImmediate(function () {
self._process()
})
}
WriteStream.prototype._process = function() {
WriteStream.prototype._process = function () {
var buffer

@@ -97,25 +104,25 @@ , self = this

, cb = function (err) {
if (!this.writable)
if (!self.writable)
return
if (this._status != 'closed')
this._status = 'ready'
if (self._status != 'closed')
self._status = 'ready'
if (err) {
this.writable = false
return this.emit('error', err)
self.writable = false
return self.emit('error', err)
}
this._process()
}.bind(this)
self._process()
}
if (this._status != 'ready' && this.writable) {
if (this._buffer.length && this._status != 'closed')
this._processDelayed()
if (self._status != 'ready' && self.writable) {
if (self._buffer.length && self._status != 'closed')
self._processDelayed()
return
}
if (this._buffer.length && this.writable) {
this._status = 'writing'
buffer = this._buffer
this._buffer = []
if (self._buffer.length && self.writable) {
self._status = 'writing'
buffer = self._buffer
self._buffer = []
this._db.batch(buffer.map(function (d) {
self._db.batch(buffer.map(function (d) {
return {

@@ -132,5 +139,5 @@ type : d.type || self._options.type

if (this._writeBlock) {
this._writeBlock = false
this.emit('drain')
if (self._writeBlock) {
self._writeBlock = false
self.emit('drain')
}

@@ -142,6 +149,6 @@

if (this._end && this._status != 'closed') {
this._status = 'closed'
this.writable = false
this.emit('close')
if (self._end && self._status != 'closed') {
self._status = 'closed'
self.writable = false
self.emit('close')
}

@@ -152,2 +159,3 @@ }

var key = entry.path || entry.props.path
, self = this

@@ -159,12 +167,12 @@ if (!key)

if (err) {
this.writable = false
return this.emit('error', err)
self.writable = false
return self.emit('error', err)
}
if (this._options.fstreamRoot &&
key.indexOf(this._options.fstreamRoot) > -1)
key = key.substr(this._options.fstreamRoot.length + 1)
if (self._options.fstreamRoot &&
key.indexOf(self._options.fstreamRoot) > -1)
key = key.substr(self._options.fstreamRoot.length + 1)
this.write({ key: key, value: data })
}.bind(this)))
self.write({ key: key, value: data })
}))
}

@@ -178,2 +186,2 @@

return new WriteStream(options, db)
}
}

@@ -16,2 +16,3 @@ {

, "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)"
, "Pedro Teixeira <pedro.teixeira@gmail.com> (https://github.com/pgte)"
]

@@ -27,3 +28,3 @@ , "keywords": [

]
, "version" : "0.10.0"
, "version" : "0.11.0"
, "main" : "lib/levelup.js"

@@ -37,5 +38,6 @@ , "dependencies" : {

, "semver" : "~1.1.4"
, "bops" : "~0.0.6"
}
, "devDependencies" : {
"leveldown" : "~0.6.0"
"leveldown" : "~0.5.0"
, "bustermove" : "*"

@@ -71,2 +73,2 @@ , "tap" : "*"

, "license" : "MIT"
}
}

@@ -11,2 +11,5 @@ LevelUP

[![NPM](https://nodei.co/npm/levelup.png)](https://nodei.co/npm/levelup/)
* <a href="#news">News</a>

@@ -665,2 +668,3 @@ * <a href="#intro">Introduction</a>

<tr><th align="left">Matteo Collina</th><td><a href="https://github.com/mcollina">GitHub/mcollina</a></td><td><a href="https://twitter.com/matteocollina">Twitter/@matteocollina</a></td></tr>
<tr><th align="left">Pedro Teixeira</th><td><a href="https://github.com/pgte">GitHub/pgte</a></td><td><a href="https://twitter.com/pgte">Twitter/@pgte</a></td></tr>
</tbody></table>

@@ -681,2 +685,2 @@

*LevelUP builds on the excellent work of the LevelDB and Snappy teams from Google and additional contributors. LevelDB and Snappy are both issued under the [New BSD Licence](http://opensource.org/licenses/BSD-3-Clause).*
*LevelUP builds on the excellent work of the LevelDB and Snappy teams from Google and additional contributors. LevelDB and Snappy are both issued under the [New BSD Licence](http://opensource.org/licenses/BSD-3-Clause).*

@@ -133,2 +133,21 @@ /* Copyright (c) 2012-2013 LevelUP contributors

, 'test end accepts data': function (done) {
this.openTestDatabase(function (db) {
var ws = db.createWriteStream()
ws.on('error', function (err) {
refute(err)
})
ws.on('close', this.verify.bind(this, ws, db, done))
var i = 0
this.sourceData.forEach(function (d) {
i ++
if (i < this.sourceData.length) {
ws.write(d)
} else {
ws.end(d)
}
}.bind(this))
}.bind(this))
}
// at the moment, destroySoon() is basically just end()

@@ -228,3 +247,3 @@ , 'test destroySoon()': function (done) {

async.waterfall([
function(cb) {
function (cb) {
this.openTestDatabase(options, function (db) {

@@ -234,3 +253,3 @@ cb(null, db);

}.bind(this),
function(db, cb) {
function (db, cb) {
var ws = db.createWriteStream()

@@ -240,3 +259,3 @@ ws.on('error', function (err) {

})
ws.on('close', function() {
ws.on('close', function () {
cb(null, db);

@@ -251,3 +270,3 @@ })

},
function(db, cb) {
function (db, cb) {
var delStream = db.createWriteStream()

@@ -257,3 +276,3 @@ delStream.on('error', function (err) {

})
delStream.on('close', function() {
delStream.on('close', function () {
cb(null, db);

@@ -269,3 +288,3 @@ })

},
function(db, cb) {
function (db, cb) {
async.forEach(

@@ -303,3 +322,3 @@ data

async.waterfall([
function(cb) {
function (cb) {
this.openTestDatabase(options, function (db) {

@@ -309,3 +328,3 @@ cb(null, db);

}.bind(this),
function(db, cb) {
function (db, cb) {
var ws = db.createWriteStream()

@@ -315,3 +334,3 @@ ws.on('error', function (err) {

})
ws.on('close', function() {
ws.on('close', function () {
cb(null, db);

@@ -326,3 +345,3 @@ })

},
function(db, cb) {
function (db, cb) {
var delStream = db.createWriteStream({ type: 'del' })

@@ -332,3 +351,3 @@ delStream.on('error', function (err) {

})
delStream.on('close', function() {
delStream.on('close', function () {
cb(null, db);

@@ -343,3 +362,3 @@ })

},
function(db, cb) {
function (db, cb) {
async.forEach(

@@ -380,3 +399,3 @@ data

async.waterfall([
function(cb) {
function (cb) {
this.openTestDatabase(options, function (db) {

@@ -386,3 +405,3 @@ cb(null, db);

}.bind(this),
function(db, cb) {
function (db, cb) {
var ws = db.createWriteStream()

@@ -392,3 +411,3 @@ ws.on('error', function (err) {

})
ws.on('close', function() {
ws.on('close', function () {
cb(null, db);

@@ -403,3 +422,3 @@ })

},
function(db, cb) {
function (db, cb) {
var delStream = db.createWriteStream({ type: 'del' })

@@ -409,3 +428,3 @@ delStream.on('error', function (err) {

})
delStream.on('close', function() {
delStream.on('close', function () {
cb(null, db);

@@ -420,3 +439,3 @@ })

},
function(db, cb) {
function (db, cb) {
async.forEach(

@@ -445,6 +464,6 @@ data

async.waterfall([
function(cb) {
function (cb) {
this.openTestDatabase(cb.bind(null, null))
}.bind(this),
function(db, cb) {
function (db, cb) {
var ws = db.createWriteStream()

@@ -461,3 +480,3 @@ ws.on('error', function (err) {

}.bind(this),
function(db, cb) {
function (db, cb) {
async.forEach(

@@ -464,0 +483,0 @@ this.sourceData

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