Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unique-filename

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unique-filename

Generate a unique filename for use in temporary directories or caches.

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is unique-filename?

The unique-filename npm package is a simple utility that generates a unique filename with an optional file path and extension. It can be used to ensure that files written to a directory do not clash with existing filenames.

What are unique-filename's main functionalities?

Generate a unique filename

This feature generates a unique filename within the specified directory. The result is a random filename that is unlikely to clash with existing files.

const uniqueFilename = require('unique-filename');
const randomFilePath = uniqueFilename('/some/path');
console.log(randomFilePath);

Generate a unique filename with a specific extension

This feature generates a unique filename with a specified file extension, ensuring that the file fits the desired format.

const uniqueFilename = require('unique-filename');
const randomFilePath = uniqueFilename('/some/path', '.txt');
console.log(randomFilePath);

Generate a unique filename with a custom random string generator

This feature allows for a custom random string generator to be used, providing control over the randomness and format of the generated filename.

const uniqueFilename = require('unique-filename');
const customRandom = () => 'custom-string';
const randomFilePath = uniqueFilename('/some/path', '.txt', customRandom);
console.log(randomFilePath);

Other packages similar to unique-filename

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc