@@ -22,7 +22,10 @@ a six letter random identifier. And just in case that you do not have that much
2222entropy left on your system, Tmp will fall back to pseudo random numbers.
2323
2424You 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.
2629
2730## An Important Note on Compatibility
2831
@@ -285,12 +288,17 @@ console.log('Dir: ', tmpobj.name);
285288
286289### Asynchronous filename generation
287290
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.
289295
290296``` javascript
291297var tmp = require (' tmp' );
292298
293- tmp .tmpName ({ template: ' /tmp/tmp-XXXXXX' }, function _tempNameGenerated (err , path ) {
299+ var options = {};
300+
301+ tmp .tmpName (options, function _tempNameGenerated (err , path ) {
294302 if (err) throw err;
295303
296304 console .log (' Created temporary filename: ' , path);
@@ -300,10 +308,12 @@ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, pa
300308### Synchronous filename generation
301309
302310The ` tmpNameSync() ` function works similarly to ` tmpName() ` .
311+ Again, you can leave out the options altogether and just invoke the function without any parameters.
303312
304313``` javascript
305314var tmp = require (' tmp' );
306- var tmpname = tmp .tmpNameSync ({ template: ' /tmp/tmp-XXXXXX' });
315+ var options = {};
316+ var tmpname = tmp .tmpNameSync (options);
307317console .log (' Created temporary filename: ' , tmpname);
308318```
309319
@@ -328,8 +338,8 @@ All options are optional :)
328338 * ` template ` : [ ` mkstemp ` ] [ 3 ] like filename template, no default
329339 * ` dir ` : the optional temporary directory, fallbacks to system default (guesses from environment)
330340 * ` 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.
333343 * ` unsafeCleanup ` : recursively removes the created temporary directory, even when it's not empty. default is ` false `
334344
335345[ 1 ] : http://nodejs.org/
0 commit comments