@@ -22,7 +22,10 @@ a six letter random identifier. And just in case that you do not have that much
22
22
entropy left on your system, Tmp will fall back to pseudo random numbers.
23
23
24
24
You can set whether you want to remove the temporary file on process exit or
25
- not, and the destination directory can also be set.
25
+ not.
26
+
27
+ And if you do not want to store your temporary directories and files in the
28
+ standard OS temporary directory, then you are free to override that as well.
26
29
27
30
## An Important Note on Compatibility
28
31
@@ -285,12 +288,16 @@ console.log('Dir: ', tmpobj.name);
285
288
286
289
### Asynchronous filename generation
287
290
288
- The ` tmpName() ` function accepts the ` prefix ` , ` postfix ` , ` dir ` , etc. parameters also:
291
+ Using ` tmpName() ` you can create temporary file names asynchronously.
292
+ The function accepts all standard options, e.g. ` prefix ` , ` postfix ` , ` dir ` , and so on.
293
+ And you can also leave out the options altogether and just call the function with a callback as first parameter.
289
294
290
295
``` javascript
291
296
var tmp = require (' tmp' );
292
297
293
- tmp .tmpName ({ template: ' /tmp/tmp-XXXXXX' }, function _tempNameGenerated (err , path ) {
298
+ var options = {};
299
+
300
+ tmp .tmpName (options, function _tempNameGenerated (err , path ) {
294
301
if (err) throw err;
295
302
296
303
console .log (' Created temporary filename: ' , path);
@@ -300,10 +307,12 @@ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, pa
300
307
### Synchronous filename generation
301
308
302
309
The ` tmpNameSync() ` function works similarly to ` tmpName() ` .
310
+ Again, you can leave out the options altogether and just invoke the function without any parameters.
303
311
304
312
``` javascript
305
313
var tmp = require (' tmp' );
306
- var tmpname = tmp .tmpNameSync ({ template: ' /tmp/tmp-XXXXXX' });
314
+ var options = {};
315
+ var tmpname = tmp .tmpNameSync (options);
307
316
console .log (' Created temporary filename: ' , tmpname);
308
317
```
309
318
@@ -328,8 +337,8 @@ All options are optional :)
328
337
* ` template ` : [ ` mkstemp ` ] [ 3 ] like filename template, no default
329
338
* ` dir ` : the optional temporary directory, fallbacks to system default (guesses from environment)
330
339
* ` tries ` : how many times should the function try to get a unique filename before giving up, default ` 3 `
331
- * ` keep ` : signals that the temporary file or directory should not be deleted on exit, default is ` false ` , means delete
332
- * Please keep in mind that it is recommended in this case to call the provided ` cleanupCallback ` function manually.
340
+ * ` keep ` : signals that the temporary file or directory should not be deleted on exit, default is ` false `
341
+ * In order to clean up, you will have to call the provided ` cleanupCallback ` function manually.
333
342
* ` unsafeCleanup ` : recursively removes the created temporary directory, even when it's not empty. default is ` false `
334
343
335
344
[ 1 ] : http://nodejs.org/
0 commit comments