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

browser-cache-blob-store

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-cache-blob-store - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

14

index.js

@@ -1,2 +0,1 @@

var eos = require('end-of-stream')
var duplexify = require('duplexify')

@@ -8,11 +7,2 @@ var through = require('through2')

var listen = function (stream, opts, cb) {
if (!cb) return stream
eos(stream, function (err) {
if (err) return cb(err)
cb(null, opts)
})
return stream
}
var BlobStore = function (opts) {

@@ -31,3 +21,3 @@ if (!window || !window.caches) throw new Error('Not supported on this platform')

var proxy = listen(through(), opts, cb)
var proxy = through()

@@ -43,2 +33,4 @@ var response = new window.Response(nodeToWebStream(proxy), {

proxy.emit('error', err)
}).then(() => {
if (cb) cb(null, opts)
})

@@ -45,0 +37,0 @@ })

{
"name": "browser-cache-blob-store",
"version": "1.1.0",
"version": "1.1.1",
"description": "blob store that stores blobs using the browser Cache interface",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,2 +19,3 @@ # browser-cache-blob-store

var cacheStore = require('browser-cache-blob-store')
var collect = require('collect-stream')
var blobs = cacheStore()

@@ -24,16 +25,19 @@

key: 'some/path/file.txt'
}, function (err, opts) {
collect(blobs.createReadStream(opts.key), function (err, readBuf) {
console.log(readBuf.toString())
})
})
ws.write('hello world\n')
ws.end(function() {
var rs = blobs.createReadStream({
key: 'some/path/file.txt'
})
rs.pipe(process.stdout)
})
ws.end()
```
## Known Issues
The blob will not be immediately available after the writable stream emits the
`finish` event. To be sure it is ready, use the callback.
## License
MIT

@@ -26,12 +26,33 @@ var tape = require('tape')

tape('Confirm cache exists after writeStream finishes', function (t) {
var buf = Buffer.alloc(50 * 1024 * 1024, 1) // 5MB buffer
tape('README example', function (t) {
common.setup(tape, function (err, store) {
t.error(err, 'setup did not error')
var ws = store.createWriteStream({
key: 'some/path/file.txt'
}, function (err, opts) {
t.error(err, 'written no errors')
collect(store.createReadStream(opts.key), function (err, readBuf) {
t.error(err, 'read no errors')
t.equal(readBuf.toString(), 'hello world\n', 'output matches')
t.end()
})
})
ws.write('hello world\n')
ws.end()
})
})
// TODO: This fails, the cache is not ready on the `finish` event, but it is
// ready on the `end` event. Need to understand streams better
tape('Confirm cache exists after writeStream finishes no callback', function (t) {
var buf = Buffer.alloc(50 * 1024 * 1024, 1) // 50MB buffer
common.setup(tape, function (err, store) {
t.error(err, 'setup did not error')
var key = 'my/cat.jpg'
var ws = store.createWriteStream(key, function (err) {
t.error(err, 'created without error')
var ws = store.createWriteStream(key)
ws.on('finish', function () {
collect(store.createReadStream(key), function (err, readBuf) {
t.error(err)
t.equal(readBuf.length, buf.length, 'Read buffer has expected length')
if (!err) t.equal(readBuf.length, buf.length, 'Read buffer has expected length')
common.teardown(tape, store, buf, function () {

@@ -51,3 +72,3 @@ t.end()

tape('Confirm cache exists after writeStream callback', function (t) {
var buf = Buffer.alloc(1 * 1024 * 1024, 1) // 5MB buffer
var buf = Buffer.alloc(50 * 1024 * 1024, 1) // 50MB buffer
common.setup(tape, function (err, store) {

@@ -61,3 +82,2 @@ t.error(err, 'setup did not error')

t.equal(readBuf.length, buf.length, 'Read buffer has expected length')
console.log(readBuf.slice(-20))
common.teardown(tape, store, buf, function () {

@@ -64,0 +84,0 @@ t.end()

@@ -16,19 +16,5 @@ var test = require('tape')

test('cancel() ensures cleanup', function (t) {
t.timeoutAfter(3000)
var nodeStream = from('foobar')
nodeStream._destroy = function () {
t.end()
}
var webStream = nodeToWebStream(nodeStream)
nodeStream.on('end', function () {
})
webStream.cancel()
})
test('cancel() ensures _destroy()', function (t) {
t.timeoutAfter(3000)
var nodeStream = from('foobar')
var nodeStream = new ReadableStream()
var webStream = nodeToWebStream(nodeStream)

@@ -35,0 +21,0 @@

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