A library which binds download.js function to PureScript, so you can download your data from an HTML5 browser in a type-safe way.
We import the download function as a Node library, so you should add it in your project:
npm install downloadjs
Then add this library (
downloadjs) to your
If it's not in a fresh package set, you'll have an extra step.
You can simply trigger a download with the
download function, providing it your payload, file name and
MIME type (if you don't know what to provide, use
module Main where import Prelude import Web.DownloadJs (download) import Effect.Class.Console (log) main = do couldDownload <- download "hello world" "hello.txt" "text/plain" log $ if couldDownload then "Done!" else "Couldn't download, because your browser is a potato."
Payload supports strings (and data URLs in it), blobs from
typed arrays from
arraybuffer-types. These types are included in
Downloadable type class.
Actually, there's none, besides of that function returns
False if it couldn't trigger a download.
For other cases, use exception handling.
Module documentation is published on Pursuit.
This library is MIT licensed.