rw-utf8-promise

Read and write to text files in utf8 format using promise API

Usage no npm install needed!

<script type="module">
  import rwUtf8Promise from 'https://cdn.skypack.dev/rw-utf8-promise';
</script>

README

Installation

npm i --save rw-utf8-promise

Usage

Read a file:


const rw = require('rw-utf8-promise')

var file_path = '/etc/hostname'

rw.read(file_path)
.then(function (hostname) {
  console.log(hostname)
})
.catch(function (err) {
  console.log(err)
})

Write to a file:


const rw = require('rw-utf8-promise')

var file_path = '/etc/hostname'
var new_hostname = 'archlinux-guy'

rw.write(file_path, new_hostname)
.then(function (hostname) {
  console.log(hostname)
})
.catch(function (err) {
  console.log(err)
})

License

MIT License