random-access-storage
Advanced tools
Comparing version 1.2.0 to 1.3.0
11
index.js
@@ -114,4 +114,11 @@ var events = require('events') | ||
this._callback = cb | ||
this._openError = null | ||
} | ||
Request.prototype._maybeOpenError = function (err) { | ||
if (this.type !== 0) return | ||
var queued = this.storage._queued | ||
for (var i = 0; i < queued.length; i++) queued[i]._openError = err | ||
} | ||
Request.prototype._unqueue = function (err) { | ||
@@ -144,2 +151,4 @@ var ra = this.storage | ||
} | ||
} else { | ||
this._maybeOpenError(err) | ||
} | ||
@@ -160,3 +169,3 @@ | ||
if (ra.opened && !ra.closed) return true | ||
if (!ra.opened) nextTick(this, new Error('Not opened')) | ||
if (!ra.opened) nextTick(this, this._openError || new Error('Not opened')) | ||
else if (ra.closed) nextTick(this, new Error('Closed')) | ||
@@ -163,0 +172,0 @@ return false |
{ | ||
"name": "random-access-storage", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Easily make random-access-storage instances", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
23
test.js
@@ -416,1 +416,24 @@ var tape = require('tape') | ||
}) | ||
tape('open error forwarded to dependents', function (t) { | ||
var s = ras({ | ||
open: req => req.callback(new Error('Nope')), | ||
read: req => req.callback(null, Buffer.from('hi')), | ||
write: req => req.callback(null, null) | ||
}) | ||
s.write(0, Buffer.from('hi'), function (err) { | ||
t.ok(err) | ||
t.same(err.message, 'Nope') | ||
}) | ||
s.read(0, 2, function (err) { | ||
t.ok(err) | ||
t.same(err.message, 'Nope') | ||
}) | ||
s.close(function (err) { | ||
t.ok(!err) | ||
t.end() | ||
}) | ||
}) |
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
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
23918
594