UrgentcareCLI 0.1.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (318) hide show
  1. checksums.yaml +4 -4
  2. data/lib/UrgentCare/CLI.rb +57 -22
  3. data/lib/UrgentCare/Office.rb +1 -5
  4. data/lib/UrgentCare/Scraper.rb +71 -0
  5. data/lib/UrgentCare/version.rb +2 -2
  6. data/lib/UrgentCare.rb +2 -1
  7. metadata +27 -321
  8. data/.gitignore +0 -11
  9. data/.rspec +0 -3
  10. data/.travis.yml +0 -5
  11. data/CODE_OF_CONDUCT.md +0 -74
  12. data/Gemfile +0 -12
  13. data/Gemfile.lock +0 -84
  14. data/LICENSE.txt +0 -21
  15. data/Notes +0 -41
  16. data/README.md +0 -41
  17. data/Rakefile +0 -8
  18. data/UrgentCare.gemspec +0 -39
  19. data/background.jpg +0 -0
  20. data/data.txt +0 -4
  21. data/lib/Urgentcare/Scraper.rb +0 -78
  22. data/node_modules/.bin/rimraf +0 -1
  23. data/node_modules/.package-lock.json +0 -250
  24. data/node_modules/balanced-match/.github/FUNDING.yml +0 -2
  25. data/node_modules/balanced-match/LICENSE.md +0 -21
  26. data/node_modules/balanced-match/README.md +0 -97
  27. data/node_modules/balanced-match/index.js +0 -62
  28. data/node_modules/balanced-match/package.json +0 -48
  29. data/node_modules/brace-expansion/LICENSE +0 -21
  30. data/node_modules/brace-expansion/README.md +0 -129
  31. data/node_modules/brace-expansion/index.js +0 -201
  32. data/node_modules/brace-expansion/package.json +0 -47
  33. data/node_modules/concat-map/.travis.yml +0 -4
  34. data/node_modules/concat-map/LICENSE +0 -18
  35. data/node_modules/concat-map/README.markdown +0 -62
  36. data/node_modules/concat-map/example/map.js +0 -6
  37. data/node_modules/concat-map/index.js +0 -13
  38. data/node_modules/concat-map/package.json +0 -43
  39. data/node_modules/concat-map/test/map.js +0 -39
  40. data/node_modules/core-util-is/LICENSE +0 -19
  41. data/node_modules/core-util-is/README.md +0 -3
  42. data/node_modules/core-util-is/float.patch +0 -604
  43. data/node_modules/core-util-is/lib/util.js +0 -107
  44. data/node_modules/core-util-is/package.json +0 -32
  45. data/node_modules/core-util-is/test.js +0 -68
  46. data/node_modules/fs.realpath/LICENSE +0 -43
  47. data/node_modules/fs.realpath/README.md +0 -33
  48. data/node_modules/fs.realpath/index.js +0 -66
  49. data/node_modules/fs.realpath/old.js +0 -303
  50. data/node_modules/fs.realpath/package.json +0 -26
  51. data/node_modules/glob/LICENSE +0 -21
  52. data/node_modules/glob/README.md +0 -375
  53. data/node_modules/glob/changelog.md +0 -67
  54. data/node_modules/glob/common.js +0 -234
  55. data/node_modules/glob/glob.js +0 -788
  56. data/node_modules/glob/package.json +0 -51
  57. data/node_modules/glob/sync.js +0 -484
  58. data/node_modules/immediate/LICENSE.txt +0 -20
  59. data/node_modules/immediate/README.md +0 -93
  60. data/node_modules/immediate/dist/immediate.js +0 -75
  61. data/node_modules/immediate/dist/immediate.min.js +0 -1
  62. data/node_modules/immediate/lib/browser.js +0 -69
  63. data/node_modules/immediate/lib/index.js +0 -73
  64. data/node_modules/immediate/package.json +0 -42
  65. data/node_modules/inflight/LICENSE +0 -15
  66. data/node_modules/inflight/README.md +0 -37
  67. data/node_modules/inflight/inflight.js +0 -54
  68. data/node_modules/inflight/package.json +0 -29
  69. data/node_modules/inherits/LICENSE +0 -16
  70. data/node_modules/inherits/README.md +0 -42
  71. data/node_modules/inherits/inherits.js +0 -9
  72. data/node_modules/inherits/inherits_browser.js +0 -27
  73. data/node_modules/inherits/package.json +0 -29
  74. data/node_modules/isarray/.npmignore +0 -1
  75. data/node_modules/isarray/.travis.yml +0 -4
  76. data/node_modules/isarray/Makefile +0 -6
  77. data/node_modules/isarray/README.md +0 -60
  78. data/node_modules/isarray/component.json +0 -19
  79. data/node_modules/isarray/index.js +0 -5
  80. data/node_modules/isarray/package.json +0 -45
  81. data/node_modules/isarray/test.js +0 -20
  82. data/node_modules/jszip/.codeclimate.yml +0 -16
  83. data/node_modules/jszip/.editorconfig +0 -8
  84. data/node_modules/jszip/.jshintignore +0 -1
  85. data/node_modules/jszip/.jshintrc +0 -21
  86. data/node_modules/jszip/.travis.yml +0 -17
  87. data/node_modules/jszip/CHANGES.md +0 -163
  88. data/node_modules/jszip/LICENSE.markdown +0 -651
  89. data/node_modules/jszip/README.markdown +0 -35
  90. data/node_modules/jszip/dist/jszip.js +0 -30
  91. data/node_modules/jszip/dist/jszip.min.js +0 -13
  92. data/node_modules/jszip/index.d.ts +0 -270
  93. data/node_modules/jszip/lib/base64.js +0 -106
  94. data/node_modules/jszip/lib/compressedObject.js +0 -74
  95. data/node_modules/jszip/lib/compressions.js +0 -14
  96. data/node_modules/jszip/lib/crc32.js +0 -77
  97. data/node_modules/jszip/lib/defaults.js +0 -11
  98. data/node_modules/jszip/lib/external.js +0 -19
  99. data/node_modules/jszip/lib/flate.js +0 -85
  100. data/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -540
  101. data/node_modules/jszip/lib/generate/index.js +0 -57
  102. data/node_modules/jszip/lib/index.js +0 -52
  103. data/node_modules/jszip/lib/license_header.js +0 -11
  104. data/node_modules/jszip/lib/load.js +0 -81
  105. data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
  106. data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
  107. data/node_modules/jszip/lib/nodejsUtils.js +0 -57
  108. data/node_modules/jszip/lib/object.js +0 -389
  109. data/node_modules/jszip/lib/readable-stream-browser.js +0 -9
  110. data/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
  111. data/node_modules/jszip/lib/reader/DataReader.js +0 -116
  112. data/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
  113. data/node_modules/jszip/lib/reader/StringReader.js +0 -38
  114. data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
  115. data/node_modules/jszip/lib/reader/readerFor.js +0 -28
  116. data/node_modules/jszip/lib/signature.js +0 -7
  117. data/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
  118. data/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
  119. data/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
  120. data/node_modules/jszip/lib/stream/DataWorker.js +0 -116
  121. data/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
  122. data/node_modules/jszip/lib/stream/StreamHelper.js +0 -212
  123. data/node_modules/jszip/lib/support.js +0 -38
  124. data/node_modules/jszip/lib/utf8.js +0 -275
  125. data/node_modules/jszip/lib/utils.js +0 -476
  126. data/node_modules/jszip/lib/zipEntries.js +0 -262
  127. data/node_modules/jszip/lib/zipEntry.js +0 -294
  128. data/node_modules/jszip/lib/zipObject.js +0 -133
  129. data/node_modules/jszip/package.json +0 -63
  130. data/node_modules/jszip/vendor/FileSaver.js +0 -247
  131. data/node_modules/lie/README.md +0 -62
  132. data/node_modules/lie/dist/lie.js +0 -350
  133. data/node_modules/lie/dist/lie.min.js +0 -1
  134. data/node_modules/lie/dist/lie.polyfill.js +0 -358
  135. data/node_modules/lie/dist/lie.polyfill.min.js +0 -1
  136. data/node_modules/lie/lib/browser.js +0 -273
  137. data/node_modules/lie/lib/index.js +0 -298
  138. data/node_modules/lie/license.md +0 -7
  139. data/node_modules/lie/lie.d.ts +0 -244
  140. data/node_modules/lie/package.json +0 -69
  141. data/node_modules/lie/polyfill.js +0 -4
  142. data/node_modules/minimatch/LICENSE +0 -15
  143. data/node_modules/minimatch/README.md +0 -209
  144. data/node_modules/minimatch/minimatch.js +0 -923
  145. data/node_modules/minimatch/package.json +0 -30
  146. data/node_modules/once/LICENSE +0 -15
  147. data/node_modules/once/README.md +0 -79
  148. data/node_modules/once/once.js +0 -42
  149. data/node_modules/once/package.json +0 -33
  150. data/node_modules/pako/CHANGELOG.md +0 -164
  151. data/node_modules/pako/LICENSE +0 -21
  152. data/node_modules/pako/README.md +0 -191
  153. data/node_modules/pako/dist/pako.js +0 -6818
  154. data/node_modules/pako/dist/pako.min.js +0 -1
  155. data/node_modules/pako/dist/pako_deflate.js +0 -3997
  156. data/node_modules/pako/dist/pako_deflate.min.js +0 -1
  157. data/node_modules/pako/dist/pako_inflate.js +0 -3300
  158. data/node_modules/pako/dist/pako_inflate.min.js +0 -1
  159. data/node_modules/pako/index.js +0 -14
  160. data/node_modules/pako/lib/deflate.js +0 -400
  161. data/node_modules/pako/lib/inflate.js +0 -423
  162. data/node_modules/pako/lib/utils/common.js +0 -105
  163. data/node_modules/pako/lib/utils/strings.js +0 -187
  164. data/node_modules/pako/lib/zlib/README +0 -59
  165. data/node_modules/pako/lib/zlib/adler32.js +0 -51
  166. data/node_modules/pako/lib/zlib/constants.js +0 -68
  167. data/node_modules/pako/lib/zlib/crc32.js +0 -59
  168. data/node_modules/pako/lib/zlib/deflate.js +0 -1874
  169. data/node_modules/pako/lib/zlib/gzheader.js +0 -58
  170. data/node_modules/pako/lib/zlib/inffast.js +0 -345
  171. data/node_modules/pako/lib/zlib/inflate.js +0 -1556
  172. data/node_modules/pako/lib/zlib/inftrees.js +0 -343
  173. data/node_modules/pako/lib/zlib/messages.js +0 -32
  174. data/node_modules/pako/lib/zlib/trees.js +0 -1222
  175. data/node_modules/pako/lib/zlib/zstream.js +0 -47
  176. data/node_modules/pako/package.json +0 -44
  177. data/node_modules/path-is-absolute/index.js +0 -20
  178. data/node_modules/path-is-absolute/license +0 -21
  179. data/node_modules/path-is-absolute/package.json +0 -43
  180. data/node_modules/path-is-absolute/readme.md +0 -59
  181. data/node_modules/process-nextick-args/index.js +0 -45
  182. data/node_modules/process-nextick-args/license.md +0 -19
  183. data/node_modules/process-nextick-args/package.json +0 -25
  184. data/node_modules/process-nextick-args/readme.md +0 -18
  185. data/node_modules/readable-stream/.travis.yml +0 -34
  186. data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
  187. data/node_modules/readable-stream/GOVERNANCE.md +0 -136
  188. data/node_modules/readable-stream/LICENSE +0 -47
  189. data/node_modules/readable-stream/README.md +0 -58
  190. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  191. data/node_modules/readable-stream/duplex-browser.js +0 -1
  192. data/node_modules/readable-stream/duplex.js +0 -1
  193. data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
  194. data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
  195. data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
  196. data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
  197. data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
  198. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  199. data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
  200. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
  201. data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
  202. data/node_modules/readable-stream/package.json +0 -52
  203. data/node_modules/readable-stream/passthrough.js +0 -1
  204. data/node_modules/readable-stream/readable-browser.js +0 -7
  205. data/node_modules/readable-stream/readable.js +0 -19
  206. data/node_modules/readable-stream/transform.js +0 -1
  207. data/node_modules/readable-stream/writable-browser.js +0 -1
  208. data/node_modules/readable-stream/writable.js +0 -8
  209. data/node_modules/rimraf/LICENSE +0 -15
  210. data/node_modules/rimraf/README.md +0 -101
  211. data/node_modules/rimraf/bin.js +0 -50
  212. data/node_modules/rimraf/package.json +0 -29
  213. data/node_modules/rimraf/rimraf.js +0 -372
  214. data/node_modules/safe-buffer/LICENSE +0 -21
  215. data/node_modules/safe-buffer/README.md +0 -584
  216. data/node_modules/safe-buffer/index.d.ts +0 -187
  217. data/node_modules/safe-buffer/index.js +0 -62
  218. data/node_modules/safe-buffer/package.json +0 -37
  219. data/node_modules/selenium-webdriver/CHANGES.md +0 -1114
  220. data/node_modules/selenium-webdriver/LICENSE +0 -202
  221. data/node_modules/selenium-webdriver/NOTICE +0 -2
  222. data/node_modules/selenium-webdriver/README.md +0 -229
  223. data/node_modules/selenium-webdriver/chrome.js +0 -295
  224. data/node_modules/selenium-webdriver/chromium.js +0 -829
  225. data/node_modules/selenium-webdriver/devtools/CDPConnection.js +0 -35
  226. data/node_modules/selenium-webdriver/edge.js +0 -224
  227. data/node_modules/selenium-webdriver/example/chrome_android.js +0 -45
  228. data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +0 -46
  229. data/node_modules/selenium-webdriver/example/firefox_channels.js +0 -84
  230. data/node_modules/selenium-webdriver/example/google_search.js +0 -50
  231. data/node_modules/selenium-webdriver/example/google_search_test.js +0 -70
  232. data/node_modules/selenium-webdriver/example/headless.js +0 -63
  233. data/node_modules/selenium-webdriver/example/logging.js +0 -64
  234. data/node_modules/selenium-webdriver/firefox.js +0 -789
  235. data/node_modules/selenium-webdriver/http/index.js +0 -324
  236. data/node_modules/selenium-webdriver/http/util.js +0 -172
  237. data/node_modules/selenium-webdriver/ie.js +0 -503
  238. data/node_modules/selenium-webdriver/index.js +0 -825
  239. data/node_modules/selenium-webdriver/io/exec.js +0 -162
  240. data/node_modules/selenium-webdriver/io/index.js +0 -348
  241. data/node_modules/selenium-webdriver/io/zip.js +0 -223
  242. data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +0 -123
  243. data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +0 -101
  244. data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +0 -101
  245. data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +0 -55
  246. data/node_modules/selenium-webdriver/lib/by.js +0 -415
  247. data/node_modules/selenium-webdriver/lib/capabilities.js +0 -553
  248. data/node_modules/selenium-webdriver/lib/command.js +0 -206
  249. data/node_modules/selenium-webdriver/lib/error.js +0 -605
  250. data/node_modules/selenium-webdriver/lib/http.js +0 -704
  251. data/node_modules/selenium-webdriver/lib/input.js +0 -946
  252. data/node_modules/selenium-webdriver/lib/logging.js +0 -661
  253. data/node_modules/selenium-webdriver/lib/promise.js +0 -285
  254. data/node_modules/selenium-webdriver/lib/proxy.js +0 -212
  255. data/node_modules/selenium-webdriver/lib/session.js +0 -77
  256. data/node_modules/selenium-webdriver/lib/symbols.js +0 -37
  257. data/node_modules/selenium-webdriver/lib/until.js +0 -429
  258. data/node_modules/selenium-webdriver/lib/webdriver.js +0 -2919
  259. data/node_modules/selenium-webdriver/net/index.js +0 -107
  260. data/node_modules/selenium-webdriver/net/portprober.js +0 -75
  261. data/node_modules/selenium-webdriver/opera.js +0 -406
  262. data/node_modules/selenium-webdriver/package.json +0 -54
  263. data/node_modules/selenium-webdriver/proxy.js +0 -32
  264. data/node_modules/selenium-webdriver/remote/index.js +0 -624
  265. data/node_modules/selenium-webdriver/safari.js +0 -168
  266. data/node_modules/selenium-webdriver/testing/index.js +0 -504
  267. data/node_modules/set-immediate-shim/index.js +0 -7
  268. data/node_modules/set-immediate-shim/package.json +0 -34
  269. data/node_modules/set-immediate-shim/readme.md +0 -31
  270. data/node_modules/string_decoder/.travis.yml +0 -50
  271. data/node_modules/string_decoder/LICENSE +0 -48
  272. data/node_modules/string_decoder/README.md +0 -47
  273. data/node_modules/string_decoder/lib/string_decoder.js +0 -296
  274. data/node_modules/string_decoder/package.json +0 -31
  275. data/node_modules/tmp/CHANGELOG.md +0 -288
  276. data/node_modules/tmp/LICENSE +0 -21
  277. data/node_modules/tmp/README.md +0 -365
  278. data/node_modules/tmp/lib/tmp.js +0 -780
  279. data/node_modules/tmp/node_modules/.bin/rimraf +0 -1
  280. data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +0 -65
  281. data/node_modules/tmp/node_modules/rimraf/LICENSE +0 -15
  282. data/node_modules/tmp/node_modules/rimraf/README.md +0 -101
  283. data/node_modules/tmp/node_modules/rimraf/bin.js +0 -68
  284. data/node_modules/tmp/node_modules/rimraf/package.json +0 -32
  285. data/node_modules/tmp/node_modules/rimraf/rimraf.js +0 -360
  286. data/node_modules/tmp/package.json +0 -58
  287. data/node_modules/util-deprecate/History.md +0 -16
  288. data/node_modules/util-deprecate/LICENSE +0 -24
  289. data/node_modules/util-deprecate/README.md +0 -53
  290. data/node_modules/util-deprecate/browser.js +0 -67
  291. data/node_modules/util-deprecate/node.js +0 -6
  292. data/node_modules/util-deprecate/package.json +0 -27
  293. data/node_modules/wrappy/LICENSE +0 -15
  294. data/node_modules/wrappy/README.md +0 -36
  295. data/node_modules/wrappy/package.json +0 -29
  296. data/node_modules/wrappy/wrappy.js +0 -33
  297. data/node_modules/ws/LICENSE +0 -21
  298. data/node_modules/ws/README.md +0 -496
  299. data/node_modules/ws/browser.js +0 -8
  300. data/node_modules/ws/index.js +0 -10
  301. data/node_modules/ws/lib/buffer-util.js +0 -129
  302. data/node_modules/ws/lib/constants.js +0 -10
  303. data/node_modules/ws/lib/event-target.js +0 -184
  304. data/node_modules/ws/lib/extension.js +0 -223
  305. data/node_modules/ws/lib/limiter.js +0 -55
  306. data/node_modules/ws/lib/permessage-deflate.js +0 -517
  307. data/node_modules/ws/lib/receiver.js +0 -507
  308. data/node_modules/ws/lib/sender.js +0 -405
  309. data/node_modules/ws/lib/stream.js +0 -165
  310. data/node_modules/ws/lib/validation.js +0 -104
  311. data/node_modules/ws/lib/websocket-server.js +0 -418
  312. data/node_modules/ws/lib/websocket.js +0 -942
  313. data/node_modules/ws/package.json +0 -56
  314. data/package-lock.json +0 -458
  315. data/package.json +0 -5
  316. data/selenium.log +0 -1
  317. data/spec.md +0 -6
  318. data/test.data +0 -2110
@@ -1,476 +0,0 @@
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
- };