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

unique-filename

Package Overview
Dependencies
Maintainers
5
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.

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19M
decreased by-9.87%
Maintainers
5
Weekly downloads
 
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 25 Aug 2022

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