1.2.4 • Published 1 year ago

select-random-file v1.2.4

Weekly downloads
20
License
ISC
Repository
github
Last release
1 year ago

select-random-file

Build status

Select a random file from a provided directory:

const randomFile = require('select-random-file')

const dir = '/tmp/whatever'
randomFile(dir, (err, file) => {
  console.log(`The random file is: ${file}.`)
})

There are a couple of things that could be added:

  • filter files by an extension
  • recursively traverse a deeper directory structure

Acknowledgements

Discussion on Stack Overflow was very useful: http://stackoverflow.com/questions/42425887/how-to-use-an-async-function-as-compare-function-of-array-filter

1.2.4

1 year ago

1.2.2

1 year ago

1.2.1

2 years ago

1.2.0

3 years ago

1.1.0

7 years ago

1.0.0

7 years ago