UrgentcareCLI 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +60 -25
- data/Notes +1 -1
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/UrgentCare.gemspec +3 -3
- data/background.jpg +0 -0
- data/lib/UrgentCare.rb +3 -0
- data/lib/UrgentCare/CLI.rb +6 -2
- data/lib/UrgentCare/version.rb +1 -1
- data/lib/Urgentcare/Scraper.rb +65 -23
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/.package-lock.json +250 -0
- data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +97 -0
- data/node_modules/balanced-match/index.js +62 -0
- data/node_modules/balanced-match/package.json +48 -0
- data/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +43 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/core-util-is/LICENSE +19 -0
- data/node_modules/core-util-is/README.md +3 -0
- data/node_modules/core-util-is/float.patch +604 -0
- data/node_modules/core-util-is/lib/util.js +107 -0
- data/node_modules/core-util-is/package.json +32 -0
- data/node_modules/core-util-is/test.js +68 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +26 -0
- data/node_modules/glob/LICENSE +21 -0
- data/node_modules/glob/README.md +375 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +234 -0
- data/node_modules/glob/glob.js +788 -0
- data/node_modules/glob/package.json +51 -0
- data/node_modules/glob/sync.js +484 -0
- data/node_modules/immediate/LICENSE.txt +20 -0
- data/node_modules/immediate/README.md +93 -0
- data/node_modules/immediate/dist/immediate.js +75 -0
- data/node_modules/immediate/dist/immediate.min.js +1 -0
- data/node_modules/immediate/lib/browser.js +69 -0
- data/node_modules/immediate/lib/index.js +73 -0
- data/node_modules/immediate/package.json +42 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +29 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +9 -0
- data/node_modules/inherits/inherits_browser.js +27 -0
- data/node_modules/inherits/package.json +29 -0
- data/node_modules/isarray/.npmignore +1 -0
- data/node_modules/isarray/.travis.yml +4 -0
- data/node_modules/isarray/Makefile +6 -0
- data/node_modules/isarray/README.md +60 -0
- data/node_modules/isarray/component.json +19 -0
- data/node_modules/isarray/index.js +5 -0
- data/node_modules/isarray/package.json +45 -0
- data/node_modules/isarray/test.js +20 -0
- data/node_modules/jszip/.codeclimate.yml +16 -0
- data/node_modules/jszip/.editorconfig +8 -0
- data/node_modules/jszip/.jshintignore +1 -0
- data/node_modules/jszip/.jshintrc +21 -0
- data/node_modules/jszip/.travis.yml +17 -0
- data/node_modules/jszip/CHANGES.md +163 -0
- data/node_modules/jszip/LICENSE.markdown +651 -0
- data/node_modules/jszip/README.markdown +35 -0
- data/node_modules/jszip/dist/jszip.js +30 -0
- data/node_modules/jszip/dist/jszip.min.js +13 -0
- data/node_modules/jszip/index.d.ts +270 -0
- data/node_modules/jszip/lib/base64.js +106 -0
- data/node_modules/jszip/lib/compressedObject.js +74 -0
- data/node_modules/jszip/lib/compressions.js +14 -0
- data/node_modules/jszip/lib/crc32.js +77 -0
- data/node_modules/jszip/lib/defaults.js +11 -0
- data/node_modules/jszip/lib/external.js +19 -0
- data/node_modules/jszip/lib/flate.js +85 -0
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
- data/node_modules/jszip/lib/generate/index.js +57 -0
- data/node_modules/jszip/lib/index.js +52 -0
- data/node_modules/jszip/lib/license_header.js +11 -0
- data/node_modules/jszip/lib/load.js +81 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- data/node_modules/jszip/lib/nodejsUtils.js +57 -0
- data/node_modules/jszip/lib/object.js +389 -0
- data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
- data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- data/node_modules/jszip/lib/reader/DataReader.js +116 -0
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- data/node_modules/jszip/lib/reader/StringReader.js +38 -0
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- data/node_modules/jszip/lib/reader/readerFor.js +28 -0
- data/node_modules/jszip/lib/signature.js +7 -0
- data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
- data/node_modules/jszip/lib/support.js +38 -0
- data/node_modules/jszip/lib/utf8.js +275 -0
- data/node_modules/jszip/lib/utils.js +476 -0
- data/node_modules/jszip/lib/zipEntries.js +262 -0
- data/node_modules/jszip/lib/zipEntry.js +294 -0
- data/node_modules/jszip/lib/zipObject.js +133 -0
- data/node_modules/jszip/package.json +63 -0
- data/node_modules/jszip/vendor/FileSaver.js +247 -0
- data/node_modules/lie/README.md +62 -0
- data/node_modules/lie/dist/lie.js +350 -0
- data/node_modules/lie/dist/lie.min.js +1 -0
- data/node_modules/lie/dist/lie.polyfill.js +358 -0
- data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- data/node_modules/lie/lib/browser.js +273 -0
- data/node_modules/lie/lib/index.js +298 -0
- data/node_modules/lie/license.md +7 -0
- data/node_modules/lie/lie.d.ts +244 -0
- data/node_modules/lie/package.json +69 -0
- data/node_modules/lie/polyfill.js +4 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +30 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +33 -0
- data/node_modules/pako/CHANGELOG.md +164 -0
- data/node_modules/pako/LICENSE +21 -0
- data/node_modules/pako/README.md +191 -0
- data/node_modules/pako/dist/pako.js +6818 -0
- data/node_modules/pako/dist/pako.min.js +1 -0
- data/node_modules/pako/dist/pako_deflate.js +3997 -0
- data/node_modules/pako/dist/pako_deflate.min.js +1 -0
- data/node_modules/pako/dist/pako_inflate.js +3300 -0
- data/node_modules/pako/dist/pako_inflate.min.js +1 -0
- data/node_modules/pako/index.js +14 -0
- data/node_modules/pako/lib/deflate.js +400 -0
- data/node_modules/pako/lib/inflate.js +423 -0
- data/node_modules/pako/lib/utils/common.js +105 -0
- data/node_modules/pako/lib/utils/strings.js +187 -0
- data/node_modules/pako/lib/zlib/README +59 -0
- data/node_modules/pako/lib/zlib/adler32.js +51 -0
- data/node_modules/pako/lib/zlib/constants.js +68 -0
- data/node_modules/pako/lib/zlib/crc32.js +59 -0
- data/node_modules/pako/lib/zlib/deflate.js +1874 -0
- data/node_modules/pako/lib/zlib/gzheader.js +58 -0
- data/node_modules/pako/lib/zlib/inffast.js +345 -0
- data/node_modules/pako/lib/zlib/inflate.js +1556 -0
- data/node_modules/pako/lib/zlib/inftrees.js +343 -0
- data/node_modules/pako/lib/zlib/messages.js +32 -0
- data/node_modules/pako/lib/zlib/trees.js +1222 -0
- data/node_modules/pako/lib/zlib/zstream.js +47 -0
- data/node_modules/pako/package.json +44 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +43 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/process-nextick-args/index.js +45 -0
- data/node_modules/process-nextick-args/license.md +19 -0
- data/node_modules/process-nextick-args/package.json +25 -0
- data/node_modules/process-nextick-args/readme.md +18 -0
- data/node_modules/readable-stream/.travis.yml +34 -0
- data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- data/node_modules/readable-stream/GOVERNANCE.md +136 -0
- data/node_modules/readable-stream/LICENSE +47 -0
- data/node_modules/readable-stream/README.md +58 -0
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- data/node_modules/readable-stream/duplex-browser.js +1 -0
- data/node_modules/readable-stream/duplex.js +1 -0
- data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- data/node_modules/readable-stream/package.json +52 -0
- data/node_modules/readable-stream/passthrough.js +1 -0
- data/node_modules/readable-stream/readable-browser.js +7 -0
- data/node_modules/readable-stream/readable.js +19 -0
- data/node_modules/readable-stream/transform.js +1 -0
- data/node_modules/readable-stream/writable-browser.js +1 -0
- data/node_modules/readable-stream/writable.js +8 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +29 -0
- data/node_modules/rimraf/rimraf.js +372 -0
- data/node_modules/safe-buffer/LICENSE +21 -0
- data/node_modules/safe-buffer/README.md +584 -0
- data/node_modules/safe-buffer/index.d.ts +187 -0
- data/node_modules/safe-buffer/index.js +62 -0
- data/node_modules/safe-buffer/package.json +37 -0
- data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
- data/node_modules/selenium-webdriver/LICENSE +202 -0
- data/node_modules/selenium-webdriver/NOTICE +2 -0
- data/node_modules/selenium-webdriver/README.md +229 -0
- data/node_modules/selenium-webdriver/chrome.js +295 -0
- data/node_modules/selenium-webdriver/chromium.js +829 -0
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
- data/node_modules/selenium-webdriver/edge.js +224 -0
- data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
- data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
- data/node_modules/selenium-webdriver/example/google_search.js +50 -0
- data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
- data/node_modules/selenium-webdriver/example/headless.js +63 -0
- data/node_modules/selenium-webdriver/example/logging.js +64 -0
- data/node_modules/selenium-webdriver/firefox.js +789 -0
- data/node_modules/selenium-webdriver/http/index.js +324 -0
- data/node_modules/selenium-webdriver/http/util.js +172 -0
- data/node_modules/selenium-webdriver/ie.js +503 -0
- data/node_modules/selenium-webdriver/index.js +825 -0
- data/node_modules/selenium-webdriver/io/exec.js +162 -0
- data/node_modules/selenium-webdriver/io/index.js +348 -0
- data/node_modules/selenium-webdriver/io/zip.js +223 -0
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
- data/node_modules/selenium-webdriver/lib/by.js +415 -0
- data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
- data/node_modules/selenium-webdriver/lib/command.js +206 -0
- data/node_modules/selenium-webdriver/lib/error.js +605 -0
- data/node_modules/selenium-webdriver/lib/http.js +704 -0
- data/node_modules/selenium-webdriver/lib/input.js +946 -0
- data/node_modules/selenium-webdriver/lib/logging.js +661 -0
- data/node_modules/selenium-webdriver/lib/promise.js +285 -0
- data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
- data/node_modules/selenium-webdriver/lib/session.js +77 -0
- data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
- data/node_modules/selenium-webdriver/lib/until.js +429 -0
- data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
- data/node_modules/selenium-webdriver/net/index.js +107 -0
- data/node_modules/selenium-webdriver/net/portprober.js +75 -0
- data/node_modules/selenium-webdriver/opera.js +406 -0
- data/node_modules/selenium-webdriver/package.json +54 -0
- data/node_modules/selenium-webdriver/proxy.js +32 -0
- data/node_modules/selenium-webdriver/remote/index.js +624 -0
- data/node_modules/selenium-webdriver/safari.js +168 -0
- data/node_modules/selenium-webdriver/testing/index.js +504 -0
- data/node_modules/set-immediate-shim/index.js +7 -0
- data/node_modules/set-immediate-shim/package.json +34 -0
- data/node_modules/set-immediate-shim/readme.md +31 -0
- data/node_modules/string_decoder/.travis.yml +50 -0
- data/node_modules/string_decoder/LICENSE +48 -0
- data/node_modules/string_decoder/README.md +47 -0
- data/node_modules/string_decoder/lib/string_decoder.js +296 -0
- data/node_modules/string_decoder/package.json +31 -0
- data/node_modules/tmp/CHANGELOG.md +288 -0
- data/node_modules/tmp/LICENSE +21 -0
- data/node_modules/tmp/README.md +365 -0
- data/node_modules/tmp/lib/tmp.js +780 -0
- data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
- data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
- data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
- data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
- data/node_modules/tmp/package.json +58 -0
- data/node_modules/util-deprecate/History.md +16 -0
- data/node_modules/util-deprecate/LICENSE +24 -0
- data/node_modules/util-deprecate/README.md +53 -0
- data/node_modules/util-deprecate/browser.js +67 -0
- data/node_modules/util-deprecate/node.js +6 -0
- data/node_modules/util-deprecate/package.json +27 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +29 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +496 -0
- data/node_modules/ws/browser.js +8 -0
- data/node_modules/ws/index.js +10 -0
- data/node_modules/ws/lib/buffer-util.js +129 -0
- data/node_modules/ws/lib/constants.js +10 -0
- data/node_modules/ws/lib/event-target.js +184 -0
- data/node_modules/ws/lib/extension.js +223 -0
- data/node_modules/ws/lib/limiter.js +55 -0
- data/node_modules/ws/lib/permessage-deflate.js +517 -0
- data/node_modules/ws/lib/receiver.js +507 -0
- data/node_modules/ws/lib/sender.js +405 -0
- data/node_modules/ws/lib/stream.js +165 -0
- data/node_modules/ws/lib/validation.js +104 -0
- data/node_modules/ws/lib/websocket-server.js +418 -0
- data/node_modules/ws/lib/websocket.js +942 -0
- data/node_modules/ws/package.json +56 -0
- data/package-lock.json +458 -0
- data/package.json +5 -0
- data/selenium.log +1 -0
- metadata +314 -19
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* This file is used by module bundlers (browserify/webpack/etc) when
|
3
|
+
* including a stream implementation. We use "readable-stream" to get a
|
4
|
+
* consistent behavior between nodejs versions but bundlers often have a shim
|
5
|
+
* for "stream". Using this shim greatly improve the compatibility and greatly
|
6
|
+
* reduce the final size of the bundle (only one stream implementation, not
|
7
|
+
* two).
|
8
|
+
*/
|
9
|
+
module.exports = require("stream");
|
@@ -0,0 +1,57 @@
|
|
1
|
+
'use strict';
|
2
|
+
var DataReader = require('./DataReader');
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
function ArrayReader(data) {
|
6
|
+
DataReader.call(this, data);
|
7
|
+
for(var i = 0; i < this.data.length; i++) {
|
8
|
+
data[i] = data[i] & 0xFF;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
utils.inherits(ArrayReader, DataReader);
|
12
|
+
/**
|
13
|
+
* @see DataReader.byteAt
|
14
|
+
*/
|
15
|
+
ArrayReader.prototype.byteAt = function(i) {
|
16
|
+
return this.data[this.zero + i];
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* @see DataReader.lastIndexOfSignature
|
20
|
+
*/
|
21
|
+
ArrayReader.prototype.lastIndexOfSignature = function(sig) {
|
22
|
+
var sig0 = sig.charCodeAt(0),
|
23
|
+
sig1 = sig.charCodeAt(1),
|
24
|
+
sig2 = sig.charCodeAt(2),
|
25
|
+
sig3 = sig.charCodeAt(3);
|
26
|
+
for (var i = this.length - 4; i >= 0; --i) {
|
27
|
+
if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
|
28
|
+
return i - this.zero;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
return -1;
|
33
|
+
};
|
34
|
+
/**
|
35
|
+
* @see DataReader.readAndCheckSignature
|
36
|
+
*/
|
37
|
+
ArrayReader.prototype.readAndCheckSignature = function (sig) {
|
38
|
+
var sig0 = sig.charCodeAt(0),
|
39
|
+
sig1 = sig.charCodeAt(1),
|
40
|
+
sig2 = sig.charCodeAt(2),
|
41
|
+
sig3 = sig.charCodeAt(3),
|
42
|
+
data = this.readData(4);
|
43
|
+
return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];
|
44
|
+
};
|
45
|
+
/**
|
46
|
+
* @see DataReader.readData
|
47
|
+
*/
|
48
|
+
ArrayReader.prototype.readData = function(size) {
|
49
|
+
this.checkOffset(size);
|
50
|
+
if(size === 0) {
|
51
|
+
return [];
|
52
|
+
}
|
53
|
+
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
54
|
+
this.index += size;
|
55
|
+
return result;
|
56
|
+
};
|
57
|
+
module.exports = ArrayReader;
|
@@ -0,0 +1,116 @@
|
|
1
|
+
'use strict';
|
2
|
+
var utils = require('../utils');
|
3
|
+
|
4
|
+
function DataReader(data) {
|
5
|
+
this.data = data; // type : see implementation
|
6
|
+
this.length = data.length;
|
7
|
+
this.index = 0;
|
8
|
+
this.zero = 0;
|
9
|
+
}
|
10
|
+
DataReader.prototype = {
|
11
|
+
/**
|
12
|
+
* Check that the offset will not go too far.
|
13
|
+
* @param {string} offset the additional offset to check.
|
14
|
+
* @throws {Error} an Error if the offset is out of bounds.
|
15
|
+
*/
|
16
|
+
checkOffset: function(offset) {
|
17
|
+
this.checkIndex(this.index + offset);
|
18
|
+
},
|
19
|
+
/**
|
20
|
+
* Check that the specified index will not be too far.
|
21
|
+
* @param {string} newIndex the index to check.
|
22
|
+
* @throws {Error} an Error if the index is out of bounds.
|
23
|
+
*/
|
24
|
+
checkIndex: function(newIndex) {
|
25
|
+
if (this.length < this.zero + newIndex || newIndex < 0) {
|
26
|
+
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?");
|
27
|
+
}
|
28
|
+
},
|
29
|
+
/**
|
30
|
+
* Change the index.
|
31
|
+
* @param {number} newIndex The new index.
|
32
|
+
* @throws {Error} if the new index is out of the data.
|
33
|
+
*/
|
34
|
+
setIndex: function(newIndex) {
|
35
|
+
this.checkIndex(newIndex);
|
36
|
+
this.index = newIndex;
|
37
|
+
},
|
38
|
+
/**
|
39
|
+
* Skip the next n bytes.
|
40
|
+
* @param {number} n the number of bytes to skip.
|
41
|
+
* @throws {Error} if the new index is out of the data.
|
42
|
+
*/
|
43
|
+
skip: function(n) {
|
44
|
+
this.setIndex(this.index + n);
|
45
|
+
},
|
46
|
+
/**
|
47
|
+
* Get the byte at the specified index.
|
48
|
+
* @param {number} i the index to use.
|
49
|
+
* @return {number} a byte.
|
50
|
+
*/
|
51
|
+
byteAt: function(i) {
|
52
|
+
// see implementations
|
53
|
+
},
|
54
|
+
/**
|
55
|
+
* Get the next number with a given byte size.
|
56
|
+
* @param {number} size the number of bytes to read.
|
57
|
+
* @return {number} the corresponding number.
|
58
|
+
*/
|
59
|
+
readInt: function(size) {
|
60
|
+
var result = 0,
|
61
|
+
i;
|
62
|
+
this.checkOffset(size);
|
63
|
+
for (i = this.index + size - 1; i >= this.index; i--) {
|
64
|
+
result = (result << 8) + this.byteAt(i);
|
65
|
+
}
|
66
|
+
this.index += size;
|
67
|
+
return result;
|
68
|
+
},
|
69
|
+
/**
|
70
|
+
* Get the next string with a given byte size.
|
71
|
+
* @param {number} size the number of bytes to read.
|
72
|
+
* @return {string} the corresponding string.
|
73
|
+
*/
|
74
|
+
readString: function(size) {
|
75
|
+
return utils.transformTo("string", this.readData(size));
|
76
|
+
},
|
77
|
+
/**
|
78
|
+
* Get raw data without conversion, <size> bytes.
|
79
|
+
* @param {number} size the number of bytes to read.
|
80
|
+
* @return {Object} the raw data, implementation specific.
|
81
|
+
*/
|
82
|
+
readData: function(size) {
|
83
|
+
// see implementations
|
84
|
+
},
|
85
|
+
/**
|
86
|
+
* Find the last occurrence of a zip signature (4 bytes).
|
87
|
+
* @param {string} sig the signature to find.
|
88
|
+
* @return {number} the index of the last occurrence, -1 if not found.
|
89
|
+
*/
|
90
|
+
lastIndexOfSignature: function(sig) {
|
91
|
+
// see implementations
|
92
|
+
},
|
93
|
+
/**
|
94
|
+
* Read the signature (4 bytes) at the current position and compare it with sig.
|
95
|
+
* @param {string} sig the expected signature
|
96
|
+
* @return {boolean} true if the signature matches, false otherwise.
|
97
|
+
*/
|
98
|
+
readAndCheckSignature: function(sig) {
|
99
|
+
// see implementations
|
100
|
+
},
|
101
|
+
/**
|
102
|
+
* Get the next date.
|
103
|
+
* @return {Date} the date.
|
104
|
+
*/
|
105
|
+
readDate: function() {
|
106
|
+
var dostime = this.readInt(4);
|
107
|
+
return new Date(Date.UTC(
|
108
|
+
((dostime >> 25) & 0x7f) + 1980, // year
|
109
|
+
((dostime >> 21) & 0x0f) - 1, // month
|
110
|
+
(dostime >> 16) & 0x1f, // day
|
111
|
+
(dostime >> 11) & 0x1f, // hour
|
112
|
+
(dostime >> 5) & 0x3f, // minute
|
113
|
+
(dostime & 0x1f) << 1)); // second
|
114
|
+
}
|
115
|
+
};
|
116
|
+
module.exports = DataReader;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
'use strict';
|
2
|
+
var Uint8ArrayReader = require('./Uint8ArrayReader');
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
function NodeBufferReader(data) {
|
6
|
+
Uint8ArrayReader.call(this, data);
|
7
|
+
}
|
8
|
+
utils.inherits(NodeBufferReader, Uint8ArrayReader);
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @see DataReader.readData
|
12
|
+
*/
|
13
|
+
NodeBufferReader.prototype.readData = function(size) {
|
14
|
+
this.checkOffset(size);
|
15
|
+
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
16
|
+
this.index += size;
|
17
|
+
return result;
|
18
|
+
};
|
19
|
+
module.exports = NodeBufferReader;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
'use strict';
|
2
|
+
var DataReader = require('./DataReader');
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
function StringReader(data) {
|
6
|
+
DataReader.call(this, data);
|
7
|
+
}
|
8
|
+
utils.inherits(StringReader, DataReader);
|
9
|
+
/**
|
10
|
+
* @see DataReader.byteAt
|
11
|
+
*/
|
12
|
+
StringReader.prototype.byteAt = function(i) {
|
13
|
+
return this.data.charCodeAt(this.zero + i);
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* @see DataReader.lastIndexOfSignature
|
17
|
+
*/
|
18
|
+
StringReader.prototype.lastIndexOfSignature = function(sig) {
|
19
|
+
return this.data.lastIndexOf(sig) - this.zero;
|
20
|
+
};
|
21
|
+
/**
|
22
|
+
* @see DataReader.readAndCheckSignature
|
23
|
+
*/
|
24
|
+
StringReader.prototype.readAndCheckSignature = function (sig) {
|
25
|
+
var data = this.readData(4);
|
26
|
+
return sig === data;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* @see DataReader.readData
|
30
|
+
*/
|
31
|
+
StringReader.prototype.readData = function(size) {
|
32
|
+
this.checkOffset(size);
|
33
|
+
// this will work because the constructor applied the "& 0xff" mask.
|
34
|
+
var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
|
35
|
+
this.index += size;
|
36
|
+
return result;
|
37
|
+
};
|
38
|
+
module.exports = StringReader;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
'use strict';
|
2
|
+
var ArrayReader = require('./ArrayReader');
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
function Uint8ArrayReader(data) {
|
6
|
+
ArrayReader.call(this, data);
|
7
|
+
}
|
8
|
+
utils.inherits(Uint8ArrayReader, ArrayReader);
|
9
|
+
/**
|
10
|
+
* @see DataReader.readData
|
11
|
+
*/
|
12
|
+
Uint8ArrayReader.prototype.readData = function(size) {
|
13
|
+
this.checkOffset(size);
|
14
|
+
if(size === 0) {
|
15
|
+
// in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
|
16
|
+
return new Uint8Array(0);
|
17
|
+
}
|
18
|
+
var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
|
19
|
+
this.index += size;
|
20
|
+
return result;
|
21
|
+
};
|
22
|
+
module.exports = Uint8ArrayReader;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var support = require('../support');
|
5
|
+
var ArrayReader = require('./ArrayReader');
|
6
|
+
var StringReader = require('./StringReader');
|
7
|
+
var NodeBufferReader = require('./NodeBufferReader');
|
8
|
+
var Uint8ArrayReader = require('./Uint8ArrayReader');
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Create a reader adapted to the data.
|
12
|
+
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.
|
13
|
+
* @return {DataReader} the data reader.
|
14
|
+
*/
|
15
|
+
module.exports = function (data) {
|
16
|
+
var type = utils.getTypeOf(data);
|
17
|
+
utils.checkSupport(type);
|
18
|
+
if (type === "string" && !support.uint8array) {
|
19
|
+
return new StringReader(data);
|
20
|
+
}
|
21
|
+
if (type === "nodebuffer") {
|
22
|
+
return new NodeBufferReader(data);
|
23
|
+
}
|
24
|
+
if (support.uint8array) {
|
25
|
+
return new Uint8ArrayReader(utils.transformTo("uint8array", data));
|
26
|
+
}
|
27
|
+
return new ArrayReader(utils.transformTo("array", data));
|
28
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
'use strict';
|
2
|
+
exports.LOCAL_FILE_HEADER = "PK\x03\x04";
|
3
|
+
exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
|
4
|
+
exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
|
5
|
+
exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
|
6
|
+
exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
|
7
|
+
exports.DATA_DESCRIPTOR = "PK\x07\x08";
|
@@ -0,0 +1,26 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var GenericWorker = require('./GenericWorker');
|
4
|
+
var utils = require('../utils');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* A worker which convert chunks to a specified type.
|
8
|
+
* @constructor
|
9
|
+
* @param {String} destType the destination type.
|
10
|
+
*/
|
11
|
+
function ConvertWorker(destType) {
|
12
|
+
GenericWorker.call(this, "ConvertWorker to " + destType);
|
13
|
+
this.destType = destType;
|
14
|
+
}
|
15
|
+
utils.inherits(ConvertWorker, GenericWorker);
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @see GenericWorker.processChunk
|
19
|
+
*/
|
20
|
+
ConvertWorker.prototype.processChunk = function (chunk) {
|
21
|
+
this.push({
|
22
|
+
data : utils.transformTo(this.destType, chunk.data),
|
23
|
+
meta : chunk.meta
|
24
|
+
});
|
25
|
+
};
|
26
|
+
module.exports = ConvertWorker;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var GenericWorker = require('./GenericWorker');
|
4
|
+
var crc32 = require('../crc32');
|
5
|
+
var utils = require('../utils');
|
6
|
+
|
7
|
+
/**
|
8
|
+
* A worker which calculate the crc32 of the data flowing through.
|
9
|
+
* @constructor
|
10
|
+
*/
|
11
|
+
function Crc32Probe() {
|
12
|
+
GenericWorker.call(this, "Crc32Probe");
|
13
|
+
this.withStreamInfo("crc32", 0);
|
14
|
+
}
|
15
|
+
utils.inherits(Crc32Probe, GenericWorker);
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @see GenericWorker.processChunk
|
19
|
+
*/
|
20
|
+
Crc32Probe.prototype.processChunk = function (chunk) {
|
21
|
+
this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
|
22
|
+
this.push(chunk);
|
23
|
+
};
|
24
|
+
module.exports = Crc32Probe;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var GenericWorker = require('./GenericWorker');
|
5
|
+
|
6
|
+
/**
|
7
|
+
* A worker which calculate the total length of the data flowing through.
|
8
|
+
* @constructor
|
9
|
+
* @param {String} propName the name used to expose the length
|
10
|
+
*/
|
11
|
+
function DataLengthProbe(propName) {
|
12
|
+
GenericWorker.call(this, "DataLengthProbe for " + propName);
|
13
|
+
this.propName = propName;
|
14
|
+
this.withStreamInfo(propName, 0);
|
15
|
+
}
|
16
|
+
utils.inherits(DataLengthProbe, GenericWorker);
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @see GenericWorker.processChunk
|
20
|
+
*/
|
21
|
+
DataLengthProbe.prototype.processChunk = function (chunk) {
|
22
|
+
if(chunk) {
|
23
|
+
var length = this.streamInfo[this.propName] || 0;
|
24
|
+
this.streamInfo[this.propName] = length + chunk.data.length;
|
25
|
+
}
|
26
|
+
GenericWorker.prototype.processChunk.call(this, chunk);
|
27
|
+
};
|
28
|
+
module.exports = DataLengthProbe;
|
29
|
+
|
@@ -0,0 +1,116 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
var GenericWorker = require('./GenericWorker');
|
5
|
+
|
6
|
+
// the size of the generated chunks
|
7
|
+
// TODO expose this as a public variable
|
8
|
+
var DEFAULT_BLOCK_SIZE = 16 * 1024;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* A worker that reads a content and emits chunks.
|
12
|
+
* @constructor
|
13
|
+
* @param {Promise} dataP the promise of the data to split
|
14
|
+
*/
|
15
|
+
function DataWorker(dataP) {
|
16
|
+
GenericWorker.call(this, "DataWorker");
|
17
|
+
var self = this;
|
18
|
+
this.dataIsReady = false;
|
19
|
+
this.index = 0;
|
20
|
+
this.max = 0;
|
21
|
+
this.data = null;
|
22
|
+
this.type = "";
|
23
|
+
|
24
|
+
this._tickScheduled = false;
|
25
|
+
|
26
|
+
dataP.then(function (data) {
|
27
|
+
self.dataIsReady = true;
|
28
|
+
self.data = data;
|
29
|
+
self.max = data && data.length || 0;
|
30
|
+
self.type = utils.getTypeOf(data);
|
31
|
+
if(!self.isPaused) {
|
32
|
+
self._tickAndRepeat();
|
33
|
+
}
|
34
|
+
}, function (e) {
|
35
|
+
self.error(e);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
utils.inherits(DataWorker, GenericWorker);
|
40
|
+
|
41
|
+
/**
|
42
|
+
* @see GenericWorker.cleanUp
|
43
|
+
*/
|
44
|
+
DataWorker.prototype.cleanUp = function () {
|
45
|
+
GenericWorker.prototype.cleanUp.call(this);
|
46
|
+
this.data = null;
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @see GenericWorker.resume
|
51
|
+
*/
|
52
|
+
DataWorker.prototype.resume = function () {
|
53
|
+
if(!GenericWorker.prototype.resume.call(this)) {
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (!this._tickScheduled && this.dataIsReady) {
|
58
|
+
this._tickScheduled = true;
|
59
|
+
utils.delay(this._tickAndRepeat, [], this);
|
60
|
+
}
|
61
|
+
return true;
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Trigger a tick a schedule an other call to this function.
|
66
|
+
*/
|
67
|
+
DataWorker.prototype._tickAndRepeat = function() {
|
68
|
+
this._tickScheduled = false;
|
69
|
+
if(this.isPaused || this.isFinished) {
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
this._tick();
|
73
|
+
if(!this.isFinished) {
|
74
|
+
utils.delay(this._tickAndRepeat, [], this);
|
75
|
+
this._tickScheduled = true;
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Read and push a chunk.
|
81
|
+
*/
|
82
|
+
DataWorker.prototype._tick = function() {
|
83
|
+
|
84
|
+
if(this.isPaused || this.isFinished) {
|
85
|
+
return false;
|
86
|
+
}
|
87
|
+
|
88
|
+
var size = DEFAULT_BLOCK_SIZE;
|
89
|
+
var data = null, nextIndex = Math.min(this.max, this.index + size);
|
90
|
+
if (this.index >= this.max) {
|
91
|
+
// EOF
|
92
|
+
return this.end();
|
93
|
+
} else {
|
94
|
+
switch(this.type) {
|
95
|
+
case "string":
|
96
|
+
data = this.data.substring(this.index, nextIndex);
|
97
|
+
break;
|
98
|
+
case "uint8array":
|
99
|
+
data = this.data.subarray(this.index, nextIndex);
|
100
|
+
break;
|
101
|
+
case "array":
|
102
|
+
case "nodebuffer":
|
103
|
+
data = this.data.slice(this.index, nextIndex);
|
104
|
+
break;
|
105
|
+
}
|
106
|
+
this.index = nextIndex;
|
107
|
+
return this.push({
|
108
|
+
data : data,
|
109
|
+
meta : {
|
110
|
+
percent : this.max ? this.index / this.max * 100 : 0
|
111
|
+
}
|
112
|
+
});
|
113
|
+
}
|
114
|
+
};
|
115
|
+
|
116
|
+
module.exports = DataWorker;
|