Skip to content

Commit b129335

Browse files
author
Philipp Alferov
committed
Fix #2
1 parent af54bea commit b129335

10 files changed

+325
-579
lines changed

dist/angular-file-saver.bundle.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,6 @@ angular.module('ngFileSaver', [])
506506
'use strict';
507507

508508
module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
509-
if (SaveAs === null) {
510-
return {
511-
saveAs: null
512-
};
513-
}
514-
515-
function isBlobInstance(obj) {
516-
return obj instanceof Blob;
517-
}
518509

519510
function save(blob, filename) {
520511
try {
@@ -527,22 +518,24 @@ module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
527518
return {
528519

529520
/**
530-
* saveAs - Immediately starts saving a file, returns undefined.
521+
* saveAs
522+
* Immediately starts saving a file, returns undefined.
531523
*
532-
* @param {object} options Set of options such as filename and data.
533-
* @return {undefined}
524+
* @name saveAs
525+
* @function
526+
* @param {Object} options Set of options such as filename and data.
527+
* - `filename` (String): Custom filename (extension is optional).
528+
* - `data` (Blob): A Blob instance.
534529
*
535-
* ##### Params on the `options` object:
536-
* - filename (string): Custom filename (extension is optional).
537-
* - data (Blob): A Blob instance.
530+
* @return {Undefined}
538531
*/
539532

540533
saveAs: function(options) {
541534
options = angular.extend({}, options);
542535
var data = options.data;
543536
var filename = options.filename;
544537

545-
if (!isBlobInstance(data)) {
538+
if (!FileSaverUtils.isBlobInstance(data)) {
546539
FileSaverUtils.handleErrors('Data argument should be a blob instance');
547540
}
548541

@@ -568,7 +561,7 @@ module.exports = function Blob($window) {
568561
'use strict';
569562

570563
module.exports = function SaveAs() {
571-
return require('FileSaver.js').saveAs || null;
564+
return require('FileSaver.js').saveAs || function() {};
572565
};
573566

574567
},{"FileSaver.js":2}],7:[function(require,module,exports){
@@ -579,17 +572,14 @@ module.exports = function FileSaverUtils() {
579572
handleErrors: function(msg) {
580573
throw new Error(msg);
581574
},
582-
isArray: function isArray(obj) {
583-
return Object.prototype.toString.call(obj) === '[object Array]';
584-
},
585-
isObject: function(obj) {
586-
return obj !== null && typeof obj === 'object';
587-
},
588575
isString: function(obj) {
589576
return typeof obj === 'string' || obj instanceof String;
590577
},
591-
isUndefined: function isUndefined(obj) {
578+
isUndefined: function(obj) {
592579
return typeof obj === 'undefined';
580+
},
581+
isBlobInstance: function(obj) {
582+
return obj instanceof Blob;
593583
}
594584
};
595585
};

dist/angular-file-saver.bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-file-saver.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ angular.module('ngFileSaver', [])
2121
'use strict';
2222

2323
module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
24-
if (SaveAs === null) {
25-
return {
26-
saveAs: null
27-
};
28-
}
29-
30-
function isBlobInstance(obj) {
31-
return obj instanceof Blob;
32-
}
3324

3425
function save(blob, filename) {
3526
try {
@@ -42,22 +33,24 @@ module.exports = function FileSaver(Blob, SaveAs, FileSaverUtils) {
4233
return {
4334

4435
/**
45-
* saveAs - Immediately starts saving a file, returns undefined.
36+
* saveAs
37+
* Immediately starts saving a file, returns undefined.
4638
*
47-
* @param {object} options Set of options such as filename and data.
48-
* @return {undefined}
39+
* @name saveAs
40+
* @function
41+
* @param {Object} options Set of options such as filename and data.
42+
* - `filename` (String): Custom filename (extension is optional).
43+
* - `data` (Blob): A Blob instance.
4944
*
50-
* ##### Params on the `options` object:
51-
* - filename (string): Custom filename (extension is optional).
52-
* - data (Blob): A Blob instance.
45+
* @return {Undefined}
5346
*/
5447

5548
saveAs: function(options) {
5649
options = angular.extend({}, options);
5750
var data = options.data;
5851
var filename = options.filename;
5952

60-
if (!isBlobInstance(data)) {
53+
if (!FileSaverUtils.isBlobInstance(data)) {
6154
FileSaverUtils.handleErrors('Data argument should be a blob instance');
6255
}
6356

@@ -104,17 +97,14 @@ module.exports = function FileSaverUtils() {
10497
handleErrors: function(msg) {
10598
throw new Error(msg);
10699
},
107-
isArray: function isArray(obj) {
108-
return Object.prototype.toString.call(obj) === '[object Array]';
109-
},
110-
isObject: function(obj) {
111-
return obj !== null && typeof obj === 'object';
112-
},
113100
isString: function(obj) {
114101
return typeof obj === 'string' || obj instanceof String;
115102
},
116-
isUndefined: function isUndefined(obj) {
103+
isUndefined: function(obj) {
117104
return typeof obj === 'undefined';
105+
},
106+
isBlobInstance: function(obj) {
107+
return obj instanceof Blob;
118108
}
119109
};
120110
};

0 commit comments

Comments
 (0)