tmp-promise
Advanced tools
Comparing version 1.0.5 to 1.1.0
{ | ||
"name": "tmp-promise", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "The tmp package with promises support and disposers.", | ||
@@ -25,3 +25,3 @@ "main": "index.js", | ||
"bluebird": "^3.5.0", | ||
"tmp": "0.0.33" | ||
"tmp": "0.1.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ # tmp-promise | ||
The [tmp](https://github.com/raszi/node-tmp) package with promises support. | ||
The [tmp](https://github.com/raszi/node-tmp) package with promises support. If you want to use `tmp` with `async/await` then this helper might be for you. | ||
@@ -33,2 +33,16 @@ This documentation is mostly copied from that package's - but with promise usage instead of callback usage adapted. | ||
With Node.js 10 and es - modules: | ||
```js | ||
import { file } from 'tmp-promise' | ||
(async () => { | ||
const {fd, path, cleanup} = await file(); | ||
// work with file here in fd | ||
cleanup(); | ||
})(); | ||
``` | ||
Or the older way: | ||
```javascript | ||
@@ -50,3 +64,16 @@ var tmp = require('tmp-promise'); | ||
With Node.js 10 and es - modules: | ||
```js | ||
import { withFile } from 'tmp-promise' | ||
withFile(async ({path, fd}) => { | ||
// when this function returns or throws - release the file | ||
await doSomethingWithFile(db); | ||
}); | ||
``` | ||
Or the older way: | ||
```js | ||
tmp.withFile(o => { | ||
@@ -53,0 +80,0 @@ console.log("File: ", o.path); |
var accessSync = require('fs').accessSync | ||
var assert = require('assert') | ||
var extname = require('path').extname | ||
var existsSync = require('fs').existsSync | ||
@@ -20,3 +21,3 @@ var tmp = require('.') | ||
assert.strictEqual(extname(filepath), '.txt') | ||
}, {postfix: '.txt'}) | ||
}, {discardDescriptor: true, postfix: '.txt'}) | ||
.then(function() | ||
@@ -23,0 +24,0 @@ { |
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
13041
309
6
118
2
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedtmp@0.1.0(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedtmp@0.0.33(transitive)
Updatedtmp@0.1.0