@@ -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
+ 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,17 @@ 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
+
294
+ You can also leave out the options altogether and just call the function with a callback as first parameter.
289
295
290
296
``` javascript
291
297
var tmp = require (' tmp' );
292
298
293
- tmp .tmpName ({ template: ' /tmp/tmp-XXXXXX' }, function _tempNameGenerated (err , path ) {
299
+ var options = {};
300
+
301
+ tmp .tmpName (options, function _tempNameGenerated (err , path ) {
294
302
if (err) throw err;
295
303
296
304
console .log (' Created temporary filename: ' , path);
@@ -300,10 +308,12 @@ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, pa
300
308
### Synchronous filename generation
301
309
302
310
The ` tmpNameSync() ` function works similarly to ` tmpName() ` .
311
+ Again, you can leave out the options altogether and just invoke the function without any parameters.
303
312
304
313
``` javascript
305
314
var tmp = require (' tmp' );
306
- var tmpname = tmp .tmpNameSync ({ template: ' /tmp/tmp-XXXXXX' });
315
+ var options = {};
316
+ var tmpname = tmp .tmpNameSync (options);
307
317
console .log (' Created temporary filename: ' , tmpname);
308
318
```
309
319
@@ -328,8 +338,8 @@ All options are optional :)
328
338
* ` template ` : [ ` mkstemp ` ] [ 3 ] like filename template, no default
329
339
* ` dir ` : the optional temporary directory, fallbacks to system default (guesses from environment)
330
340
* ` 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.
341
+ * ` keep ` : signals that the temporary file or directory should not be deleted on exit, default is ` false `
342
+ * In order to clean up, you will have to call the provided ` cleanupCallback ` function manually.
333
343
* ` unsafeCleanup ` : recursively removes the created temporary directory, even when it's not empty. default is ` false `
334
344
335
345
[ 1 ] : http://nodejs.org/
0 commit comments