Comparing version 0.9.7 to 0.9.8
@@ -24,2 +24,4 @@ if (global.GENTLY) require = GENTLY.hijack(require); | ||
this._writeStream = null; | ||
this._fdRead = null; | ||
this._fdWrite = null; | ||
@@ -96,6 +98,22 @@ this._load(); | ||
/** | ||
* Close dirty db file stream, release file handle | ||
*/ | ||
Dirty.prototype.close = function() { | ||
if (!this.path) { | ||
return; | ||
} | ||
this._maybeFlush(); | ||
var self = this; | ||
fs.close(this._fdRead, function() { | ||
self.emit('read_close', 0); | ||
}); | ||
fs.close(this._fdWrite, function() { | ||
self.emit('write_close', 0); | ||
}); | ||
}; | ||
// Called when a dirty connection is instantiated | ||
@@ -168,2 +186,5 @@ Dirty.prototype._load = function() { | ||
self.emit('load', length); | ||
}) | ||
.on('open', function(fd) { | ||
self._fdRead = fd; | ||
}); | ||
@@ -179,2 +200,6 @@ | ||
}); | ||
this._writeStream.on('open', function(fd) { | ||
self._fdWrite = fd; | ||
}); | ||
}; | ||
@@ -181,0 +206,0 @@ |
{ | ||
"name": "dirty", | ||
"description": "A tiny & fast key value store with append-only disk log. Ideal for apps with < 1 million records.", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"dependencies": {}, | ||
@@ -6,0 +6,0 @@ "main": "./lib/dirty", |
@@ -98,2 +98,6 @@ # node-dirty | ||
### dirty.close() | ||
Close the dirty db file handle. | ||
### dirty event: 'load' (length) | ||
@@ -111,4 +115,14 @@ | ||
### dirty event: 'read_close' () | ||
Emitted once the database file read stream closed. | ||
### dirty event : 'write_close' () | ||
Emitted once the database file write stream closed. | ||
## Tests | ||
[![Build Status](https://travis-ci.org/felixge/node-dirty.png)](https://travis-ci.org/felixge/node-dirty) | ||
Dirty utilizes the [Mocha](http://visionmedia.github.com/mocha/) test framework. | ||
@@ -115,0 +129,0 @@ |
var config = require('./config'); | ||
path = require('path'), | ||
fs = require('fs'), | ||
@@ -7,2 +8,6 @@ dirty = require(config.LIB_DIRTY), | ||
// exists moved from path to fs in node v0.7.1 | ||
// https://raw.github.com/joyent/node/v0.7.1/ChangeLog | ||
var exists = (fs.exists) ? fs.exists : path.exists; | ||
function dirtyAPITests(file) { | ||
@@ -12,6 +17,10 @@ var mode = (file) ? 'persistent' : 'transient'; | ||
describe('dirty api (' + mode + ' mode)', function() { | ||
function cleanup() { | ||
if (fs.existsSync(file)) { | ||
fs.unlinkSync(file); | ||
} | ||
function cleanup(done) { | ||
exists(file, function(doesExist) { | ||
if (doesExist) { | ||
fs.unlinkSync(file); | ||
} | ||
done(); | ||
}); | ||
} | ||
@@ -18,0 +27,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27772
34
742
138
1