UrgentcareCLI 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/UrgentCare/CLI.rb +1 -2
- data/lib/UrgentCare/Scraper.rb +65 -0
- data/lib/UrgentCare/version.rb +2 -2
- data/lib/UrgentCare.rb +1 -0
- metadata +3 -313
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -84
- data/LICENSE.txt +0 -21
- data/Notes +0 -41
- data/README.md +0 -41
- data/Rakefile +0 -8
- data/UrgentCare.gemspec +0 -39
- data/background.jpg +0 -0
- data/data.txt +0 -4
- data/lib/Urgentcare/Scraper.rb +0 -78
- data/node_modules/.bin/rimraf +0 -1
- data/node_modules/.package-lock.json +0 -250
- data/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- data/node_modules/balanced-match/LICENSE.md +0 -21
- data/node_modules/balanced-match/README.md +0 -97
- data/node_modules/balanced-match/index.js +0 -62
- data/node_modules/balanced-match/package.json +0 -48
- data/node_modules/brace-expansion/LICENSE +0 -21
- data/node_modules/brace-expansion/README.md +0 -129
- data/node_modules/brace-expansion/index.js +0 -201
- data/node_modules/brace-expansion/package.json +0 -47
- data/node_modules/concat-map/.travis.yml +0 -4
- data/node_modules/concat-map/LICENSE +0 -18
- data/node_modules/concat-map/README.markdown +0 -62
- data/node_modules/concat-map/example/map.js +0 -6
- data/node_modules/concat-map/index.js +0 -13
- data/node_modules/concat-map/package.json +0 -43
- data/node_modules/concat-map/test/map.js +0 -39
- data/node_modules/core-util-is/LICENSE +0 -19
- data/node_modules/core-util-is/README.md +0 -3
- data/node_modules/core-util-is/float.patch +0 -604
- data/node_modules/core-util-is/lib/util.js +0 -107
- data/node_modules/core-util-is/package.json +0 -32
- data/node_modules/core-util-is/test.js +0 -68
- data/node_modules/fs.realpath/LICENSE +0 -43
- data/node_modules/fs.realpath/README.md +0 -33
- data/node_modules/fs.realpath/index.js +0 -66
- data/node_modules/fs.realpath/old.js +0 -303
- data/node_modules/fs.realpath/package.json +0 -26
- data/node_modules/glob/LICENSE +0 -21
- data/node_modules/glob/README.md +0 -375
- data/node_modules/glob/changelog.md +0 -67
- data/node_modules/glob/common.js +0 -234
- data/node_modules/glob/glob.js +0 -788
- data/node_modules/glob/package.json +0 -51
- data/node_modules/glob/sync.js +0 -484
- data/node_modules/immediate/LICENSE.txt +0 -20
- data/node_modules/immediate/README.md +0 -93
- data/node_modules/immediate/dist/immediate.js +0 -75
- data/node_modules/immediate/dist/immediate.min.js +0 -1
- data/node_modules/immediate/lib/browser.js +0 -69
- data/node_modules/immediate/lib/index.js +0 -73
- data/node_modules/immediate/package.json +0 -42
- data/node_modules/inflight/LICENSE +0 -15
- data/node_modules/inflight/README.md +0 -37
- data/node_modules/inflight/inflight.js +0 -54
- data/node_modules/inflight/package.json +0 -29
- data/node_modules/inherits/LICENSE +0 -16
- data/node_modules/inherits/README.md +0 -42
- data/node_modules/inherits/inherits.js +0 -9
- data/node_modules/inherits/inherits_browser.js +0 -27
- data/node_modules/inherits/package.json +0 -29
- data/node_modules/isarray/.npmignore +0 -1
- data/node_modules/isarray/.travis.yml +0 -4
- data/node_modules/isarray/Makefile +0 -6
- data/node_modules/isarray/README.md +0 -60
- data/node_modules/isarray/component.json +0 -19
- data/node_modules/isarray/index.js +0 -5
- data/node_modules/isarray/package.json +0 -45
- data/node_modules/isarray/test.js +0 -20
- data/node_modules/jszip/.codeclimate.yml +0 -16
- data/node_modules/jszip/.editorconfig +0 -8
- data/node_modules/jszip/.jshintignore +0 -1
- data/node_modules/jszip/.jshintrc +0 -21
- data/node_modules/jszip/.travis.yml +0 -17
- data/node_modules/jszip/CHANGES.md +0 -163
- data/node_modules/jszip/LICENSE.markdown +0 -651
- data/node_modules/jszip/README.markdown +0 -35
- data/node_modules/jszip/dist/jszip.js +0 -30
- data/node_modules/jszip/dist/jszip.min.js +0 -13
- data/node_modules/jszip/index.d.ts +0 -270
- data/node_modules/jszip/lib/base64.js +0 -106
- data/node_modules/jszip/lib/compressedObject.js +0 -74
- data/node_modules/jszip/lib/compressions.js +0 -14
- data/node_modules/jszip/lib/crc32.js +0 -77
- data/node_modules/jszip/lib/defaults.js +0 -11
- data/node_modules/jszip/lib/external.js +0 -19
- data/node_modules/jszip/lib/flate.js +0 -85
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -540
- data/node_modules/jszip/lib/generate/index.js +0 -57
- data/node_modules/jszip/lib/index.js +0 -52
- data/node_modules/jszip/lib/license_header.js +0 -11
- data/node_modules/jszip/lib/load.js +0 -81
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
- data/node_modules/jszip/lib/nodejsUtils.js +0 -57
- data/node_modules/jszip/lib/object.js +0 -389
- data/node_modules/jszip/lib/readable-stream-browser.js +0 -9
- data/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
- data/node_modules/jszip/lib/reader/DataReader.js +0 -116
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
- data/node_modules/jszip/lib/reader/StringReader.js +0 -38
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
- data/node_modules/jszip/lib/reader/readerFor.js +0 -28
- data/node_modules/jszip/lib/signature.js +0 -7
- data/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
- data/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
- data/node_modules/jszip/lib/stream/DataWorker.js +0 -116
- data/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
- data/node_modules/jszip/lib/stream/StreamHelper.js +0 -212
- data/node_modules/jszip/lib/support.js +0 -38
- data/node_modules/jszip/lib/utf8.js +0 -275
- data/node_modules/jszip/lib/utils.js +0 -476
- data/node_modules/jszip/lib/zipEntries.js +0 -262
- data/node_modules/jszip/lib/zipEntry.js +0 -294
- data/node_modules/jszip/lib/zipObject.js +0 -133
- data/node_modules/jszip/package.json +0 -63
- data/node_modules/jszip/vendor/FileSaver.js +0 -247
- data/node_modules/lie/README.md +0 -62
- data/node_modules/lie/dist/lie.js +0 -350
- data/node_modules/lie/dist/lie.min.js +0 -1
- data/node_modules/lie/dist/lie.polyfill.js +0 -358
- data/node_modules/lie/dist/lie.polyfill.min.js +0 -1
- data/node_modules/lie/lib/browser.js +0 -273
- data/node_modules/lie/lib/index.js +0 -298
- data/node_modules/lie/license.md +0 -7
- data/node_modules/lie/lie.d.ts +0 -244
- data/node_modules/lie/package.json +0 -69
- data/node_modules/lie/polyfill.js +0 -4
- data/node_modules/minimatch/LICENSE +0 -15
- data/node_modules/minimatch/README.md +0 -209
- data/node_modules/minimatch/minimatch.js +0 -923
- data/node_modules/minimatch/package.json +0 -30
- data/node_modules/once/LICENSE +0 -15
- data/node_modules/once/README.md +0 -79
- data/node_modules/once/once.js +0 -42
- data/node_modules/once/package.json +0 -33
- data/node_modules/pako/CHANGELOG.md +0 -164
- data/node_modules/pako/LICENSE +0 -21
- data/node_modules/pako/README.md +0 -191
- data/node_modules/pako/dist/pako.js +0 -6818
- data/node_modules/pako/dist/pako.min.js +0 -1
- data/node_modules/pako/dist/pako_deflate.js +0 -3997
- data/node_modules/pako/dist/pako_deflate.min.js +0 -1
- data/node_modules/pako/dist/pako_inflate.js +0 -3300
- data/node_modules/pako/dist/pako_inflate.min.js +0 -1
- data/node_modules/pako/index.js +0 -14
- data/node_modules/pako/lib/deflate.js +0 -400
- data/node_modules/pako/lib/inflate.js +0 -423
- data/node_modules/pako/lib/utils/common.js +0 -105
- data/node_modules/pako/lib/utils/strings.js +0 -187
- data/node_modules/pako/lib/zlib/README +0 -59
- data/node_modules/pako/lib/zlib/adler32.js +0 -51
- data/node_modules/pako/lib/zlib/constants.js +0 -68
- data/node_modules/pako/lib/zlib/crc32.js +0 -59
- data/node_modules/pako/lib/zlib/deflate.js +0 -1874
- data/node_modules/pako/lib/zlib/gzheader.js +0 -58
- data/node_modules/pako/lib/zlib/inffast.js +0 -345
- data/node_modules/pako/lib/zlib/inflate.js +0 -1556
- data/node_modules/pako/lib/zlib/inftrees.js +0 -343
- data/node_modules/pako/lib/zlib/messages.js +0 -32
- data/node_modules/pako/lib/zlib/trees.js +0 -1222
- data/node_modules/pako/lib/zlib/zstream.js +0 -47
- data/node_modules/pako/package.json +0 -44
- data/node_modules/path-is-absolute/index.js +0 -20
- data/node_modules/path-is-absolute/license +0 -21
- data/node_modules/path-is-absolute/package.json +0 -43
- data/node_modules/path-is-absolute/readme.md +0 -59
- data/node_modules/process-nextick-args/index.js +0 -45
- data/node_modules/process-nextick-args/license.md +0 -19
- data/node_modules/process-nextick-args/package.json +0 -25
- data/node_modules/process-nextick-args/readme.md +0 -18
- data/node_modules/readable-stream/.travis.yml +0 -34
- data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- data/node_modules/readable-stream/GOVERNANCE.md +0 -136
- data/node_modules/readable-stream/LICENSE +0 -47
- data/node_modules/readable-stream/README.md +0 -58
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- data/node_modules/readable-stream/duplex-browser.js +0 -1
- data/node_modules/readable-stream/duplex.js +0 -1
- data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- data/node_modules/readable-stream/package.json +0 -52
- data/node_modules/readable-stream/passthrough.js +0 -1
- data/node_modules/readable-stream/readable-browser.js +0 -7
- data/node_modules/readable-stream/readable.js +0 -19
- data/node_modules/readable-stream/transform.js +0 -1
- data/node_modules/readable-stream/writable-browser.js +0 -1
- data/node_modules/readable-stream/writable.js +0 -8
- data/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/rimraf/README.md +0 -101
- data/node_modules/rimraf/bin.js +0 -50
- data/node_modules/rimraf/package.json +0 -29
- data/node_modules/rimraf/rimraf.js +0 -372
- data/node_modules/safe-buffer/LICENSE +0 -21
- data/node_modules/safe-buffer/README.md +0 -584
- data/node_modules/safe-buffer/index.d.ts +0 -187
- data/node_modules/safe-buffer/index.js +0 -62
- data/node_modules/safe-buffer/package.json +0 -37
- data/node_modules/selenium-webdriver/CHANGES.md +0 -1114
- data/node_modules/selenium-webdriver/LICENSE +0 -202
- data/node_modules/selenium-webdriver/NOTICE +0 -2
- data/node_modules/selenium-webdriver/README.md +0 -229
- data/node_modules/selenium-webdriver/chrome.js +0 -295
- data/node_modules/selenium-webdriver/chromium.js +0 -829
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +0 -35
- data/node_modules/selenium-webdriver/edge.js +0 -224
- data/node_modules/selenium-webdriver/example/chrome_android.js +0 -45
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +0 -46
- data/node_modules/selenium-webdriver/example/firefox_channels.js +0 -84
- data/node_modules/selenium-webdriver/example/google_search.js +0 -50
- data/node_modules/selenium-webdriver/example/google_search_test.js +0 -70
- data/node_modules/selenium-webdriver/example/headless.js +0 -63
- data/node_modules/selenium-webdriver/example/logging.js +0 -64
- data/node_modules/selenium-webdriver/firefox.js +0 -789
- data/node_modules/selenium-webdriver/http/index.js +0 -324
- data/node_modules/selenium-webdriver/http/util.js +0 -172
- data/node_modules/selenium-webdriver/ie.js +0 -503
- data/node_modules/selenium-webdriver/index.js +0 -825
- data/node_modules/selenium-webdriver/io/exec.js +0 -162
- data/node_modules/selenium-webdriver/io/index.js +0 -348
- data/node_modules/selenium-webdriver/io/zip.js +0 -223
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +0 -123
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +0 -55
- data/node_modules/selenium-webdriver/lib/by.js +0 -415
- data/node_modules/selenium-webdriver/lib/capabilities.js +0 -553
- data/node_modules/selenium-webdriver/lib/command.js +0 -206
- data/node_modules/selenium-webdriver/lib/error.js +0 -605
- data/node_modules/selenium-webdriver/lib/http.js +0 -704
- data/node_modules/selenium-webdriver/lib/input.js +0 -946
- data/node_modules/selenium-webdriver/lib/logging.js +0 -661
- data/node_modules/selenium-webdriver/lib/promise.js +0 -285
- data/node_modules/selenium-webdriver/lib/proxy.js +0 -212
- data/node_modules/selenium-webdriver/lib/session.js +0 -77
- data/node_modules/selenium-webdriver/lib/symbols.js +0 -37
- data/node_modules/selenium-webdriver/lib/until.js +0 -429
- data/node_modules/selenium-webdriver/lib/webdriver.js +0 -2919
- data/node_modules/selenium-webdriver/net/index.js +0 -107
- data/node_modules/selenium-webdriver/net/portprober.js +0 -75
- data/node_modules/selenium-webdriver/opera.js +0 -406
- data/node_modules/selenium-webdriver/package.json +0 -54
- data/node_modules/selenium-webdriver/proxy.js +0 -32
- data/node_modules/selenium-webdriver/remote/index.js +0 -624
- data/node_modules/selenium-webdriver/safari.js +0 -168
- data/node_modules/selenium-webdriver/testing/index.js +0 -504
- data/node_modules/set-immediate-shim/index.js +0 -7
- data/node_modules/set-immediate-shim/package.json +0 -34
- data/node_modules/set-immediate-shim/readme.md +0 -31
- data/node_modules/string_decoder/.travis.yml +0 -50
- data/node_modules/string_decoder/LICENSE +0 -48
- data/node_modules/string_decoder/README.md +0 -47
- data/node_modules/string_decoder/lib/string_decoder.js +0 -296
- data/node_modules/string_decoder/package.json +0 -31
- data/node_modules/tmp/CHANGELOG.md +0 -288
- data/node_modules/tmp/LICENSE +0 -21
- data/node_modules/tmp/README.md +0 -365
- data/node_modules/tmp/lib/tmp.js +0 -780
- data/node_modules/tmp/node_modules/.bin/rimraf +0 -1
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +0 -65
- data/node_modules/tmp/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/tmp/node_modules/rimraf/README.md +0 -101
- data/node_modules/tmp/node_modules/rimraf/bin.js +0 -68
- data/node_modules/tmp/node_modules/rimraf/package.json +0 -32
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +0 -360
- data/node_modules/tmp/package.json +0 -58
- data/node_modules/util-deprecate/History.md +0 -16
- data/node_modules/util-deprecate/LICENSE +0 -24
- data/node_modules/util-deprecate/README.md +0 -53
- data/node_modules/util-deprecate/browser.js +0 -67
- data/node_modules/util-deprecate/node.js +0 -6
- data/node_modules/util-deprecate/package.json +0 -27
- data/node_modules/wrappy/LICENSE +0 -15
- data/node_modules/wrappy/README.md +0 -36
- data/node_modules/wrappy/package.json +0 -29
- data/node_modules/wrappy/wrappy.js +0 -33
- data/node_modules/ws/LICENSE +0 -21
- data/node_modules/ws/README.md +0 -496
- data/node_modules/ws/browser.js +0 -8
- data/node_modules/ws/index.js +0 -10
- data/node_modules/ws/lib/buffer-util.js +0 -129
- data/node_modules/ws/lib/constants.js +0 -10
- data/node_modules/ws/lib/event-target.js +0 -184
- data/node_modules/ws/lib/extension.js +0 -223
- data/node_modules/ws/lib/limiter.js +0 -55
- data/node_modules/ws/lib/permessage-deflate.js +0 -517
- data/node_modules/ws/lib/receiver.js +0 -507
- data/node_modules/ws/lib/sender.js +0 -405
- data/node_modules/ws/lib/stream.js +0 -165
- data/node_modules/ws/lib/validation.js +0 -104
- data/node_modules/ws/lib/websocket-server.js +0 -418
- data/node_modules/ws/lib/websocket.js +0 -942
- data/node_modules/ws/package.json +0 -56
- data/package-lock.json +0 -458
- data/package.json +0 -5
- data/selenium.log +0 -1
- data/spec.md +0 -6
- data/test.data +0 -2110
@@ -1,57 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var compressions = require('../compressions');
|
4
|
-
var ZipFileWorker = require('./ZipFileWorker');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Find the compression to use.
|
8
|
-
* @param {String} fileCompression the compression defined at the file level, if any.
|
9
|
-
* @param {String} zipCompression the compression defined at the load() level.
|
10
|
-
* @return {Object} the compression object to use.
|
11
|
-
*/
|
12
|
-
var getCompression = function (fileCompression, zipCompression) {
|
13
|
-
|
14
|
-
var compressionName = fileCompression || zipCompression;
|
15
|
-
var compression = compressions[compressionName];
|
16
|
-
if (!compression) {
|
17
|
-
throw new Error(compressionName + " is not a valid compression method !");
|
18
|
-
}
|
19
|
-
return compression;
|
20
|
-
};
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Create a worker to generate a zip file.
|
24
|
-
* @param {JSZip} zip the JSZip instance at the right root level.
|
25
|
-
* @param {Object} options to generate the zip file.
|
26
|
-
* @param {String} comment the comment to use.
|
27
|
-
*/
|
28
|
-
exports.generateWorker = function (zip, options, comment) {
|
29
|
-
|
30
|
-
var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);
|
31
|
-
var entriesCount = 0;
|
32
|
-
try {
|
33
|
-
|
34
|
-
zip.forEach(function (relativePath, file) {
|
35
|
-
entriesCount++;
|
36
|
-
var compression = getCompression(file.options.compression, options.compression);
|
37
|
-
var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
|
38
|
-
var dir = file.dir, date = file.date;
|
39
|
-
|
40
|
-
file._compressWorker(compression, compressionOptions)
|
41
|
-
.withStreamInfo("file", {
|
42
|
-
name : relativePath,
|
43
|
-
dir : dir,
|
44
|
-
date : date,
|
45
|
-
comment : file.comment || "",
|
46
|
-
unixPermissions : file.unixPermissions,
|
47
|
-
dosPermissions : file.dosPermissions
|
48
|
-
})
|
49
|
-
.pipe(zipFileWorker);
|
50
|
-
});
|
51
|
-
zipFileWorker.entriesCount = entriesCount;
|
52
|
-
} catch (e) {
|
53
|
-
zipFileWorker.error(e);
|
54
|
-
}
|
55
|
-
|
56
|
-
return zipFileWorker;
|
57
|
-
};
|
@@ -1,52 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Representation a of zip file in js
|
5
|
-
* @constructor
|
6
|
-
*/
|
7
|
-
function JSZip() {
|
8
|
-
// if this constructor is used without `new`, it adds `new` before itself:
|
9
|
-
if(!(this instanceof JSZip)) {
|
10
|
-
return new JSZip();
|
11
|
-
}
|
12
|
-
|
13
|
-
if(arguments.length) {
|
14
|
-
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
15
|
-
}
|
16
|
-
|
17
|
-
// object containing the files :
|
18
|
-
// {
|
19
|
-
// "folder/" : {...},
|
20
|
-
// "folder/data.txt" : {...}
|
21
|
-
// }
|
22
|
-
this.files = {};
|
23
|
-
|
24
|
-
this.comment = null;
|
25
|
-
|
26
|
-
// Where we are in the hierarchy
|
27
|
-
this.root = "";
|
28
|
-
this.clone = function() {
|
29
|
-
var newObj = new JSZip();
|
30
|
-
for (var i in this) {
|
31
|
-
if (typeof this[i] !== "function") {
|
32
|
-
newObj[i] = this[i];
|
33
|
-
}
|
34
|
-
}
|
35
|
-
return newObj;
|
36
|
-
};
|
37
|
-
}
|
38
|
-
JSZip.prototype = require('./object');
|
39
|
-
JSZip.prototype.loadAsync = require('./load');
|
40
|
-
JSZip.support = require('./support');
|
41
|
-
JSZip.defaults = require('./defaults');
|
42
|
-
|
43
|
-
// TODO find a better way to handle this version,
|
44
|
-
// a require('package.json').version doesn't work with webpack, see #327
|
45
|
-
JSZip.version = "3.6.0";
|
46
|
-
|
47
|
-
JSZip.loadAsync = function (content, options) {
|
48
|
-
return new JSZip().loadAsync(content, options);
|
49
|
-
};
|
50
|
-
|
51
|
-
JSZip.external = require("./external");
|
52
|
-
module.exports = JSZip;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
|
3
|
-
JSZip v__VERSION__ - A JavaScript class for generating and reading zip files
|
4
|
-
<http://stuartk.com/jszip>
|
5
|
-
|
6
|
-
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
7
|
-
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
|
8
|
-
|
9
|
-
JSZip uses the library pako released under the MIT license :
|
10
|
-
https://github.com/nodeca/pako/blob/master/LICENSE
|
11
|
-
*/
|
@@ -1,81 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
var utils = require('./utils');
|
3
|
-
var external = require("./external");
|
4
|
-
var utf8 = require('./utf8');
|
5
|
-
var ZipEntries = require('./zipEntries');
|
6
|
-
var Crc32Probe = require('./stream/Crc32Probe');
|
7
|
-
var nodejsUtils = require("./nodejsUtils");
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Check the CRC32 of an entry.
|
11
|
-
* @param {ZipEntry} zipEntry the zip entry to check.
|
12
|
-
* @return {Promise} the result.
|
13
|
-
*/
|
14
|
-
function checkEntryCRC32(zipEntry) {
|
15
|
-
return new external.Promise(function (resolve, reject) {
|
16
|
-
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
|
17
|
-
worker.on("error", function (e) {
|
18
|
-
reject(e);
|
19
|
-
})
|
20
|
-
.on("end", function () {
|
21
|
-
if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
|
22
|
-
reject(new Error("Corrupted zip : CRC32 mismatch"));
|
23
|
-
} else {
|
24
|
-
resolve();
|
25
|
-
}
|
26
|
-
})
|
27
|
-
.resume();
|
28
|
-
});
|
29
|
-
}
|
30
|
-
|
31
|
-
module.exports = function (data, options) {
|
32
|
-
var zip = this;
|
33
|
-
options = utils.extend(options || {}, {
|
34
|
-
base64: false,
|
35
|
-
checkCRC32: false,
|
36
|
-
optimizedBinaryString: false,
|
37
|
-
createFolders: false,
|
38
|
-
decodeFileName: utf8.utf8decode
|
39
|
-
});
|
40
|
-
|
41
|
-
if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
|
42
|
-
return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
|
43
|
-
}
|
44
|
-
|
45
|
-
return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64)
|
46
|
-
.then(function (data) {
|
47
|
-
var zipEntries = new ZipEntries(options);
|
48
|
-
zipEntries.load(data);
|
49
|
-
return zipEntries;
|
50
|
-
}).then(function checkCRC32(zipEntries) {
|
51
|
-
var promises = [external.Promise.resolve(zipEntries)];
|
52
|
-
var files = zipEntries.files;
|
53
|
-
if (options.checkCRC32) {
|
54
|
-
for (var i = 0; i < files.length; i++) {
|
55
|
-
promises.push(checkEntryCRC32(files[i]));
|
56
|
-
}
|
57
|
-
}
|
58
|
-
return external.Promise.all(promises);
|
59
|
-
}).then(function addFiles(results) {
|
60
|
-
var zipEntries = results.shift();
|
61
|
-
var files = zipEntries.files;
|
62
|
-
for (var i = 0; i < files.length; i++) {
|
63
|
-
var input = files[i];
|
64
|
-
zip.file(input.fileNameStr, input.decompressed, {
|
65
|
-
binary: true,
|
66
|
-
optimizedBinaryString: true,
|
67
|
-
date: input.date,
|
68
|
-
dir: input.dir,
|
69
|
-
comment: input.fileCommentStr.length ? input.fileCommentStr : null,
|
70
|
-
unixPermissions: input.unixPermissions,
|
71
|
-
dosPermissions: input.dosPermissions,
|
72
|
-
createFolders: options.createFolders
|
73
|
-
});
|
74
|
-
}
|
75
|
-
if (zipEntries.zipComment.length) {
|
76
|
-
zip.comment = zipEntries.zipComment;
|
77
|
-
}
|
78
|
-
|
79
|
-
return zip;
|
80
|
-
});
|
81
|
-
};
|
@@ -1,74 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require('../utils');
|
4
|
-
var GenericWorker = require('../stream/GenericWorker');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* A worker that use a nodejs stream as source.
|
8
|
-
* @constructor
|
9
|
-
* @param {String} filename the name of the file entry for this stream.
|
10
|
-
* @param {Readable} stream the nodejs stream.
|
11
|
-
*/
|
12
|
-
function NodejsStreamInputAdapter(filename, stream) {
|
13
|
-
GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
|
14
|
-
this._upstreamEnded = false;
|
15
|
-
this._bindStream(stream);
|
16
|
-
}
|
17
|
-
|
18
|
-
utils.inherits(NodejsStreamInputAdapter, GenericWorker);
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Prepare the stream and bind the callbacks on it.
|
22
|
-
* Do this ASAP on node 0.10 ! A lazy binding doesn't always work.
|
23
|
-
* @param {Stream} stream the nodejs stream to use.
|
24
|
-
*/
|
25
|
-
NodejsStreamInputAdapter.prototype._bindStream = function (stream) {
|
26
|
-
var self = this;
|
27
|
-
this._stream = stream;
|
28
|
-
stream.pause();
|
29
|
-
stream
|
30
|
-
.on("data", function (chunk) {
|
31
|
-
self.push({
|
32
|
-
data: chunk,
|
33
|
-
meta : {
|
34
|
-
percent : 0
|
35
|
-
}
|
36
|
-
});
|
37
|
-
})
|
38
|
-
.on("error", function (e) {
|
39
|
-
if(self.isPaused) {
|
40
|
-
this.generatedError = e;
|
41
|
-
} else {
|
42
|
-
self.error(e);
|
43
|
-
}
|
44
|
-
})
|
45
|
-
.on("end", function () {
|
46
|
-
if(self.isPaused) {
|
47
|
-
self._upstreamEnded = true;
|
48
|
-
} else {
|
49
|
-
self.end();
|
50
|
-
}
|
51
|
-
});
|
52
|
-
};
|
53
|
-
NodejsStreamInputAdapter.prototype.pause = function () {
|
54
|
-
if(!GenericWorker.prototype.pause.call(this)) {
|
55
|
-
return false;
|
56
|
-
}
|
57
|
-
this._stream.pause();
|
58
|
-
return true;
|
59
|
-
};
|
60
|
-
NodejsStreamInputAdapter.prototype.resume = function () {
|
61
|
-
if(!GenericWorker.prototype.resume.call(this)) {
|
62
|
-
return false;
|
63
|
-
}
|
64
|
-
|
65
|
-
if(this._upstreamEnded) {
|
66
|
-
this.end();
|
67
|
-
} else {
|
68
|
-
this._stream.resume();
|
69
|
-
}
|
70
|
-
|
71
|
-
return true;
|
72
|
-
};
|
73
|
-
|
74
|
-
module.exports = NodejsStreamInputAdapter;
|
@@ -1,42 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var Readable = require('readable-stream').Readable;
|
4
|
-
|
5
|
-
var utils = require('../utils');
|
6
|
-
utils.inherits(NodejsStreamOutputAdapter, Readable);
|
7
|
-
|
8
|
-
/**
|
9
|
-
* A nodejs stream using a worker as source.
|
10
|
-
* @see the SourceWrapper in http://nodejs.org/api/stream.html
|
11
|
-
* @constructor
|
12
|
-
* @param {StreamHelper} helper the helper wrapping the worker
|
13
|
-
* @param {Object} options the nodejs stream options
|
14
|
-
* @param {Function} updateCb the update callback.
|
15
|
-
*/
|
16
|
-
function NodejsStreamOutputAdapter(helper, options, updateCb) {
|
17
|
-
Readable.call(this, options);
|
18
|
-
this._helper = helper;
|
19
|
-
|
20
|
-
var self = this;
|
21
|
-
helper.on("data", function (data, meta) {
|
22
|
-
if (!self.push(data)) {
|
23
|
-
self._helper.pause();
|
24
|
-
}
|
25
|
-
if(updateCb) {
|
26
|
-
updateCb(meta);
|
27
|
-
}
|
28
|
-
})
|
29
|
-
.on("error", function(e) {
|
30
|
-
self.emit('error', e);
|
31
|
-
})
|
32
|
-
.on("end", function () {
|
33
|
-
self.push(null);
|
34
|
-
});
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
NodejsStreamOutputAdapter.prototype._read = function() {
|
39
|
-
this._helper.resume();
|
40
|
-
};
|
41
|
-
|
42
|
-
module.exports = NodejsStreamOutputAdapter;
|
@@ -1,57 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
/**
|
5
|
-
* True if this is running in Nodejs, will be undefined in a browser.
|
6
|
-
* In a browser, browserify won't include this file and the whole module
|
7
|
-
* will be resolved an empty object.
|
8
|
-
*/
|
9
|
-
isNode : typeof Buffer !== "undefined",
|
10
|
-
/**
|
11
|
-
* Create a new nodejs Buffer from an existing content.
|
12
|
-
* @param {Object} data the data to pass to the constructor.
|
13
|
-
* @param {String} encoding the encoding to use.
|
14
|
-
* @return {Buffer} a new Buffer.
|
15
|
-
*/
|
16
|
-
newBufferFrom: function(data, encoding) {
|
17
|
-
if (Buffer.from && Buffer.from !== Uint8Array.from) {
|
18
|
-
return Buffer.from(data, encoding);
|
19
|
-
} else {
|
20
|
-
if (typeof data === "number") {
|
21
|
-
// Safeguard for old Node.js versions. On newer versions,
|
22
|
-
// Buffer.from(number) / Buffer(number, encoding) already throw.
|
23
|
-
throw new Error("The \"data\" argument must not be a number");
|
24
|
-
}
|
25
|
-
return new Buffer(data, encoding);
|
26
|
-
}
|
27
|
-
},
|
28
|
-
/**
|
29
|
-
* Create a new nodejs Buffer with the specified size.
|
30
|
-
* @param {Integer} size the size of the buffer.
|
31
|
-
* @return {Buffer} a new Buffer.
|
32
|
-
*/
|
33
|
-
allocBuffer: function (size) {
|
34
|
-
if (Buffer.alloc) {
|
35
|
-
return Buffer.alloc(size);
|
36
|
-
} else {
|
37
|
-
var buf = new Buffer(size);
|
38
|
-
buf.fill(0);
|
39
|
-
return buf;
|
40
|
-
}
|
41
|
-
},
|
42
|
-
/**
|
43
|
-
* Find out if an object is a Buffer.
|
44
|
-
* @param {Object} b the object to test.
|
45
|
-
* @return {Boolean} true if the object is a Buffer, false otherwise.
|
46
|
-
*/
|
47
|
-
isBuffer : function(b){
|
48
|
-
return Buffer.isBuffer(b);
|
49
|
-
},
|
50
|
-
|
51
|
-
isStream : function (obj) {
|
52
|
-
return obj &&
|
53
|
-
typeof obj.on === "function" &&
|
54
|
-
typeof obj.pause === "function" &&
|
55
|
-
typeof obj.resume === "function";
|
56
|
-
}
|
57
|
-
};
|
@@ -1,389 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
var utf8 = require('./utf8');
|
3
|
-
var utils = require('./utils');
|
4
|
-
var GenericWorker = require('./stream/GenericWorker');
|
5
|
-
var StreamHelper = require('./stream/StreamHelper');
|
6
|
-
var defaults = require('./defaults');
|
7
|
-
var CompressedObject = require('./compressedObject');
|
8
|
-
var ZipObject = require('./zipObject');
|
9
|
-
var generate = require("./generate");
|
10
|
-
var nodejsUtils = require("./nodejsUtils");
|
11
|
-
var NodejsStreamInputAdapter = require("./nodejs/NodejsStreamInputAdapter");
|
12
|
-
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Add a file in the current folder.
|
16
|
-
* @private
|
17
|
-
* @param {string} name the name of the file
|
18
|
-
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
|
19
|
-
* @param {Object} originalOptions the options of the file
|
20
|
-
* @return {Object} the new file.
|
21
|
-
*/
|
22
|
-
var fileAdd = function(name, data, originalOptions) {
|
23
|
-
// be sure sub folders exist
|
24
|
-
var dataType = utils.getTypeOf(data),
|
25
|
-
parent;
|
26
|
-
|
27
|
-
|
28
|
-
/*
|
29
|
-
* Correct options.
|
30
|
-
*/
|
31
|
-
|
32
|
-
var o = utils.extend(originalOptions || {}, defaults);
|
33
|
-
o.date = o.date || new Date();
|
34
|
-
if (o.compression !== null) {
|
35
|
-
o.compression = o.compression.toUpperCase();
|
36
|
-
}
|
37
|
-
|
38
|
-
if (typeof o.unixPermissions === "string") {
|
39
|
-
o.unixPermissions = parseInt(o.unixPermissions, 8);
|
40
|
-
}
|
41
|
-
|
42
|
-
// UNX_IFDIR 0040000 see zipinfo.c
|
43
|
-
if (o.unixPermissions && (o.unixPermissions & 0x4000)) {
|
44
|
-
o.dir = true;
|
45
|
-
}
|
46
|
-
// Bit 4 Directory
|
47
|
-
if (o.dosPermissions && (o.dosPermissions & 0x0010)) {
|
48
|
-
o.dir = true;
|
49
|
-
}
|
50
|
-
|
51
|
-
if (o.dir) {
|
52
|
-
name = forceTrailingSlash(name);
|
53
|
-
}
|
54
|
-
if (o.createFolders && (parent = parentFolder(name))) {
|
55
|
-
folderAdd.call(this, parent, true);
|
56
|
-
}
|
57
|
-
|
58
|
-
var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false;
|
59
|
-
if (!originalOptions || typeof originalOptions.binary === "undefined") {
|
60
|
-
o.binary = !isUnicodeString;
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
var isCompressedEmpty = (data instanceof CompressedObject) && data.uncompressedSize === 0;
|
65
|
-
|
66
|
-
if (isCompressedEmpty || o.dir || !data || data.length === 0) {
|
67
|
-
o.base64 = false;
|
68
|
-
o.binary = true;
|
69
|
-
data = "";
|
70
|
-
o.compression = "STORE";
|
71
|
-
dataType = "string";
|
72
|
-
}
|
73
|
-
|
74
|
-
/*
|
75
|
-
* Convert content to fit.
|
76
|
-
*/
|
77
|
-
|
78
|
-
var zipObjectContent = null;
|
79
|
-
if (data instanceof CompressedObject || data instanceof GenericWorker) {
|
80
|
-
zipObjectContent = data;
|
81
|
-
} else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
|
82
|
-
zipObjectContent = new NodejsStreamInputAdapter(name, data);
|
83
|
-
} else {
|
84
|
-
zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);
|
85
|
-
}
|
86
|
-
|
87
|
-
var object = new ZipObject(name, zipObjectContent, o);
|
88
|
-
this.files[name] = object;
|
89
|
-
/*
|
90
|
-
TODO: we can't throw an exception because we have async promises
|
91
|
-
(we can have a promise of a Date() for example) but returning a
|
92
|
-
promise is useless because file(name, data) returns the JSZip
|
93
|
-
object for chaining. Should we break that to allow the user
|
94
|
-
to catch the error ?
|
95
|
-
|
96
|
-
return external.Promise.resolve(zipObjectContent)
|
97
|
-
.then(function () {
|
98
|
-
return object;
|
99
|
-
});
|
100
|
-
*/
|
101
|
-
};
|
102
|
-
|
103
|
-
/**
|
104
|
-
* Find the parent folder of the path.
|
105
|
-
* @private
|
106
|
-
* @param {string} path the path to use
|
107
|
-
* @return {string} the parent folder, or ""
|
108
|
-
*/
|
109
|
-
var parentFolder = function (path) {
|
110
|
-
if (path.slice(-1) === '/') {
|
111
|
-
path = path.substring(0, path.length - 1);
|
112
|
-
}
|
113
|
-
var lastSlash = path.lastIndexOf('/');
|
114
|
-
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
|
115
|
-
};
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Returns the path with a slash at the end.
|
119
|
-
* @private
|
120
|
-
* @param {String} path the path to check.
|
121
|
-
* @return {String} the path with a trailing slash.
|
122
|
-
*/
|
123
|
-
var forceTrailingSlash = function(path) {
|
124
|
-
// Check the name ends with a /
|
125
|
-
if (path.slice(-1) !== "/") {
|
126
|
-
path += "/"; // IE doesn't like substr(-1)
|
127
|
-
}
|
128
|
-
return path;
|
129
|
-
};
|
130
|
-
|
131
|
-
/**
|
132
|
-
* Add a (sub) folder in the current folder.
|
133
|
-
* @private
|
134
|
-
* @param {string} name the folder's name
|
135
|
-
* @param {boolean=} [createFolders] If true, automatically create sub
|
136
|
-
* folders. Defaults to false.
|
137
|
-
* @return {Object} the new folder.
|
138
|
-
*/
|
139
|
-
var folderAdd = function(name, createFolders) {
|
140
|
-
createFolders = (typeof createFolders !== 'undefined') ? createFolders : defaults.createFolders;
|
141
|
-
|
142
|
-
name = forceTrailingSlash(name);
|
143
|
-
|
144
|
-
// Does this folder already exist?
|
145
|
-
if (!this.files[name]) {
|
146
|
-
fileAdd.call(this, name, null, {
|
147
|
-
dir: true,
|
148
|
-
createFolders: createFolders
|
149
|
-
});
|
150
|
-
}
|
151
|
-
return this.files[name];
|
152
|
-
};
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Cross-window, cross-Node-context regular expression detection
|
156
|
-
* @param {Object} object Anything
|
157
|
-
* @return {Boolean} true if the object is a regular expression,
|
158
|
-
* false otherwise
|
159
|
-
*/
|
160
|
-
function isRegExp(object) {
|
161
|
-
return Object.prototype.toString.call(object) === "[object RegExp]";
|
162
|
-
}
|
163
|
-
|
164
|
-
// return the actual prototype of JSZip
|
165
|
-
var out = {
|
166
|
-
/**
|
167
|
-
* @see loadAsync
|
168
|
-
*/
|
169
|
-
load: function() {
|
170
|
-
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
171
|
-
},
|
172
|
-
|
173
|
-
|
174
|
-
/**
|
175
|
-
* Call a callback function for each entry at this folder level.
|
176
|
-
* @param {Function} cb the callback function:
|
177
|
-
* function (relativePath, file) {...}
|
178
|
-
* It takes 2 arguments : the relative path and the file.
|
179
|
-
*/
|
180
|
-
forEach: function(cb) {
|
181
|
-
var filename, relativePath, file;
|
182
|
-
for (filename in this.files) {
|
183
|
-
if (!this.files.hasOwnProperty(filename)) {
|
184
|
-
continue;
|
185
|
-
}
|
186
|
-
file = this.files[filename];
|
187
|
-
relativePath = filename.slice(this.root.length, filename.length);
|
188
|
-
if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root
|
189
|
-
cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
|
190
|
-
}
|
191
|
-
}
|
192
|
-
},
|
193
|
-
|
194
|
-
/**
|
195
|
-
* Filter nested files/folders with the specified function.
|
196
|
-
* @param {Function} search the predicate to use :
|
197
|
-
* function (relativePath, file) {...}
|
198
|
-
* It takes 2 arguments : the relative path and the file.
|
199
|
-
* @return {Array} An array of matching elements.
|
200
|
-
*/
|
201
|
-
filter: function(search) {
|
202
|
-
var result = [];
|
203
|
-
this.forEach(function (relativePath, entry) {
|
204
|
-
if (search(relativePath, entry)) { // the file matches the function
|
205
|
-
result.push(entry);
|
206
|
-
}
|
207
|
-
|
208
|
-
});
|
209
|
-
return result;
|
210
|
-
},
|
211
|
-
|
212
|
-
/**
|
213
|
-
* Add a file to the zip file, or search a file.
|
214
|
-
* @param {string|RegExp} name The name of the file to add (if data is defined),
|
215
|
-
* the name of the file to find (if no data) or a regex to match files.
|
216
|
-
* @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
|
217
|
-
* @param {Object} o File options
|
218
|
-
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
|
219
|
-
* a file (when searching by string) or an array of files (when searching by regex).
|
220
|
-
*/
|
221
|
-
file: function(name, data, o) {
|
222
|
-
if (arguments.length === 1) {
|
223
|
-
if (isRegExp(name)) {
|
224
|
-
var regexp = name;
|
225
|
-
return this.filter(function(relativePath, file) {
|
226
|
-
return !file.dir && regexp.test(relativePath);
|
227
|
-
});
|
228
|
-
}
|
229
|
-
else { // text
|
230
|
-
var obj = this.files[this.root + name];
|
231
|
-
if (obj && !obj.dir) {
|
232
|
-
return obj;
|
233
|
-
} else {
|
234
|
-
return null;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
238
|
-
else { // more than one argument : we have data !
|
239
|
-
name = this.root + name;
|
240
|
-
fileAdd.call(this, name, data, o);
|
241
|
-
}
|
242
|
-
return this;
|
243
|
-
},
|
244
|
-
|
245
|
-
/**
|
246
|
-
* Add a directory to the zip file, or search.
|
247
|
-
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
|
248
|
-
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
|
249
|
-
*/
|
250
|
-
folder: function(arg) {
|
251
|
-
if (!arg) {
|
252
|
-
return this;
|
253
|
-
}
|
254
|
-
|
255
|
-
if (isRegExp(arg)) {
|
256
|
-
return this.filter(function(relativePath, file) {
|
257
|
-
return file.dir && arg.test(relativePath);
|
258
|
-
});
|
259
|
-
}
|
260
|
-
|
261
|
-
// else, name is a new folder
|
262
|
-
var name = this.root + arg;
|
263
|
-
var newFolder = folderAdd.call(this, name);
|
264
|
-
|
265
|
-
// Allow chaining by returning a new object with this folder as the root
|
266
|
-
var ret = this.clone();
|
267
|
-
ret.root = newFolder.name;
|
268
|
-
return ret;
|
269
|
-
},
|
270
|
-
|
271
|
-
/**
|
272
|
-
* Delete a file, or a directory and all sub-files, from the zip
|
273
|
-
* @param {string} name the name of the file to delete
|
274
|
-
* @return {JSZip} this JSZip object
|
275
|
-
*/
|
276
|
-
remove: function(name) {
|
277
|
-
name = this.root + name;
|
278
|
-
var file = this.files[name];
|
279
|
-
if (!file) {
|
280
|
-
// Look for any folders
|
281
|
-
if (name.slice(-1) !== "/") {
|
282
|
-
name += "/";
|
283
|
-
}
|
284
|
-
file = this.files[name];
|
285
|
-
}
|
286
|
-
|
287
|
-
if (file && !file.dir) {
|
288
|
-
// file
|
289
|
-
delete this.files[name];
|
290
|
-
} else {
|
291
|
-
// maybe a folder, delete recursively
|
292
|
-
var kids = this.filter(function(relativePath, file) {
|
293
|
-
return file.name.slice(0, name.length) === name;
|
294
|
-
});
|
295
|
-
for (var i = 0; i < kids.length; i++) {
|
296
|
-
delete this.files[kids[i].name];
|
297
|
-
}
|
298
|
-
}
|
299
|
-
|
300
|
-
return this;
|
301
|
-
},
|
302
|
-
|
303
|
-
/**
|
304
|
-
* Generate the complete zip file
|
305
|
-
* @param {Object} options the options to generate the zip file :
|
306
|
-
* - compression, "STORE" by default.
|
307
|
-
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
|
308
|
-
* @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
|
309
|
-
*/
|
310
|
-
generate: function(options) {
|
311
|
-
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
312
|
-
},
|
313
|
-
|
314
|
-
/**
|
315
|
-
* Generate the complete zip file as an internal stream.
|
316
|
-
* @param {Object} options the options to generate the zip file :
|
317
|
-
* - compression, "STORE" by default.
|
318
|
-
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
|
319
|
-
* @return {StreamHelper} the streamed zip file.
|
320
|
-
*/
|
321
|
-
generateInternalStream: function(options) {
|
322
|
-
var worker, opts = {};
|
323
|
-
try {
|
324
|
-
opts = utils.extend(options || {}, {
|
325
|
-
streamFiles: false,
|
326
|
-
compression: "STORE",
|
327
|
-
compressionOptions : null,
|
328
|
-
type: "",
|
329
|
-
platform: "DOS",
|
330
|
-
comment: null,
|
331
|
-
mimeType: 'application/zip',
|
332
|
-
encodeFileName: utf8.utf8encode
|
333
|
-
});
|
334
|
-
|
335
|
-
opts.type = opts.type.toLowerCase();
|
336
|
-
opts.compression = opts.compression.toUpperCase();
|
337
|
-
|
338
|
-
// "binarystring" is preferred but the internals use "string".
|
339
|
-
if(opts.type === "binarystring") {
|
340
|
-
opts.type = "string";
|
341
|
-
}
|
342
|
-
|
343
|
-
if (!opts.type) {
|
344
|
-
throw new Error("No output type specified.");
|
345
|
-
}
|
346
|
-
|
347
|
-
utils.checkSupport(opts.type);
|
348
|
-
|
349
|
-
// accept nodejs `process.platform`
|
350
|
-
if(
|
351
|
-
opts.platform === 'darwin' ||
|
352
|
-
opts.platform === 'freebsd' ||
|
353
|
-
opts.platform === 'linux' ||
|
354
|
-
opts.platform === 'sunos'
|
355
|
-
) {
|
356
|
-
opts.platform = "UNIX";
|
357
|
-
}
|
358
|
-
if (opts.platform === 'win32') {
|
359
|
-
opts.platform = "DOS";
|
360
|
-
}
|
361
|
-
|
362
|
-
var comment = opts.comment || this.comment || "";
|
363
|
-
worker = generate.generateWorker(this, opts, comment);
|
364
|
-
} catch (e) {
|
365
|
-
worker = new GenericWorker("error");
|
366
|
-
worker.error(e);
|
367
|
-
}
|
368
|
-
return new StreamHelper(worker, opts.type || "string", opts.mimeType);
|
369
|
-
},
|
370
|
-
/**
|
371
|
-
* Generate the complete zip file asynchronously.
|
372
|
-
* @see generateInternalStream
|
373
|
-
*/
|
374
|
-
generateAsync: function(options, onUpdate) {
|
375
|
-
return this.generateInternalStream(options).accumulate(onUpdate);
|
376
|
-
},
|
377
|
-
/**
|
378
|
-
* Generate the complete zip file asynchronously.
|
379
|
-
* @see generateInternalStream
|
380
|
-
*/
|
381
|
-
generateNodeStream: function(options, onUpdate) {
|
382
|
-
options = options || {};
|
383
|
-
if (!options.type) {
|
384
|
-
options.type = "nodebuffer";
|
385
|
-
}
|
386
|
-
return this.generateInternalStream(options).toNodejsStream(onUpdate);
|
387
|
-
}
|
388
|
-
};
|
389
|
-
module.exports = out;
|