file-writer

fileWriter base on web browser by using HTML5 interface(download attr), support mostly modern browser including IE 10+

Usage no npm install needed!

<script type="module">
  import fileWriter from 'https://cdn.skypack.dev/file-writer';
</script>

README

Introduction

fileWriter tool base on web browser by using HTML5 interface(download attr), support mostly modern browser including IE 10+

Install

npm install file-writer

Usage example

import writer from 'file-writer';
writer('a.csv', '\
year,age,status,sex,population\r\n\
1850,20,0,1,1017281\r\n\
1850,20,0,2,1003841\r\n\
')

And then the browser will pop a download dialog with filename 'a.csv'.

API

  • .writer(filename = 'file', content, encode = 'utf-8'): content will be encoded as binary automaticly; you'r recommended to supply fileName with extension.

Contributing

We welcome all contributions, please submit any ideas as pull requests or as a GitHub issue.

Licence

MIT