
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
create temporary files and directories
$ npm install mktemp
import * as os from 'node:os';
import * as path from 'node:path';
import * as mktemp from 'mktemp';
const tempDir = os.tmpdir();
mktemp.createFile(path.join(tempDir, 'XXXXX.txt'), function (err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
});
// return value match a /^[\da-zA-Z]{5}\.tmp$/
mktemp.createFileSync(path.join(tempDir, 'XXXXX.tmp'));
mktemp.createDir(path.join(tempDir, 'XXXXXXX'), function (err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{7}$/
console.log(path);
});
// return value match a /^XXX-[\da-zA-Z]{3}$/
mktemp.createDirSync(path.join(tempDir, 'XXX-XXX'));
if support Promise, can use Promise style.
import * as mktemp from 'mktemp';
mktemp
.createFile('XXXXX.txt')
.then(function (path) {
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
})
.catch(function (err) {
console.error(err);
});
mktemp
.createDir('XXXXX')
.then(function (path) {
// path match a /^[\da-zA-Z]{5}$/
console.log(path);
})
.catch(function (err) {
console.error(err);
});
mktemp functions are replace to random string from placeholder "X" in template. see example:
mktemp.createFileSync('XXXXXXX'); // match a /^[\da-zA-Z]{7}$/
mktemp.createFileSync('XXX.tmp'); // match a /^[\da-zA-Z]{3}\.tmp$/
mktemp.createFileSync('XXX-XXX'); // match a /^XXX-[\da-zA-Z]{3}$/
template
String
- filename templatemode
Number
- file permission mode (default: 0o600
)callback
function(err, path)
- callback function
err
: Error|Null
- error objectpath
: String
- pathcreate blank file of unique filename. return Promise if callback is not passed.
template
String
- filename templatemode
Number
- file permission mode (default: 0o600
)return
String
- pathsync version createFile.
template
String
- dirname templatemode
Number
- directory permission mode (default: 0o700
)callback
function(err, path)
- callback function
err
: Error|Null
- error objectpath
: String
- pathcreate directory of unique dirname. return Promise if callback is not passed.
template
String
- dirname templatemode
Number
- directory permission mode (default: 0o700
)return
String
- pathsync version createDir.
The MIT license.
FAQs
create temporary files and directories
The npm package mktemp receives a total of 584,649 weekly downloads. As such, mktemp popularity was classified as popular.
We found that mktemp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.