Socket
Socket
Sign inDemoInstall

graceful-fs

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graceful-fs - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

83

graceful-fs.js

@@ -85,2 +85,8 @@ // this keeps a queue of opened file descriptors, and will make

break
case 'ReadFileReq':
readFile(req.path, req.options, req.cb)
break
case 'WriteFileReq':
writeFile(req.path, req.data, req.options, req.cb)
break
default:

@@ -148,2 +154,79 @@ throw new Error('Unknown req type: ' + req.constructor.name)

fs.readFile = gracefulReadFile
function gracefulReadFile(path, options, cb) {
if (typeof options === "function") cb = options, options = null
if (typeof cb !== "function") cb = noop
if (fs._curOpen >= fs.MAX_OPEN) {
queue.push(new ReadFileReq(path, options, cb))
setTimeout(flush)
return
}
readFile(path, options, function (er, data) {
if (er && er.code === "EMFILE" && fs._curOpen > fs.MIN_MAX_OPEN) {
fs.MAX_OPEN = fs._curOpen - 1
return fs.readFile(path, options, cb)
}
cb(er, data)
})
}
function readFile (path, options, cb) {
cb = cb || noop
fs._curOpen ++
fs._originalFs.readFile.call(fs, path, options, function (er, data) {
onclose()
cb(er, data)
})
}
function ReadFileReq (path, options, cb) {
this.path = path
this.options = options
this.cb = cb
}
fs.writeFile = gracefulWriteFile
function gracefulWriteFile(path, data, options, cb) {
if (typeof options === "function") cb = options, options = null
if (typeof cb !== "function") cb = noop
if (fs._curOpen >= fs.MAX_OPEN) {
queue.push(new WriteFileReq(path, data, options, cb))
setTimeout(flush)
return
}
writeFile(path, data, options, function (er) {
if (er && er.code === "EMFILE" && fs._curOpen > fs.MIN_MAX_OPEN) {
fs.MAX_OPEN = fs._curOpen - 1
return fs.writeFile(path, data, options, cb)
}
cb(er)
})
}
function writeFile (path, data, options, cb) {
cb = cb || noop
fs._curOpen ++
fs._originalFs.writeFile.call(fs, path, data, options, function (er) {
onclose()
cb(er)
})
}
function WriteFileReq (path, data, options, cb) {
this.path = path
this.data = data
this.options = options
this.cb = cb
}
// (re-)implement some things that are known busted or missing.

@@ -150,0 +233,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"description": "A drop-in replacement for fs, making various improvements.",
"version": "1.2.2",
"version": "1.2.3",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

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