Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filestream-cache

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filestream-cache - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

16

index.js

@@ -20,3 +20,2 @@ var fs = require('fs');

this.defaultTtl = options.defaultTtl || twelveHoursInSeconds;
this.serveStale = options.serveStale || false;

@@ -228,2 +227,10 @@ // TODO: Where's best to handle errors here?

stream.on('error', function(err) {
cacheStream.then(function(s) { s.end();
fs.unlink(cachedObjectPath, function(e) {
});
});
cachedStream.emit('error', err);
});
var cachedStream = stream.pipe(through(function(chunk, enc, callback) {

@@ -244,9 +251,2 @@ this.push(chunk, enc);

stream.on('error', function(err) {
cacheStream.then(function(s) { s.end();
fs.unlink(cachedObjectPath, function(e) {
});
});
cachedStream.emit('error', err);
});

@@ -253,0 +253,0 @@ return cachedStream;

@@ -17,4 +17,4 @@ {

},
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT"
}

@@ -57,2 +57,25 @@ var StreamCache = require('../index'); var fs = require('fs');

it("should not cache an erroring Readable stream", function(done) {
var testBucket = 'writeThrough#readableerror';
var cacheKey = 'test';
var stream = helpers.createErroringReadableStream();
var testDirectory = helpers.localTestDirectory(testBucket);
var streamCache = new StreamCache(testDirectory);
var cachedStream = streamCache.writeThrough(cacheKey, stream);
cachedStream.on('error', function(err) {
assert.equal(err.code, 'ENOENT');
var cachedObjectPromise = streamCache._read(cacheKey);
cachedObjectPromise.then(function(object) {
assert.equal(object, false);
rmrf(testDirectory);
done();
});
});
});
it("should write the stream to the cache and return the stream without modification", function(done) {

@@ -59,0 +82,0 @@ var streamContent = 'my test stream content';

@@ -49,2 +49,7 @@ 'use strict';

function createErroringReadableStream() {
var stream = fs.createReadStream("/dev/not/a/thing");
return stream;
}
function testPurgeFunction(cacheKeys, expected, filterFunction) {

@@ -116,3 +121,4 @@ // Add some uniqueness with Date.now()

createStream: createStream,
createErroringReadableStream: createErroringReadableStream,
createErroringStream: createErroringStream
};
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