OLD | NEW |
1 static Blob _create([List blobParts = null, String type, String endings]) { | 1 static Blob _create([List blobParts = null, String type, String endings]) { |
2 // TODO: validate that blobParts is a JS Array and convert if not. | 2 // TODO: validate that blobParts is a JS Array and convert if not. |
3 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed | 3 // TODO: any coercions on the elements of blobParts, e.g. coerce a typed |
4 // array to ArrayBuffer if it is a total view. | 4 // array to ArrayBuffer if it is a total view. |
5 if (type == null && endings == null) { | 5 if (type == null && endings == null) { |
6 return _create_1(blobParts); | 6 return _create_1(blobParts); |
7 } | 7 } |
8 var bag = _create_bag(); | 8 var bag = _create_bag(); |
9 if (type != null) _bag_set(bag, 'type', type); | 9 if (type != null) _bag_set(bag, 'type', type); |
10 if (endings != null) _bag_set(bag, 'endings', endings); | 10 if (endings != null) _bag_set(bag, 'endings', endings); |
11 return _create_2(blobParts, bag); | 11 return _create_2(blobParts, bag); |
12 } | 12 } |
13 | 13 |
14 static _create_1(parts) => JS('Blob', 'new Blob(#)', parts); | 14 static _create_1(parts) => JS('Blob', 'new Blob(#)', parts); |
15 static _create_2(parts, bag) => JS('Blob', 'new Blob(#, #)', parts, bag); | 15 static _create_2(parts, bag) => JS('Blob', 'new Blob(#, #)', parts, bag); |
16 | 16 |
17 static _create_bag() => JS('var', '{}'); | 17 static _create_bag() => JS('var', '{}'); |
18 static _bag_set(bag, key, value) { JS('void', '#[#] = #', bag, key, value); } | 18 static _bag_set(bag, key, value) { JS('void', '#[#] = #', bag, key, value); } |
OLD | NEW |