Skip to content

Commit be89cb9

Browse files
author
Philipp Alferov
committed
Build assets
1 parent 1afa8a1 commit be89cb9

File tree

4 files changed

+112
-116
lines changed

4 files changed

+112
-116
lines changed

dist/angular-file-saver.js

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,87 +11,85 @@
1111
*
1212
*/
1313

14-
function handleErrors (msg) {
14+
function handleErrors(msg) {
1515
throw new Error(msg);
1616
}
1717

18-
function isArray (obj) {
18+
function isArray(obj) {
1919
return Object.prototype.toString.call(obj) === '[object Array]';
2020
}
2121

22-
function isObject (obj) {
22+
function isObject(obj) {
2323
return obj !== null && typeof obj === 'object';
2424
}
2525

26-
function isString (obj) {
26+
function isString(obj) {
2727
return typeof obj === 'string' || obj instanceof String;
2828
}
2929

30-
function isUndefined (obj) {
31-
return typeof obj == "undefined";
30+
function isUndefined(obj) {
31+
return typeof obj === 'undefined';
3232
}
3333

34-
angular
35-
.module('fileSaver', [])
36-
.factory('SaveAs', ['$window', SaveAs]);
34+
function SaveAs($window) {
35+
var saveAs = $window.saveAs;
36+
var Blob = $window.Blob;
3737

38-
function SaveAs ($window) {
39-
var saveAs = $window.saveAs;
40-
var Blob = $window.Blob;
38+
if (isUndefined(saveAs)) {
39+
handleErrors('saveAs is not supported. Please include saveAs polyfill');
40+
}
4141

42-
if (isUndefined(saveAs)) {
43-
handleErrors('saveAs is not supported. Please include saveAs polyfill');
44-
}
42+
if (isUndefined(Blob)) {
43+
handleErrors('Blob is not supported. Please include blob polyfill');
44+
}
4545

46-
if (isUndefined(Blob)) {
47-
handleErrors('Blob is not supported. Please include blob polyfill');
48-
}
46+
function isBlobInstance(obj) {
47+
return obj instanceof Blob;
48+
}
4949

50-
function isBlobInstance (obj) {
51-
return obj instanceof Blob;
50+
function save(blob, filename) {
51+
try {
52+
saveAs(blob, filename);
53+
} catch(err) {
54+
handleErrors(err.message);
5255
}
56+
}
57+
58+
return {
59+
60+
/**
61+
* download - Immediately starts saving a file, returns undefined.
62+
*
63+
* @param {array|Blob} data Represented as an array or a Blob object
64+
* @param {string} filename
65+
* @param {object} options Set of Blob constructor options.
66+
* Optional parameter, if Blob object is passed as first argument
67+
* @return {undefined}
68+
*/
69+
70+
download: function(data, filename, options) {
71+
options = options || {};
5372

54-
function save(blob, filename) {
55-
try {
56-
saveAs(blob, filename);
57-
} catch(err) {
58-
handleErrors(err.message);
73+
if (!isArray(data) && !isBlobInstance(data)) {
74+
handleErrors('Data argument should be represented as an array or Blob instance');
5975
}
60-
}
6176

62-
return {
63-
64-
/**
65-
* download - Immediately starts saving a file, returns undefined.
66-
*
67-
* @param {array|Blob} data Represented as an array or a Blob object
68-
* @param {string} filename
69-
* @param {object} options Set of Blob constructor options.
70-
* Optional parameter, if Blob object is passed as first argument
71-
* @return {undefined}
72-
*/
73-
74-
download: function (data, filename, options) {
75-
if (!isArray(data) || !isBlobInstance(data)) {
76-
handleErrors('Data argument should be represented as an array or Blob instance');
77-
}
78-
79-
if (!isString(filename)) {
80-
handleErrors('Filename argument should be a string');
81-
}
82-
83-
if (!isObject(options)) {
84-
handleErrors('Options argument should be an object');
85-
}
86-
87-
if (isBlobInstance(data)) {
88-
return save(data, filename);
89-
}
90-
91-
var blob = new Blob(data, options);
92-
return save(blob, filename);
77+
if (!isString(filename)) {
78+
handleErrors('Filename argument should be a string');
9379
}
94-
};
95-
}
80+
81+
if (isBlobInstance(data)) {
82+
return save(data, filename);
83+
}
84+
85+
var blob = new Blob(data, options);
86+
return save(blob, filename);
87+
}
88+
};
89+
}
90+
91+
angular
92+
.module('fileSaver', [])
93+
.factory('SaveAs', ['$window', SaveAs]);
9694

9795
},{}]},{},[1]);

dist/angular-file-saver.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.

docs/dist/examples.js

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28892,87 +28892,85 @@ if (typeof module !== "undefined" && module !== null) {
2889228892
*
2889328893
*/
2889428894

28895-
function handleErrors (msg) {
28895+
function handleErrors(msg) {
2889628896
throw new Error(msg);
2889728897
}
2889828898

28899-
function isArray (obj) {
28899+
function isArray(obj) {
2890028900
return Object.prototype.toString.call(obj) === '[object Array]';
2890128901
}
2890228902

28903-
function isObject (obj) {
28903+
function isObject(obj) {
2890428904
return obj !== null && typeof obj === 'object';
2890528905
}
2890628906

28907-
function isString (obj) {
28907+
function isString(obj) {
2890828908
return typeof obj === 'string' || obj instanceof String;
2890928909
}
2891028910

28911-
function isUndefined (obj) {
28912-
return typeof obj == "undefined";
28911+
function isUndefined(obj) {
28912+
return typeof obj === 'undefined';
2891328913
}
2891428914

28915-
angular
28916-
.module('fileSaver', [])
28917-
.factory('SaveAs', ['$window', SaveAs]);
28915+
function SaveAs($window) {
28916+
var saveAs = $window.saveAs;
28917+
var Blob = $window.Blob;
2891828918

28919-
function SaveAs ($window) {
28920-
var saveAs = $window.saveAs;
28921-
var Blob = $window.Blob;
28919+
if (isUndefined(saveAs)) {
28920+
handleErrors('saveAs is not supported. Please include saveAs polyfill');
28921+
}
2892228922

28923-
if (isUndefined(saveAs)) {
28924-
handleErrors('saveAs is not supported. Please include saveAs polyfill');
28925-
}
28923+
if (isUndefined(Blob)) {
28924+
handleErrors('Blob is not supported. Please include blob polyfill');
28925+
}
2892628926

28927-
if (isUndefined(Blob)) {
28928-
handleErrors('Blob is not supported. Please include blob polyfill');
28929-
}
28927+
function isBlobInstance(obj) {
28928+
return obj instanceof Blob;
28929+
}
2893028930

28931-
function isBlobInstance (obj) {
28932-
return obj instanceof Blob;
28931+
function save(blob, filename) {
28932+
try {
28933+
saveAs(blob, filename);
28934+
} catch(err) {
28935+
handleErrors(err.message);
2893328936
}
28937+
}
2893428938

28935-
function save(blob, filename) {
28936-
try {
28937-
saveAs(blob, filename);
28938-
} catch(err) {
28939-
handleErrors(err.message);
28940-
}
28941-
}
28939+
return {
2894228940

28943-
return {
28941+
/**
28942+
* download - Immediately starts saving a file, returns undefined.
28943+
*
28944+
* @param {array|Blob} data Represented as an array or a Blob object
28945+
* @param {string} filename
28946+
* @param {object} options Set of Blob constructor options.
28947+
* Optional parameter, if Blob object is passed as first argument
28948+
* @return {undefined}
28949+
*/
2894428950

28945-
/**
28946-
* download - Immediately starts saving a file, returns undefined.
28947-
*
28948-
* @param {array|Blob} data Represented as an array or a Blob object
28949-
* @param {string} filename
28950-
* @param {object} options Set of Blob constructor options.
28951-
* Optional parameter, if Blob object is passed as first argument
28952-
* @return {undefined}
28953-
*/
28951+
download: function(data, filename, options) {
28952+
options = options || {};
2895428953

28955-
download: function (data, filename, options) {
28956-
if (!isArray(data) || !isBlobInstance(data)) {
28957-
handleErrors('Data argument should be represented as an array or Blob instance');
28958-
}
28954+
if (!isArray(data) && !isBlobInstance(data)) {
28955+
handleErrors('Data argument should be represented as an array or Blob instance');
28956+
}
2895928957

28960-
if (!isString(filename)) {
28961-
handleErrors('Filename argument should be a string');
28962-
}
28958+
if (!isString(filename)) {
28959+
handleErrors('Filename argument should be a string');
28960+
}
2896328961

28964-
if (!isObject(options)) {
28965-
handleErrors('Options argument should be an object');
28966-
}
28962+
if (isBlobInstance(data)) {
28963+
return save(data, filename);
28964+
}
2896728965

28968-
if (isBlobInstance(data)) {
28969-
return save(data, filename);
28970-
}
28966+
var blob = new Blob(data, options);
28967+
return save(blob, filename);
28968+
}
28969+
};
28970+
}
2897128971

28972-
var blob = new Blob(data, options);
28973-
return save(blob, filename);
28974-
}
28975-
};
28976-
}
28972+
angular
28973+
.module('fileSaver', [])
28974+
.factory('SaveAs', ['$window', SaveAs]);
2897728975

2897828976
},{}]},{},[1]);

docs/dist/examples.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.

0 commit comments

Comments
 (0)