4.0.0 • Published 9 months ago

unique-filename v4.0.0

Weekly downloads
11,345,283
License
ISC
Repository
github
Last release
9 months ago

unique-filename

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

const uniqueFilename = require('unique-filename')

// returns something like: '/tmp/c5b28f47'
const randomTmpfile = uniqueFilename(os.tmpdir())

// returns something like: '/tmp/my-test-51a7b48d'
const randomPrefixedTmpfile = uniqueFilename(os.tmpdir(), 'my-test')

// returns something like: '/my-tmp-dir/testing-7ddd44c0'
const uniqueTmpfile = uniqueFilename('/my-tmp-dir', 'testing', '/my/thing/to/uniq/on')

uniqueFilename(dir, fileprefix, uniqstr) → String

Returns the full path of a unique filename that looks like: dir/prefix-7ddd44c0 or dir/7ddd44c0

dir – The path you want the filename in. os.tmpdir() is a good choice for this.

fileprefix – A string to append prior to the unique part of the filename. The parameter is required if uniqstr is also passed in but is otherwise optional and can be undefined/null/''. If present and not empty then this string plus a hyphen are prepended to the unique part.

uniqstr – Optional, if not passed the unique part of the resulting filename will be random. If passed in it will be generated from this string in a reproducible way.

cacachevuedragdropuploadimagespopsmart-common-authkilli8n-react-native-fast-imageinvoicewave_back@cashremit/cr-streamline-iconsbb-chat@frxf/frxf@texttree/demo-bsa-reference-rcl@fundefund/funde_ckgql_din_mod@l1nyanm1ng/react-picture-viewer@saeon/ol-react@saeon/quick-formcogoportutilsjs4cytoscape@mink-opn/build-tokens@saaspe/componentsexpand-react-bridgenode-gio@everything-registry/sub-chunk-3013jawwy-sdkreact-native-sphereuisphereuitalkso-clitest-carosello-campustest-iki-mini-appwinx-form-winxweb-elements-iconsvue-button-test1webchewedmasterwow.js-juziwuchuansupercluster-googlemaps-adapter-clonestestapatestujsk_custom_ckeditor5svelte-component-libtextfield-samplevue-compmentvantiq-reactvue-dev-clone@djgu/cli@drblmthw/testujsk_custom_ckeditor5@ct-note/table@ct-note/warning@ct-note/image@ct-note/inline-code@ct-note/list@ct-note/marker@ct-note/paragraph@ct-note/quote@ct-note/simple-image@ct-note/checklist@ct-note/code@ct-note/delimiter@ct-note/embed@ct-note/header@cube-design/react@cybermega/flutter-resource-manager-rs@blkmarketco/components-library@beldore/react-otp-input@percent/percent-api-hooks@positionex/position-sdk@rbc-public/react-selectable-fastjeuxuijesusdemojesh-calculationjmpr-jpmjamuskalimjameslinenode.js1kydra@simstudio/htmldiffdfeuk-frontenddfeuk-frontend-manualsushi-sdk-ftm@castrum-nubis/bulmazzzxxxyyy321123styletoolsstnenopmoc-iustock-ticker-react-widgettehmusimhujanud7-act2tingzi-vuepresstinymce-plugin-toyu-librarytldrawlignin@artiso-solutions/vue-html-to-paper@applaud/cacache@asiz33/smartblok-vendure-plugin@arielapaula/components@arielapaula/test@aviinash_jha/react-native-test_multiply@ali5049/react-native-buttons@beisen/npm@buganto/client@carhoo/widget-dealers@cdk8s-extensions/argo-rollout@cleveradssolutions/cas.cordova.ironsource@cleveradssolutions/cas.cordova.kidoz
4.0.0

9 months ago

3.0.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.1

7 years ago

1.1.0

10 years ago

1.0.0

10 years ago