| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/framework7/cordova/node_modules/with-open-file/ |
Upload File : |
# with-open-file [](https://travis-ci.org/raphinesse/with-open-file)
> Do stuff with an open file, knowing it will finally be closed
Because the built-in way requires way too much boilerplate.
## Install
```
$ npm install with-open-file
```
## Usage
```js
const withOpenFile = require('with-open-file')
withOpenFile('foo.txt', 'r', fd => {
// Process file using fd
})
withOpenFile.sync('foo.txt', 'r', fd => {
// Process file synchronously using fd
})
```
## API
### withOpenFile(...openArgs, callback)
Returns a `Promise` wrapping the result of calling `callback` with the requested file descriptor.
### withOpenFile.sync(...openArgs, callback)
Returns the result of calling `callback` with the requested file descriptor.
#### ...openArgs
Arguments as supported by [`fs.openSync`](https://nodejs.org/api/fs.html#fs_fs_opensync_path_flags_mode)
#### callback
Type: `function`
## License
MIT © Raphael von der Grün