file-saver
Advanced tools
Comparing version 1.3.8 to 2.0.0-rc.1
{ | ||
"_from": "file-saver@1.3.3", | ||
"_id": "file-saver@1.3.3", | ||
"_inBundle": false, | ||
"_integrity": "sha1-zdTETTqiZOrC9o7BZbx5HDSvEjI=", | ||
"_location": "/file-saver", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "file-saver@1.3.3", | ||
"name": "file-saver", | ||
"escapedName": "file-saver", | ||
"rawSpec": "1.3.3", | ||
"saveSpec": null, | ||
"fetchSpec": "1.3.3" | ||
}, | ||
"_requiredBy": [ | ||
"#USER", | ||
"/" | ||
"name": "file-saver", | ||
"version": "2.0.0-rc.1", | ||
"description": "An HTML5 saveAs() FileSaver implementation", | ||
"main": "dist/FileSaver.min.js", | ||
"module": "src/FileSaver.js", | ||
"files": [ | ||
"dist/FileSaver.js", | ||
"dist/FileSaver.min.js", | ||
"src/FileSaver.js" | ||
], | ||
"_resolved": "https://registry.npmjs.org/file-saver/-/file-saver-1.3.3.tgz", | ||
"_shasum": "cdd4c44d3aa264eac2f68ec165bc791c34af1232", | ||
"_spec": "file-saver@1.3.3", | ||
"_where": "/Users/jimmywarting/git/FileSaver.js", | ||
"author": { | ||
"name": "Eli Grey", | ||
"email": "me@eligrey.com" | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 0", | ||
"build:development": "babel -o dist/FileSaver.js --plugins @babel/plugin-transform-modules-umd src/FileSaver.js", | ||
"build:production": "babel -o dist/FileSaver.min.js -s --plugins @babel/plugin-transform-modules-umd --presets minify src/FileSaver.js", | ||
"build": "npm run build:development && npm run build:production", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/eligrey/FileSaver.js/issues" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/eligrey/FileSaver.js" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"description": "An HTML5 saveAs() FileSaver implementation", | ||
"devDependencies": { | ||
"uglify-js": "^2.6.2" | ||
}, | ||
"homepage": "https://github.com/eligrey/FileSaver.js#readme", | ||
"keywords": [ | ||
@@ -45,14 +28,14 @@ "filesaver", | ||
], | ||
"author": "Eli Grey <me@eligrey.com>", | ||
"license": "MIT", | ||
"main": "FileSaver.js", | ||
"name": "file-saver", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/eligrey/FileSaver.js.git" | ||
"bugs": { | ||
"url": "https://github.com/eligrey/FileSaver.js/issues" | ||
}, | ||
"scripts": { | ||
"build": "uglifyjs FileSaver.js --mangle --comments /@source/ > FileSaver.min.js", | ||
"test": "echo \"Error: no test specified\" && exit 0" | ||
}, | ||
"version": "1.3.8" | ||
"homepage": "https://github.com/eligrey/FileSaver.js#readme", | ||
"devDependencies": { | ||
"@babel/cli": "^7.1.0", | ||
"@babel/core": "^7.1.0", | ||
"@babel/plugin-transform-modules-umd": "^7.1.0", | ||
"babel-preset-minify": "^0.4.3" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
If you need to save really large files bigger then the blob's size limitation or don't have | ||
If you need to save really large files bigger then the blob's size limitation or don't have | ||
enough RAM, then have a look at the more advanced [StreamSaver.js](https://github.com/jimmywarting/StreamSaver.js) | ||
@@ -35,2 +35,3 @@ that can save data directly to the hard drive asynchronously with the power of the new streams API. That will have | ||
| Safari < 6 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | ||
| Safari 10.1+ | Blob | Yes | n/a | None | | ||
@@ -57,12 +58,16 @@ Feature detection is possible: | ||
saveAs must be run within a user interaction event such as onTouchDown or onClick; setTimeout will prevent saveAs from triggering. Due to restrictions in iOS saveAs opens in a new window instead of downloading, if you want this fixed please [tell Apple](https://bugs.webkit.org/show_bug.cgi?id=102914) how this bug is affecting you. | ||
saveAs must be run within a user interaction event such as onTouchDown or onClick; setTimeout will prevent saveAs from triggering. Due to restrictions in iOS saveAs opens in a new window instead of downloading, if you want this fixed please [tell Apple how this WebKit bug is affecting you](https://bugs.webkit.org/show_bug.cgi?id=167341). | ||
Syntax | ||
------ | ||
### Import saveAs() from file-saver | ||
```js | ||
import { saveAs } from 'file-saver/FileSaver'; | ||
``` | ||
```js | ||
FileSaver saveAs(Blob/File data, optional DOMString filename, optional Boolean disableAutoBOM) | ||
FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Boolean autoBOM) | ||
``` | ||
Pass `true` for `disableAutoBOM` if you don't want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)). | ||
Pass `true` for `autoBOM` if you don't want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)). | ||
@@ -72,2 +77,9 @@ Examples | ||
### Saving text using require | ||
```js | ||
var FileSaver = require('file-saver'); | ||
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); | ||
FileSaver.saveAs(blob, "hello world.txt"); | ||
``` | ||
### Saving text | ||
@@ -77,5 +89,15 @@ | ||
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); | ||
saveAs(blob, "hello world.txt"); | ||
FileSaver.saveAs(blob, "hello world.txt"); | ||
``` | ||
### Saving urls | ||
```js | ||
FileSaver.saveAs("https://httpbin.org/image", "image.jpg"); | ||
``` | ||
Using urls within the same origin will just use `a[download]` | ||
Otherwise it will first check if it supports cors header with a synchronously head request | ||
if it dose it will download the data and save it using blob urls | ||
if not it will try to download it using `a[download]` | ||
The standard W3C File API [`Blob`][4] interface is not available in all browsers. | ||
@@ -101,8 +123,10 @@ [Blob.js][5] is a cross-browser `Blob` implementation that solves this. | ||
File itself already contains a name, There is a hand full of ways to get a file | ||
instance (from storage, file input, new constructor) | ||
instance (from storage, file input, new constructor, clipboard event) | ||
But if you still want to change the name, then you can change it in the 2nd argument | ||
```js | ||
// Note: Ie and Edge don't support the new File constructor, | ||
// so it's better to construct blobs and use saveAs(blob, filename) | ||
var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"}); | ||
saveAs(file); | ||
FileSaver.saveAs(file); | ||
``` | ||
@@ -121,15 +145,2 @@ | ||
Contributing | ||
------------ | ||
The `FileSaver.js` distribution file is compiled with Uglify.js like so: | ||
```bash | ||
uglifyjs FileSaver.js --mangle --comments /@source/ > FileSaver.min.js | ||
# or simply: | ||
npm run build | ||
``` | ||
Please make sure you build a production version before submitting a pull request. | ||
Installation | ||
@@ -142,1 +153,7 @@ ------------------ | ||
``` | ||
Additionally, TypeScript definitions can be installed via: | ||
```bash | ||
npm install @types/file-saver --save-dev | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
153
20845
4
6
290
2