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

chrome-fs

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-fs - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

notes.txt

123

chrome.js

@@ -128,3 +128,3 @@ var util = require('util')

exports.fchown = function (fd, uid, gid, callback) {
this.chown(fd.filePath, uid, gid, callback)
this.chown(fd.fullPath, uid, gid, callback)
}

@@ -147,3 +147,3 @@

exports.fchmod = function (fd, mode, callback) {
this.chmod(fd.filePath, mode, callback)
this.chmod(fd.fullPath, mode, callback)
}

@@ -338,3 +338,5 @@

fd.onerror = cb
fd.onwriteend = cb
fd.onwriteend = function () {
cb()
}
fd.truncate(len)

@@ -344,3 +346,3 @@ }

exports.truncate = function (path, len, callback) {
if (util.isNumber(path)) {
if (util.isObject(path)) {
return this.ftruncate(path, len, callback)

@@ -356,5 +358,11 @@ }

callback = maybeCallback(callback)
this.open(path, 'r+', function (er, fd) {
this.open(path, 'w', function (er, fd) {
if (er) return callback(er)
fd.onwriteend = callback
fd.onwriteend = function (evt) {
if (evt.type !== 'writeend') {
callback(evt)
} else {
callback()
}
}
fd.truncate(len)

@@ -425,3 +433,9 @@ })

exports.fstat = function (fd, callback) {
this.stat(fd.filePath, callback)
if (typeof fds[fd.fullPath] === 'undefined') {
var ebadf = new Error()
ebadf.code = 'EBADF'
window.setTimeout(callback, 0, ebadf)
} else {
this.stat(fd.fullPath, callback)
}
}

@@ -454,2 +468,3 @@

fileEntry.createWriter(function (fileWriter) {
fileWriter.flags = flags
fileWriter.fullPath = fileEntry.fullPath

@@ -463,2 +478,3 @@ fds[fileWriter.fullPath] = {}

fileEntry.file(function (file) {
file.fullPath = fileEntry.fullPath
fds[file.fullPath] = {}

@@ -484,3 +500,3 @@ fds[file.fullPath].status = 'open'

var dird = {}
dird.filePath = path
dird.fullPath = path
callback(null, dird)

@@ -589,3 +605,2 @@ }

}
var encoding = options.encoding

@@ -607,2 +622,4 @@ assertEncoding(encoding)

window.setTimeout(callback, 0, null, new Buffer(this.result, 'binary'))
} else if (options.encoding === 'hex') {
window.setTimeout(callback, 0, null, new Buffer(this.result).toString('hex'))
} else {

@@ -618,7 +635,15 @@ window.setTimeout(callback, 0, null, this.result)

fileReader.readAsText(file)
} else if (file.type === 'application/octet-binary') {
} else {
fileReader.readAsArrayBuffer(file)
}
})
}, callback)
}, function (err) {
if (err.name === 'TypeMismatchError') {
var eisdir = new Error()
eisdir.code = 'EISDIR'
callback(eisdir)
} else {
callback(err)
}
})
}, callback)

@@ -642,10 +667,23 @@ }

// but this causes the stream to keep sending write events.
// So currently fs and writestream have there own implementations
fd.onwriteend = function () {
if (position !== null) {
fd.seek(position)
}
if (fd.flags.indexOf('a') > -1) {
fd.seek(fd.length)
}
fd.write(bufblob)
callback(null, tmpbuf.length, tmpbuf)
}
callback(null, tmpbuf.length)
} else {
if (position !== null) {
fd.seek(position)
}
if (fd.flags.indexOf('a') > -1) {
fd.seek(fd.length)
}
fd.write(bufblob)
if (typeof callback === 'function') {
callback(null, tmpbuf.length)
callback(null, tmpbuf.length, tmpbuf)
}

@@ -706,2 +744,11 @@ }

fileEntry.remove(callback)
}, function (err) {
if (err.name === 'TypeMismatchError') {
var eisdir = new Error()
eisdir.code = 'EISDIR'
eisdir.path = path
callback(eisdir)
} else {
callback(err)
}
})

@@ -736,5 +783,8 @@ }, callback)

var opts = {}
if (flag === 'w') {
if (flag.indexOf('w') > -1) {
opts = {create: true}
}
if (flag.indexOf('x') > -1) {
opts.exclusive = true
}
cfs.root.getFile(

@@ -746,8 +796,10 @@ path,

// otherwise we get the file because 'standards'
if (flag === 'w') {
if (flag.indexOf('w') > -1) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onerror = callback
// make sure we have an empty file
// fileWriter.truncate(0)
if (typeof callback === 'function') {
fileWriter.onwriteend = function (evt) {
window.setTimeout(callback, 0, null, evt)
window.setTimeout(callback, 0)
}

@@ -758,14 +810,43 @@ } else {

fileWriter.onprogress = function () {}
var blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
var blob
if (typeof data === 'string') {
blob = new Blob([data], {type: 'text/plain'}) // eslint-disable-line
} else {
if (options.encoding === 'hex') {
// convert the hex data to a string then save it.
blob = new Blob([new Buffer(data, 'hex').toString('hex')], {type: 'text/plain'}) // eslint-disable-line
} else {
blob = new Blob([data], {type: 'application/octet-binary'}) // eslint-disable-line
}
}
fileWriter.write(blob)
}, function (evt) {
if (evt.type !== 'writeend') {
callback(evt)
callback()
} else {
callback()
}
})
} else {
callback('incorrect flag')
var err = new Error()
err.code = 'UNKNOWN'
err.message = 'flag not supported: ' + flag
callback(err)
}
}, function () {})
}, callback)
}, function (err) {
if (err.name === 'TypeMismatchError') {
var eisdir = Error()
eisdir.code = 'EISDIR'
callback(eisdir)
} else {
callback(err)
}
})
}, function (evt) {
if (evt.type !== 'writeend') {
callback(evt)
} else {
callback()
}
})
}

@@ -772,0 +853,0 @@

2

package.json
{
"name": "chrome-fs",
"version": "6.0.0",
"version": "7.0.0",
"description": "Use the Node `fs` API in Chrome Apps",

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

@@ -118,4 +118,12 @@ # chrome-fs

### Encoding
Currently only UTF-8 is supported
### File Extensions
There seems to be an issue around saving files in chomefs
# Contributors
anton whalley @no9
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