| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1× 1× 1× 1× | const path = require("path");
const TMP_DIR = require("os").tmpDir();
function makeTemporaryPath(prefix) {
prefix = prefix || "";
const random = (Math.random() * 0x100000000 + 1).toString(36);
const now = new Date();
const date = now.getYear().toString() + now.getMonth() + now.getDate();
const name = [prefix, date, "-", process.pid, "-", random].join("");
return path.join(TMP_DIR, name);
}
module.exports = makeTemporaryPath;
|