UrgentcareCLI 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +60 -25
  4. data/Notes +1 -1
  5. data/README.md +5 -5
  6. data/Rakefile +2 -0
  7. data/UrgentCare.gemspec +3 -3
  8. data/background.jpg +0 -0
  9. data/lib/UrgentCare.rb +3 -0
  10. data/lib/UrgentCare/CLI.rb +6 -2
  11. data/lib/UrgentCare/version.rb +1 -1
  12. data/lib/Urgentcare/Scraper.rb +65 -23
  13. data/node_modules/.bin/rimraf +1 -0
  14. data/node_modules/.package-lock.json +250 -0
  15. data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  16. data/node_modules/balanced-match/LICENSE.md +21 -0
  17. data/node_modules/balanced-match/README.md +97 -0
  18. data/node_modules/balanced-match/index.js +62 -0
  19. data/node_modules/balanced-match/package.json +48 -0
  20. data/node_modules/brace-expansion/LICENSE +21 -0
  21. data/node_modules/brace-expansion/README.md +129 -0
  22. data/node_modules/brace-expansion/index.js +201 -0
  23. data/node_modules/brace-expansion/package.json +47 -0
  24. data/node_modules/concat-map/.travis.yml +4 -0
  25. data/node_modules/concat-map/LICENSE +18 -0
  26. data/node_modules/concat-map/README.markdown +62 -0
  27. data/node_modules/concat-map/example/map.js +6 -0
  28. data/node_modules/concat-map/index.js +13 -0
  29. data/node_modules/concat-map/package.json +43 -0
  30. data/node_modules/concat-map/test/map.js +39 -0
  31. data/node_modules/core-util-is/LICENSE +19 -0
  32. data/node_modules/core-util-is/README.md +3 -0
  33. data/node_modules/core-util-is/float.patch +604 -0
  34. data/node_modules/core-util-is/lib/util.js +107 -0
  35. data/node_modules/core-util-is/package.json +32 -0
  36. data/node_modules/core-util-is/test.js +68 -0
  37. data/node_modules/fs.realpath/LICENSE +43 -0
  38. data/node_modules/fs.realpath/README.md +33 -0
  39. data/node_modules/fs.realpath/index.js +66 -0
  40. data/node_modules/fs.realpath/old.js +303 -0
  41. data/node_modules/fs.realpath/package.json +26 -0
  42. data/node_modules/glob/LICENSE +21 -0
  43. data/node_modules/glob/README.md +375 -0
  44. data/node_modules/glob/changelog.md +67 -0
  45. data/node_modules/glob/common.js +234 -0
  46. data/node_modules/glob/glob.js +788 -0
  47. data/node_modules/glob/package.json +51 -0
  48. data/node_modules/glob/sync.js +484 -0
  49. data/node_modules/immediate/LICENSE.txt +20 -0
  50. data/node_modules/immediate/README.md +93 -0
  51. data/node_modules/immediate/dist/immediate.js +75 -0
  52. data/node_modules/immediate/dist/immediate.min.js +1 -0
  53. data/node_modules/immediate/lib/browser.js +69 -0
  54. data/node_modules/immediate/lib/index.js +73 -0
  55. data/node_modules/immediate/package.json +42 -0
  56. data/node_modules/inflight/LICENSE +15 -0
  57. data/node_modules/inflight/README.md +37 -0
  58. data/node_modules/inflight/inflight.js +54 -0
  59. data/node_modules/inflight/package.json +29 -0
  60. data/node_modules/inherits/LICENSE +16 -0
  61. data/node_modules/inherits/README.md +42 -0
  62. data/node_modules/inherits/inherits.js +9 -0
  63. data/node_modules/inherits/inherits_browser.js +27 -0
  64. data/node_modules/inherits/package.json +29 -0
  65. data/node_modules/isarray/.npmignore +1 -0
  66. data/node_modules/isarray/.travis.yml +4 -0
  67. data/node_modules/isarray/Makefile +6 -0
  68. data/node_modules/isarray/README.md +60 -0
  69. data/node_modules/isarray/component.json +19 -0
  70. data/node_modules/isarray/index.js +5 -0
  71. data/node_modules/isarray/package.json +45 -0
  72. data/node_modules/isarray/test.js +20 -0
  73. data/node_modules/jszip/.codeclimate.yml +16 -0
  74. data/node_modules/jszip/.editorconfig +8 -0
  75. data/node_modules/jszip/.jshintignore +1 -0
  76. data/node_modules/jszip/.jshintrc +21 -0
  77. data/node_modules/jszip/.travis.yml +17 -0
  78. data/node_modules/jszip/CHANGES.md +163 -0
  79. data/node_modules/jszip/LICENSE.markdown +651 -0
  80. data/node_modules/jszip/README.markdown +35 -0
  81. data/node_modules/jszip/dist/jszip.js +30 -0
  82. data/node_modules/jszip/dist/jszip.min.js +13 -0
  83. data/node_modules/jszip/index.d.ts +270 -0
  84. data/node_modules/jszip/lib/base64.js +106 -0
  85. data/node_modules/jszip/lib/compressedObject.js +74 -0
  86. data/node_modules/jszip/lib/compressions.js +14 -0
  87. data/node_modules/jszip/lib/crc32.js +77 -0
  88. data/node_modules/jszip/lib/defaults.js +11 -0
  89. data/node_modules/jszip/lib/external.js +19 -0
  90. data/node_modules/jszip/lib/flate.js +85 -0
  91. data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
  92. data/node_modules/jszip/lib/generate/index.js +57 -0
  93. data/node_modules/jszip/lib/index.js +52 -0
  94. data/node_modules/jszip/lib/license_header.js +11 -0
  95. data/node_modules/jszip/lib/load.js +81 -0
  96. data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
  97. data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
  98. data/node_modules/jszip/lib/nodejsUtils.js +57 -0
  99. data/node_modules/jszip/lib/object.js +389 -0
  100. data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
  101. data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
  102. data/node_modules/jszip/lib/reader/DataReader.js +116 -0
  103. data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
  104. data/node_modules/jszip/lib/reader/StringReader.js +38 -0
  105. data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
  106. data/node_modules/jszip/lib/reader/readerFor.js +28 -0
  107. data/node_modules/jszip/lib/signature.js +7 -0
  108. data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
  109. data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
  110. data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
  111. data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
  112. data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
  113. data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
  114. data/node_modules/jszip/lib/support.js +38 -0
  115. data/node_modules/jszip/lib/utf8.js +275 -0
  116. data/node_modules/jszip/lib/utils.js +476 -0
  117. data/node_modules/jszip/lib/zipEntries.js +262 -0
  118. data/node_modules/jszip/lib/zipEntry.js +294 -0
  119. data/node_modules/jszip/lib/zipObject.js +133 -0
  120. data/node_modules/jszip/package.json +63 -0
  121. data/node_modules/jszip/vendor/FileSaver.js +247 -0
  122. data/node_modules/lie/README.md +62 -0
  123. data/node_modules/lie/dist/lie.js +350 -0
  124. data/node_modules/lie/dist/lie.min.js +1 -0
  125. data/node_modules/lie/dist/lie.polyfill.js +358 -0
  126. data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
  127. data/node_modules/lie/lib/browser.js +273 -0
  128. data/node_modules/lie/lib/index.js +298 -0
  129. data/node_modules/lie/license.md +7 -0
  130. data/node_modules/lie/lie.d.ts +244 -0
  131. data/node_modules/lie/package.json +69 -0
  132. data/node_modules/lie/polyfill.js +4 -0
  133. data/node_modules/minimatch/LICENSE +15 -0
  134. data/node_modules/minimatch/README.md +209 -0
  135. data/node_modules/minimatch/minimatch.js +923 -0
  136. data/node_modules/minimatch/package.json +30 -0
  137. data/node_modules/once/LICENSE +15 -0
  138. data/node_modules/once/README.md +79 -0
  139. data/node_modules/once/once.js +42 -0
  140. data/node_modules/once/package.json +33 -0
  141. data/node_modules/pako/CHANGELOG.md +164 -0
  142. data/node_modules/pako/LICENSE +21 -0
  143. data/node_modules/pako/README.md +191 -0
  144. data/node_modules/pako/dist/pako.js +6818 -0
  145. data/node_modules/pako/dist/pako.min.js +1 -0
  146. data/node_modules/pako/dist/pako_deflate.js +3997 -0
  147. data/node_modules/pako/dist/pako_deflate.min.js +1 -0
  148. data/node_modules/pako/dist/pako_inflate.js +3300 -0
  149. data/node_modules/pako/dist/pako_inflate.min.js +1 -0
  150. data/node_modules/pako/index.js +14 -0
  151. data/node_modules/pako/lib/deflate.js +400 -0
  152. data/node_modules/pako/lib/inflate.js +423 -0
  153. data/node_modules/pako/lib/utils/common.js +105 -0
  154. data/node_modules/pako/lib/utils/strings.js +187 -0
  155. data/node_modules/pako/lib/zlib/README +59 -0
  156. data/node_modules/pako/lib/zlib/adler32.js +51 -0
  157. data/node_modules/pako/lib/zlib/constants.js +68 -0
  158. data/node_modules/pako/lib/zlib/crc32.js +59 -0
  159. data/node_modules/pako/lib/zlib/deflate.js +1874 -0
  160. data/node_modules/pako/lib/zlib/gzheader.js +58 -0
  161. data/node_modules/pako/lib/zlib/inffast.js +345 -0
  162. data/node_modules/pako/lib/zlib/inflate.js +1556 -0
  163. data/node_modules/pako/lib/zlib/inftrees.js +343 -0
  164. data/node_modules/pako/lib/zlib/messages.js +32 -0
  165. data/node_modules/pako/lib/zlib/trees.js +1222 -0
  166. data/node_modules/pako/lib/zlib/zstream.js +47 -0
  167. data/node_modules/pako/package.json +44 -0
  168. data/node_modules/path-is-absolute/index.js +20 -0
  169. data/node_modules/path-is-absolute/license +21 -0
  170. data/node_modules/path-is-absolute/package.json +43 -0
  171. data/node_modules/path-is-absolute/readme.md +59 -0
  172. data/node_modules/process-nextick-args/index.js +45 -0
  173. data/node_modules/process-nextick-args/license.md +19 -0
  174. data/node_modules/process-nextick-args/package.json +25 -0
  175. data/node_modules/process-nextick-args/readme.md +18 -0
  176. data/node_modules/readable-stream/.travis.yml +34 -0
  177. data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  178. data/node_modules/readable-stream/GOVERNANCE.md +136 -0
  179. data/node_modules/readable-stream/LICENSE +47 -0
  180. data/node_modules/readable-stream/README.md +58 -0
  181. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  182. data/node_modules/readable-stream/duplex-browser.js +1 -0
  183. data/node_modules/readable-stream/duplex.js +1 -0
  184. data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  185. data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  186. data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  187. data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  188. data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
  189. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
  190. data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
  191. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  192. data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  193. data/node_modules/readable-stream/package.json +52 -0
  194. data/node_modules/readable-stream/passthrough.js +1 -0
  195. data/node_modules/readable-stream/readable-browser.js +7 -0
  196. data/node_modules/readable-stream/readable.js +19 -0
  197. data/node_modules/readable-stream/transform.js +1 -0
  198. data/node_modules/readable-stream/writable-browser.js +1 -0
  199. data/node_modules/readable-stream/writable.js +8 -0
  200. data/node_modules/rimraf/LICENSE +15 -0
  201. data/node_modules/rimraf/README.md +101 -0
  202. data/node_modules/rimraf/bin.js +50 -0
  203. data/node_modules/rimraf/package.json +29 -0
  204. data/node_modules/rimraf/rimraf.js +372 -0
  205. data/node_modules/safe-buffer/LICENSE +21 -0
  206. data/node_modules/safe-buffer/README.md +584 -0
  207. data/node_modules/safe-buffer/index.d.ts +187 -0
  208. data/node_modules/safe-buffer/index.js +62 -0
  209. data/node_modules/safe-buffer/package.json +37 -0
  210. data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
  211. data/node_modules/selenium-webdriver/LICENSE +202 -0
  212. data/node_modules/selenium-webdriver/NOTICE +2 -0
  213. data/node_modules/selenium-webdriver/README.md +229 -0
  214. data/node_modules/selenium-webdriver/chrome.js +295 -0
  215. data/node_modules/selenium-webdriver/chromium.js +829 -0
  216. data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
  217. data/node_modules/selenium-webdriver/edge.js +224 -0
  218. data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
  219. data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
  220. data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
  221. data/node_modules/selenium-webdriver/example/google_search.js +50 -0
  222. data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
  223. data/node_modules/selenium-webdriver/example/headless.js +63 -0
  224. data/node_modules/selenium-webdriver/example/logging.js +64 -0
  225. data/node_modules/selenium-webdriver/firefox.js +789 -0
  226. data/node_modules/selenium-webdriver/http/index.js +324 -0
  227. data/node_modules/selenium-webdriver/http/util.js +172 -0
  228. data/node_modules/selenium-webdriver/ie.js +503 -0
  229. data/node_modules/selenium-webdriver/index.js +825 -0
  230. data/node_modules/selenium-webdriver/io/exec.js +162 -0
  231. data/node_modules/selenium-webdriver/io/index.js +348 -0
  232. data/node_modules/selenium-webdriver/io/zip.js +223 -0
  233. data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
  234. data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
  235. data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
  236. data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
  237. data/node_modules/selenium-webdriver/lib/by.js +415 -0
  238. data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
  239. data/node_modules/selenium-webdriver/lib/command.js +206 -0
  240. data/node_modules/selenium-webdriver/lib/error.js +605 -0
  241. data/node_modules/selenium-webdriver/lib/http.js +704 -0
  242. data/node_modules/selenium-webdriver/lib/input.js +946 -0
  243. data/node_modules/selenium-webdriver/lib/logging.js +661 -0
  244. data/node_modules/selenium-webdriver/lib/promise.js +285 -0
  245. data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
  246. data/node_modules/selenium-webdriver/lib/session.js +77 -0
  247. data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
  248. data/node_modules/selenium-webdriver/lib/until.js +429 -0
  249. data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
  250. data/node_modules/selenium-webdriver/net/index.js +107 -0
  251. data/node_modules/selenium-webdriver/net/portprober.js +75 -0
  252. data/node_modules/selenium-webdriver/opera.js +406 -0
  253. data/node_modules/selenium-webdriver/package.json +54 -0
  254. data/node_modules/selenium-webdriver/proxy.js +32 -0
  255. data/node_modules/selenium-webdriver/remote/index.js +624 -0
  256. data/node_modules/selenium-webdriver/safari.js +168 -0
  257. data/node_modules/selenium-webdriver/testing/index.js +504 -0
  258. data/node_modules/set-immediate-shim/index.js +7 -0
  259. data/node_modules/set-immediate-shim/package.json +34 -0
  260. data/node_modules/set-immediate-shim/readme.md +31 -0
  261. data/node_modules/string_decoder/.travis.yml +50 -0
  262. data/node_modules/string_decoder/LICENSE +48 -0
  263. data/node_modules/string_decoder/README.md +47 -0
  264. data/node_modules/string_decoder/lib/string_decoder.js +296 -0
  265. data/node_modules/string_decoder/package.json +31 -0
  266. data/node_modules/tmp/CHANGELOG.md +288 -0
  267. data/node_modules/tmp/LICENSE +21 -0
  268. data/node_modules/tmp/README.md +365 -0
  269. data/node_modules/tmp/lib/tmp.js +780 -0
  270. data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
  271. data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
  272. data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
  273. data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
  274. data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
  275. data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
  276. data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
  277. data/node_modules/tmp/package.json +58 -0
  278. data/node_modules/util-deprecate/History.md +16 -0
  279. data/node_modules/util-deprecate/LICENSE +24 -0
  280. data/node_modules/util-deprecate/README.md +53 -0
  281. data/node_modules/util-deprecate/browser.js +67 -0
  282. data/node_modules/util-deprecate/node.js +6 -0
  283. data/node_modules/util-deprecate/package.json +27 -0
  284. data/node_modules/wrappy/LICENSE +15 -0
  285. data/node_modules/wrappy/README.md +36 -0
  286. data/node_modules/wrappy/package.json +29 -0
  287. data/node_modules/wrappy/wrappy.js +33 -0
  288. data/node_modules/ws/LICENSE +21 -0
  289. data/node_modules/ws/README.md +496 -0
  290. data/node_modules/ws/browser.js +8 -0
  291. data/node_modules/ws/index.js +10 -0
  292. data/node_modules/ws/lib/buffer-util.js +129 -0
  293. data/node_modules/ws/lib/constants.js +10 -0
  294. data/node_modules/ws/lib/event-target.js +184 -0
  295. data/node_modules/ws/lib/extension.js +223 -0
  296. data/node_modules/ws/lib/limiter.js +55 -0
  297. data/node_modules/ws/lib/permessage-deflate.js +517 -0
  298. data/node_modules/ws/lib/receiver.js +507 -0
  299. data/node_modules/ws/lib/sender.js +405 -0
  300. data/node_modules/ws/lib/stream.js +165 -0
  301. data/node_modules/ws/lib/validation.js +104 -0
  302. data/node_modules/ws/lib/websocket-server.js +418 -0
  303. data/node_modules/ws/lib/websocket.js +942 -0
  304. data/node_modules/ws/package.json +56 -0
  305. data/package-lock.json +458 -0
  306. data/package.json +5 -0
  307. data/selenium.log +1 -0
  308. metadata +314 -19
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ exports.base64 = true;
4
+ exports.array = true;
5
+ exports.string = true;
6
+ exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
7
+ exports.nodebuffer = typeof Buffer !== "undefined";
8
+ // contains true if JSZip can read/generate Uint8Array, false otherwise.
9
+ exports.uint8array = typeof Uint8Array !== "undefined";
10
+
11
+ if (typeof ArrayBuffer === "undefined") {
12
+ exports.blob = false;
13
+ }
14
+ else {
15
+ var buffer = new ArrayBuffer(0);
16
+ try {
17
+ exports.blob = new Blob([buffer], {
18
+ type: "application/zip"
19
+ }).size === 0;
20
+ }
21
+ catch (e) {
22
+ try {
23
+ var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
24
+ var builder = new Builder();
25
+ builder.append(buffer);
26
+ exports.blob = builder.getBlob('application/zip').size === 0;
27
+ }
28
+ catch (e) {
29
+ exports.blob = false;
30
+ }
31
+ }
32
+ }
33
+
34
+ try {
35
+ exports.nodestream = !!require('readable-stream').Readable;
36
+ } catch(e) {
37
+ exports.nodestream = false;
38
+ }
@@ -0,0 +1,275 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./utils');
4
+ var support = require('./support');
5
+ var nodejsUtils = require('./nodejsUtils');
6
+ var GenericWorker = require('./stream/GenericWorker');
7
+
8
+ /**
9
+ * The following functions come from pako, from pako/lib/utils/strings
10
+ * released under the MIT license, see pako https://github.com/nodeca/pako/
11
+ */
12
+
13
+ // Table with utf8 lengths (calculated by first byte of sequence)
14
+ // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
15
+ // because max possible codepoint is 0x10ffff
16
+ var _utf8len = new Array(256);
17
+ for (var i=0; i<256; i++) {
18
+ _utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
19
+ }
20
+ _utf8len[254]=_utf8len[254]=1; // Invalid sequence start
21
+
22
+ // convert string to array (typed, when possible)
23
+ var string2buf = function (str) {
24
+ var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
25
+
26
+ // count binary size
27
+ for (m_pos = 0; m_pos < str_len; m_pos++) {
28
+ c = str.charCodeAt(m_pos);
29
+ if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
30
+ c2 = str.charCodeAt(m_pos+1);
31
+ if ((c2 & 0xfc00) === 0xdc00) {
32
+ c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
33
+ m_pos++;
34
+ }
35
+ }
36
+ buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
37
+ }
38
+
39
+ // allocate buffer
40
+ if (support.uint8array) {
41
+ buf = new Uint8Array(buf_len);
42
+ } else {
43
+ buf = new Array(buf_len);
44
+ }
45
+
46
+ // convert
47
+ for (i=0, m_pos = 0; i < buf_len; m_pos++) {
48
+ c = str.charCodeAt(m_pos);
49
+ if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
50
+ c2 = str.charCodeAt(m_pos+1);
51
+ if ((c2 & 0xfc00) === 0xdc00) {
52
+ c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
53
+ m_pos++;
54
+ }
55
+ }
56
+ if (c < 0x80) {
57
+ /* one byte */
58
+ buf[i++] = c;
59
+ } else if (c < 0x800) {
60
+ /* two bytes */
61
+ buf[i++] = 0xC0 | (c >>> 6);
62
+ buf[i++] = 0x80 | (c & 0x3f);
63
+ } else if (c < 0x10000) {
64
+ /* three bytes */
65
+ buf[i++] = 0xE0 | (c >>> 12);
66
+ buf[i++] = 0x80 | (c >>> 6 & 0x3f);
67
+ buf[i++] = 0x80 | (c & 0x3f);
68
+ } else {
69
+ /* four bytes */
70
+ buf[i++] = 0xf0 | (c >>> 18);
71
+ buf[i++] = 0x80 | (c >>> 12 & 0x3f);
72
+ buf[i++] = 0x80 | (c >>> 6 & 0x3f);
73
+ buf[i++] = 0x80 | (c & 0x3f);
74
+ }
75
+ }
76
+
77
+ return buf;
78
+ };
79
+
80
+ // Calculate max possible position in utf8 buffer,
81
+ // that will not break sequence. If that's not possible
82
+ // - (very small limits) return max size as is.
83
+ //
84
+ // buf[] - utf8 bytes array
85
+ // max - length limit (mandatory);
86
+ var utf8border = function(buf, max) {
87
+ var pos;
88
+
89
+ max = max || buf.length;
90
+ if (max > buf.length) { max = buf.length; }
91
+
92
+ // go back from last position, until start of sequence found
93
+ pos = max-1;
94
+ while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
95
+
96
+ // Fuckup - very small and broken sequence,
97
+ // return max, because we should return something anyway.
98
+ if (pos < 0) { return max; }
99
+
100
+ // If we came to start of buffer - that means vuffer is too small,
101
+ // return max too.
102
+ if (pos === 0) { return max; }
103
+
104
+ return (pos + _utf8len[buf[pos]] > max) ? pos : max;
105
+ };
106
+
107
+ // convert array to string
108
+ var buf2string = function (buf) {
109
+ var str, i, out, c, c_len;
110
+ var len = buf.length;
111
+
112
+ // Reserve max possible length (2 words per char)
113
+ // NB: by unknown reasons, Array is significantly faster for
114
+ // String.fromCharCode.apply than Uint16Array.
115
+ var utf16buf = new Array(len*2);
116
+
117
+ for (out=0, i=0; i<len;) {
118
+ c = buf[i++];
119
+ // quick process ascii
120
+ if (c < 0x80) { utf16buf[out++] = c; continue; }
121
+
122
+ c_len = _utf8len[c];
123
+ // skip 5 & 6 byte codes
124
+ if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }
125
+
126
+ // apply mask on first byte
127
+ c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
128
+ // join the rest
129
+ while (c_len > 1 && i < len) {
130
+ c = (c << 6) | (buf[i++] & 0x3f);
131
+ c_len--;
132
+ }
133
+
134
+ // terminated by end of string?
135
+ if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
136
+
137
+ if (c < 0x10000) {
138
+ utf16buf[out++] = c;
139
+ } else {
140
+ c -= 0x10000;
141
+ utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
142
+ utf16buf[out++] = 0xdc00 | (c & 0x3ff);
143
+ }
144
+ }
145
+
146
+ // shrinkBuf(utf16buf, out)
147
+ if (utf16buf.length !== out) {
148
+ if(utf16buf.subarray) {
149
+ utf16buf = utf16buf.subarray(0, out);
150
+ } else {
151
+ utf16buf.length = out;
152
+ }
153
+ }
154
+
155
+ // return String.fromCharCode.apply(null, utf16buf);
156
+ return utils.applyFromCharCode(utf16buf);
157
+ };
158
+
159
+
160
+ // That's all for the pako functions.
161
+
162
+
163
+ /**
164
+ * Transform a javascript string into an array (typed if possible) of bytes,
165
+ * UTF-8 encoded.
166
+ * @param {String} str the string to encode
167
+ * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
168
+ */
169
+ exports.utf8encode = function utf8encode(str) {
170
+ if (support.nodebuffer) {
171
+ return nodejsUtils.newBufferFrom(str, "utf-8");
172
+ }
173
+
174
+ return string2buf(str);
175
+ };
176
+
177
+
178
+ /**
179
+ * Transform a bytes array (or a representation) representing an UTF-8 encoded
180
+ * string into a javascript string.
181
+ * @param {Array|Uint8Array|Buffer} buf the data de decode
182
+ * @return {String} the decoded string.
183
+ */
184
+ exports.utf8decode = function utf8decode(buf) {
185
+ if (support.nodebuffer) {
186
+ return utils.transformTo("nodebuffer", buf).toString("utf-8");
187
+ }
188
+
189
+ buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
190
+
191
+ return buf2string(buf);
192
+ };
193
+
194
+ /**
195
+ * A worker to decode utf8 encoded binary chunks into string chunks.
196
+ * @constructor
197
+ */
198
+ function Utf8DecodeWorker() {
199
+ GenericWorker.call(this, "utf-8 decode");
200
+ // the last bytes if a chunk didn't end with a complete codepoint.
201
+ this.leftOver = null;
202
+ }
203
+ utils.inherits(Utf8DecodeWorker, GenericWorker);
204
+
205
+ /**
206
+ * @see GenericWorker.processChunk
207
+ */
208
+ Utf8DecodeWorker.prototype.processChunk = function (chunk) {
209
+
210
+ var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data);
211
+
212
+ // 1st step, re-use what's left of the previous chunk
213
+ if (this.leftOver && this.leftOver.length) {
214
+ if(support.uint8array) {
215
+ var previousData = data;
216
+ data = new Uint8Array(previousData.length + this.leftOver.length);
217
+ data.set(this.leftOver, 0);
218
+ data.set(previousData, this.leftOver.length);
219
+ } else {
220
+ data = this.leftOver.concat(data);
221
+ }
222
+ this.leftOver = null;
223
+ }
224
+
225
+ var nextBoundary = utf8border(data);
226
+ var usableData = data;
227
+ if (nextBoundary !== data.length) {
228
+ if (support.uint8array) {
229
+ usableData = data.subarray(0, nextBoundary);
230
+ this.leftOver = data.subarray(nextBoundary, data.length);
231
+ } else {
232
+ usableData = data.slice(0, nextBoundary);
233
+ this.leftOver = data.slice(nextBoundary, data.length);
234
+ }
235
+ }
236
+
237
+ this.push({
238
+ data : exports.utf8decode(usableData),
239
+ meta : chunk.meta
240
+ });
241
+ };
242
+
243
+ /**
244
+ * @see GenericWorker.flush
245
+ */
246
+ Utf8DecodeWorker.prototype.flush = function () {
247
+ if(this.leftOver && this.leftOver.length) {
248
+ this.push({
249
+ data : exports.utf8decode(this.leftOver),
250
+ meta : {}
251
+ });
252
+ this.leftOver = null;
253
+ }
254
+ };
255
+ exports.Utf8DecodeWorker = Utf8DecodeWorker;
256
+
257
+ /**
258
+ * A worker to endcode string chunks into utf8 encoded binary chunks.
259
+ * @constructor
260
+ */
261
+ function Utf8EncodeWorker() {
262
+ GenericWorker.call(this, "utf-8 encode");
263
+ }
264
+ utils.inherits(Utf8EncodeWorker, GenericWorker);
265
+
266
+ /**
267
+ * @see GenericWorker.processChunk
268
+ */
269
+ Utf8EncodeWorker.prototype.processChunk = function (chunk) {
270
+ this.push({
271
+ data : exports.utf8encode(chunk.data),
272
+ meta : chunk.meta
273
+ });
274
+ };
275
+ exports.Utf8EncodeWorker = Utf8EncodeWorker;
@@ -0,0 +1,476 @@
1
+ 'use strict';
2
+
3
+ var support = require('./support');
4
+ var base64 = require('./base64');
5
+ var nodejsUtils = require('./nodejsUtils');
6
+ var setImmediate = require('set-immediate-shim');
7
+ var external = require("./external");
8
+
9
+
10
+ /**
11
+ * Convert a string that pass as a "binary string": it should represent a byte
12
+ * array but may have > 255 char codes. Be sure to take only the first byte
13
+ * and returns the byte array.
14
+ * @param {String} str the string to transform.
15
+ * @return {Array|Uint8Array} the string in a binary format.
16
+ */
17
+ function string2binary(str) {
18
+ var result = null;
19
+ if (support.uint8array) {
20
+ result = new Uint8Array(str.length);
21
+ } else {
22
+ result = new Array(str.length);
23
+ }
24
+ return stringToArrayLike(str, result);
25
+ }
26
+
27
+ /**
28
+ * Create a new blob with the given content and the given type.
29
+ * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
30
+ * an Uint8Array because the stock browser of android 4 won't accept it (it
31
+ * will be silently converted to a string, "[object Uint8Array]").
32
+ *
33
+ * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
34
+ * when a large amount of Array is used to create the Blob, the amount of
35
+ * memory consumed is nearly 100 times the original data amount.
36
+ *
37
+ * @param {String} type the mime type of the blob.
38
+ * @return {Blob} the created blob.
39
+ */
40
+ exports.newBlob = function(part, type) {
41
+ exports.checkSupport("blob");
42
+
43
+ try {
44
+ // Blob constructor
45
+ return new Blob([part], {
46
+ type: type
47
+ });
48
+ }
49
+ catch (e) {
50
+
51
+ try {
52
+ // deprecated, browser only, old way
53
+ var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
54
+ var builder = new Builder();
55
+ builder.append(part);
56
+ return builder.getBlob(type);
57
+ }
58
+ catch (e) {
59
+
60
+ // well, fuck ?!
61
+ throw new Error("Bug : can't construct the Blob.");
62
+ }
63
+ }
64
+
65
+
66
+ };
67
+ /**
68
+ * The identity function.
69
+ * @param {Object} input the input.
70
+ * @return {Object} the same input.
71
+ */
72
+ function identity(input) {
73
+ return input;
74
+ }
75
+
76
+ /**
77
+ * Fill in an array with a string.
78
+ * @param {String} str the string to use.
79
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
80
+ * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
81
+ */
82
+ function stringToArrayLike(str, array) {
83
+ for (var i = 0; i < str.length; ++i) {
84
+ array[i] = str.charCodeAt(i) & 0xFF;
85
+ }
86
+ return array;
87
+ }
88
+
89
+ /**
90
+ * An helper for the function arrayLikeToString.
91
+ * This contains static information and functions that
92
+ * can be optimized by the browser JIT compiler.
93
+ */
94
+ var arrayToStringHelper = {
95
+ /**
96
+ * Transform an array of int into a string, chunk by chunk.
97
+ * See the performances notes on arrayLikeToString.
98
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
99
+ * @param {String} type the type of the array.
100
+ * @param {Integer} chunk the chunk size.
101
+ * @return {String} the resulting string.
102
+ * @throws Error if the chunk is too big for the stack.
103
+ */
104
+ stringifyByChunk: function(array, type, chunk) {
105
+ var result = [], k = 0, len = array.length;
106
+ // shortcut
107
+ if (len <= chunk) {
108
+ return String.fromCharCode.apply(null, array);
109
+ }
110
+ while (k < len) {
111
+ if (type === "array" || type === "nodebuffer") {
112
+ result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
113
+ }
114
+ else {
115
+ result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
116
+ }
117
+ k += chunk;
118
+ }
119
+ return result.join("");
120
+ },
121
+ /**
122
+ * Call String.fromCharCode on every item in the array.
123
+ * This is the naive implementation, which generate A LOT of intermediate string.
124
+ * This should be used when everything else fail.
125
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
126
+ * @return {String} the result.
127
+ */
128
+ stringifyByChar: function(array){
129
+ var resultStr = "";
130
+ for(var i = 0; i < array.length; i++) {
131
+ resultStr += String.fromCharCode(array[i]);
132
+ }
133
+ return resultStr;
134
+ },
135
+ applyCanBeUsed : {
136
+ /**
137
+ * true if the browser accepts to use String.fromCharCode on Uint8Array
138
+ */
139
+ uint8array : (function () {
140
+ try {
141
+ return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
142
+ } catch (e) {
143
+ return false;
144
+ }
145
+ })(),
146
+ /**
147
+ * true if the browser accepts to use String.fromCharCode on nodejs Buffer.
148
+ */
149
+ nodebuffer : (function () {
150
+ try {
151
+ return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
152
+ } catch (e) {
153
+ return false;
154
+ }
155
+ })()
156
+ }
157
+ };
158
+
159
+ /**
160
+ * Transform an array-like object to a string.
161
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
162
+ * @return {String} the result.
163
+ */
164
+ function arrayLikeToString(array) {
165
+ // Performances notes :
166
+ // --------------------
167
+ // String.fromCharCode.apply(null, array) is the fastest, see
168
+ // see http://jsperf.com/converting-a-uint8array-to-a-string/2
169
+ // but the stack is limited (and we can get huge arrays !).
170
+ //
171
+ // result += String.fromCharCode(array[i]); generate too many strings !
172
+ //
173
+ // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
174
+ // TODO : we now have workers that split the work. Do we still need that ?
175
+ var chunk = 65536,
176
+ type = exports.getTypeOf(array),
177
+ canUseApply = true;
178
+ if (type === "uint8array") {
179
+ canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
180
+ } else if (type === "nodebuffer") {
181
+ canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
182
+ }
183
+
184
+ if (canUseApply) {
185
+ while (chunk > 1) {
186
+ try {
187
+ return arrayToStringHelper.stringifyByChunk(array, type, chunk);
188
+ } catch (e) {
189
+ chunk = Math.floor(chunk / 2);
190
+ }
191
+ }
192
+ }
193
+
194
+ // no apply or chunk error : slow and painful algorithm
195
+ // default browser on android 4.*
196
+ return arrayToStringHelper.stringifyByChar(array);
197
+ }
198
+
199
+ exports.applyFromCharCode = arrayLikeToString;
200
+
201
+
202
+ /**
203
+ * Copy the data from an array-like to an other array-like.
204
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
205
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
206
+ * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
207
+ */
208
+ function arrayLikeToArrayLike(arrayFrom, arrayTo) {
209
+ for (var i = 0; i < arrayFrom.length; i++) {
210
+ arrayTo[i] = arrayFrom[i];
211
+ }
212
+ return arrayTo;
213
+ }
214
+
215
+ // a matrix containing functions to transform everything into everything.
216
+ var transform = {};
217
+
218
+ // string to ?
219
+ transform["string"] = {
220
+ "string": identity,
221
+ "array": function(input) {
222
+ return stringToArrayLike(input, new Array(input.length));
223
+ },
224
+ "arraybuffer": function(input) {
225
+ return transform["string"]["uint8array"](input).buffer;
226
+ },
227
+ "uint8array": function(input) {
228
+ return stringToArrayLike(input, new Uint8Array(input.length));
229
+ },
230
+ "nodebuffer": function(input) {
231
+ return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
232
+ }
233
+ };
234
+
235
+ // array to ?
236
+ transform["array"] = {
237
+ "string": arrayLikeToString,
238
+ "array": identity,
239
+ "arraybuffer": function(input) {
240
+ return (new Uint8Array(input)).buffer;
241
+ },
242
+ "uint8array": function(input) {
243
+ return new Uint8Array(input);
244
+ },
245
+ "nodebuffer": function(input) {
246
+ return nodejsUtils.newBufferFrom(input);
247
+ }
248
+ };
249
+
250
+ // arraybuffer to ?
251
+ transform["arraybuffer"] = {
252
+ "string": function(input) {
253
+ return arrayLikeToString(new Uint8Array(input));
254
+ },
255
+ "array": function(input) {
256
+ return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
257
+ },
258
+ "arraybuffer": identity,
259
+ "uint8array": function(input) {
260
+ return new Uint8Array(input);
261
+ },
262
+ "nodebuffer": function(input) {
263
+ return nodejsUtils.newBufferFrom(new Uint8Array(input));
264
+ }
265
+ };
266
+
267
+ // uint8array to ?
268
+ transform["uint8array"] = {
269
+ "string": arrayLikeToString,
270
+ "array": function(input) {
271
+ return arrayLikeToArrayLike(input, new Array(input.length));
272
+ },
273
+ "arraybuffer": function(input) {
274
+ return input.buffer;
275
+ },
276
+ "uint8array": identity,
277
+ "nodebuffer": function(input) {
278
+ return nodejsUtils.newBufferFrom(input);
279
+ }
280
+ };
281
+
282
+ // nodebuffer to ?
283
+ transform["nodebuffer"] = {
284
+ "string": arrayLikeToString,
285
+ "array": function(input) {
286
+ return arrayLikeToArrayLike(input, new Array(input.length));
287
+ },
288
+ "arraybuffer": function(input) {
289
+ return transform["nodebuffer"]["uint8array"](input).buffer;
290
+ },
291
+ "uint8array": function(input) {
292
+ return arrayLikeToArrayLike(input, new Uint8Array(input.length));
293
+ },
294
+ "nodebuffer": identity
295
+ };
296
+
297
+ /**
298
+ * Transform an input into any type.
299
+ * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
300
+ * If no output type is specified, the unmodified input will be returned.
301
+ * @param {String} outputType the output type.
302
+ * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
303
+ * @throws {Error} an Error if the browser doesn't support the requested output type.
304
+ */
305
+ exports.transformTo = function(outputType, input) {
306
+ if (!input) {
307
+ // undefined, null, etc
308
+ // an empty string won't harm.
309
+ input = "";
310
+ }
311
+ if (!outputType) {
312
+ return input;
313
+ }
314
+ exports.checkSupport(outputType);
315
+ var inputType = exports.getTypeOf(input);
316
+ var result = transform[inputType][outputType](input);
317
+ return result;
318
+ };
319
+
320
+ /**
321
+ * Return the type of the input.
322
+ * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
323
+ * @param {Object} input the input to identify.
324
+ * @return {String} the (lowercase) type of the input.
325
+ */
326
+ exports.getTypeOf = function(input) {
327
+ if (typeof input === "string") {
328
+ return "string";
329
+ }
330
+ if (Object.prototype.toString.call(input) === "[object Array]") {
331
+ return "array";
332
+ }
333
+ if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
334
+ return "nodebuffer";
335
+ }
336
+ if (support.uint8array && input instanceof Uint8Array) {
337
+ return "uint8array";
338
+ }
339
+ if (support.arraybuffer && input instanceof ArrayBuffer) {
340
+ return "arraybuffer";
341
+ }
342
+ };
343
+
344
+ /**
345
+ * Throw an exception if the type is not supported.
346
+ * @param {String} type the type to check.
347
+ * @throws {Error} an Error if the browser doesn't support the requested type.
348
+ */
349
+ exports.checkSupport = function(type) {
350
+ var supported = support[type.toLowerCase()];
351
+ if (!supported) {
352
+ throw new Error(type + " is not supported by this platform");
353
+ }
354
+ };
355
+
356
+ exports.MAX_VALUE_16BITS = 65535;
357
+ exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
358
+
359
+ /**
360
+ * Prettify a string read as binary.
361
+ * @param {string} str the string to prettify.
362
+ * @return {string} a pretty string.
363
+ */
364
+ exports.pretty = function(str) {
365
+ var res = '',
366
+ code, i;
367
+ for (i = 0; i < (str || "").length; i++) {
368
+ code = str.charCodeAt(i);
369
+ res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
370
+ }
371
+ return res;
372
+ };
373
+
374
+ /**
375
+ * Defer the call of a function.
376
+ * @param {Function} callback the function to call asynchronously.
377
+ * @param {Array} args the arguments to give to the callback.
378
+ */
379
+ exports.delay = function(callback, args, self) {
380
+ setImmediate(function () {
381
+ callback.apply(self || null, args || []);
382
+ });
383
+ };
384
+
385
+ /**
386
+ * Extends a prototype with an other, without calling a constructor with
387
+ * side effects. Inspired by nodejs' `utils.inherits`
388
+ * @param {Function} ctor the constructor to augment
389
+ * @param {Function} superCtor the parent constructor to use
390
+ */
391
+ exports.inherits = function (ctor, superCtor) {
392
+ var Obj = function() {};
393
+ Obj.prototype = superCtor.prototype;
394
+ ctor.prototype = new Obj();
395
+ };
396
+
397
+ /**
398
+ * Merge the objects passed as parameters into a new one.
399
+ * @private
400
+ * @param {...Object} var_args All objects to merge.
401
+ * @return {Object} a new object with the data of the others.
402
+ */
403
+ exports.extend = function() {
404
+ var result = {}, i, attr;
405
+ for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers
406
+ for (attr in arguments[i]) {
407
+ if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
408
+ result[attr] = arguments[i][attr];
409
+ }
410
+ }
411
+ }
412
+ return result;
413
+ };
414
+
415
+ /**
416
+ * Transform arbitrary content into a Promise.
417
+ * @param {String} name a name for the content being processed.
418
+ * @param {Object} inputData the content to process.
419
+ * @param {Boolean} isBinary true if the content is not an unicode string
420
+ * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.
421
+ * @param {Boolean} isBase64 true if the string content is encoded with base64.
422
+ * @return {Promise} a promise in a format usable by JSZip.
423
+ */
424
+ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
425
+
426
+ // if inputData is already a promise, this flatten it.
427
+ var promise = external.Promise.resolve(inputData).then(function(data) {
428
+
429
+
430
+ var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);
431
+
432
+ if (isBlob && typeof FileReader !== "undefined") {
433
+ return new external.Promise(function (resolve, reject) {
434
+ var reader = new FileReader();
435
+
436
+ reader.onload = function(e) {
437
+ resolve(e.target.result);
438
+ };
439
+ reader.onerror = function(e) {
440
+ reject(e.target.error);
441
+ };
442
+ reader.readAsArrayBuffer(data);
443
+ });
444
+ } else {
445
+ return data;
446
+ }
447
+ });
448
+
449
+ return promise.then(function(data) {
450
+ var dataType = exports.getTypeOf(data);
451
+
452
+ if (!dataType) {
453
+ return external.Promise.reject(
454
+ new Error("Can't read the data of '" + name + "'. Is it " +
455
+ "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")
456
+ );
457
+ }
458
+ // special case : it's way easier to work with Uint8Array than with ArrayBuffer
459
+ if (dataType === "arraybuffer") {
460
+ data = exports.transformTo("uint8array", data);
461
+ } else if (dataType === "string") {
462
+ if (isBase64) {
463
+ data = base64.decode(data);
464
+ }
465
+ else if (isBinary) {
466
+ // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask
467
+ if (isOptimizedBinaryString !== true) {
468
+ // this is a string, not in a base64 format.
469
+ // Be sure that this is a correct "binary string"
470
+ data = string2binary(data);
471
+ }
472
+ }
473
+ }
474
+ return data;
475
+ });
476
+ };