Comparing version 8.0.0 to 9.0.0
@@ -829,8 +829,8 @@ var util = require('util') | ||
}, function (evt) { | ||
if (evt.type !== 'writeend') { | ||
callback(evt) | ||
} else { | ||
callback() | ||
} | ||
}) | ||
if (evt.type !== 'writeend') { | ||
callback(evt) | ||
} else { | ||
callback() | ||
} | ||
}) | ||
} | ||
@@ -919,2 +919,3 @@ | ||
} | ||
// debugger // eslint-disable-line | ||
@@ -1025,3 +1026,3 @@ // a little bit bigger buffer and water marks by default | ||
self.push(data) | ||
self.once('finish', self.close) | ||
// self.once('finish', self.close) | ||
} | ||
@@ -1039,3 +1040,3 @@ | ||
this.pos += this._readableState.highWaterMark | ||
// this.once('finish', this.close) | ||
} | ||
@@ -1047,3 +1048,2 @@ | ||
} | ||
this.destroyed = true | ||
@@ -1116,2 +1116,5 @@ this.close() | ||
WriteStream.prototype.open = function () { | ||
this.writelist = [] | ||
this.currentbuffersize = 0 | ||
this.tds = 0 | ||
exports.open(this.path, this.flags, this.mode, function (er, fd) { | ||
@@ -1124,2 +1127,5 @@ if (er) { | ||
this.fd = fd | ||
if (this.flags.indexOf('a') > -1) { | ||
this.fd.seek(this.fd.length) | ||
} | ||
this.emit('open', fd) | ||
@@ -1149,2 +1155,3 @@ }.bind(this)) | ||
var self = this | ||
this.fd.onerror = function (err) { | ||
@@ -1169,45 +1176,36 @@ if (err.name === 'TypeMismatchError') { | ||
var bufblob = new Blob([data], {type: 'application/octet-binary'}) // eslint-disable-line | ||
if (this.fd.readyState > 0) { | ||
if (typeof this.tmpbuffer === 'undefined') { | ||
this.tmpbuffer = [] | ||
} | ||
this.tmpbuffer += data | ||
this.isWriting = false | ||
} else { | ||
if (typeof this.fd.write === 'function') { | ||
if (this.flags.indexOf('a') > -1) { | ||
this.fd.seek(this.fd.length) | ||
} | ||
this.fd.write(bufblob) | ||
this.bytesWritten += data.length | ||
callback(null, bufblob.length) | ||
} else { | ||
if (typeof this.tmpbuffer === 'undefined') { | ||
this.tmpbuffer = [] | ||
} | ||
this.tmpbuffer += data | ||
this.isWriting = false | ||
} | ||
this.writelist.push(data) | ||
this.tds += data.length | ||
callback(null, data.length) | ||
} | ||
WriteStream.prototype._intenalwrite = function () { | ||
// if fd is null then don't write | ||
if (this.fd === null) { | ||
return | ||
} | ||
// When the ws.end() is called directly without an 'write' | ||
// this.fd.onwriteend = function (e) { throws an is null error | ||
if (this.fd !== null) { | ||
this.fd.onwriteend = function (e) { | ||
if (!self.isWriting) { | ||
if (self.tmpbuffer.length > 0) { | ||
self.isWriting = true | ||
var tmpblob = new Blob([self.tmpbuffer], {type: 'application/octet-binary'}) // eslint-disable-line | ||
self.tmpbuffer = [] | ||
self.fd.write(tmpblob) | ||
callback(null, tmpblob.length) | ||
self.bytesWritten += self.tmpbuffer.length | ||
} | ||
} | ||
} | ||
} | ||
var dataToWrite = Buffer.concat(this.writelist) | ||
this.writelist = [] | ||
var initblob = new Blob([dataToWrite]) // eslint-disable-line | ||
this.fd.write(initblob) | ||
} | ||
WriteStream.prototype.destroy = ReadStream.prototype.destroy | ||
WriteStream.prototype.close = ReadStream.prototype.close | ||
WriteStream.prototype.close = function (cb) { | ||
this._intenalwrite() | ||
var self = this | ||
if (cb) { | ||
this.once('close', cb) | ||
} | ||
if (this.closed) { | ||
this.emit('close') | ||
} | ||
this.closed = true | ||
close() | ||
function close (fd) { | ||
self.emit('close') | ||
self.fd = null | ||
} | ||
} | ||
@@ -1214,0 +1212,0 @@ // There is no shutdown() for files. |
{ | ||
"name": "chrome-fs", | ||
"version": "8.0.0", | ||
"version": "9.0.0", | ||
"description": "Use the Node `fs` API in Chrome Apps", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
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
9
1141
42841