with-open-file
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "with-open-file", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Do stuff with an open file, knowing it will finally be closed", | ||
@@ -5,0 +5,0 @@ "repository": "raphinesse/with-open-file", |
@@ -18,16 +18,11 @@ # with-open-file [![Build Status](https://travis-ci.org/raphinesse/with-open-file.svg?branch=master)](https://travis-ci.org/raphinesse/with-open-file) | ||
```js | ||
const fs = require('fs-extra') | ||
const withOpenFile = require('with-open-file') | ||
const buf = Buffer.alloc(5) | ||
withOpenFile('foo.txt', 'r', fd => { | ||
return fs.read(fd, buf, 0, buf.length, 0) | ||
// Process file using fd | ||
}) | ||
//=> { bytesRead: 5, buffer: ... } | ||
withOpenFile.sync('foo.txt', 'r', fd => { | ||
return fs.readSync(fd, buf, 0, buf.length, 0) | ||
// Process file using synchronously using fd | ||
}) | ||
//=> 5 | ||
``` | ||
@@ -40,3 +35,3 @@ | ||
Returns the result of calling `callback` with the requested file descriptor. | ||
Returns a `Promise` wrapping the result of calling `callback` with the requested file descriptor. | ||
@@ -43,0 +38,0 @@ ### withOpenFile.sync(...openArgs, callback) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3444
48