
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
temp-write
Advanced tools
The temp-write npm package allows you to write temporary files to the filesystem. It is useful for scenarios where you need to create temporary files that are automatically cleaned up after use.
Write temporary file with content
This feature allows you to write a string to a temporary file and get the file path. The file is automatically cleaned up after the process exits.
const tempWrite = require('temp-write');
const fs = require('fs');
(async () => {
const filePath = await tempWrite('Hello, world!');
console.log(filePath);
console.log(fs.readFileSync(filePath, 'utf8'));
})();
Write temporary file with specific extension
This feature allows you to specify the extension of the temporary file. The file is automatically cleaned up after the process exits.
const tempWrite = require('temp-write');
const fs = require('fs');
(async () => {
const filePath = await tempWrite('Hello, world!', { extension: 'txt' });
console.log(filePath);
console.log(fs.readFileSync(filePath, 'utf8'));
})();
Write temporary file with specific name
This feature allows you to specify the name of the temporary file. The file is automatically cleaned up after the process exits.
const tempWrite = require('temp-write');
const fs = require('fs');
(async () => {
const filePath = await tempWrite('Hello, world!', { name: 'example.txt' });
console.log(filePath);
console.log(fs.readFileSync(filePath, 'utf8'));
})();
The tmp package provides similar functionality for creating temporary files and directories. It offers more control over the lifecycle of the temporary files and directories, including manual cleanup.
The temp package is another alternative for handling temporary files and directories. It provides a more comprehensive API for managing temporary resources, including automatic cleanup and custom directory support.
The fs-extra package extends the native fs module with additional methods, including methods for handling temporary files. It provides a more extensive set of file system utilities beyond just temporary file handling.
Write data to a random temporary file
npm install temp-write
import fs from 'node:fs';
import tempWrite from 'temp-write';
const filePath = tempWrite.sync('unicorn');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b'
fs.readFileSync(filePath, 'utf8');
//=> 'unicorn'
tempWrite.sync('unicorn', 'pony.png');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png'
tempWrite.sync('unicorn', 'rainbow/cake/pony.png');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png'
Returns a Promise
for the file path of the temporary file.
Returns the file path of the temporary file.
Type: string | Uint8Array | stream.Readable
The data to write to the temporary file. Streams are supported only with the async API.
Type: string
Examples: 'img.png'
'foo/bar/baz.png'
Optionally specify a file path which is appended to the random path.
FAQs
Write data to a random temporary file
The npm package temp-write receives a total of 916,677 weekly downloads. As such, temp-write popularity was classified as popular.
We found that temp-write 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.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.