4.0.0 • Published 1 year ago

unique-filename v4.0.0

Weekly downloads
11,345,283
License
ISC
Repository
github
Last release
1 year 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@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.js1kydraiiif-manifest-editorinfostoryhubot-budahot-zone-vuegridfs-storegrid-component-react-ex-1guruwayguruway.jshelp-widgetgundam5litepie-datepicker-gabeluojia-cli-devmangudinlagirajinmanan-react-native-expo-authorize-netm2m-chartjs-plugin-crosshairlabtesttwol2forlernakrown_login_librarymd-vditor@wavecore/core-node@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@udooku/react-image-comparison-slider@tonysusi/vapid@tmind/yuna-tools@thedoctor0/vuex-shared-mutations@tomw2w/my-nuxt-layer@vitali_shcherbina/styled-lib@zh0st/evm-chains@zebracompany/f_editoranakketigaanaklanangteaanakwadonteaagent-get-agenta_react_reflux_demoained-ckeditor5b2x-utilsastra-ufo-sdkarifbudixzap-vue-captchaarchlibraryappcharge-checkout@cleveradssolutions/cas.cordova.adcolony@cleveradssolutions/cas.cordova.admob@cleveradssolutions/cas.cordova.applovin@cleveradssolutions/cas.cordova.facebook
4.0.0

1 year 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