Gathering detailed insights and metrics for uniquefilename
Gathering detailed insights and metrics for uniquefilename
Gathering detailed insights and metrics for uniquefilename
Gathering detailed insights and metrics for uniquefilename
npm install uniquefilename
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2 Stars
34 Commits
1 Forks
3 Watching
1 Branches
2 Contributors
Updated on 28 Dec 2020
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
44.8%
42
Compared to previous day
Last week
-10.8%
249
Compared to previous week
Last month
-28.4%
1,279
Compared to previous month
Last year
-52.9%
32,018
Compared to previous year
A module to get a filename - that doesn't already exist on the filesystem - using incremental values.
1npm install uniquefilename
1var uniquefilename = require('uniquefilename'); 2options = {}; 3uniquefilename.get('/path/to/dir/file.jpg', options, function(filename) { 4 // filename might be "/path/to/dir/file.jpg", 5 // "/path/to/dir/file-2.jpg", "/path/to/dir/file-3.jpg", etc... 6 // depending on the files that exist on your filesystem 7});
If a callback is not supplied, a Promise is returned (using bluebird).
1var uniquefilename = require('uniquefilename'); 2uniquefilename.get('/path/to/dir/file.jpg', {}).then(function (filename) { 3 console.log(filename); 4});
1var uniquefilename = require('uniquefilename'); 2options = {separator: '~', paddingCharacter: '0', paddingSize: 4, mode: 'alphanumeric'}; 3uniquefilename.get('/path/to/dir/file.jpg', options, function(filename) { 4 // filename might be "/path/to/dir/file.jpg", 5 // "/path/to/dir/file~000h.jpg", "/path/to/dir/file~00h9.jpg", etc... 6 // depending on the files that exist on your filesystem 7});
If the specified filename exists, the separator will be added before the incremental value such as: file{separator}2.jpg
The default value is '-'
.
The mode allows you to specify which characters to use to generate the incremental value (the string after the separator)
The default value is 'numeric'
.
'numeric'
Using the following characters: 1234567890
'alpha'
Using the following characters: abcdefghijklmnopqrstuvwxyz
'ALPHA'
Using the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
'alphanumeric'
Using the following characters: 0123456789abcdefghijklmnopqrstuvwxyz
'ALPHANUMERIC'
Using the following characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
'charset'
You must specify the characters you wish to use in the charset
optionIf you wish to left-pad the incremental values with a character, use this option. Here's an example :
1var uniquefilename = require('uniquefilename'); 2options = {mode: 'alpha', paddingCharacter: '0', paddingSize: 3}; 3uniquefilename.get('/path/to/dir/file.jpg', options, function(filename) { 4 // filename might be "/path/to/dir/file.jpg", 5 // "/path/to/dir/file-002.jpg", "/path/to/dir/file-045.jpg", etc... 6 // depending on the files that exist on your filesystem 7});
If alwaysAppend
is true
filenames will include the separator and attachment from the first request. So instead of
file.jpg
, file-2.jpg
you'd get file-1.jpg
, file-2.jpg
.
Multer is a node.js middleware for handling multipart/form-data
, which is primarily used for uploading files.
The following example shows you how to use multer along with this module to move an uploaded file to a unique filename :
1var multer = require('multer'); 2var path = require('path'); 3var uniquefilename = require('uniquefilename'); 4 5router.use(multer({ 6 storage: multer.diskStorage({ 7 destination: function (req, file, cb) { 8 cb(null, './public/uploads/') 9 }, 10 filename: function (req, file, cb) { 11 originalname = path.resolve('./public/uploads/' + file.originalname); 12 options = {}; 13 uniquefilename.get(originalname, options, function(filename) { 14 cb(null, path.basename(filename)); 15 }); 16 } 17 }) 18}).single('thumbnail'));
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More