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,285 @@
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
3
|
+
// distributed with this work for additional information
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
6
|
+
// "License"); you may not use this file except in compliance
|
7
|
+
// with the License. You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
12
|
+
// software distributed under the License is distributed on an
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
// KIND, either express or implied. See the License for the
|
15
|
+
// specific language governing permissions and limitations
|
16
|
+
// under the License.
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @fileoverview Defines a handful of utility functions to simplify working
|
20
|
+
* with promises.
|
21
|
+
*/
|
22
|
+
|
23
|
+
'use strict'
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Determines whether a {@code value} should be treated as a promise.
|
27
|
+
* Any object whose "then" property is a function will be considered a promise.
|
28
|
+
*
|
29
|
+
* @param {?} value The value to test.
|
30
|
+
* @return {boolean} Whether the value is a promise.
|
31
|
+
*/
|
32
|
+
function isPromise(value) {
|
33
|
+
return Object.prototype.toString.call(value) === '[object Promise]'
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Creates a promise that will be resolved at a set time in the future.
|
38
|
+
* @param {number} ms The amount of time, in milliseconds, to wait before
|
39
|
+
* resolving the promise.
|
40
|
+
* @return {!Promise<void>} The promise.
|
41
|
+
*/
|
42
|
+
function delayed(ms) {
|
43
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Wraps a function that expects a node-style callback as its final
|
48
|
+
* argument. This callback expects two arguments: an error value (which will be
|
49
|
+
* null if the call succeeded), and the success value as the second argument.
|
50
|
+
* The callback will the resolve or reject the returned promise, based on its
|
51
|
+
* arguments.
|
52
|
+
* @param {!Function} fn The function to wrap.
|
53
|
+
* @param {...?} args The arguments to apply to the function, excluding the
|
54
|
+
* final callback.
|
55
|
+
* @return {!Thenable} A promise that will be resolved with the
|
56
|
+
* result of the provided function's callback.
|
57
|
+
*/
|
58
|
+
function checkedNodeCall(fn, ...args) {
|
59
|
+
return new Promise(function (fulfill, reject) {
|
60
|
+
try {
|
61
|
+
fn(...args, function (error, value) {
|
62
|
+
error ? reject(error) : fulfill(value)
|
63
|
+
})
|
64
|
+
} catch (ex) {
|
65
|
+
reject(ex)
|
66
|
+
}
|
67
|
+
})
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Registers a listener to invoke when a promise is resolved, regardless
|
72
|
+
* of whether the promise's value was successfully computed. This function
|
73
|
+
* is synonymous with the {@code finally} clause in a synchronous API:
|
74
|
+
*
|
75
|
+
* // Synchronous API:
|
76
|
+
* try {
|
77
|
+
* doSynchronousWork();
|
78
|
+
* } finally {
|
79
|
+
* cleanUp();
|
80
|
+
* }
|
81
|
+
*
|
82
|
+
* // Asynchronous promise API:
|
83
|
+
* doAsynchronousWork().finally(cleanUp);
|
84
|
+
*
|
85
|
+
* __Note:__ similar to the {@code finally} clause, if the registered
|
86
|
+
* callback returns a rejected promise or throws an error, it will silently
|
87
|
+
* replace the rejection error (if any) from this promise:
|
88
|
+
*
|
89
|
+
* try {
|
90
|
+
* throw Error('one');
|
91
|
+
* } finally {
|
92
|
+
* throw Error('two'); // Hides Error: one
|
93
|
+
* }
|
94
|
+
*
|
95
|
+
* let p = Promise.reject(Error('one'));
|
96
|
+
* promise.finally(p, function() {
|
97
|
+
* throw Error('two'); // Hides Error: one
|
98
|
+
* });
|
99
|
+
*
|
100
|
+
* @param {!IThenable<?>} promise The promise to add the listener to.
|
101
|
+
* @param {function(): (R|IThenable<R>)} callback The function to call when
|
102
|
+
* the promise is resolved.
|
103
|
+
* @return {!Promise<R>} A promise that will be resolved with the callback
|
104
|
+
* result.
|
105
|
+
* @template R
|
106
|
+
*/
|
107
|
+
async function thenFinally(promise, callback) {
|
108
|
+
try {
|
109
|
+
await Promise.resolve(promise)
|
110
|
+
return callback()
|
111
|
+
} catch (e) {
|
112
|
+
await callback()
|
113
|
+
throw e
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Calls a function for each element in an array and inserts the result into a
|
119
|
+
* new array, which is used as the fulfillment value of the promise returned
|
120
|
+
* by this function.
|
121
|
+
*
|
122
|
+
* If the return value of the mapping function is a promise, this function
|
123
|
+
* will wait for it to be fulfilled before inserting it into the new array.
|
124
|
+
*
|
125
|
+
* If the mapping function throws or returns a rejected promise, the
|
126
|
+
* promise returned by this function will be rejected with the same reason.
|
127
|
+
* Only the first failure will be reported; all subsequent errors will be
|
128
|
+
* silently ignored.
|
129
|
+
*
|
130
|
+
* @param {!(Array<TYPE>|IThenable<!Array<TYPE>>)} array The array to iterate
|
131
|
+
* over, or a promise that will resolve to said array.
|
132
|
+
* @param {function(this: SELF, TYPE, number, !Array<TYPE>): ?} fn The
|
133
|
+
* function to call for each element in the array. This function should
|
134
|
+
* expect three arguments (the element, the index, and the array itself.
|
135
|
+
* @param {SELF=} self The object to be used as the value of 'this' within `fn`.
|
136
|
+
* @template TYPE, SELF
|
137
|
+
*/
|
138
|
+
async function map(array, fn, self = undefined) {
|
139
|
+
const v = await Promise.resolve(array)
|
140
|
+
if (!Array.isArray(v)) {
|
141
|
+
throw TypeError('not an array')
|
142
|
+
}
|
143
|
+
|
144
|
+
const arr = /** @type {!Array} */ (v)
|
145
|
+
const n = arr.length
|
146
|
+
const values = new Array(n)
|
147
|
+
|
148
|
+
for (let i = 0; i < n; i++) {
|
149
|
+
if (i in arr) {
|
150
|
+
values[i] = await Promise.resolve(fn.call(self, arr[i], i, arr))
|
151
|
+
}
|
152
|
+
}
|
153
|
+
return values
|
154
|
+
}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Calls a function for each element in an array, and if the function returns
|
158
|
+
* true adds the element to a new array.
|
159
|
+
*
|
160
|
+
* If the return value of the filter function is a promise, this function
|
161
|
+
* will wait for it to be fulfilled before determining whether to insert the
|
162
|
+
* element into the new array.
|
163
|
+
*
|
164
|
+
* If the filter function throws or returns a rejected promise, the promise
|
165
|
+
* returned by this function will be rejected with the same reason. Only the
|
166
|
+
* first failure will be reported; all subsequent errors will be silently
|
167
|
+
* ignored.
|
168
|
+
*
|
169
|
+
* @param {!(Array<TYPE>|IThenable<!Array<TYPE>>)} array The array to iterate
|
170
|
+
* over, or a promise that will resolve to said array.
|
171
|
+
* @param {function(this: SELF, TYPE, number, !Array<TYPE>): (
|
172
|
+
* boolean|IThenable<boolean>)} fn The function
|
173
|
+
* to call for each element in the array.
|
174
|
+
* @param {SELF=} self The object to be used as the value of 'this' within `fn`.
|
175
|
+
* @template TYPE, SELF
|
176
|
+
*/
|
177
|
+
async function filter(array, fn, self = undefined) {
|
178
|
+
const v = await Promise.resolve(array)
|
179
|
+
if (!Array.isArray(v)) {
|
180
|
+
throw TypeError('not an array')
|
181
|
+
}
|
182
|
+
|
183
|
+
const arr = /** @type {!Array} */ (v)
|
184
|
+
const n = arr.length
|
185
|
+
const values = []
|
186
|
+
let valuesLength = 0
|
187
|
+
|
188
|
+
for (let i = 0; i < n; i++) {
|
189
|
+
if (i in arr) {
|
190
|
+
const value = arr[i]
|
191
|
+
const include = await fn.call(self, value, i, arr)
|
192
|
+
if (include) {
|
193
|
+
values[valuesLength++] = value
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return values
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Returns a promise that will be resolved with the input value in a
|
202
|
+
* fully-resolved state. If the value is an array, each element will be fully
|
203
|
+
* resolved. Likewise, if the value is an object, all keys will be fully
|
204
|
+
* resolved. In both cases, all nested arrays and objects will also be
|
205
|
+
* fully resolved. All fields are resolved in place; the returned promise will
|
206
|
+
* resolve on {@code value} and not a copy.
|
207
|
+
*
|
208
|
+
* Warning: This function makes no checks against objects that contain
|
209
|
+
* cyclical references:
|
210
|
+
*
|
211
|
+
* var value = {};
|
212
|
+
* value['self'] = value;
|
213
|
+
* promise.fullyResolved(value); // Stack overflow.
|
214
|
+
*
|
215
|
+
* @param {*} value The value to fully resolve.
|
216
|
+
* @return {!Thenable} A promise for a fully resolved version
|
217
|
+
* of the input value.
|
218
|
+
*/
|
219
|
+
async function fullyResolved(value) {
|
220
|
+
value = await Promise.resolve(value)
|
221
|
+
if (Array.isArray(value)) {
|
222
|
+
return fullyResolveKeys(/** @type {!Array} */ (value))
|
223
|
+
}
|
224
|
+
|
225
|
+
if (value && typeof value === 'object') {
|
226
|
+
return fullyResolveKeys(/** @type {!Object} */ (value))
|
227
|
+
}
|
228
|
+
|
229
|
+
if (typeof value === 'function') {
|
230
|
+
return fullyResolveKeys(/** @type {!Object} */ (value))
|
231
|
+
}
|
232
|
+
|
233
|
+
return value
|
234
|
+
}
|
235
|
+
|
236
|
+
/**
|
237
|
+
* @param {!(Array|Object)} obj the object to resolve.
|
238
|
+
* @return {!Thenable} A promise that will be resolved with the
|
239
|
+
* input object once all of its values have been fully resolved.
|
240
|
+
*/
|
241
|
+
async function fullyResolveKeys(obj) {
|
242
|
+
const isArray = Array.isArray(obj)
|
243
|
+
const numKeys = isArray ? obj.length : Object.keys(obj).length
|
244
|
+
|
245
|
+
if (!numKeys) {
|
246
|
+
return obj
|
247
|
+
}
|
248
|
+
|
249
|
+
async function forEachProperty(obj, fn) {
|
250
|
+
for (let key in obj) {
|
251
|
+
await fn(obj[key], key)
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
async function forEachElement(arr, fn) {
|
256
|
+
for (let i = 0; i < arr.length; i++) {
|
257
|
+
await fn(arr[i], i)
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
const forEachKey = isArray ? forEachElement : forEachProperty
|
262
|
+
await forEachKey(obj, async function (partialValue, key) {
|
263
|
+
if (
|
264
|
+
!Array.isArray(partialValue) &&
|
265
|
+
(!partialValue || typeof partialValue !== 'object')
|
266
|
+
) {
|
267
|
+
return
|
268
|
+
}
|
269
|
+
let resolvedValue = await fullyResolved(partialValue)
|
270
|
+
obj[key] = resolvedValue
|
271
|
+
})
|
272
|
+
return obj
|
273
|
+
}
|
274
|
+
|
275
|
+
// PUBLIC API
|
276
|
+
|
277
|
+
module.exports = {
|
278
|
+
checkedNodeCall,
|
279
|
+
delayed,
|
280
|
+
filter,
|
281
|
+
finally: thenFinally,
|
282
|
+
fullyResolved,
|
283
|
+
isPromise,
|
284
|
+
map,
|
285
|
+
}
|
@@ -0,0 +1,212 @@
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
3
|
+
// distributed with this work for additional information
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
6
|
+
// "License"); you may not use this file except in compliance
|
7
|
+
// with the License. You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
12
|
+
// software distributed under the License is distributed on an
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
// KIND, either express or implied. See the License for the
|
15
|
+
// specific language governing permissions and limitations
|
16
|
+
// under the License.
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @fileoverview Defines functions for configuring a webdriver proxy:
|
20
|
+
*
|
21
|
+
* const proxy = require('selenium-webdriver/proxy');
|
22
|
+
* const {Capabilities} = require('selenium-webdriver');
|
23
|
+
*
|
24
|
+
* let capabilities = new Capabilities();
|
25
|
+
* capabilities.setProxy(proxy.manual({http: 'host:1234'});
|
26
|
+
*/
|
27
|
+
|
28
|
+
'use strict'
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Supported {@linkplain Config proxy configuration} types.
|
32
|
+
*
|
33
|
+
* @enum {string}
|
34
|
+
*/
|
35
|
+
const Type = {
|
36
|
+
AUTODETECT: 'autodetect',
|
37
|
+
DIRECT: 'direct',
|
38
|
+
MANUAL: 'manual',
|
39
|
+
PAC: 'pac',
|
40
|
+
SYSTEM: 'system',
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Describes how a proxy should be configured for a WebDriver session.
|
45
|
+
* @record
|
46
|
+
*/
|
47
|
+
function Config() {}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* The proxy type.
|
51
|
+
* @type {Type}
|
52
|
+
*/
|
53
|
+
Config.prototype.proxyType
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Describes how to configure a PAC proxy.
|
57
|
+
* @record
|
58
|
+
* @extends {Config}
|
59
|
+
*/
|
60
|
+
function PacConfig() {}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* URL for the PAC file to use.
|
64
|
+
*
|
65
|
+
* @type {string}
|
66
|
+
*/
|
67
|
+
PacConfig.prototype.proxyAutoconfigUrl
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Record object that defines a manual proxy configuration. Manual
|
71
|
+
* configurations can be easily created using either the
|
72
|
+
* {@link ./proxy.manual proxy.manual()} or {@link ./proxy.socks proxy.socks()}
|
73
|
+
* factory method.
|
74
|
+
*
|
75
|
+
* @record
|
76
|
+
* @extends {Config}
|
77
|
+
*/
|
78
|
+
function ManualConfig() {}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* The proxy host for FTP requests.
|
82
|
+
*
|
83
|
+
* @type {(string|undefined)}
|
84
|
+
*/
|
85
|
+
ManualConfig.prototype.ftpProxy
|
86
|
+
|
87
|
+
/**
|
88
|
+
* The proxy host for HTTP requests.
|
89
|
+
*
|
90
|
+
* @type {(string|undefined)}
|
91
|
+
*/
|
92
|
+
ManualConfig.prototype.httpProxy
|
93
|
+
|
94
|
+
/**
|
95
|
+
* An array of hosts which should bypass all proxies.
|
96
|
+
*
|
97
|
+
* @type {(Array<string>|undefined)}
|
98
|
+
*/
|
99
|
+
ManualConfig.prototype.noProxy
|
100
|
+
|
101
|
+
/**
|
102
|
+
* The proxy host for HTTPS requests.
|
103
|
+
*
|
104
|
+
* @type {(string|undefined)}
|
105
|
+
*/
|
106
|
+
ManualConfig.prototype.sslProxy
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Defines the host and port for the SOCKS proxy to use.
|
110
|
+
*
|
111
|
+
* @type {(number|undefined)}
|
112
|
+
*/
|
113
|
+
ManualConfig.prototype.socksProxy
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Defines the SOCKS proxy version. Must be a number in the range [0, 255].
|
117
|
+
*
|
118
|
+
* @type {(number|undefined)}
|
119
|
+
*/
|
120
|
+
ManualConfig.prototype.socksVersion
|
121
|
+
|
122
|
+
// PUBLIC API
|
123
|
+
|
124
|
+
/** @const */ exports.Config = Config
|
125
|
+
/** @const */ exports.ManualConfig = ManualConfig
|
126
|
+
/** @const */ exports.PacConfig = PacConfig
|
127
|
+
/** @const */ exports.Type = Type
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Configures WebDriver to bypass all browser proxies.
|
131
|
+
* @return {!Config} A new proxy configuration object.
|
132
|
+
*/
|
133
|
+
exports.direct = function () {
|
134
|
+
return { proxyType: Type.DIRECT }
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Manually configures the browser proxy. The following options are
|
139
|
+
* supported:
|
140
|
+
*
|
141
|
+
* - `ftp`: Proxy host to use for FTP requests
|
142
|
+
* - `http`: Proxy host to use for HTTP requests
|
143
|
+
* - `https`: Proxy host to use for HTTPS requests
|
144
|
+
* - `bypass`: A list of hosts requests should directly connect to,
|
145
|
+
* bypassing any other proxies for that request. May be specified as a
|
146
|
+
* comma separated string, or a list of strings.
|
147
|
+
*
|
148
|
+
* Behavior is undefined for FTP, HTTP, and HTTPS requests if the
|
149
|
+
* corresponding key is omitted from the configuration options.
|
150
|
+
*
|
151
|
+
* @param {{ftp: (string|undefined),
|
152
|
+
* http: (string|undefined),
|
153
|
+
* https: (string|undefined),
|
154
|
+
* bypass: (Array<string>|undefined)}} options Proxy
|
155
|
+
* configuration options.
|
156
|
+
* @return {!ManualConfig} A new proxy configuration object.
|
157
|
+
*/
|
158
|
+
exports.manual = function ({ ftp, http, https, bypass }) {
|
159
|
+
return {
|
160
|
+
proxyType: Type.MANUAL,
|
161
|
+
ftpProxy: ftp,
|
162
|
+
httpProxy: http,
|
163
|
+
sslProxy: https,
|
164
|
+
noProxy: bypass,
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Creates a proxy configuration for a socks proxy.
|
170
|
+
*
|
171
|
+
* __Example:__
|
172
|
+
*
|
173
|
+
* const {Capabilities} = require('selenium-webdriver');
|
174
|
+
* const proxy = require('selenium-webdriver/lib/proxy');
|
175
|
+
*
|
176
|
+
* let capabilities = new Capabilities();
|
177
|
+
* capabilities.setProxy(proxy.socks('localhost:1234'));
|
178
|
+
*
|
179
|
+
* // Or, to include authentication.
|
180
|
+
* capabilities.setProxy(proxy.socks('bob:password@localhost:1234'));
|
181
|
+
*
|
182
|
+
*
|
183
|
+
* @param {string} socksProxy The proxy host, in the form `hostname:port`.
|
184
|
+
* @param {number=} socksVersion The SOCKS proxy version.
|
185
|
+
* @return {!ManualConfig} A new proxy configuration object.
|
186
|
+
* @see https://en.wikipedia.org/wiki/SOCKS
|
187
|
+
*/
|
188
|
+
exports.socks = function (socksProxy, socksVersion = undefined) {
|
189
|
+
return /** @type {!Config} */ ({
|
190
|
+
proxyType: Type.MANUAL,
|
191
|
+
socksProxy,
|
192
|
+
socksVersion,
|
193
|
+
})
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Configures WebDriver to configure the browser proxy using the PAC file at
|
198
|
+
* the given URL.
|
199
|
+
* @param {string} proxyAutoconfigUrl URL for the PAC proxy to use.
|
200
|
+
* @return {!PacConfig} A new proxy configuration object.
|
201
|
+
*/
|
202
|
+
exports.pac = function (proxyAutoconfigUrl) {
|
203
|
+
return { proxyType: Type.PAC, proxyAutoconfigUrl }
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Configures WebDriver to use the current system's proxy.
|
208
|
+
* @return {!Config} A new proxy configuration object.
|
209
|
+
*/
|
210
|
+
exports.system = function () {
|
211
|
+
return { proxyType: Type.SYSTEM }
|
212
|
+
}
|