Skip to content

mkstemp

mkstemp(suffix: string, prefix: string, dir?: string, _text?: boolean): Promise<[FileHandle, string]>

Defined in: packages/pythonlib/src/tempfile.node.ts:59

Create a temporary file and return a tuple of (handle, path).

Parameters

ParameterTypeDefault valueDescription
suffixstring""Optional suffix for the filename
prefixstring"tmp"Optional prefix for the filename (default: “tmp”)
dir?stringundefinedOptional directory (default: system temp dir)
_text?booleanfalse-

Returns

Promise<[FileHandle, string]>

Promise of tuple [FileHandle, path]

Example

const [handle, path] = await mkstemp(".txt", "myapp-")
await handle.write(Buffer.from("data"))
await handle.close()