1 # tempy [![Build Status](https://travis-ci.org/sindresorhus/tempy.svg?branch=master)](https://travis-ci.org/sindresorhus/tempy)
3 > Get a random temporary file or directory path
16 const tempy = require('tempy');
19 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4f504b9edb5ba0e89451617bf9f971dd'
21 tempy.file({extension: 'png'});
22 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/a9fb0decd08179eb6cf4691568aa2018.png'
24 tempy.file({name: 'unicorn.png'});
25 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/f7f62bfd4e2a05f1589947647ed3f9ec/unicorn.png'
28 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
34 ### tempy.file([options])
36 Get a temporary file path you can write to.
42 *You usually won't need either the `extension` or `name` option. Specify them only when actually needed.*
54 Filename. Mutually exclusive with the `extension` option.
58 Get a temporary directory path. The directory is created for you.
62 Get the root temporary directory path. For example: `/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T`
67 ### Why doesn't it have a cleanup method?
69 The operating system will clean up when needed. No point in us wasting resources and adding complexity.
74 - [temp-write](https://github.com/sindresorhus/temp-write) - Write string/buffer/stream to a random temp file
79 MIT © [Sindre Sorhus](https://sindresorhus.com)