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

fd

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fd - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

16

example/index.js

@@ -17,4 +17,4 @@ // run `npm install` in the current directory to install

, statCache = AC({
max : 10
, maxAge : 1000
max : 100
, maxAge : 10000
, load : function (path, callback) {

@@ -27,4 +27,4 @@ fs.stat(path, callback)

, fdCache = AC({
max : 2
, maxAge : 1000
max : 100
, maxAge : 10000
// use fdman to open & close

@@ -68,8 +68,4 @@ , load : fdman.open.bind(fdman)

var st = fs.createReadStream(p, { fd: fd, start: 0, end: stat.size })
.on('end', function () {
checkin(p, fd)
})
.on('error', function () {
checkin(p, fd)
})
.on('end', checkin)
.on('error', checkin)

@@ -76,0 +72,0 @@ // override destroy so we don't close the fd

@@ -6,3 +6,3 @@ const fs = require('fs')

// the reason we use a combination of path+fd to store references
// in this._usingfd is that it is possible to have multiple fds
// in this._fds is that it is possible to have multiple fds
// for the same file simultaneously. Particularly in the situation

@@ -18,7 +18,6 @@ // where an fd is pending for a close but hasn't been checked back

delete this._usingfd[key(path, fd)]
delete this._usingfd[path]
delete this._fds[key(path, fd)]
delete this._fds[path]
if (this._pendingClose[key(path, fd)]) {
console.log('close', path, fd)
fs.close(fd, function () {})

@@ -37,3 +36,3 @@ totalOpenFds--

process.nextTick(function () {
if (!this._usingfd[key(path, fd)])
if (!this._fds[key(path, fd)])
cleanupFd.call(this, path, fd)

@@ -48,11 +47,10 @@ }.bind(this))

// then just use that.
if (this._usingfd[path] && !this._pendingClose[key(path, this._usingfd[path])])
return cb(null, this._usingfd[path])
if (this._fds[path] && !this._pendingClose[key(path, this._fds[path])])
return cb(null, this._fds[path])
fs.open(path, 'r', function (er, fd) {
if (!er) {
console.log('open', path, fd)
totalOpenFds++
this._usingfd[path] = fd
this._usingfd[fd + path] = 0
this._fds[path] = fd
this._fds[fd + path] = 0
}

@@ -67,4 +65,4 @@

this._usingfd[path] = fd
this._usingfd[key(path, fd)] = (this._usingfd[key(path, fd)] || 0) + 1
this._fds[path] = fd
this._fds[key(path, fd)] = (this._fds[key(path, fd)] || 0) + 1
}

@@ -75,3 +73,3 @@

if (this._usingfd[path] && --this._usingfd[key(path, fd)] === 0)
if (this._fds[path] && --this._fds[key(path, fd)] === 0)
cleanupFd.call(this, path, fd)

@@ -102,3 +100,3 @@ }

return Object.create(FDManager, {
_usingfd : { value: Object.create(null) }
_fds : { value: Object.create(null) }
, _pendingClose : { value: Object.create(null) }

@@ -105,0 +103,0 @@ })

{
"name" : "fd"
, "description" : "File descriptor manager"
, "version" : "0.0.1"
, "version" : "0.0.2"
, "homepage" : "https://github.com/rvagg/node-fd"

@@ -6,0 +6,0 @@ , "authors" : [

@@ -29,4 +29,4 @@ # fd [![Build Status](https://secure.travis-ci.org/rvagg/node-fd.png)](http://travis-ci.org/rvagg/node-fd)

, statCache = AC({
max : 10
, maxAge : 1000
max : 100
, maxAge : 10000
, load : function (path, callback) {

@@ -39,4 +39,4 @@ fs.stat(path, callback)

, fdCache = AC({
max : 2
, maxAge : 1000
max : 100
, maxAge : 10000
// use fdman to open & close

@@ -79,9 +79,5 @@ , load : fdman.open.bind(fdman)

// stream from the fd to the response
var st = fs.createReadStream(p, { fd: fd, start: 0, end: stat.size })
.on('end', function () {
checkin(p, fd)
})
.on('error', function () {
checkin(p, fd)
})
var st = fs.createReadStream(p, { fd: fd, start: 0, end: stat.size })n
.on('end', checkin)
.on('error', checkin)

@@ -95,3 +91,4 @@ // override destroy so we don't close the fd

})
}).listen(8080)```
}).listen(8080)
```

@@ -98,0 +95,0 @@ ## API

@@ -132,2 +132,3 @@ var tap = require('tap')

// good luck figuring this out buddy
// it made sense when it was coming out of my fingers at least
mkfiletree.makeTemp('fd', filetree, function (err, dir) {

@@ -134,0 +135,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