• Creates a unique temporary directory. A unique directory name is generated by appending six random characters to the end of the provided prefix. Due to platform inconsistencies, avoid trailing X characters in prefix. Some platforms, notably the BSDs, can return more than six random characters, and replace trailing X characters in prefix with random characters.

    The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.

    import { mkdtemp } from "fs/promises";

    try {
    await mkdtemp(path.join(os.tmpdir(), "foo-"));
    } catch (err) {
    console.error(err);
    }

    The fsPromises.mkdtemp() method will append the six randomly selected characters directly to the prefix string. For instance, given a directory/tmp, if the intention is to create a temporary directory within/tmp, theprefix must end with a trailing platform-specific path separator (require("path").sep).

    Since

    v0.0.67

    Returns

    Fulfills with a string containing the filesystem path of the newly created temporary directory.

    Parameters

    Returns Promise<string>

  • Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

    Parameters

    • prefix: string
    • options: BufferEncodingOption

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, "utf8" is used.

    Returns Promise<"buffer".Buffer>

  • Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

    Parameters

    • prefix: string
    • Optional options: "fs".EncodingOption

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, "utf8" is used.

    Returns Promise<string | "buffer".Buffer>

  • Creates a unique temporary directory. A unique directory name is generated by appending six random characters to the end of the provided prefix. Due to platform inconsistencies, avoid trailing X characters in prefix. Some platforms, notably the BSDs, can return more than six random characters, and replace trailing X characters in prefix with random characters.

    The optional options argument can be a string specifying an encoding, or an object with an encoding property specifying the character encoding to use.

    import { mkdtemp } from "fs/promises";

    try {
    await mkdtemp(path.join(os.tmpdir(), "foo-"));
    } catch (err) {
    console.error(err);
    }

    The fsPromises.mkdtemp() method will append the six randomly selected characters directly to the prefix string. For instance, given a directory/tmp, if the intention is to create a temporary directory within/tmp, theprefix must end with a trailing platform-specific path separator (require("path").sep).

    Since

    v0.0.67

    Returns

    Fulfills with a string containing the filesystem path of the newly created temporary directory.

    Parameters

    Returns Promise<string>

  • Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

    Parameters

    • prefix: string
    • options: BufferEncodingOption

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, "utf8" is used.

    Returns Promise<"buffer".Buffer>

  • Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

    Parameters

    • prefix: string
    • Optional options: "fs".EncodingOption

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, "utf8" is used.

    Returns Promise<string | "buffer".Buffer>

Generated using TypeDoc