Global

Methods

dir(options, callbacknullable)

Creates a temporary directory.
Parameters:
Name Type Attributes Description
options Options | dirCallback the options or the callback function
callback dirCallback <nullable>
Source:

dirSync(options) → {DirSyncObject}

Synchronous version of dir.
Parameters:
Name Type Description
options Options
Source:
Throws:
if it cannot create a directory
Type
Error
Returns:
object consists of name and removeCallback
Type
DirSyncObject

file(options, callbacknullable)

Creates and opens a temporary file.
Parameters:
Name Type Attributes Description
options Options | null | undefined | fileCallback the config options or the callback function or null or undefined
callback fileCallback <nullable>
Source:

fileSync(options) → {FileSyncObject}

Synchronous version of file.
Parameters:
Name Type Description
options Options
Source:
Throws:
if cannot create a file
Type
Error
Returns:
object consists of name, fd and removeCallback
Type
FileSyncObject

setGracefulCleanup()

Sets the graceful cleanup. If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit, otherwise the temporary objects will remain in place, waiting to be cleaned up on system restart or otherwise scheduled temporary object removals.
Source:

tmpName(options, callbacknullable)

Gets a temporary file name.
Parameters:
Name Type Attributes Description
options Options | tmpNameCallback options or callback
callback tmpNameCallback <nullable>
the callback function
Source:

tmpNameSync(options) → {string}

Synchronous version of tmpName.
Parameters:
Name Type Description
options Object
Source:
Throws:
if the options are invalid or could not generate a filename
Type
Error
Returns:
the generated random name
Type
string

Type Definitions

DirSyncObject

Type:
  • Object
Properties:
Name Type Description
name string the name of the directory
removeCallback fileCallback the callback function to remove the directory
Source:

FileSyncObject

Type:
  • Object
Properties:
Name Type Description
name string the name of the file
fd string the file descriptor or -1 if the fd has been discarded
removeCallback fileCallback the callback function to remove the file
Source:

Options

Configuration options.
Type:
  • Object
Properties:
Name Type Attributes Description
keep boolean <nullable>
the temporary object (file or dir) will not be garbage collected
tries number <nullable>
the number of tries before give up the name generation
(?int) mode the access mode, defaults are 0o700 for directories and 0o600 for files
template string <nullable>
the "mkstemp" like filename template
name string <nullable>
fixed name relative to tmpdir or the specified dir option
dir string <nullable>
tmp directory relative to the root tmp directory in use
prefix string <nullable>
prefix for the generated name
postfix string <nullable>
postfix for the generated name
tmpdir string <nullable>
the root tmp directory which overrides the os tmpdir
unsafeCleanup boolean <nullable>
recursively removes the created temporary directory, even when it's not empty
detachDescriptor boolean <nullable>
detaches the file descriptor, caller is responsible for closing the file, tmp will no longer try closing the file during garbage collection
discardDescriptor boolean <nullable>
discards the file descriptor (closes file, fd is -1), tmp will no longer try closing the file during garbage collection
Source:

cleanupCallback(nextopt)

Removes the temporary created file or directory.
Parameters:
Name Type Attributes Description
next simpleCallback <optional>
function to call whenever the tmp object needs to be removed
Source:

cleanupCallbackSync()

Removes the temporary created file or directory.
Source:

dirCallback(errnullable, name, fn)

Parameters:
Name Type Attributes Description
err Error <nullable>
the error object if anything goes wrong
name string the temporary file name
fn cleanupCallback the cleanup callback function
Source:

dirCallbackSync(errnullable, name, fn)

Parameters:
Name Type Attributes Description
err Error <nullable>
the error object if anything goes wrong
name string the temporary file name
fn cleanupCallbackSync the cleanup callback function
Source:

fileCallback(errnullable, name, fd, fn)

Parameters:
Name Type Attributes Description
err Error <nullable>
the error object if anything goes wrong
name string the temporary file name
fd number the file descriptor or -1 if the fd had been discarded
fn cleanupCallback the cleanup callback function
Source:

fileCallbackSync(errnullable, name, fd, fn)

Parameters:
Name Type Attributes Description
err Error <nullable>
the error object if anything goes wrong
name string the temporary file name
fd number the file descriptor or -1 if the fd had been discarded
fn cleanupCallbackSync the cleanup callback function
Source:

simpleCallback()

Callback function for function composition.
Source:
See:

tmpNameCallback(errnullable, name)

Parameters:
Name Type Attributes Description
err Error <nullable>
the error object if anything goes wrong
name string the temporary file name
Source: