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.0.0 to 1.1.0

15

index.js

@@ -227,3 +227,5 @@ var fs = require('fs');

return stream.pipe(through(function(chunk, enc, callback) {
var cachedStream = stream.pipe(through(function(chunk, enc, callback) {
this.push(chunk, enc);
cacheStream.then(function(cache) {

@@ -233,3 +235,2 @@ cache.write(chunk, enc);

this.push(chunk, enc);
callback();

@@ -242,2 +243,12 @@ }, function flush(callback) {

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

@@ -244,0 +255,0 @@

2

package.json

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

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

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

describe("#writeThrough(identifier, stream)", function() {
it("should not cache an erroring stream", function(done) {
var testBucket = 'writeThrough#error';
var cacheKey = 'test';
var stream = helpers.createErroringStream("test content");
var testDirectory = helpers.localTestDirectory(testBucket);
var streamCache = new StreamCache(testDirectory);
var cachedStream = streamCache.writeThrough(cacheKey, stream);
cachedStream.on('error', function(err) {
assert.equal(err.message, 'fail');
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) {

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

@@ -9,2 +9,3 @@ 'use strict';

var assert = require('assert');
var PassThrough = require('stream').PassThrough;

@@ -40,2 +41,11 @@ function localTestDirectory(bucket) {

function createErroringStream(streamContents) {
var stream = new PassThrough();
stream.write(streamContents);
process.nextTick(function() {
stream.emit('error', new Error("fail"));
});
return stream;
}
function testPurgeFunction(cacheKeys, expected, filterFunction) {

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

testIsStale: testIsStale,
createStream: createStream
createStream: createStream,
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