possify

```js test('buffer', async t => { const readFile = possify(util.promisify(fs.readFile)) const index = await readFile('./index.js', {}) t.is(true, Buffer.isBuffer(index)) })

Usage no npm install needed!

<script type="module">
  import possify from 'https://cdn.skypack.dev/possify';
</script>

README

Possify

test('buffer', async t => {
  const readFile = possify(util.promisify(fs.readFile))
  const index = await readFile('./index.js', {})
  t.is(true, Buffer.isBuffer(index))
})

test('string', async t => {
  const readFile = possify(util.promisify(fs.readFile))
  const index = await readFile('./index.js', { encoding: 'utf8' })
  t.is(true, typeof index === 'string')
})

test('error', async t => {
  const readFile = possify(util.promisify(fs.readFile))
  const error = await readFile('./zzz.js', { encoding: 'utf8' })
  t.is(true, error instanceof Error)
})