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

fs2

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs2 - npm Package Compare versions

Comparing version 0.3.13 to 0.3.14

78

descriptors-handler.js

@@ -63,3 +63,3 @@ /* eslint max-lines: off */

if (err && (err.code === "EMFILE" || err.code === "ENFILE")) {
if (limit > openCount) limit = openCount;
if (limit > openCount) limit = openCount - 1;
queue.push({ fn: self, context, args });

@@ -77,3 +77,71 @@ release();

const wrapPromised = function () {
const handlePromised = function () {
const { open } = fs.promises;
fs.promises.open = defineLength(function (...args) {
if (count >= limit) {
const deferred = getDeferred();
queue.push({ fn: fs.promises.open, context: this, args, deferred });
return deferred.promise;
}
const openCount = count++;
++debugStats.promisesFd;
return open(...args).then(
handle => {
const { close } = handle;
handle.close = function () {
return close.call(this).then(() => {
--debugStats.promisesFd;
--count;
release();
});
return callback ? undefined : promise;
};
return handle;
},
function (error) {
--debugStats.promisesFd;
--count;
if (err.code === "EMFILE" || err.code === "ENFILE") {
if (limit > openCount) limit = openCount - 1;
const deferred = getDeferred();
queue.push({ fn: fs.open, context: this, args, deferred });
release();
return deferred.promise;
}
release();
throw error;
}
);
}, fs.promises.open.length);
const wrapPromised = function (asyncFn, type) {
let self;
debugStats[type] = 0;
return (self = defineLength(function (...args) {
if (count >= limit) {
const deferred = getDeferred();
queue.push({ fn: self, context: this, args, deferred });
return deferred.promise;
}
const openCount = count++;
++debugStats[type];
return asyncFn(...args).catch(error => {
--debugStats[type];
--count;
if (error.code === "EMFILE" || error.code === "ENFILE") {
if (limit > openCount) limit = openCount - 1;
const deferred = getDeferred();
queue.push({ fn: fs.promises.opendir, context: this, args, deferred });
release();
return deferred.promise;
}
release();
throw error;
});
}, asyncFn.length));
};
fs.promises.writeFile = wrapPromised(fs.promises.writeFile, "promisesWriteFile");
if (fs.opendirSync) {

@@ -137,3 +205,3 @@ const wrapDirEntries = require("./lib/wrap-dir-entries");

if (error.code === "EMFILE" || error.code === "ENFILE") {
if (limit > openCount) limit = openCount;
if (limit > openCount) limit = openCount - 1;
const deferred = getDeferred();

@@ -182,3 +250,3 @@ queue.push({ fn: fs.promises.opendir, context: this, args, deferred });

if (err.code === "EMFILE" || err.code === "ENFILE") {
if (limit > openCount) limit = openCount;
if (limit > openCount) limit = openCount - 1;
queue.push({ fn: fs.open, context: this, args });

@@ -224,3 +292,3 @@ release();

if (fs.promises) wrapPromised();
if (fs.promises) handlePromised();

@@ -227,0 +295,0 @@ Object.defineProperty(exports, "initialized", d("e", true));

2

package.json
{
"name": "fs2",
"version": "0.3.13",
"version": "0.3.14",
"description": "fs (file system package) extensions",

@@ -5,0 +5,0 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",

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