fs-writefile-promise

Promise version of fs.writefile

Usage no npm install needed!

<script type="module">
  import fsWritefilePromise from 'https://cdn.skypack.dev/fs-writefile-promise';
</script>

README

fs.writeFile Promise

License version Build Status

Promise version of fs.writeFile:
Asynchronously writes data to a file, replacing the file if it already exists.

Install

npm install fs-writefile-promise

API

write(filename, data [, options])

  • filename: String
  • data String or Buffer
  • options: Object

Return: Object (Promise)

When it finishes, it will be fulfilled with the file name that was written to.

When it fails, it will be rejected with an error as its first argument.

write('/tmp/foo', 'bar')
  .then(filename => console.log(filename)) //=> '/tmp/foo'
  .catch(err => console.error(err))

options

The option object will be directly passed to fs.writeFile.


Author: Ahmad Nassri • Github: @ahmadnassri • Twitter: @AhmadNassri