This project is part of the @thi.ng/umbrella monorepo.
Local asset download for web apps, with automatic MIME type detection.
ALPHA - bleeding edge / work-in-progress
yarn add @thi.ng/download
Package sizes (gzipped): ESM: 0.4KB / CJS: 0.4KB / UMD: 0.5KB
Several demos in this repo's /examples directory are using this package.
A selection:
Interactive grid generator, SVG generation & export, undo/redo support
import { download } from "@thi.ng/download";
const src = "Hellö wörld!";
// mime type derived from file extension (.txt)
download("hello.txt", src, {
utf8: true,
expire: 1000
});
// with explicit MIME type string
download("hello.txt", src, {
mime: "text/plain",
utf8: true,
expire: 1000
});
...or using MIME type preset from @thi.ng/mime.
import { MIME_TYPES } from "@thi.ng/mime";
download("hello.txt", src, {
mime: MIME_TYPES.text,
utf8: true,
expire: 1000
});
Karsten Schmidt
© 2020 Karsten Schmidt // Apache Software License 2.0