Skip to content

Commit 030d65f

Browse files
author
Philipp Alferov
committed
Change order of arguments
1 parent 47ec656 commit 030d65f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-file-saver",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"main": [
55
"src/file-saver.js"
66
],

src/file-saver.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
return true;
3838
}
3939

40+
//If browser does not suport Blob natively, but the object passed as
41+
//first argument represented as BlobBuilder polyfill instance
4042
if (!blobSupport && data instanceof BlobBuilder) {
4143
return true;
4244
}
@@ -49,16 +51,29 @@
4951
}
5052

5153
return {
52-
saveFile: function (filename, settings) {
53-
var data = settings.data;
54-
var type = settings.options;
5554

55+
/**
56+
* saveFile - Immediately starts saving a file, returns undefined.
57+
*
58+
* @param {string|array|object} data Data, represented as a string,
59+
* an array or a Blob object;
60+
* @param {string} filename
61+
* @param {object} options Set of options for the Blob constructor.
62+
* Optional parameter, if Blob object is passed as first argument
63+
* @return {undefined}
64+
*/
65+
66+
saveFile: function (data, filename, options) {
67+
var blob;
68+
options = (typeof options === 'undefined') ? {} : options;
5669

5770
if (isBlobInstance(data)) {
5871
return saveAs(data, filename);
5972
}
6073

61-
var blob = blobInit(data, type);
74+
data = data instanceof Array ? data : [data];
75+
76+
blob = blobInit(data, options);
6277

6378
return saveAs(blob, filename);
6479
}

0 commit comments

Comments
 (0)