From ee080d6a13da1ca4b6d1b139d3e62b15e81f7425 Mon Sep 17 00:00:00 2001 From: Bryan Ngo Date: Sun, 2 Sep 2018 17:57:45 -0700 Subject: [PATCH] added email servicer AR --- .gitignore | 1 + ARs/applePayReminder.md | 13 +- ARs/emailServicer.md | 19 + node_modules/.bin/jade | 296 +- node_modules/.bin/mime | 9 +- node_modules/append-field/package.json | 22 +- node_modules/assertion-error/package.json | 13 +- node_modules/async/package.json | 13 +- node_modules/balanced-match/package.json | 24 +- node_modules/bluebird/package.json | 13 +- .../node_modules/bytes/package.json | 104 +- .../node_modules/content-type/package.json | 95 +- .../debug/node_modules/ms/package.json | 78 +- .../node_modules/debug/package.json | 98 +- .../node_modules/depd/package.json | 88 +- .../node_modules/inherits/package.json | 85 +- .../node_modules/setprototypeof/package.json | 81 +- .../node_modules/statuses/package.json | 120 +- .../node_modules/http-errors/package.json | 100 +- .../node_modules/iconv-lite/package.json | 109 +- .../node_modules/ee-first/package.json | 78 +- .../node_modules/on-finished/package.json | 78 +- .../body-parser/node_modules/qs/package.json | 123 +- .../raw-body/node_modules/unpipe/package.json | 76 +- .../node_modules/raw-body/package.json | 82 +- .../node_modules/media-typer/package.json | 76 +- .../node_modules/mime-db/package.json | 105 +- .../node_modules/mime-types/package.json | 99 +- .../node_modules/type-is/package.json | 91 +- node_modules/body-parser/package.json | 82 +- node_modules/brace-expansion/package.json | 24 +- node_modules/bson/package.json | 27 +- node_modules/buffer-from/LICENSE | 21 + node_modules/buffer-from/index.js | 69 + node_modules/buffer-from/package.json | 52 + node_modules/buffer-from/readme.md | 69 + node_modules/buffer-shims/package.json | 22 - .../busboy/node_modules/isarray/package.json | 13 +- .../node_modules/readable-stream/package.json | 23 +- .../node_modules/string_decoder/package.json | 23 +- node_modules/busboy/package.json | 25 +- node_modules/chai/package.json | 21 +- .../cli/node_modules/glob/package.json | 24 +- .../cli/node_modules/minimatch/package.json | 24 +- node_modules/cli/package.json | 24 +- node_modules/commander/package.json | 13 +- node_modules/concat-map/package.json | 14 +- node_modules/concat-stream/LICENSE | 24 + node_modules/concat-stream/index.js | 144 + node_modules/concat-stream/package.json | 84 + node_modules/concat-stream/readme.md | 102 + node_modules/connect-flash/package.json | 21 +- node_modules/console-browserify/package.json | 24 +- .../cookie-signature/package.json | 87 +- .../node_modules/cookie/package.json | 90 +- node_modules/cookie-parser/package.json | 94 +- node_modules/cookie-signature/package.json | 13 +- node_modules/cookie/package.json | 13 +- node_modules/core-util-is/package.json | 44 +- node_modules/crc/package.json | 13 +- node_modules/date-now/package.json | 24 +- .../debug/node_modules/ms/package.json | 78 +- node_modules/debug/package.json | 99 +- node_modules/deep-eql/package.json | 13 +- node_modules/depd/package.json | 23 +- .../dicer/node_modules/isarray/package.json | 13 +- .../node_modules/readable-stream/package.json | 23 +- .../node_modules/string_decoder/package.json | 23 +- node_modules/dicer/package.json | 13 +- node_modules/diff/package.json | 13 +- .../node_modules/domelementtype/package.json | 24 +- .../node_modules/entities/package.json | 24 +- node_modules/dom-serializer/package.json | 24 +- node_modules/domelementtype/package.json | 24 +- node_modules/domhandler/package.json | 24 +- node_modules/domutils/package.json | 24 +- node_modules/ee-first/LICENSE | 22 + node_modules/ee-first/README.md | 80 + node_modules/ee-first/index.js | 95 + node_modules/ee-first/package.json | 63 + node_modules/entities/package.json | 24 +- node_modules/es6-promise/package.json | 4 +- node_modules/exit/package.json | 24 +- .../node_modules/debug/package.json | 13 +- node_modules/express-session/package.json | 21 +- .../node_modules/mime-db/package.json | 105 +- .../node_modules/mime-types/package.json | 99 +- .../node_modules/negotiator/package.json | 107 +- .../express/node_modules/accepts/package.json | 91 +- .../node_modules/array-flatten/package.json | 87 +- .../content-disposition/package.json | 95 +- .../node_modules/content-type/package.json | 95 +- .../cookie-signature/package.json | 87 +- .../express/node_modules/cookie/package.json | 90 +- .../debug/node_modules/ms/package.json | 78 +- .../express/node_modules/debug/package.json | 100 +- .../express/node_modules/depd/package.json | 89 +- .../node_modules/encodeurl/package.json | 95 +- .../node_modules/escape-html/package.json | 89 +- .../express/node_modules/etag/package.json | 91 +- .../node_modules/statuses/package.json | 120 +- .../node_modules/unpipe/package.json | 76 +- .../node_modules/finalhandler/package.json | 79 +- .../express/node_modules/fresh/package.json | 103 +- .../merge-descriptors/package.json | 146 +- .../express/node_modules/methods/package.json | 104 +- .../node_modules/ee-first/package.json | 78 +- .../node_modules/on-finished/package.json | 80 +- .../node_modules/parseurl/package.json | 101 +- .../node_modules/path-to-regexp/package.json | 213 +- .../node_modules/forwarded/package.json | 88 +- .../node_modules/ipaddr.js/package.json | 83 +- .../node_modules/proxy-addr/package.json | 93 +- .../express/node_modules/qs/package.json | 123 +- .../node_modules/range-parser/package.json | 105 +- .../node_modules/send/node_modules/.bin/mime | 9 +- .../send/node_modules/destroy/package.json | 84 +- .../node_modules/inherits/package.json | 85 +- .../node_modules/setprototypeof/package.json | 81 +- .../node_modules/http-errors/package.json | 100 +- .../send/node_modules/mime/package.json | 84 +- .../send/node_modules/ms/package.json | 103 +- .../send/node_modules/statuses/package.json | 121 +- .../express/node_modules/send/package.json | 93 +- .../node_modules/serve-static/package.json | 80 +- .../node_modules/media-typer/package.json | 76 +- .../node_modules/mime-db/package.json | 105 +- .../node_modules/mime-types/package.json | 99 +- .../express/node_modules/type-is/package.json | 91 +- .../node_modules/utils-merge/package.json | 87 +- .../express/node_modules/vary/package.json | 91 +- node_modules/express/package.json | 118 +- node_modules/fs.realpath/package.json | 24 +- node_modules/glob/package.json | 13 +- node_modules/graceful-fs/package.json | 23 +- node_modules/growl/package.json | 22 +- node_modules/hooks-fixed/package.json | 13 +- .../node_modules/isarray/package.json | 14 +- .../node_modules/readable-stream/package.json | 24 +- .../node_modules/string_decoder/package.json | 24 +- node_modules/htmlparser2/package.json | 24 +- node_modules/inflight/package.json | 24 +- node_modules/inherits/package.json | 50 +- node_modules/isarray/package.json | 18 - node_modules/jade/node_modules/.bin/cleancss | 184 +- node_modules/jade/node_modules/.bin/mkdirp | 34 +- node_modules/jade/node_modules/.bin/uglifyjs | 636 +- .../character-parser/package.json | 84 +- .../graceful-readlink/package.json | 72 +- .../node_modules/commander/package.json | 102 +- .../node_modules/amdefine/package.json | 77 +- .../node_modules/source-map/package.json | 97 +- .../jade/node_modules/clean-css/package.json | 114 +- .../jade/node_modules/commander/package.json | 98 +- .../constantinople/node_modules/.bin/acorn | 72 +- .../node_modules/acorn/package.json | 108 +- .../node_modules/constantinople/package.json | 80 +- .../node_modules/is-promise/package.json | 76 +- .../promise/node_modules/asap/package.json | 52 +- .../node_modules/promise/package.json | 91 +- .../node_modules/jstransformer/package.json | 86 +- .../mkdirp/node_modules/minimist/package.json | 99 +- .../jade/node_modules/mkdirp/package.json | 89 +- .../transformers/node_modules/.bin/uglifyjs | 371 +- .../css/node_modules/css-parse/package.json | 62 +- .../node_modules/css-stringify/package.json | 66 +- .../node_modules/css/package.json | 62 +- .../node_modules/is-promise/package.json | 74 +- .../node_modules/promise/package.json | 74 +- .../node_modules/wordwrap/package.json | 101 +- .../node_modules/optimist/package.json | 86 +- .../node_modules/amdefine/package.json | 77 +- .../node_modules/source-map/package.json | 91 +- .../node_modules/uglify-js/package.json | 84 +- .../node_modules/transformers/package.json | 151 +- .../node_modules/source-map/package.json | 100 +- .../uglify-to-browserify/package.json | 79 +- .../yargs/node_modules/camelcase/package.json | 80 +- .../node_modules/is-buffer/package.json | 62 +- .../node_modules/kind-of/package.json | 104 +- .../node_modules/longest/package.json | 94 +- .../node_modules/repeat-string/package.json | 102 +- .../node_modules/align-text/package.json | 92 +- .../node_modules/lazy-cache/package.json | 96 +- .../node_modules/center-align/package.json | 98 +- .../node_modules/is-buffer/package.json | 62 +- .../node_modules/kind-of/package.json | 104 +- .../node_modules/longest/package.json | 94 +- .../node_modules/repeat-string/package.json | 102 +- .../node_modules/align-text/package.json | 92 +- .../node_modules/right-align/package.json | 84 +- .../cliui/node_modules/wordwrap/package.json | 95 +- .../yargs/node_modules/cliui/package.json | 114 +- .../node_modules/decamelize/package.json | 86 +- .../node_modules/window-size/package.json | 72 +- .../uglify-js/node_modules/yargs/package.json | 154 +- .../jade/node_modules/uglify-js/package.json | 127 +- .../node_modules/void-elements/package.json | 90 +- .../node_modules/with/node_modules/.bin/acorn | 55 +- .../acorn-globals/node_modules/.bin/acorn | 72 +- .../node_modules/acorn/package.json | 109 +- .../node_modules/acorn-globals/package.json | 100 +- .../with/node_modules/acorn/package.json | 101 +- .../jade/node_modules/with/package.json | 78 +- node_modules/jade/package.json | 151 +- .../jshint/node_modules/lodash/package.json | 24 +- .../node_modules/minimatch/package.json | 24 +- node_modules/jshint/package.json | 25 +- node_modules/kareem/package.json | 13 +- node_modules/lodash.get/package.json | 13 +- node_modules/lodash/package.json | 23 +- node_modules/lru-cache/package.json | 23 +- node_modules/media-typer/HISTORY.md | 22 + node_modules/media-typer/LICENSE | 22 + node_modules/media-typer/README.md | 81 + node_modules/media-typer/index.js | 270 + node_modules/media-typer/package.json | 61 + node_modules/mime-db/HISTORY.md | 391 + node_modules/mime-db/LICENSE | 22 + node_modules/mime-db/README.md | 94 + node_modules/mime-db/db.json | 7671 +++++++ node_modules/mime-db/index.js | 11 + node_modules/mime-db/package.json | 100 + node_modules/mime-types/HISTORY.md | 278 + node_modules/mime-types/LICENSE | 23 + node_modules/mime-types/README.md | 108 + node_modules/mime-types/index.js | 188 + node_modules/mime-types/package.json | 86 + node_modules/mime/.eslintrc.json | 51 + node_modules/mime/.github/ISSUE_TEMPLATE.md | 6 + .../mime/.github/PULL_REQUEST_TEMPLATE.md | 6 + node_modules/mime/.npmignore | 0 node_modules/mime/.travis.yml | 5 + node_modules/mime/CHANGELOG.md | 225 + node_modules/mime/CONTRIBUTING.md | 5 + node_modules/mime/README.md | 202 +- node_modules/mime/build/build.js | 11 - node_modules/mime/build/test.js | 60 - node_modules/mime/cli.js | 6 +- node_modules/mime/index.js | 4 + node_modules/mime/lite.js | 4 + node_modules/mime/mime.js | 133 +- node_modules/mime/package.json | 96 +- node_modules/mime/src/README_js.md | 179 + node_modules/mime/src/build.js | 71 + node_modules/mime/src/test.js | 257 + node_modules/mime/types.json | 1 - node_modules/mime/types/other.json | 1 + node_modules/mime/types/standard.json | 1 + node_modules/minimatch/package.json | 23 +- .../node_modules => }/minimist/.travis.yml | 0 .../mkdirp/node_modules => }/minimist/LICENSE | 0 .../minimist/example/parse.js | 0 .../node_modules => }/minimist/index.js | 0 .../node_modules => }/minimist/package.json | 95 +- .../minimist/readme.markdown | 0 .../node_modules => }/minimist/test/dash.js | 0 .../minimist/test/default_bool.js | 0 .../node_modules => }/minimist/test/dotted.js | 0 .../node_modules => }/minimist/test/long.js | 0 .../node_modules => }/minimist/test/parse.js | 0 .../minimist/test/parse_modified.js | 0 .../node_modules => }/minimist/test/short.js | 0 .../minimist/test/whitespace.js | 0 node_modules/mkdirp/package.json | 13 +- .../mocha/node_modules/growl/package.json | 23 +- .../jade/node_modules/commander/package.json | 13 +- .../jade/node_modules/mkdirp/package.json | 13 +- .../mocha/node_modules/jade/package.json | 13 +- node_modules/mocha/package.json | 21 +- node_modules/mongodb-core/.eslintrc | 37 +- .../mongodb-core/.evergreen/config.yml | 677 + .../.evergreen/install-dependencies.sh | 32 + .../.evergreen/run-atlas-tests.sh | 10 + .../mongodb-core/.evergreen/run-tests.sh | 36 + node_modules/mongodb-core/CODE_OF_CONDUCT.md | 80 + node_modules/mongodb-core/CONTRIBUTING.md | 29 + node_modules/mongodb-core/HISTORY.md | 310 +- node_modules/mongodb-core/README.md | 6 +- node_modules/mongodb-core/conf.json | 2 + node_modules/mongodb-core/index.js | 54 +- .../lib/auth/defaultAuthProviders.js | 29 + node_modules/mongodb-core/lib/auth/gssapi.js | 366 +- node_modules/mongodb-core/lib/auth/mongocr.js | 201 +- node_modules/mongodb-core/lib/auth/plain.js | 145 +- node_modules/mongodb-core/lib/auth/scram.js | 441 +- node_modules/mongodb-core/lib/auth/sspi.js | 310 +- node_modules/mongodb-core/lib/auth/x509.js | 135 +- .../mongodb-core/lib/connection/apm.js | 223 + .../lib/connection/command_result.js | 8 +- .../mongodb-core/lib/connection/commands.js | 313 +- .../mongodb-core/lib/connection/connection.js | 628 +- .../mongodb-core/lib/connection/logger.js | 240 +- .../mongodb-core/lib/connection/pool.js | 892 +- .../mongodb-core/lib/connection/utils.js | 77 +- node_modules/mongodb-core/lib/cursor.js | 662 +- node_modules/mongodb-core/lib/error.js | 162 +- node_modules/mongodb-core/lib/sdam/cursor.js | 749 + .../mongodb-core/lib/sdam/monitoring.js | 217 + node_modules/mongodb-core/lib/sdam/server.js | 413 + .../lib/sdam/server_description.js | 141 + .../mongodb-core/lib/sdam/server_selectors.js | 206 + .../mongodb-core/lib/sdam/topology.js | 666 + .../lib/sdam/topology_description.js | 364 + node_modules/mongodb-core/lib/sessions.js | 459 + .../mongodb-core/lib/tools/smoke_plugin.js | 10 +- .../mongodb-core/lib/topologies/mongos.js | 755 +- .../lib/topologies/read_preference.js | 191 +- .../mongodb-core/lib/topologies/replset.js | 1103 +- .../lib/topologies/replset_state.js | 620 +- .../mongodb-core/lib/topologies/server.js | 747 +- .../mongodb-core/lib/topologies/shared.js | 288 +- node_modules/mongodb-core/lib/transactions.js | 134 + node_modules/mongodb-core/lib/uri_parser.js | 318 + node_modules/mongodb-core/lib/utils.js | 107 +- .../lib/wireprotocol/2_6_support.js | 280 +- .../lib/wireprotocol/3_2_support.js | 495 +- .../lib/wireprotocol/compression.js | 73 + .../mongodb-core/lib/wireprotocol/shared.js | 46 +- .../mongodb-core/node_modules/bson/HISTORY.md | 253 + .../mongodb-core/node_modules/bson/LICENSE.md | 201 + .../mongodb-core/node_modules/bson/README.md | 170 + .../mongodb-core/node_modules/bson/bower.json | 25 + .../node_modules/bson/browser_build/bson.js | 17748 ++++++++++++++++ .../bson/browser_build/package.json | 8 + .../mongodb-core/node_modules/bson/index.js | 46 + .../node_modules/bson/lib/bson/binary.js | 382 + .../node_modules/bson/lib/bson/bson.js | 385 + .../node_modules/bson/lib/bson/code.js | 24 + .../node_modules/bson/lib/bson/db_ref.js | 32 + .../node_modules/bson/lib/bson/decimal128.js | 818 + .../node_modules/bson/lib/bson/double.js | 33 + .../bson/lib/bson/float_parser.js | 124 + .../node_modules/bson/lib/bson/int_32.js | 33 + .../node_modules/bson/lib/bson/long.js | 851 + .../node_modules/bson/lib/bson/map.js | 128 + .../node_modules/bson/lib/bson/max_key.js | 14 + .../node_modules/bson/lib/bson/min_key.js | 14 + .../node_modules/bson/lib/bson/objectid.js | 387 + .../bson/lib/bson/parser/calculate_size.js | 255 + .../bson/lib/bson/parser/deserializer.js | 780 + .../bson/lib/bson/parser/serializer.js | 1183 + .../bson/lib/bson/parser/utils.js | 14 + .../node_modules/bson/lib/bson/regexp.js | 33 + .../node_modules/bson/lib/bson/symbol.js | 50 + .../node_modules/bson/lib/bson/timestamp.js | 854 + .../node_modules/bson/package.json | 87 + node_modules/mongodb-core/package.json | 76 +- node_modules/mongodb-core/yarn.lock | 3433 +++ .../mongodb/.evergreen/_config.template.yml | 157 + node_modules/mongodb/.evergreen/config.yml | 590 + .../.evergreen/generate_evergreen_tasks.js | 204 + .../.evergreen/install-dependencies.sh | 32 + node_modules/mongodb/.evergreen/run-tests.sh | 36 + node_modules/mongodb/CHANGES_3.0.0.md | 316 + node_modules/mongodb/CODE_OF_CONDUCT.md | 80 + node_modules/mongodb/CONTRIBUTING.md | 29 + node_modules/mongodb/HISTORY.md | 383 +- node_modules/mongodb/README.md | 423 +- node_modules/mongodb/conf.json | 33 +- node_modules/mongodb/index.js | 31 +- node_modules/mongodb/lib/admin.js | 578 +- .../mongodb/lib/aggregation_cursor.js | 175 +- node_modules/mongodb/lib/apm.js | 609 +- node_modules/mongodb/lib/authenticate.js | 132 +- node_modules/mongodb/lib/bulk/common.js | 1081 +- node_modules/mongodb/lib/bulk/ordered.js | 585 +- node_modules/mongodb/lib/bulk/unordered.js | 607 +- node_modules/mongodb/lib/change_stream.js | 455 + node_modules/mongodb/lib/collection.js | 3365 +-- node_modules/mongodb/lib/command_cursor.js | 172 +- node_modules/mongodb/lib/cursor.js | 1012 +- node_modules/mongodb/lib/db.js | 1769 +- node_modules/mongodb/lib/error.js | 43 + .../mongodb/lib/gridfs-stream/download.js | 96 +- .../mongodb/lib/gridfs-stream/index.js | 133 +- .../mongodb/lib/gridfs-stream/upload.js | 87 +- node_modules/mongodb/lib/gridfs/chunk.js | 80 +- node_modules/mongodb/lib/gridfs/grid_store.js | 1253 +- node_modules/mongodb/lib/mongo_client.js | 849 +- .../mongodb/lib/operations/admin_ops.js | 62 + .../mongodb/lib/operations/collection_ops.js | 1455 ++ .../mongodb/lib/operations/cursor_ops.js | 237 + node_modules/mongodb/lib/operations/db_ops.js | 982 + .../lib/operations/mongo_client_ops.js | 636 + node_modules/mongodb/lib/topologies/mongos.js | 452 + .../mongodb/lib/topologies/replset.js | 497 + node_modules/mongodb/lib/topologies/server.js | 455 + .../mongodb/lib/topologies/topology_base.js | 446 + node_modules/mongodb/lib/url_parser.js | 604 +- node_modules/mongodb/lib/utils.js | 631 +- node_modules/mongodb/package.json | 87 +- node_modules/mongodb/yarn.lock | 3595 ++-- .../node_modules/mongodb-core/.coveralls.yml | 1 + .../node_modules/mongodb-core}/.eslintrc | 0 .../node_modules/mongodb-core/HISTORY.md | 714 + .../node_modules/mongodb-core/LICENSE | 201 + .../node_modules/mongodb-core/Makefile | 11 + .../node_modules/mongodb-core/README.md | 228 + .../node_modules}/mongodb-core/TESTING.md | 0 .../mongodb-core/THIRD-PARTY-NOTICES | 41 + .../node_modules/mongodb-core/conf.json | 59 + .../node_modules/mongodb-core/index.js | 32 + .../mongodb-core/lib/auth/gssapi.js | 262 + .../mongodb-core/lib/auth/mongocr.js | 181 + .../mongodb-core/lib/auth/plain.js | 168 + .../mongodb-core/lib/auth/scram.js | 339 + .../mongodb-core/lib/auth/sspi.js | 250 + .../mongodb-core/lib/auth/x509.js | 164 + .../lib/connection/command_result.js | 34 + .../mongodb-core/lib/connection/commands.js | 546 + .../mongodb-core/lib/connection/connection.js | 619 + .../mongodb-core/lib/connection/logger.js | 228 + .../mongodb-core/lib/connection/pool.js | 1387 ++ .../mongodb-core/lib/connection/utils.js | 86 + .../node_modules/mongodb-core/lib/cursor.js | 704 + .../node_modules/mongodb-core/lib/error.js | 44 + .../mongodb-core/lib/tools/smoke_plugin.js | 59 + .../mongodb-core/lib/topologies/mongos.js | 1307 ++ .../lib/topologies/read_preference.js | 118 + .../mongodb-core/lib/topologies/replset.js | 1473 ++ .../lib/topologies/replset_state.js | 1001 + .../mongodb-core/lib/topologies/server.js | 880 + .../mongodb-core/lib/topologies/shared.js | 334 + .../node_modules/mongodb-core/lib/utils.js | 32 + .../lib/wireprotocol/2_4_support.js | 0 .../lib/wireprotocol/2_6_support.js | 334 + .../lib/wireprotocol/3_2_support.js | 549 + .../mongodb-core/lib/wireprotocol/commands.js | 0 .../mongodb-core/lib/wireprotocol/shared.js | 27 + .../node_modules/mongodb-core/package.json | 76 + .../node_modules}/mongodb-core/test.js | 0 .../node_modules}/mongodb-core/test1.js | 0 .../node_modules}/mongodb/.coveralls.yml | 0 .../mongoose/node_modules/mongodb/.eslintrc | 15 + .../mongoose/node_modules/mongodb/HISTORY.md | 1767 ++ .../mongoose/node_modules/mongodb/LICENSE | 201 + .../mongoose/node_modules/mongodb/Makefile | 11 + .../mongoose/node_modules/mongodb/README.md | 415 + .../node_modules/mongodb/THIRD-PARTY-NOTICES | 41 + .../node_modules/mongodb/boot_auth.js | 52 + .../mongoose/node_modules/mongodb/conf.json | 76 + .../mongoose/node_modules/mongodb/index.js | 56 + .../node_modules/mongodb/insert_bench.js | 231 + .../node_modules/mongodb/lib/admin.js | 579 + .../mongodb/lib/aggregation_cursor.js | 438 + .../mongoose/node_modules/mongodb/lib/apm.js | 596 + .../node_modules/mongodb/lib/authenticate.js | 110 + .../node_modules/mongodb/lib/bulk/common.js | 440 + .../node_modules/mongodb/lib/bulk/ordered.js | 539 + .../mongodb/lib/bulk/unordered.js | 541 + .../node_modules/mongodb/lib/collection.js | 3377 +++ .../mongodb/lib/command_cursor.js | 320 + .../node_modules/mongodb/lib/cursor.js | 1208 ++ .../mongoose/node_modules/mongodb/lib/db.js | 1805 ++ .../mongodb/lib/gridfs-stream/download.js | 409 + .../mongodb/lib/gridfs-stream/index.js | 367 + .../mongodb/lib/gridfs-stream/upload.js | 527 + .../node_modules/mongodb/lib/gridfs/chunk.js | 230 + .../mongodb/lib/gridfs/grid_store.js | 1954 ++ .../node_modules}/mongodb/lib/metadata.js | 0 .../node_modules/mongodb/lib/mongo_client.js | 531 + .../node_modules}/mongodb/lib/mongos.js | 0 .../mongodb/lib/read_preference.js | 0 .../node_modules}/mongodb/lib/replset.js | 0 .../node_modules}/mongodb/lib/server.js | 0 .../mongodb/lib/topology_base.js | 0 .../node_modules/mongodb/lib/url_parser.js | 526 + .../node_modules/mongodb/lib/utils.js | 375 + .../node_modules/mongodb/package.json | 90 + .../node_modules}/mongodb/rev.md | 0 .../mongoose/node_modules/mongodb/yarn.lock | 3299 +++ node_modules/mongoose/package.json | 28 +- .../node_modules/basic-auth/package.json | 103 +- .../debug/node_modules/ms/package.json | 78 +- .../morgan/node_modules/debug/package.json | 98 +- .../morgan/node_modules/depd/package.json | 88 +- .../node_modules/ee-first/package.json | 78 +- .../node_modules/on-finished/package.json | 78 +- .../node_modules/on-headers/package.json | 92 +- node_modules/morgan/package.json | 102 +- node_modules/mpath/package.json | 13 +- node_modules/mpromise/package.json | 13 +- .../mquery/node_modules/debug/package.json | 13 +- .../mquery/node_modules/sliced/package.json | 13 +- node_modules/mquery/package.json | 13 +- node_modules/ms/package.json | 13 +- node_modules/multer/CHANGELOG.md | 4 + node_modules/multer/README.md | 1 + node_modules/multer/node_modules/.bin/mkdirp | 34 +- .../node_modules/append-field/.npmignore | 1 + .../multer/node_modules/append-field/LICENSE | 21 + .../node_modules/append-field/README.md | 44 + .../multer/node_modules/append-field/index.js | 12 + .../append-field/lib/parse-path.js | 53 + .../append-field/lib/set-value.js | 64 + .../node_modules/append-field/package.json | 52 + .../node_modules/append-field/test/forms.js | 19 + .../multer/node_modules/mkdirp/package.json | 85 +- node_modules/multer/package.json | 105 +- node_modules/muri/package.json | 13 +- node_modules/nodemailer/CHANGELOG.md | 522 + node_modules/nodemailer/CONTRIBUTING.md | 67 + node_modules/nodemailer/LICENSE | 16 + node_modules/nodemailer/README.md | 77 + .../nodemailer/lib/addressparser/index.js | 292 + node_modules/nodemailer/lib/base64/index.js | 142 + node_modules/nodemailer/lib/dkim/index.js | 251 + .../nodemailer/lib/dkim/message-parser.js | 156 + .../nodemailer/lib/dkim/relaxed-body.js | 154 + node_modules/nodemailer/lib/dkim/sign.js | 117 + node_modules/nodemailer/lib/fetch/cookies.js | 284 + node_modules/nodemailer/lib/fetch/index.js | 277 + .../nodemailer/lib/json-transport/index.js | 82 + .../nodemailer/lib/mail-composer/index.js | 545 + node_modules/nodemailer/lib/mailer/index.js | 423 + .../nodemailer/lib/mailer/mail-message.js | 295 + .../nodemailer/lib/mime-funcs/index.js | 628 + .../nodemailer/lib/mime-funcs/mime-types.js | 2109 ++ .../nodemailer/lib/mime-node/index.js | 1242 ++ .../nodemailer/lib/mime-node/last-newline.js | 33 + node_modules/nodemailer/lib/nodemailer.js | 148 + node_modules/nodemailer/lib/qp/index.js | 219 + .../lib/sendmail-transport/index.js | 208 + .../lib/sendmail-transport/le-unix.js | 43 + .../lib/sendmail-transport/le-windows.js | 52 + .../nodemailer/lib/ses-transport/index.js | 312 + node_modules/nodemailer/lib/shared/index.js | 387 + .../lib/smtp-connection/data-stream.js | 108 + .../lib/smtp-connection/http-proxy-client.js | 131 + .../nodemailer/lib/smtp-connection/index.js | 1569 ++ .../nodemailer/lib/smtp-pool/index.js | 600 + .../nodemailer/lib/smtp-pool/pool-resource.js | 252 + .../nodemailer/lib/smtp-transport/index.js | 407 + .../nodemailer/lib/stream-transport/index.js | 142 + .../nodemailer/lib/well-known/index.js | 47 + .../nodemailer/lib/well-known/services.json | 265 + node_modules/nodemailer/lib/xoauth2/index.js | 312 + node_modules/nodemailer/package.json | 71 + node_modules/object-assign/index.js | 39 + node_modules/object-assign/license | 21 + node_modules/object-assign/package.json | 70 + node_modules/object-assign/readme.md | 51 + node_modules/on-finished/HISTORY.md | 88 + node_modules/on-finished/LICENSE | 23 + node_modules/on-finished/README.md | 154 + node_modules/on-finished/index.js | 196 + node_modules/on-finished/package.json | 70 + node_modules/on-headers/package.json | 23 +- node_modules/once/package.json | 24 +- node_modules/parseurl/package.json | 23 +- .../passport-local-mongoose/package.json | 21 +- node_modules/passport-local/package.json | 21 +- node_modules/passport-strategy/package.json | 23 +- node_modules/passport/package.json | 21 +- node_modules/path-is-absolute/package.json | 24 +- node_modules/pause/package.json | 13 +- .../process-nextick-args/package.json | 22 - node_modules/random-bytes/package.json | 23 +- node_modules/readable-stream/package.json | 5 +- node_modules/regexp-clone/package.json | 13 +- node_modules/require_optional/package.json | 13 +- node_modules/safe-buffer/package.json | 14 +- node_modules/saslprep/.editorconfig | 10 + node_modules/saslprep/.eslintrc | 17 + node_modules/saslprep/.travis.yml | 5 + node_modules/saslprep/LICENSE | 22 + node_modules/saslprep/index.js | 122 + node_modules/saslprep/lib/code-points.js | 996 + node_modules/saslprep/lib/util.js | 15 + node_modules/saslprep/package.json | 62 + node_modules/saslprep/readme.md | 31 + node_modules/saslprep/test/index.js | 70 + node_modules/saslprep/test/util.js | 15 + node_modules/scmp/package.json | 23 +- node_modules/semver/README.md | 2 +- node_modules/semver/package.json | 12 +- .../node_modules/etag/package.json | 90 +- .../node_modules/fresh/package.json | 102 +- .../node_modules/ms/package.json | 103 +- .../node_modules/parseurl/package.json | 100 +- node_modules/serve-favicon/package.json | 89 +- node_modules/shelljs/package.json | 24 +- node_modules/should/package.json | 21 +- node_modules/sigmund/package.json | 23 +- node_modules/sliced/package.json | 13 +- node_modules/streamsearch/package.json | 13 +- node_modules/strip-json-comments/package.json | 24 +- node_modules/type-detect/package.json | 13 +- node_modules/type-is/HISTORY.md | 236 + node_modules/type-is/LICENSE | 23 + node_modules/type-is/README.md | 146 + node_modules/type-is/index.js | 262 + node_modules/type-is/package.json | 84 + node_modules/typedarray/.travis.yml | 4 + node_modules/typedarray/LICENSE | 35 + node_modules/typedarray/example/tarray.js | 4 + node_modules/typedarray/index.js | 630 + node_modules/typedarray/package.json | 83 + node_modules/typedarray/readme.markdown | 61 + .../typedarray/test/server/undef_globals.js | 19 + node_modules/typedarray/test/tarray.js | 10 + node_modules/uid-safe/package.json | 23 +- node_modules/util-deprecate/package.json | 18 - node_modules/utils-merge/package.json | 13 +- node_modules/wrappy/package.json | 24 +- node_modules/xtend/.jshintrc | 30 + node_modules/xtend/.npmignore | 1 + node_modules/xtend/LICENCE | 19 + node_modules/xtend/Makefile | 4 + node_modules/xtend/README.md | 32 + node_modules/xtend/immutable.js | 19 + node_modules/xtend/mutable.js | 17 + node_modules/xtend/package.json | 86 + node_modules/xtend/test.js | 83 + package-lock.json | 179 +- package.json | 9 +- 617 files changed, 124933 insertions(+), 23230 deletions(-) create mode 100644 ARs/emailServicer.md mode change 100755 => 120000 node_modules/.bin/jade mode change 100755 => 120000 node_modules/.bin/mime create mode 100644 node_modules/buffer-from/LICENSE create mode 100644 node_modules/buffer-from/index.js create mode 100644 node_modules/buffer-from/package.json create mode 100644 node_modules/buffer-from/readme.md create mode 100644 node_modules/concat-stream/LICENSE create mode 100644 node_modules/concat-stream/index.js create mode 100644 node_modules/concat-stream/package.json create mode 100644 node_modules/concat-stream/readme.md create mode 100644 node_modules/ee-first/LICENSE create mode 100644 node_modules/ee-first/README.md create mode 100644 node_modules/ee-first/index.js create mode 100644 node_modules/ee-first/package.json mode change 100755 => 120000 node_modules/express/node_modules/send/node_modules/.bin/mime mode change 100755 => 120000 node_modules/jade/node_modules/.bin/cleancss mode change 100755 => 120000 node_modules/jade/node_modules/.bin/mkdirp mode change 100755 => 120000 node_modules/jade/node_modules/.bin/uglifyjs mode change 100755 => 120000 node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn mode change 100755 => 120000 node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs mode change 100755 => 120000 node_modules/jade/node_modules/with/node_modules/.bin/acorn mode change 100755 => 120000 node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn create mode 100644 node_modules/media-typer/HISTORY.md create mode 100644 node_modules/media-typer/LICENSE create mode 100644 node_modules/media-typer/README.md create mode 100644 node_modules/media-typer/index.js create mode 100644 node_modules/media-typer/package.json create mode 100644 node_modules/mime-db/HISTORY.md create mode 100644 node_modules/mime-db/LICENSE create mode 100644 node_modules/mime-db/README.md create mode 100644 node_modules/mime-db/db.json create mode 100644 node_modules/mime-db/index.js create mode 100644 node_modules/mime-db/package.json create mode 100644 node_modules/mime-types/HISTORY.md create mode 100644 node_modules/mime-types/LICENSE create mode 100644 node_modules/mime-types/README.md create mode 100644 node_modules/mime-types/index.js create mode 100644 node_modules/mime-types/package.json create mode 100644 node_modules/mime/.eslintrc.json create mode 100644 node_modules/mime/.github/ISSUE_TEMPLATE.md create mode 100644 node_modules/mime/.github/PULL_REQUEST_TEMPLATE.md delete mode 100644 node_modules/mime/.npmignore create mode 100644 node_modules/mime/.travis.yml create mode 100644 node_modules/mime/CHANGELOG.md create mode 100644 node_modules/mime/CONTRIBUTING.md delete mode 100644 node_modules/mime/build/build.js delete mode 100644 node_modules/mime/build/test.js create mode 100644 node_modules/mime/index.js create mode 100644 node_modules/mime/lite.js create mode 100644 node_modules/mime/src/README_js.md create mode 100755 node_modules/mime/src/build.js create mode 100644 node_modules/mime/src/test.js delete mode 100644 node_modules/mime/types.json create mode 100644 node_modules/mime/types/other.json create mode 100644 node_modules/mime/types/standard.json rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/.travis.yml (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/LICENSE (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/example/parse.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/index.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/package.json (57%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/readme.markdown (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/dash.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/default_bool.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/dotted.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/long.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/parse.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/parse_modified.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/short.js (100%) rename node_modules/{multer/node_modules/mkdirp/node_modules => }/minimist/test/whitespace.js (100%) create mode 100644 node_modules/mongodb-core/.evergreen/config.yml create mode 100644 node_modules/mongodb-core/.evergreen/install-dependencies.sh create mode 100644 node_modules/mongodb-core/.evergreen/run-atlas-tests.sh create mode 100755 node_modules/mongodb-core/.evergreen/run-tests.sh create mode 100644 node_modules/mongodb-core/CODE_OF_CONDUCT.md create mode 100644 node_modules/mongodb-core/CONTRIBUTING.md create mode 100644 node_modules/mongodb-core/lib/auth/defaultAuthProviders.js create mode 100644 node_modules/mongodb-core/lib/connection/apm.js create mode 100644 node_modules/mongodb-core/lib/sdam/cursor.js create mode 100644 node_modules/mongodb-core/lib/sdam/monitoring.js create mode 100644 node_modules/mongodb-core/lib/sdam/server.js create mode 100644 node_modules/mongodb-core/lib/sdam/server_description.js create mode 100644 node_modules/mongodb-core/lib/sdam/server_selectors.js create mode 100644 node_modules/mongodb-core/lib/sdam/topology.js create mode 100644 node_modules/mongodb-core/lib/sdam/topology_description.js create mode 100644 node_modules/mongodb-core/lib/sessions.js create mode 100644 node_modules/mongodb-core/lib/transactions.js create mode 100644 node_modules/mongodb-core/lib/uri_parser.js create mode 100644 node_modules/mongodb-core/lib/wireprotocol/compression.js create mode 100644 node_modules/mongodb-core/node_modules/bson/HISTORY.md create mode 100644 node_modules/mongodb-core/node_modules/bson/LICENSE.md create mode 100644 node_modules/mongodb-core/node_modules/bson/README.md create mode 100644 node_modules/mongodb-core/node_modules/bson/bower.json create mode 100644 node_modules/mongodb-core/node_modules/bson/browser_build/bson.js create mode 100644 node_modules/mongodb-core/node_modules/bson/browser_build/package.json create mode 100644 node_modules/mongodb-core/node_modules/bson/index.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/binary.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/bson.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/code.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/db_ref.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/decimal128.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/double.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/float_parser.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/int_32.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/long.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/map.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/max_key.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/min_key.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/objectid.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/parser/calculate_size.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/parser/deserializer.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/parser/utils.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/regexp.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/symbol.js create mode 100644 node_modules/mongodb-core/node_modules/bson/lib/bson/timestamp.js create mode 100644 node_modules/mongodb-core/node_modules/bson/package.json create mode 100644 node_modules/mongodb-core/yarn.lock create mode 100644 node_modules/mongodb/.evergreen/_config.template.yml create mode 100644 node_modules/mongodb/.evergreen/config.yml create mode 100644 node_modules/mongodb/.evergreen/generate_evergreen_tasks.js create mode 100644 node_modules/mongodb/.evergreen/install-dependencies.sh create mode 100755 node_modules/mongodb/.evergreen/run-tests.sh create mode 100644 node_modules/mongodb/CHANGES_3.0.0.md create mode 100644 node_modules/mongodb/CODE_OF_CONDUCT.md create mode 100644 node_modules/mongodb/CONTRIBUTING.md create mode 100644 node_modules/mongodb/lib/change_stream.js create mode 100644 node_modules/mongodb/lib/error.js create mode 100644 node_modules/mongodb/lib/operations/admin_ops.js create mode 100644 node_modules/mongodb/lib/operations/collection_ops.js create mode 100644 node_modules/mongodb/lib/operations/cursor_ops.js create mode 100644 node_modules/mongodb/lib/operations/db_ops.js create mode 100644 node_modules/mongodb/lib/operations/mongo_client_ops.js create mode 100644 node_modules/mongodb/lib/topologies/mongos.js create mode 100644 node_modules/mongodb/lib/topologies/replset.js create mode 100644 node_modules/mongodb/lib/topologies/server.js create mode 100644 node_modules/mongodb/lib/topologies/topology_base.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/.coveralls.yml rename node_modules/{mongodb => mongoose/node_modules/mongodb-core}/.eslintrc (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb-core/HISTORY.md create mode 100644 node_modules/mongoose/node_modules/mongodb-core/LICENSE create mode 100644 node_modules/mongoose/node_modules/mongodb-core/Makefile create mode 100644 node_modules/mongoose/node_modules/mongodb-core/README.md rename node_modules/{ => mongoose/node_modules}/mongodb-core/TESTING.md (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb-core/THIRD-PARTY-NOTICES create mode 100644 node_modules/mongoose/node_modules/mongodb-core/conf.json create mode 100644 node_modules/mongoose/node_modules/mongodb-core/index.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/gssapi.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/mongocr.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/plain.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/sspi.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/auth/x509.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/command_result.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/commands.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/logger.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/connection/utils.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/error.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/tools/smoke_plugin.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/mongos.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/read_preference.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset_state.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/topologies/shared.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/utils.js rename node_modules/{ => mongoose/node_modules}/mongodb-core/lib/wireprotocol/2_4_support.js (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js rename node_modules/{ => mongoose/node_modules}/mongodb-core/lib/wireprotocol/commands.js (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/shared.js create mode 100644 node_modules/mongoose/node_modules/mongodb-core/package.json rename node_modules/{ => mongoose/node_modules}/mongodb-core/test.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb-core/test1.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb/.coveralls.yml (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb/.eslintrc create mode 100644 node_modules/mongoose/node_modules/mongodb/HISTORY.md create mode 100644 node_modules/mongoose/node_modules/mongodb/LICENSE create mode 100644 node_modules/mongoose/node_modules/mongodb/Makefile create mode 100644 node_modules/mongoose/node_modules/mongodb/README.md create mode 100644 node_modules/mongoose/node_modules/mongodb/THIRD-PARTY-NOTICES create mode 100644 node_modules/mongoose/node_modules/mongodb/boot_auth.js create mode 100644 node_modules/mongoose/node_modules/mongodb/conf.json create mode 100644 node_modules/mongoose/node_modules/mongodb/index.js create mode 100644 node_modules/mongoose/node_modules/mongodb/insert_bench.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/admin.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/apm.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/authenticate.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/collection.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/cursor.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/db.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js rename node_modules/{ => mongoose/node_modules}/mongodb/lib/metadata.js (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js rename node_modules/{ => mongoose/node_modules}/mongodb/lib/mongos.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb/lib/read_preference.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb/lib/replset.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb/lib/server.js (100%) rename node_modules/{ => mongoose/node_modules}/mongodb/lib/topology_base.js (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/url_parser.js create mode 100644 node_modules/mongoose/node_modules/mongodb/lib/utils.js create mode 100644 node_modules/mongoose/node_modules/mongodb/package.json rename node_modules/{ => mongoose/node_modules}/mongodb/rev.md (100%) create mode 100644 node_modules/mongoose/node_modules/mongodb/yarn.lock mode change 100755 => 120000 node_modules/multer/node_modules/.bin/mkdirp create mode 100644 node_modules/multer/node_modules/append-field/.npmignore create mode 100644 node_modules/multer/node_modules/append-field/LICENSE create mode 100644 node_modules/multer/node_modules/append-field/README.md create mode 100644 node_modules/multer/node_modules/append-field/index.js create mode 100644 node_modules/multer/node_modules/append-field/lib/parse-path.js create mode 100644 node_modules/multer/node_modules/append-field/lib/set-value.js create mode 100644 node_modules/multer/node_modules/append-field/package.json create mode 100644 node_modules/multer/node_modules/append-field/test/forms.js create mode 100644 node_modules/nodemailer/CHANGELOG.md create mode 100644 node_modules/nodemailer/CONTRIBUTING.md create mode 100644 node_modules/nodemailer/LICENSE create mode 100644 node_modules/nodemailer/README.md create mode 100644 node_modules/nodemailer/lib/addressparser/index.js create mode 100644 node_modules/nodemailer/lib/base64/index.js create mode 100644 node_modules/nodemailer/lib/dkim/index.js create mode 100644 node_modules/nodemailer/lib/dkim/message-parser.js create mode 100644 node_modules/nodemailer/lib/dkim/relaxed-body.js create mode 100644 node_modules/nodemailer/lib/dkim/sign.js create mode 100644 node_modules/nodemailer/lib/fetch/cookies.js create mode 100644 node_modules/nodemailer/lib/fetch/index.js create mode 100644 node_modules/nodemailer/lib/json-transport/index.js create mode 100644 node_modules/nodemailer/lib/mail-composer/index.js create mode 100644 node_modules/nodemailer/lib/mailer/index.js create mode 100644 node_modules/nodemailer/lib/mailer/mail-message.js create mode 100644 node_modules/nodemailer/lib/mime-funcs/index.js create mode 100644 node_modules/nodemailer/lib/mime-funcs/mime-types.js create mode 100644 node_modules/nodemailer/lib/mime-node/index.js create mode 100644 node_modules/nodemailer/lib/mime-node/last-newline.js create mode 100644 node_modules/nodemailer/lib/nodemailer.js create mode 100644 node_modules/nodemailer/lib/qp/index.js create mode 100644 node_modules/nodemailer/lib/sendmail-transport/index.js create mode 100644 node_modules/nodemailer/lib/sendmail-transport/le-unix.js create mode 100644 node_modules/nodemailer/lib/sendmail-transport/le-windows.js create mode 100644 node_modules/nodemailer/lib/ses-transport/index.js create mode 100644 node_modules/nodemailer/lib/shared/index.js create mode 100644 node_modules/nodemailer/lib/smtp-connection/data-stream.js create mode 100644 node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js create mode 100644 node_modules/nodemailer/lib/smtp-connection/index.js create mode 100644 node_modules/nodemailer/lib/smtp-pool/index.js create mode 100644 node_modules/nodemailer/lib/smtp-pool/pool-resource.js create mode 100644 node_modules/nodemailer/lib/smtp-transport/index.js create mode 100644 node_modules/nodemailer/lib/stream-transport/index.js create mode 100644 node_modules/nodemailer/lib/well-known/index.js create mode 100644 node_modules/nodemailer/lib/well-known/services.json create mode 100644 node_modules/nodemailer/lib/xoauth2/index.js create mode 100644 node_modules/nodemailer/package.json create mode 100644 node_modules/object-assign/index.js create mode 100644 node_modules/object-assign/license create mode 100644 node_modules/object-assign/package.json create mode 100644 node_modules/object-assign/readme.md create mode 100644 node_modules/on-finished/HISTORY.md create mode 100644 node_modules/on-finished/LICENSE create mode 100644 node_modules/on-finished/README.md create mode 100644 node_modules/on-finished/index.js create mode 100644 node_modules/on-finished/package.json create mode 100644 node_modules/saslprep/.editorconfig create mode 100644 node_modules/saslprep/.eslintrc create mode 100644 node_modules/saslprep/.travis.yml create mode 100644 node_modules/saslprep/LICENSE create mode 100644 node_modules/saslprep/index.js create mode 100644 node_modules/saslprep/lib/code-points.js create mode 100644 node_modules/saslprep/lib/util.js create mode 100644 node_modules/saslprep/package.json create mode 100644 node_modules/saslprep/readme.md create mode 100644 node_modules/saslprep/test/index.js create mode 100644 node_modules/saslprep/test/util.js create mode 100644 node_modules/type-is/HISTORY.md create mode 100644 node_modules/type-is/LICENSE create mode 100644 node_modules/type-is/README.md create mode 100644 node_modules/type-is/index.js create mode 100644 node_modules/type-is/package.json create mode 100644 node_modules/typedarray/.travis.yml create mode 100644 node_modules/typedarray/LICENSE create mode 100644 node_modules/typedarray/example/tarray.js create mode 100644 node_modules/typedarray/index.js create mode 100644 node_modules/typedarray/package.json create mode 100644 node_modules/typedarray/readme.markdown create mode 100644 node_modules/typedarray/test/server/undef_globals.js create mode 100644 node_modules/typedarray/test/tarray.js create mode 100644 node_modules/xtend/.jshintrc create mode 100644 node_modules/xtend/.npmignore create mode 100644 node_modules/xtend/LICENCE create mode 100644 node_modules/xtend/Makefile create mode 100644 node_modules/xtend/README.md create mode 100644 node_modules/xtend/immutable.js create mode 100644 node_modules/xtend/mutable.js create mode 100644 node_modules/xtend/package.json create mode 100644 node_modules/xtend/test.js diff --git a/.gitignore b/.gitignore index 50e8acc..82cd205 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ public/js/super_secret.js *.xml .idea *.swp +playground \ No newline at end of file diff --git a/ARs/applePayReminder.md b/ARs/applePayReminder.md index 460bca7..d2ad1d7 100644 --- a/ARs/applePayReminder.md +++ b/ARs/applePayReminder.md @@ -20,12 +20,17 @@ through Google Sheets (which I hate navigating to). - Each entry will be of the form ```JSON { - name: - month: - daysLate: - paid: + name: "Alice", + month: 0, + daysLate: 2, + paid: false } ``` + - `name`: STRING + - `month`: INT (with values 0-11) + - `datsLate`: INT + - `paid`: BOOL + 2) Set up a cron that populates `apple_pay_records` with X entries for month Y at the beginning of each month. Each entry will correspond to a user. For now, there won't be any entries diff --git a/ARs/emailServicer.md b/ARs/emailServicer.md new file mode 100644 index 0000000..b7de18e --- /dev/null +++ b/ARs/emailServicer.md @@ -0,0 +1,19 @@ +# Architecture Review: Email Servicer +## Goal +I've always wanted my own domain. And I got one (`bryngo.me`). I've always wanted to send emails from said domain, and now it's time to do just that. + +Another motivation for doing this is I want to use the node module `nodemailer` to send out emails. Of course, I can just do this with my gmail, but Google doesn't play nice with such 3rd party services. + +## Steps +1. Follow [this guide](https://www.digitalocean.com/community/tutorials/how-to-run-your-own-mail-server-with-mail-in-a-box-on-ubuntu-14-04) +to figure out how to send emails from my server domain. +2. Install `nodemailer` +3. Done? + +## Testing +1. After setting up the mail server, I'll manually send emails to myself. +2. Once I can verify the mail server work, I can look into connecting it +to the code. + - I can do this by just running the script found [here](https://www.w3schools.com/nodejs/nodejs_email.asp). +## Misc +- This AR isn't really an AR, honestly. It's just some documentation on what I'm doing to my server in case I need reference to it one day. diff --git a/node_modules/.bin/jade b/node_modules/.bin/jade deleted file mode 100755 index a2c509f..0000000 --- a/node_modules/.bin/jade +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var fs = require('fs') - , program = require('commander') - , path = require('path') - , basename = path.basename - , dirname = path.dirname - , resolve = path.resolve - , normalize = path.normalize - , join = path.join - , mkdirp = require('mkdirp') - , jade = require('../'); - -// jade options - -var options = {}; - -// options - -program - .version(require('../package.json').version) - .usage('[options] [dir|file ...]') - .option('-O, --obj ', 'JavaScript options object or JSON file containing it') - .option('-o, --out ', 'output the compiled html to ') - .option('-p, --path ', 'filename used to resolve includes') - .option('-P, --pretty', 'compile pretty html output') - .option('-c, --client', 'compile function for client-side runtime.js') - .option('-n, --name ', 'The name of the compiled template (requires --client)') - .option('-D, --no-debug', 'compile without debugging (smaller functions)') - .option('-w, --watch', 'watch files for changes and automatically re-render') - .option('-E, --extension ', 'specify the output file extension') - .option('-H, --hierarchy', 'keep directory hierarchy when a directory is specified') - .option('--name-after-file', 'Name the template after the last section of the file path (requires --client and overriden by --name)') - .option('--doctype ', 'Specify the doctype on the command line (useful if it is not specified by the template)') - - -program.on('--help', function(){ - console.log(' Examples:'); - console.log(''); - console.log(' # translate jade the templates dir'); - console.log(' $ jade templates'); - console.log(''); - console.log(' # create {foo,bar}.html'); - console.log(' $ jade {foo,bar}.jade'); - console.log(''); - console.log(' # jade over stdio'); - console.log(' $ jade < my.jade > my.html'); - console.log(''); - console.log(' # jade over stdio'); - console.log(' $ echo \'h1 Jade!\' | jade'); - console.log(''); - console.log(' # foo, bar dirs rendering to /tmp'); - console.log(' $ jade foo bar --out /tmp '); - console.log(''); -}); - -program.parse(process.argv); - -// options given, parse them - -if (program.obj) { - options = parseObj(program.obj); -} - -/** - * Parse object either in `input` or in the file called `input`. The latter is - * searched first. - */ -function parseObj (input) { - var str, out; - try { - str = fs.readFileSync(program.obj); - } catch (e) { - return eval('(' + program.obj + ')'); - } - // We don't want to catch exceptions thrown in JSON.parse() so have to - // use this two-step approach. - return JSON.parse(str); -} - -// --path - -if (program.path) options.filename = program.path; - -// --no-debug - -options.compileDebug = program.debug; - -// --client - -options.client = program.client; - -// --pretty - -options.pretty = program.pretty; - -// --watch - -options.watch = program.watch; - -// --name - -if (typeof program.name === 'string') { - options.name = program.name; -} - -// --doctype - -options.doctype = program.doctype; - -// left-over args are file paths - -var files = program.args; - -// array of paths that are being watched - -var watchList = []; - -// function for rendering -var render = program.watch ? tryRender : renderFile; - -// compile files - -if (files.length) { - console.log(); - if (options.watch) { - process.on('SIGINT', function() { - process.exit(1); - }); - } - files.forEach(function (file) { - render(file); - }); - process.on('exit', function () { - console.log(); - }); -// stdio -} else { - stdin(); -} - -/** - * Watch for changes on path - * - * Renders `base` if specified, otherwise renders `path`. - */ -function watchFile(path, base, rootPath) { - path = normalize(path); - if (watchList.indexOf(path) !== -1) return; - console.log(" \033[90mwatching \033[36m%s\033[0m", path); - fs.watchFile(path, {persistent: true, interval: 200}, - function (curr, prev) { - // File doesn't exist anymore. Keep watching. - if (curr.mtime.getTime() === 0) return; - // istanbul ignore if - if (curr.mtime.getTime() === prev.mtime.getTime()) return; - tryRender(base || path, rootPath); - }); - watchList.push(path); -} - -/** - * Convert error to string - */ -function errorToString(e) { - return e.stack || /* istanbul ignore next */ (e.message || e); -} - -/** - * Try to render `path`; if an exception is thrown it is printed to stderr and - * otherwise ignored. - * - * This is used in watch mode. - */ -function tryRender(path, rootPath) { - try { - renderFile(path, rootPath); - } catch (e) { - // keep watching when error occured. - console.error(errorToString(e)); - } -} - -/** - * Compile from stdin. - */ - -function stdin() { - var buf = ''; - process.stdin.setEncoding('utf8'); - process.stdin.on('data', function(chunk){ buf += chunk; }); - process.stdin.on('end', function(){ - var output; - if (options.client) { - output = jade.compileClient(buf, options); - } else { - var fn = jade.compile(buf, options); - var output = fn(options); - } - process.stdout.write(output); - }).resume(); - - process.on('SIGINT', function() { - process.stdout.write('\n'); - process.stdin.emit('end'); - process.stdout.write('\n'); - process.exit(); - }) -} - -var hierarchyWarned = false; - -/** - * Process the given path, compiling the jade files found. - * Always walk the subdirectories. - * - * @param path path of the file, might be relative - * @param rootPath path relative to the directory specified in the command - */ - -function renderFile(path, rootPath) { - var re = /\.jade$/; - var stat = fs.lstatSync(path); - // Found jade file/\.jade$/ - if (stat.isFile() && re.test(path)) { - // Try to watch the file if needed. watchFile takes care of duplicates. - if (options.watch) watchFile(path, null, rootPath); - if (program.nameAfterFile) { - options.name = getNameFromFileName(path); - } - var fn = options.client - ? jade.compileFileClient(path, options) - : jade.compileFile(path, options); - if (options.watch && fn.dependencies) { - // watch dependencies, and recompile the base - fn.dependencies.forEach(function (dep) { - watchFile(dep, path, rootPath); - }); - } - - // --extension - var extname; - if (program.extension) extname = '.' + program.extension; - else if (options.client) extname = '.js'; - else extname = '.html'; - - // path: foo.jade -> foo. - path = path.replace(re, extname); - if (program.out) { - // prepend output directory - if (rootPath && program.hierarchy) { - // replace the rootPath of the resolved path with output directory - path = resolve(path).replace(new RegExp('^' + resolve(rootPath)), ''); - path = join(program.out, path); - } else { - if (rootPath && !hierarchyWarned) { - console.warn('In Jade 2.0.0 --hierarchy will become the default.'); - hierarchyWarned = true; - } - // old behavior or if no rootPath handling is needed - path = join(program.out, basename(path)); - } - } - var dir = resolve(dirname(path)); - mkdirp.sync(dir, 0755); - var output = options.client ? fn : fn(options); - fs.writeFileSync(path, output); - console.log(' \033[90mrendered \033[36m%s\033[0m', normalize(path)); - // Found directory - } else if (stat.isDirectory()) { - var files = fs.readdirSync(path); - files.map(function(filename) { - return path + '/' + filename; - }).forEach(function (file) { - render(file, rootPath || path); - }); - } -} - -/** - * Get a sensible name for a template function from a file path - * - * @param {String} filename - * @returns {String} - */ -function getNameFromFileName(filename) { - var file = basename(filename, '.jade'); - return file.toLowerCase().replace(/[^a-z0-9]+([a-z])/g, function (_, character) { - return character.toUpperCase(); - }) + 'Template'; -} diff --git a/node_modules/.bin/jade b/node_modules/.bin/jade new file mode 120000 index 0000000..65a3bac --- /dev/null +++ b/node_modules/.bin/jade @@ -0,0 +1 @@ +../jade/bin/jade.js \ No newline at end of file diff --git a/node_modules/.bin/mime b/node_modules/.bin/mime deleted file mode 100755 index 20b1ffe..0000000 --- a/node_modules/.bin/mime +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env node - -var mime = require('./mime.js'); -var file = process.argv[2]; -var type = mime.lookup(file); - -process.stdout.write(type + '\n'); - diff --git a/node_modules/.bin/mime b/node_modules/.bin/mime new file mode 120000 index 0000000..fbb7ee0 --- /dev/null +++ b/node_modules/.bin/mime @@ -0,0 +1 @@ +../mime/cli.js \ No newline at end of file diff --git a/node_modules/append-field/package.json b/node_modules/append-field/package.json index 3546137..bedf170 100644 --- a/node_modules/append-field/package.json +++ b/node_modules/append-field/package.json @@ -1,27 +1,31 @@ { - "_from": "append-field", + "_args": [ + [ + "append-field@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "append-field@1.0.0", "_id": "append-field@1.0.0", "_inBundle": false, "_integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=", "_location": "/append-field", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "append-field", + "raw": "append-field@1.0.0", "name": "append-field", "escapedName": "append-field", - "rawSpec": "", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.0.0" }, "_requiredBy": [ - "#USER", "/" ], "_resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", - "_shasum": "1e3440e915f0b1203d23748e78edd7b9b5b43e56", - "_spec": "append-field", + "_spec": "1.0.0", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Linus Unnebäck", @@ -30,8 +34,6 @@ "bugs": { "url": "https://github.com/LinusU/node-append-field/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant field appender (for lack of a better name). Useful for people implementing `application/x-www-form-urlencoded` and `multipart/form-data` parsers.", "devDependencies": { "mocha": "^2.2.4", diff --git a/node_modules/assertion-error/package.json b/node_modules/assertion-error/package.json index 73ffd3b..232b738 100644 --- a/node_modules/assertion-error/package.json +++ b/node_modules/assertion-error/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "assertion-error@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "assertion-error@1.0.0", "_id": "assertion-error@1.0.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/chai" ], "_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz", - "_shasum": "c7f85438fdd466bc7ca16ab90c81513797a5d23b", - "_spec": "assertion-error@1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/chai", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jake Luer", "email": "jake@qualiancy.com", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/chaijs/assertion-error/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification.", "devDependencies": { "component": "*" diff --git a/node_modules/async/package.json b/node_modules/async/package.json index 6d131c3..c5bcd0a 100644 --- a/node_modules/async/package.json +++ b/node_modules/async/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "async@2.6.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "async@2.6.0", "_id": "async@2.6.0", "_inBundle": false, @@ -19,20 +25,17 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "_shasum": "61a29abb6fcc026fea77e56d1c6ec53a795951f4", - "_spec": "async@2.6.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "2.6.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Caolan McMahon" }, "bugs": { "url": "https://github.com/caolan/async/issues" }, - "bundleDependencies": false, "dependencies": { "lodash": "^4.14.0" }, - "deprecated": false, "description": "Higher-order functions and common patterns for asynchronous code", "devDependencies": { "babel-cli": "^6.24.0", diff --git a/node_modules/balanced-match/package.json b/node_modules/balanced-match/package.json index 582a425..de8b9e4 100644 --- a/node_modules/balanced-match/package.json +++ b/node_modules/balanced-match/package.json @@ -1,27 +1,33 @@ { - "_from": "balanced-match@^1.0.0", + "_args": [ + [ + "balanced-match@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "balanced-match@1.0.0", "_id": "balanced-match@1.0.0", "_inBundle": false, "_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "_location": "/balanced-match", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "balanced-match@^1.0.0", + "raw": "balanced-match@1.0.0", "name": "balanced-match", "escapedName": "balanced-match", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/brace-expansion" ], "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767", - "_spec": "balanced-match@^1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/brace-expansion", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", @@ -30,9 +36,7 @@ "bugs": { "url": "https://github.com/juliangruber/balanced-match/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Match balanced character pairs, like \"{\" and \"}\"", "devDependencies": { "matcha": "^0.7.0", diff --git a/node_modules/bluebird/package.json b/node_modules/bluebird/package.json index d2e7554..9279d97 100644 --- a/node_modules/bluebird/package.json +++ b/node_modules/bluebird/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "bluebird@3.5.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "bluebird@3.5.0", "_id": "bluebird@3.5.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/mquery" ], "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", - "_shasum": "791420d7f551eea2897453a8a77653f96606d67c", - "_spec": "bluebird@3.5.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mquery", + "_spec": "3.5.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Petka Antonov", "email": "petka_antonov@hotmail.com", @@ -31,8 +36,6 @@ "bugs": { "url": "http://github.com/petkaantonov/bluebird/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Full featured Promises/A+ implementation with exceptionally good performance", "devDependencies": { "acorn": "~0.6.0", diff --git a/node_modules/body-parser/node_modules/bytes/package.json b/node_modules/body-parser/node_modules/bytes/package.json index bb34928..0cff771 100644 --- a/node_modules/body-parser/node_modules/bytes/package.json +++ b/node_modules/body-parser/node_modules/bytes/package.json @@ -1,12 +1,46 @@ { - "name": "bytes", - "description": "Utility to parse a string bytes to bytes and vice-versa", - "version": "2.4.0", + "_args": [ + [ + "bytes@2.4.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "bytes@2.4.0", + "_id": "bytes@2.4.0", + "_inBundle": false, + "_integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=", + "_location": "/body-parser/bytes", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "bytes@2.4.0", + "name": "bytes", + "escapedName": "bytes", + "rawSpec": "2.4.0", + "saveSpec": null, + "fetchSpec": "2.4.0" + }, + "_requiredBy": [ + "/body-parser", + "/body-parser/raw-body" + ], + "_resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", + "_spec": "2.4.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca", "url": "http://tjholowaychuk.com" }, + "bugs": { + "url": "https://github.com/visionmedia/bytes.js/issues" + }, + "component": { + "scripts": { + "bytes/index.js": "index.js" + } + }, "contributors": [ { "name": "Jed Watson", @@ -17,7 +51,17 @@ "email": "theo.fidry@gmail.com" } ], - "license": "MIT", + "description": "Utility to parse a string bytes to bytes and vice-versa", + "devDependencies": { + "mocha": "1.21.5" + }, + "files": [ + "History.md", + "LICENSE", + "Readme.md", + "index.js" + ], + "homepage": "https://github.com/visionmedia/bytes.js#readme", "keywords": [ "byte", "bytes", @@ -27,58 +71,14 @@ "convert", "converter" ], + "license": "MIT", + "name": "bytes", "repository": { "type": "git", - "url": "https://github.com/visionmedia/bytes.js" + "url": "git+https://github.com/visionmedia/bytes.js.git" }, - "component": { - "scripts": { - "bytes/index.js": "index.js" - } - }, - "devDependencies": { - "mocha": "1.21.5" - }, - "files": [ - "History.md", - "LICENSE", - "Readme.md", - "index.js" - ], "scripts": { "test": "mocha --check-leaks --reporter spec" }, - "gitHead": "2a598442bdfa796df8d01a96cc54495cda550e70", - "bugs": { - "url": "https://github.com/visionmedia/bytes.js/issues" - }, - "homepage": "https://github.com/visionmedia/bytes.js", - "_id": "bytes@2.4.0", - "_shasum": "7d97196f9d5baf7f6935e25985549edd2a6c2339", - "_from": "bytes@2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "7d97196f9d5baf7f6935e25985549edd2a6c2339", - "tarball": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/bytes-2.4.0.tgz_1464812473023_0.6271433881483972" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz" + "version": "2.4.0" } diff --git a/node_modules/body-parser/node_modules/content-type/package.json b/node_modules/body-parser/node_modules/content-type/package.json index 9f11091..8a90e6c 100644 --- a/node_modules/body-parser/node_modules/content-type/package.json +++ b/node_modules/body-parser/node_modules/content-type/package.json @@ -1,70 +1,71 @@ { - "name": "content-type", - "description": "Create and parse HTTP Content-Type header", - "version": "1.0.2", + "_args": [ + [ + "content-type@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "content-type@1.0.2", + "_id": "content-type@1.0.2", + "_inBundle": false, + "_integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=", + "_location": "/body-parser/content-type", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "content-type@1.0.2", + "name": "content-type", + "escapedName": "content-type", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "content-type", - "http", - "req", - "res", - "rfc7231" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/content-type.git" + "bugs": { + "url": "https://github.com/jshttp/content-type/issues" }, + "description": "Create and parse HTTP Content-Type header", "devDependencies": { "istanbul": "0.4.3", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/content-type#readme", + "keywords": [ + "content-type", + "http", + "req", + "res", + "rfc7231" + ], + "license": "MIT", + "name": "content-type", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/content-type.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "8118763adfbbac80cf1254191889330aec8b8be7", - "bugs": { - "url": "https://github.com/jshttp/content-type/issues" - }, - "homepage": "https://github.com/jshttp/content-type#readme", - "_id": "content-type@1.0.2", - "_shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "_from": "content-type@>=1.0.2 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "tarball": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/content-type-1.0.2.tgz_1462852785748_0.5491233412176371" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.2" } diff --git a/node_modules/body-parser/node_modules/debug/node_modules/ms/package.json b/node_modules/body-parser/node_modules/debug/node_modules/ms/package.json index e36489e..4fc4671 100644 --- a/node_modules/body-parser/node_modules/debug/node_modules/ms/package.json +++ b/node_modules/body-parser/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,52 @@ { - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" + "_args": [ + [ + "ms@0.7.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.1", + "_id": "ms@0.7.1", + "_inBundle": false, + "_integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "_location": "/body-parser/debug/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.1", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.1", + "saveSpec": null, + "fetchSpec": "0.7.1" }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" + "_requiredBy": [ + "/body-parser/debug" + ], + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "_spec": "0.7.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" }, "component": { "scripts": { "ms/index.js": "index.js" } }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" + "description": "Tiny ms conversion utility", + "devDependencies": { + "expect.js": "*", + "mocha": "*", + "serve": "*" }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + "homepage": "https://github.com/guille/ms.js#readme", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.7.1" } diff --git a/node_modules/body-parser/node_modules/debug/package.json b/node_modules/body-parser/node_modules/debug/package.json index f2148c9..495eed5 100644 --- a/node_modules/body-parser/node_modules/debug/package.json +++ b/node_modules/body-parser/node_modules/debug/package.json @@ -1,20 +1,46 @@ { - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" + "_args": [ + [ + "debug@2.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "debug@2.2.0", + "_id": "debug@2.2.0", + "_inBundle": false, + "_integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "_location": "/body-parser/debug", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "debug@2.2.0", + "name": "debug", + "escapedName": "debug", + "rawSpec": "2.2.0", + "saveSpec": null, + "fetchSpec": "2.2.0" }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" + "_requiredBy": [ + "/body-parser" ], + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "_spec": "2.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, "contributors": [ { "name": "Nathan Rajlich", @@ -22,52 +48,26 @@ "url": "http://n8.io" } ], - "license": "MIT", "dependencies": { "ms": "0.7.1" }, + "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@>=2.2.0 <2.3.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } + "homepage": "https://github.com/visionmedia/debug#readme", + "keywords": [ + "debug", + "log", + "debugger" ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + "license": "MIT", + "main": "./node.js", + "name": "debug", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.2.0" } diff --git a/node_modules/body-parser/node_modules/depd/package.json b/node_modules/body-parser/node_modules/depd/package.json index edfc0b2..e123176 100644 --- a/node_modules/body-parser/node_modules/depd/package.json +++ b/node_modules/body-parser/node_modules/depd/package.json @@ -1,27 +1,50 @@ { - "name": "depd", - "description": "Deprecate all the things", - "version": "1.1.0", + "_args": [ + [ + "depd@1.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "depd@1.1.0", + "_id": "depd@1.1.0", + "_inBundle": false, + "_integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=", + "_location": "/body-parser/depd", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "depd@1.1.0", + "name": "depd", + "escapedName": "depd", + "rawSpec": "1.1.0", + "saveSpec": null, + "fetchSpec": "1.1.0" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "_spec": "1.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "deprecate", - "deprecated" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/dougwilson/nodejs-depd.git" - }, "browser": "lib/browser/index.js", + "bugs": { + "url": "https://github.com/dougwilson/nodejs-depd/issues" + }, + "description": "Deprecate all the things", "devDependencies": { - "benchmark": "1.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0", "istanbul": "0.3.5", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "lib/", "History.md", @@ -29,8 +52,16 @@ "index.js", "Readme.md" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/dougwilson/nodejs-depd#readme", + "keywords": [ + "deprecate", + "deprecated" + ], + "license": "MIT", + "name": "depd", + "repository": { + "type": "git", + "url": "git+https://github.com/dougwilson/nodejs-depd.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -38,30 +69,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" }, - "gitHead": "78c659de20283e3a6bee92bda455e6daff01686a", - "bugs": { - "url": "https://github.com/dougwilson/nodejs-depd/issues" - }, - "homepage": "https://github.com/dougwilson/nodejs-depd", - "_id": "depd@1.1.0", - "_shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "_from": "depd@>=1.1.0 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "tarball": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.0" } diff --git a/node_modules/body-parser/node_modules/http-errors/node_modules/inherits/package.json b/node_modules/body-parser/node_modules/http-errors/node_modules/inherits/package.json index 092ed55..d093524 100644 --- a/node_modules/body-parser/node_modules/http-errors/node_modules/inherits/package.json +++ b/node_modules/body-parser/node_modules/http-errors/node_modules/inherits/package.json @@ -1,7 +1,45 @@ { - "name": "inherits", + "_args": [ + [ + "inherits@2.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "inherits@2.0.3", + "_id": "inherits@2.0.3", + "_inBundle": false, + "_integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "_location": "/body-parser/http-errors/inherits", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "inherits@2.0.3", + "name": "inherits", + "escapedName": "inherits", + "rawSpec": "2.0.3", + "saveSpec": null, + "fetchSpec": "2.0.3" + }, + "_requiredBy": [ + "/body-parser/http-errors" + ], + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "_spec": "2.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "browser": "./inherits_browser.js", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", - "version": "2.0.3", + "devDependencies": { + "tap": "^7.1.0" + }, + "files": [ + "inherits.js", + "inherits_browser.js" + ], + "homepage": "https://github.com/isaacs/inherits#readme", "keywords": [ "inheritance", "class", @@ -12,52 +50,15 @@ "browser", "browserify" ], + "license": "ISC", "main": "./inherits.js", - "browser": "./inherits_browser.js", + "name": "inherits", "repository": { "type": "git", "url": "git://github.com/isaacs/inherits.git" }, - "license": "ISC", "scripts": { "test": "node test" }, - "devDependencies": { - "tap": "^7.1.0" - }, - "files": [ - "inherits.js", - "inherits_browser.js" - ], - "gitHead": "e05d0fb27c61a3ec687214f0476386b765364d5f", - "bugs": { - "url": "https://github.com/isaacs/inherits/issues" - }, - "homepage": "https://github.com/isaacs/inherits#readme", - "_id": "inherits@2.0.3", - "_shasum": "633c2c83e3da42a502f52466022480f4208261de", - "_from": "inherits@2.0.3", - "_npmVersion": "3.10.7", - "_nodeVersion": "6.5.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "633c2c83e3da42a502f52466022480f4208261de", - "tarball": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/inherits-2.0.3.tgz_1473295776489_0.08142363070510328" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readme": "ERROR: No README data found!" + "version": "2.0.3" } diff --git a/node_modules/body-parser/node_modules/http-errors/node_modules/setprototypeof/package.json b/node_modules/body-parser/node_modules/http-errors/node_modules/setprototypeof/package.json index 33c91f8..f5cb7f1 100644 --- a/node_modules/body-parser/node_modules/http-errors/node_modules/setprototypeof/package.json +++ b/node_modules/body-parser/node_modules/http-errors/node_modules/setprototypeof/package.json @@ -1,53 +1,54 @@ { - "name": "setprototypeof", - "version": "1.0.2", - "description": "A small polyfill for Object.setprototypeof", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/wesleytodd/setprototypeof.git" + "_args": [ + [ + "setprototypeof@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "setprototypeof@1.0.2", + "_id": "setprototypeof@1.0.2", + "_inBundle": false, + "_integrity": "sha1-gaVSFB7BBLiOic44MQOtXGZWTQg=", + "_location": "/body-parser/http-errors/setprototypeof", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "setprototypeof@1.0.2", + "name": "setprototypeof", + "escapedName": "setprototypeof", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" }, - "keywords": [ - "polyfill", - "object", - "setprototypeof" + "_requiredBy": [ + "/body-parser/http-errors" ], + "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Wes Todd" }, - "license": "ISC", "bugs": { "url": "https://github.com/wesleytodd/setprototypeof/issues" }, + "description": "A small polyfill for Object.setprototypeof", "homepage": "https://github.com/wesleytodd/setprototypeof", - "gitHead": "34da239ae7ab69b7b42791d5b928379ce51a0ff2", - "_id": "setprototypeof@1.0.2", - "_shasum": "81a552141ec104b88e89ce383103ad5c66564d08", - "_from": "setprototypeof@1.0.2", - "_npmVersion": "3.10.8", - "_nodeVersion": "7.0.0", - "_npmUser": { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - }, - "dist": { - "shasum": "81a552141ec104b88e89ce383103ad5c66564d08", - "tarball": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz" - }, - "maintainers": [ - { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - } + "keywords": [ + "polyfill", + "object", + "setprototypeof" ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/setprototypeof-1.0.2.tgz_1479056139581_0.43114364007487893" + "license": "ISC", + "main": "index.js", + "name": "setprototypeof", + "repository": { + "type": "git", + "url": "git+https://github.com/wesleytodd/setprototypeof.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", - "readme": "ERROR: No README data found!" + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.0.2" } diff --git a/node_modules/body-parser/node_modules/http-errors/node_modules/statuses/package.json b/node_modules/body-parser/node_modules/http-errors/node_modules/statuses/package.json index f608474..f5eb472 100644 --- a/node_modules/body-parser/node_modules/http-errors/node_modules/statuses/package.json +++ b/node_modules/body-parser/node_modules/http-errors/node_modules/statuses/package.json @@ -1,7 +1,35 @@ { - "name": "statuses", - "description": "HTTP status utility", - "version": "1.3.1", + "_args": [ + [ + "statuses@1.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "statuses@1.3.1", + "_id": "statuses@1.3.1", + "_inBundle": false, + "_integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "_location": "/body-parser/http-errors/statuses", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "statuses@1.3.1", + "name": "statuses", + "escapedName": "statuses", + "rawSpec": "1.3.1", + "saveSpec": null, + "fetchSpec": "1.3.1" + }, + "_requiredBy": [ + "/body-parser/http-errors" + ], + "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "_spec": "1.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/statuses/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,22 +41,7 @@ "url": "http://jongleberry.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/statuses.git" - }, - "license": "MIT", - "keywords": [ - "http", - "status", - "code" - ], - "files": [ - "HISTORY.md", - "index.js", - "codes.json", - "LICENSE" - ], + "description": "HTTP status utility", "devDependencies": { "csv-parse": "1.1.7", "eslint": "3.10.0", @@ -42,6 +55,24 @@ "engines": { "node": ">= 0.6" }, + "files": [ + "HISTORY.md", + "index.js", + "codes.json", + "LICENSE" + ], + "homepage": "https://github.com/jshttp/statuses#readme", + "keywords": [ + "http", + "status", + "code" + ], + "license": "MIT", + "name": "statuses", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/statuses.git" + }, "scripts": { "build": "node scripts/build.js", "fetch": "node scripts/fetch.js", @@ -51,54 +82,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "28a619be77f5b4741e6578a5764c5b06ec6d4aea", - "bugs": { - "url": "https://github.com/jshttp/statuses/issues" - }, - "homepage": "https://github.com/jshttp/statuses", - "_id": "statuses@1.3.1", - "_shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "_from": "statuses@>=1.3.1 <2.0.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/statuses-1.3.1.tgz_1478923281491_0.5574048184789717" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.1" } diff --git a/node_modules/body-parser/node_modules/http-errors/package.json b/node_modules/body-parser/node_modules/http-errors/package.json index 44c1f98..88c8160 100644 --- a/node_modules/body-parser/node_modules/http-errors/package.json +++ b/node_modules/body-parser/node_modules/http-errors/package.json @@ -1,12 +1,40 @@ { - "name": "http-errors", - "description": "Create HTTP error objects", - "version": "1.5.1", + "_args": [ + [ + "http-errors@1.5.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "http-errors@1.5.1", + "_id": "http-errors@1.5.1", + "_inBundle": false, + "_integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=", + "_location": "/body-parser/http-errors", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "http-errors@1.5.1", + "name": "http-errors", + "escapedName": "http-errors", + "rawSpec": "1.5.1", + "saveSpec": null, + "fetchSpec": "1.5.1" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", + "_spec": "1.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/jshttp/http-errors/issues" + }, "contributors": [ { "name": "Alan Plum", @@ -17,16 +45,12 @@ "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/http-errors.git" - }, "dependencies": { "inherits": "2.0.3", "setprototypeof": "1.0.2", "statuses": ">= 1.3.1 < 2" }, + "description": "Create HTTP error objects", "devDependencies": { "eslint": "3.10.2", "eslint-config-standard": "6.2.1", @@ -39,58 +63,28 @@ "engines": { "node": ">= 0.6" }, - "scripts": { - "lint": "eslint --plugin markdown --ext js,md .", - "test": "mocha --reporter spec --bail", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, - "keywords": [ - "http", - "error" - ], "files": [ "index.js", "HISTORY.md", "LICENSE", "README.md" ], - "gitHead": "a55db90c7a2c0bafedb4bfa35a85eee5f53a37e9", - "bugs": { - "url": "https://github.com/jshttp/http-errors/issues" - }, - "homepage": "https://github.com/jshttp/http-errors", - "_id": "http-errors@1.5.1", - "_shasum": "788c0d2c1de2c81b9e6e8c01843b6b97eb920750", - "_from": "http-errors@>=1.5.0 <1.6.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "egeste", - "email": "npm@egeste.net" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } + "homepage": "https://github.com/jshttp/http-errors#readme", + "keywords": [ + "http", + "error" ], - "dist": { - "shasum": "788c0d2c1de2c81b9e6e8c01843b6b97eb920750", - "tarball": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz" + "license": "MIT", + "name": "http-errors", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/http-errors.git" }, - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/http-errors-1.5.1.tgz_1479361411507_0.47469806275330484" + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --bail", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.5.1" } diff --git a/node_modules/body-parser/node_modules/iconv-lite/package.json b/node_modules/body-parser/node_modules/iconv-lite/package.json index 6e72175..a9d432f 100644 --- a/node_modules/body-parser/node_modules/iconv-lite/package.json +++ b/node_modules/body-parser/node_modules/iconv-lite/package.json @@ -1,18 +1,44 @@ { - "name": "iconv-lite", - "description": "Convert character encodings in pure javascript.", - "version": "0.4.13", - "license": "MIT", - "keywords": [ - "iconv", - "convert", - "charset", - "icu" + "_args": [ + [ + "iconv-lite@0.4.13", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "iconv-lite@0.4.13", + "_id": "iconv-lite@0.4.13", + "_inBundle": false, + "_integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "_location": "/body-parser/iconv-lite", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "iconv-lite@0.4.13", + "name": "iconv-lite", + "escapedName": "iconv-lite", + "rawSpec": "0.4.13", + "saveSpec": null, + "fetchSpec": "0.4.13" + }, + "_requiredBy": [ + "/body-parser", + "/body-parser/raw-body" + ], + "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", + "_spec": "0.4.13", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Alexander Shtuchkin", "email": "ashtuchkin@gmail.com" }, + "browser": { + "./extend-node": false, + "./streams": false + }, + "bugs": { + "url": "https://github.com/ashtuchkin/iconv-lite/issues" + }, "contributors": [ { "name": "Jinwu Zhan", @@ -63,56 +89,37 @@ "url": "https://github.com/nleush" } ], - "main": "./lib/index.js", - "homepage": "https://github.com/ashtuchkin/iconv-lite", - "bugs": { - "url": "https://github.com/ashtuchkin/iconv-lite/issues" + "description": "Convert character encodings in pure javascript.", + "devDependencies": { + "async": "*", + "errto": "*", + "iconv": "2.1", + "istanbul": "*", + "mocha": "*", + "request": "2.47", + "unorm": "*" + }, + "engines": { + "node": ">=0.8.0" }, + "homepage": "https://github.com/ashtuchkin/iconv-lite", + "keywords": [ + "iconv", + "convert", + "charset", + "icu" + ], + "license": "MIT", + "main": "./lib/index.js", + "name": "iconv-lite", "repository": { "type": "git", "url": "git://github.com/ashtuchkin/iconv-lite.git" }, - "engines": { - "node": ">=0.8.0" - }, "scripts": { "coverage": "istanbul cover _mocha -- --grep .", "coverage-open": "open coverage/lcov-report/index.html", "test": "mocha --reporter spec --grep ." }, - "browser": { - "./extend-node": false, - "./streams": false - }, - "devDependencies": { - "mocha": "*", - "request": "2.47", - "unorm": "*", - "errto": "*", - "async": "*", - "istanbul": "*", - "iconv": "2.1" - }, - "gitHead": "f5ec51b1e7dd1477a3570824960641eebdc5fbc6", - "_id": "iconv-lite@0.4.13", - "_shasum": "1f88aba4ab0b1508e8312acc39345f36e992e2f2", - "_from": "iconv-lite@0.4.13", - "_npmVersion": "2.14.4", - "_nodeVersion": "4.1.1", - "_npmUser": { - "name": "ashtuchkin", - "email": "ashtuchkin@gmail.com" - }, - "maintainers": [ - { - "name": "ashtuchkin", - "email": "ashtuchkin@gmail.com" - } - ], - "dist": { - "shasum": "1f88aba4ab0b1508e8312acc39345f36e992e2f2", - "tarball": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz" + "version": "0.4.13" } diff --git a/node_modules/body-parser/node_modules/on-finished/node_modules/ee-first/package.json b/node_modules/body-parser/node_modules/on-finished/node_modules/ee-first/package.json index c67faf1..4df7d4c 100644 --- a/node_modules/body-parser/node_modules/on-finished/node_modules/ee-first/package.json +++ b/node_modules/body-parser/node_modules/on-finished/node_modules/ee-first/package.json @@ -1,23 +1,47 @@ { - "name": "ee-first", - "description": "return the first event in a set of ee/event pairs", - "version": "1.1.1", + "_args": [ + [ + "ee-first@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ee-first@1.1.1", + "_id": "ee-first@1.1.1", + "_inBundle": false, + "_integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "_location": "/body-parser/on-finished/ee-first", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ee-first@1.1.1", + "name": "ee-first", + "escapedName": "ee-first", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/body-parser/on-finished" + ], + "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/jonathanong/ee-first/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jonathanong/ee-first.git" - }, + "description": "return the first event in a set of ee/event pairs", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -26,39 +50,17 @@ "index.js", "LICENSE" ], + "homepage": "https://github.com/jonathanong/ee-first#readme", + "license": "MIT", + "name": "ee-first", + "repository": { + "type": "git", + "url": "git+https://github.com/jonathanong/ee-first.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "512e0ce4cc3643f603708f965a97b61b1a9c0441", - "bugs": { - "url": "https://github.com/jonathanong/ee-first/issues" - }, - "homepage": "https://github.com/jonathanong/ee-first", - "_id": "ee-first@1.1.1", - "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "_from": "ee-first@1.1.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "tarball": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.1" } diff --git a/node_modules/body-parser/node_modules/on-finished/package.json b/node_modules/body-parser/node_modules/on-finished/package.json index 97a5680..6afb244 100644 --- a/node_modules/body-parser/node_modules/on-finished/package.json +++ b/node_modules/body-parser/node_modules/on-finished/package.json @@ -1,7 +1,35 @@ { - "name": "on-finished", - "description": "Execute a callback when a request closes, finishes, or errors", - "version": "2.3.0", + "_args": [ + [ + "on-finished@2.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "on-finished@2.3.0", + "_id": "on-finished@2.3.0", + "_inBundle": false, + "_integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "_location": "/body-parser/on-finished", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "on-finished@2.3.0", + "name": "on-finished", + "escapedName": "on-finished", + "rawSpec": "2.3.0", + "saveSpec": null, + "fetchSpec": "2.3.0" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "_spec": "2.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/on-finished/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,14 +41,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/on-finished.git" - }, "dependencies": { "ee-first": "1.1.1" }, + "description": "Execute a callback when a request closes, finishes, or errors", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -33,39 +57,17 @@ "LICENSE", "index.js" ], + "homepage": "https://github.com/jshttp/on-finished#readme", + "license": "MIT", + "name": "on-finished", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-finished.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "34babcb58126a416fcf5205768204f2e12699dda", - "bugs": { - "url": "https://github.com/jshttp/on-finished/issues" - }, - "homepage": "https://github.com/jshttp/on-finished", - "_id": "on-finished@2.3.0", - "_shasum": "20f1336481b083cd75337992a16971aa2d906947", - "_from": "on-finished@>=2.3.0 <2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "20f1336481b083cd75337992a16971aa2d906947", - "tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.3.0" } diff --git a/node_modules/body-parser/node_modules/qs/package.json b/node_modules/body-parser/node_modules/qs/package.json index 265c172..6be7e86 100644 --- a/node_modules/body-parser/node_modules/qs/package.json +++ b/node_modules/body-parser/node_modules/qs/package.json @@ -1,13 +1,35 @@ { - "name": "qs", - "description": "A querystring parser that supports nesting and arrays, with a depth limit", - "homepage": "https://github.com/ljharb/qs", - "version": "6.2.0", - "repository": { - "type": "git", - "url": "git+https://github.com/ljharb/qs.git" + "_args": [ + [ + "qs@6.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "qs@6.2.0", + "_id": "qs@6.2.0", + "_inBundle": false, + "_integrity": "sha1-O3hIwDwt7OaalSKw+ujEEm10Xzs=", + "_location": "/body-parser/qs", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "qs@6.2.0", + "name": "qs", + "escapedName": "qs", + "rawSpec": "6.2.0", + "saveSpec": null, + "fetchSpec": "6.2.0" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", + "_spec": "6.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/ljharb/qs/issues" }, - "main": "lib/index.js", "contributors": [ { "name": "Jordan Harband", @@ -15,72 +37,43 @@ "url": "http://ljharb.codes" } ], - "keywords": [ - "querystring", - "qs" - ], - "engines": { - "node": ">=0.6" - }, "dependencies": {}, + "description": "A querystring parser that supports nesting and arrays, with a depth limit", "devDependencies": { + "@ljharb/eslint-config": "^4.0.0", "browserify": "^13.0.1", - "tape": "^4.5.1", "covert": "^1.1.0", - "mkdirp": "^0.5.1", "eslint": "^2.9.0", - "@ljharb/eslint-config": "^4.0.0", - "parallelshell": "^2.0.0", + "evalmd": "^0.0.17", "iconv-lite": "^0.4.13", - "evalmd": "^0.0.17" + "mkdirp": "^0.5.1", + "parallelshell": "^2.0.0", + "tape": "^4.5.1" }, - "scripts": { - "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", - "test": "npm run --silent coverage", - "tests-only": "node test", - "readme": "evalmd README.md", - "lint": "eslint lib/*.js text/*.js", - "coverage": "covert test", - "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", - "prepublish": "npm run dist" + "engines": { + "node": ">=0.6" }, + "homepage": "https://github.com/ljharb/qs", + "keywords": [ + "querystring", + "qs" + ], "license": "BSD-3-Clause", - "gitHead": "d67d315b606c6bb809fedcbeebbbdb7f863852aa", - "bugs": { - "url": "https://github.com/ljharb/qs/issues" - }, - "_id": "qs@6.2.0", - "_shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "_from": "qs@6.2.0", - "_npmVersion": "3.8.6", - "_nodeVersion": "6.1.0", - "_npmUser": { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - "dist": { - "shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "tarball": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz" + "main": "lib/index.js", + "name": "qs", + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/qs.git" }, - "maintainers": [ - { - "name": "hueniverse", - "email": "eran@hammer.io" - }, - { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - { - "name": "nlf", - "email": "quitlahok@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/qs-6.2.0.tgz_1462749349998_0.03372702235355973" + "scripts": { + "coverage": "covert test", + "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", + "lint": "eslint lib/*.js text/*.js", + "prepublish": "npm run dist", + "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", + "readme": "evalmd README.md", + "test": "npm run --silent coverage", + "tests-only": "node test" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "6.2.0" } diff --git a/node_modules/body-parser/node_modules/raw-body/node_modules/unpipe/package.json b/node_modules/body-parser/node_modules/raw-body/node_modules/unpipe/package.json index ae1b405..b0abd35 100644 --- a/node_modules/body-parser/node_modules/raw-body/node_modules/unpipe/package.json +++ b/node_modules/body-parser/node_modules/raw-body/node_modules/unpipe/package.json @@ -1,59 +1,65 @@ { - "name": "unpipe", - "description": "Unpipe a stream from all destinations", - "version": "1.0.0", + "_args": [ + [ + "unpipe@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "unpipe@1.0.0", + "_id": "unpipe@1.0.0", + "_inBundle": false, + "_integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "_location": "/body-parser/raw-body/unpipe", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "unpipe@1.0.0", + "name": "unpipe", + "escapedName": "unpipe", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/body-parser/raw-body" + ], + "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/unpipe.git" + "bugs": { + "url": "https://github.com/stream-utils/unpipe/issues" }, + "description": "Unpipe a stream from all destinations", "devDependencies": { "istanbul": "0.3.15", "mocha": "2.2.5", "readable-stream": "1.1.13" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/stream-utils/unpipe#readme", + "license": "MIT", + "name": "unpipe", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/unpipe.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "d2df901c06487430e78dca62b6edb8bb2fc5e99d", - "bugs": { - "url": "https://github.com/stream-utils/unpipe/issues" - }, - "homepage": "https://github.com/stream-utils/unpipe", - "_id": "unpipe@1.0.0", - "_shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "_from": "unpipe@1.0.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "tarball": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.0" } diff --git a/node_modules/body-parser/node_modules/raw-body/package.json b/node_modules/body-parser/node_modules/raw-body/package.json index 06694d7..ca5d841 100644 --- a/node_modules/body-parser/node_modules/raw-body/package.json +++ b/node_modules/body-parser/node_modules/raw-body/package.json @@ -1,12 +1,40 @@ { - "name": "raw-body", - "description": "Get and validate the raw body of a readable stream.", - "version": "2.1.7", + "_args": [ + [ + "raw-body@2.1.7", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "raw-body@2.1.7", + "_id": "raw-body@2.1.7", + "_inBundle": false, + "_integrity": "sha1-rf6s4uT7MJgFgBTQjActzFl1h3Q=", + "_location": "/body-parser/raw-body", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "raw-body@2.1.7", + "name": "raw-body", + "escapedName": "raw-body", + "rawSpec": "2.1.7", + "saveSpec": null, + "fetchSpec": "2.1.7" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz", + "_spec": "2.1.7", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/stream-utils/raw-body/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -17,16 +45,12 @@ "email": "raynos2@gmail.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/raw-body.git" - }, "dependencies": { "bytes": "2.4.0", "iconv-lite": "0.4.13", "unpipe": "1.0.0" }, + "description": "Get and validate the raw body of a readable stream.", "devDependencies": { "bluebird": "3.4.1", "eslint": "2.13.0", @@ -47,44 +71,18 @@ "README.md", "index.js" ], + "homepage": "https://github.com/stream-utils/raw-body#readme", + "license": "MIT", + "name": "raw-body", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/raw-body.git" + }, "scripts": { "lint": "eslint **/*.js", "test": "mocha --trace-deprecation --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --trace-deprecation --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --trace-deprecation --reporter spec --check-leaks test/" }, - "gitHead": "9d13a27048cc97958fc14fc12418c6aa76f0b1f9", - "bugs": { - "url": "https://github.com/stream-utils/raw-body/issues" - }, - "homepage": "https://github.com/stream-utils/raw-body#readme", - "_id": "raw-body@2.1.7", - "_shasum": "adfeace2e4fb3098058014d08c072dcc59758774", - "_from": "raw-body@>=2.1.7 <2.2.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "adfeace2e4fb3098058014d08c072dcc59758774", - "tarball": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/raw-body-2.1.7.tgz_1466363663010_0.38383363327011466" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz" + "version": "2.1.7" } diff --git a/node_modules/body-parser/node_modules/type-is/node_modules/media-typer/package.json b/node_modules/body-parser/node_modules/type-is/node_modules/media-typer/package.json index f6d6712..66961ed 100644 --- a/node_modules/body-parser/node_modules/type-is/node_modules/media-typer/package.json +++ b/node_modules/body-parser/node_modules/type-is/node_modules/media-typer/package.json @@ -1,58 +1,64 @@ { - "name": "media-typer", - "description": "Simple RFC 6838 media type parser and formatter", - "version": "0.3.0", + "_args": [ + [ + "media-typer@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "media-typer@0.3.0", + "_id": "media-typer@0.3.0", + "_inBundle": false, + "_integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "_location": "/body-parser/type-is/media-typer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "media-typer@0.3.0", + "name": "media-typer", + "escapedName": "media-typer", + "rawSpec": "0.3.0", + "saveSpec": null, + "fetchSpec": "0.3.0" + }, + "_requiredBy": [ + "/body-parser/type-is" + ], + "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/media-typer.git" + "bugs": { + "url": "https://github.com/jshttp/media-typer/issues" }, + "description": "Simple RFC 6838 media type parser and formatter", "devDependencies": { "istanbul": "0.3.2", "mocha": "~1.21.4", "should": "~4.0.4" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/media-typer#readme", + "license": "MIT", + "name": "media-typer", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/media-typer.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "d49d41ffd0bb5a0655fa44a59df2ec0bfc835b16", - "bugs": { - "url": "https://github.com/jshttp/media-typer/issues" - }, - "homepage": "https://github.com/jshttp/media-typer", - "_id": "media-typer@0.3.0", - "_shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "_from": "media-typer@0.3.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "tarball": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.0" } diff --git a/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json b/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json index 2bbf8d4..7014d89 100644 --- a/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json +++ b/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json @@ -1,7 +1,35 @@ { - "name": "mime-db", - "description": "Media Type Database", - "version": "1.27.0", + "_args": [ + [ + "mime-db@1.27.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-db@1.27.0", + "_id": "mime-db@1.27.0", + "_inBundle": false, + "_integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", + "_location": "/body-parser/type-is/mime-types/mime-db", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-db@1.27.0", + "name": "mime-db", + "escapedName": "mime-db", + "rawSpec": "1.27.0", + "saveSpec": null, + "fetchSpec": "1.27.0" + }, + "_requiredBy": [ + "/body-parser/type-is/mime-types" + ], + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "_spec": "1.27.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,20 +46,7 @@ "url": "http://github.com/broofa" } ], - "license": "MIT", - "keywords": [ - "mime", - "db", - "type", - "types", - "database", - "charset", - "charsets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-db.git" - }, + "description": "Media Type Database", "devDependencies": { "bluebird": "3.5.0", "co": "4.6.0", @@ -47,6 +62,9 @@ "raw-body": "2.2.0", "stream-to-array": "2.3.0" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", @@ -54,8 +72,21 @@ "db.json", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-db#readme", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "license": "MIT", + "name": "mime-db", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" }, "scripts": { "build": "node scripts/build", @@ -66,39 +97,5 @@ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "c232c21378647dfbb7762410c7b025a47f114b94", - "bugs": { - "url": "https://github.com/jshttp/mime-db/issues" - }, - "homepage": "https://github.com/jshttp/mime-db#readme", - "_id": "mime-db@1.27.0", - "_shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "_from": "mime-db@>=1.27.0 <1.28.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-db-1.27.0.tgz_1489722296902_0.15233952621929348" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.27.0" } diff --git a/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/package.json b/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/package.json index 020006a..459720b 100644 --- a/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/package.json +++ b/node_modules/body-parser/node_modules/type-is/node_modules/mime-types/package.json @@ -1,7 +1,35 @@ { - "name": "mime-types", - "description": "The ultimate javascript content-type utility.", - "version": "2.1.15", + "_args": [ + [ + "mime-types@2.1.15", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-types@2.1.15", + "_id": "mime-types@2.1.15", + "_inBundle": false, + "_integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", + "_location": "/body-parser/type-is/mime-types", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-types@2.1.15", + "name": "mime-types", + "escapedName": "mime-types", + "rawSpec": "2.1.15", + "saveSpec": null, + "fetchSpec": "2.1.15" + }, + "_requiredBy": [ + "/body-parser/type-is" + ], + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "_spec": "2.1.15", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,18 +46,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "mime", - "types" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-types.git" - }, "dependencies": { "mime-db": "~1.27.0" }, + "description": "The ultimate javascript content-type utility.", "devDependencies": { "eslint": "3.18.0", "eslint-config-standard": "7.1.0", @@ -38,13 +58,24 @@ "istanbul": "0.4.5", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-types#readme", + "keywords": [ + "mime", + "types" + ], + "license": "MIT", + "name": "mime-types", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" }, "scripts": { "lint": "eslint .", @@ -52,43 +83,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" }, - "gitHead": "c44863eb0463ee16f3eb04576591cc4c4d6b214c", - "bugs": { - "url": "https://github.com/jshttp/mime-types/issues" - }, - "homepage": "https://github.com/jshttp/mime-types#readme", - "_id": "mime-types@2.1.15", - "_shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "_from": "mime-types@>=2.1.15 <2.2.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-types-2.1.15.tgz_1490327753615_0.3609113476704806" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "readme": "ERROR: No README data found!" + "version": "2.1.15" } diff --git a/node_modules/body-parser/node_modules/type-is/package.json b/node_modules/body-parser/node_modules/type-is/package.json index c4aed89..15e6271 100644 --- a/node_modules/body-parser/node_modules/type-is/package.json +++ b/node_modules/body-parser/node_modules/type-is/package.json @@ -1,7 +1,35 @@ { - "name": "type-is", - "description": "Infer the content-type of a request.", - "version": "1.6.15", + "_args": [ + [ + "type-is@1.6.15", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "type-is@1.6.15", + "_id": "type-is@1.6.15", + "_inBundle": false, + "_integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "_location": "/body-parser/type-is", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "type-is@1.6.15", + "name": "type-is", + "escapedName": "type-is", + "rawSpec": "1.6.15", + "saveSpec": null, + "fetchSpec": "1.6.15" + }, + "_requiredBy": [ + "/body-parser" + ], + "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "_spec": "1.6.15", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/type-is/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,15 +41,11 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/type-is.git" - }, "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.15" }, + "description": "Infer the content-type of a request.", "devDependencies": { "eslint": "3.19.0", "eslint-config-standard": "7.1.0", @@ -39,50 +63,23 @@ "HISTORY.md", "index.js" ], - "scripts": { - "lint": "eslint --plugin markdown --ext js,md .", - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, + "homepage": "https://github.com/jshttp/type-is#readme", "keywords": [ "content", "type", "checking" ], - "gitHead": "9e88be851cc628364ad8842433dce32437ea4e73", - "bugs": { - "url": "https://github.com/jshttp/type-is/issues" - }, - "homepage": "https://github.com/jshttp/type-is#readme", - "_id": "type-is@1.6.15", - "_shasum": "cab10fb4909e441c82842eafe1ad646c81804410", - "_from": "type-is@>=1.6.13 <1.7.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "cab10fb4909e441c82842eafe1ad646c81804410", - "tarball": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz" + "license": "MIT", + "name": "type-is", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/type-is.git" }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/type-is-1.6.15.tgz_1491016789014_0.6958203655667603" + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", - "readme": "ERROR: No README data found!" + "version": "1.6.15" } diff --git a/node_modules/body-parser/package.json b/node_modules/body-parser/package.json index 8ae4423..4ba8e10 100644 --- a/node_modules/body-parser/package.json +++ b/node_modules/body-parser/package.json @@ -1,7 +1,35 @@ { - "name": "body-parser", - "description": "Node.js body parsing middleware", - "version": "1.15.2", + "_args": [ + [ + "body-parser@1.15.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "body-parser@1.15.2", + "_id": "body-parser@1.15.2", + "_inBundle": false, + "_integrity": "sha1-11eM9PHRHV9uqATO813Hp/9trmc=", + "_location": "/body-parser", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "body-parser@1.15.2", + "name": "body-parser", + "escapedName": "body-parser", + "rawSpec": "1.15.2", + "saveSpec": null, + "fetchSpec": "1.15.2" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.15.2.tgz", + "_spec": "1.15.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/expressjs/body-parser/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,11 +41,6 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/body-parser.git" - }, "dependencies": { "bytes": "2.4.0", "content-type": "~1.0.2", @@ -30,6 +53,7 @@ "raw-body": "~2.1.7", "type-is": "~1.6.13" }, + "description": "Node.js body parsing middleware", "devDependencies": { "eslint": "2.13.0", "eslint-config-standard": "5.3.1", @@ -40,14 +64,21 @@ "mocha": "2.5.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "lib/", "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/expressjs/body-parser#readme", + "license": "MIT", + "name": "body-parser", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/body-parser.git" }, "scripts": { "lint": "eslint **/*.js", @@ -55,34 +86,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/" }, - "gitHead": "3c8218446d919a5e87fa696971fb7f69b10afc1c", - "bugs": { - "url": "https://github.com/expressjs/body-parser/issues" - }, - "homepage": "https://github.com/expressjs/body-parser#readme", - "_id": "body-parser@1.15.2", - "_shasum": "d7578cf4f1d11d5f6ea804cef35dc7a7ff6dae67", - "_from": "body-parser@>=1.15.2 <1.16.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "d7578cf4f1d11d5f6ea804cef35dc7a7ff6dae67", - "tarball": "https://registry.npmjs.org/body-parser/-/body-parser-1.15.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/body-parser-1.15.2.tgz_1466393694089_0.7908455491997302" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.15.2.tgz" + "version": "1.15.2" } diff --git a/node_modules/brace-expansion/package.json b/node_modules/brace-expansion/package.json index faf146e..cc6921d 100644 --- a/node_modules/brace-expansion/package.json +++ b/node_modules/brace-expansion/package.json @@ -1,28 +1,34 @@ { - "_from": "brace-expansion@^1.1.7", + "_args": [ + [ + "brace-expansion@1.1.11", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "brace-expansion@1.1.11", "_id": "brace-expansion@1.1.11", "_inBundle": false, "_integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "_location": "/brace-expansion", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "brace-expansion@^1.1.7", + "raw": "brace-expansion@1.1.11", "name": "brace-expansion", "escapedName": "brace-expansion", - "rawSpec": "^1.1.7", + "rawSpec": "1.1.11", "saveSpec": null, - "fetchSpec": "^1.1.7" + "fetchSpec": "1.1.11" }, "_requiredBy": [ "/cli/minimatch", "/jshint/minimatch" ], "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "_shasum": "3c7fcbf529d87226f3d2f52b966ff5271eb441dd", - "_spec": "brace-expansion@^1.1.7", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/minimatch", + "_spec": "1.1.11", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", @@ -31,12 +37,10 @@ "bugs": { "url": "https://github.com/juliangruber/brace-expansion/issues" }, - "bundleDependencies": false, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" }, - "deprecated": false, "description": "Brace expansion as known from sh/bash", "devDependencies": { "matcha": "^0.7.0", diff --git a/node_modules/bson/package.json b/node_modules/bson/package.json index b8b72a3..826dc99 100644 --- a/node_modules/bson/package.json +++ b/node_modules/bson/package.json @@ -1,28 +1,33 @@ { - "_from": "bson@~1.0.4", + "_args": [ + [ + "bson@1.0.9", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "bson@1.0.9", "_id": "bson@1.0.9", "_inBundle": false, "_integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg==", "_location": "/bson", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "bson@~1.0.4", + "raw": "bson@1.0.9", "name": "bson", "escapedName": "bson", - "rawSpec": "~1.0.4", + "rawSpec": "1.0.9", "saveSpec": null, - "fetchSpec": "~1.0.4" + "fetchSpec": "1.0.9" }, "_requiredBy": [ - "/mongodb-core", - "/mongoose" + "/mongoose", + "/mongoose/mongodb-core" ], "_resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz", - "_shasum": "12319f8323b1254739b7c6bef8d3e89ae05a2f57", - "_spec": "bson@~1.0.4", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "1.0.9", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Christian Amor Kvalheim", "email": "christkv@gmail.com" @@ -31,12 +36,10 @@ "bugs": { "url": "https://github.com/mongodb/js-bson/issues" }, - "bundleDependencies": false, "config": { "native": false }, "contributors": [], - "deprecated": false, "description": "A bson parser for node.js and the browser", "devDependencies": { "babel-core": "^6.14.0", diff --git a/node_modules/buffer-from/LICENSE b/node_modules/buffer-from/LICENSE new file mode 100644 index 0000000..e4bf1d6 --- /dev/null +++ b/node_modules/buffer-from/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016, 2018 Linus Unnebäck + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/buffer-from/index.js b/node_modules/buffer-from/index.js new file mode 100644 index 0000000..d92a83d --- /dev/null +++ b/node_modules/buffer-from/index.js @@ -0,0 +1,69 @@ +var toString = Object.prototype.toString + +var isModern = ( + typeof Buffer.alloc === 'function' && + typeof Buffer.allocUnsafe === 'function' && + typeof Buffer.from === 'function' +) + +function isArrayBuffer (input) { + return toString.call(input).slice(8, -1) === 'ArrayBuffer' +} + +function fromArrayBuffer (obj, byteOffset, length) { + byteOffset >>>= 0 + + var maxLength = obj.byteLength - byteOffset + + if (maxLength < 0) { + throw new RangeError("'offset' is out of bounds") + } + + if (length === undefined) { + length = maxLength + } else { + length >>>= 0 + + if (length > maxLength) { + throw new RangeError("'length' is out of bounds") + } + } + + return isModern + ? Buffer.from(obj.slice(byteOffset, byteOffset + length)) + : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length))) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + return isModern + ? Buffer.from(string, encoding) + : new Buffer(string, encoding) +} + +function bufferFrom (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (isArrayBuffer(value)) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + return isModern + ? Buffer.from(value) + : new Buffer(value) +} + +module.exports = bufferFrom diff --git a/node_modules/buffer-from/package.json b/node_modules/buffer-from/package.json new file mode 100644 index 0000000..ef524eb --- /dev/null +++ b/node_modules/buffer-from/package.json @@ -0,0 +1,52 @@ +{ + "_from": "buffer-from@^1.0.0", + "_id": "buffer-from@1.1.1", + "_inBundle": false, + "_integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "_location": "/buffer-from", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "buffer-from@^1.0.0", + "name": "buffer-from", + "escapedName": "buffer-from", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/concat-stream" + ], + "_resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "_shasum": "32713bc028f75c02fdb710d7c7bcec1f2c6070ef", + "_spec": "buffer-from@^1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/concat-stream", + "bugs": { + "url": "https://github.com/LinusU/buffer-from/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.", + "devDependencies": { + "standard": "^7.1.2" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/LinusU/buffer-from#readme", + "keywords": [ + "buffer", + "buffer from" + ], + "license": "MIT", + "name": "buffer-from", + "repository": { + "type": "git", + "url": "git+https://github.com/LinusU/buffer-from.git" + }, + "scripts": { + "test": "standard && node test" + }, + "version": "1.1.1" +} diff --git a/node_modules/buffer-from/readme.md b/node_modules/buffer-from/readme.md new file mode 100644 index 0000000..9880a55 --- /dev/null +++ b/node_modules/buffer-from/readme.md @@ -0,0 +1,69 @@ +# Buffer From + +A [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available. + +## Installation + +```sh +npm install --save buffer-from +``` + +## Usage + +```js +const bufferFrom = require('buffer-from') + +console.log(bufferFrom([1, 2, 3, 4])) +//=> + +const arr = new Uint8Array([1, 2, 3, 4]) +console.log(bufferFrom(arr.buffer, 1, 2)) +//=> + +console.log(bufferFrom('test', 'utf8')) +//=> + +const buf = bufferFrom('test') +console.log(bufferFrom(buf)) +//=> +``` + +## API + +### bufferFrom(array) + +- `array` <Array> + +Allocates a new `Buffer` using an `array` of octets. + +### bufferFrom(arrayBuffer[, byteOffset[, length]]) + +- `arrayBuffer` <ArrayBuffer> The `.buffer` property of a TypedArray or ArrayBuffer +- `byteOffset` <Integer> Where to start copying from `arrayBuffer`. **Default:** `0` +- `length` <Integer> How many bytes to copy from `arrayBuffer`. **Default:** `arrayBuffer.length - byteOffset` + +When passed a reference to the `.buffer` property of a TypedArray instance, the +newly created `Buffer` will share the same allocated memory as the TypedArray. + +The optional `byteOffset` and `length` arguments specify a memory range within +the `arrayBuffer` that will be shared by the `Buffer`. + +### bufferFrom(buffer) + +- `buffer` <Buffer> An existing `Buffer` to copy data from + +Copies the passed `buffer` data onto a new `Buffer` instance. + +### bufferFrom(string[, encoding]) + +- `string` <String> A string to encode. +- `encoding` <String> The encoding of `string`. **Default:** `'utf8'` + +Creates a new `Buffer` containing the given JavaScript string `string`. If +provided, the `encoding` parameter identifies the character encoding of +`string`. + +## See also + +- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc` +- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe` diff --git a/node_modules/buffer-shims/package.json b/node_modules/buffer-shims/package.json index 1c7a9f7..eec96eb 100644 --- a/node_modules/buffer-shims/package.json +++ b/node_modules/buffer-shims/package.json @@ -4,16 +4,6 @@ "_inBundle": false, "_integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "_location": "/buffer-shims", - "_nodeVersion": "5.11.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/buffer-shims-1.0.0.tgz_1462560889323_0.8640750856138766" - }, - "_npmUser": { - "name": "cwmma", - "email": "calvin.metcalf@gmail.com" - }, - "_npmVersion": "3.8.6", "_phantomChildren": {}, "_requested": { "type": "range", @@ -41,24 +31,12 @@ "devDependencies": { "tape": "^4.5.1" }, - "directories": {}, - "dist": { - "shasum": "9978ce317388c649ad8793028c3477ef044a8b51", - "tarball": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz" - }, "files": [ "index.js" ], - "gitHead": "ea89b3857ab5b8203957922a84e9a48cf4c47e0a", "homepage": "https://github.com/calvinmetcalf/buffer-shims#readme", "license": "MIT", "main": "index.js", - "maintainers": [ - { - "name": "cwmma", - "email": "calvin.metcalf@gmail.com" - } - ], "name": "buffer-shims", "repository": { "type": "git", diff --git a/node_modules/busboy/node_modules/isarray/package.json b/node_modules/busboy/node_modules/isarray/package.json index 47377ec..b8bbf47 100644 --- a/node_modules/busboy/node_modules/isarray/package.json +++ b/node_modules/busboy/node_modules/isarray/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "isarray@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "isarray@0.0.1", "_id": "isarray@0.0.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/busboy/readable-stream" ], "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_spec": "isarray@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/busboy/node_modules/readable-stream", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/juliangruber/isarray/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Array#isArray for older browsers", "devDependencies": { "tap": "*" diff --git a/node_modules/busboy/node_modules/readable-stream/package.json b/node_modules/busboy/node_modules/readable-stream/package.json index ca55b2a..6618a4e 100644 --- a/node_modules/busboy/node_modules/readable-stream/package.json +++ b/node_modules/busboy/node_modules/readable-stream/package.json @@ -1,27 +1,32 @@ { - "_from": "readable-stream@1.1.x", + "_args": [ + [ + "readable-stream@1.1.14", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "readable-stream@1.1.14", "_id": "readable-stream@1.1.14", "_inBundle": false, "_integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "_location": "/busboy/readable-stream", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "readable-stream@1.1.x", + "raw": "readable-stream@1.1.14", "name": "readable-stream", "escapedName": "readable-stream", - "rawSpec": "1.1.x", + "rawSpec": "1.1.14", "saveSpec": null, - "fetchSpec": "1.1.x" + "fetchSpec": "1.1.14" }, "_requiredBy": [ "/busboy" ], "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "_shasum": "7cf4c54ef648e3813084c636dd2079e166c081d9", - "_spec": "readable-stream@1.1.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/busboy", + "_spec": "1.1.14", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -33,14 +38,12 @@ "bugs": { "url": "https://github.com/isaacs/readable-stream/issues" }, - "bundleDependencies": false, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "0.0.1", "string_decoder": "~0.10.x" }, - "deprecated": false, "description": "Streams3, a user-land copy of the stream library from Node.js v0.11.x", "devDependencies": { "tap": "~0.2.6" diff --git a/node_modules/busboy/node_modules/string_decoder/package.json b/node_modules/busboy/node_modules/string_decoder/package.json index 25d637b..3f3293d 100644 --- a/node_modules/busboy/node_modules/string_decoder/package.json +++ b/node_modules/busboy/node_modules/string_decoder/package.json @@ -1,33 +1,36 @@ { - "_from": "string_decoder@~0.10.x", + "_args": [ + [ + "string_decoder@0.10.31", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "string_decoder@0.10.31", "_id": "string_decoder@0.10.31", "_inBundle": false, "_integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "_location": "/busboy/string_decoder", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "string_decoder@~0.10.x", + "raw": "string_decoder@0.10.31", "name": "string_decoder", "escapedName": "string_decoder", - "rawSpec": "~0.10.x", + "rawSpec": "0.10.31", "saveSpec": null, - "fetchSpec": "~0.10.x" + "fetchSpec": "0.10.31" }, "_requiredBy": [ "/busboy/readable-stream" ], "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", - "_spec": "string_decoder@~0.10.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/busboy/node_modules/readable-stream", + "_spec": "0.10.31", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/rvagg/string_decoder/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "The string_decoder module from Node core", "devDependencies": { "tap": "~0.4.8" diff --git a/node_modules/busboy/package.json b/node_modules/busboy/package.json index 27e8ac6..a7912dd 100644 --- a/node_modules/busboy/package.json +++ b/node_modules/busboy/package.json @@ -1,5 +1,11 @@ { - "_from": "busboy", + "_args": [ + [ + "busboy@0.2.14", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "busboy@0.2.14", "_id": "busboy@0.2.14", "_inBundle": false, "_integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", @@ -9,22 +15,21 @@ "inherits": "2.0.3" }, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "busboy", + "raw": "busboy@0.2.14", "name": "busboy", "escapedName": "busboy", - "rawSpec": "", + "rawSpec": "0.2.14", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "0.2.14" }, "_requiredBy": [ - "#USER", - "/" + "/", + "/multer" ], "_resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", - "_shasum": "6c2a622efcf47c57bbbe1e2a9c37ad36c7925453", - "_spec": "busboy", + "_spec": "0.2.14", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Brian White", @@ -33,12 +38,10 @@ "bugs": { "url": "https://github.com/mscdex/busboy/issues" }, - "bundleDependencies": false, "dependencies": { "dicer": "0.2.5", "readable-stream": "1.1.x" }, - "deprecated": false, "description": "A streaming parser for HTML form data for node.js", "engines": { "node": ">=0.8.0" diff --git a/node_modules/chai/package.json b/node_modules/chai/package.json index c3dc55d..ad85ef6 100644 --- a/node_modules/chai/package.json +++ b/node_modules/chai/package.json @@ -1,26 +1,31 @@ { - "_from": "chai@~1.8.1", + "_args": [ + [ + "chai@1.8.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "chai@1.8.1", "_id": "chai@1.8.1", "_inBundle": false, "_integrity": "sha1-zHeGbV5+vKK9dRRLHtw3Coh4X3I=", "_location": "/chai", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "chai@~1.8.1", + "raw": "chai@1.8.1", "name": "chai", "escapedName": "chai", - "rawSpec": "~1.8.1", + "rawSpec": "1.8.1", "saveSpec": null, - "fetchSpec": "~1.8.1" + "fetchSpec": "1.8.1" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/chai/-/chai-1.8.1.tgz", - "_shasum": "cc77866d5e7ebca2bd75144b1edc370a88785f72", - "_spec": "chai@~1.8.1", + "_spec": "1.8.1", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jake Luer", @@ -29,7 +34,6 @@ "bugs": { "url": "https://github.com/chaijs/chai/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Jake Luer", @@ -53,7 +57,6 @@ "assertion-error": "1.0.0", "deep-eql": "0.1.3" }, - "deprecated": false, "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.", "devDependencies": { "component": "*", diff --git a/node_modules/cli/node_modules/glob/package.json b/node_modules/cli/node_modules/glob/package.json index c9d6fbf..7f19c19 100644 --- a/node_modules/cli/node_modules/glob/package.json +++ b/node_modules/cli/node_modules/glob/package.json @@ -1,27 +1,33 @@ { - "_from": "glob@^7.1.1", + "_args": [ + [ + "glob@7.1.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "glob@7.1.2", "_id": "glob@7.1.2", "_inBundle": false, "_integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "_location": "/cli/glob", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "glob@^7.1.1", + "raw": "glob@7.1.2", "name": "glob", "escapedName": "glob", - "rawSpec": "^7.1.1", + "rawSpec": "7.1.2", "saveSpec": null, - "fetchSpec": "^7.1.1" + "fetchSpec": "7.1.2" }, "_requiredBy": [ "/cli" ], "_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "_shasum": "c19c9df9a028702d678612384a6552404c636d15", - "_spec": "glob@^7.1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli", + "_spec": "7.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,7 +36,6 @@ "bugs": { "url": "https://github.com/isaacs/node-glob/issues" }, - "bundleDependencies": false, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -39,7 +44,6 @@ "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, - "deprecated": false, "description": "a little globber", "devDependencies": { "mkdirp": "0", diff --git a/node_modules/cli/node_modules/minimatch/package.json b/node_modules/cli/node_modules/minimatch/package.json index 0759bf5..a454428 100644 --- a/node_modules/cli/node_modules/minimatch/package.json +++ b/node_modules/cli/node_modules/minimatch/package.json @@ -1,27 +1,33 @@ { - "_from": "minimatch@^3.0.4", + "_args": [ + [ + "minimatch@3.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "minimatch@3.0.4", "_id": "minimatch@3.0.4", "_inBundle": false, "_integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "_location": "/cli/minimatch", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "minimatch@^3.0.4", + "raw": "minimatch@3.0.4", "name": "minimatch", "escapedName": "minimatch", - "rawSpec": "^3.0.4", + "rawSpec": "3.0.4", "saveSpec": null, - "fetchSpec": "^3.0.4" + "fetchSpec": "3.0.4" }, "_requiredBy": [ "/cli/glob" ], "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "_shasum": "5166e286457f03306064be5497e8dbb0c3d32083", - "_spec": "minimatch@^3.0.4", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/glob", + "_spec": "3.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,11 +36,9 @@ "bugs": { "url": "https://github.com/isaacs/minimatch/issues" }, - "bundleDependencies": false, "dependencies": { "brace-expansion": "^1.1.7" }, - "deprecated": false, "description": "a glob matcher in javascript", "devDependencies": { "tap": "^10.3.2" diff --git a/node_modules/cli/package.json b/node_modules/cli/package.json index f9d9b0a..2a60ee5 100755 --- a/node_modules/cli/package.json +++ b/node_modules/cli/package.json @@ -1,5 +1,12 @@ { - "_from": "cli@~1.0.0", + "_args": [ + [ + "cli@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "cli@1.0.1", "_id": "cli@1.0.1", "_inBundle": false, "_integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", @@ -13,22 +20,21 @@ "path-is-absolute": "1.0.1" }, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "cli@~1.0.0", + "raw": "cli@1.0.1", "name": "cli", "escapedName": "cli", - "rawSpec": "~1.0.0", + "rawSpec": "1.0.1", "saveSpec": null, - "fetchSpec": "~1.0.0" + "fetchSpec": "1.0.1" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "_shasum": "22817534f24bfa4950c34d532d48ecbc621b8c14", - "_spec": "cli@~1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Chris O'Hara", "email": "cohara87@gmail.com" @@ -36,7 +42,6 @@ "bugs": { "url": "http://github.com/node-js-libs/cli/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Meyer" @@ -46,7 +51,6 @@ "exit": "0.1.2", "glob": "^7.1.1" }, - "deprecated": false, "description": "A tool for rapidly building command line apps", "engines": { "node": ">=0.2.5" diff --git a/node_modules/commander/package.json b/node_modules/commander/package.json index 921dff9..1b6e06e 100644 --- a/node_modules/commander/package.json +++ b/node_modules/commander/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "commander@2.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "commander@2.0.0", "_id": "commander@2.0.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/mocha" ], "_resolved": "https://registry.npmjs.org/commander/-/commander-2.0.0.tgz", - "_shasum": "d1b86f901f8b64bd941bdeadaf924530393be928", - "_spec": "commander@2.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mocha", + "_spec": "2.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/visionmedia/commander.js/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "the complete solution for node.js command-line programs", "devDependencies": { "should": ">= 0.0.1" diff --git a/node_modules/concat-map/package.json b/node_modules/concat-map/package.json index 3f8afaa..77f8884 100644 --- a/node_modules/concat-map/package.json +++ b/node_modules/concat-map/package.json @@ -1,4 +1,11 @@ { + "_args": [ + [ + "concat-map@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, "_from": "concat-map@0.0.1", "_id": "concat-map@0.0.1", "_inBundle": false, @@ -19,9 +26,8 @@ "/brace-expansion" ], "_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b", - "_spec": "concat-map@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/brace-expansion", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "James Halliday", "email": "mail@substack.net", @@ -30,8 +36,6 @@ "bugs": { "url": "https://github.com/substack/node-concat-map/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "concatenative mapdashery", "devDependencies": { "tape": "~2.4.0" diff --git a/node_modules/concat-stream/LICENSE b/node_modules/concat-stream/LICENSE new file mode 100644 index 0000000..99c130e --- /dev/null +++ b/node_modules/concat-stream/LICENSE @@ -0,0 +1,24 @@ +The MIT License + +Copyright (c) 2013 Max Ogden + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/concat-stream/index.js b/node_modules/concat-stream/index.js new file mode 100644 index 0000000..dd672a7 --- /dev/null +++ b/node_modules/concat-stream/index.js @@ -0,0 +1,144 @@ +var Writable = require('readable-stream').Writable +var inherits = require('inherits') +var bufferFrom = require('buffer-from') + +if (typeof Uint8Array === 'undefined') { + var U8 = require('typedarray').Uint8Array +} else { + var U8 = Uint8Array +} + +function ConcatStream(opts, cb) { + if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb) + + if (typeof opts === 'function') { + cb = opts + opts = {} + } + if (!opts) opts = {} + + var encoding = opts.encoding + var shouldInferEncoding = false + + if (!encoding) { + shouldInferEncoding = true + } else { + encoding = String(encoding).toLowerCase() + if (encoding === 'u8' || encoding === 'uint8') { + encoding = 'uint8array' + } + } + + Writable.call(this, { objectMode: true }) + + this.encoding = encoding + this.shouldInferEncoding = shouldInferEncoding + + if (cb) this.on('finish', function () { cb(this.getBody()) }) + this.body = [] +} + +module.exports = ConcatStream +inherits(ConcatStream, Writable) + +ConcatStream.prototype._write = function(chunk, enc, next) { + this.body.push(chunk) + next() +} + +ConcatStream.prototype.inferEncoding = function (buff) { + var firstBuffer = buff === undefined ? this.body[0] : buff; + if (Buffer.isBuffer(firstBuffer)) return 'buffer' + if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array' + if (Array.isArray(firstBuffer)) return 'array' + if (typeof firstBuffer === 'string') return 'string' + if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object' + return 'buffer' +} + +ConcatStream.prototype.getBody = function () { + if (!this.encoding && this.body.length === 0) return [] + if (this.shouldInferEncoding) this.encoding = this.inferEncoding() + if (this.encoding === 'array') return arrayConcat(this.body) + if (this.encoding === 'string') return stringConcat(this.body) + if (this.encoding === 'buffer') return bufferConcat(this.body) + if (this.encoding === 'uint8array') return u8Concat(this.body) + return this.body +} + +var isArray = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]' +} + +function isArrayish (arr) { + return /Array\]$/.test(Object.prototype.toString.call(arr)) +} + +function isBufferish (p) { + return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function') +} + +function stringConcat (parts) { + var strings = [] + var needsToString = false + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (typeof p === 'string') { + strings.push(p) + } else if (Buffer.isBuffer(p)) { + strings.push(p) + } else if (isBufferish(p)) { + strings.push(bufferFrom(p)) + } else { + strings.push(bufferFrom(String(p))) + } + } + if (Buffer.isBuffer(parts[0])) { + strings = Buffer.concat(strings) + strings = strings.toString('utf8') + } else { + strings = strings.join('') + } + return strings +} + +function bufferConcat (parts) { + var bufs = [] + for (var i = 0; i < parts.length; i++) { + var p = parts[i] + if (Buffer.isBuffer(p)) { + bufs.push(p) + } else if (isBufferish(p)) { + bufs.push(bufferFrom(p)) + } else { + bufs.push(bufferFrom(String(p))) + } + } + return Buffer.concat(bufs) +} + +function arrayConcat (parts) { + var res = [] + for (var i = 0; i < parts.length; i++) { + res.push.apply(res, parts[i]) + } + return res +} + +function u8Concat (parts) { + var len = 0 + for (var i = 0; i < parts.length; i++) { + if (typeof parts[i] === 'string') { + parts[i] = bufferFrom(parts[i]) + } + len += parts[i].length + } + var u8 = new U8(len) + for (var i = 0, offset = 0; i < parts.length; i++) { + var part = parts[i] + for (var j = 0; j < part.length; j++) { + u8[offset++] = part[j] + } + } + return u8 +} diff --git a/node_modules/concat-stream/package.json b/node_modules/concat-stream/package.json new file mode 100644 index 0000000..564d9c8 --- /dev/null +++ b/node_modules/concat-stream/package.json @@ -0,0 +1,84 @@ +{ + "_from": "concat-stream@^1.5.2", + "_id": "concat-stream@1.6.2", + "_inBundle": false, + "_integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "_location": "/concat-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "concat-stream@^1.5.2", + "name": "concat-stream", + "escapedName": "concat-stream", + "rawSpec": "^1.5.2", + "saveSpec": null, + "fetchSpec": "^1.5.2" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "_shasum": "904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34", + "_spec": "concat-stream@^1.5.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "author": { + "name": "Max Ogden", + "email": "max@maxogden.com" + }, + "bugs": { + "url": "http://github.com/maxogden/concat-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "deprecated": false, + "description": "writable stream that concatenates strings or binary data and calls a callback with the result", + "devDependencies": { + "tape": "^4.6.3" + }, + "engines": [ + "node >= 0.8" + ], + "files": [ + "index.js" + ], + "homepage": "https://github.com/maxogden/concat-stream#readme", + "license": "MIT", + "main": "index.js", + "name": "concat-stream", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/maxogden/concat-stream.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "tags": [ + "stream", + "simple", + "util", + "utility" + ], + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "1.6.2" +} diff --git a/node_modules/concat-stream/readme.md b/node_modules/concat-stream/readme.md new file mode 100644 index 0000000..7aa19c4 --- /dev/null +++ b/node_modules/concat-stream/readme.md @@ -0,0 +1,102 @@ +# concat-stream + +Writable stream that concatenates all the data from a stream and calls a callback with the result. Use this when you want to collect all the data from a stream into a single buffer. + +[![Build Status](https://travis-ci.org/maxogden/concat-stream.svg?branch=master)](https://travis-ci.org/maxogden/concat-stream) + +[![NPM](https://nodei.co/npm/concat-stream.png)](https://nodei.co/npm/concat-stream/) + +### description + +Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you. + +Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM). + +There are also `objectMode` streams that emit things other than Buffers, and you can concatenate these too. See below for details. + +## Related + +`concat-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. + +### examples + +#### Buffers + +```js +var fs = require('fs') +var concat = require('concat-stream') + +var readStream = fs.createReadStream('cat.png') +var concatStream = concat(gotPicture) + +readStream.on('error', handleError) +readStream.pipe(concatStream) + +function gotPicture(imageBuffer) { + // imageBuffer is all of `cat.png` as a node.js Buffer +} + +function handleError(err) { + // handle your error appropriately here, e.g.: + console.error(err) // print the error to STDERR + process.exit(1) // exit program with non-zero exit code +} + +``` + +#### Arrays + +```js +var write = concat(function(data) {}) +write.write([1,2,3]) +write.write([4,5,6]) +write.end() +// data will be [1,2,3,4,5,6] in the above callback +``` + +#### Uint8Arrays + +```js +var write = concat(function(data) {}) +var a = new Uint8Array(3) +a[0] = 97; a[1] = 98; a[2] = 99 +write.write(a) +write.write('!') +write.end(Buffer.from('!!1')) +``` + +See `test/` for more examples + +# methods + +```js +var concat = require('concat-stream') +``` + +## var writable = concat(opts={}, cb) + +Return a `writable` stream that will fire `cb(data)` with all of the data that +was written to the stream. Data can be written to `writable` as strings, +Buffers, arrays of byte integers, and Uint8Arrays. + +By default `concat-stream` will give you back the same data type as the type of the first buffer written to the stream. Use `opts.encoding` to set what format `data` should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason. + +* `string` - get a string +* `buffer` - get back a Buffer +* `array` - get an array of byte integers +* `uint8array`, `u8`, `uint8` - get back a Uint8Array +* `object`, get back an array of Objects + +If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`. + +If nothing is written to `writable` then `data` will be an empty array `[]`. + +# error handling + +`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors. + +We recommend using [`end-of-stream`](https://npmjs.org/end-of-stream) or [`pump`](https://npmjs.org/pump) for writing error tolerant stream code. + +# license + +MIT LICENSE diff --git a/node_modules/connect-flash/package.json b/node_modules/connect-flash/package.json index 8ad9a6a..7499e60 100644 --- a/node_modules/connect-flash/package.json +++ b/node_modules/connect-flash/package.json @@ -1,26 +1,31 @@ { - "_from": "connect-flash@^0.1.1", + "_args": [ + [ + "connect-flash@0.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "connect-flash@0.1.1", "_id": "connect-flash@0.1.1", "_inBundle": false, "_integrity": "sha1-2GMPJtlaf4UfmVax6MxnMvO2qjA=", "_location": "/connect-flash", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "connect-flash@^0.1.1", + "raw": "connect-flash@0.1.1", "name": "connect-flash", "escapedName": "connect-flash", - "rawSpec": "^0.1.1", + "rawSpec": "0.1.1", "saveSpec": null, - "fetchSpec": "^0.1.1" + "fetchSpec": "0.1.1" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/connect-flash/-/connect-flash-0.1.1.tgz", - "_shasum": "d8630f26d95a7f851f9956b1e8cc6732f3b6aa30", - "_spec": "connect-flash@^0.1.1", + "_spec": "0.1.1", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", @@ -30,9 +35,7 @@ "bugs": { "url": "http://github.com/jaredhanson/connect-flash/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Flash message middleware for Connect.", "devDependencies": { "vows": "0.6.x" diff --git a/node_modules/console-browserify/package.json b/node_modules/console-browserify/package.json index 851058f..73bce49 100644 --- a/node_modules/console-browserify/package.json +++ b/node_modules/console-browserify/package.json @@ -1,27 +1,33 @@ { - "_from": "console-browserify@1.1.x", + "_args": [ + [ + "console-browserify@1.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "console-browserify@1.1.0", "_id": "console-browserify@1.1.0", "_inBundle": false, "_integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "_location": "/console-browserify", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "console-browserify@1.1.x", + "raw": "console-browserify@1.1.0", "name": "console-browserify", "escapedName": "console-browserify", - "rawSpec": "1.1.x", + "rawSpec": "1.1.0", "saveSpec": null, - "fetchSpec": "1.1.x" + "fetchSpec": "1.1.0" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "_shasum": "f0241c45730a9fc6323b206dbf38edc741d0bb10", - "_spec": "console-browserify@1.1.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "1.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Raynos", "email": "raynos2@gmail.com" @@ -30,7 +36,6 @@ "url": "https://github.com/Raynos/console-browserify/issues", "email": "raynos2@gmail.com" }, - "bundleDependencies": false, "contributors": [ { "name": "Raynos" @@ -39,7 +44,6 @@ "dependencies": { "date-now": "^0.1.4" }, - "deprecated": false, "description": "Emulate console for all the browsers", "devDependencies": { "jsonify": "0.0.0", diff --git a/node_modules/cookie-parser/node_modules/cookie-signature/package.json b/node_modules/cookie-parser/node_modules/cookie-signature/package.json index f564ea5..1fcc127 100644 --- a/node_modules/cookie-parser/node_modules/cookie-signature/package.json +++ b/node_modules/cookie-parser/node_modules/cookie-signature/package.json @@ -1,59 +1,60 @@ { - "name": "cookie-signature", - "version": "1.0.6", - "description": "Sign and unsign cookies", - "keywords": [ - "cookie", - "sign", - "unsign" + "_args": [ + [ + "cookie-signature@1.0.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cookie-signature@1.0.6", + "_id": "cookie-signature@1.0.6", + "_inBundle": false, + "_integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "_location": "/cookie-parser/cookie-signature", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cookie-signature@1.0.6", + "name": "cookie-signature", + "escapedName": "cookie-signature", + "rawSpec": "1.0.6", + "saveSpec": null, + "fetchSpec": "1.0.6" + }, + "_requiredBy": [ + "/cookie-parser" ], + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "_spec": "1.0.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@learnboost.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/visionmedia/node-cookie-signature.git" + "bugs": { + "url": "https://github.com/visionmedia/node-cookie-signature/issues" }, "dependencies": {}, + "description": "Sign and unsign cookies", "devDependencies": { "mocha": "*", "should": "*" }, - "scripts": { - "test": "mocha --require should --reporter spec" - }, + "homepage": "https://github.com/visionmedia/node-cookie-signature#readme", + "keywords": [ + "cookie", + "sign", + "unsign" + ], + "license": "MIT", "main": "index", - "gitHead": "391b56cf44d88c493491b7e3fc53208cfb976d2a", - "bugs": { - "url": "https://github.com/visionmedia/node-cookie-signature/issues" - }, - "homepage": "https://github.com/visionmedia/node-cookie-signature", - "_id": "cookie-signature@1.0.6", - "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "_from": "cookie-signature@1.0.6", - "_npmVersion": "2.3.0", - "_nodeVersion": "0.10.36", - "_npmUser": { - "name": "natevw", - "email": "natevw@yahoo.com" + "name": "cookie-signature", + "repository": { + "type": "git", + "url": "git+https://github.com/visionmedia/node-cookie-signature.git" }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "natevw", - "email": "natevw@yahoo.com" - } - ], - "dist": { - "shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "tarball": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" + "scripts": { + "test": "mocha --require should --reporter spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.6" } diff --git a/node_modules/cookie-parser/node_modules/cookie/package.json b/node_modules/cookie-parser/node_modules/cookie/package.json index bb3556a..6dd924c 100644 --- a/node_modules/cookie-parser/node_modules/cookie/package.json +++ b/node_modules/cookie-parser/node_modules/cookie/package.json @@ -1,72 +1,74 @@ { - "name": "cookie", - "description": "HTTP server cookie parsing and serialization", - "version": "0.3.1", + "_args": [ + [ + "cookie@0.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cookie@0.3.1", + "_id": "cookie@0.3.1", + "_inBundle": false, + "_integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "_location": "/cookie-parser/cookie", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cookie@0.3.1", + "name": "cookie", + "escapedName": "cookie", + "rawSpec": "0.3.1", + "saveSpec": null, + "fetchSpec": "0.3.1" + }, + "_requiredBy": [ + "/cookie-parser" + ], + "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "_spec": "0.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Roman Shtylman", "email": "shtylman@gmail.com" }, + "bugs": { + "url": "https://github.com/jshttp/cookie/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "keywords": [ - "cookie", - "cookies" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/cookie.git" - }, + "description": "HTTP server cookie parsing and serialization", "devDependencies": { "istanbul": "0.4.3", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/cookie#readme", + "keywords": [ + "cookie", + "cookies" + ], + "license": "MIT", + "name": "cookie", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/cookie.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "e3c77d497d66c8b8d4b677b8954c1b192a09f0b3", - "bugs": { - "url": "https://github.com/jshttp/cookie/issues" - }, - "homepage": "https://github.com/jshttp/cookie", - "_id": "cookie@0.3.1", - "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "_from": "cookie@0.3.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "tarball": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/cookie-0.3.1.tgz_1464323556714_0.6435900838114321" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.1" } diff --git a/node_modules/cookie-parser/package.json b/node_modules/cookie-parser/package.json index e1a2287..754f8bf 100644 --- a/node_modules/cookie-parser/package.json +++ b/node_modules/cookie-parser/package.json @@ -1,81 +1,79 @@ { - "name": "cookie-parser", - "description": "cookie parsing with signatures", - "version": "1.4.3", + "_args": [ + [ + "cookie-parser@1.4.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cookie-parser@1.4.3", + "_id": "cookie-parser@1.4.3", + "_inBundle": false, + "_integrity": "sha1-D+MfoZ0AC5X0qt8fU/3CuKIDuqU=", + "_location": "/cookie-parser", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cookie-parser@1.4.3", + "name": "cookie-parser", + "escapedName": "cookie-parser", + "rawSpec": "1.4.3", + "saveSpec": null, + "fetchSpec": "1.4.3" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz", + "_spec": "1.4.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca", "url": "http://tjholowaychuk.com" }, + "bugs": { + "url": "https://github.com/expressjs/cookie-parser/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/cookie-parser.git" - }, - "keywords": [ - "cookie", - "middleware" - ], "dependencies": { "cookie": "0.3.1", "cookie-signature": "1.0.6" }, + "description": "cookie parsing with signatures", "devDependencies": { "istanbul": "0.4.3", "mocha": "2.5.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8.0" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.8.0" + "homepage": "https://github.com/expressjs/cookie-parser#readme", + "keywords": [ + "cookie", + "middleware" + ], + "license": "MIT", + "name": "cookie-parser", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/cookie-parser.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "ad0b2cb834affe3929f0a690cd0494cd0b96d6be", - "bugs": { - "url": "https://github.com/expressjs/cookie-parser/issues" - }, - "homepage": "https://github.com/expressjs/cookie-parser", - "_id": "cookie-parser@1.4.3", - "_shasum": "0fe31fa19d000b95f4aadf1f53fdc2b8a203baa5", - "_from": "cookie-parser@>=1.4.3 <1.5.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "0fe31fa19d000b95f4aadf1f53fdc2b8a203baa5", - "tarball": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/cookie-parser-1.4.3.tgz_1464325360032_0.20419598533771932" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz", - "readme": "ERROR: No README data found!" + "version": "1.4.3" } diff --git a/node_modules/cookie-signature/package.json b/node_modules/cookie-signature/package.json index 334f253..08c85e9 100644 --- a/node_modules/cookie-signature/package.json +++ b/node_modules/cookie-signature/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "cookie-signature@1.0.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "cookie-signature@1.0.6", "_id": "cookie-signature@1.0.6", "_inBundle": false, @@ -19,9 +25,8 @@ "/express-session" ], "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "_spec": "cookie-signature@1.0.6", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "1.0.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@learnboost.com" @@ -29,9 +34,7 @@ "bugs": { "url": "https://github.com/visionmedia/node-cookie-signature/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Sign and unsign cookies", "devDependencies": { "mocha": "*", diff --git a/node_modules/cookie/package.json b/node_modules/cookie/package.json index e382063..8003b21 100644 --- a/node_modules/cookie/package.json +++ b/node_modules/cookie/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "cookie@0.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "cookie@0.3.1", "_id": "cookie@0.3.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/express-session" ], "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "_spec": "cookie@0.3.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "0.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Roman Shtylman", "email": "shtylman@gmail.com" @@ -29,14 +34,12 @@ "bugs": { "url": "https://github.com/jshttp/cookie/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "deprecated": false, "description": "HTTP server cookie parsing and serialization", "devDependencies": { "istanbul": "0.4.3", diff --git a/node_modules/core-util-is/package.json b/node_modules/core-util-is/package.json index 1434ead..4d06348 100644 --- a/node_modules/core-util-is/package.json +++ b/node_modules/core-util-is/package.json @@ -1,33 +1,35 @@ { - "_from": "core-util-is@~1.0.0", + "_args": [ + [ + "core-util-is@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "core-util-is@1.0.2", "_id": "core-util-is@1.0.2", "_inBundle": false, "_integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "_location": "/core-util-is", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "_npmVersion": "3.3.2", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "core-util-is@~1.0.0", + "raw": "core-util-is@1.0.2", "name": "core-util-is", "escapedName": "core-util-is", - "rawSpec": "~1.0.0", + "rawSpec": "1.0.2", "saveSpec": null, - "fetchSpec": "~1.0.0" + "fetchSpec": "1.0.2" }, "_requiredBy": [ + "/busboy/readable-stream", + "/dicer/readable-stream", + "/htmlparser2/readable-stream", "/readable-stream" ], "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", - "_spec": "core-util-is@~1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/readable-stream", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -36,18 +38,10 @@ "bugs": { "url": "https://github.com/isaacs/core-util-is/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "The `util.is*` functions introduced in Node v0.12.", "devDependencies": { "tap": "^2.3.0" }, - "directories": {}, - "dist": { - "shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", - "tarball": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" - }, - "gitHead": "a177da234df5638b363ddc15fa324619a38577c8", "homepage": "https://github.com/isaacs/core-util-is#readme", "keywords": [ "util", @@ -62,12 +56,6 @@ ], "license": "MIT", "main": "lib/util.js", - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], "name": "core-util-is", "repository": { "type": "git", diff --git a/node_modules/crc/package.json b/node_modules/crc/package.json index a41d8a1..1dd81d3 100644 --- a/node_modules/crc/package.json +++ b/node_modules/crc/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "crc@3.4.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "crc@3.4.4", "_id": "crc@3.4.4", "_inBundle": false, @@ -19,9 +25,8 @@ "/express-session" ], "_resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", - "_shasum": "9da1e980e3bd44fc5c93bf5ab3da3378d85e466b", - "_spec": "crc@3.4.4", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "3.4.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Alex Gorbatchev", "url": "https://github.com/alexgorbatchev" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/alexgorbatchev/node-crc/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the Browser.", "devDependencies": { "babel-cli": "^6.3.15", diff --git a/node_modules/date-now/package.json b/node_modules/date-now/package.json index 3cb6fb1..702af9d 100644 --- a/node_modules/date-now/package.json +++ b/node_modules/date-now/package.json @@ -1,27 +1,33 @@ { - "_from": "date-now@^0.1.4", + "_args": [ + [ + "date-now@0.1.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "date-now@0.1.4", "_id": "date-now@0.1.4", "_inBundle": false, "_integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "_location": "/date-now", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "date-now@^0.1.4", + "raw": "date-now@0.1.4", "name": "date-now", "escapedName": "date-now", - "rawSpec": "^0.1.4", + "rawSpec": "0.1.4", "saveSpec": null, - "fetchSpec": "^0.1.4" + "fetchSpec": "0.1.4" }, "_requiredBy": [ "/console-browserify" ], "_resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "_shasum": "eaf439fd4d4848ad74e5cc7dbef200672b9e345b", - "_spec": "date-now@^0.1.4", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/console-browserify", + "_spec": "0.1.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Raynos", "email": "raynos2@gmail.com" @@ -30,14 +36,12 @@ "url": "https://github.com/Colingo/date-now/issues", "email": "raynos2@gmail.com" }, - "bundleDependencies": false, "contributors": [ { "name": "Artem Shoobovych" } ], "dependencies": {}, - "deprecated": false, "description": "A requirable version of Date.now()", "devDependencies": { "browserify": "https://github.com/raynos/node-browserify/tarball/master", diff --git a/node_modules/debug/node_modules/ms/package.json b/node_modules/debug/node_modules/ms/package.json index e36489e..25dce0f 100644 --- a/node_modules/debug/node_modules/ms/package.json +++ b/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,52 @@ { - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" + "_args": [ + [ + "ms@0.7.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.1", + "_id": "ms@0.7.1", + "_inBundle": false, + "_integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "_location": "/debug/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.1", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.1", + "saveSpec": null, + "fetchSpec": "0.7.1" }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" + "_requiredBy": [ + "/debug" + ], + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "_spec": "0.7.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" }, "component": { "scripts": { "ms/index.js": "index.js" } }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" + "description": "Tiny ms conversion utility", + "devDependencies": { + "expect.js": "*", + "mocha": "*", + "serve": "*" }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + "homepage": "https://github.com/guille/ms.js#readme", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.7.1" } diff --git a/node_modules/debug/package.json b/node_modules/debug/package.json index f2148c9..7e34dec 100644 --- a/node_modules/debug/package.json +++ b/node_modules/debug/package.json @@ -1,20 +1,47 @@ { - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" + "_args": [ + [ + "debug@2.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "debug@2.2.0", + "_id": "debug@2.2.0", + "_inBundle": false, + "_integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "_location": "/debug", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "debug@2.2.0", + "name": "debug", + "escapedName": "debug", + "rawSpec": "2.2.0", + "saveSpec": null, + "fetchSpec": "2.2.0" }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" + "_requiredBy": [ + "/", + "/mocha" ], + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "_spec": "2.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, "contributors": [ { "name": "Nathan Rajlich", @@ -22,52 +49,26 @@ "url": "http://n8.io" } ], - "license": "MIT", "dependencies": { "ms": "0.7.1" }, + "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@>=2.2.0 <2.3.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } + "homepage": "https://github.com/visionmedia/debug#readme", + "keywords": [ + "debug", + "log", + "debugger" ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + "license": "MIT", + "main": "./node.js", + "name": "debug", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.2.0" } diff --git a/node_modules/deep-eql/package.json b/node_modules/deep-eql/package.json index 899bff4..7795bf4 100644 --- a/node_modules/deep-eql/package.json +++ b/node_modules/deep-eql/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "deep-eql@0.1.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "deep-eql@0.1.3", "_id": "deep-eql@0.1.3", "_inBundle": false, @@ -19,9 +25,8 @@ "/chai" ], "_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", - "_shasum": "ef558acab8de25206cd713906d74e56930eb69f2", - "_spec": "deep-eql@0.1.3", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/chai", + "_spec": "0.1.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jake Luer", "email": "jake@alogicalparadox.com" @@ -29,11 +34,9 @@ "bugs": { "url": "https://github.com/chaijs/deep-eql/issues" }, - "bundleDependencies": false, "dependencies": { "type-detect": "0.1.1" }, - "deprecated": false, "description": "Improved deep equality testing for Node.js and the browser.", "devDependencies": { "component": "*", diff --git a/node_modules/depd/package.json b/node_modules/depd/package.json index d37ea4a..e357c23 100644 --- a/node_modules/depd/package.json +++ b/node_modules/depd/package.json @@ -1,27 +1,32 @@ { - "_from": "depd@~1.1.1", + "_args": [ + [ + "depd@1.1.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "depd@1.1.2", "_id": "depd@1.1.2", "_inBundle": false, "_integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "_location": "/depd", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "depd@~1.1.1", + "raw": "depd@1.1.2", "name": "depd", "escapedName": "depd", - "rawSpec": "~1.1.1", + "rawSpec": "1.1.2", "saveSpec": null, - "fetchSpec": "~1.1.1" + "fetchSpec": "1.1.2" }, "_requiredBy": [ "/express-session" ], "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "_shasum": "9bcd52e14c097763e749b274c4346ed2e560b5a9", - "_spec": "depd@~1.1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "1.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" @@ -30,8 +35,6 @@ "bugs": { "url": "https://github.com/dougwilson/nodejs-depd/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Deprecate all the things", "devDependencies": { "beautify-benchmark": "0.2.4", diff --git a/node_modules/dicer/node_modules/isarray/package.json b/node_modules/dicer/node_modules/isarray/package.json index c861e25..1a56fee 100644 --- a/node_modules/dicer/node_modules/isarray/package.json +++ b/node_modules/dicer/node_modules/isarray/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "isarray@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "isarray@0.0.1", "_id": "isarray@0.0.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/dicer/readable-stream" ], "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_spec": "isarray@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dicer/node_modules/readable-stream", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/juliangruber/isarray/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Array#isArray for older browsers", "devDependencies": { "tap": "*" diff --git a/node_modules/dicer/node_modules/readable-stream/package.json b/node_modules/dicer/node_modules/readable-stream/package.json index 7e6e150..25d64eb 100644 --- a/node_modules/dicer/node_modules/readable-stream/package.json +++ b/node_modules/dicer/node_modules/readable-stream/package.json @@ -1,27 +1,32 @@ { - "_from": "readable-stream@1.1.x", + "_args": [ + [ + "readable-stream@1.1.14", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "readable-stream@1.1.14", "_id": "readable-stream@1.1.14", "_inBundle": false, "_integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "_location": "/dicer/readable-stream", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "readable-stream@1.1.x", + "raw": "readable-stream@1.1.14", "name": "readable-stream", "escapedName": "readable-stream", - "rawSpec": "1.1.x", + "rawSpec": "1.1.14", "saveSpec": null, - "fetchSpec": "1.1.x" + "fetchSpec": "1.1.14" }, "_requiredBy": [ "/dicer" ], "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "_shasum": "7cf4c54ef648e3813084c636dd2079e166c081d9", - "_spec": "readable-stream@1.1.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dicer", + "_spec": "1.1.14", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -33,14 +38,12 @@ "bugs": { "url": "https://github.com/isaacs/readable-stream/issues" }, - "bundleDependencies": false, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "0.0.1", "string_decoder": "~0.10.x" }, - "deprecated": false, "description": "Streams3, a user-land copy of the stream library from Node.js v0.11.x", "devDependencies": { "tap": "~0.2.6" diff --git a/node_modules/dicer/node_modules/string_decoder/package.json b/node_modules/dicer/node_modules/string_decoder/package.json index c2073fc..36c4180 100644 --- a/node_modules/dicer/node_modules/string_decoder/package.json +++ b/node_modules/dicer/node_modules/string_decoder/package.json @@ -1,33 +1,36 @@ { - "_from": "string_decoder@~0.10.x", + "_args": [ + [ + "string_decoder@0.10.31", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "string_decoder@0.10.31", "_id": "string_decoder@0.10.31", "_inBundle": false, "_integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "_location": "/dicer/string_decoder", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "string_decoder@~0.10.x", + "raw": "string_decoder@0.10.31", "name": "string_decoder", "escapedName": "string_decoder", - "rawSpec": "~0.10.x", + "rawSpec": "0.10.31", "saveSpec": null, - "fetchSpec": "~0.10.x" + "fetchSpec": "0.10.31" }, "_requiredBy": [ "/dicer/readable-stream" ], "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", - "_spec": "string_decoder@~0.10.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dicer/node_modules/readable-stream", + "_spec": "0.10.31", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/rvagg/string_decoder/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "The string_decoder module from Node core", "devDependencies": { "tap": "~0.4.8" diff --git a/node_modules/dicer/package.json b/node_modules/dicer/package.json index 1cb5f9e..89f11c0 100644 --- a/node_modules/dicer/package.json +++ b/node_modules/dicer/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "dicer@0.2.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "dicer@0.2.5", "_id": "dicer@0.2.5", "_inBundle": false, @@ -22,9 +28,8 @@ "/busboy" ], "_resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", - "_shasum": "5996c086bb33218c812c090bddc09cd12facb70f", - "_spec": "dicer@0.2.5", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/busboy", + "_spec": "0.2.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Brian White", "email": "mscdex@mscdex.net" @@ -32,12 +37,10 @@ "bugs": { "url": "https://github.com/mscdex/dicer/issues" }, - "bundleDependencies": false, "dependencies": { "readable-stream": "1.1.x", "streamsearch": "0.1.2" }, - "deprecated": false, "description": "A very fast streaming multipart parser for node.js", "engines": { "node": ">=0.8.0" diff --git a/node_modules/diff/package.json b/node_modules/diff/package.json index 6b14b2c..4e4f3cf 100644 --- a/node_modules/diff/package.json +++ b/node_modules/diff/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "diff@1.0.7", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "diff@1.0.7", "_id": "diff@1.0.7", "_inBundle": false, @@ -19,16 +25,13 @@ "/mocha" ], "_resolved": "https://registry.npmjs.org/diff/-/diff-1.0.7.tgz", - "_shasum": "24bbb001c4a7d5522169e7cabdb2c2814ed91cf4", - "_spec": "diff@1.0.7", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mocha", + "_spec": "1.0.7", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "http://github.com/kpdecker/jsdiff/issues", "email": "kpdecker@gmail.com" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "A javascript text diff implementation.", "devDependencies": { "mocha": "~1.6", diff --git a/node_modules/dom-serializer/node_modules/domelementtype/package.json b/node_modules/dom-serializer/node_modules/domelementtype/package.json index 79ac02a..96d5d52 100644 --- a/node_modules/dom-serializer/node_modules/domelementtype/package.json +++ b/node_modules/dom-serializer/node_modules/domelementtype/package.json @@ -1,27 +1,33 @@ { - "_from": "domelementtype@~1.1.1", + "_args": [ + [ + "domelementtype@1.1.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "domelementtype@1.1.3", "_id": "domelementtype@1.1.3", "_inBundle": false, "_integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", "_location": "/dom-serializer/domelementtype", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "domelementtype@~1.1.1", + "raw": "domelementtype@1.1.3", "name": "domelementtype", "escapedName": "domelementtype", - "rawSpec": "~1.1.1", + "rawSpec": "1.1.3", "saveSpec": null, - "fetchSpec": "~1.1.1" + "fetchSpec": "1.1.3" }, "_requiredBy": [ "/dom-serializer" ], "_resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "_shasum": "bd28773e2642881aec51544924299c5cd822185b", - "_spec": "domelementtype@~1.1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dom-serializer", + "_spec": "1.1.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,8 +35,6 @@ "bugs": { "url": "https://github.com/FB55/domelementtype/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "all the types of nodes in htmlparser2's dom", "homepage": "https://github.com/FB55/domelementtype#readme", "keywords": [ diff --git a/node_modules/dom-serializer/node_modules/entities/package.json b/node_modules/dom-serializer/node_modules/entities/package.json index 9f949fc..ae67357 100644 --- a/node_modules/dom-serializer/node_modules/entities/package.json +++ b/node_modules/dom-serializer/node_modules/entities/package.json @@ -1,27 +1,33 @@ { - "_from": "entities@~1.1.1", + "_args": [ + [ + "entities@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "entities@1.1.1", "_id": "entities@1.1.1", "_inBundle": false, "_integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", "_location": "/dom-serializer/entities", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "entities@~1.1.1", + "raw": "entities@1.1.1", "name": "entities", "escapedName": "entities", - "rawSpec": "~1.1.1", + "rawSpec": "1.1.1", "saveSpec": null, - "fetchSpec": "~1.1.1" + "fetchSpec": "1.1.1" }, "_requiredBy": [ "/dom-serializer" ], "_resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "_shasum": "6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0", - "_spec": "entities@~1.1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dom-serializer", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,8 +35,6 @@ "bugs": { "url": "https://github.com/fb55/node-entities/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Encode & decode XML/HTML entities with ease", "devDependencies": { "coveralls": "*", diff --git a/node_modules/dom-serializer/package.json b/node_modules/dom-serializer/package.json index 2c57d6b..187b307 100644 --- a/node_modules/dom-serializer/package.json +++ b/node_modules/dom-serializer/package.json @@ -1,27 +1,33 @@ { - "_from": "dom-serializer@0", + "_args": [ + [ + "dom-serializer@0.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "dom-serializer@0.1.0", "_id": "dom-serializer@0.1.0", "_inBundle": false, "_integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", "_location": "/dom-serializer", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "dom-serializer@0", + "raw": "dom-serializer@0.1.0", "name": "dom-serializer", "escapedName": "dom-serializer", - "rawSpec": "0", + "rawSpec": "0.1.0", "saveSpec": null, - "fetchSpec": "0" + "fetchSpec": "0.1.0" }, "_requiredBy": [ "/domutils" ], "_resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "_shasum": "073c697546ce0780ce23be4a28e293e40bc30c82", - "_spec": "dom-serializer@0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/domutils", + "_spec": "0.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,12 +35,10 @@ "bugs": { "url": "https://github.com/cheeriojs/dom-renderer/issues" }, - "bundleDependencies": false, "dependencies": { "domelementtype": "~1.1.1", "entities": "~1.1.1" }, - "deprecated": false, "description": "render dom nodes to string", "devDependencies": { "cheerio": "*", diff --git a/node_modules/domelementtype/package.json b/node_modules/domelementtype/package.json index 4ebab56..f7a1c9d 100644 --- a/node_modules/domelementtype/package.json +++ b/node_modules/domelementtype/package.json @@ -1,19 +1,26 @@ { - "_from": "domelementtype@1", + "_args": [ + [ + "domelementtype@1.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "domelementtype@1.3.0", "_id": "domelementtype@1.3.0", "_inBundle": false, "_integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", "_location": "/domelementtype", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "domelementtype@1", + "raw": "domelementtype@1.3.0", "name": "domelementtype", "escapedName": "domelementtype", - "rawSpec": "1", + "rawSpec": "1.3.0", "saveSpec": null, - "fetchSpec": "1" + "fetchSpec": "1.3.0" }, "_requiredBy": [ "/domhandler", @@ -21,9 +28,8 @@ "/htmlparser2" ], "_resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "_shasum": "b17aed82e8ab59e52dd9c19b1756e0fc187204c2", - "_spec": "domelementtype@1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2", + "_spec": "1.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -31,8 +37,6 @@ "bugs": { "url": "https://github.com/FB55/domelementtype/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "all the types of nodes in htmlparser2's dom", "homepage": "https://github.com/FB55/domelementtype#readme", "keywords": [ diff --git a/node_modules/domhandler/package.json b/node_modules/domhandler/package.json index 19cb5b0..cc2f9b6 100644 --- a/node_modules/domhandler/package.json +++ b/node_modules/domhandler/package.json @@ -1,27 +1,33 @@ { - "_from": "domhandler@2.3", + "_args": [ + [ + "domhandler@2.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "domhandler@2.3.0", "_id": "domhandler@2.3.0", "_inBundle": false, "_integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", "_location": "/domhandler", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "domhandler@2.3", + "raw": "domhandler@2.3.0", "name": "domhandler", "escapedName": "domhandler", - "rawSpec": "2.3", + "rawSpec": "2.3.0", "saveSpec": null, - "fetchSpec": "2.3" + "fetchSpec": "2.3.0" }, "_requiredBy": [ "/htmlparser2" ], "_resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "_shasum": "2de59a0822d5027fabff6f032c2b25a2a8abe738", - "_spec": "domhandler@2.3", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2", + "_spec": "2.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,11 +35,9 @@ "bugs": { "url": "https://github.com/fb55/DomHandler/issues" }, - "bundleDependencies": false, "dependencies": { "domelementtype": "1" }, - "deprecated": false, "description": "handler for htmlparser2 that turns pages into a dom", "devDependencies": { "htmlparser2": "3.8", diff --git a/node_modules/domutils/package.json b/node_modules/domutils/package.json index 8898036..cac10c8 100644 --- a/node_modules/domutils/package.json +++ b/node_modules/domutils/package.json @@ -1,27 +1,33 @@ { - "_from": "domutils@1.5", + "_args": [ + [ + "domutils@1.5.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "domutils@1.5.1", "_id": "domutils@1.5.1", "_inBundle": false, "_integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", "_location": "/domutils", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "domutils@1.5", + "raw": "domutils@1.5.1", "name": "domutils", "escapedName": "domutils", - "rawSpec": "1.5", + "rawSpec": "1.5.1", "saveSpec": null, - "fetchSpec": "1.5" + "fetchSpec": "1.5.1" }, "_requiredBy": [ "/htmlparser2" ], "_resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "_shasum": "dcd8488a26f563d61079e48c9f7b7e32373682cf", - "_spec": "domutils@1.5", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2", + "_spec": "1.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,12 +35,10 @@ "bugs": { "url": "https://github.com/FB55/domutils/issues" }, - "bundleDependencies": false, "dependencies": { "dom-serializer": "0", "domelementtype": "1" }, - "deprecated": false, "description": "utilities for working with htmlparser2's dom", "devDependencies": { "domhandler": "2", diff --git a/node_modules/ee-first/LICENSE b/node_modules/ee-first/LICENSE new file mode 100644 index 0000000..a7ae8ee --- /dev/null +++ b/node_modules/ee-first/LICENSE @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/ee-first/README.md b/node_modules/ee-first/README.md new file mode 100644 index 0000000..cbd2478 --- /dev/null +++ b/node_modules/ee-first/README.md @@ -0,0 +1,80 @@ +# EE First + +[![NPM version][npm-image]][npm-url] +[![Build status][travis-image]][travis-url] +[![Test coverage][coveralls-image]][coveralls-url] +[![License][license-image]][license-url] +[![Downloads][downloads-image]][downloads-url] +[![Gittip][gittip-image]][gittip-url] + +Get the first event in a set of event emitters and event pairs, +then clean up after itself. + +## Install + +```sh +$ npm install ee-first +``` + +## API + +```js +var first = require('ee-first') +``` + +### first(arr, listener) + +Invoke `listener` on the first event from the list specified in `arr`. `arr` is +an array of arrays, with each array in the format `[ee, ...event]`. `listener` +will be called only once, the first time any of the given events are emitted. If +`error` is one of the listened events, then if that fires first, the `listener` +will be given the `err` argument. + +The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the +first argument emitted from an `error` event, if applicable; `ee` is the event +emitter that fired; `event` is the string event name that fired; and `args` is an +array of the arguments that were emitted on the event. + +```js +var ee1 = new EventEmitter() +var ee2 = new EventEmitter() + +first([ + [ee1, 'close', 'end', 'error'], + [ee2, 'error'] +], function (err, ee, event, args) { + // listener invoked +}) +``` + +#### .cancel() + +The group of listeners can be cancelled before being invoked and have all the event +listeners removed from the underlying event emitters. + +```js +var thunk = first([ + [ee1, 'close', 'end', 'error'], + [ee2, 'error'] +], function (err, ee, event, args) { + // listener invoked +}) + +// cancel and clean up +thunk.cancel() +``` + +[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square +[npm-url]: https://npmjs.org/package/ee-first +[github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square +[github-url]: https://github.com/jonathanong/ee-first/tags +[travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square +[travis-url]: https://travis-ci.org/jonathanong/ee-first +[coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square +[coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master +[license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square +[license-url]: LICENSE.md +[downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square +[downloads-url]: https://npmjs.org/package/ee-first +[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square +[gittip-url]: https://www.gittip.com/jonathanong/ diff --git a/node_modules/ee-first/index.js b/node_modules/ee-first/index.js new file mode 100644 index 0000000..501287c --- /dev/null +++ b/node_modules/ee-first/index.js @@ -0,0 +1,95 @@ +/*! + * ee-first + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = first + +/** + * Get the first event in a set of event emitters and event pairs. + * + * @param {array} stuff + * @param {function} done + * @public + */ + +function first(stuff, done) { + if (!Array.isArray(stuff)) + throw new TypeError('arg must be an array of [ee, events...] arrays') + + var cleanups = [] + + for (var i = 0; i < stuff.length; i++) { + var arr = stuff[i] + + if (!Array.isArray(arr) || arr.length < 2) + throw new TypeError('each array member must be [ee, events...]') + + var ee = arr[0] + + for (var j = 1; j < arr.length; j++) { + var event = arr[j] + var fn = listener(event, callback) + + // listen to the event + ee.on(event, fn) + // push this listener to the list of cleanups + cleanups.push({ + ee: ee, + event: event, + fn: fn, + }) + } + } + + function callback() { + cleanup() + done.apply(null, arguments) + } + + function cleanup() { + var x + for (var i = 0; i < cleanups.length; i++) { + x = cleanups[i] + x.ee.removeListener(x.event, x.fn) + } + } + + function thunk(fn) { + done = fn + } + + thunk.cancel = cleanup + + return thunk +} + +/** + * Create the event listener. + * @private + */ + +function listener(event, done) { + return function onevent(arg1) { + var args = new Array(arguments.length) + var ee = this + var err = event === 'error' + ? arg1 + : null + + // copy args to prevent arguments escaping scope + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] + } + + done(err, ee, event, args) + } +} diff --git a/node_modules/ee-first/package.json b/node_modules/ee-first/package.json new file mode 100644 index 0000000..1d27319 --- /dev/null +++ b/node_modules/ee-first/package.json @@ -0,0 +1,63 @@ +{ + "_from": "ee-first@1.1.1", + "_id": "ee-first@1.1.1", + "_inBundle": false, + "_integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "_location": "/ee-first", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ee-first@1.1.1", + "name": "ee-first", + "escapedName": "ee-first", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/on-finished" + ], + "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", + "_spec": "ee-first@1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/on-finished", + "author": { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + "bugs": { + "url": "https://github.com/jonathanong/ee-first/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + } + ], + "deprecated": false, + "description": "return the first event in a set of ee/event pairs", + "devDependencies": { + "istanbul": "0.3.9", + "mocha": "2.2.5" + }, + "files": [ + "index.js", + "LICENSE" + ], + "homepage": "https://github.com/jonathanong/ee-first#readme", + "license": "MIT", + "name": "ee-first", + "repository": { + "type": "git", + "url": "git+https://github.com/jonathanong/ee-first.git" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "version": "1.1.1" +} diff --git a/node_modules/entities/package.json b/node_modules/entities/package.json index 83832f9..90917d1 100644 --- a/node_modules/entities/package.json +++ b/node_modules/entities/package.json @@ -1,27 +1,33 @@ { - "_from": "entities@1.0", + "_args": [ + [ + "entities@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "entities@1.0.0", "_id": "entities@1.0.0", "_inBundle": false, "_integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", "_location": "/entities", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "entities@1.0", + "raw": "entities@1.0.0", "name": "entities", "escapedName": "entities", - "rawSpec": "1.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "1.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/htmlparser2" ], "_resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "_shasum": "b2987aa3821347fcde642b24fdfc9e4fb712bf26", - "_spec": "entities@1.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -29,8 +35,6 @@ "bugs": { "url": "https://github.com/fb55/node-entities/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Encode & decode XML/HTML entities with ease", "devDependencies": { "coveralls": "*", diff --git a/node_modules/es6-promise/package.json b/node_modules/es6-promise/package.json index 0420d2c..2e4d4ca 100644 --- a/node_modules/es6-promise/package.json +++ b/node_modules/es6-promise/package.json @@ -16,12 +16,12 @@ "fetchSpec": "3.2.1" }, "_requiredBy": [ - "/mongodb" + "/mongoose/mongodb" ], "_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", "_shasum": "ec56233868032909207170c39448e24449dd1fc4", "_spec": "es6-promise@3.2.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose/node_modules/mongodb", "author": { "name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors", "url": "Conversion to ES6 API by Jake Archibald" diff --git a/node_modules/exit/package.json b/node_modules/exit/package.json index fef6fc5..957935b 100644 --- a/node_modules/exit/package.json +++ b/node_modules/exit/package.json @@ -1,28 +1,34 @@ { - "_from": "exit@0.1.x", + "_args": [ + [ + "exit@0.1.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "exit@0.1.2", "_id": "exit@0.1.2", "_inBundle": false, "_integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "_location": "/exit", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "exit@0.1.x", + "raw": "exit@0.1.2", "name": "exit", "escapedName": "exit", - "rawSpec": "0.1.x", + "rawSpec": "0.1.2", "saveSpec": null, - "fetchSpec": "0.1.x" + "fetchSpec": "0.1.2" }, "_requiredBy": [ "/cli", "/jshint" ], "_resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "_shasum": "0632638f8d877cc82107d30a0fff1a17cba1cd0c", - "_spec": "exit@0.1.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "0.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "\"Cowboy\" Ben Alman", "url": "http://benalman.com/" @@ -30,8 +36,6 @@ "bugs": { "url": "https://github.com/cowboy/node-exit/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "A replacement for process.exit that ensures stdio are fully drained before exiting.", "devDependencies": { "grunt": "~0.4.1", diff --git a/node_modules/express-session/node_modules/debug/package.json b/node_modules/express-session/node_modules/debug/package.json index 74d8532..aaec129 100644 --- a/node_modules/express-session/node_modules/debug/package.json +++ b/node_modules/express-session/node_modules/debug/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "debug@2.6.9", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "debug@2.6.9", "_id": "debug@2.6.9", "_inBundle": false, @@ -19,9 +25,8 @@ "/express-session" ], "_resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "_shasum": "5d128515df134ff327e90a4c93f4e077a536341f", - "_spec": "debug@2.6.9", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "2.6.9", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" @@ -30,7 +35,6 @@ "bugs": { "url": "https://github.com/visionmedia/debug/issues" }, - "bundleDependencies": false, "component": { "scripts": { "debug/index.js": "browser.js", @@ -51,7 +55,6 @@ "dependencies": { "ms": "2.0.0" }, - "deprecated": false, "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", diff --git a/node_modules/express-session/package.json b/node_modules/express-session/package.json index 42be18b..16c5ea8 100644 --- a/node_modules/express-session/package.json +++ b/node_modules/express-session/package.json @@ -1,5 +1,11 @@ { - "_from": "express-session@^1.10.1", + "_args": [ + [ + "express-session@1.15.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "express-session@1.15.6", "_id": "express-session@1.15.6", "_inBundle": false, "_integrity": "sha512-r0nrHTCYtAMrFwZ0kBzZEXa1vtPVrw0dKvGSrKP4dahwBQ1BJpF2/y1Pp4sCD/0kvxV4zZeclyvfmw0B4RMJQA==", @@ -8,21 +14,20 @@ "ms": "2.0.0" }, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "express-session@^1.10.1", + "raw": "express-session@1.15.6", "name": "express-session", "escapedName": "express-session", - "rawSpec": "^1.10.1", + "rawSpec": "1.15.6", "saveSpec": null, - "fetchSpec": "^1.10.1" + "fetchSpec": "1.15.6" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/express-session/-/express-session-1.15.6.tgz", - "_shasum": "47b4160c88f42ab70fe8a508e31cbff76757ab0a", - "_spec": "express-session@^1.10.1", + "_spec": "1.15.6", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", @@ -32,7 +37,6 @@ "bugs": { "url": "https://github.com/expressjs/session/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -54,7 +58,6 @@ "uid-safe": "~2.1.5", "utils-merge": "1.0.1" }, - "deprecated": false, "description": "Simple session middleware for Express", "devDependencies": { "after": "0.8.2", diff --git a/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json b/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json index 2bbf8d4..1da77f8 100644 --- a/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json +++ b/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json @@ -1,7 +1,35 @@ { - "name": "mime-db", - "description": "Media Type Database", - "version": "1.27.0", + "_args": [ + [ + "mime-db@1.27.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-db@1.27.0", + "_id": "mime-db@1.27.0", + "_inBundle": false, + "_integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", + "_location": "/express/accepts/mime-types/mime-db", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-db@1.27.0", + "name": "mime-db", + "escapedName": "mime-db", + "rawSpec": "1.27.0", + "saveSpec": null, + "fetchSpec": "1.27.0" + }, + "_requiredBy": [ + "/express/accepts/mime-types" + ], + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "_spec": "1.27.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,20 +46,7 @@ "url": "http://github.com/broofa" } ], - "license": "MIT", - "keywords": [ - "mime", - "db", - "type", - "types", - "database", - "charset", - "charsets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-db.git" - }, + "description": "Media Type Database", "devDependencies": { "bluebird": "3.5.0", "co": "4.6.0", @@ -47,6 +62,9 @@ "raw-body": "2.2.0", "stream-to-array": "2.3.0" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", @@ -54,8 +72,21 @@ "db.json", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-db#readme", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "license": "MIT", + "name": "mime-db", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" }, "scripts": { "build": "node scripts/build", @@ -66,39 +97,5 @@ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "c232c21378647dfbb7762410c7b025a47f114b94", - "bugs": { - "url": "https://github.com/jshttp/mime-db/issues" - }, - "homepage": "https://github.com/jshttp/mime-db#readme", - "_id": "mime-db@1.27.0", - "_shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "_from": "mime-db@>=1.27.0 <1.28.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-db-1.27.0.tgz_1489722296902_0.15233952621929348" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.27.0" } diff --git a/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json b/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json index cf28324..1dcbf69 100644 --- a/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json +++ b/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json @@ -1,7 +1,35 @@ { - "name": "mime-types", - "description": "The ultimate javascript content-type utility.", - "version": "2.1.15", + "_args": [ + [ + "mime-types@2.1.15", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-types@2.1.15", + "_id": "mime-types@2.1.15", + "_inBundle": false, + "_integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", + "_location": "/express/accepts/mime-types", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-types@2.1.15", + "name": "mime-types", + "escapedName": "mime-types", + "rawSpec": "2.1.15", + "saveSpec": null, + "fetchSpec": "2.1.15" + }, + "_requiredBy": [ + "/express/accepts" + ], + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "_spec": "2.1.15", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,18 +46,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "mime", - "types" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-types.git" - }, "dependencies": { "mime-db": "~1.27.0" }, + "description": "The ultimate javascript content-type utility.", "devDependencies": { "eslint": "3.18.0", "eslint-config-standard": "7.1.0", @@ -38,13 +58,24 @@ "istanbul": "0.4.5", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-types#readme", + "keywords": [ + "mime", + "types" + ], + "license": "MIT", + "name": "mime-types", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" }, "scripts": { "lint": "eslint .", @@ -52,43 +83,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" }, - "gitHead": "c44863eb0463ee16f3eb04576591cc4c4d6b214c", - "bugs": { - "url": "https://github.com/jshttp/mime-types/issues" - }, - "homepage": "https://github.com/jshttp/mime-types#readme", - "_id": "mime-types@2.1.15", - "_shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "_from": "mime-types@>=2.1.11 <2.2.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-types-2.1.15.tgz_1490327753615_0.3609113476704806" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "readme": "ERROR: No README data found!" + "version": "2.1.15" } diff --git a/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json b/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json index a7c2c2a..17a5355 100644 --- a/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json +++ b/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json @@ -1,7 +1,35 @@ { - "name": "negotiator", - "description": "HTTP content negotiation", - "version": "0.6.1", + "_args": [ + [ + "negotiator@0.6.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "negotiator@0.6.1", + "_id": "negotiator@0.6.1", + "_inBundle": false, + "_integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "_location": "/express/accepts/negotiator", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "negotiator@0.6.1", + "name": "negotiator", + "escapedName": "negotiator", + "rawSpec": "0.6.1", + "saveSpec": null, + "fetchSpec": "0.6.1" + }, + "_requiredBy": [ + "/express/accepts" + ], + "_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "_spec": "0.6.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/negotiator/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -17,23 +45,14 @@ "url": "http://blog.izs.me/" } ], - "license": "MIT", - "keywords": [ - "http", - "content negotiation", - "accept", - "accept-language", - "accept-encoding", - "accept-charset" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/negotiator.git" - }, + "description": "HTTP content negotiation", "devDependencies": { "istanbul": "0.4.3", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "lib/", "HISTORY.md", @@ -41,51 +60,25 @@ "index.js", "README.md" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/negotiator#readme", + "keywords": [ + "http", + "content negotiation", + "accept", + "accept-language", + "accept-encoding", + "accept-charset" + ], + "license": "MIT", + "name": "negotiator", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/negotiator.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "751c381c32707f238143cd65d78520e16f4ef9e5", - "bugs": { - "url": "https://github.com/jshttp/negotiator/issues" - }, - "homepage": "https://github.com/jshttp/negotiator#readme", - "_id": "negotiator@0.6.1", - "_shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", - "_from": "negotiator@0.6.1", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "2b327184e8992101177b28563fb5e7102acd0ca9", - "tarball": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "federomero", - "email": "federomero@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/negotiator-0.6.1.tgz_1462250848695_0.027451182017102838" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.6.1" } diff --git a/node_modules/express/node_modules/accepts/package.json b/node_modules/express/node_modules/accepts/package.json index 6bff56f..bad9029 100644 --- a/node_modules/express/node_modules/accepts/package.json +++ b/node_modules/express/node_modules/accepts/package.json @@ -1,7 +1,35 @@ { - "name": "accepts", - "description": "Higher-level content negotiation", - "version": "1.3.3", + "_args": [ + [ + "accepts@1.3.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "accepts@1.3.3", + "_id": "accepts@1.3.3", + "_inBundle": false, + "_integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "_location": "/express/accepts", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "accepts@1.3.3", + "name": "accepts", + "escapedName": "accepts", + "rawSpec": "1.3.3", + "saveSpec": null, + "fetchSpec": "1.3.3" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "_spec": "1.3.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/accepts/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,67 +41,40 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/accepts.git" - }, "dependencies": { "mime-types": "~2.1.11", "negotiator": "0.6.1" }, + "description": "Higher-level content negotiation", "devDependencies": { "istanbul": "0.4.3", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, + "homepage": "https://github.com/jshttp/accepts#readme", "keywords": [ "content", "negotiation", "accept", "accepts" ], - "gitHead": "3e925b1e65ed7da2798849683d49814680dfa426", - "bugs": { - "url": "https://github.com/jshttp/accepts/issues" - }, - "homepage": "https://github.com/jshttp/accepts#readme", - "_id": "accepts@1.3.3", - "_shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", - "_from": "accepts@>=1.3.3 <1.4.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "c3ca7434938648c3e0d9c1e328dd68b622c284ca", - "tarball": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz" + "license": "MIT", + "name": "accepts", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/accepts.git" }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/accepts-1.3.3.tgz_1462251932032_0.7092335098423064" + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.3" } diff --git a/node_modules/express/node_modules/array-flatten/package.json b/node_modules/express/node_modules/array-flatten/package.json index b1636ee..8715b53 100644 --- a/node_modules/express/node_modules/array-flatten/package.json +++ b/node_modules/express/node_modules/array-flatten/package.json @@ -1,62 +1,67 @@ { - "name": "array-flatten", - "version": "1.1.1", - "description": "Flatten an array of nested arrays into a single flat array", - "main": "array-flatten.js", - "files": [ - "array-flatten.js", - "LICENSE" + "_args": [ + [ + "array-flatten@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "scripts": { - "test": "istanbul cover _mocha -- -R spec" - }, - "repository": { - "type": "git", - "url": "git://github.com/blakeembrey/array-flatten.git" + "_from": "array-flatten@1.1.1", + "_id": "array-flatten@1.1.1", + "_inBundle": false, + "_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", + "_location": "/express/array-flatten", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "array-flatten@1.1.1", + "name": "array-flatten", + "escapedName": "array-flatten", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" }, - "keywords": [ - "array", - "flatten", - "arguments", - "depth" + "_requiredBy": [ + "/express" ], + "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Blake Embrey", "email": "hello@blakeembrey.com", "url": "http://blakeembrey.me" }, - "license": "MIT", "bugs": { "url": "https://github.com/blakeembrey/array-flatten/issues" }, - "homepage": "https://github.com/blakeembrey/array-flatten", + "description": "Flatten an array of nested arrays into a single flat array", "devDependencies": { "istanbul": "^0.3.13", "mocha": "^2.2.4", "pre-commit": "^1.0.7", "standard": "^3.7.3" }, - "gitHead": "1963a9189229d408e1e8f585a00c8be9edbd1803", - "_id": "array-flatten@1.1.1", - "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", - "_from": "array-flatten@1.1.1", - "_npmVersion": "2.11.3", - "_nodeVersion": "2.3.3", - "_npmUser": { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - "maintainers": [ - { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - } + "files": [ + "array-flatten.js", + "LICENSE" ], - "dist": { - "shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", - "tarball": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" + "homepage": "https://github.com/blakeembrey/array-flatten", + "keywords": [ + "array", + "flatten", + "arguments", + "depth" + ], + "license": "MIT", + "main": "array-flatten.js", + "name": "array-flatten", + "repository": { + "type": "git", + "url": "git://github.com/blakeembrey/array-flatten.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "readme": "ERROR: No README data found!" + "scripts": { + "test": "istanbul cover _mocha -- -R spec" + }, + "version": "1.1.1" } diff --git a/node_modules/express/node_modules/content-disposition/package.json b/node_modules/express/node_modules/content-disposition/package.json index bb07418..132381d 100644 --- a/node_modules/express/node_modules/content-disposition/package.json +++ b/node_modules/express/node_modules/content-disposition/package.json @@ -1,24 +1,42 @@ { - "name": "content-disposition", - "description": "Create and parse Content-Disposition header", - "version": "0.5.2", + "_args": [ + [ + "content-disposition@0.5.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "content-disposition@0.5.2", + "_id": "content-disposition@0.5.2", + "_inBundle": false, + "_integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", + "_location": "/express/content-disposition", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "content-disposition@0.5.2", + "name": "content-disposition", + "escapedName": "content-disposition", + "rawSpec": "0.5.2", + "saveSpec": null, + "fetchSpec": "0.5.2" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "_spec": "0.5.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/content-disposition/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "keywords": [ - "content-disposition", - "http", - "rfc6266", - "res" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/content-disposition.git" - }, + "description": "Create and parse Content-Disposition header", "devDependencies": { "eslint": "3.11.1", "eslint-config-standard": "6.2.1", @@ -27,14 +45,27 @@ "istanbul": "0.4.5", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/content-disposition#readme", + "keywords": [ + "content-disposition", + "http", + "rfc6266", + "res" + ], + "license": "MIT", + "name": "content-disposition", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/content-disposition.git" }, "scripts": { "lint": "eslint .", @@ -42,35 +73,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "2a08417377cf55678c9f870b305f3c6c088920f3", - "bugs": { - "url": "https://github.com/jshttp/content-disposition/issues" - }, - "homepage": "https://github.com/jshttp/content-disposition#readme", - "_id": "content-disposition@0.5.2", - "_shasum": "0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4", - "_from": "content-disposition@0.5.2", - "_npmVersion": "2.15.9", - "_nodeVersion": "4.6.0", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4", - "tarball": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/content-disposition-0.5.2.tgz_1481246224565_0.35659545403905213" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "readme": "ERROR: No README data found!" + "version": "0.5.2" } diff --git a/node_modules/express/node_modules/content-type/package.json b/node_modules/express/node_modules/content-type/package.json index 9f11091..106c0e6 100644 --- a/node_modules/express/node_modules/content-type/package.json +++ b/node_modules/express/node_modules/content-type/package.json @@ -1,70 +1,71 @@ { - "name": "content-type", - "description": "Create and parse HTTP Content-Type header", - "version": "1.0.2", + "_args": [ + [ + "content-type@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "content-type@1.0.2", + "_id": "content-type@1.0.2", + "_inBundle": false, + "_integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=", + "_location": "/express/content-type", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "content-type@1.0.2", + "name": "content-type", + "escapedName": "content-type", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "content-type", - "http", - "req", - "res", - "rfc7231" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/content-type.git" + "bugs": { + "url": "https://github.com/jshttp/content-type/issues" }, + "description": "Create and parse HTTP Content-Type header", "devDependencies": { "istanbul": "0.4.3", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/content-type#readme", + "keywords": [ + "content-type", + "http", + "req", + "res", + "rfc7231" + ], + "license": "MIT", + "name": "content-type", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/content-type.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "8118763adfbbac80cf1254191889330aec8b8be7", - "bugs": { - "url": "https://github.com/jshttp/content-type/issues" - }, - "homepage": "https://github.com/jshttp/content-type#readme", - "_id": "content-type@1.0.2", - "_shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "_from": "content-type@>=1.0.2 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "b7d113aee7a8dd27bd21133c4dc2529df1721eed", - "tarball": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/content-type-1.0.2.tgz_1462852785748_0.5491233412176371" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.2" } diff --git a/node_modules/express/node_modules/cookie-signature/package.json b/node_modules/express/node_modules/cookie-signature/package.json index f564ea5..cd65904 100644 --- a/node_modules/express/node_modules/cookie-signature/package.json +++ b/node_modules/express/node_modules/cookie-signature/package.json @@ -1,59 +1,60 @@ { - "name": "cookie-signature", - "version": "1.0.6", - "description": "Sign and unsign cookies", - "keywords": [ - "cookie", - "sign", - "unsign" + "_args": [ + [ + "cookie-signature@1.0.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cookie-signature@1.0.6", + "_id": "cookie-signature@1.0.6", + "_inBundle": false, + "_integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", + "_location": "/express/cookie-signature", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cookie-signature@1.0.6", + "name": "cookie-signature", + "escapedName": "cookie-signature", + "rawSpec": "1.0.6", + "saveSpec": null, + "fetchSpec": "1.0.6" + }, + "_requiredBy": [ + "/express" ], + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "_spec": "1.0.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@learnboost.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/visionmedia/node-cookie-signature.git" + "bugs": { + "url": "https://github.com/visionmedia/node-cookie-signature/issues" }, "dependencies": {}, + "description": "Sign and unsign cookies", "devDependencies": { "mocha": "*", "should": "*" }, - "scripts": { - "test": "mocha --require should --reporter spec" - }, + "homepage": "https://github.com/visionmedia/node-cookie-signature#readme", + "keywords": [ + "cookie", + "sign", + "unsign" + ], + "license": "MIT", "main": "index", - "gitHead": "391b56cf44d88c493491b7e3fc53208cfb976d2a", - "bugs": { - "url": "https://github.com/visionmedia/node-cookie-signature/issues" - }, - "homepage": "https://github.com/visionmedia/node-cookie-signature", - "_id": "cookie-signature@1.0.6", - "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "_from": "cookie-signature@1.0.6", - "_npmVersion": "2.3.0", - "_nodeVersion": "0.10.36", - "_npmUser": { - "name": "natevw", - "email": "natevw@yahoo.com" + "name": "cookie-signature", + "repository": { + "type": "git", + "url": "git+https://github.com/visionmedia/node-cookie-signature.git" }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "natevw", - "email": "natevw@yahoo.com" - } - ], - "dist": { - "shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c", - "tarball": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" + "scripts": { + "test": "mocha --require should --reporter spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.6" } diff --git a/node_modules/express/node_modules/cookie/package.json b/node_modules/express/node_modules/cookie/package.json index bb3556a..5162cfb 100644 --- a/node_modules/express/node_modules/cookie/package.json +++ b/node_modules/express/node_modules/cookie/package.json @@ -1,72 +1,74 @@ { - "name": "cookie", - "description": "HTTP server cookie parsing and serialization", - "version": "0.3.1", + "_args": [ + [ + "cookie@0.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cookie@0.3.1", + "_id": "cookie@0.3.1", + "_inBundle": false, + "_integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", + "_location": "/express/cookie", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cookie@0.3.1", + "name": "cookie", + "escapedName": "cookie", + "rawSpec": "0.3.1", + "saveSpec": null, + "fetchSpec": "0.3.1" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "_spec": "0.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Roman Shtylman", "email": "shtylman@gmail.com" }, + "bugs": { + "url": "https://github.com/jshttp/cookie/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "keywords": [ - "cookie", - "cookies" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/cookie.git" - }, + "description": "HTTP server cookie parsing and serialization", "devDependencies": { "istanbul": "0.4.3", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/cookie#readme", + "keywords": [ + "cookie", + "cookies" + ], + "license": "MIT", + "name": "cookie", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/cookie.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "e3c77d497d66c8b8d4b677b8954c1b192a09f0b3", - "bugs": { - "url": "https://github.com/jshttp/cookie/issues" - }, - "homepage": "https://github.com/jshttp/cookie", - "_id": "cookie@0.3.1", - "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "_from": "cookie@0.3.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb", - "tarball": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/cookie-0.3.1.tgz_1464323556714_0.6435900838114321" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.1" } diff --git a/node_modules/express/node_modules/debug/node_modules/ms/package.json b/node_modules/express/node_modules/debug/node_modules/ms/package.json index e36489e..c1734c9 100644 --- a/node_modules/express/node_modules/debug/node_modules/ms/package.json +++ b/node_modules/express/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,52 @@ { - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" + "_args": [ + [ + "ms@0.7.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.1", + "_id": "ms@0.7.1", + "_inBundle": false, + "_integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "_location": "/express/debug/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.1", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.1", + "saveSpec": null, + "fetchSpec": "0.7.1" }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" + "_requiredBy": [ + "/express/debug" + ], + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "_spec": "0.7.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" }, "component": { "scripts": { "ms/index.js": "index.js" } }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" + "description": "Tiny ms conversion utility", + "devDependencies": { + "expect.js": "*", + "mocha": "*", + "serve": "*" }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + "homepage": "https://github.com/guille/ms.js#readme", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.7.1" } diff --git a/node_modules/express/node_modules/debug/package.json b/node_modules/express/node_modules/debug/package.json index f2148c9..09f019f 100644 --- a/node_modules/express/node_modules/debug/package.json +++ b/node_modules/express/node_modules/debug/package.json @@ -1,20 +1,48 @@ { - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" + "_args": [ + [ + "debug@2.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "debug@2.2.0", + "_id": "debug@2.2.0", + "_inBundle": false, + "_integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "_location": "/express/debug", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "debug@2.2.0", + "name": "debug", + "escapedName": "debug", + "rawSpec": "2.2.0", + "saveSpec": null, + "fetchSpec": "2.2.0" }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" + "_requiredBy": [ + "/express", + "/express/finalhandler", + "/express/send" ], + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "_spec": "2.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, "contributors": [ { "name": "Nathan Rajlich", @@ -22,52 +50,26 @@ "url": "http://n8.io" } ], - "license": "MIT", "dependencies": { "ms": "0.7.1" }, + "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@>=2.2.0 <2.3.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } + "homepage": "https://github.com/visionmedia/debug#readme", + "keywords": [ + "debug", + "log", + "debugger" ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + "license": "MIT", + "main": "./node.js", + "name": "debug", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.2.0" } diff --git a/node_modules/express/node_modules/depd/package.json b/node_modules/express/node_modules/depd/package.json index edfc0b2..f5674cb 100644 --- a/node_modules/express/node_modules/depd/package.json +++ b/node_modules/express/node_modules/depd/package.json @@ -1,27 +1,51 @@ { - "name": "depd", - "description": "Deprecate all the things", - "version": "1.1.0", + "_args": [ + [ + "depd@1.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "depd@1.1.0", + "_id": "depd@1.1.0", + "_inBundle": false, + "_integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=", + "_location": "/express/depd", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "depd@1.1.0", + "name": "depd", + "escapedName": "depd", + "rawSpec": "1.1.0", + "saveSpec": null, + "fetchSpec": "1.1.0" + }, + "_requiredBy": [ + "/express", + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "_spec": "1.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "deprecate", - "deprecated" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/dougwilson/nodejs-depd.git" - }, "browser": "lib/browser/index.js", + "bugs": { + "url": "https://github.com/dougwilson/nodejs-depd/issues" + }, + "description": "Deprecate all the things", "devDependencies": { - "benchmark": "1.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0", "istanbul": "0.3.5", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "lib/", "History.md", @@ -29,8 +53,16 @@ "index.js", "Readme.md" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/dougwilson/nodejs-depd#readme", + "keywords": [ + "deprecate", + "deprecated" + ], + "license": "MIT", + "name": "depd", + "repository": { + "type": "git", + "url": "git+https://github.com/dougwilson/nodejs-depd.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -38,30 +70,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" }, - "gitHead": "78c659de20283e3a6bee92bda455e6daff01686a", - "bugs": { - "url": "https://github.com/dougwilson/nodejs-depd/issues" - }, - "homepage": "https://github.com/dougwilson/nodejs-depd", - "_id": "depd@1.1.0", - "_shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "_from": "depd@>=1.1.0 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "tarball": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.0" } diff --git a/node_modules/express/node_modules/encodeurl/package.json b/node_modules/express/node_modules/encodeurl/package.json index b9a2d11..6e62ee0 100644 --- a/node_modules/express/node_modules/encodeurl/package.json +++ b/node_modules/express/node_modules/encodeurl/package.json @@ -1,23 +1,44 @@ { - "name": "encodeurl", - "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences", - "version": "1.0.1", + "_args": [ + [ + "encodeurl@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "encodeurl@1.0.1", + "_id": "encodeurl@1.0.1", + "_inBundle": false, + "_integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", + "_location": "/express/encodeurl", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "encodeurl@1.0.1", + "name": "encodeurl", + "escapedName": "encodeurl", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/express", + "/express/send", + "/express/serve-static" + ], + "_resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/pillarjs/encodeurl/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "keywords": [ - "encode", - "encodeurl", - "url" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/encodeurl.git" - }, + "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences", "devDependencies": { "eslint": "2.11.1", "eslint-config-standard": "5.3.1", @@ -26,14 +47,26 @@ "istanbul": "0.4.3", "mocha": "2.5.3" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/pillarjs/encodeurl#readme", + "keywords": [ + "encode", + "encodeurl", + "url" + ], + "license": "MIT", + "name": "encodeurl", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/encodeurl.git" }, "scripts": { "lint": "eslint **/*.js", @@ -41,35 +74,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "39ed0c235fed4cea7d012038fd6bb0480561d226", - "bugs": { - "url": "https://github.com/pillarjs/encodeurl/issues" - }, - "homepage": "https://github.com/pillarjs/encodeurl#readme", - "_id": "encodeurl@1.0.1", - "_shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", - "_from": "encodeurl@>=1.0.1 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "79e3d58655346909fe6f0f45a5de68103b294d20", - "tarball": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/encodeurl-1.0.1.tgz_1465519736251_0.09314409433864057" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.1" } diff --git a/node_modules/express/node_modules/escape-html/package.json b/node_modules/express/node_modules/escape-html/package.json index 3f418d6..ab82c0a 100644 --- a/node_modules/express/node_modules/escape-html/package.json +++ b/node_modules/express/node_modules/escape-html/package.json @@ -1,57 +1,62 @@ { - "name": "escape-html", + "_args": [ + [ + "escape-html@1.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "escape-html@1.0.3", + "_id": "escape-html@1.0.3", + "_inBundle": false, + "_integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "_location": "/express/escape-html", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "escape-html@1.0.3", + "name": "escape-html", + "escapedName": "escape-html", + "rawSpec": "1.0.3", + "saveSpec": null, + "fetchSpec": "1.0.3" + }, + "_requiredBy": [ + "/express", + "/express/finalhandler", + "/express/send", + "/express/serve-static" + ], + "_resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "_spec": "1.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/component/escape-html/issues" + }, "description": "Escape string for use in HTML", - "version": "1.0.3", - "license": "MIT", + "devDependencies": { + "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0" + }, + "files": [ + "LICENSE", + "Readme.md", + "index.js" + ], + "homepage": "https://github.com/component/escape-html#readme", "keywords": [ "escape", "html", "utility" ], + "license": "MIT", + "name": "escape-html", "repository": { "type": "git", "url": "git+https://github.com/component/escape-html.git" }, - "devDependencies": { - "benchmark": "1.0.0", - "beautify-benchmark": "0.2.4" - }, - "files": [ - "LICENSE", - "Readme.md", - "index.js" - ], "scripts": { "bench": "node benchmark/index.js" }, - "gitHead": "7ac2ea3977fcac3d4c5be8d2a037812820c65f28", - "bugs": { - "url": "https://github.com/component/escape-html/issues" - }, - "homepage": "https://github.com/component/escape-html", - "_id": "escape-html@1.0.3", - "_shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", - "_from": "escape-html@>=1.0.3 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "0258eae4d3d0c0974de1c169188ef0051d1d1988", - "tarball": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.3" } diff --git a/node_modules/express/node_modules/etag/package.json b/node_modules/express/node_modules/etag/package.json index b1b5d22..60b5d6b 100644 --- a/node_modules/express/node_modules/etag/package.json +++ b/node_modules/express/node_modules/etag/package.json @@ -1,7 +1,36 @@ { - "name": "etag", - "description": "Create simple ETags", - "version": "1.7.0", + "_args": [ + [ + "etag@1.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "etag@1.7.0", + "_id": "etag@1.7.0", + "_inBundle": false, + "_integrity": "sha1-A9MLX2fdbmMtKUXTDWZScxo01dg=", + "_location": "/express/etag", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "etag@1.7.0", + "name": "etag", + "escapedName": "etag", + "rawSpec": "1.7.0", + "saveSpec": null, + "fetchSpec": "1.7.0" + }, + "_requiredBy": [ + "/express", + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", + "_spec": "1.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/etag/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -12,31 +41,34 @@ "email": "david.bjorklund@gmail.com" } ], - "license": "MIT", - "keywords": [ - "etag", - "http", - "res" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/etag.git" - }, + "description": "Create simple ETags", "devDependencies": { - "benchmark": "1.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0", "istanbul": "0.3.14", "mocha": "~1.21.4", "seedrandom": "2.3.11" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/etag#readme", + "keywords": [ + "etag", + "http", + "res" + ], + "license": "MIT", + "name": "etag", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/etag.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -44,30 +76,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "a511f5c8c930fd9546dbd88acb080f96bc788cfc", - "bugs": { - "url": "https://github.com/jshttp/etag/issues" - }, - "homepage": "https://github.com/jshttp/etag", - "_id": "etag@1.7.0", - "_shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "_from": "etag@>=1.7.0 <1.8.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "tarball": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.7.0" } diff --git a/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json b/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json index 1f8d214..36945d6 100644 --- a/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json +++ b/node_modules/express/node_modules/finalhandler/node_modules/statuses/package.json @@ -1,7 +1,35 @@ { - "name": "statuses", - "description": "HTTP status utility", - "version": "1.3.1", + "_args": [ + [ + "statuses@1.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "statuses@1.3.1", + "_id": "statuses@1.3.1", + "_inBundle": false, + "_integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "_location": "/express/finalhandler/statuses", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "statuses@1.3.1", + "name": "statuses", + "escapedName": "statuses", + "rawSpec": "1.3.1", + "saveSpec": null, + "fetchSpec": "1.3.1" + }, + "_requiredBy": [ + "/express/finalhandler" + ], + "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "_spec": "1.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/statuses/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,22 +41,7 @@ "url": "http://jongleberry.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/statuses.git" - }, - "license": "MIT", - "keywords": [ - "http", - "status", - "code" - ], - "files": [ - "HISTORY.md", - "index.js", - "codes.json", - "LICENSE" - ], + "description": "HTTP status utility", "devDependencies": { "csv-parse": "1.1.7", "eslint": "3.10.0", @@ -42,6 +55,24 @@ "engines": { "node": ">= 0.6" }, + "files": [ + "HISTORY.md", + "index.js", + "codes.json", + "LICENSE" + ], + "homepage": "https://github.com/jshttp/statuses#readme", + "keywords": [ + "http", + "status", + "code" + ], + "license": "MIT", + "name": "statuses", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/statuses.git" + }, "scripts": { "build": "node scripts/build.js", "fetch": "node scripts/fetch.js", @@ -51,54 +82,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "28a619be77f5b4741e6578a5764c5b06ec6d4aea", - "bugs": { - "url": "https://github.com/jshttp/statuses/issues" - }, - "homepage": "https://github.com/jshttp/statuses", - "_id": "statuses@1.3.1", - "_shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "_from": "statuses@>=1.3.1 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/statuses-1.3.1.tgz_1478923281491_0.5574048184789717" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.1" } diff --git a/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json b/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json index dc61177..57f0913 100644 --- a/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json +++ b/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json @@ -1,59 +1,65 @@ { - "name": "unpipe", - "description": "Unpipe a stream from all destinations", - "version": "1.0.0", + "_args": [ + [ + "unpipe@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "unpipe@1.0.0", + "_id": "unpipe@1.0.0", + "_inBundle": false, + "_integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "_location": "/express/finalhandler/unpipe", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "unpipe@1.0.0", + "name": "unpipe", + "escapedName": "unpipe", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/express/finalhandler" + ], + "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/unpipe.git" + "bugs": { + "url": "https://github.com/stream-utils/unpipe/issues" }, + "description": "Unpipe a stream from all destinations", "devDependencies": { "istanbul": "0.3.15", "mocha": "2.2.5", "readable-stream": "1.1.13" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/stream-utils/unpipe#readme", + "license": "MIT", + "name": "unpipe", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/unpipe.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "d2df901c06487430e78dca62b6edb8bb2fc5e99d", - "bugs": { - "url": "https://github.com/stream-utils/unpipe/issues" - }, - "homepage": "https://github.com/stream-utils/unpipe", - "_id": "unpipe@1.0.0", - "_shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "_from": "unpipe@>=1.0.0 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", - "tarball": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.0" } diff --git a/node_modules/express/node_modules/finalhandler/package.json b/node_modules/express/node_modules/finalhandler/package.json index cc7eaf3..432c928 100644 --- a/node_modules/express/node_modules/finalhandler/package.json +++ b/node_modules/express/node_modules/finalhandler/package.json @@ -1,15 +1,38 @@ { - "name": "finalhandler", - "description": "Node.js final http responder", - "version": "0.5.1", + "_args": [ + [ + "finalhandler@0.5.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "finalhandler@0.5.1", + "_id": "finalhandler@0.5.1", + "_inBundle": false, + "_integrity": "sha1-LEANjUUwk1vCMlScX6OF7Afeb80=", + "_location": "/express/finalhandler", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "finalhandler@0.5.1", + "name": "finalhandler", + "escapedName": "finalhandler", + "rawSpec": "0.5.1", + "saveSpec": null, + "fetchSpec": "0.5.1" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz", + "_spec": "0.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/pillarjs/finalhandler" + "bugs": { + "url": "https://github.com/pillarjs/finalhandler/issues" }, "dependencies": { "debug": "~2.2.0", @@ -18,6 +41,7 @@ "statuses": "~1.3.1", "unpipe": "~1.0.0" }, + "description": "Node.js final http responder", "devDependencies": { "eslint": "3.10.0", "eslint-config-standard": "6.2.1", @@ -29,13 +53,20 @@ "readable-stream": "2.1.2", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/pillarjs/finalhandler#readme", + "license": "MIT", + "name": "finalhandler", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/finalhandler.git" }, "scripts": { "lint": "eslint --plugin markdown --ext js,md .", @@ -43,33 +74,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "ae6137a81049eecb2d57341b1a9c4efed46a25da", - "bugs": { - "url": "https://github.com/pillarjs/finalhandler/issues" - }, - "homepage": "https://github.com/pillarjs/finalhandler", - "_id": "finalhandler@0.5.1", - "_shasum": "2c400d8d4530935bc232549c5fa385ec07de6fcd", - "_from": "finalhandler@0.5.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "2c400d8d4530935bc232549c5fa385ec07de6fcd", - "tarball": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/finalhandler-0.5.1.tgz_1479018213560_0.8304649770725518" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz" + "version": "0.5.1" } diff --git a/node_modules/express/node_modules/fresh/package.json b/node_modules/express/node_modules/fresh/package.json index c0fc622..b34ce92 100644 --- a/node_modules/express/node_modules/fresh/package.json +++ b/node_modules/express/node_modules/fresh/package.json @@ -1,12 +1,41 @@ { - "name": "fresh", - "description": "HTTP response freshness testing", - "version": "0.3.0", + "_args": [ + [ + "fresh@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "fresh@0.3.0", + "_id": "fresh@0.3.0", + "_inBundle": false, + "_integrity": "sha1-ZR+DjiJCTnVm3hYdg1jKoZn4PU8=", + "_location": "/express/fresh", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "fresh@0.3.0", + "name": "fresh", + "escapedName": "fresh", + "rawSpec": "0.3.0", + "saveSpec": null, + "fetchSpec": "0.3.0" + }, + "_requiredBy": [ + "/express", + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca", "url": "http://tjholowaychuk.com" }, + "bugs": { + "url": "https://github.com/jshttp/fresh/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,70 +47,36 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "fresh", - "http", - "conditional", - "cache" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/fresh.git" - }, + "description": "HTTP response freshness testing", "devDependencies": { "istanbul": "0.3.9", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/fresh#readme", + "keywords": [ + "fresh", + "http", + "conditional", + "cache" + ], + "license": "MIT", + "name": "fresh", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/fresh.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "14616c9748368ca08cd6a955dd88ab659b778634", - "bugs": { - "url": "https://github.com/jshttp/fresh/issues" - }, - "homepage": "https://github.com/jshttp/fresh", - "_id": "fresh@0.3.0", - "_shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "_from": "fresh@0.3.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "tarball": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.0" } diff --git a/node_modules/express/node_modules/merge-descriptors/package.json b/node_modules/express/node_modules/merge-descriptors/package.json index e2cde77..641b792 100644 --- a/node_modules/express/node_modules/merge-descriptors/package.json +++ b/node_modules/express/node_modules/merge-descriptors/package.json @@ -1,12 +1,40 @@ { - "name": "merge-descriptors", - "description": "Merge objects using descriptors", - "version": "1.0.1", + "_args": [ + [ + "merge-descriptors@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "merge-descriptors@1.0.1", + "_id": "merge-descriptors@1.0.1", + "_inBundle": false, + "_integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "_location": "/express/merge-descriptors", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "merge-descriptors@1.0.1", + "name": "merge-descriptors", + "escapedName": "merge-descriptors", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/component/merge-descriptors/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -17,11 +45,7 @@ "email": "grabbou@gmail.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/component/merge-descriptors.git" - }, + "description": "Merge objects using descriptors", "devDependencies": { "istanbul": "0.4.1", "mocha": "1.21.5" @@ -32,107 +56,17 @@ "README.md", "index.js" ], + "homepage": "https://github.com/component/merge-descriptors#readme", + "license": "MIT", + "name": "merge-descriptors", + "repository": { + "type": "git", + "url": "git+https://github.com/component/merge-descriptors.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "f26c49c3b423b0b2ac31f6e32a84e1632f2d7ac2", - "bugs": { - "url": "https://github.com/component/merge-descriptors/issues" - }, - "homepage": "https://github.com/component/merge-descriptors", - "_id": "merge-descriptors@1.0.1", - "_shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", - "_from": "merge-descriptors@1.0.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "anthonyshort", - "email": "antshort@gmail.com" - }, - { - "name": "clintwood", - "email": "clint@anotherway.co.za" - }, - { - "name": "dfcreative", - "email": "df.creative@gmail.com" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "ianstormtaylor", - "email": "ian@ianstormtaylor.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "mattmueller", - "email": "mattmuelle@gmail.com" - }, - { - "name": "queckezz", - "email": "fabian.eichenberger@gmail.com" - }, - { - "name": "stephenmathieson", - "email": "me@stephenmathieson.com" - }, - { - "name": "thehydroimpulse", - "email": "dnfagnan@gmail.com" - }, - { - "name": "timaschew", - "email": "timaschew@gmail.com" - }, - { - "name": "timoxley", - "email": "secoif@gmail.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "trevorgerhardt", - "email": "trevorgerhardt@gmail.com" - }, - { - "name": "yields", - "email": "yields@icloud.com" - } - ], - "dist": { - "shasum": "b00aaa556dd8b44568150ec9d1b953f3f90cbb61", - "tarball": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.1" } diff --git a/node_modules/express/node_modules/methods/package.json b/node_modules/express/node_modules/methods/package.json index 09ed887..b88b450 100644 --- a/node_modules/express/node_modules/methods/package.json +++ b/node_modules/express/node_modules/methods/package.json @@ -1,7 +1,38 @@ { - "name": "methods", - "description": "HTTP methods that node supports", - "version": "1.1.2", + "_args": [ + [ + "methods@1.1.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "methods@1.1.2", + "_id": "methods@1.1.2", + "_inBundle": false, + "_integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "_location": "/express/methods", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "methods@1.1.2", + "name": "methods", + "escapedName": "methods", + "rawSpec": "1.1.2", + "saveSpec": null, + "fetchSpec": "1.1.2" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "_spec": "1.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "browser": { + "http": false + }, + "bugs": { + "url": "https://github.com/jshttp/methods/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,71 +49,34 @@ "url": "http://tjholowaychuk.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/methods.git" - }, + "description": "HTTP methods that node supports", "devDependencies": { "istanbul": "0.4.1", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "index.js", "HISTORY.md", "LICENSE" ], - "engines": { - "node": ">= 0.6" - }, - "scripts": { - "test": "mocha --reporter spec --bail --check-leaks test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, - "browser": { - "http": false - }, + "homepage": "https://github.com/jshttp/methods#readme", "keywords": [ "http", "methods" ], - "gitHead": "25d257d913f1b94bd2d73581521ff72c81469140", - "bugs": { - "url": "https://github.com/jshttp/methods/issues" - }, - "homepage": "https://github.com/jshttp/methods", - "_id": "methods@1.1.2", - "_shasum": "5529a4d67654134edcc5266656835b0f851afcee", - "_from": "methods@>=1.1.2 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" + "license": "MIT", + "name": "methods", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/methods.git" }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "5529a4d67654134edcc5266656835b0f851afcee", - "tarball": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.2" } diff --git a/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json b/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json index c67faf1..736621f 100644 --- a/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json +++ b/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json @@ -1,23 +1,47 @@ { - "name": "ee-first", - "description": "return the first event in a set of ee/event pairs", - "version": "1.1.1", + "_args": [ + [ + "ee-first@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ee-first@1.1.1", + "_id": "ee-first@1.1.1", + "_inBundle": false, + "_integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "_location": "/express/on-finished/ee-first", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ee-first@1.1.1", + "name": "ee-first", + "escapedName": "ee-first", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/express/on-finished" + ], + "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/jonathanong/ee-first/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jonathanong/ee-first.git" - }, + "description": "return the first event in a set of ee/event pairs", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -26,39 +50,17 @@ "index.js", "LICENSE" ], + "homepage": "https://github.com/jonathanong/ee-first#readme", + "license": "MIT", + "name": "ee-first", + "repository": { + "type": "git", + "url": "git+https://github.com/jonathanong/ee-first.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "512e0ce4cc3643f603708f965a97b61b1a9c0441", - "bugs": { - "url": "https://github.com/jonathanong/ee-first/issues" - }, - "homepage": "https://github.com/jonathanong/ee-first", - "_id": "ee-first@1.1.1", - "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "_from": "ee-first@1.1.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "tarball": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.1" } diff --git a/node_modules/express/node_modules/on-finished/package.json b/node_modules/express/node_modules/on-finished/package.json index 97a5680..46b087e 100644 --- a/node_modules/express/node_modules/on-finished/package.json +++ b/node_modules/express/node_modules/on-finished/package.json @@ -1,7 +1,37 @@ { - "name": "on-finished", - "description": "Execute a callback when a request closes, finishes, or errors", - "version": "2.3.0", + "_args": [ + [ + "on-finished@2.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "on-finished@2.3.0", + "_id": "on-finished@2.3.0", + "_inBundle": false, + "_integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "_location": "/express/on-finished", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "on-finished@2.3.0", + "name": "on-finished", + "escapedName": "on-finished", + "rawSpec": "2.3.0", + "saveSpec": null, + "fetchSpec": "2.3.0" + }, + "_requiredBy": [ + "/express", + "/express/finalhandler", + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "_spec": "2.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/on-finished/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,14 +43,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/on-finished.git" - }, "dependencies": { "ee-first": "1.1.1" }, + "description": "Execute a callback when a request closes, finishes, or errors", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -33,39 +59,17 @@ "LICENSE", "index.js" ], + "homepage": "https://github.com/jshttp/on-finished#readme", + "license": "MIT", + "name": "on-finished", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-finished.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "34babcb58126a416fcf5205768204f2e12699dda", - "bugs": { - "url": "https://github.com/jshttp/on-finished/issues" - }, - "homepage": "https://github.com/jshttp/on-finished", - "_id": "on-finished@2.3.0", - "_shasum": "20f1336481b083cd75337992a16971aa2d906947", - "_from": "on-finished@>=2.3.0 <2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "20f1336481b083cd75337992a16971aa2d906947", - "tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.3.0" } diff --git a/node_modules/express/node_modules/parseurl/package.json b/node_modules/express/node_modules/parseurl/package.json index 7f57caa..8f45f99 100644 --- a/node_modules/express/node_modules/parseurl/package.json +++ b/node_modules/express/node_modules/parseurl/package.json @@ -1,38 +1,70 @@ { - "name": "parseurl", - "description": "parse a url with memoization", - "version": "1.3.1", + "_args": [ + [ + "parseurl@1.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "parseurl@1.3.1", + "_id": "parseurl@1.3.1", + "_inBundle": false, + "_integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", + "_location": "/express/parseurl", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "parseurl@1.3.1", + "name": "parseurl", + "escapedName": "parseurl", + "rawSpec": "1.3.1", + "saveSpec": null, + "fetchSpec": "1.3.1" + }, + "_requiredBy": [ + "/express", + "/express/serve-static" + ], + "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "_spec": "1.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/pillarjs/parseurl/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/parseurl.git" - }, - "license": "MIT", + "description": "parse a url with memoization", "devDependencies": { - "benchmark": "2.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "2.0.0", "fast-url-parser": "1.1.3", "istanbul": "0.4.2", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/pillarjs/parseurl#readme", + "license": "MIT", + "name": "parseurl", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/parseurl.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -40,50 +72,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec test/" }, - "gitHead": "6d22d376d75b927ab2b5347ce3a1d6735133dd43", - "bugs": { - "url": "https://github.com/pillarjs/parseurl/issues" - }, - "homepage": "https://github.com/pillarjs/parseurl", - "_id": "parseurl@1.3.1", - "_shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "_from": "parseurl@>=1.3.1 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - } - ], - "dist": { - "shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "tarball": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.1" } diff --git a/node_modules/express/node_modules/path-to-regexp/package.json b/node_modules/express/node_modules/path-to-regexp/package.json index 042586a..b359e00 100644 --- a/node_modules/express/node_modules/path-to-regexp/package.json +++ b/node_modules/express/node_modules/path-to-regexp/package.json @@ -1,185 +1,62 @@ { - "name": "path-to-regexp", + "_args": [ + [ + "path-to-regexp@0.1.7", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "path-to-regexp@0.1.7", + "_id": "path-to-regexp@0.1.7", + "_inBundle": false, + "_integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", + "_location": "/express/path-to-regexp", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "path-to-regexp@0.1.7", + "name": "path-to-regexp", + "escapedName": "path-to-regexp", + "rawSpec": "0.1.7", + "saveSpec": null, + "fetchSpec": "0.1.7" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "_spec": "0.1.7", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/component/path-to-regexp/issues" + }, + "component": { + "scripts": { + "path-to-regexp": "index.js" + } + }, "description": "Express style path to RegExp utility", - "version": "0.1.7", + "devDependencies": { + "istanbul": "^0.2.6", + "mocha": "^1.17.1" + }, "files": [ "index.js", "LICENSE" ], - "scripts": { - "test": "istanbul cover _mocha -- -R spec" - }, + "homepage": "https://github.com/component/path-to-regexp#readme", "keywords": [ "express", "regexp" ], - "component": { - "scripts": { - "path-to-regexp": "index.js" - } - }, "license": "MIT", + "name": "path-to-regexp", "repository": { "type": "git", "url": "git+https://github.com/component/path-to-regexp.git" }, - "devDependencies": { - "mocha": "^1.17.1", - "istanbul": "^0.2.6" - }, - "gitHead": "039118d6c3c186d3f176c73935ca887a32a33d93", - "bugs": { - "url": "https://github.com/component/path-to-regexp/issues" - }, - "homepage": "https://github.com/component/path-to-regexp#readme", - "_id": "path-to-regexp@0.1.7", - "_shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", - "_from": "path-to-regexp@0.1.7", - "_npmVersion": "2.13.2", - "_nodeVersion": "2.3.3", - "_npmUser": { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "hughsk", - "email": "hughskennedy@gmail.com" - }, - { - "name": "timaschew", - "email": "timaschew@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - { - "name": "retrofox", - "email": "rdsuarez@gmail.com" - }, - { - "name": "coreh", - "email": "thecoreh@gmail.com" - }, - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "kelonye", - "email": "kelonyemitchel@gmail.com" - }, - { - "name": "mattmueller", - "email": "mattmuelle@gmail.com" - }, - { - "name": "yields", - "email": "yields@icloud.com" - }, - { - "name": "anthonyshort", - "email": "antshort@gmail.com" - }, - { - "name": "ianstormtaylor", - "email": "ian@ianstormtaylor.com" - }, - { - "name": "cristiandouce", - "email": "cristian@gravityonmars.com" - }, - { - "name": "swatinem", - "email": "arpad.borsos@googlemail.com" - }, - { - "name": "stagas", - "email": "gstagas@gmail.com" - }, - { - "name": "amasad", - "email": "amjad.masad@gmail.com" - }, - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - { - "name": "calvinfo", - "email": "calvin@calv.info" - }, - { - "name": "blakeembrey", - "email": "hello@blakeembrey.com" - }, - { - "name": "timoxley", - "email": "secoif@gmail.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "queckezz", - "email": "fabian.eichenberger@gmail.com" - }, - { - "name": "nami-doc", - "email": "vendethiel@hotmail.fr" - }, - { - "name": "clintwood", - "email": "clint@anotherway.co.za" - }, - { - "name": "thehydroimpulse", - "email": "dnfagnan@gmail.com" - }, - { - "name": "stephenmathieson", - "email": "me@stephenmathieson.com" - }, - { - "name": "trevorgerhardt", - "email": "trevorgerhardt@gmail.com" - }, - { - "name": "dfcreative", - "email": "df.creative@gmail.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - } - ], - "dist": { - "shasum": "df604178005f522f15eb4490e7247a1bfaa67f8c", - "tarball": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" + "scripts": { + "test": "istanbul cover _mocha -- -R spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "readme": "ERROR: No README data found!" + "version": "0.1.7" } diff --git a/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json b/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json index 35297a6..a55081f 100644 --- a/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json +++ b/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json @@ -1,65 +1,71 @@ { - "name": "forwarded", - "description": "Parse HTTP X-Forwarded-For header", - "version": "0.1.0", + "_args": [ + [ + "forwarded@0.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "forwarded@0.1.0", + "_id": "forwarded@0.1.0", + "_inBundle": false, + "_integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=", + "_location": "/express/proxy-addr/forwarded", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "forwarded@0.1.0", + "name": "forwarded", + "escapedName": "forwarded", + "rawSpec": "0.1.0", + "saveSpec": null, + "fetchSpec": "0.1.0" + }, + "_requiredBy": [ + "/express/proxy-addr" + ], + "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", + "_spec": "0.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/forwarded/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "keywords": [ - "x-forwarded-for", - "http", - "req" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/forwarded.git" - }, + "description": "Parse HTTP X-Forwarded-For header", "devDependencies": { "istanbul": "0.3.2", "mocha": "~1.21.4" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/forwarded#readme", + "keywords": [ + "x-forwarded-for", + "http", + "req" + ], + "license": "MIT", + "name": "forwarded", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/forwarded.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "e9a9faeb3cfaadf40eb57d144fff26bca9b818e8", - "bugs": { - "url": "https://github.com/jshttp/forwarded/issues" - }, - "homepage": "https://github.com/jshttp/forwarded", - "_id": "forwarded@0.1.0", - "_shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", - "_from": "forwarded@>=0.1.0 <0.2.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "19ef9874c4ae1c297bcf078fde63a09b66a84363", - "tarball": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", - "readme": "ERROR: No README data found!" + "version": "0.1.0" } diff --git a/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json b/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json index 7e9a2d0..fd084c0 100644 --- a/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json +++ b/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json @@ -1,64 +1,67 @@ { - "name": "ipaddr.js", - "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.", - "version": "1.3.0", + "_args": [ + [ + "ipaddr.js@1.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ipaddr.js@1.3.0", + "_id": "ipaddr.js@1.3.0", + "_inBundle": false, + "_integrity": "sha1-HgOlL9rYOou7KyXL9JmLTP/NPew=", + "_location": "/express/proxy-addr/ipaddr.js", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ipaddr.js@1.3.0", + "name": "ipaddr.js", + "escapedName": "ipaddr.js", + "rawSpec": "1.3.0", + "saveSpec": null, + "fetchSpec": "1.3.0" + }, + "_requiredBy": [ + "/express/proxy-addr" + ], + "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", + "_spec": "1.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "whitequark", "email": "whitequark@whitequark.org" }, - "directories": { - "lib": "./lib" + "bugs": { + "url": "https://github.com/whitequark/ipaddr.js/issues" }, "dependencies": {}, + "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.", "devDependencies": { "coffee-script": "~1.6", "nodeunit": ">=0.8.2 <0.8.7", "uglify-js": "latest" }, - "scripts": { - "test": "cake build test" + "directories": { + "lib": "./lib" }, + "engines": { + "node": ">= 0.10" + }, + "homepage": "https://github.com/whitequark/ipaddr.js#readme", "keywords": [ "ip", "ipv4", "ipv6" ], + "license": "MIT", + "main": "./lib/ipaddr", + "name": "ipaddr.js", "repository": { "type": "git", "url": "git://github.com/whitequark/ipaddr.js.git" }, - "main": "./lib/ipaddr", - "engines": { - "node": ">= 0.10" - }, - "license": "MIT", - "gitHead": "9c557556e495a2c60a3c656e4f9f8b3a1e14dedc", - "bugs": { - "url": "https://github.com/whitequark/ipaddr.js/issues" - }, - "homepage": "https://github.com/whitequark/ipaddr.js#readme", - "_id": "ipaddr.js@1.3.0", - "_shasum": "1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec", - "_from": "ipaddr.js@1.3.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "whitequark", - "email": "whitequark@whitequark.org" - }, - "maintainers": [ - { - "name": "whitequark", - "email": "whitequark@whitequark.org" - } - ], - "dist": { - "shasum": "1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec", - "tarball": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/ipaddr.js-1.3.0.tgz_1489544932893_0.961968986550346" + "scripts": { + "test": "cake build test" }, - "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.0" } diff --git a/node_modules/express/node_modules/proxy-addr/package.json b/node_modules/express/node_modules/proxy-addr/package.json index 93227d7..ef9a97a 100644 --- a/node_modules/express/node_modules/proxy-addr/package.json +++ b/node_modules/express/node_modules/proxy-addr/package.json @@ -1,39 +1,70 @@ { - "name": "proxy-addr", - "description": "Determine address of proxied request", - "version": "1.1.4", + "_args": [ + [ + "proxy-addr@1.1.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "proxy-addr@1.1.4", + "_id": "proxy-addr@1.1.4", + "_inBundle": false, + "_integrity": "sha1-J+VF9pYKRKYn2bREZ+NcG2tM4vM=", + "_location": "/express/proxy-addr", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "proxy-addr@1.1.4", + "name": "proxy-addr", + "escapedName": "proxy-addr", + "rawSpec": "1.1.4", + "saveSpec": null, + "fetchSpec": "1.1.4" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", + "_spec": "1.1.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "ip", - "proxy", - "x-forwarded-for" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/proxy-addr.git" + "bugs": { + "url": "https://github.com/jshttp/proxy-addr/issues" }, "dependencies": { "forwarded": "~0.1.0", "ipaddr.js": "1.3.0" }, + "description": "Determine address of proxied request", "devDependencies": { - "benchmark": "2.1.3", "beautify-benchmark": "0.2.4", + "benchmark": "2.1.3", "istanbul": "0.4.5", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/proxy-addr#readme", + "keywords": [ + "ip", + "proxy", + "x-forwarded-for" + ], + "license": "MIT", + "name": "proxy-addr", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/proxy-addr.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -41,35 +72,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "4c636264c036d9825e8a3cf50555a272e3246fe6", - "bugs": { - "url": "https://github.com/jshttp/proxy-addr/issues" - }, - "homepage": "https://github.com/jshttp/proxy-addr#readme", - "_id": "proxy-addr@1.1.4", - "_shasum": "27e545f6960a44a627d9b44467e35c1b6b4ce2f3", - "_from": "proxy-addr@>=1.1.3 <1.2.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "27e545f6960a44a627d9b44467e35c1b6b4ce2f3", - "tarball": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/proxy-addr-1.1.4.tgz_1490396252699_0.9566438721958548" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.4.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.4" } diff --git a/node_modules/express/node_modules/qs/package.json b/node_modules/express/node_modules/qs/package.json index 265c172..fe40457 100644 --- a/node_modules/express/node_modules/qs/package.json +++ b/node_modules/express/node_modules/qs/package.json @@ -1,13 +1,35 @@ { - "name": "qs", - "description": "A querystring parser that supports nesting and arrays, with a depth limit", - "homepage": "https://github.com/ljharb/qs", - "version": "6.2.0", - "repository": { - "type": "git", - "url": "git+https://github.com/ljharb/qs.git" + "_args": [ + [ + "qs@6.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "qs@6.2.0", + "_id": "qs@6.2.0", + "_inBundle": false, + "_integrity": "sha1-O3hIwDwt7OaalSKw+ujEEm10Xzs=", + "_location": "/express/qs", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "qs@6.2.0", + "name": "qs", + "escapedName": "qs", + "rawSpec": "6.2.0", + "saveSpec": null, + "fetchSpec": "6.2.0" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", + "_spec": "6.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/ljharb/qs/issues" }, - "main": "lib/index.js", "contributors": [ { "name": "Jordan Harband", @@ -15,72 +37,43 @@ "url": "http://ljharb.codes" } ], - "keywords": [ - "querystring", - "qs" - ], - "engines": { - "node": ">=0.6" - }, "dependencies": {}, + "description": "A querystring parser that supports nesting and arrays, with a depth limit", "devDependencies": { + "@ljharb/eslint-config": "^4.0.0", "browserify": "^13.0.1", - "tape": "^4.5.1", "covert": "^1.1.0", - "mkdirp": "^0.5.1", "eslint": "^2.9.0", - "@ljharb/eslint-config": "^4.0.0", - "parallelshell": "^2.0.0", + "evalmd": "^0.0.17", "iconv-lite": "^0.4.13", - "evalmd": "^0.0.17" + "mkdirp": "^0.5.1", + "parallelshell": "^2.0.0", + "tape": "^4.5.1" }, - "scripts": { - "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", - "test": "npm run --silent coverage", - "tests-only": "node test", - "readme": "evalmd README.md", - "lint": "eslint lib/*.js text/*.js", - "coverage": "covert test", - "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", - "prepublish": "npm run dist" + "engines": { + "node": ">=0.6" }, + "homepage": "https://github.com/ljharb/qs", + "keywords": [ + "querystring", + "qs" + ], "license": "BSD-3-Clause", - "gitHead": "d67d315b606c6bb809fedcbeebbbdb7f863852aa", - "bugs": { - "url": "https://github.com/ljharb/qs/issues" - }, - "_id": "qs@6.2.0", - "_shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "_from": "qs@6.2.0", - "_npmVersion": "3.8.6", - "_nodeVersion": "6.1.0", - "_npmUser": { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - "dist": { - "shasum": "3b7848c03c2dece69a9522b0fae8c4126d745f3b", - "tarball": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz" + "main": "lib/index.js", + "name": "qs", + "repository": { + "type": "git", + "url": "git+https://github.com/ljharb/qs.git" }, - "maintainers": [ - { - "name": "hueniverse", - "email": "eran@hammer.io" - }, - { - "name": "ljharb", - "email": "ljharb@gmail.com" - }, - { - "name": "nlf", - "email": "quitlahok@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/qs-6.2.0.tgz_1462749349998_0.03372702235355973" + "scripts": { + "coverage": "covert test", + "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js", + "lint": "eslint lib/*.js text/*.js", + "prepublish": "npm run dist", + "pretest": "parallelshell 'npm run --silent readme' 'npm run --silent lint'", + "readme": "evalmd README.md", + "test": "npm run --silent coverage", + "tests-only": "node test" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "6.2.0" } diff --git a/node_modules/express/node_modules/range-parser/package.json b/node_modules/express/node_modules/range-parser/package.json index 060a5cf..8397da6 100644 --- a/node_modules/express/node_modules/range-parser/package.json +++ b/node_modules/express/node_modules/range-parser/package.json @@ -1,12 +1,41 @@ { - "name": "range-parser", + "_args": [ + [ + "range-parser@1.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "range-parser@1.2.0", + "_id": "range-parser@1.2.0", + "_inBundle": false, + "_integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=", + "_location": "/express/range-parser", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "range-parser@1.2.0", + "name": "range-parser", + "escapedName": "range-parser", + "rawSpec": "1.2.0", + "saveSpec": null, + "fetchSpec": "1.2.0" + }, + "_requiredBy": [ + "/express", + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "_spec": "1.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca", "url": "http://tjholowaychuk.com" }, - "description": "Range header field string parser", - "version": "1.2.0", + "bugs": { + "url": "https://github.com/jshttp/range-parser/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -22,16 +51,7 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "range", - "parser", - "http" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/range-parser.git" - }, + "description": "Range header field string parser", "devDependencies": { "eslint": "2.11.1", "eslint-config-standard": "5.3.1", @@ -40,13 +60,25 @@ "istanbul": "0.4.3", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/range-parser#readme", + "keywords": [ + "range", + "parser", + "http" + ], + "license": "MIT", + "name": "range-parser", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/range-parser.git" }, "scripts": { "lint": "eslint **/*.js", @@ -54,46 +86,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" }, - "gitHead": "0665aca31639d799dee1d35fb10970799559ec48", - "bugs": { - "url": "https://github.com/jshttp/range-parser/issues" - }, - "homepage": "https://github.com/jshttp/range-parser", - "_id": "range-parser@1.2.0", - "_shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", - "_from": "range-parser@>=1.2.0 <1.3.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "f49be6b487894ddc40dcc94a322f611092e00d5e", - "tarball": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/range-parser-1.2.0.tgz_1464803293097_0.6830497414339334" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.2.0" } diff --git a/node_modules/express/node_modules/send/node_modules/.bin/mime b/node_modules/express/node_modules/send/node_modules/.bin/mime deleted file mode 100755 index 20b1ffe..0000000 --- a/node_modules/express/node_modules/send/node_modules/.bin/mime +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env node - -var mime = require('./mime.js'); -var file = process.argv[2]; -var type = mime.lookup(file); - -process.stdout.write(type + '\n'); - diff --git a/node_modules/express/node_modules/send/node_modules/.bin/mime b/node_modules/express/node_modules/send/node_modules/.bin/mime new file mode 120000 index 0000000..fbb7ee0 --- /dev/null +++ b/node_modules/express/node_modules/send/node_modules/.bin/mime @@ -0,0 +1 @@ +../mime/cli.js \ No newline at end of file diff --git a/node_modules/express/node_modules/send/node_modules/destroy/package.json b/node_modules/express/node_modules/send/node_modules/destroy/package.json index ec1ed98..0941a72 100644 --- a/node_modules/express/node_modules/send/node_modules/destroy/package.json +++ b/node_modules/express/node_modules/send/node_modules/destroy/package.json @@ -1,36 +1,56 @@ { - "name": "destroy", - "description": "destroy a stream if possible", - "version": "1.0.4", + "_args": [ + [ + "destroy@1.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "destroy@1.0.4", + "_id": "destroy@1.0.4", + "_inBundle": false, + "_integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", + "_location": "/express/send/destroy", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "destroy@1.0.4", + "name": "destroy", + "escapedName": "destroy", + "rawSpec": "1.0.4", + "saveSpec": null, + "fetchSpec": "1.0.4" + }, + "_requiredBy": [ + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "_spec": "1.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/stream-utils/destroy/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/stream-utils/destroy.git" - }, + "description": "destroy a stream if possible", "devDependencies": { "istanbul": "0.4.2", "mocha": "2.3.4" }, - "scripts": { - "test": "mocha --reporter spec", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, "files": [ "index.js", "LICENSE" ], + "homepage": "https://github.com/stream-utils/destroy#readme", "keywords": [ "stream", "streams", @@ -39,34 +59,16 @@ "leak", "fd" ], - "gitHead": "86edea01456f5fa1027f6a47250c34c713cbcc3b", - "bugs": { - "url": "https://github.com/stream-utils/destroy/issues" - }, - "homepage": "https://github.com/stream-utils/destroy", - "_id": "destroy@1.0.4", - "_shasum": "978857442c44749e4206613e37946205826abd80", - "_from": "destroy@>=1.0.4 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" + "license": "MIT", + "name": "destroy", + "repository": { + "type": "git", + "url": "git+https://github.com/stream-utils/destroy.git" }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "978857442c44749e4206613e37946205826abd80", - "tarball": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz" + "scripts": { + "test": "mocha --reporter spec", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.4" } diff --git a/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json b/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json index 092ed55..72ddcab 100644 --- a/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json +++ b/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json @@ -1,7 +1,45 @@ { - "name": "inherits", + "_args": [ + [ + "inherits@2.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "inherits@2.0.3", + "_id": "inherits@2.0.3", + "_inBundle": false, + "_integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "_location": "/express/send/http-errors/inherits", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "inherits@2.0.3", + "name": "inherits", + "escapedName": "inherits", + "rawSpec": "2.0.3", + "saveSpec": null, + "fetchSpec": "2.0.3" + }, + "_requiredBy": [ + "/express/send/http-errors" + ], + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "_spec": "2.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "browser": "./inherits_browser.js", + "bugs": { + "url": "https://github.com/isaacs/inherits/issues" + }, "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", - "version": "2.0.3", + "devDependencies": { + "tap": "^7.1.0" + }, + "files": [ + "inherits.js", + "inherits_browser.js" + ], + "homepage": "https://github.com/isaacs/inherits#readme", "keywords": [ "inheritance", "class", @@ -12,52 +50,15 @@ "browser", "browserify" ], + "license": "ISC", "main": "./inherits.js", - "browser": "./inherits_browser.js", + "name": "inherits", "repository": { "type": "git", "url": "git://github.com/isaacs/inherits.git" }, - "license": "ISC", "scripts": { "test": "node test" }, - "devDependencies": { - "tap": "^7.1.0" - }, - "files": [ - "inherits.js", - "inherits_browser.js" - ], - "gitHead": "e05d0fb27c61a3ec687214f0476386b765364d5f", - "bugs": { - "url": "https://github.com/isaacs/inherits/issues" - }, - "homepage": "https://github.com/isaacs/inherits#readme", - "_id": "inherits@2.0.3", - "_shasum": "633c2c83e3da42a502f52466022480f4208261de", - "_from": "inherits@2.0.3", - "_npmVersion": "3.10.7", - "_nodeVersion": "6.5.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "633c2c83e3da42a502f52466022480f4208261de", - "tarball": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/inherits-2.0.3.tgz_1473295776489_0.08142363070510328" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readme": "ERROR: No README data found!" + "version": "2.0.3" } diff --git a/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json b/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json index 33c91f8..fd92012 100644 --- a/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json +++ b/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/setprototypeof/package.json @@ -1,53 +1,54 @@ { - "name": "setprototypeof", - "version": "1.0.2", - "description": "A small polyfill for Object.setprototypeof", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/wesleytodd/setprototypeof.git" + "_args": [ + [ + "setprototypeof@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "setprototypeof@1.0.2", + "_id": "setprototypeof@1.0.2", + "_inBundle": false, + "_integrity": "sha1-gaVSFB7BBLiOic44MQOtXGZWTQg=", + "_location": "/express/send/http-errors/setprototypeof", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "setprototypeof@1.0.2", + "name": "setprototypeof", + "escapedName": "setprototypeof", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" }, - "keywords": [ - "polyfill", - "object", - "setprototypeof" + "_requiredBy": [ + "/express/send/http-errors" ], + "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Wes Todd" }, - "license": "ISC", "bugs": { "url": "https://github.com/wesleytodd/setprototypeof/issues" }, + "description": "A small polyfill for Object.setprototypeof", "homepage": "https://github.com/wesleytodd/setprototypeof", - "gitHead": "34da239ae7ab69b7b42791d5b928379ce51a0ff2", - "_id": "setprototypeof@1.0.2", - "_shasum": "81a552141ec104b88e89ce383103ad5c66564d08", - "_from": "setprototypeof@1.0.2", - "_npmVersion": "3.10.8", - "_nodeVersion": "7.0.0", - "_npmUser": { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - }, - "dist": { - "shasum": "81a552141ec104b88e89ce383103ad5c66564d08", - "tarball": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz" - }, - "maintainers": [ - { - "name": "wesleytodd", - "email": "wes@wesleytodd.com" - } + "keywords": [ + "polyfill", + "object", + "setprototypeof" ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/setprototypeof-1.0.2.tgz_1479056139581_0.43114364007487893" + "license": "ISC", + "main": "index.js", + "name": "setprototypeof", + "repository": { + "type": "git", + "url": "git+https://github.com/wesleytodd/setprototypeof.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", - "readme": "ERROR: No README data found!" + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.0.2" } diff --git a/node_modules/express/node_modules/send/node_modules/http-errors/package.json b/node_modules/express/node_modules/send/node_modules/http-errors/package.json index ee086d0..a31ddfa 100644 --- a/node_modules/express/node_modules/send/node_modules/http-errors/package.json +++ b/node_modules/express/node_modules/send/node_modules/http-errors/package.json @@ -1,12 +1,40 @@ { - "name": "http-errors", - "description": "Create HTTP error objects", - "version": "1.5.1", + "_args": [ + [ + "http-errors@1.5.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "http-errors@1.5.1", + "_id": "http-errors@1.5.1", + "_inBundle": false, + "_integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=", + "_location": "/express/send/http-errors", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "http-errors@1.5.1", + "name": "http-errors", + "escapedName": "http-errors", + "rawSpec": "1.5.1", + "saveSpec": null, + "fetchSpec": "1.5.1" + }, + "_requiredBy": [ + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", + "_spec": "1.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/jshttp/http-errors/issues" + }, "contributors": [ { "name": "Alan Plum", @@ -17,16 +45,12 @@ "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/http-errors.git" - }, "dependencies": { "inherits": "2.0.3", "setprototypeof": "1.0.2", "statuses": ">= 1.3.1 < 2" }, + "description": "Create HTTP error objects", "devDependencies": { "eslint": "3.10.2", "eslint-config-standard": "6.2.1", @@ -39,58 +63,28 @@ "engines": { "node": ">= 0.6" }, - "scripts": { - "lint": "eslint --plugin markdown --ext js,md .", - "test": "mocha --reporter spec --bail", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" - }, - "keywords": [ - "http", - "error" - ], "files": [ "index.js", "HISTORY.md", "LICENSE", "README.md" ], - "gitHead": "a55db90c7a2c0bafedb4bfa35a85eee5f53a37e9", - "bugs": { - "url": "https://github.com/jshttp/http-errors/issues" - }, - "homepage": "https://github.com/jshttp/http-errors", - "_id": "http-errors@1.5.1", - "_shasum": "788c0d2c1de2c81b9e6e8c01843b6b97eb920750", - "_from": "http-errors@>=1.5.1 <1.6.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "egeste", - "email": "npm@egeste.net" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } + "homepage": "https://github.com/jshttp/http-errors#readme", + "keywords": [ + "http", + "error" ], - "dist": { - "shasum": "788c0d2c1de2c81b9e6e8c01843b6b97eb920750", - "tarball": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz" + "license": "MIT", + "name": "http-errors", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/http-errors.git" }, - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/http-errors-1.5.1.tgz_1479361411507_0.47469806275330484" + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --bail", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.5.1" } diff --git a/node_modules/express/node_modules/send/node_modules/mime/package.json b/node_modules/express/node_modules/send/node_modules/mime/package.json index 9c9c711..8e9da58 100644 --- a/node_modules/express/node_modules/send/node_modules/mime/package.json +++ b/node_modules/express/node_modules/send/node_modules/mime/package.json @@ -1,16 +1,43 @@ { + "_args": [ + [ + "mime@1.3.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime@1.3.4", + "_id": "mime@1.3.4", + "_inBundle": false, + "_integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=", + "_location": "/express/send/mime", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime@1.3.4", + "name": "mime", + "escapedName": "mime", + "rawSpec": "1.3.4", + "saveSpec": null, + "fetchSpec": "1.3.4" + }, + "_requiredBy": [ + "/express/send" + ], + "_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "_spec": "1.3.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Robert Kieffer", "email": "robert@broofa.com", "url": "http://github.com/broofa" }, - "scripts": { - "prepublish": "node build/build.js > types.json", - "test": "node build/test.js" - }, "bin": { "mime": "cli.js" }, + "bugs": { + "url": "https://github.com/broofa/node-mime/issues" + }, "contributors": [ { "name": "Benjamin Thomas", @@ -18,56 +45,31 @@ "url": "http://github.com/bentomas" } ], - "description": "A comprehensive library for mime-type mapping", - "licenses": [ - { - "type": "MIT", - "url": "https://raw.github.com/broofa/node-mime/master/LICENSE" - } - ], "dependencies": {}, + "description": "A comprehensive library for mime-type mapping", "devDependencies": { "mime-db": "^1.2.0" }, + "homepage": "https://github.com/broofa/node-mime#readme", "keywords": [ "util", "mime" ], + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/broofa/node-mime/master/LICENSE" + } + ], "main": "mime.js", "name": "mime", "repository": { "url": "git+https://github.com/broofa/node-mime.git", "type": "git" }, - "version": "1.3.4", - "gitHead": "1628f6e0187095009dcef4805c3a49706f137974", - "bugs": { - "url": "https://github.com/broofa/node-mime/issues" - }, - "homepage": "https://github.com/broofa/node-mime", - "_id": "mime@1.3.4", - "_shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", - "_from": "mime@1.3.4", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "broofa", - "email": "robert@broofa.com" - }, - "maintainers": [ - { - "name": "broofa", - "email": "robert@broofa.com" - }, - { - "name": "bentomas", - "email": "benjamin@benjaminthomas.org" - } - ], - "dist": { - "shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53", - "tarball": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz" + "scripts": { + "prepublish": "node build/build.js > types.json", + "test": "node build/test.js" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.4" } diff --git a/node_modules/express/node_modules/send/node_modules/ms/package.json b/node_modules/express/node_modules/send/node_modules/ms/package.json index 706e8b8..c485f06 100644 --- a/node_modules/express/node_modules/send/node_modules/ms/package.json +++ b/node_modules/express/node_modules/send/node_modules/ms/package.json @@ -1,31 +1,63 @@ { - "name": "ms", - "version": "0.7.2", - "description": "Tiny milisecond conversion utility", - "repository": { - "type": "git", - "url": "git+https://github.com/zeit/ms.git" + "_args": [ + [ + "ms@0.7.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.2", + "_id": "ms@0.7.2", + "_inBundle": false, + "_integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "_location": "/express/send/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.2", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.2", + "saveSpec": null, + "fetchSpec": "0.7.2" }, - "main": "./index", - "files": [ - "index.js" + "_requiredBy": [ + "/express/send" ], - "scripts": { - "test": "xo && mocha test/index.js", - "test-browser": "serve ./test" + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "_spec": "0.7.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/zeit/ms/issues" }, - "license": "MIT", + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "description": "Tiny milisecond conversion utility", "devDependencies": { "expect.js": "^0.3.1", "mocha": "^3.0.2", "serve": "^1.4.0", "xo": "^0.17.0" }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } + "files": [ + "index.js" + ], + "homepage": "https://github.com/zeit/ms#readme", + "license": "MIT", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git+https://github.com/zeit/ms.git" + }, + "scripts": { + "test": "xo && mocha test/index.js", + "test-browser": "serve ./test" }, + "version": "0.7.2", "xo": { "space": true, "semicolon": false, @@ -35,40 +67,5 @@ "rules": { "complexity": 0 } - }, - "gitHead": "ac92a7e0790ba2622a74d9d60690ca0d2c070a45", - "bugs": { - "url": "https://github.com/zeit/ms/issues" - }, - "homepage": "https://github.com/zeit/ms#readme", - "_id": "ms@0.7.2", - "_shasum": "ae25cf2512b3885a1d95d7f037868d8431124765", - "_from": "ms@0.7.2", - "_npmVersion": "3.10.8", - "_nodeVersion": "6.8.0", - "_npmUser": { - "name": "leo", - "email": "leo@zeit.co" - }, - "dist": { - "shasum": "ae25cf2512b3885a1d95d7f037868d8431124765", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - }, - "maintainers": [ - { - "name": "leo", - "email": "leo@zeit.co" - }, - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/ms-0.7.2.tgz_1477383407940_0.4743474116548896" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "readme": "ERROR: No README data found!" + } } diff --git a/node_modules/express/node_modules/send/node_modules/statuses/package.json b/node_modules/express/node_modules/send/node_modules/statuses/package.json index 1f8d214..2fe06c8 100644 --- a/node_modules/express/node_modules/send/node_modules/statuses/package.json +++ b/node_modules/express/node_modules/send/node_modules/statuses/package.json @@ -1,7 +1,36 @@ { - "name": "statuses", - "description": "HTTP status utility", - "version": "1.3.1", + "_args": [ + [ + "statuses@1.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "statuses@1.3.1", + "_id": "statuses@1.3.1", + "_inBundle": false, + "_integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "_location": "/express/send/statuses", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "statuses@1.3.1", + "name": "statuses", + "escapedName": "statuses", + "rawSpec": "1.3.1", + "saveSpec": null, + "fetchSpec": "1.3.1" + }, + "_requiredBy": [ + "/express/send", + "/express/send/http-errors" + ], + "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "_spec": "1.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/statuses/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,22 +42,7 @@ "url": "http://jongleberry.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/statuses.git" - }, - "license": "MIT", - "keywords": [ - "http", - "status", - "code" - ], - "files": [ - "HISTORY.md", - "index.js", - "codes.json", - "LICENSE" - ], + "description": "HTTP status utility", "devDependencies": { "csv-parse": "1.1.7", "eslint": "3.10.0", @@ -42,6 +56,24 @@ "engines": { "node": ">= 0.6" }, + "files": [ + "HISTORY.md", + "index.js", + "codes.json", + "LICENSE" + ], + "homepage": "https://github.com/jshttp/statuses#readme", + "keywords": [ + "http", + "status", + "code" + ], + "license": "MIT", + "name": "statuses", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/statuses.git" + }, "scripts": { "build": "node scripts/build.js", "fetch": "node scripts/fetch.js", @@ -51,54 +83,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "28a619be77f5b4741e6578a5764c5b06ec6d4aea", - "bugs": { - "url": "https://github.com/jshttp/statuses/issues" - }, - "homepage": "https://github.com/jshttp/statuses", - "_id": "statuses@1.3.1", - "_shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "_from": "statuses@>=1.3.1 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e", - "tarball": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/statuses-1.3.1.tgz_1478923281491_0.5574048184789717" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.1" } diff --git a/node_modules/express/node_modules/send/package.json b/node_modules/express/node_modules/send/package.json index 011a85f..6a6efcd 100644 --- a/node_modules/express/node_modules/send/package.json +++ b/node_modules/express/node_modules/send/package.json @@ -1,27 +1,46 @@ { - "name": "send", - "description": "Better streaming static file server with Range and conditional-GET support", - "version": "0.14.2", + "_args": [ + [ + "send@0.14.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "send@0.14.2", + "_id": "send@0.14.2", + "_inBundle": false, + "_integrity": "sha1-ObBDiz9RC+Xcb2Z6EfcWiTaM3u8=", + "_location": "/express/send", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "send@0.14.2", + "name": "send", + "escapedName": "send", + "rawSpec": "0.14.2", + "saveSpec": null, + "fetchSpec": "0.14.2" + }, + "_requiredBy": [ + "/express", + "/express/serve-static" + ], + "_resolved": "https://registry.npmjs.org/send/-/send-0.14.2.tgz", + "_spec": "0.14.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "bugs": { + "url": "https://github.com/pillarjs/send/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/send.git" - }, - "keywords": [ - "static", - "file", - "server" - ], "dependencies": { "debug": "~2.2.0", "depd": "~1.1.0", @@ -37,6 +56,7 @@ "range-parser": "~1.2.0", "statuses": "~1.3.1" }, + "description": "Better streaming static file server with Range and conditional-GET support", "devDependencies": { "after": "0.8.2", "eslint": "2.11.1", @@ -47,14 +67,26 @@ "mocha": "2.5.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8.0" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8.0" + "homepage": "https://github.com/pillarjs/send#readme", + "keywords": [ + "static", + "file", + "server" + ], + "license": "MIT", + "name": "send", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/send.git" }, "scripts": { "lint": "eslint .", @@ -62,34 +94,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot" }, - "gitHead": "f3397bc0170fb9f2d84c45e81981dff6e58e102d", - "bugs": { - "url": "https://github.com/pillarjs/send/issues" - }, - "homepage": "https://github.com/pillarjs/send#readme", - "_id": "send@0.14.2", - "_shasum": "39b0438b3f510be5dc6f667a11f71689368cdeef", - "_from": "send@0.14.2", - "_npmVersion": "2.15.9", - "_nodeVersion": "4.6.0", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "39b0438b3f510be5dc6f667a11f71689368cdeef", - "tarball": "https://registry.npmjs.org/send/-/send-0.14.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/send-0.14.2.tgz_1485185381110_0.5022726391907781" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/send/-/send-0.14.2.tgz" + "version": "0.14.2" } diff --git a/node_modules/express/node_modules/serve-static/package.json b/node_modules/express/node_modules/serve-static/package.json index b93ab3e..76c04e8 100644 --- a/node_modules/express/node_modules/serve-static/package.json +++ b/node_modules/express/node_modules/serve-static/package.json @@ -1,15 +1,38 @@ { - "name": "serve-static", - "description": "Serve static files", - "version": "1.11.2", + "_args": [ + [ + "serve-static@1.11.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "serve-static@1.11.2", + "_id": "serve-static@1.11.2", + "_inBundle": false, + "_integrity": "sha1-LPmIm9RDWjIMw2iVyapXvWYuasc=", + "_location": "/express/serve-static", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "serve-static@1.11.2", + "name": "serve-static", + "escapedName": "serve-static", + "rawSpec": "1.11.2", + "saveSpec": null, + "fetchSpec": "1.11.2" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.2.tgz", + "_spec": "1.11.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/serve-static.git" + "bugs": { + "url": "https://github.com/expressjs/serve-static/issues" }, "dependencies": { "encodeurl": "~1.0.1", @@ -17,6 +40,7 @@ "parseurl": "~1.3.1", "send": "0.14.2" }, + "description": "Serve static files", "devDependencies": { "eslint": "3.14.0", "eslint-config-standard": "6.2.1", @@ -26,13 +50,20 @@ "mocha": "2.5.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8.0" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.8.0" + "homepage": "https://github.com/expressjs/serve-static#readme", + "license": "MIT", + "name": "serve-static", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/serve-static.git" }, "scripts": { "lint": "eslint .", @@ -40,34 +71,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "01f2a83d7456ef03a89e8c951c757dd79ae92522", - "bugs": { - "url": "https://github.com/expressjs/serve-static/issues" - }, - "homepage": "https://github.com/expressjs/serve-static#readme", - "_id": "serve-static@1.11.2", - "_shasum": "2cf9889bd4435a320cc36895c9aa57bd662e6ac7", - "_from": "serve-static@>=1.11.2 <1.12.0", - "_npmVersion": "2.15.9", - "_nodeVersion": "4.6.0", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "2cf9889bd4435a320cc36895c9aa57bd662e6ac7", - "tarball": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.2.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/serve-static-1.11.2.tgz_1485190261958_0.8670230756979436" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.2.tgz" + "version": "1.11.2" } diff --git a/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json b/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json index f6d6712..0e52ee0 100644 --- a/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json +++ b/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json @@ -1,58 +1,64 @@ { - "name": "media-typer", - "description": "Simple RFC 6838 media type parser and formatter", - "version": "0.3.0", + "_args": [ + [ + "media-typer@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "media-typer@0.3.0", + "_id": "media-typer@0.3.0", + "_inBundle": false, + "_integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "_location": "/express/type-is/media-typer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "media-typer@0.3.0", + "name": "media-typer", + "escapedName": "media-typer", + "rawSpec": "0.3.0", + "saveSpec": null, + "fetchSpec": "0.3.0" + }, + "_requiredBy": [ + "/express/type-is" + ], + "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/media-typer.git" + "bugs": { + "url": "https://github.com/jshttp/media-typer/issues" }, + "description": "Simple RFC 6838 media type parser and formatter", "devDependencies": { "istanbul": "0.3.2", "mocha": "~1.21.4", "should": "~4.0.4" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/media-typer#readme", + "license": "MIT", + "name": "media-typer", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/media-typer.git" }, "scripts": { "test": "mocha --reporter spec --check-leaks --bail test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "d49d41ffd0bb5a0655fa44a59df2ec0bfc835b16", - "bugs": { - "url": "https://github.com/jshttp/media-typer/issues" - }, - "homepage": "https://github.com/jshttp/media-typer", - "_id": "media-typer@0.3.0", - "_shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "_from": "media-typer@0.3.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "8710d7af0aa626f8fffa1ce00168545263255748", - "tarball": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.0" } diff --git a/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json b/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json index 2bbf8d4..1f463c0 100644 --- a/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json +++ b/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json @@ -1,7 +1,35 @@ { - "name": "mime-db", - "description": "Media Type Database", - "version": "1.27.0", + "_args": [ + [ + "mime-db@1.27.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-db@1.27.0", + "_id": "mime-db@1.27.0", + "_inBundle": false, + "_integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", + "_location": "/express/type-is/mime-types/mime-db", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-db@1.27.0", + "name": "mime-db", + "escapedName": "mime-db", + "rawSpec": "1.27.0", + "saveSpec": null, + "fetchSpec": "1.27.0" + }, + "_requiredBy": [ + "/express/type-is/mime-types" + ], + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", + "_spec": "1.27.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,20 +46,7 @@ "url": "http://github.com/broofa" } ], - "license": "MIT", - "keywords": [ - "mime", - "db", - "type", - "types", - "database", - "charset", - "charsets" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-db.git" - }, + "description": "Media Type Database", "devDependencies": { "bluebird": "3.5.0", "co": "4.6.0", @@ -47,6 +62,9 @@ "raw-body": "2.2.0", "stream-to-array": "2.3.0" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", @@ -54,8 +72,21 @@ "db.json", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-db#readme", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "license": "MIT", + "name": "mime-db", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" }, "scripts": { "build": "node scripts/build", @@ -66,39 +97,5 @@ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "update": "npm run fetch && npm run build" }, - "gitHead": "c232c21378647dfbb7762410c7b025a47f114b94", - "bugs": { - "url": "https://github.com/jshttp/mime-db/issues" - }, - "homepage": "https://github.com/jshttp/mime-db#readme", - "_id": "mime-db@1.27.0", - "_shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "_from": "mime-db@>=1.27.0 <1.28.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "820f572296bbd20ec25ed55e5b5de869e5436eb1", - "tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-db-1.27.0.tgz_1489722296902_0.15233952621929348" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.27.0" } diff --git a/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json b/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json index cf28324..f99c5ee 100644 --- a/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json +++ b/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json @@ -1,7 +1,35 @@ { - "name": "mime-types", - "description": "The ultimate javascript content-type utility.", - "version": "2.1.15", + "_args": [ + [ + "mime-types@2.1.15", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mime-types@2.1.15", + "_id": "mime-types@2.1.15", + "_inBundle": false, + "_integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", + "_location": "/express/type-is/mime-types", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mime-types@2.1.15", + "name": "mime-types", + "escapedName": "mime-types", + "rawSpec": "2.1.15", + "saveSpec": null, + "fetchSpec": "2.1.15" + }, + "_requiredBy": [ + "/express/type-is" + ], + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", + "_spec": "2.1.15", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,18 +46,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "mime", - "types" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/mime-types.git" - }, "dependencies": { "mime-db": "~1.27.0" }, + "description": "The ultimate javascript content-type utility.", "devDependencies": { "eslint": "3.18.0", "eslint-config-standard": "7.1.0", @@ -38,13 +58,24 @@ "istanbul": "0.4.5", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/mime-types#readme", + "keywords": [ + "mime", + "types" + ], + "license": "MIT", + "name": "mime-types", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" }, "scripts": { "lint": "eslint .", @@ -52,43 +83,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" }, - "gitHead": "c44863eb0463ee16f3eb04576591cc4c4d6b214c", - "bugs": { - "url": "https://github.com/jshttp/mime-types/issues" - }, - "homepage": "https://github.com/jshttp/mime-types#readme", - "_id": "mime-types@2.1.15", - "_shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "_from": "mime-types@>=2.1.11 <2.2.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "a4ebf5064094569237b8cf70046776d09fc92aed", - "tarball": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/mime-types-2.1.15.tgz_1490327753615_0.3609113476704806" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "readme": "ERROR: No README data found!" + "version": "2.1.15" } diff --git a/node_modules/express/node_modules/type-is/package.json b/node_modules/express/node_modules/type-is/package.json index 3fc2dc5..950c2da 100644 --- a/node_modules/express/node_modules/type-is/package.json +++ b/node_modules/express/node_modules/type-is/package.json @@ -1,7 +1,35 @@ { - "name": "type-is", - "description": "Infer the content-type of a request.", - "version": "1.6.15", + "_args": [ + [ + "type-is@1.6.15", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "type-is@1.6.15", + "_id": "type-is@1.6.15", + "_inBundle": false, + "_integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "_location": "/express/type-is", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "type-is@1.6.15", + "name": "type-is", + "escapedName": "type-is", + "rawSpec": "1.6.15", + "saveSpec": null, + "fetchSpec": "1.6.15" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "_spec": "1.6.15", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/type-is/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,15 +41,11 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/type-is.git" - }, "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.15" }, + "description": "Infer the content-type of a request.", "devDependencies": { "eslint": "3.19.0", "eslint-config-standard": "7.1.0", @@ -39,50 +63,23 @@ "HISTORY.md", "index.js" ], - "scripts": { - "lint": "eslint --plugin markdown --ext js,md .", - "test": "mocha --reporter spec --check-leaks --bail test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", - "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" - }, + "homepage": "https://github.com/jshttp/type-is#readme", "keywords": [ "content", "type", "checking" ], - "gitHead": "9e88be851cc628364ad8842433dce32437ea4e73", - "bugs": { - "url": "https://github.com/jshttp/type-is/issues" - }, - "homepage": "https://github.com/jshttp/type-is#readme", - "_id": "type-is@1.6.15", - "_shasum": "cab10fb4909e441c82842eafe1ad646c81804410", - "_from": "type-is@>=1.6.14 <1.7.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "cab10fb4909e441c82842eafe1ad646c81804410", - "tarball": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz" + "license": "MIT", + "name": "type-is", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/type-is.git" }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/type-is-1.6.15.tgz_1491016789014_0.6958203655667603" + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", - "readme": "ERROR: No README data found!" + "version": "1.6.15" } diff --git a/node_modules/express/node_modules/utils-merge/package.json b/node_modules/express/node_modules/utils-merge/package.json index e86cad0..49c6534 100644 --- a/node_modules/express/node_modules/utils-merge/package.json +++ b/node_modules/express/node_modules/utils-merge/package.json @@ -1,22 +1,53 @@ { - "name": "utils-merge", - "version": "1.0.0", - "description": "merge() utility function", - "keywords": [ - "util" + "_args": [ + [ + "utils-merge@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "git://github.com/jaredhanson/utils-merge.git" - }, - "bugs": { - "url": "http://github.com/jaredhanson/utils-merge/issues" + "_from": "utils-merge@1.0.0", + "_id": "utils-merge@1.0.0", + "_inBundle": false, + "_integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", + "_location": "/express/utils-merge", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "utils-merge@1.0.0", + "name": "utils-merge", + "escapedName": "utils-merge", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", "email": "jaredhanson@gmail.com", "url": "http://www.jaredhanson.net/" }, + "bugs": { + "url": "http://github.com/jaredhanson/utils-merge/issues" + }, + "dependencies": {}, + "description": "merge() utility function", + "devDependencies": { + "chai": "1.x.x", + "mocha": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + }, + "homepage": "https://github.com/jaredhanson/utils-merge#readme", + "keywords": [ + "util" + ], "licenses": [ { "type": "MIT", @@ -24,37 +55,13 @@ } ], "main": "./index", - "dependencies": {}, - "devDependencies": { - "mocha": "1.x.x", - "chai": "1.x.x" + "name": "utils-merge", + "repository": { + "type": "git", + "url": "git://github.com/jaredhanson/utils-merge.git" }, "scripts": { "test": "mocha --reporter spec --require test/bootstrap/node test/*.test.js" }, - "engines": { - "node": ">= 0.4.0" - }, - "_id": "utils-merge@1.0.0", - "dist": { - "shasum": "0294fb922bb9375153541c4f7096231f287c8af8", - "tarball": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" - }, - "_from": "utils-merge@1.0.0", - "_npmVersion": "1.2.25", - "_npmUser": { - "name": "jaredhanson", - "email": "jaredhanson@gmail.com" - }, - "maintainers": [ - { - "name": "jaredhanson", - "email": "jaredhanson@gmail.com" - } - ], - "directories": {}, - "_shasum": "0294fb922bb9375153541c4f7096231f287c8af8", - "_resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "readme": "ERROR: No README data found!", - "homepage": "https://github.com/jaredhanson/utils-merge#readme" + "version": "1.0.0" } diff --git a/node_modules/express/node_modules/vary/package.json b/node_modules/express/node_modules/vary/package.json index 4a8471f..53a26df 100644 --- a/node_modules/express/node_modules/vary/package.json +++ b/node_modules/express/node_modules/vary/package.json @@ -1,21 +1,40 @@ { - "name": "vary", - "description": "Manipulate the HTTP Vary header", - "version": "1.1.1", + "_args": [ + [ + "vary@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "vary@1.1.1", + "_id": "vary@1.1.1", + "_inBundle": false, + "_integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=", + "_location": "/express/vary", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "vary@1.1.1", + "name": "vary", + "escapedName": "vary", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/express" + ], + "_resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "http", - "res", - "vary" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/vary.git" + "bugs": { + "url": "https://github.com/jshttp/vary/issues" }, + "description": "Manipulate the HTTP Vary header", "devDependencies": { "eslint": "3.18.0", "eslint-config-standard": "7.1.0", @@ -26,14 +45,26 @@ "mocha": "2.5.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/jshttp/vary#readme", + "keywords": [ + "http", + "res", + "vary" + ], + "license": "MIT", + "name": "vary", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/vary.git" }, "scripts": { "lint": "eslint --plugin markdown --ext js,md .", @@ -41,35 +72,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "ca7edac6b919a45bf9e2c5cb6ba31c1790e9f046", - "bugs": { - "url": "https://github.com/jshttp/vary/issues" - }, - "homepage": "https://github.com/jshttp/vary#readme", - "_id": "vary@1.1.1", - "_shasum": "67535ebb694c1d52257457984665323f587e8d37", - "_from": "vary@>=1.1.0 <1.2.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.7.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "67535ebb694c1d52257457984665323f587e8d37", - "tarball": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/vary-1.1.1.tgz_1490045547529_0.9355870047584176" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.1" } diff --git a/node_modules/express/package.json b/node_modules/express/package.json index f0ffc25..8da80f4 100644 --- a/node_modules/express/package.json +++ b/node_modules/express/package.json @@ -1,11 +1,39 @@ { - "name": "express", - "description": "Fast, unopinionated, minimalist web framework", - "version": "4.14.1", + "_args": [ + [ + "express@4.14.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "express@4.14.1", + "_id": "express@4.14.1", + "_inBundle": false, + "_integrity": "sha1-ZGwjf3ZvFIwhIK/wc4F7nk1+DTM=", + "_location": "/express", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "express@4.14.1", + "name": "express", + "escapedName": "express", + "rawSpec": "4.14.1", + "saveSpec": null, + "fetchSpec": "4.14.1" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/express/-/express-4.14.1.tgz", + "_spec": "4.14.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "bugs": { + "url": "https://github.com/expressjs/express/issues" + }, "contributors": [ { "name": "Aaron Heckmann", @@ -36,23 +64,6 @@ "email": "hanul@hanul.me" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/express.git" - }, - "homepage": "http://expressjs.com/", - "keywords": [ - "express", - "framework", - "sinatra", - "web", - "rest", - "restful", - "router", - "app", - "api" - ], "dependencies": { "accepts": "~1.3.3", "array-flatten": "1.1.1", @@ -81,13 +92,17 @@ "utils-merge": "1.0.0", "vary": "~1.1.0" }, + "description": "Fast, unopinionated, minimalist web framework", "devDependencies": { "after": "0.8.2", "body-parser": "1.16.0", + "connect-redis": "~2.4.1", "cookie-parser": "~1.4.3", + "cookie-session": "~1.2.0", "ejs": "2.5.5", "express-session": "1.15.0", "istanbul": "0.4.5", + "jade": "~1.11.0", "marked": "0.3.6", "method-override": "~2.3.6", "mocha": "3.2.0", @@ -95,9 +110,6 @@ "multiparty": "4.1.3", "should": "11.2.0", "supertest": "1.2.0", - "connect-redis": "~2.4.1", - "cookie-session": "~1.2.0", - "jade": "~1.11.0", "vhost": "~3.0.2" }, "engines": { @@ -110,51 +122,29 @@ "index.js", "lib/" ], + "homepage": "http://expressjs.com/", + "keywords": [ + "express", + "framework", + "sinatra", + "web", + "rest", + "restful", + "router", + "app", + "api" + ], + "license": "MIT", + "name": "express", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/express.git" + }, "scripts": { "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/", "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/" }, - "gitHead": "0437c513f2dbc8d1dfc5a3e35fe35182bd3a671e", - "bugs": { - "url": "https://github.com/expressjs/express/issues" - }, - "_id": "express@4.14.1", - "_shasum": "646c237f766f148c2120aff073817b9e4d7e0d33", - "_from": "express@>=4.14.0 <4.15.0", - "_npmVersion": "2.15.9", - "_nodeVersion": "4.6.1", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "646c237f766f148c2120aff073817b9e4d7e0d33", - "tarball": "https://registry.npmjs.org/express/-/express-4.14.1.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "hacksparrow", - "email": "captain@hacksparrow.com" - }, - { - "name": "jasnell", - "email": "jasnell@gmail.com" - }, - { - "name": "mikeal", - "email": "mikeal.rogers@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/express-4.14.1.tgz_1485642795215_0.5481494057457894" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/express/-/express-4.14.1.tgz" + "version": "4.14.1" } diff --git a/node_modules/fs.realpath/package.json b/node_modules/fs.realpath/package.json index f5aa99d..a46349a 100644 --- a/node_modules/fs.realpath/package.json +++ b/node_modules/fs.realpath/package.json @@ -1,27 +1,33 @@ { - "_from": "fs.realpath@^1.0.0", + "_args": [ + [ + "fs.realpath@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "fs.realpath@1.0.0", "_id": "fs.realpath@1.0.0", "_inBundle": false, "_integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "_location": "/fs.realpath", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "fs.realpath@^1.0.0", + "raw": "fs.realpath@1.0.0", "name": "fs.realpath", "escapedName": "fs.realpath", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/cli/glob" ], "_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "_shasum": "1504ad2523158caa40db4a2787cb01411994ea4f", - "_spec": "fs.realpath@^1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/glob", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,9 +36,7 @@ "bugs": { "url": "https://github.com/isaacs/fs.realpath/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails", "devDependencies": {}, "files": [ diff --git a/node_modules/glob/package.json b/node_modules/glob/package.json index 0247cfe..d9f44fb 100644 --- a/node_modules/glob/package.json +++ b/node_modules/glob/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "glob@3.2.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "glob@3.2.3", "_id": "glob@3.2.3", "_inBundle": false, @@ -19,9 +25,8 @@ "/mocha" ], "_resolved": "https://registry.npmjs.org/glob/-/glob-3.2.3.tgz", - "_shasum": "e313eeb249c7affaa5c475286b0e115b59839467", - "_spec": "glob@3.2.3", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mocha", + "_spec": "3.2.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,13 +35,11 @@ "bugs": { "url": "https://github.com/isaacs/node-glob/issues" }, - "bundleDependencies": false, "dependencies": { "graceful-fs": "~2.0.0", "inherits": "2", "minimatch": "~0.2.11" }, - "deprecated": false, "description": "a little globber", "devDependencies": { "mkdirp": "0", diff --git a/node_modules/graceful-fs/package.json b/node_modules/graceful-fs/package.json index f77536b..33087f6 100644 --- a/node_modules/graceful-fs/package.json +++ b/node_modules/graceful-fs/package.json @@ -1,27 +1,32 @@ { - "_from": "graceful-fs@~2.0.0", + "_args": [ + [ + "graceful-fs@2.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "graceful-fs@2.0.3", "_id": "graceful-fs@2.0.3", "_inBundle": false, "_integrity": "sha1-fNLNsiiko/Nule+mzBQt59GhNtA=", "_location": "/graceful-fs", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "graceful-fs@~2.0.0", + "raw": "graceful-fs@2.0.3", "name": "graceful-fs", "escapedName": "graceful-fs", - "rawSpec": "~2.0.0", + "rawSpec": "2.0.3", "saveSpec": null, - "fetchSpec": "~2.0.0" + "fetchSpec": "2.0.3" }, "_requiredBy": [ "/glob" ], "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz", - "_shasum": "7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0", - "_spec": "graceful-fs@~2.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/glob", + "_spec": "2.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,8 +35,6 @@ "bugs": { "url": "https://github.com/isaacs/node-graceful-fs/issues" }, - "bundleDependencies": false, - "deprecated": "please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js", "description": "A drop-in replacement for fs, making various improvements.", "directories": { "test": "test" diff --git a/node_modules/growl/package.json b/node_modules/growl/package.json index 626293f..d53ae56 100644 --- a/node_modules/growl/package.json +++ b/node_modules/growl/package.json @@ -1,27 +1,31 @@ { - "_from": "growl", + "_args": [ + [ + "growl@1.10.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "growl@1.10.5", "_id": "growl@1.10.5", "_inBundle": false, "_integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "_location": "/growl", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "growl", + "raw": "growl@1.10.5", "name": "growl", "escapedName": "growl", - "rawSpec": "", + "rawSpec": "1.10.5", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.10.5" }, "_requiredBy": [ - "#USER", "/" ], "_resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "_shasum": "f2735dc2283674fa67478b10181059355c369e5e", - "_spec": "growl", + "_spec": "1.10.5", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", @@ -30,8 +34,6 @@ "bugs": { "url": "https://github.com/tj/node-growl/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Growl unobtrusive notifications", "devDependencies": { "eslint": "^4.8.0", diff --git a/node_modules/hooks-fixed/package.json b/node_modules/hooks-fixed/package.json index 8aa5f03..56e7c0a 100644 --- a/node_modules/hooks-fixed/package.json +++ b/node_modules/hooks-fixed/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "hooks-fixed@2.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "hooks-fixed@2.0.2", "_id": "hooks-fixed@2.0.2", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.2.tgz", - "_shasum": "20076daa07e77d8a6106883ce3f1722e051140b0", - "_spec": "hooks-fixed@2.0.2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "2.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Brian Noguchi", "email": "brian.noguchi@gmail.com", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/vkarpov15/hooks-fixed/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Adds pre and post hook functionality to your JavaScript methods.", "devDependencies": { "expresso": ">=0.7.6", diff --git a/node_modules/htmlparser2/node_modules/isarray/package.json b/node_modules/htmlparser2/node_modules/isarray/package.json index 5ef76b1..b362967 100644 --- a/node_modules/htmlparser2/node_modules/isarray/package.json +++ b/node_modules/htmlparser2/node_modules/isarray/package.json @@ -1,4 +1,11 @@ { + "_args": [ + [ + "isarray@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, "_from": "isarray@0.0.1", "_id": "isarray@0.0.1", "_inBundle": false, @@ -19,9 +26,8 @@ "/htmlparser2/readable-stream" ], "_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "_spec": "isarray@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2/node_modules/readable-stream", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Julian Gruber", "email": "mail@juliangruber.com", @@ -30,9 +36,7 @@ "bugs": { "url": "https://github.com/juliangruber/isarray/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Array#isArray for older browsers", "devDependencies": { "tap": "*" diff --git a/node_modules/htmlparser2/node_modules/readable-stream/package.json b/node_modules/htmlparser2/node_modules/readable-stream/package.json index 472c0e0..62fe544 100644 --- a/node_modules/htmlparser2/node_modules/readable-stream/package.json +++ b/node_modules/htmlparser2/node_modules/readable-stream/package.json @@ -1,27 +1,33 @@ { - "_from": "readable-stream@1.1", + "_args": [ + [ + "readable-stream@1.1.14", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "readable-stream@1.1.14", "_id": "readable-stream@1.1.14", "_inBundle": false, "_integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "_location": "/htmlparser2/readable-stream", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "readable-stream@1.1", + "raw": "readable-stream@1.1.14", "name": "readable-stream", "escapedName": "readable-stream", - "rawSpec": "1.1", + "rawSpec": "1.1.14", "saveSpec": null, - "fetchSpec": "1.1" + "fetchSpec": "1.1.14" }, "_requiredBy": [ "/htmlparser2" ], "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "_shasum": "7cf4c54ef648e3813084c636dd2079e166c081d9", - "_spec": "readable-stream@1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2", + "_spec": "1.1.14", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -33,14 +39,12 @@ "bugs": { "url": "https://github.com/isaacs/readable-stream/issues" }, - "bundleDependencies": false, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "0.0.1", "string_decoder": "~0.10.x" }, - "deprecated": false, "description": "Streams3, a user-land copy of the stream library from Node.js v0.11.x", "devDependencies": { "tap": "~0.2.6" diff --git a/node_modules/htmlparser2/node_modules/string_decoder/package.json b/node_modules/htmlparser2/node_modules/string_decoder/package.json index c843b40..e916895 100644 --- a/node_modules/htmlparser2/node_modules/string_decoder/package.json +++ b/node_modules/htmlparser2/node_modules/string_decoder/package.json @@ -1,33 +1,37 @@ { - "_from": "string_decoder@~0.10.x", + "_args": [ + [ + "string_decoder@0.10.31", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "string_decoder@0.10.31", "_id": "string_decoder@0.10.31", "_inBundle": false, "_integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "_location": "/htmlparser2/string_decoder", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "string_decoder@~0.10.x", + "raw": "string_decoder@0.10.31", "name": "string_decoder", "escapedName": "string_decoder", - "rawSpec": "~0.10.x", + "rawSpec": "0.10.31", "saveSpec": null, - "fetchSpec": "~0.10.x" + "fetchSpec": "0.10.31" }, "_requiredBy": [ "/htmlparser2/readable-stream" ], "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94", - "_spec": "string_decoder@~0.10.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/htmlparser2/node_modules/readable-stream", + "_spec": "0.10.31", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/rvagg/string_decoder/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "The string_decoder module from Node core", "devDependencies": { "tap": "~0.4.8" diff --git a/node_modules/htmlparser2/package.json b/node_modules/htmlparser2/package.json index 8a56f3e..c60e554 100644 --- a/node_modules/htmlparser2/package.json +++ b/node_modules/htmlparser2/package.json @@ -1,5 +1,12 @@ { - "_from": "htmlparser2@3.8.x", + "_args": [ + [ + "htmlparser2@3.8.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "htmlparser2@3.8.3", "_id": "htmlparser2@3.8.3", "_inBundle": false, "_integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", @@ -9,22 +16,21 @@ "inherits": "2.0.3" }, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "htmlparser2@3.8.x", + "raw": "htmlparser2@3.8.3", "name": "htmlparser2", "escapedName": "htmlparser2", - "rawSpec": "3.8.x", + "rawSpec": "3.8.3", "saveSpec": null, - "fetchSpec": "3.8.x" + "fetchSpec": "3.8.3" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "_shasum": "996c28b191516a8be86501a7d79757e5c70c1068", - "_spec": "htmlparser2@3.8.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "3.8.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Felix Boehm", "email": "me@feedic.com" @@ -35,7 +41,6 @@ "bugs": { "url": "http://github.com/fb55/htmlparser2/issues" }, - "bundleDependencies": false, "dependencies": { "domelementtype": "1", "domhandler": "2.3", @@ -43,7 +48,6 @@ "entities": "1.0", "readable-stream": "1.1" }, - "deprecated": false, "description": "Fast & forgiving HTML/XML/RSS parser", "devDependencies": { "coveralls": "*", diff --git a/node_modules/inflight/package.json b/node_modules/inflight/package.json index 2f79b7f..d68bb37 100644 --- a/node_modules/inflight/package.json +++ b/node_modules/inflight/package.json @@ -1,27 +1,33 @@ { - "_from": "inflight@^1.0.4", + "_args": [ + [ + "inflight@1.0.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "inflight@1.0.6", "_id": "inflight@1.0.6", "_inBundle": false, "_integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "_location": "/inflight", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "inflight@^1.0.4", + "raw": "inflight@1.0.6", "name": "inflight", "escapedName": "inflight", - "rawSpec": "^1.0.4", + "rawSpec": "1.0.6", "saveSpec": null, - "fetchSpec": "^1.0.4" + "fetchSpec": "1.0.6" }, "_requiredBy": [ "/cli/glob" ], "_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "_shasum": "49bd6331d7d02d0c09bc910a1075ba8165b56df9", - "_spec": "inflight@^1.0.4", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/glob", + "_spec": "1.0.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,12 +36,10 @@ "bugs": { "url": "https://github.com/isaacs/inflight/issues" }, - "bundleDependencies": false, "dependencies": { "once": "^1.3.0", "wrappy": "1" }, - "deprecated": false, "description": "Add callbacks to requests in flight to avoid async duplication", "devDependencies": { "tap": "^7.1.2" diff --git a/node_modules/inherits/package.json b/node_modules/inherits/package.json index 0a102d1..81b4838 100644 --- a/node_modules/inherits/package.json +++ b/node_modules/inherits/package.json @@ -1,58 +1,50 @@ { - "_from": "inherits@2", + "_args": [ + [ + "inherits@2.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "inherits@2.0.3", "_id": "inherits@2.0.3", "_inBundle": false, "_integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "_location": "/inherits", - "_nodeVersion": "6.5.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/inherits-2.0.3.tgz_1473295776489_0.08142363070510328" - }, - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "_npmVersion": "3.10.7", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "inherits@2", + "raw": "inherits@2.0.3", "name": "inherits", "escapedName": "inherits", - "rawSpec": "2", + "rawSpec": "2.0.3", "saveSpec": null, - "fetchSpec": "2" + "fetchSpec": "2.0.3" }, "_requiredBy": [ + "/busboy/readable-stream", + "/cli/glob", + "/concat-stream", + "/dicer/readable-stream", "/glob", + "/htmlparser2/readable-stream", "/readable-stream" ], "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "_shasum": "633c2c83e3da42a502f52466022480f4208261de", - "_spec": "inherits@2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/glob", + "_spec": "2.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "browser": "./inherits_browser.js", "bugs": { "url": "https://github.com/isaacs/inherits/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", "devDependencies": { "tap": "^7.1.0" }, - "directories": {}, - "dist": { - "shasum": "633c2c83e3da42a502f52466022480f4208261de", - "tarball": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" - }, "files": [ "inherits.js", "inherits_browser.js" ], - "gitHead": "e05d0fb27c61a3ec687214f0476386b765364d5f", "homepage": "https://github.com/isaacs/inherits#readme", "keywords": [ "inheritance", @@ -66,12 +58,6 @@ ], "license": "ISC", "main": "./inherits.js", - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], "name": "inherits", "repository": { "type": "git", diff --git a/node_modules/isarray/package.json b/node_modules/isarray/package.json index 09ef8a6..f59d464 100644 --- a/node_modules/isarray/package.json +++ b/node_modules/isarray/package.json @@ -4,12 +4,6 @@ "_inBundle": false, "_integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "_location": "/isarray", - "_nodeVersion": "5.1.0", - "_npmUser": { - "name": "juliangruber", - "email": "julian@juliangruber.com" - }, - "_npmVersion": "3.3.12", "_phantomChildren": {}, "_requested": { "type": "range", @@ -43,12 +37,6 @@ "devDependencies": { "tape": "~2.13.4" }, - "directories": {}, - "dist": { - "shasum": "bb935d48582cba168c06834957a54a3e07124f11", - "tarball": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" - }, - "gitHead": "2a23a281f369e9ae06394c0fb4d2381355a6ba33", "homepage": "https://github.com/juliangruber/isarray", "keywords": [ "browser", @@ -57,12 +45,6 @@ ], "license": "MIT", "main": "index.js", - "maintainers": [ - { - "name": "juliangruber", - "email": "julian@juliangruber.com" - } - ], "name": "isarray", "repository": { "type": "git", diff --git a/node_modules/jade/node_modules/.bin/cleancss b/node_modules/jade/node_modules/.bin/cleancss deleted file mode 100755 index afe7c84..0000000 --- a/node_modules/jade/node_modules/.bin/cleancss +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env node - -var fs = require('fs'); -var path = require('path'); -var CleanCSS = require('../index'); - -var commands = require('commander'); - -var packageConfig = fs.readFileSync(path.join(path.dirname(fs.realpathSync(process.argv[1])), '../package.json')); -var buildVersion = JSON.parse(packageConfig).version; - -var isWindows = process.platform == 'win32'; - -// Specify commander options to parse command line params correctly -commands - .version(buildVersion, '-v, --version') - .usage('[options] source-file, [source-file, ...]') - .option('-b, --keep-line-breaks', 'Keep line breaks') - .option('-c, --compatibility [ie7|ie8]', 'Force compatibility mode (see Readme for advanced examples)') - .option('-d, --debug', 'Shows debug information (minification time & compression efficiency)') - .option('-o, --output [output-file]', 'Use [output-file] as output instead of STDOUT') - .option('-r, --root [root-path]', 'Set a root path to which resolve absolute @import rules') - .option('-s, --skip-import', 'Disable @import processing') - .option('-t, --timeout [seconds]', 'Per connection timeout when fetching remote @imports (defaults to 5 seconds)') - .option('--rounding-precision [n]', 'Rounds to `N` decimal places. Defaults to 2. -1 disables rounding', parseInt) - .option('--s0', 'Remove all special comments, i.e. /*! comment */') - .option('--s1', 'Remove all special comments but the first one') - .option('--semantic-merging', 'Enables unsafe mode by assuming BEM-like semantic stylesheets (warning, this may break your styling!)') - .option('--skip-advanced', 'Disable advanced optimizations - ruleset reordering & merging') - .option('--skip-aggressive-merging', 'Disable properties merging based on their order') - .option('--skip-import-from [rules]', 'Disable @import processing for specified rules', function (val) { return val.split(','); }, []) - .option('--skip-media-merging', 'Disable @media merging') - .option('--skip-rebase', 'Disable URLs rebasing') - .option('--skip-restructuring', 'Disable restructuring optimizations') - .option('--skip-shorthand-compacting', 'Disable shorthand compacting') - .option('--source-map', 'Enables building input\'s source map') - .option('--source-map-inline-sources', 'Enables inlining sources inside source maps'); - -commands.on('--help', function () { - console.log(' Examples:\n'); - console.log(' %> cleancss one.css'); - console.log(' %> cleancss -o one-min.css one.css'); - if (isWindows) { - console.log(' %> type one.css two.css three.css | cleancss -o merged-and-minified.css'); - } else { - console.log(' %> cat one.css two.css three.css | cleancss -o merged-and-minified.css'); - console.log(' %> cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz'); - } - console.log(''); - process.exit(); -}); - -commands.parse(process.argv); - -// If no sensible data passed in just print help and exit -var fromStdin = !process.env.__DIRECT__ && !process.stdin.isTTY; -if (!fromStdin && commands.args.length === 0) { - commands.outputHelp(); - return 0; -} - -// Now coerce commands into CleanCSS configuration... -var options = { - advanced: commands.skipAdvanced ? false : true, - aggressiveMerging: commands.skipAggressiveMerging ? false : true, - compatibility: commands.compatibility, - debug: commands.debug, - inliner: commands.timeout ? { timeout: parseFloat(commands.timeout) * 1000 } : undefined, - keepBreaks: !!commands.keepLineBreaks, - keepSpecialComments: commands.s0 ? 0 : (commands.s1 ? 1 : '*'), - mediaMerging: commands.skipMediaMerging ? false : true, - processImport: commands.skipImport ? false : true, - processImportFrom: processImportFrom(commands.skipImportFrom), - rebase: commands.skipRebase ? false : true, - restructuring: commands.skipRestructuring ? false : true, - root: commands.root, - roundingPrecision: commands.roundingPrecision, - semanticMerging: commands.semanticMerging ? true : false, - shorthandCompacting: commands.skipShorthandCompacting ? false : true, - sourceMap: commands.sourceMap, - sourceMapInlineSources: commands.sourceMapInlineSources, - target: commands.output -}; - -if (options.root || commands.args.length > 0) { - var relativeTo = options.root || commands.args[0]; - - if (isRemote(relativeTo)) { - options.relativeTo = relativeTo; - } else { - var resolvedRelativeTo = path.resolve(relativeTo); - - options.relativeTo = fs.statSync(resolvedRelativeTo).isFile() ? - path.dirname(resolvedRelativeTo) : - resolvedRelativeTo; - } -} - -if (options.sourceMap && !options.target) { - outputFeedback(['Source maps will not be built because you have not specified an output file.'], true); - options.sourceMap = false; -} - -// ... and do the magic! -if (commands.args.length > 0) { - minify(commands.args); -} else { - var stdin = process.openStdin(); - stdin.setEncoding('utf-8'); - var data = ''; - stdin.on('data', function (chunk) { - data += chunk; - }); - stdin.on('end', function () { - minify(data); - }); -} - -function isRemote(path) { - return /^https?:\/\//.test(path) || /^\/\//.test(path); -} - -function processImportFrom(rules) { - if (rules.length === 0) { - return ['all']; - } else if (rules.length == 1 && rules[0] == 'all') { - return []; - } else { - return rules.map(function (rule) { - if (rule == 'local') - return 'remote'; - else if (rule == 'remote') - return 'local'; - else - return '!' + rule; - }); - } -} - -function minify(data) { - new CleanCSS(options).minify(data, function (errors, minified) { - if (options.debug) { - console.error('Original: %d bytes', minified.stats.originalSize); - console.error('Minified: %d bytes', minified.stats.minifiedSize); - console.error('Efficiency: %d%', ~~(minified.stats.efficiency * 10000) / 100.0); - console.error('Time spent: %dms', minified.stats.timeSpent); - } - - outputFeedback(minified.errors, true); - outputFeedback(minified.warnings); - - if (minified.errors.length > 0) - process.exit(1); - - if (minified.sourceMap) { - var mapFilename = path.basename(options.target) + '.map'; - output(minified.styles + '/*# sourceMappingURL=' + mapFilename + ' */'); - outputMap(minified.sourceMap, mapFilename); - } else { - output(minified.styles); - } - }); -} - -function output(minified) { - if (options.target) - fs.writeFileSync(options.target, minified, 'utf8'); - else - process.stdout.write(minified); -} - -function outputMap(sourceMap, mapFilename) { - var mapPath = path.join(path.dirname(options.target), mapFilename); - fs.writeFileSync(mapPath, sourceMap.toString(), 'utf-8'); -} - -function outputFeedback(messages, isError) { - var prefix = isError ? '\x1B[31mERROR\x1B[39m:' : 'WARNING:'; - - messages.forEach(function (message) { - console.error('%s %s', prefix, message); - }); -} diff --git a/node_modules/jade/node_modules/.bin/cleancss b/node_modules/jade/node_modules/.bin/cleancss new file mode 120000 index 0000000..2a3439e --- /dev/null +++ b/node_modules/jade/node_modules/.bin/cleancss @@ -0,0 +1 @@ +../clean-css/bin/cleancss \ No newline at end of file diff --git a/node_modules/jade/node_modules/.bin/mkdirp b/node_modules/jade/node_modules/.bin/mkdirp deleted file mode 100755 index d95de15..0000000 --- a/node_modules/jade/node_modules/.bin/mkdirp +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -var mkdirp = require('../'); -var minimist = require('minimist'); -var fs = require('fs'); - -var argv = minimist(process.argv.slice(2), { - alias: { m: 'mode', h: 'help' }, - string: [ 'mode' ] -}); -if (argv.help) { - fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout); - return; -} - -var paths = argv._.slice(); -var mode = argv.mode ? parseInt(argv.mode, 8) : undefined; - -(function next () { - if (paths.length === 0) return; - var p = paths.shift(); - - if (mode === undefined) mkdirp(p, cb) - else mkdirp(p, mode, cb) - - function cb (err) { - if (err) { - console.error(err.message); - process.exit(1); - } - else next(); - } -})(); diff --git a/node_modules/jade/node_modules/.bin/mkdirp b/node_modules/jade/node_modules/.bin/mkdirp new file mode 120000 index 0000000..017896c --- /dev/null +++ b/node_modules/jade/node_modules/.bin/mkdirp @@ -0,0 +1 @@ +../mkdirp/bin/cmd.js \ No newline at end of file diff --git a/node_modules/jade/node_modules/.bin/uglifyjs b/node_modules/jade/node_modules/.bin/uglifyjs deleted file mode 100755 index 63b2f26..0000000 --- a/node_modules/jade/node_modules/.bin/uglifyjs +++ /dev/null @@ -1,635 +0,0 @@ -#! /usr/bin/env node -// -*- js -*- - -"use strict"; - -var UglifyJS = require("../tools/node"); -var sys = require("util"); -var yargs = require("yargs"); -var fs = require("fs"); -var path = require("path"); -var acorn; -var screw_ie8 = true; -var ARGS = yargs - .usage("$0 input1.js [input2.js ...] [options]\n\ -Use a single dash to read input from the standard input.\ -\n\n\ -NOTE: by default there is no mangling/compression.\n\ -Without [options] it will simply parse input files and dump the AST\n\ -with whitespace and comments discarded. To achieve compression and\n\ -mangling you need to use `-c` and `-m`.\ -") - .describe("source-map", "Specify an output file where to generate source map.") - .describe("source-map-root", "The path to the original source to be included in the source map.") - .describe("source-map-url", "The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.") - .describe("source-map-inline", "Write base64-encoded source map to the end of js output. Disabled by default") - .describe("source-map-include-sources", "Pass this flag if you want to include the content of source files in the source map as sourcesContent property.") - .describe("in-source-map", "Input source map, useful if you're compressing JS that was generated from some other original code.") - .describe("screw-ie8", "Do not support Internet Explorer 6/7/8. This flag is enabled by default.") - .describe("support-ie8", "Support non-standard Internet Explorer 6/7/8 javascript.") - .describe("expr", "Parse a single expression, rather than a program (for parsing JSON)") - .describe("p", "Skip prefix for original filenames that appear in source maps. \ -For example -p 3 will drop 3 directories from file names and ensure they are relative paths. \ -You can also specify -p relative, which will make UglifyJS figure out itself the relative paths between original sources, \ -the source map and the output file.") - .describe("o", "Output file (default STDOUT).") - .describe("b", "Beautify output/specify output options.") - .describe("m", "Mangle names/pass mangler options.") - .describe("r", "Reserved names to exclude from mangling.") - .describe("c", "Enable compressor/pass compressor options. \ -Pass options like -c hoist_vars=false,if_return=false. \ -Use -c with no argument to use the default compression options.") - .describe("d", "Global definitions") - .describe("e", "Embed everything in a big function, with a configurable parameter/argument list.") - - .describe("comments", "Preserve copyright comments in the output. \ -By default this works like Google Closure, keeping JSDoc-style comments that contain \"@license\" or \"@preserve\". \ -You can optionally pass one of the following arguments to this flag:\n\ -- \"all\" to keep all comments\n\ -- a valid JS RegExp like `/foo/`or `/^!/` to keep only matching comments.\n\ -\ -Note that currently not *all* comments can be kept when compression is on, \ -because of dead code removal or cascading statements into sequences.") - - .describe("preamble", "Preamble to prepend to the output. You can use this to insert a \ -comment, for example for licensing information. This will not be \ -parsed, but the source map will adjust for its presence.") - - .describe("stats", "Display operations run time on STDERR.") - .describe("acorn", "Use Acorn for parsing.") - .describe("spidermonkey", "Assume input files are SpiderMonkey AST format (as JSON).") - .describe("self", "Build itself (UglifyJS2) as a library (implies --wrap=UglifyJS --export-all)") - .describe("wrap", "Embed everything in a big function, making the “exports” and “global” variables available. \ -You need to pass an argument to this option to specify the name that your module will take when included in, say, a browser.") - .describe("export-all", "Only used when --wrap, this tells UglifyJS to add code to automatically export all globals.") - .describe("lint", "Display some scope warnings") - .describe("v", "Verbose") - .describe("V", "Print version number and exit.") - .describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.") - .describe("bare-returns", "Allow return outside of functions. Useful when minifying CommonJS modules.") - .describe("keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.") - .describe("quotes", "Quote style (0 - auto, 1 - single, 2 - double, 3 - original)") - .describe("reserved-file", "File containing reserved names") - .describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props") - .describe("mangle-props", "Mangle property names (0 - disabled, 1 - mangle all properties, 2 - mangle unquoted properies)") - .describe("mangle-regex", "Only mangle property names matching the regex") - .describe("name-cache", "File to hold mangled names mappings") - .describe("pure-funcs", "List of functions that can be safely removed if their return value is not used") - .describe("dump-spidermonkey-ast", "Dump SpiderMonkey AST to stdout.") - .describe("wrap-iife", "Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option") - - .alias("p", "prefix") - .alias("o", "output") - .alias("v", "verbose") - .alias("b", "beautify") - .alias("m", "mangle") - .alias("c", "compress") - .alias("d", "define") - .alias("r", "reserved") - .alias("V", "version") - .alias("e", "enclose") - .alias("q", "quotes") - - .string("source-map") - .string("source-map-root") - .string("source-map-url") - .string("b") - .string("beautify") - .string("m") - .string("mangle") - .string("mangle-props-debug") - .string("c") - .string("compress") - .string("d") - .string("define") - .string("e") - .string("enclose") - .string("comments") - .string("wrap") - .string("p") - .string("prefix") - .string("name-cache") - - .array("reserved-file") - .array("pure-funcs") - - .boolean("expr") - .boolean("source-map-inline") - .boolean("source-map-include-sources") - .boolean("screw-ie8") - .boolean("support-ie8") - .boolean("export-all") - .boolean("self") - .boolean("v") - .boolean("verbose") - .boolean("stats") - .boolean("acorn") - .boolean("spidermonkey") - .boolean("dump-spidermonkey-ast") - .boolean("lint") - .boolean("V") - .boolean("version") - .boolean("noerr") - .boolean("bare-returns") - .boolean("keep-fnames") - .boolean("reserve-domprops") - .boolean("wrap-iife") - - .wrap(80) - - .argv -; - -normalize(ARGS); - -if (ARGS.noerr) { - UglifyJS.DefaultsError.croak = function(msg, defs) { - print_error("WARN: " + msg); - }; -} - -if (ARGS.version || ARGS.V) { - var json = require("../package.json"); - print(json.name + ' ' + json.version); - process.exit(0); -} - -if (ARGS.ast_help) { - var desc = UglifyJS.describe_ast(); - print(typeof desc == "string" ? desc : JSON.stringify(desc, null, 2)); - process.exit(0); -} - -if (ARGS.h || ARGS.help) { - print(yargs.help()); - process.exit(0); -} - -if (ARGS.acorn) { - acorn = require("acorn"); -} - -var COMPRESS = getOptions("c", true); -var MANGLE = getOptions("m", true); -var BEAUTIFY = getOptions("b", true); -var RESERVED = null; - -if (ARGS.reserved_file) ARGS.reserved_file.forEach(function(filename){ - RESERVED = UglifyJS.readReservedFile(filename, RESERVED); -}); - -if (ARGS.reserve_domprops) { - RESERVED = UglifyJS.readDefaultReservedFile(RESERVED); -} - -if (ARGS.d) { - if (COMPRESS) COMPRESS.global_defs = getOptions("d"); -} - -if (ARGS.pure_funcs) { - if (COMPRESS) COMPRESS.pure_funcs = ARGS.pure_funcs; -} - -if (ARGS.r) { - if (MANGLE) MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/); -} - -if (RESERVED && MANGLE) { - if (!MANGLE.except) MANGLE.except = RESERVED.vars; - else MANGLE.except = MANGLE.except.concat(RESERVED.vars); -} - -function readNameCache(key) { - return UglifyJS.readNameCache(ARGS.name_cache, key); -} - -function writeNameCache(key, cache) { - return UglifyJS.writeNameCache(ARGS.name_cache, key, cache); -} - -function extractRegex(str) { - if (/^\/.*\/[a-zA-Z]*$/.test(str)) { - var regex_pos = str.lastIndexOf("/"); - return new RegExp(str.substr(1, regex_pos - 1), str.substr(regex_pos + 1)); - } else { - throw new Error("Invalid regular expression: " + str); - } -} - -if (ARGS.quotes === true) { - ARGS.quotes = 3; -} - -if (ARGS.mangle_props === true) { - ARGS.mangle_props = 1; -} else if (ARGS.mangle_props === "unquoted") { - ARGS.mangle_props = 2; -} - -var OUTPUT_OPTIONS = { - beautify : BEAUTIFY ? true : false, - max_line_len : 32000, - preamble : ARGS.preamble || null, - quote_style : ARGS.quotes != null ? ARGS.quotes : 0, -}; - -if (ARGS.mangle_props == 2) { - OUTPUT_OPTIONS.keep_quoted_props = true; - if (COMPRESS && !("properties" in COMPRESS)) - COMPRESS.properties = false; -} - -if (ARGS.support_ie8 === true && ARGS.screw_ie8 !== true) { - screw_ie8 = false; -} - -if (COMPRESS) COMPRESS.screw_ie8 = screw_ie8; -if (MANGLE) MANGLE.screw_ie8 = screw_ie8; -OUTPUT_OPTIONS.screw_ie8 = screw_ie8; - -if (ARGS.keep_fnames) { - if (COMPRESS) COMPRESS.keep_fnames = true; - if (MANGLE) MANGLE.keep_fnames = true; -} - -if (ARGS.wrap_iife) { - if (COMPRESS) COMPRESS.negate_iife = false; - OUTPUT_OPTIONS.wrap_iife = true; -} - -if (BEAUTIFY) - UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY); - -if (ARGS.comments === "") { - OUTPUT_OPTIONS.comments = "some"; -} else { - OUTPUT_OPTIONS.comments = ARGS.comments; -} - -var files = ARGS._.slice(); - -if (process.platform === "win32") - files = UglifyJS.simple_glob(files); - -if (ARGS.self) { - if (files.length > 0) { - print_error("WARN: Ignoring input files since --self was passed"); - } - files = UglifyJS.FILES; - if (!ARGS.wrap) ARGS.wrap = "UglifyJS"; -} - -var ORIG_MAP = ARGS.in_source_map; - -if (ORIG_MAP && ORIG_MAP != "inline") { - ORIG_MAP = JSON.parse(fs.readFileSync(ORIG_MAP)); - if (files.length == 0) { - print_error("INFO: Using file from the input source map: " + ORIG_MAP.file); - files = [ ORIG_MAP.file ]; - } -} - -if (files.length == 0) { - files = [ "-" ]; -} - -if (ORIG_MAP == "inline") { - if (files.length > 1) { - print_error("ERROR: Inline source map only works with singular input"); - process.exit(1); - } - if (ARGS.acorn || ARGS.spidermonkey) { - print_error("ERROR: Inline source map only works with built-in parser"); - process.exit(1); - } -} - -if (files.indexOf("-") >= 0 && ARGS.source_map) { - print_error("ERROR: Source map doesn't work with input from STDIN"); - process.exit(1); -} - -if (files.filter(function(el){ return el == "-" }).length > 1) { - print_error("ERROR: Can read a single file from STDIN (two or more dashes specified)"); - process.exit(1); -} - -var STATS = {}; -var TOPLEVEL = null; -var P_RELATIVE = ARGS.p && ARGS.p == "relative"; -var SOURCES_CONTENT = {}; -var index = 0; - -!function cb() { - if (index == files.length) return done(); - var file = files[index++]; - read_whole_file(file, function (err, code) { - if (err) { - print_error("ERROR: can't read file: " + file); - process.exit(1); - } - if (ORIG_MAP == "inline") { - ORIG_MAP = read_source_map(code); - } - if (ARGS.p != null) { - if (P_RELATIVE) { - file = path.relative(path.dirname(ARGS.source_map), file).replace(/\\/g, '/'); - } else { - var p = parseInt(ARGS.p, 10); - if (!isNaN(p)) { - file = file.replace(/^\/+/, "").split(/\/+/).slice(ARGS.p).join("/"); - } - } - } - SOURCES_CONTENT[file] = code; - time_it("parse", function(){ - if (ARGS.spidermonkey) { - var program = JSON.parse(code); - if (!TOPLEVEL) TOPLEVEL = program; - else TOPLEVEL.body = TOPLEVEL.body.concat(program.body); - } - else if (ARGS.acorn) { - TOPLEVEL = acorn.parse(code, { - locations : true, - sourceFile : file, - program : TOPLEVEL - }); - } - else { - try { - TOPLEVEL = UglifyJS.parse(code, { - filename : file, - toplevel : TOPLEVEL, - expression : ARGS.expr, - bare_returns : ARGS.bare_returns, - }); - } catch(ex) { - if (ex instanceof UglifyJS.JS_Parse_Error) { - print_error("Parse error at " + file + ":" + ex.line + "," + ex.col); - var col = ex.col; - var lines = code.split(/\r?\n/); - var line = lines[ex.line - 1]; - if (!line && !col) { - line = lines[ex.line - 2]; - col = line.length; - } - if (line) { - if (col > 40) { - line = line.slice(col - 40); - col = 40; - } - print_error(line.slice(0, 80)); - print_error(line.slice(0, col).replace(/\S/g, " ") + "^"); - } - print_error(ex.stack); - process.exit(1); - } - throw ex; - } - }; - }); - cb(); - }); -}(); - -function done() { - var OUTPUT_FILE = ARGS.o; - - var SOURCE_MAP = (ARGS.source_map || ARGS.source_map_inline) ? UglifyJS.SourceMap({ - file: P_RELATIVE ? path.relative(path.dirname(ARGS.source_map), OUTPUT_FILE) : OUTPUT_FILE, - root: ARGS.source_map_root || ORIG_MAP && ORIG_MAP.sourceRoot, - orig: ORIG_MAP, - }) : null; - - OUTPUT_OPTIONS.source_map = SOURCE_MAP; - - try { - var output = UglifyJS.OutputStream(OUTPUT_OPTIONS); - var compressor = COMPRESS && UglifyJS.Compressor(COMPRESS); - } catch(ex) { - if (ex instanceof UglifyJS.DefaultsError) { - print_error(ex.message); - print_error("Supported options:"); - print_error(sys.inspect(ex.defs)); - process.exit(1); - } - } - - if (ARGS.acorn || ARGS.spidermonkey) time_it("convert_ast", function(){ - TOPLEVEL = UglifyJS.AST_Node.from_mozilla_ast(TOPLEVEL); - }); - - if (ARGS.wrap != null) { - TOPLEVEL = TOPLEVEL.wrap_commonjs(ARGS.wrap, ARGS.export_all); - } - - if (ARGS.enclose != null) { - var arg_parameter_list = ARGS.enclose; - if (arg_parameter_list === true) { - arg_parameter_list = []; - } - else if (!(arg_parameter_list instanceof Array)) { - arg_parameter_list = [arg_parameter_list]; - } - TOPLEVEL = TOPLEVEL.wrap_enclose(arg_parameter_list); - } - - if (ARGS.mangle_props || ARGS.name_cache) (function(){ - var reserved = RESERVED ? RESERVED.props : null; - var cache = readNameCache("props"); - var regex; - - try { - regex = ARGS.mangle_regex ? extractRegex(ARGS.mangle_regex) : null; - } catch (e) { - print_error("ERROR: Invalid --mangle-regex: " + e.message); - process.exit(1); - } - - TOPLEVEL = UglifyJS.mangle_properties(TOPLEVEL, { - reserved : reserved, - cache : cache, - only_cache : !ARGS.mangle_props, - regex : regex, - ignore_quoted : ARGS.mangle_props == 2, - debug : typeof ARGS.mangle_props_debug === "undefined" ? false : ARGS.mangle_props_debug - }); - writeNameCache("props", cache); - })(); - - var SCOPE_IS_NEEDED = COMPRESS || MANGLE || ARGS.lint - var TL_CACHE = readNameCache("vars"); - if (MANGLE) MANGLE.cache = TL_CACHE; - - if (SCOPE_IS_NEEDED) { - time_it("scope", function(){ - TOPLEVEL.figure_out_scope(MANGLE || { screw_ie8: screw_ie8, cache: TL_CACHE }); - if (ARGS.lint) { - TOPLEVEL.scope_warnings(); - } - }); - } - - if (COMPRESS) { - time_it("squeeze", function(){ - TOPLEVEL = compressor.compress(TOPLEVEL); - }); - } - - if (SCOPE_IS_NEEDED) { - time_it("scope", function(){ - TOPLEVEL.figure_out_scope(MANGLE || { screw_ie8: screw_ie8, cache: TL_CACHE }); - if (MANGLE && !TL_CACHE) { - TOPLEVEL.compute_char_frequency(MANGLE); - } - }); - } - - if (MANGLE) time_it("mangle", function(){ - TOPLEVEL.mangle_names(MANGLE); - }); - - writeNameCache("vars", TL_CACHE); - - if (ARGS.source_map_include_sources) { - for (var file in SOURCES_CONTENT) { - if (SOURCES_CONTENT.hasOwnProperty(file)) { - SOURCE_MAP.get().setSourceContent(file, SOURCES_CONTENT[file]); - } - } - } - - if (ARGS.dump_spidermonkey_ast) { - print(JSON.stringify(TOPLEVEL.to_mozilla_ast(), null, 2)); - } else { - time_it("generate", function(){ - TOPLEVEL.print(output); - }); - - output = output.get(); - - if (SOURCE_MAP) { - if (ARGS.source_map_inline) { - var base64_string = new Buffer(SOURCE_MAP.toString()).toString('base64'); - output += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + base64_string; - } else { - fs.writeFileSync(ARGS.source_map, SOURCE_MAP, "utf8"); - var source_map_url = ARGS.source_map_url || ( - P_RELATIVE - ? path.relative(path.dirname(OUTPUT_FILE), ARGS.source_map) - : ARGS.source_map - ); - output += "\n//# sourceMappingURL=" + source_map_url; - } - } - - if (OUTPUT_FILE) { - fs.writeFileSync(OUTPUT_FILE, output, "utf8"); - } else { - print(output); - } - } - - if (ARGS.stats) { - print_error(UglifyJS.string_template("Timing information (compressed {count} files):", { - count: files.length - })); - for (var i in STATS) if (STATS.hasOwnProperty(i)) { - print_error(UglifyJS.string_template("- {name}: {time}s", { - name: i, - time: (STATS[i] / 1000).toFixed(3) - })); - } - } -} - -/* -----[ functions ]----- */ - -function normalize(o) { - for (var i in o) if (o.hasOwnProperty(i) && /-/.test(i)) { - o[i.replace(/-/g, "_")] = o[i]; - delete o[i]; - } -} - -function getOptions(flag, constants) { - var x = ARGS[flag]; - if (x == null || x === false) return null; - var ret = {}; - if (x !== "") { - if (Array.isArray(x)) x = x.map(function (v) { return "(" + v + ")"; }).join(", "); - - var ast; - try { - ast = UglifyJS.parse(x, { cli: true, expression: true }); - } catch(ex) { - if (ex instanceof UglifyJS.JS_Parse_Error) { - print_error("Error parsing arguments for flag `" + flag + "': " + x); - process.exit(1); - } - } - ast.walk(new UglifyJS.TreeWalker(function(node){ - if (node instanceof UglifyJS.AST_Seq) return; // descend - if (node instanceof UglifyJS.AST_Assign) { - var name = node.left.print_to_string().replace(/-/g, "_"); - var value = node.right; - if (constants) - value = new Function("return (" + value.print_to_string() + ")")(); - ret[name] = value; - return true; // no descend - } - if (node instanceof UglifyJS.AST_Symbol || node instanceof UglifyJS.AST_Binary) { - var name = node.print_to_string().replace(/-/g, "_"); - ret[name] = true; - return true; // no descend - } - print_error(node.TYPE) - print_error("Error parsing arguments for flag `" + flag + "': " + x); - process.exit(1); - })); - } - return ret; -} - -function read_whole_file(filename, cb) { - if (filename == "-") { - var chunks = []; - process.stdin.setEncoding('utf-8'); - process.stdin.on('data', function (chunk) { - chunks.push(chunk); - }).on('end', function () { - cb(null, chunks.join("")); - }); - process.openStdin(); - } else { - fs.readFile(filename, "utf-8", cb); - } -} - -function read_source_map(code) { - var match = /\n\/\/# sourceMappingURL=data:application\/json(;.*?)?;base64,(.*)/.exec(code); - if (!match) { - print_error("WARN: inline source map not found"); - return null; - } - return JSON.parse(new Buffer(match[2], "base64")); -} - -function time_it(name, cont) { - var t1 = new Date().getTime(); - var ret = cont(); - if (ARGS.stats) { - var spent = new Date().getTime() - t1; - if (STATS[name]) STATS[name] += spent; - else STATS[name] = spent; - } - return ret; -} - -function print_error(msg) { - console.error("%s", msg); -} - -function print(txt) { - console.log("%s", txt); -} diff --git a/node_modules/jade/node_modules/.bin/uglifyjs b/node_modules/jade/node_modules/.bin/uglifyjs new file mode 120000 index 0000000..fef3468 --- /dev/null +++ b/node_modules/jade/node_modules/.bin/uglifyjs @@ -0,0 +1 @@ +../uglify-js/bin/uglifyjs \ No newline at end of file diff --git a/node_modules/jade/node_modules/character-parser/package.json b/node_modules/jade/node_modules/character-parser/package.json index ffeb3f9..7c44f0a 100644 --- a/node_modules/jade/node_modules/character-parser/package.json +++ b/node_modules/jade/node_modules/character-parser/package.json @@ -1,15 +1,44 @@ { - "name": "character-parser", - "version": "1.2.1", - "description": "Parse JavaScript one character at a time to look for snippets in Templates. This is not a validator, it's just designed to allow you to have sections of JavaScript delimited by brackets robustly.", - "main": "index.js", - "scripts": { - "test": "mocha -R spec" + "_args": [ + [ + "character-parser@1.2.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "character-parser@1.2.1", + "_id": "character-parser@1.2.1", + "_inBundle": false, + "_integrity": "sha1-wN3kqxgnE7kZuXCVmhI+zBow/NY=", + "_location": "/jade/character-parser", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "character-parser@1.2.1", + "name": "character-parser", + "escapedName": "character-parser", + "rawSpec": "1.2.1", + "saveSpec": null, + "fetchSpec": "1.2.1" }, - "repository": { - "type": "git", - "url": "https://github.com/ForbesLindesay/character-parser.git" + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/character-parser/-/character-parser-1.2.1.tgz", + "_spec": "1.2.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "ForbesLindesay" + }, + "bugs": { + "url": "https://github.com/ForbesLindesay/character-parser/issues" + }, + "description": "Parse JavaScript one character at a time to look for snippets in Templates. This is not a validator, it's just designed to allow you to have sections of JavaScript delimited by brackets robustly.", + "devDependencies": { + "better-assert": "~1.0.0", + "mocha": "~1.9.0" }, + "homepage": "https://github.com/ForbesLindesay/character-parser#readme", "keywords": [ "parser", "JavaScript", @@ -20,36 +49,15 @@ "escape", "escaping" ], - "author": { - "name": "ForbesLindesay" - }, "license": "MIT", - "devDependencies": { - "better-assert": "~1.0.0", - "mocha": "~1.9.0" - }, - "bugs": { - "url": "https://github.com/ForbesLindesay/character-parser/issues" - }, - "homepage": "https://github.com/ForbesLindesay/character-parser", - "_id": "character-parser@1.2.1", - "dist": { - "shasum": "c0dde4ab182713b919b970959a123ecc1a30fcd6", - "tarball": "https://registry.npmjs.org/character-parser/-/character-parser-1.2.1.tgz" + "main": "index.js", + "name": "character-parser", + "repository": { + "type": "git", + "url": "git+https://github.com/ForbesLindesay/character-parser.git" }, - "_from": "character-parser@1.2.1", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindeay.co.uk" + "scripts": { + "test": "mocha -R spec" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "directories": {}, - "_shasum": "c0dde4ab182713b919b970959a123ecc1a30fcd6", - "_resolved": "https://registry.npmjs.org/character-parser/-/character-parser-1.2.1.tgz" + "version": "1.2.1" } diff --git a/node_modules/jade/node_modules/clean-css/node_modules/commander/node_modules/graceful-readlink/package.json b/node_modules/jade/node_modules/clean-css/node_modules/commander/node_modules/graceful-readlink/package.json index 754b2b2..09514b1 100644 --- a/node_modules/jade/node_modules/clean-css/node_modules/commander/node_modules/graceful-readlink/package.json +++ b/node_modules/jade/node_modules/clean-css/node_modules/commander/node_modules/graceful-readlink/package.json @@ -1,47 +1,53 @@ { - "name": "graceful-readlink", - "version": "1.0.1", - "description": "graceful fs.readlink", - "main": "index.js", - "repository": { - "type": "git", - "url": "git://github.com/zhiyelee/graceful-readlink.git" + "_args": [ + [ + "graceful-readlink@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "graceful-readlink@1.0.1", + "_id": "graceful-readlink@1.0.1", + "_inBundle": false, + "_integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "_location": "/jade/clean-css/commander/graceful-readlink", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "graceful-readlink@1.0.1", + "name": "graceful-readlink", + "escapedName": "graceful-readlink", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/jade/clean-css/commander" + ], + "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "zhiyelee" }, - "homepage": "https://github.com/zhiyelee/graceful-readlink", "bugs": { "url": "https://github.com/zhiyelee/graceful-readlink/issues" }, + "description": "graceful fs.readlink", + "homepage": "https://github.com/zhiyelee/graceful-readlink", "keywords": [ "fs.readlink", "readlink" ], - "author": { - "name": "zhiyelee" - }, "license": "MIT", + "main": "index.js", + "name": "graceful-readlink", + "repository": { + "type": "git", + "url": "git://github.com/zhiyelee/graceful-readlink.git" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "gitHead": "f6655275bebef706fb63fd01b5f062a7052419a5", - "_id": "graceful-readlink@1.0.1", - "_shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725", - "_from": "graceful-readlink@>=1.0.0", - "_npmVersion": "2.1.17", - "_nodeVersion": "0.11.14", - "_npmUser": { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - }, - "maintainers": [ - { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - } - ], - "dist": { - "shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725", - "tarball": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/clean-css/node_modules/commander/package.json b/node_modules/jade/node_modules/clean-css/node_modules/commander/package.json index 81c2e66..3cfab3b 100644 --- a/node_modules/jade/node_modules/clean-css/node_modules/commander/package.json +++ b/node_modules/jade/node_modules/clean-css/node_modules/commander/package.json @@ -1,74 +1,68 @@ { - "name": "commander", - "version": "2.8.1", - "description": "the complete solution for node.js command-line programs", - "keywords": [ - "command", - "option", - "parser" + "_args": [ + [ + "commander@2.8.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "commander@2.8.1", + "_id": "commander@2.8.1", + "_inBundle": false, + "_integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", + "_location": "/jade/clean-css/commander", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "commander@2.8.1", + "name": "commander", + "escapedName": "commander", + "rawSpec": "2.8.1", + "saveSpec": null, + "fetchSpec": "2.8.1" + }, + "_requiredBy": [ + "/jade/clean-css" + ], + "_resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "_spec": "2.8.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/tj/commander.js.git" + "bugs": { + "url": "https://github.com/tj/commander.js/issues" + }, + "dependencies": { + "graceful-readlink": ">= 1.0.0" }, + "description": "the complete solution for node.js command-line programs", "devDependencies": { "should": ">= 0.0.1", "sinon": ">= 1.14.1" }, - "scripts": { - "test": "make test" - }, - "main": "index", "engines": { "node": ">= 0.6.x" }, "files": [ "index.js" ], - "dependencies": { - "graceful-readlink": ">= 1.0.0" - }, - "gitHead": "c6c84726050b19c0373de27cd359f3baddff579f", - "bugs": { - "url": "https://github.com/tj/commander.js/issues" - }, - "homepage": "https://github.com/tj/commander.js", - "_id": "commander@2.8.1", - "_shasum": "06be367febfda0c330aa1e2a072d3dc9762425d4", - "_from": "commander@>=2.8.0 <2.9.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "0.12.0", - "_npmUser": { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "somekittens", - "email": "rkoutnik@gmail.com" - }, - { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - }, - { - "name": "thethomaseffect", - "email": "thethomaseffect@gmail.com" - } + "homepage": "https://github.com/tj/commander.js#readme", + "keywords": [ + "command", + "option", + "parser" ], - "dist": { - "shasum": "06be367febfda0c330aa1e2a072d3dc9762425d4", - "tarball": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz" + "license": "MIT", + "main": "index", + "name": "commander", + "repository": { + "type": "git", + "url": "git+https://github.com/tj/commander.js.git" + }, + "scripts": { + "test": "make test" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz" + "version": "2.8.1" } diff --git a/node_modules/jade/node_modules/clean-css/node_modules/source-map/node_modules/amdefine/package.json b/node_modules/jade/node_modules/clean-css/node_modules/source-map/node_modules/amdefine/package.json index b143c17..73f988a 100644 --- a/node_modules/jade/node_modules/clean-css/node_modules/source-map/node_modules/amdefine/package.json +++ b/node_modules/jade/node_modules/clean-css/node_modules/source-map/node_modules/amdefine/package.json @@ -1,50 +1,51 @@ { - "name": "amdefine", - "description": "Provide AMD's define() API for declaring modules in the AMD format", - "version": "1.0.1", - "homepage": "http://github.com/jrburke/amdefine", + "_args": [ + [ + "amdefine@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "amdefine@1.0.1", + "_id": "amdefine@1.0.1", + "_inBundle": false, + "_integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "_location": "/jade/clean-css/source-map/amdefine", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "amdefine@1.0.1", + "name": "amdefine", + "escapedName": "amdefine", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/jade/clean-css/source-map" + ], + "_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "James Burke", "email": "jrburke@gmail.com", "url": "http://github.com/jrburke" }, - "license": "BSD-3-Clause OR MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jrburke/amdefine.git" - }, - "main": "./amdefine.js", - "engines": { - "node": ">=0.4.2" - }, - "gitHead": "e59edc9da24404ec7937098e3992f8fb0e260be7", "bugs": { "url": "https://github.com/jrburke/amdefine/issues" }, - "_id": "amdefine@1.0.1", - "scripts": {}, - "_shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5", - "_from": "amdefine@>=0.0.4", - "_npmVersion": "3.10.3", - "_nodeVersion": "6.7.0", - "_npmUser": { - "name": "jrburke", - "email": "jrburke@gmail.com" - }, - "dist": { - "shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5", - "tarball": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + "description": "Provide AMD's define() API for declaring modules in the AMD format", + "engines": { + "node": ">=0.4.2" }, - "maintainers": [ - { - "name": "jrburke", - "email": "jrburke@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/amdefine-1.0.1.tgz_1478062849665_0.19916908955201507" + "homepage": "http://github.com/jrburke/amdefine", + "license": "BSD-3-Clause OR MIT", + "main": "./amdefine.js", + "name": "amdefine", + "repository": { + "type": "git", + "url": "git+https://github.com/jrburke/amdefine.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/clean-css/node_modules/source-map/package.json b/node_modules/jade/node_modules/clean-css/node_modules/source-map/package.json index ad3a939..c064234 100644 --- a/node_modules/jade/node_modules/clean-css/node_modules/source-map/package.json +++ b/node_modules/jade/node_modules/clean-css/node_modules/source-map/package.json @@ -1,12 +1,39 @@ { - "name": "source-map", - "description": "Generates and consumes source maps", - "version": "0.4.4", - "homepage": "https://github.com/mozilla/source-map", + "_args": [ + [ + "source-map@0.4.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "source-map@0.4.4", + "_id": "source-map@0.4.4", + "_inBundle": false, + "_integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "_location": "/jade/clean-css/source-map", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "source-map@0.4.4", + "name": "source-map", + "escapedName": "source-map", + "rawSpec": "0.4.4", + "saveSpec": null, + "fetchSpec": "0.4.4" + }, + "_requiredBy": [ + "/jade/clean-css" + ], + "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "_spec": "0.4.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Nick Fitzgerald", "email": "nfitzgerald@mozilla.com" }, + "bugs": { + "url": "https://github.com/mozilla/source-map/issues" + }, "contributors": [ { "name": "Tobias Koppers", @@ -141,60 +168,34 @@ "email": "giladp007@gmail.com" } ], - "repository": { - "type": "git", - "url": "http://github.com/mozilla/source-map.git" + "dependencies": { + "amdefine": ">=0.0.4" + }, + "description": "Generates and consumes source maps", + "devDependencies": { + "dryice": ">=0.4.8" }, "directories": { "lib": "./lib" }, - "main": "./lib/source-map.js", + "engines": { + "node": ">=0.8.0" + }, "files": [ "lib/", "build/" ], - "engines": { - "node": ">=0.8.0" - }, + "homepage": "https://github.com/mozilla/source-map", "license": "BSD-3-Clause", - "dependencies": { - "amdefine": ">=0.0.4" - }, - "devDependencies": { - "dryice": ">=0.4.8" + "main": "./lib/source-map.js", + "name": "source-map", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/mozilla/source-map.git" }, "scripts": { - "test": "node test/run-tests.js", - "build": "node Makefile.dryice.js" - }, - "bugs": { - "url": "https://github.com/mozilla/source-map/issues" - }, - "_id": "source-map@0.4.4", - "_shasum": "eba4f5da9c0dc999de68032d8b4f76173652036b", - "_from": "source-map@>=0.4.0 <0.5.0", - "_npmVersion": "1.4.9", - "_npmUser": { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - }, - "maintainers": [ - { - "name": "mozilla-devtools", - "email": "mozilla-developer-tools@googlegroups.com" - }, - { - "name": "mozilla", - "email": "dherman@mozilla.com" - }, - { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - } - ], - "dist": { - "shasum": "eba4f5da9c0dc999de68032d8b4f76173652036b", - "tarball": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz" + "build": "node Makefile.dryice.js", + "test": "node test/run-tests.js" }, - "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz" + "version": "0.4.4" } diff --git a/node_modules/jade/node_modules/clean-css/package.json b/node_modules/jade/node_modules/clean-css/package.json index bb995e4..2813f6d 100644 --- a/node_modules/jade/node_modules/clean-css/package.json +++ b/node_modules/jade/node_modules/clean-css/package.json @@ -1,47 +1,48 @@ { - "name": "clean-css", - "version": "3.4.26", + "_args": [ + [ + "clean-css@3.4.26", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "clean-css@3.4.26", + "_id": "clean-css@3.4.26", + "_inBundle": false, + "_integrity": "sha1-VTI7NE/zvO5oSi6sgck9+Ppz3us=", + "_location": "/jade/clean-css", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "clean-css@3.4.26", + "name": "clean-css", + "escapedName": "clean-css", + "rawSpec": "3.4.26", + "saveSpec": null, + "fetchSpec": "3.4.26" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.26.tgz", + "_spec": "3.4.26", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jakub Pawlowicz", "email": "contact@jakubpawlowicz.com", "url": "http://twitter.com/jakubpawlowicz" }, - "description": "A well-tested CSS minifier", - "license": "MIT", - "keywords": [ - "css", - "minifier" - ], - "homepage": "https://github.com/jakubpawlowicz/clean-css", - "repository": { - "type": "git", - "url": "git+https://github.com/jakubpawlowicz/clean-css.git" - }, - "bugs": { - "url": "https://github.com/jakubpawlowicz/clean-css/issues" - }, "bin": { "cleancss": "./bin/cleancss" }, - "main": "index.js", - "files": [ - "bin", - "lib", - "History.md", - "index.js", - "LICENSE" - ], - "scripts": { - "browserify": "browserify --standalone CleanCSS index.js | uglifyjs --compress --mangle -o cleancss-browser.js", - "bench": "node ./test/bench.js", - "check": "jshint ./bin/cleancss .", - "prepublish": "npm run check", - "test": "vows" + "bugs": { + "url": "https://github.com/jakubpawlowicz/clean-css/issues" }, "dependencies": { "commander": "2.8.x", "source-map": "0.4.x" }, + "description": "A well-tested CSS minifier", "devDependencies": { "browserify": "11.x", "http-proxy": "1.x", @@ -54,34 +55,31 @@ "engines": { "node": ">=0.10.0" }, - "gitHead": "343e16ef21ad24f138060cd910f36e2fe1ca12e4", - "_id": "clean-css@3.4.26", - "_shasum": "55323b344ff3bcee684a2eac81c93df8fa73deeb", - "_from": "clean-css@>=3.1.9 <4.0.0", - "_npmVersion": "2.15.11", - "_nodeVersion": "4.6.2", - "_npmUser": { - "name": "jakub.pawlowicz", - "email": "contact@jakubpawlowicz.com" - }, - "dist": { - "shasum": "55323b344ff3bcee684a2eac81c93df8fa73deeb", - "tarball": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.26.tgz" - }, - "maintainers": [ - { - "name": "goalsmashers", - "email": "jakub@goalsmashers.com" - }, - { - "name": "jakub.pawlowicz", - "email": "contact@jakubpawlowicz.com" - } + "files": [ + "bin", + "lib", + "History.md", + "index.js", + "LICENSE" ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/clean-css-3.4.26.tgz_1494437176568_0.09391578938812017" + "homepage": "https://github.com/jakubpawlowicz/clean-css", + "keywords": [ + "css", + "minifier" + ], + "license": "MIT", + "main": "index.js", + "name": "clean-css", + "repository": { + "type": "git", + "url": "git+https://github.com/jakubpawlowicz/clean-css.git" + }, + "scripts": { + "bench": "node ./test/bench.js", + "browserify": "browserify --standalone CleanCSS index.js | uglifyjs --compress --mangle -o cleancss-browser.js", + "check": "jshint ./bin/cleancss .", + "prepublish": "npm run check", + "test": "vows" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.26.tgz" + "version": "3.4.26" } diff --git a/node_modules/jade/node_modules/commander/package.json b/node_modules/jade/node_modules/commander/package.json index 1db2df2..e43631e 100644 --- a/node_modules/jade/node_modules/commander/package.json +++ b/node_modules/jade/node_modules/commander/package.json @@ -1,71 +1,65 @@ { - "name": "commander", - "version": "2.6.0", - "description": "the complete solution for node.js command-line programs", - "keywords": [ - "command", - "option", - "parser", - "prompt" + "_args": [ + [ + "commander@2.6.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "commander@2.6.0", + "_id": "commander@2.6.0", + "_inBundle": false, + "_integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", + "_location": "/jade/commander", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "commander@2.6.0", + "name": "commander", + "escapedName": "commander", + "rawSpec": "2.6.0", + "saveSpec": null, + "fetchSpec": "2.6.0" + }, + "_requiredBy": [ + "/jade" ], + "_resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", + "_spec": "2.6.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/tj/commander.js.git" + "bugs": { + "url": "https://github.com/tj/commander.js/issues" }, + "description": "the complete solution for node.js command-line programs", "devDependencies": { "should": ">= 0.0.1" }, - "scripts": { - "test": "make test" - }, - "main": "index", "engines": { "node": ">= 0.6.x" }, "files": [ "index.js" ], - "gitHead": "c6807fd154dd3b7ce8756f141f8d3acfcc74be60", - "bugs": { - "url": "https://github.com/tj/commander.js/issues" - }, - "homepage": "https://github.com/tj/commander.js", - "_id": "commander@2.6.0", - "_shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d", - "_from": "commander@>=2.6.0 <2.7.0", - "_npmVersion": "2.1.12", - "_nodeVersion": "0.11.14", - "_npmUser": { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "somekittens", - "email": "rkoutnik@gmail.com" - }, - { - "name": "zhiyelee", - "email": "zhiyelee@gmail.com" - }, - { - "name": "thethomaseffect", - "email": "thethomaseffect@gmail.com" - } + "homepage": "https://github.com/tj/commander.js#readme", + "keywords": [ + "command", + "option", + "parser", + "prompt" ], - "dist": { - "shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d", - "tarball": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz" + "license": "MIT", + "main": "index", + "name": "commander", + "repository": { + "type": "git", + "url": "git+https://github.com/tj/commander.js.git" + }, + "scripts": { + "test": "make test" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz" + "version": "2.6.0" } diff --git a/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn b/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn deleted file mode 100755 index db07909..0000000 --- a/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } } - -var _path = require("path"); - -var _fs = require("fs"); - -var _distAcornJs = require("../dist/acorn.js"); - -var acorn = _interopRequireWildcard(_distAcornJs); - -var infile = undefined, - forceFile = undefined, - silent = false, - compact = false, - tokenize = false; -var options = {}; - -function help(status) { - var print = status == 0 ? console.log : console.error; - print("usage: " + (0, _path.basename)(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]"); - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]"); - process.exit(status); -} - -for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i]; - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg;else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i];else if (arg == "--ecma3") options.ecmaVersion = 3;else if (arg == "--ecma5") options.ecmaVersion = 5;else if (arg == "--ecma6") options.ecmaVersion = 6;else if (arg == "--locations") options.locations = true;else if (arg == "--allow-hash-bang") options.allowHashBang = true;else if (arg == "--silent") silent = true;else if (arg == "--compact") compact = true;else if (arg == "--help") help(0);else if (arg == "--tokenize") tokenize = true;else if (arg == "--module") options.sourceType = 'module';else help(1); -} - -function run(code) { - var result = undefined; - if (!tokenize) { - try { - result = acorn.parse(code, options); - } catch (e) { - console.error(e.message);process.exit(1); - } - } else { - result = []; - var tokenizer = acorn.tokenizer(code, options), - token = undefined; - while (true) { - try { - token = tokenizer.getToken(); - } catch (e) { - console.error(e.message);process.exit(1); - } - result.push(token); - if (token.type == acorn.tokTypes.eof) break; - } - } - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2)); -} - -if (forceFile || infile && infile != "-") { - run((0, _fs.readFileSync)(infile, "utf8")); -} else { - (function () { - var code = ""; - process.stdin.resume(); - process.stdin.on("data", function (chunk) { - return code += chunk; - }); - process.stdin.on("end", function () { - return run(code); - }); - })(); -} \ No newline at end of file diff --git a/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn b/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn new file mode 120000 index 0000000..cf76760 --- /dev/null +++ b/node_modules/jade/node_modules/constantinople/node_modules/.bin/acorn @@ -0,0 +1 @@ +../acorn/bin/acorn \ No newline at end of file diff --git a/node_modules/jade/node_modules/constantinople/node_modules/acorn/package.json b/node_modules/jade/node_modules/constantinople/node_modules/acorn/package.json index 3e20d2e..37a0694 100644 --- a/node_modules/jade/node_modules/constantinople/node_modules/acorn/package.json +++ b/node_modules/jade/node_modules/constantinople/node_modules/acorn/package.json @@ -1,40 +1,37 @@ { - "name": "acorn", - "description": "ECMAScript parser", - "homepage": "https://github.com/ternjs/acorn", - "main": "dist/acorn.js", - "version": "2.7.0", - "engines": { - "node": ">=0.4.0" - }, - "maintainers": [ - { - "name": "marijn", - "email": "marijnh@gmail.com" - }, - { - "name": "rreverser", - "email": "me@rreverser.com" - } + "_args": [ + [ + "acorn@2.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "git+https://github.com/ternjs/acorn.git" - }, - "license": "MIT", - "scripts": { - "prepublish": "node bin/build-acorn.js", - "test": "node test/run.js" + "_from": "acorn@2.7.0", + "_id": "acorn@2.7.0", + "_inBundle": false, + "_integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=", + "_location": "/jade/constantinople/acorn", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "acorn@2.7.0", + "name": "acorn", + "escapedName": "acorn", + "rawSpec": "2.7.0", + "saveSpec": null, + "fetchSpec": "2.7.0" }, + "_requiredBy": [ + "/jade/constantinople" + ], + "_resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", + "_spec": "2.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bin": { "acorn": "./bin/acorn" }, - "devDependencies": { - "babel-core": "^5.6.15", - "babelify": "^6.1.2", - "browserify": "^10.2.4", - "browserify-derequire": "^0.9.4", - "unicode-7.0.0": "~0.1.5" + "bugs": { + "url": "https://github.com/ternjs/acorn/issues" }, "contributors": [ { @@ -164,23 +161,40 @@ "name": "zsjforcn" } ], - "gitHead": "1405436064bff087f14af55a763396aa5c0ca148", - "bugs": { - "url": "https://github.com/ternjs/acorn/issues" + "description": "ECMAScript parser", + "devDependencies": { + "babel-core": "^5.6.15", + "babelify": "^6.1.2", + "browserify": "^10.2.4", + "browserify-derequire": "^0.9.4", + "unicode-7.0.0": "~0.1.5" }, - "_id": "acorn@2.7.0", - "_shasum": "ab6e7d9d886aaca8b085bc3312b79a198433f0e7", - "_from": "acorn@>=2.1.0 <3.0.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "marijn", - "email": "marijnh@gmail.com" + "engines": { + "node": ">=0.4.0" }, - "dist": { - "shasum": "ab6e7d9d886aaca8b085bc3312b79a198433f0e7", - "tarball": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz" + "homepage": "https://github.com/ternjs/acorn", + "license": "MIT", + "main": "dist/acorn.js", + "maintainers": [ + { + "name": "Marijn Haverbeke", + "email": "marijnh@gmail.com", + "url": "http://marijnhaverbeke.nl" + }, + { + "name": "Ingvar Stepanyan", + "email": "me@rreverser.com", + "url": "http://rreverser.com/" + } + ], + "name": "acorn", + "repository": { + "type": "git", + "url": "git+https://github.com/ternjs/acorn.git" + }, + "scripts": { + "prepublish": "node bin/build-acorn.js", + "test": "node test/run.js" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz" + "version": "2.7.0" } diff --git a/node_modules/jade/node_modules/constantinople/package.json b/node_modules/jade/node_modules/constantinople/package.json index 2258b67..7c7862c 100644 --- a/node_modules/jade/node_modules/constantinople/package.json +++ b/node_modules/jade/node_modules/constantinople/package.json @@ -1,49 +1,55 @@ { - "name": "constantinople", - "version": "3.0.2", - "description": "Determine whether a JavaScript expression evaluates to a constant (using UglifyJS)", - "keywords": [], + "_args": [ + [ + "constantinople@3.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "constantinople@3.0.2", + "_id": "constantinople@3.0.2", + "_inBundle": false, + "_integrity": "sha1-S5RdmTeQe82Y7ldRIsOBdRZUQUE=", + "_location": "/jade/constantinople", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "constantinople@3.0.2", + "name": "constantinople", + "escapedName": "constantinople", + "rawSpec": "3.0.2", + "saveSpec": null, + "fetchSpec": "3.0.2" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.0.2.tgz", + "_spec": "3.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "ForbesLindesay" + }, + "bugs": { + "url": "https://github.com/ForbesLindesay/constantinople/issues" + }, "dependencies": { "acorn": "^2.1.0" }, + "description": "Determine whether a JavaScript expression evaluates to a constant (using UglifyJS)", "devDependencies": { "mocha": "*" }, - "scripts": { - "test": "mocha -R spec" - }, + "homepage": "https://github.com/ForbesLindesay/constantinople#readme", + "keywords": [], + "license": "MIT", + "name": "constantinople", "repository": { "type": "git", - "url": "https://github.com/ForbesLindesay/constantinople.git" - }, - "author": { - "name": "ForbesLindesay" + "url": "git+https://github.com/ForbesLindesay/constantinople.git" }, - "license": "MIT", - "gitHead": "8947fdfb41428b1c8f5df1645f38bc0af34d7f21", - "bugs": { - "url": "https://github.com/ForbesLindesay/constantinople/issues" - }, - "homepage": "https://github.com/ForbesLindesay/constantinople", - "_id": "constantinople@3.0.2", - "_shasum": "4b945d9937907bcd98ee575122c3817516544141", - "_from": "constantinople@>=3.0.1 <3.1.0", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.6.2", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "dist": { - "shasum": "4b945d9937907bcd98ee575122c3817516544141", - "tarball": "https://registry.npmjs.org/constantinople/-/constantinople-3.0.2.tgz" + "scripts": { + "test": "mocha -R spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.0.2.tgz" + "version": "3.0.2" } diff --git a/node_modules/jade/node_modules/jstransformer/node_modules/is-promise/package.json b/node_modules/jade/node_modules/jstransformer/node_modules/is-promise/package.json index 57df9a3..ffe4a25 100644 --- a/node_modules/jade/node_modules/jstransformer/node_modules/is-promise/package.json +++ b/node_modules/jade/node_modules/jstransformer/node_modules/is-promise/package.json @@ -1,47 +1,53 @@ { - "name": "is-promise", - "version": "2.1.0", - "description": "Test whether an object looks like a promises-a+ promise", - "main": "index.js", - "scripts": { - "test": "mocha -R spec" - }, - "repository": { - "type": "git", - "url": "https://github.com/then/is-promise.git" + "_args": [ + [ + "is-promise@2.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "is-promise@2.1.0", + "_id": "is-promise@2.1.0", + "_inBundle": false, + "_integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "_location": "/jade/jstransformer/is-promise", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "is-promise@2.1.0", + "name": "is-promise", + "escapedName": "is-promise", + "rawSpec": "2.1.0", + "saveSpec": null, + "fetchSpec": "2.1.0" }, + "_requiredBy": [ + "/jade/jstransformer" + ], + "_resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "_spec": "2.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", + "bugs": { + "url": "https://github.com/then/is-promise/issues" + }, + "description": "Test whether an object looks like a promises-a+ promise", "devDependencies": { "better-assert": "~0.1.0", "mocha": "~1.7.4" }, - "gitHead": "056f8ac12eed91886ac4f0f7d872a176f6ed698f", - "bugs": { - "url": "https://github.com/then/is-promise/issues" - }, - "homepage": "https://github.com/then/is-promise", - "_id": "is-promise@2.1.0", - "_shasum": "79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa", - "_from": "is-promise@>=2.0.0 <3.0.0", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.6.2", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" + "homepage": "https://github.com/then/is-promise#readme", + "license": "MIT", + "main": "index.js", + "name": "is-promise", + "repository": { + "type": "git", + "url": "git+https://github.com/then/is-promise.git" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "dist": { - "shasum": "79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa", - "tarball": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz" + "scripts": { + "test": "mocha -R spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz" + "version": "2.1.0" } diff --git a/node_modules/jade/node_modules/jstransformer/node_modules/promise/node_modules/asap/package.json b/node_modules/jade/node_modules/jstransformer/node_modules/promise/node_modules/asap/package.json index c4cbf95..045a85b 100644 --- a/node_modules/jade/node_modules/jstransformer/node_modules/promise/node_modules/asap/package.json +++ b/node_modules/jade/node_modules/jstransformer/node_modules/promise/node_modules/asap/package.json @@ -1,6 +1,32 @@ { - "name": "asap", - "version": "1.0.0", + "_args": [ + [ + "asap@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "asap@1.0.0", + "_id": "asap@1.0.0", + "_inBundle": false, + "_integrity": "sha1-sqRdpf36ILBJb8N2jMJ8EvqRan0=", + "_location": "/jade/jstransformer/promise/asap", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "asap@1.0.0", + "name": "asap", + "escapedName": "asap", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/jade/jstransformer/promise" + ], + "_resolved": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "description": "High-priority task queue for Node.js and browsers", "keywords": [ "event", @@ -14,24 +40,6 @@ } ], "main": "asap", - "_id": "asap@1.0.0", - "dist": { - "shasum": "b2a45da5fdfa20b0496fc3768cc27c12fa916a7d", - "tarball": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz" - }, - "_from": "asap@>=1.0.0 <1.1.0", - "_npmVersion": "1.2.15", - "_npmUser": { - "name": "kriskowal", - "email": "kris.kowal@cixar.com" - }, - "maintainers": [ - { - "name": "kriskowal", - "email": "kris.kowal@cixar.com" - } - ], - "directories": {}, - "_shasum": "b2a45da5fdfa20b0496fc3768cc27c12fa916a7d", - "_resolved": "https://registry.npmjs.org/asap/-/asap-1.0.0.tgz" + "name": "asap", + "version": "1.0.0" } diff --git a/node_modules/jade/node_modules/jstransformer/node_modules/promise/package.json b/node_modules/jade/node_modules/jstransformer/node_modules/promise/package.json index d6c09e4..0766795 100644 --- a/node_modules/jade/node_modules/jstransformer/node_modules/promise/package.json +++ b/node_modules/jade/node_modules/jstransformer/node_modules/promise/package.json @@ -1,56 +1,59 @@ { - "name": "promise", - "version": "6.1.0", - "description": "Bare bones Promises/A+ implementation", - "main": "index.js", - "scripts": { - "test": "mocha --timeout 200 --slow 99999", - "test-resolve": "mocha test/resolver-tests.js -R spec --timeout 200 --slow 999999", - "test-extensions": "mocha test/extensions-tests.js -R spec --timeout 200 --slow 999999" - }, - "repository": { - "type": "git", - "url": "https://github.com/then/promise.git" - }, + "_args": [ + [ + "promise@6.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "promise@6.1.0", + "_id": "promise@6.1.0", + "_inBundle": false, + "_integrity": "sha1-LOcp9rlLRcJoka0GAsXJDgTG7vY=", + "_location": "/jade/jstransformer/promise", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "promise@6.1.0", + "name": "promise", + "escapedName": "promise", + "rawSpec": "6.1.0", + "saveSpec": null, + "fetchSpec": "6.1.0" + }, + "_requiredBy": [ + "/jade/jstransformer" + ], + "_resolved": "https://registry.npmjs.org/promise/-/promise-6.1.0.tgz", + "_spec": "6.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", - "devDependencies": { - "promises-aplus-tests": "*", - "better-assert": "*", - "mocha": "*" + "bugs": { + "url": "https://github.com/then/promise/issues" }, "dependencies": { "asap": "~1.0.0" }, - "gitHead": "c627c0cc1f886ed3aa26edec97838ec9e7dd858b", - "bugs": { - "url": "https://github.com/then/promise/issues" + "description": "Bare bones Promises/A+ implementation", + "devDependencies": { + "better-assert": "*", + "mocha": "*", + "promises-aplus-tests": "*" }, - "homepage": "https://github.com/then/promise", - "_id": "promise@6.1.0", - "_shasum": "2ce729f6b94b45c26891ad0602c5c90e04c6eef6", - "_from": "promise@>=6.0.1 <7.0.0", - "_npmVersion": "1.5.0-alpha-4", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" + "homepage": "https://github.com/then/promise#readme", + "license": "MIT", + "main": "index.js", + "name": "promise", + "repository": { + "type": "git", + "url": "git+https://github.com/then/promise.git" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "nathan7", - "email": "nathan@nathan7.eu" - } - ], - "dist": { - "shasum": "2ce729f6b94b45c26891ad0602c5c90e04c6eef6", - "tarball": "https://registry.npmjs.org/promise/-/promise-6.1.0.tgz" + "scripts": { + "test": "mocha --timeout 200 --slow 99999", + "test-extensions": "mocha test/extensions-tests.js -R spec --timeout 200 --slow 999999", + "test-resolve": "mocha test/resolver-tests.js -R spec --timeout 200 --slow 999999" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/promise/-/promise-6.1.0.tgz" + "version": "6.1.0" } diff --git a/node_modules/jade/node_modules/jstransformer/package.json b/node_modules/jade/node_modules/jstransformer/package.json index cb56972..81cbc48 100644 --- a/node_modules/jade/node_modules/jstransformer/package.json +++ b/node_modules/jade/node_modules/jstransformer/package.json @@ -1,60 +1,66 @@ { - "name": "jstransformer", - "version": "0.0.2", - "description": "Normalize the API of any jstransformer", - "keywords": [ - "jstransformer" + "_args": [ + [ + "jstransformer@0.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "jstransformer@0.0.2", + "_id": "jstransformer@0.0.2", + "_inBundle": false, + "_integrity": "sha1-eq4pqQPRls+glz2IXT5HlH7Ndqs=", + "_location": "/jade/jstransformer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "jstransformer@0.0.2", + "name": "jstransformer", + "escapedName": "jstransformer", + "rawSpec": "0.0.2", + "saveSpec": null, + "fetchSpec": "0.0.2" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz", + "_spec": "0.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "ForbesLindesay" + }, + "bugs": { + "url": "https://github.com/jstransformers/jstransformer/issues" + }, "dependencies": { "is-promise": "^2.0.0", "promise": "^6.0.1" }, + "description": "Normalize the API of any jstransformer", "devDependencies": { "coveralls": "^2.11.2", "istanbul": "^0.3.5", "testit": "^1.2.0" }, - "scripts": { - "test": "node test", - "coverage": "istanbul cover test", - "coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls" - }, "files": [ "index.js", "LICENSE" ], + "homepage": "https://github.com/jstransformers/jstransformer#readme", + "keywords": [ + "jstransformer" + ], + "license": "MIT", + "name": "jstransformer", "repository": { "type": "git", - "url": "https://github.com/jstransformers/jstransformer.git" - }, - "author": { - "name": "ForbesLindesay" - }, - "license": "MIT", - "gitHead": "99b40c1aa9fa984585aa50f4618d97a0287495c1", - "bugs": { - "url": "https://github.com/jstransformers/jstransformer/issues" + "url": "git+https://github.com/jstransformers/jstransformer.git" }, - "homepage": "https://github.com/jstransformers/jstransformer", - "_id": "jstransformer@0.0.2", - "_shasum": "7aae29a903d196cfa0973d885d3e47947ecd76ab", - "_from": "jstransformer@0.0.2", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.6.2", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "dist": { - "shasum": "7aae29a903d196cfa0973d885d3e47947ecd76ab", - "tarball": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz" + "scripts": { + "coverage": "istanbul cover test", + "coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", + "test": "node test" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz" + "version": "0.0.2" } diff --git a/node_modules/jade/node_modules/mkdirp/node_modules/minimist/package.json b/node_modules/jade/node_modules/mkdirp/node_modules/minimist/package.json index 0c9af0e..37a959b 100644 --- a/node_modules/jade/node_modules/mkdirp/node_modules/minimist/package.json +++ b/node_modules/jade/node_modules/mkdirp/node_modules/minimist/package.json @@ -1,11 +1,58 @@ { - "name": "minimist", - "version": "0.0.8", + "_args": [ + [ + "minimist@0.0.8", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "minimist@0.0.8", + "_id": "minimist@0.0.8", + "_inBundle": false, + "_integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "_location": "/jade/mkdirp/minimist", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "minimist@0.0.8", + "name": "minimist", + "escapedName": "minimist", + "rawSpec": "0.0.8", + "saveSpec": null, + "fetchSpec": "0.0.8" + }, + "_requiredBy": [ + "/jade/mkdirp" + ], + "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "_spec": "0.0.8", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/minimist/issues" + }, "description": "parse argument options", - "main": "index.js", "devDependencies": { - "tape": "~1.0.4", - "tap": "~0.4.0" + "tap": "~0.4.0", + "tape": "~1.0.4" + }, + "homepage": "https://github.com/substack/minimist", + "keywords": [ + "argv", + "getopt", + "parser", + "optimist" + ], + "license": "MIT", + "main": "index.js", + "name": "minimist", + "repository": { + "type": "git", + "url": "git://github.com/substack/minimist.git" }, "scripts": { "test": "tap test/*.js" @@ -23,45 +70,5 @@ "opera/12" ] }, - "repository": { - "type": "git", - "url": "git://github.com/substack/minimist.git" - }, - "homepage": "https://github.com/substack/minimist", - "keywords": [ - "argv", - "getopt", - "parser", - "optimist" - ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/substack/minimist/issues" - }, - "_id": "minimist@0.0.8", - "dist": { - "shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", - "tarball": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - }, - "_from": "minimist@0.0.8", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d", - "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "readme": "ERROR: No README data found!" + "version": "0.0.8" } diff --git a/node_modules/jade/node_modules/mkdirp/package.json b/node_modules/jade/node_modules/mkdirp/package.json index 2c4d859..20b6e16 100644 --- a/node_modules/jade/node_modules/mkdirp/package.json +++ b/node_modules/jade/node_modules/mkdirp/package.json @@ -1,17 +1,59 @@ { - "name": "mkdirp", - "description": "Recursively mkdir, like `mkdir -p`", - "version": "0.5.1", + "_args": [ + [ + "mkdirp@0.5.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mkdirp@0.5.1", + "_id": "mkdirp@0.5.1", + "_inBundle": false, + "_integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "_location": "/jade/mkdirp", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mkdirp@0.5.1", + "name": "mkdirp", + "escapedName": "mkdirp", + "rawSpec": "0.5.1", + "saveSpec": null, + "fetchSpec": "0.5.1" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "_spec": "0.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, - "main": "index.js", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "bugs": { + "url": "https://github.com/substack/node-mkdirp/issues" + }, + "dependencies": { + "minimist": "0.0.8" + }, + "description": "Recursively mkdir, like `mkdir -p`", + "devDependencies": { + "mock-fs": "2 >=2.7.0", + "tap": "1" + }, + "homepage": "https://github.com/substack/node-mkdirp#readme", "keywords": [ "mkdir", "directory" ], + "license": "MIT", + "main": "index.js", + "name": "mkdirp", "repository": { "type": "git", "url": "git+https://github.com/substack/node-mkdirp.git" @@ -19,42 +61,5 @@ "scripts": { "test": "tap test/*.js" }, - "dependencies": { - "minimist": "0.0.8" - }, - "devDependencies": { - "tap": "1", - "mock-fs": "2 >=2.7.0" - }, - "bin": { - "mkdirp": "bin/cmd.js" - }, - "license": "MIT", - "gitHead": "d4eff0f06093aed4f387e88e9fc301cb76beedc7", - "bugs": { - "url": "https://github.com/substack/node-mkdirp/issues" - }, - "homepage": "https://github.com/substack/node-mkdirp#readme", - "_id": "mkdirp@0.5.1", - "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", - "_from": "mkdirp@>=0.5.0 <0.6.0", - "_npmVersion": "2.9.0", - "_nodeVersion": "2.0.0", - "_npmUser": { - "name": "substack", - "email": "substack@gmail.com" - }, - "dist": { - "shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", - "tarball": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.5.1" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs b/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs deleted file mode 100755 index dc9a451..0000000 --- a/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs +++ /dev/null @@ -1,370 +0,0 @@ -#! /usr/bin/env node -// -*- js -*- - -"use strict"; - -var UglifyJS = require("../tools/node"); -var sys = require("util"); -var optimist = require("optimist"); -var fs = require("fs"); -var acorn; -var ARGS = optimist - .usage("$0 input1.js [input2.js ...] [options]\n\ -Use a single dash to read input from the standard input.\ -\n\n\ -NOTE: by default there is no mangling/compression.\n\ -Without [options] it will simply parse input files and dump the AST\n\ -with whitespace and comments discarded. To achieve compression and\n\ -mangling you need to use `-c` and `-m`.\ -") - .describe("source-map", "Specify an output file where to generate source map.") - .describe("source-map-root", "The path to the original source to be included in the source map.") - .describe("source-map-url", "The path to the source map to be added in //@ sourceMappingURL. Defaults to the value passed with --source-map.") - .describe("in-source-map", "Input source map, useful if you're compressing JS that was generated from some other original code.") - .describe("p", "Skip prefix for original filenames that appear in source maps. \ -For example -p 3 will drop 3 directories from file names and ensure they are relative paths.") - .describe("o", "Output file (default STDOUT).") - .describe("b", "Beautify output/specify output options.") - .describe("m", "Mangle names/pass mangler options.") - .describe("r", "Reserved names to exclude from mangling.") - .describe("c", "Enable compressor/pass compressor options. \ -Pass options like -c hoist_vars=false,if_return=false. \ -Use -c with no argument to use the default compression options.") - .describe("d", "Global definitions") - - .describe("comments", "Preserve copyright comments in the output. \ -By default this works like Google Closure, keeping JSDoc-style comments that contain \"@license\" or \"@preserve\". \ -You can optionally pass one of the following arguments to this flag:\n\ -- \"all\" to keep all comments\n\ -- a valid JS regexp (needs to start with a slash) to keep only comments that match.\n\ -\ -Note that currently not *all* comments can be kept when compression is on, \ -because of dead code removal or cascading statements into sequences.") - - .describe("stats", "Display operations run time on STDERR.") - .describe("acorn", "Use Acorn for parsing.") - .describe("spidermonkey", "Assume input fles are SpiderMonkey AST format (as JSON).") - .describe("self", "Build itself (UglifyJS2) as a library (implies --wrap=UglifyJS --export-all)") - .describe("wrap", "Embed everything in a big function, making the “exports” and “global” variables available. \ -You need to pass an argument to this option to specify the name that your module will take when included in, say, a browser.") - .describe("export-all", "Only used when --wrap, this tells UglifyJS to add code to automatically export all globals.") - .describe("lint", "Display some scope warnings") - .describe("v", "Verbose") - .describe("V", "Print version number and exit.") - - .alias("p", "prefix") - .alias("o", "output") - .alias("v", "verbose") - .alias("b", "beautify") - .alias("m", "mangle") - .alias("c", "compress") - .alias("d", "define") - .alias("r", "reserved") - .alias("V", "version") - - .string("source-map") - .string("source-map-root") - .string("source-map-url") - .string("b") - .string("m") - .string("c") - .string("d") - .string("comments") - .string("wrap") - .boolean("export-all") - .boolean("self") - .boolean("v") - .boolean("stats") - .boolean("acorn") - .boolean("spidermonkey") - .boolean("lint") - .boolean("V") - - .wrap(80) - - .argv -; - -normalize(ARGS); - -if (ARGS.version || ARGS.V) { - var json = require("../package.json"); - sys.puts(json.name + ' ' + json.version); - process.exit(0); -} - -if (ARGS.ast_help) { - var desc = UglifyJS.describe_ast(); - sys.puts(typeof desc == "string" ? desc : JSON.stringify(desc, null, 2)); - process.exit(0); -} - -if (ARGS.h || ARGS.help) { - sys.puts(optimist.help()); - process.exit(0); -} - -if (ARGS.acorn) { - acorn = require("acorn"); -} - -var COMPRESS = getOptions("c", true); -var MANGLE = getOptions("m", true); -var BEAUTIFY = getOptions("b", true); - -if (COMPRESS && ARGS.d) { - COMPRESS.global_defs = getOptions("d"); -} - -if (MANGLE && ARGS.r) { - MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/); -} - -var OUTPUT_OPTIONS = { - beautify: BEAUTIFY ? true : false -}; - -if (BEAUTIFY) - UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY); - -if (ARGS.comments) { - if (/^\//.test(ARGS.comments)) { - OUTPUT_OPTIONS.comments = new Function("return(" + ARGS.comments + ")")(); - } else if (ARGS.comments == "all") { - OUTPUT_OPTIONS.comments = true; - } else { - OUTPUT_OPTIONS.comments = function(node, comment) { - var text = comment.value; - var type = comment.type; - if (type == "comment2") { - // multiline comment - return /@preserve|@license|@cc_on/i.test(text); - } - } - } -} - -var files = ARGS._.slice(); - -if (ARGS.self) { - if (files.length > 0) { - sys.error("WARN: Ignoring input files since --self was passed"); - } - files = UglifyJS.FILES; - if (!ARGS.wrap) ARGS.wrap = "UglifyJS"; - ARGS.export_all = true; -} - -var ORIG_MAP = ARGS.in_source_map; - -if (ORIG_MAP) { - ORIG_MAP = JSON.parse(fs.readFileSync(ORIG_MAP)); - if (files.length == 0) { - sys.error("INFO: Using file from the input source map: " + ORIG_MAP.file); - files = [ ORIG_MAP.file ]; - } - if (ARGS.source_map_root == null) { - ARGS.source_map_root = ORIG_MAP.sourceRoot; - } -} - -if (files.length == 0) { - files = [ "-" ]; -} - -if (files.indexOf("-") >= 0 && ARGS.source_map) { - sys.error("ERROR: Source map doesn't work with input from STDIN"); - process.exit(1); -} - -if (files.filter(function(el){ return el == "-" }).length > 1) { - sys.error("ERROR: Can read a single file from STDIN (two or more dashes specified)"); - process.exit(1); -} - -var STATS = {}; -var OUTPUT_FILE = ARGS.o; -var TOPLEVEL = null; - -var SOURCE_MAP = ARGS.source_map ? UglifyJS.SourceMap({ - file: OUTPUT_FILE, - root: ARGS.source_map_root, - orig: ORIG_MAP, -}) : null; - -OUTPUT_OPTIONS.source_map = SOURCE_MAP; - -try { - var output = UglifyJS.OutputStream(OUTPUT_OPTIONS); - var compressor = COMPRESS && UglifyJS.Compressor(COMPRESS); -} catch(ex) { - if (ex instanceof UglifyJS.DefaultsError) { - sys.error(ex.msg); - sys.error("Supported options:"); - sys.error(sys.inspect(ex.defs)); - process.exit(1); - } -} - -files.forEach(function(file) { - var code = read_whole_file(file); - if (ARGS.p != null) { - file = file.replace(/^\/+/, "").split(/\/+/).slice(ARGS.p).join("/"); - } - time_it("parse", function(){ - if (ARGS.spidermonkey) { - var program = JSON.parse(code); - if (!TOPLEVEL) TOPLEVEL = program; - else TOPLEVEL.body = TOPLEVEL.body.concat(program.body); - } - else if (ARGS.acorn) { - TOPLEVEL = acorn.parse(code, { - locations : true, - trackComments : true, - sourceFile : file, - program : TOPLEVEL - }); - } - else { - TOPLEVEL = UglifyJS.parse(code, { - filename: file, - toplevel: TOPLEVEL - }); - }; - }); -}); - -if (ARGS.acorn || ARGS.spidermonkey) time_it("convert_ast", function(){ - TOPLEVEL = UglifyJS.AST_Node.from_mozilla_ast(TOPLEVEL); -}); - -if (ARGS.wrap) { - TOPLEVEL = TOPLEVEL.wrap_commonjs(ARGS.wrap, ARGS.export_all); -} - -var SCOPE_IS_NEEDED = COMPRESS || MANGLE || ARGS.lint; - -if (SCOPE_IS_NEEDED) { - time_it("scope", function(){ - TOPLEVEL.figure_out_scope(); - if (ARGS.lint) { - TOPLEVEL.scope_warnings(); - } - }); -} - -if (COMPRESS) { - time_it("squeeze", function(){ - TOPLEVEL = TOPLEVEL.transform(compressor); - }); -} - -if (SCOPE_IS_NEEDED) { - time_it("scope", function(){ - TOPLEVEL.figure_out_scope(); - if (MANGLE) { - TOPLEVEL.compute_char_frequency(MANGLE); - } - }); -} - -if (MANGLE) time_it("mangle", function(){ - TOPLEVEL.mangle_names(MANGLE); -}); -time_it("generate", function(){ - TOPLEVEL.print(output); -}); - -output = output.get(); - -if (SOURCE_MAP) { - fs.writeFileSync(ARGS.source_map, SOURCE_MAP, "utf8"); - output += "\n/*\n//@ sourceMappingURL=" + (ARGS.source_map_url || ARGS.source_map) + "\n*/"; -} - -if (OUTPUT_FILE) { - fs.writeFileSync(OUTPUT_FILE, output, "utf8"); -} else { - sys.print(output); - sys.error("\n"); -} - -if (ARGS.stats) { - sys.error(UglifyJS.string_template("Timing information (compressed {count} files):", { - count: files.length - })); - for (var i in STATS) if (STATS.hasOwnProperty(i)) { - sys.error(UglifyJS.string_template("- {name}: {time}s", { - name: i, - time: (STATS[i] / 1000).toFixed(3) - })); - } -} - -/* -----[ functions ]----- */ - -function normalize(o) { - for (var i in o) if (o.hasOwnProperty(i) && /-/.test(i)) { - o[i.replace(/-/g, "_")] = o[i]; - delete o[i]; - } -} - -function getOptions(x, constants) { - x = ARGS[x]; - if (!x) return null; - var ret = {}; - if (x !== true) { - var ast; - try { - ast = UglifyJS.parse(x); - } catch(ex) { - if (ex instanceof UglifyJS.JS_Parse_Error) { - sys.error("Error parsing arguments in: " + x); - process.exit(1); - } - } - ast.walk(new UglifyJS.TreeWalker(function(node){ - if (node instanceof UglifyJS.AST_Toplevel) return; // descend - if (node instanceof UglifyJS.AST_SimpleStatement) return; // descend - if (node instanceof UglifyJS.AST_Seq) return; // descend - if (node instanceof UglifyJS.AST_Assign) { - var name = node.left.print_to_string({ beautify: false }).replace(/-/g, "_"); - var value = node.right; - if (constants) - value = new Function("return (" + value.print_to_string() + ")")(); - ret[name] = value; - return true; // no descend - } - sys.error(node.TYPE) - sys.error("Error parsing arguments in: " + x); - process.exit(1); - })); - } - return ret; -} - -function read_whole_file(filename) { - if (filename == "-") { - // XXX: this sucks. How does one read the whole STDIN - // synchronously? - filename = "/dev/stdin"; - } - try { - return fs.readFileSync(filename, "utf8"); - } catch(ex) { - sys.error("ERROR: can't read file: " + filename); - process.exit(1); - } -} - -function time_it(name, cont) { - var t1 = new Date().getTime(); - var ret = cont(); - if (ARGS.stats) { - var spent = new Date().getTime() - t1; - if (STATS[name]) STATS[name] += spent; - else STATS[name] = spent; - } - return ret; -} diff --git a/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs b/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs new file mode 120000 index 0000000..fef3468 --- /dev/null +++ b/node_modules/jade/node_modules/transformers/node_modules/.bin/uglifyjs @@ -0,0 +1 @@ +../uglify-js/bin/uglifyjs \ No newline at end of file diff --git a/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-parse/package.json b/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-parse/package.json index 9540655..e822ac2 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-parse/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-parse/package.json @@ -1,39 +1,47 @@ { - "name": "css-parse", - "version": "1.0.4", - "description": "CSS parser", - "keywords": [ - "css", - "parser", - "stylesheet" + "_args": [ + [ + "css-parse@1.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "css-parse@1.0.4", + "_id": "css-parse@1.0.4", + "_inBundle": false, + "_integrity": "sha1-OLBQP7+dqfVOnB29pg4UXHcRe90=", + "_location": "/jade/transformers/css/css-parse", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "css-parse@1.0.4", + "name": "css-parse", + "escapedName": "css-parse", + "rawSpec": "1.0.4", + "saveSpec": null, + "fetchSpec": "1.0.4" + }, + "_requiredBy": [ + "/jade/transformers/css" + ], + "_resolved": "https://registry.npmjs.org/css-parse/-/css-parse-1.0.4.tgz", + "_spec": "1.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "description": "CSS parser", "devDependencies": { "mocha": "*", "should": "*" }, - "main": "index", - "_id": "css-parse@1.0.4", - "dist": { - "shasum": "38b0503fbf9da9f54e9c1dbda60e145c77117bdd", - "tarball": "https://registry.npmjs.org/css-parse/-/css-parse-1.0.4.tgz" - }, - "_npmVersion": "1.1.61", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } + "keywords": [ + "css", + "parser", + "stylesheet" ], - "directories": {}, - "_shasum": "38b0503fbf9da9f54e9c1dbda60e145c77117bdd", - "_resolved": "https://registry.npmjs.org/css-parse/-/css-parse-1.0.4.tgz", - "_from": "css-parse@1.0.4" + "main": "index", + "name": "css-parse", + "version": "1.0.4" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-stringify/package.json b/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-stringify/package.json index a5f29ca..93ebf30 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-stringify/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/css/node_modules/css-stringify/package.json @@ -1,40 +1,48 @@ { - "name": "css-stringify", - "version": "1.0.5", - "description": "CSS compiler", - "keywords": [ - "css", - "stringify", - "stylesheet" + "_args": [ + [ + "css-stringify@1.0.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "css-stringify@1.0.5", + "_id": "css-stringify@1.0.5", + "_inBundle": false, + "_integrity": "sha1-sNBClG2ylTu50pKQCmy19tASIDE=", + "_location": "/jade/transformers/css/css-stringify", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "css-stringify@1.0.5", + "name": "css-stringify", + "escapedName": "css-stringify", + "rawSpec": "1.0.5", + "saveSpec": null, + "fetchSpec": "1.0.5" + }, + "_requiredBy": [ + "/jade/transformers/css" + ], + "_resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz", + "_spec": "1.0.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "description": "CSS compiler", "devDependencies": { + "css-parse": "1.0.3", "mocha": "*", - "should": "*", - "css-parse": "1.0.3" + "should": "*" }, - "main": "index", - "_id": "css-stringify@1.0.5", - "dist": { - "shasum": "b0d042946db2953bb9d292900a6cb5f6d0122031", - "tarball": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz" - }, - "_from": "css-stringify@1.0.5", - "_npmVersion": "1.2.14", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } + "keywords": [ + "css", + "stringify", + "stylesheet" ], - "directories": {}, - "_shasum": "b0d042946db2953bb9d292900a6cb5f6d0122031", - "_resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz" + "main": "index", + "name": "css-stringify", + "version": "1.0.5" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/css/package.json b/node_modules/jade/node_modules/transformers/node_modules/css/package.json index de70056..30a19e4 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/css/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/css/package.json @@ -1,12 +1,32 @@ { - "name": "css", - "version": "1.0.8", - "description": "CSS parser / stringifier using css-parse and css-stringify", - "keywords": [ - "css", - "parser", - "stylesheet" + "_args": [ + [ + "css@1.0.8", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], + "_from": "css@1.0.8", + "_id": "css@1.0.8", + "_inBundle": false, + "_integrity": "sha1-k4aBHKgrzMnuf7WnMrHioxfIo+c=", + "_location": "/jade/transformers/css", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "css@1.0.8", + "name": "css", + "escapedName": "css", + "rawSpec": "1.0.8", + "saveSpec": null, + "fetchSpec": "1.0.8" + }, + "_requiredBy": [ + "/jade/transformers" + ], + "_resolved": "https://registry.npmjs.org/css/-/css-1.0.8.tgz", + "_spec": "1.0.8", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" @@ -15,25 +35,13 @@ "css-parse": "1.0.4", "css-stringify": "1.0.5" }, - "main": "index", - "_id": "css@1.0.8", - "dist": { - "shasum": "9386811ca82bccc9ee7fb5a732b1e2a317c8a3e7", - "tarball": "https://registry.npmjs.org/css/-/css-1.0.8.tgz" - }, - "_from": "css@>=1.0.8 <1.1.0", - "_npmVersion": "1.2.14", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } + "description": "CSS parser / stringifier using css-parse and css-stringify", + "keywords": [ + "css", + "parser", + "stylesheet" ], - "directories": {}, - "_shasum": "9386811ca82bccc9ee7fb5a732b1e2a317c8a3e7", - "_resolved": "https://registry.npmjs.org/css/-/css-1.0.8.tgz" + "main": "index", + "name": "css", + "version": "1.0.8" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/promise/node_modules/is-promise/package.json b/node_modules/jade/node_modules/transformers/node_modules/promise/node_modules/is-promise/package.json index 3073534..fdfb378 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/promise/node_modules/is-promise/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/promise/node_modules/is-promise/package.json @@ -1,45 +1,53 @@ { - "name": "is-promise", - "version": "1.0.1", - "description": "Test whether an object looks like a promises-a+ promise", - "main": "index.js", - "scripts": { - "test": "mocha -R spec" - }, - "repository": { - "type": "git", - "url": "https://github.com/then/is-promise.git" + "_args": [ + [ + "is-promise@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "is-promise@1.0.1", + "_id": "is-promise@1.0.1", + "_inBundle": false, + "_integrity": "sha1-MVc3YcBX4zwukaq56W2gjO++duU=", + "_location": "/jade/transformers/promise/is-promise", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "is-promise@1.0.1", + "name": "is-promise", + "escapedName": "is-promise", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" }, + "_requiredBy": [ + "/jade/transformers/promise" + ], + "_resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", + "bugs": { + "url": "https://github.com/then/is-promise/issues" + }, + "description": "Test whether an object looks like a promises-a+ promise", "devDependencies": { "better-assert": "~0.1.0", "mocha": "~1.7.4" }, - "bugs": { - "url": "https://github.com/then/is-promise/issues" - }, - "homepage": "https://github.com/then/is-promise", - "_id": "is-promise@1.0.1", - "dist": { - "shasum": "31573761c057e33c2e91aab9e96da08cefbe76e5", - "tarball": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz" + "homepage": "https://github.com/then/is-promise#readme", + "license": "MIT", + "main": "index.js", + "name": "is-promise", + "repository": { + "type": "git", + "url": "git+https://github.com/then/is-promise.git" }, - "_from": "is-promise@>=1.0.0 <2.0.0", - "_npmVersion": "1.4.3", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindeay.co.uk" + "scripts": { + "test": "mocha -R spec" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "directories": {}, - "_shasum": "31573761c057e33c2e91aab9e96da08cefbe76e5", - "_resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/promise/package.json b/node_modules/jade/node_modules/transformers/node_modules/promise/package.json index 93a9229..4510f22 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/promise/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/promise/package.json @@ -1,45 +1,57 @@ { - "name": "promise", - "version": "2.0.0", - "description": "Bare bones Promises/A+ implementation", - "main": "index.js", - "scripts": { - "test": "mocha -R spec --timeout 200 --slow 99999" - }, - "repository": { - "type": "git", - "url": "https://github.com/then/promise.git" + "_args": [ + [ + "promise@2.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "promise@2.0.0", + "_id": "promise@2.0.0", + "_inBundle": false, + "_integrity": "sha1-RmSKqdYFr10ucMMCS/WUNtoCuA4=", + "_location": "/jade/transformers/promise", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "promise@2.0.0", + "name": "promise", + "escapedName": "promise", + "rawSpec": "2.0.0", + "saveSpec": null, + "fetchSpec": "2.0.0" }, + "_requiredBy": [ + "/jade/transformers" + ], + "_resolved": "https://registry.npmjs.org/promise/-/promise-2.0.0.tgz", + "_spec": "2.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", + "bugs": { + "url": "https://github.com/then/promise/issues" + }, "dependencies": { "is-promise": "~1" }, + "description": "Bare bones Promises/A+ implementation", "devDependencies": { - "promises-aplus-tests": "*", + "better-assert": "~1.0.0", "mocha-as-promised": "~1.2.1", - "better-assert": "~1.0.0" + "promises-aplus-tests": "*" }, - "_id": "promise@2.0.0", - "dist": { - "shasum": "46648aa9d605af5d2e70c3024bf59436da02b80e", - "tarball": "https://registry.npmjs.org/promise/-/promise-2.0.0.tgz" + "homepage": "https://github.com/then/promise#readme", + "license": "MIT", + "main": "index.js", + "name": "promise", + "repository": { + "type": "git", + "url": "git+https://github.com/then/promise.git" }, - "_from": "promise@>=2.0.0 <2.1.0", - "_npmVersion": "1.2.10", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" + "scripts": { + "test": "mocha -R spec --timeout 200 --slow 99999" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "directories": {}, - "_shasum": "46648aa9d605af5d2e70c3024bf59436da02b80e", - "_resolved": "https://registry.npmjs.org/promise/-/promise-2.0.0.tgz" + "version": "2.0.0" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap/package.json b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap/package.json index a414064..8c67aa4 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/node_modules/wordwrap/package.json @@ -1,62 +1,69 @@ { - "name": "wordwrap", - "description": "Wrap those words. Show them at what columns to start and stop.", - "version": "0.0.3", - "repository": { - "type": "git", - "url": "git://github.com/substack/node-wordwrap.git" + "_args": [ + [ + "wordwrap@0.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "wordwrap@0.0.3", + "_id": "wordwrap@0.0.3", + "_inBundle": false, + "_integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "_location": "/jade/transformers/uglify-js/optimist/wordwrap", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "wordwrap@0.0.3", + "name": "wordwrap", + "escapedName": "wordwrap", + "rawSpec": "0.0.3", + "saveSpec": null, + "fetchSpec": "0.0.3" }, - "main": "./index.js", - "keywords": [ - "word", - "wrap", - "rule", - "format", - "column" + "_requiredBy": [ + "/jade/transformers/uglify-js/optimist" ], - "directories": { - "lib": ".", - "example": "example", - "test": "test" + "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "_spec": "0.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" }, - "scripts": { - "test": "expresso" + "bugs": { + "url": "https://github.com/substack/node-wordwrap/issues" }, + "description": "Wrap those words. Show them at what columns to start and stop.", "devDependencies": { "expresso": "=0.7.x" }, + "directories": { + "lib": ".", + "example": "example", + "test": "test" + }, "engines": { "node": ">=0.4.0" }, + "homepage": "https://github.com/substack/node-wordwrap#readme", + "keywords": [ + "word", + "wrap", + "rule", + "format", + "column" + ], "license": "MIT", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" + "main": "./index.js", + "name": "wordwrap", + "repository": { + "type": "git", + "url": "git://github.com/substack/node-wordwrap.git" }, - "gitHead": "e59aa1bd338914019456bdfba034508c9c4cb29d", - "bugs": { - "url": "https://github.com/substack/node-wordwrap/issues" + "scripts": { + "test": "expresso" }, - "homepage": "https://github.com/substack/node-wordwrap#readme", - "_id": "wordwrap@0.0.3", - "_shasum": "a3d5da6cd5c0bc0008d37234bbaf1bed63059107", - "_from": "wordwrap@>=0.0.2 <0.1.0", - "_npmVersion": "2.9.0", - "_nodeVersion": "2.0.0", - "_npmUser": { - "name": "substack", - "email": "substack@gmail.com" - }, - "dist": { - "shasum": "a3d5da6cd5c0bc0008d37234bbaf1bed63059107", - "tarball": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" + "version": "0.0.3" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/package.json b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/package.json index 8e19288..6a68065 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/optimist/package.json @@ -1,22 +1,52 @@ { - "name": "optimist", - "version": "0.3.7", - "description": "Light-weight option parsing with an argv hash. No optstrings attached.", - "main": "./index.js", + "_args": [ + [ + "optimist@0.3.7", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "optimist@0.3.7", + "_id": "optimist@0.3.7", + "_inBundle": false, + "_integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=", + "_location": "/jade/transformers/uglify-js/optimist", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "optimist@0.3.7", + "name": "optimist", + "escapedName": "optimist", + "rawSpec": "0.3.7", + "saveSpec": null, + "fetchSpec": "0.3.7" + }, + "_requiredBy": [ + "/jade/transformers/uglify-js" + ], + "_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz", + "_spec": "0.3.7", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/node-optimist/issues" + }, "dependencies": { "wordwrap": "~0.0.2" }, + "description": "Light-weight option parsing with an argv hash. No optstrings attached.", "devDependencies": { "hashish": "~0.0.4", "tap": "~0.4.0" }, - "scripts": { - "test": "tap ./test/*.js" - }, - "repository": { - "type": "git", - "url": "http://github.com/substack/node-optimist.git" + "engine": { + "node": ">=0.4" }, + "homepage": "https://github.com/substack/node-optimist#readme", "keywords": [ "argument", "args", @@ -26,33 +56,15 @@ "cli", "command" ], - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, "license": "MIT/X11", - "engine": { - "node": ">=0.4" + "main": "./index.js", + "name": "optimist", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/substack/node-optimist.git" }, - "_id": "optimist@0.3.7", - "dist": { - "shasum": "c90941ad59e4273328923074d2cf2e7cbc6ec0d9", - "tarball": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz" - }, - "_from": "optimist@>=0.3.5 <0.4.0", - "_npmVersion": "1.2.2", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "c90941ad59e4273328923074d2cf2e7cbc6ec0d9", - "_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz" + "scripts": { + "test": "tap ./test/*.js" + }, + "version": "0.3.7" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/package.json b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/package.json index b143c17..43295a1 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/node_modules/amdefine/package.json @@ -1,50 +1,51 @@ { - "name": "amdefine", - "description": "Provide AMD's define() API for declaring modules in the AMD format", - "version": "1.0.1", - "homepage": "http://github.com/jrburke/amdefine", + "_args": [ + [ + "amdefine@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "amdefine@1.0.1", + "_id": "amdefine@1.0.1", + "_inBundle": false, + "_integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "_location": "/jade/transformers/uglify-js/source-map/amdefine", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "amdefine@1.0.1", + "name": "amdefine", + "escapedName": "amdefine", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/jade/transformers/uglify-js/source-map" + ], + "_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "James Burke", "email": "jrburke@gmail.com", "url": "http://github.com/jrburke" }, - "license": "BSD-3-Clause OR MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jrburke/amdefine.git" - }, - "main": "./amdefine.js", - "engines": { - "node": ">=0.4.2" - }, - "gitHead": "e59edc9da24404ec7937098e3992f8fb0e260be7", "bugs": { "url": "https://github.com/jrburke/amdefine/issues" }, - "_id": "amdefine@1.0.1", - "scripts": {}, - "_shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5", - "_from": "amdefine@>=0.0.4", - "_npmVersion": "3.10.3", - "_nodeVersion": "6.7.0", - "_npmUser": { - "name": "jrburke", - "email": "jrburke@gmail.com" - }, - "dist": { - "shasum": "4a5282ac164729e93619bcfd3ad151f817ce91f5", - "tarball": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + "description": "Provide AMD's define() API for declaring modules in the AMD format", + "engines": { + "node": ">=0.4.2" }, - "maintainers": [ - { - "name": "jrburke", - "email": "jrburke@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/amdefine-1.0.1.tgz_1478062849665_0.19916908955201507" + "homepage": "http://github.com/jrburke/amdefine", + "license": "BSD-3-Clause OR MIT", + "main": "./amdefine.js", + "name": "amdefine", + "repository": { + "type": "git", + "url": "git+https://github.com/jrburke/amdefine.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/package.json b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/package.json index 7d796c8..12aa5ca 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/node_modules/source-map/package.json @@ -1,12 +1,39 @@ { - "name": "source-map", - "description": "Generates and consumes source maps", - "version": "0.1.43", - "homepage": "https://github.com/mozilla/source-map", + "_args": [ + [ + "source-map@0.1.43", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "source-map@0.1.43", + "_id": "source-map@0.1.43", + "_inBundle": false, + "_integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "_location": "/jade/transformers/uglify-js/source-map", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "source-map@0.1.43", + "name": "source-map", + "escapedName": "source-map", + "rawSpec": "0.1.43", + "saveSpec": null, + "fetchSpec": "0.1.43" + }, + "_requiredBy": [ + "/jade/transformers/uglify-js" + ], + "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "_spec": "0.1.43", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Nick Fitzgerald", "email": "nfitzgerald@mozilla.com" }, + "bugs": { + "url": "https://github.com/mozilla/source-map/issues" + }, "contributors": [ { "name": "Tobias Koppers", @@ -125,61 +152,35 @@ "email": "daniel@danielespeset.com" } ], - "repository": { - "type": "git", - "url": "http://github.com/mozilla/source-map.git" + "dependencies": { + "amdefine": ">=0.0.4" + }, + "description": "Generates and consumes source maps", + "devDependencies": { + "dryice": ">=0.4.8" }, "directories": { "lib": "./lib" }, - "main": "./lib/source-map.js", "engines": { "node": ">=0.8.0" }, + "homepage": "https://github.com/mozilla/source-map", "licenses": [ { "type": "BSD", "url": "http://opensource.org/licenses/BSD-3-Clause" } ], - "dependencies": { - "amdefine": ">=0.0.4" - }, - "devDependencies": { - "dryice": ">=0.4.8" + "main": "./lib/source-map.js", + "name": "source-map", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/mozilla/source-map.git" }, "scripts": { - "test": "node test/run-tests.js", - "build": "node Makefile.dryice.js" - }, - "bugs": { - "url": "https://github.com/mozilla/source-map/issues" - }, - "_id": "source-map@0.1.43", - "_shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346", - "_from": "source-map@>=0.1.7 <0.2.0", - "_npmVersion": "1.4.9", - "_npmUser": { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - }, - "maintainers": [ - { - "name": "mozilla-devtools", - "email": "mozilla-developer-tools@googlegroups.com" - }, - { - "name": "mozilla", - "email": "dherman@mozilla.com" - }, - { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - } - ], - "dist": { - "shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346", - "tarball": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz" + "build": "node Makefile.dryice.js", + "test": "node test/run-tests.js" }, - "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz" + "version": "0.1.43" } diff --git a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/package.json b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/package.json index 929f0f5..1df44c0 100644 --- a/node_modules/jade/node_modules/transformers/node_modules/uglify-js/package.json +++ b/node_modules/jade/node_modules/transformers/node_modules/uglify-js/package.json @@ -1,54 +1,68 @@ { - "name": "uglify-js", + "_args": [ + [ + "uglify-js@2.2.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "uglify-js@2.2.5", + "_id": "uglify-js@2.2.5", + "_inBundle": false, + "_integrity": "sha1-puAqcNg5eSuXgEiLe4sYTAlcmcc=", + "_location": "/jade/transformers/uglify-js", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "uglify-js@2.2.5", + "name": "uglify-js", + "escapedName": "uglify-js", + "rawSpec": "2.2.5", + "saveSpec": null, + "fetchSpec": "2.2.5" + }, + "_requiredBy": [ + "/jade/transformers" + ], + "_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.2.5.tgz", + "_spec": "2.2.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "bugs": { + "url": "https://github.com/mishoo/UglifyJS2/issues" + }, + "dependencies": { + "optimist": "~0.3.5", + "source-map": "~0.1.7" + }, "description": "JavaScript parser, mangler/compressor and beautifier toolkit", - "homepage": "http://lisperator.net/uglifyjs", - "main": "tools/node.js", - "version": "2.2.5", "engines": { "node": ">=0.4.0" }, + "homepage": "http://lisperator.net/uglifyjs", + "main": "tools/node.js", "maintainers": [ { - "name": "caires", - "email": "cairesvs@gmail.com" - }, - { - "name": "mape", - "email": "mape@mape.me" - }, - { - "name": "mishoo", - "email": "mihai.bazon@gmail.com" + "name": "Mihai Bazon", + "email": "mihai.bazon@gmail.com", + "url": "http://lisperator.net/" } ], + "name": "uglify-js", "repositories": [ { "type": "git", - "url": "https://github.com/mishoo/UglifyJS2.git" + "url": "git+https://github.com/mishoo/UglifyJS2.git" } ], - "dependencies": { - "source-map": "~0.1.7", - "optimist": "~0.3.5" - }, - "bin": { - "uglifyjs": "bin/uglifyjs" + "repository": { + "type": "git", + "url": "git+https://github.com/mishoo/UglifyJS2.git" }, "scripts": { "test": "node test/run-tests.js" }, - "_id": "uglify-js@2.2.5", - "dist": { - "shasum": "a6e02a70d839792b9780488b7b8b184c095c99c7", - "tarball": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.2.5.tgz" - }, - "_npmVersion": "1.1.66", - "_npmUser": { - "name": "mishoo", - "email": "mihai.bazon@gmail.com" - }, - "directories": {}, - "_shasum": "a6e02a70d839792b9780488b7b8b184c095c99c7", - "_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.2.5.tgz", - "_from": "uglify-js@>=2.2.5 <2.3.0" + "version": "2.2.5" } diff --git a/node_modules/jade/node_modules/transformers/package.json b/node_modules/jade/node_modules/transformers/package.json index 3cef10b..fe7a582 100644 --- a/node_modules/jade/node_modules/transformers/package.json +++ b/node_modules/jade/node_modules/transformers/package.json @@ -1,90 +1,101 @@ { - "name": "transformers", - "version": "2.1.0", - "description": "String/Data transformations for use in templating libraries, static site generators and web frameworks", - "main": "lib/transformers.js", - "scripts": { - "pretest": "node test/update-package && npm install", - "test": "mocha test/test.js -R spec" - }, - "repository": { - "type": "git", - "url": "https://github.com/ForbesLindesay/transformers.git" + "_args": [ + [ + "transformers@2.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "transformers@2.1.0", + "_id": "transformers@2.1.0", + "_inBundle": false, + "_integrity": "sha1-XSPLNVYd2F3Gf7hIIwm0fVPM6ac=", + "_location": "/jade/transformers", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "transformers@2.1.0", + "name": "transformers", + "escapedName": "transformers", + "rawSpec": "2.1.0", + "saveSpec": null, + "fetchSpec": "2.1.0" }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/transformers/-/transformers-2.1.0.tgz", + "_spec": "2.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", - "gitHead": "4b46e72cba3ad3403fd5ed3802d5472dcfa77311", + "bugs": { + "url": "https://github.com/ForbesLindesay/transformers/issues" + }, + "dependencies": { + "css": "~1.0.8", + "promise": "~2.0", + "uglify-js": "~2.2.5" + }, + "description": "String/Data transformations for use in templating libraries, static site generators and web frameworks", "devDependencies": { - "mocha": "~1.8", - "expect.js": "~0.2", - "swig": "*", "atpl": "*", - "liquor": "*", - "ejs": "*", + "coffee-script": "*", + "coffeecup": "*", + "coffeekup": "*", + "component-builder": "*", + "cson": "*", + "dot": "*", + "dust": "*", + "dustjs-linkedin": "*", "eco": "*", - "jqtpl": "*", - "hamljs": "*", + "ect": "*", + "ejs": "*", + "expect.js": "~0.2", "haml-coffee": "*", - "whiskers": "*", - "hogan.js": "*", + "hamljs": "*", "handlebars": "*", - "underscore": "*", - "walrus": "*", - "mustache": "*", - "mote": "*", - "toffee": "*", - "just": "*", - "ect": "*", + "highlight.js": "*", + "hogan.js": "*", + "html2jade": "*", "jade": "*", - "then-jade": "*", - "dust": "*", - "dustjs-linkedin": "*", "jazz": "*", - "qejs": "*", + "jqtpl": "*", + "just": "*", "less": "*", - "stylus": "*", - "sass": "*", + "liquor": "*", + "markdown": "*", + "markdown-js": "*", "marked": "*", + "mocha": "~1.8", + "mote": "*", + "mustache": "*", + "plates": "*", + "qejs": "*", + "sass": "*", + "stylus": "*", "supermarked": "*", - "markdown-js": "*", - "markdown": "*", - "coffee-script": "*", - "cson": "*", - "coffeekup": "*", - "coffeecup": "*", + "swig": "*", "templayed": "*", - "plates": "*", - "dot": "*", - "component-builder": "*", - "html2jade": "*", - "highlight.js": "*" - }, - "dependencies": { - "promise": "~2.0", - "css": "~1.0.8", - "uglify-js": "~2.2.5" + "then-jade": "*", + "toffee": "*", + "underscore": "*", + "walrus": "*", + "whiskers": "*" }, - "_id": "transformers@2.1.0", - "dist": { - "shasum": "5d23cb35561dd85dc67fb8482309b47d53cce9a7", - "tarball": "https://registry.npmjs.org/transformers/-/transformers-2.1.0.tgz" + "gitHead": "4b46e72cba3ad3403fd5ed3802d5472dcfa77311", + "homepage": "https://github.com/ForbesLindesay/transformers#readme", + "license": "MIT", + "main": "lib/transformers.js", + "name": "transformers", + "repository": { + "type": "git", + "url": "git+https://github.com/ForbesLindesay/transformers.git" }, - "_from": "transformers@2.1.0", - "_npmVersion": "1.2.10", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" + "scripts": { + "pretest": "node test/update-package && npm install", + "test": "mocha test/test.js -R spec" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "deprecated": "Deprecated, use jstransformer", - "directories": {}, - "_shasum": "5d23cb35561dd85dc67fb8482309b47d53cce9a7", - "_resolved": "https://registry.npmjs.org/transformers/-/transformers-2.1.0.tgz" + "version": "2.1.0" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/source-map/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/source-map/package.json index 98d287a..47d178d 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/source-map/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/source-map/package.json @@ -1,12 +1,39 @@ { - "name": "source-map", - "description": "Generates and consumes source maps", - "version": "0.5.6", - "homepage": "https://github.com/mozilla/source-map", + "_args": [ + [ + "source-map@0.5.6", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "source-map@0.5.6", + "_id": "source-map@0.5.6", + "_inBundle": false, + "_integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "_location": "/jade/uglify-js/source-map", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "source-map@0.5.6", + "name": "source-map", + "escapedName": "source-map", + "rawSpec": "0.5.6", + "saveSpec": null, + "fetchSpec": "0.5.6" + }, + "_requiredBy": [ + "/jade/uglify-js" + ], + "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "_spec": "0.5.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Nick Fitzgerald", "email": "nfitzgerald@mozilla.com" }, + "bugs": { + "url": "https://github.com/mozilla/source-map/issues" + }, "contributors": [ { "name": "Tobias Koppers", @@ -153,11 +180,14 @@ "email": "nicolas.lalevee@hibnet.org" } ], - "repository": { - "type": "git", - "url": "http://github.com/mozilla/source-map.git" + "description": "Generates and consumes source maps", + "devDependencies": { + "doctoc": "^0.15.0", + "webpack": "^1.12.0" + }, + "engines": { + "node": ">=0.10.0" }, - "main": "./source-map.js", "files": [ "source-map.js", "lib/", @@ -166,54 +196,18 @@ "dist/source-map.min.js", "dist/source-map.min.js.map" ], - "engines": { - "node": ">=0.10.0" - }, + "homepage": "https://github.com/mozilla/source-map", "license": "BSD-3-Clause", + "main": "./source-map.js", + "name": "source-map", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/mozilla/source-map.git" + }, "scripts": { - "test": "npm run build && node test/run-tests.js", "build": "webpack --color", + "test": "npm run build && node test/run-tests.js", "toc": "doctoc --title '## Table of Contents' README.md && doctoc --title '## Table of Contents' CONTRIBUTING.md" }, - "devDependencies": { - "doctoc": "^0.15.0", - "webpack": "^1.12.0" - }, - "gitHead": "aa0398ced67beebea34f0d36f766505656c344f6", - "bugs": { - "url": "https://github.com/mozilla/source-map/issues" - }, - "_id": "source-map@0.5.6", - "_shasum": "75ce38f52bf0733c5a7f0c118d81334a2bb5f412", - "_from": "source-map@>=0.5.1 <0.6.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.3.0", - "_npmUser": { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - }, - "maintainers": [ - { - "name": "mozilla-devtools", - "email": "mozilla-developer-tools@googlegroups.com" - }, - { - "name": "mozilla", - "email": "dherman@mozilla.com" - }, - { - "name": "nickfitzgerald", - "email": "fitzgen@gmail.com" - } - ], - "dist": { - "shasum": "75ce38f52bf0733c5a7f0c118d81334a2bb5f412", - "tarball": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/source-map-0.5.6.tgz_1462209962516_0.9263619624543935" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" + "version": "0.5.6" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/uglify-to-browserify/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/uglify-to-browserify/package.json index 38d69a2..016998d 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/uglify-to-browserify/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/uglify-to-browserify/package.json @@ -1,46 +1,55 @@ { - "name": "uglify-to-browserify", - "version": "1.0.2", - "description": "A transform to make UglifyJS work in browserify.", - "keywords": [], - "dependencies": {}, - "devDependencies": { - "uglify-js": "~2.4.0", - "source-map": "~0.1.27" - }, - "scripts": { - "test": "node test/index.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/ForbesLindesay/uglify-to-browserify.git" + "_args": [ + [ + "uglify-to-browserify@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "uglify-to-browserify@1.0.2", + "_id": "uglify-to-browserify@1.0.2", + "_inBundle": false, + "_integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "_location": "/jade/uglify-js/uglify-to-browserify", + "_optional": true, + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "uglify-to-browserify@1.0.2", + "name": "uglify-to-browserify", + "escapedName": "uglify-to-browserify", + "rawSpec": "1.0.2", + "saveSpec": null, + "fetchSpec": "1.0.2" }, + "_requiredBy": [ + "/jade/uglify-js" + ], + "_resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", "bugs": { "url": "https://github.com/ForbesLindesay/uglify-to-browserify/issues" }, - "homepage": "https://github.com/ForbesLindesay/uglify-to-browserify", - "_id": "uglify-to-browserify@1.0.2", - "dist": { - "shasum": "6e0924d6bda6b5afe349e39a6d632850a0f882b7", - "tarball": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz" + "dependencies": {}, + "description": "A transform to make UglifyJS work in browserify.", + "devDependencies": { + "source-map": "~0.1.27", + "uglify-js": "~2.4.0" + }, + "homepage": "https://github.com/ForbesLindesay/uglify-to-browserify#readme", + "keywords": [], + "license": "MIT", + "name": "uglify-to-browserify", + "repository": { + "type": "git", + "url": "git+https://github.com/ForbesLindesay/uglify-to-browserify.git" }, - "_from": "uglify-to-browserify@>=1.0.0 <1.1.0", - "_npmVersion": "1.3.14", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindeay.co.uk" + "scripts": { + "test": "node test/index.js" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "directories": {}, - "_shasum": "6e0924d6bda6b5afe349e39a6d632850a0f882b7", - "_resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz" + "version": "1.0.2" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/camelcase/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/camelcase/package.json index c0c6593..6061c01 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/camelcase/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/camelcase/package.json @@ -1,26 +1,51 @@ { - "name": "camelcase", - "version": "1.2.1", - "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/sindresorhus/camelcase" + "_args": [ + [ + "camelcase@1.2.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "camelcase@1.2.1", + "_id": "camelcase@1.2.1", + "_inBundle": false, + "_integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "_location": "/jade/uglify-js/yargs/camelcase", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "camelcase@1.2.1", + "name": "camelcase", + "escapedName": "camelcase", + "rawSpec": "1.2.1", + "saveSpec": null, + "fetchSpec": "1.2.1" }, + "_requiredBy": [ + "/jade/uglify-js/yargs" + ], + "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "_spec": "1.2.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "http://sindresorhus.com" }, + "bugs": { + "url": "https://github.com/sindresorhus/camelcase/issues" + }, + "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", + "devDependencies": { + "ava": "0.0.4" + }, "engines": { "node": ">=0.10.0" }, - "scripts": { - "test": "node test.js" - }, "files": [ "index.js" ], + "homepage": "https://github.com/sindresorhus/camelcase#readme", "keywords": [ "camelcase", "camel-case", @@ -35,33 +60,14 @@ "text", "convert" ], - "devDependencies": { - "ava": "0.0.4" - }, - "gitHead": "185ba12da723be9c1ee986cc2956bdc4c517a141", - "bugs": { - "url": "https://github.com/sindresorhus/camelcase/issues" - }, - "homepage": "https://github.com/sindresorhus/camelcase", - "_id": "camelcase@1.2.1", - "_shasum": "9bb5304d2e0b56698b2c758b08a3eaa9daa58a39", - "_from": "camelcase@>=1.0.2 <2.0.0", - "_npmVersion": "2.11.2", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" + "license": "MIT", + "name": "camelcase", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/camelcase.git" }, - "dist": { - "shasum": "9bb5304d2e0b56698b2c758b08a3eaa9daa58a39", - "tarball": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz" + "scripts": { + "test": "node test.js" }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz" + "version": "1.2.1" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json index 0b7c5f1..46a9b9c 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json @@ -1,7 +1,32 @@ { - "name": "is-buffer", - "description": "Determine if an object is a Buffer", - "version": "1.1.5", + "_args": [ + [ + "is-buffer@1.1.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "is-buffer@1.1.5", + "_id": "is-buffer@1.1.5", + "_inBundle": false, + "_integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/align-text/kind-of/is-buffer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "is-buffer@1.1.5", + "name": "is-buffer", + "escapedName": "is-buffer", + "rawSpec": "1.1.5", + "saveSpec": null, + "fetchSpec": "1.1.5" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align/align-text/kind-of" + ], + "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "_spec": "1.1.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", @@ -11,11 +36,13 @@ "url": "https://github.com/feross/is-buffer/issues" }, "dependencies": {}, + "description": "Determine if an object is a Buffer", "devDependencies": { "standard": "*", "tape": "^4.0.0", "zuul": "^3.0.0" }, + "homepage": "https://github.com/feross/is-buffer#readme", "keywords": [ "buffer", "buffers", @@ -35,6 +62,7 @@ ], "license": "MIT", "main": "index.js", + "name": "is-buffer", "repository": { "type": "git", "url": "git://github.com/feross/is-buffer.git" @@ -48,31 +76,5 @@ "testling": { "files": "test/*.js" }, - "gitHead": "56dc50e7b271c7d2968269430cbd4f717bbcf6c0", - "homepage": "https://github.com/feross/is-buffer#readme", - "_id": "is-buffer@1.1.5", - "_shasum": "1f3b26ef613b214b88cbca23cc6c01d87961eecc", - "_from": "is-buffer@>=1.1.5 <2.0.0", - "_npmVersion": "3.10.10", - "_nodeVersion": "6.9.5", - "_npmUser": { - "name": "feross", - "email": "feross@feross.org" - }, - "dist": { - "shasum": "1f3b26ef613b214b88cbca23cc6c01d87961eecc", - "tarball": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz" - }, - "maintainers": [ - { - "name": "feross", - "email": "feross@feross.org" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/is-buffer-1.1.5.tgz_1489193465717_0.9356542676687241" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz" + "version": "1.1.5" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/package.json index 9d266c7..ab87739 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/package.json @@ -1,12 +1,39 @@ { - "name": "kind-of", - "description": "Get the native type of a value.", - "version": "3.2.2", - "homepage": "https://github.com/jonschlinkert/kind-of", + "_args": [ + [ + "kind-of@3.2.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "kind-of@3.2.2", + "_id": "kind-of@3.2.2", + "_inBundle": false, + "_integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/align-text/kind-of", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "kind-of@3.2.2", + "name": "kind-of", + "escapedName": "kind-of", + "rawSpec": "3.2.2", + "saveSpec": null, + "fetchSpec": "3.2.2" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "_spec": "3.2.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, + "bugs": { + "url": "https://github.com/jonschlinkert/kind-of/issues" + }, "contributors": [ { "name": "David Fox-Powell", @@ -33,28 +60,10 @@ "url": "http://about.me/peterdehaan" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/kind-of.git" - }, - "bugs": { - "url": "https://github.com/jonschlinkert/kind-of/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha", - "prepublish": "browserify -o browser.js -e index.js -s index --bare" - }, "dependencies": { "is-buffer": "^1.1.5" }, + "description": "Get the native type of a value.", "devDependencies": { "ansi-bold": "^0.1.1", "benchmarked": "^1.0.0", @@ -65,6 +74,13 @@ "type-of": "^2.0.1", "typeof": "^1.0.0" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/kind-of", "keywords": [ "arguments", "array", @@ -88,6 +104,17 @@ "typeof", "types" ], + "license": "MIT", + "main": "index.js", + "name": "kind-of", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/kind-of.git" + }, + "scripts": { + "prepublish": "browserify -o browser.js -e index.js -s index --bare", + "test": "mocha" + }, "verb": { "related": { "list": [ @@ -111,34 +138,5 @@ "verb" ] }, - "gitHead": "0ffe67cf12f5396047c1bacf04232b7deeb24063", - "_id": "kind-of@3.2.2", - "_shasum": "31ea21a734bab9bbb0f32466d893aea51e4a3c64", - "_from": "kind-of@>=3.0.2 <4.0.0", - "_npmVersion": "4.5.0", - "_nodeVersion": "7.7.3", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - } - ], - "dist": { - "shasum": "31ea21a734bab9bbb0f32466d893aea51e4a3c64", - "tarball": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/kind-of-3.2.2.tgz_1494958899918_0.23780996026471257" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz" + "version": "3.2.2" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/longest/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/longest/package.json index 648de13..2316ac5 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/longest/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/longest/package.json @@ -1,37 +1,51 @@ { - "name": "longest", - "description": "Get the longest item in an array.", - "version": "1.0.1", - "homepage": "https://github.com/jonschlinkert/longest", + "_args": [ + [ + "longest@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "longest@1.0.1", + "_id": "longest@1.0.1", + "_inBundle": false, + "_integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/align-text/longest", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "longest@1.0.1", + "name": "longest", + "escapedName": "longest", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "https://github.com/jonschlinkert/longest.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/longest/issues" }, - "license": { - "type": "MIT", - "url": "https://github.com/jonschlinkert/longest/blob/master/LICENSE" - }, - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, + "description": "Get the longest item in an array.", "devDependencies": { "fill-range": "^2.1.0", "mocha": "*" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/longest", "keywords": [ "array", "element", @@ -40,30 +54,18 @@ "length", "longest" ], - "gitHead": "99d9d8257584500aedaea54427a828197c452b0a", - "_id": "longest@1.0.1", - "_shasum": "30a0b2da38f73770e8294a0d22e6625ed77d0097", - "_from": "longest@>=1.0.1 <2.0.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "0.12.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/longest/blob/master/LICENSE" }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - } - ], - "dist": { - "shasum": "30a0b2da38f73770e8294a0d22e6625ed77d0097", - "tarball": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz" + "main": "index.js", + "name": "longest", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/longest.git" + }, + "scripts": { + "test": "mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/repeat-string/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/repeat-string/package.json index f1ed51f..d16104a 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/repeat-string/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/repeat-string/package.json @@ -1,12 +1,39 @@ { - "name": "repeat-string", - "description": "Repeat the given string n times. Fastest implementation for repeating a string.", - "version": "1.6.1", - "homepage": "https://github.com/jonschlinkert/repeat-string", + "_args": [ + [ + "repeat-string@1.6.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "repeat-string@1.6.1", + "_id": "repeat-string@1.6.1", + "_inBundle": false, + "_integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/align-text/repeat-string", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "repeat-string@1.6.1", + "name": "repeat-string", + "escapedName": "repeat-string", + "rawSpec": "1.6.1", + "saveSpec": null, + "fetchSpec": "1.6.1" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "_spec": "1.6.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "http://github.com/jonschlinkert" }, + "bugs": { + "url": "https://github.com/jonschlinkert/repeat-string/issues" + }, "contributors": [ { "name": "Brian Woodward", @@ -34,24 +61,7 @@ "url": "wooorm.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/repeat-string.git" - }, - "bugs": { - "url": "https://github.com/jonschlinkert/repeat-string/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10" - }, - "scripts": { - "test": "mocha" - }, + "description": "Repeat the given string n times. Fastest implementation for repeating a string.", "devDependencies": { "ansi-cyan": "^0.1.1", "benchmarked": "^0.2.5", @@ -62,6 +72,13 @@ "text-table": "^0.2.0", "yargs-parser": "^4.0.2" }, + "engines": { + "node": ">=0.10" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/repeat-string", "keywords": [ "fast", "fastest", @@ -79,6 +96,16 @@ "string", "times" ], + "license": "MIT", + "main": "index.js", + "name": "repeat-string", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/repeat-string.git" + }, + "scripts": { + "test": "mocha" + }, "verb": { "toc": false, "layout": "default", @@ -100,34 +127,5 @@ "verb" ] }, - "gitHead": "1a95c5d99a02999ccd2cf4663959a18bd2def7b8", - "_id": "repeat-string@1.6.1", - "_shasum": "8dcae470e1c88abc2d600fff4a776286da75e637", - "_from": "repeat-string@>=1.5.2 <2.0.0", - "_npmVersion": "3.10.3", - "_nodeVersion": "6.7.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - } - ], - "dist": { - "shasum": "8dcae470e1c88abc2d600fff4a776286da75e637", - "tarball": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/repeat-string-1.6.1.tgz_1477241638674_0.3764322670176625" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" + "version": "1.6.1" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/package.json index d247d6a..082cd8a 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/package.json @@ -1,40 +1,57 @@ { - "name": "align-text", - "description": "Align the text in a string.", - "version": "0.1.4", - "homepage": "https://github.com/jonschlinkert/align-text", + "_args": [ + [ + "align-text@0.1.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "align-text@0.1.4", + "_id": "align-text@0.1.4", + "_inBundle": false, + "_integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/align-text", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "align-text@0.1.4", + "name": "align-text", + "escapedName": "align-text", + "rawSpec": "0.1.4", + "saveSpec": null, + "fetchSpec": "0.1.4" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align" + ], + "_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "_spec": "0.1.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "git://github.com/jonschlinkert/align-text.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/align-text/issues" }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, "dependencies": { "kind-of": "^3.0.2", "longest": "^1.0.1", "repeat-string": "^1.5.2" }, + "description": "Align the text in a string.", "devDependencies": { "mocha": "*", "should": "*", "word-wrap": "^1.0.3" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/align-text", "keywords": [ "align", "align-center", @@ -49,34 +66,15 @@ "text", "typography" ], - "gitHead": "7f08e823a54c6bda319d875895813537a66a4c5e", - "_id": "align-text@0.1.4", - "_shasum": "0cd90a561093f35d0a99256c22b7069433fad117", - "_from": "align-text@>=0.1.3 <0.2.0", - "_npmVersion": "3.6.0", - "_nodeVersion": "5.5.0", - "_npmUser": { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - } - ], - "dist": { - "shasum": "0cd90a561093f35d0a99256c22b7069433fad117", - "tarball": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + "license": "MIT", + "main": "index.js", + "name": "align-text", + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/align-text.git" }, - "_npmOperationalInternal": { - "host": "packages-9-west.internal.npmjs.com", - "tmp": "tmp/align-text-0.1.4.tgz_1454377856920_0.9624228512402624" + "scripts": { + "test": "mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + "version": "0.1.4" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/lazy-cache/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/lazy-cache/package.json index 6e87e3e..5002623 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/lazy-cache/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/lazy-cache/package.json @@ -1,36 +1,53 @@ { - "name": "lazy-cache", - "description": "Cache requires to be lazy-loaded when needed.", - "version": "1.0.4", - "homepage": "https://github.com/jonschlinkert/lazy-cache", + "_args": [ + [ + "lazy-cache@1.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "lazy-cache@1.0.4", + "_id": "lazy-cache@1.0.4", + "_inBundle": false, + "_integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "_location": "/jade/uglify-js/yargs/cliui/center-align/lazy-cache", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "lazy-cache@1.0.4", + "name": "lazy-cache", + "escapedName": "lazy-cache", + "rawSpec": "1.0.4", + "saveSpec": null, + "fetchSpec": "1.0.4" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/center-align" + ], + "_resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "_spec": "1.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/lazy-cache.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/lazy-cache/issues" }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, + "description": "Cache requires to be lazy-loaded when needed.", "devDependencies": { "ansi-yellow": "^0.1.1", "glob": "^7.0.3", "gulp-format-md": "^0.1.8", "mocha": "^2.4.5" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/lazy-cache", "keywords": [ "cache", "caching", @@ -40,6 +57,16 @@ "require", "requires" ], + "license": "MIT", + "main": "index.js", + "name": "lazy-cache", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/lazy-cache.git" + }, + "scripts": { + "test": "mocha" + }, "verb": { "related": { "list": [ @@ -61,34 +88,5 @@ "verb" ] }, - "gitHead": "d081ffbda147391083a6856fafb1c5d82308f80c", - "_id": "lazy-cache@1.0.4", - "_shasum": "a1d78fc3a50474cb80845d3b3b6e1da49a446e8e", - "_from": "lazy-cache@>=1.0.3 <2.0.0", - "_npmVersion": "3.6.0", - "_nodeVersion": "5.5.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - } - ], - "dist": { - "shasum": "a1d78fc3a50474cb80845d3b3b6e1da49a446e8e", - "tarball": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/lazy-cache-1.0.4.tgz_1461378859142_0.0996799839194864" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz" + "version": "1.0.4" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/package.json index de94468..16a8944 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/package.json @@ -1,38 +1,55 @@ { - "name": "center-align", - "description": "Center-align the text in a string.", - "version": "0.1.3", - "homepage": "https://github.com/jonschlinkert/center-align", + "_args": [ + [ + "center-align@0.1.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "center-align@0.1.3", + "_id": "center-align@0.1.3", + "_inBundle": false, + "_integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "_location": "/jade/uglify-js/yargs/cliui/center-align", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "center-align@0.1.3", + "name": "center-align", + "escapedName": "center-align", + "rawSpec": "0.1.3", + "saveSpec": null, + "fetchSpec": "0.1.3" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui" + ], + "_resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "_spec": "0.1.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/center-align.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/center-align/issues" }, - "license": "MIT", - "files": [ - "index.js", - "utils.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, "dependencies": { "align-text": "^0.1.3", "lazy-cache": "^1.0.3" }, + "description": "Center-align the text in a string.", "devDependencies": { "mocha": "^2.2.0" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js", + "utils.js" + ], + "homepage": "https://github.com/jonschlinkert/center-align", "keywords": [ "align", "align-center", @@ -43,6 +60,16 @@ "text", "typography" ], + "license": "MIT", + "main": "index.js", + "name": "center-align", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/center-align.git" + }, + "scripts": { + "test": "mocha" + }, "verb": { "related": { "description": "", @@ -54,34 +81,5 @@ ] } }, - "gitHead": "5c5fab5012fceaa3e21a00162958c0ed11109419", - "_id": "center-align@0.1.3", - "_shasum": "aa0d32629b6ee972200411cbd4461c907bc2b7ad", - "_from": "center-align@>=0.1.1 <0.2.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.3.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - }, - { - "name": "jonschlinkert", - "email": "github@sellside.com" - } - ], - "dist": { - "shasum": "aa0d32629b6ee972200411cbd4461c907bc2b7ad", - "tarball": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-9-west.internal.npmjs.com", - "tmp": "tmp/center-align-0.1.3.tgz_1454366538829_0.9471865000668913" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz" + "version": "0.1.3" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json index 0b7c5f1..aae8cc6 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer/package.json @@ -1,7 +1,32 @@ { - "name": "is-buffer", - "description": "Determine if an object is a Buffer", - "version": "1.1.5", + "_args": [ + [ + "is-buffer@1.1.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "is-buffer@1.1.5", + "_id": "is-buffer@1.1.5", + "_inBundle": false, + "_integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "_location": "/jade/uglify-js/yargs/cliui/right-align/align-text/kind-of/is-buffer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "is-buffer@1.1.5", + "name": "is-buffer", + "escapedName": "is-buffer", + "rawSpec": "1.1.5", + "saveSpec": null, + "fetchSpec": "1.1.5" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/right-align/align-text/kind-of" + ], + "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "_spec": "1.1.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", @@ -11,11 +36,13 @@ "url": "https://github.com/feross/is-buffer/issues" }, "dependencies": {}, + "description": "Determine if an object is a Buffer", "devDependencies": { "standard": "*", "tape": "^4.0.0", "zuul": "^3.0.0" }, + "homepage": "https://github.com/feross/is-buffer#readme", "keywords": [ "buffer", "buffers", @@ -35,6 +62,7 @@ ], "license": "MIT", "main": "index.js", + "name": "is-buffer", "repository": { "type": "git", "url": "git://github.com/feross/is-buffer.git" @@ -48,31 +76,5 @@ "testling": { "files": "test/*.js" }, - "gitHead": "56dc50e7b271c7d2968269430cbd4f717bbcf6c0", - "homepage": "https://github.com/feross/is-buffer#readme", - "_id": "is-buffer@1.1.5", - "_shasum": "1f3b26ef613b214b88cbca23cc6c01d87961eecc", - "_from": "is-buffer@>=1.1.5 <2.0.0", - "_npmVersion": "3.10.10", - "_nodeVersion": "6.9.5", - "_npmUser": { - "name": "feross", - "email": "feross@feross.org" - }, - "dist": { - "shasum": "1f3b26ef613b214b88cbca23cc6c01d87961eecc", - "tarball": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz" - }, - "maintainers": [ - { - "name": "feross", - "email": "feross@feross.org" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/is-buffer-1.1.5.tgz_1489193465717_0.9356542676687241" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz" + "version": "1.1.5" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/package.json index 9d266c7..7b0d1a6 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/kind-of/package.json @@ -1,12 +1,39 @@ { - "name": "kind-of", - "description": "Get the native type of a value.", - "version": "3.2.2", - "homepage": "https://github.com/jonschlinkert/kind-of", + "_args": [ + [ + "kind-of@3.2.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "kind-of@3.2.2", + "_id": "kind-of@3.2.2", + "_inBundle": false, + "_integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "_location": "/jade/uglify-js/yargs/cliui/right-align/align-text/kind-of", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "kind-of@3.2.2", + "name": "kind-of", + "escapedName": "kind-of", + "rawSpec": "3.2.2", + "saveSpec": null, + "fetchSpec": "3.2.2" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/right-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "_spec": "3.2.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, + "bugs": { + "url": "https://github.com/jonschlinkert/kind-of/issues" + }, "contributors": [ { "name": "David Fox-Powell", @@ -33,28 +60,10 @@ "url": "http://about.me/peterdehaan" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/kind-of.git" - }, - "bugs": { - "url": "https://github.com/jonschlinkert/kind-of/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha", - "prepublish": "browserify -o browser.js -e index.js -s index --bare" - }, "dependencies": { "is-buffer": "^1.1.5" }, + "description": "Get the native type of a value.", "devDependencies": { "ansi-bold": "^0.1.1", "benchmarked": "^1.0.0", @@ -65,6 +74,13 @@ "type-of": "^2.0.1", "typeof": "^1.0.0" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/kind-of", "keywords": [ "arguments", "array", @@ -88,6 +104,17 @@ "typeof", "types" ], + "license": "MIT", + "main": "index.js", + "name": "kind-of", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/kind-of.git" + }, + "scripts": { + "prepublish": "browserify -o browser.js -e index.js -s index --bare", + "test": "mocha" + }, "verb": { "related": { "list": [ @@ -111,34 +138,5 @@ "verb" ] }, - "gitHead": "0ffe67cf12f5396047c1bacf04232b7deeb24063", - "_id": "kind-of@3.2.2", - "_shasum": "31ea21a734bab9bbb0f32466d893aea51e4a3c64", - "_from": "kind-of@>=3.0.2 <4.0.0", - "_npmVersion": "4.5.0", - "_nodeVersion": "7.7.3", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - } - ], - "dist": { - "shasum": "31ea21a734bab9bbb0f32466d893aea51e4a3c64", - "tarball": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/kind-of-3.2.2.tgz_1494958899918_0.23780996026471257" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz" + "version": "3.2.2" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/longest/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/longest/package.json index 648de13..249efec 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/longest/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/longest/package.json @@ -1,37 +1,51 @@ { - "name": "longest", - "description": "Get the longest item in an array.", - "version": "1.0.1", - "homepage": "https://github.com/jonschlinkert/longest", + "_args": [ + [ + "longest@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "longest@1.0.1", + "_id": "longest@1.0.1", + "_inBundle": false, + "_integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "_location": "/jade/uglify-js/yargs/cliui/right-align/align-text/longest", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "longest@1.0.1", + "name": "longest", + "escapedName": "longest", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/right-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "https://github.com/jonschlinkert/longest.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/longest/issues" }, - "license": { - "type": "MIT", - "url": "https://github.com/jonschlinkert/longest/blob/master/LICENSE" - }, - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, + "description": "Get the longest item in an array.", "devDependencies": { "fill-range": "^2.1.0", "mocha": "*" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/longest", "keywords": [ "array", "element", @@ -40,30 +54,18 @@ "length", "longest" ], - "gitHead": "99d9d8257584500aedaea54427a828197c452b0a", - "_id": "longest@1.0.1", - "_shasum": "30a0b2da38f73770e8294a0d22e6625ed77d0097", - "_from": "longest@>=1.0.1 <2.0.0", - "_npmVersion": "2.5.1", - "_nodeVersion": "0.12.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" + "license": { + "type": "MIT", + "url": "https://github.com/jonschlinkert/longest/blob/master/LICENSE" }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - } - ], - "dist": { - "shasum": "30a0b2da38f73770e8294a0d22e6625ed77d0097", - "tarball": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz" + "main": "index.js", + "name": "longest", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/longest.git" + }, + "scripts": { + "test": "mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz" + "version": "1.0.1" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/repeat-string/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/repeat-string/package.json index f1ed51f..9c72c5e 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/repeat-string/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/node_modules/repeat-string/package.json @@ -1,12 +1,39 @@ { - "name": "repeat-string", - "description": "Repeat the given string n times. Fastest implementation for repeating a string.", - "version": "1.6.1", - "homepage": "https://github.com/jonschlinkert/repeat-string", + "_args": [ + [ + "repeat-string@1.6.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "repeat-string@1.6.1", + "_id": "repeat-string@1.6.1", + "_inBundle": false, + "_integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "_location": "/jade/uglify-js/yargs/cliui/right-align/align-text/repeat-string", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "repeat-string@1.6.1", + "name": "repeat-string", + "escapedName": "repeat-string", + "rawSpec": "1.6.1", + "saveSpec": null, + "fetchSpec": "1.6.1" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/right-align/align-text" + ], + "_resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "_spec": "1.6.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "http://github.com/jonschlinkert" }, + "bugs": { + "url": "https://github.com/jonschlinkert/repeat-string/issues" + }, "contributors": [ { "name": "Brian Woodward", @@ -34,24 +61,7 @@ "url": "wooorm.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/jonschlinkert/repeat-string.git" - }, - "bugs": { - "url": "https://github.com/jonschlinkert/repeat-string/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10" - }, - "scripts": { - "test": "mocha" - }, + "description": "Repeat the given string n times. Fastest implementation for repeating a string.", "devDependencies": { "ansi-cyan": "^0.1.1", "benchmarked": "^0.2.5", @@ -62,6 +72,13 @@ "text-table": "^0.2.0", "yargs-parser": "^4.0.2" }, + "engines": { + "node": ">=0.10" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/repeat-string", "keywords": [ "fast", "fastest", @@ -79,6 +96,16 @@ "string", "times" ], + "license": "MIT", + "main": "index.js", + "name": "repeat-string", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/repeat-string.git" + }, + "scripts": { + "test": "mocha" + }, "verb": { "toc": false, "layout": "default", @@ -100,34 +127,5 @@ "verb" ] }, - "gitHead": "1a95c5d99a02999ccd2cf4663959a18bd2def7b8", - "_id": "repeat-string@1.6.1", - "_shasum": "8dcae470e1c88abc2d600fff4a776286da75e637", - "_from": "repeat-string@>=1.5.2 <2.0.0", - "_npmVersion": "3.10.3", - "_nodeVersion": "6.7.0", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "doowb", - "email": "brian.woodward@gmail.com" - } - ], - "dist": { - "shasum": "8dcae470e1c88abc2d600fff4a776286da75e637", - "tarball": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/repeat-string-1.6.1.tgz_1477241638674_0.3764322670176625" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" + "version": "1.6.1" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/package.json index d247d6a..6ca82bf 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/node_modules/align-text/package.json @@ -1,40 +1,57 @@ { - "name": "align-text", - "description": "Align the text in a string.", - "version": "0.1.4", - "homepage": "https://github.com/jonschlinkert/align-text", + "_args": [ + [ + "align-text@0.1.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "align-text@0.1.4", + "_id": "align-text@0.1.4", + "_inBundle": false, + "_integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "_location": "/jade/uglify-js/yargs/cliui/right-align/align-text", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "align-text@0.1.4", + "name": "align-text", + "escapedName": "align-text", + "rawSpec": "0.1.4", + "saveSpec": null, + "fetchSpec": "0.1.4" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui/right-align" + ], + "_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "_spec": "0.1.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "git://github.com/jonschlinkert/align-text.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/align-text/issues" }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, "dependencies": { "kind-of": "^3.0.2", "longest": "^1.0.1", "repeat-string": "^1.5.2" }, + "description": "Align the text in a string.", "devDependencies": { "mocha": "*", "should": "*", "word-wrap": "^1.0.3" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/align-text", "keywords": [ "align", "align-center", @@ -49,34 +66,15 @@ "text", "typography" ], - "gitHead": "7f08e823a54c6bda319d875895813537a66a4c5e", - "_id": "align-text@0.1.4", - "_shasum": "0cd90a561093f35d0a99256c22b7069433fad117", - "_from": "align-text@>=0.1.3 <0.2.0", - "_npmVersion": "3.6.0", - "_nodeVersion": "5.5.0", - "_npmUser": { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - { - "name": "shinnn", - "email": "snnskwtnb@gmail.com" - } - ], - "dist": { - "shasum": "0cd90a561093f35d0a99256c22b7069433fad117", - "tarball": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + "license": "MIT", + "main": "index.js", + "name": "align-text", + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/align-text.git" }, - "_npmOperationalInternal": { - "host": "packages-9-west.internal.npmjs.com", - "tmp": "tmp/align-text-0.1.4.tgz_1454377856920_0.9624228512402624" + "scripts": { + "test": "mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + "version": "0.1.4" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/package.json index 3122113..b08031c 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/right-align/package.json @@ -1,37 +1,54 @@ { - "name": "right-align", - "description": "Right-align the text in a string.", - "version": "0.1.3", - "homepage": "https://github.com/jonschlinkert/right-align", + "_args": [ + [ + "right-align@0.1.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "right-align@0.1.3", + "_id": "right-align@0.1.3", + "_inBundle": false, + "_integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "_location": "/jade/uglify-js/yargs/cliui/right-align", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "right-align@0.1.3", + "name": "right-align", + "escapedName": "right-align", + "rawSpec": "0.1.3", + "saveSpec": null, + "fetchSpec": "0.1.3" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui" + ], + "_resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "_spec": "0.1.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "git://github.com/jonschlinkert/right-align.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/right-align/issues" }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, "dependencies": { "align-text": "^0.1.1" }, + "description": "Right-align the text in a string.", "devDependencies": { "mocha": "*", "should": "*" }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/jonschlinkert/right-align", "keywords": [ "align", "align-center", @@ -42,26 +59,15 @@ "text", "typography" ], - "gitHead": "23ee38d6eedbcbfed241ace6587ce5730684dd18", - "_id": "right-align@0.1.3", - "_shasum": "61339b722fe6a3515689210d24e14c96148613ef", - "_from": "right-align@>=0.1.1 <0.2.0", - "_npmVersion": "2.10.1", - "_nodeVersion": "0.12.4", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" + "license": "MIT", + "main": "index.js", + "name": "right-align", + "repository": { + "type": "git", + "url": "git://github.com/jonschlinkert/right-align.git" }, - "maintainers": [ - { - "name": "jonschlinkert", - "email": "github@sellside.com" - } - ], - "dist": { - "shasum": "61339b722fe6a3515689210d24e14c96148613ef", - "tarball": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz" + "scripts": { + "test": "mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz" + "version": "0.1.3" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/wordwrap/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/wordwrap/package.json index e8f689b..8bb68a3 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/wordwrap/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/wordwrap/package.json @@ -1,12 +1,53 @@ { - "name": "wordwrap", + "_args": [ + [ + "wordwrap@0.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "wordwrap@0.0.2", + "_id": "wordwrap@0.0.2", + "_inBundle": false, + "_integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "_location": "/jade/uglify-js/yargs/cliui/wordwrap", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "wordwrap@0.0.2", + "name": "wordwrap", + "escapedName": "wordwrap", + "rawSpec": "0.0.2", + "saveSpec": null, + "fetchSpec": "0.0.2" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs/cliui" + ], + "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "_spec": "0.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/node-wordwrap/issues" + }, "description": "Wrap those words. Show them at what columns to start and stop.", - "version": "0.0.2", - "repository": { - "type": "git", - "url": "git://github.com/substack/node-wordwrap.git" + "devDependencies": { + "expresso": "=0.7.x" }, - "main": "./index.js", + "directories": { + "lib": ".", + "example": "example", + "test": "test" + }, + "engines": { + "node": ">=0.4.0" + }, + "homepage": "https://github.com/substack/node-wordwrap#readme", "keywords": [ "word", "wrap", @@ -14,43 +55,15 @@ "format", "column" ], - "directories": { - "lib": ".", - "example": "example", - "test": "test" + "license": "MIT/X11", + "main": "./index.js", + "name": "wordwrap", + "repository": { + "type": "git", + "url": "git://github.com/substack/node-wordwrap.git" }, "scripts": { "test": "expresso" }, - "devDependencies": { - "expresso": "=0.7.x" - }, - "engines": { - "node": ">=0.4.0" - }, - "license": "MIT/X11", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "_id": "wordwrap@0.0.2", - "dependencies": {}, - "_engineSupported": true, - "_npmVersion": "1.0.10", - "_nodeVersion": "v0.5.0-pre", - "_defaultsLoaded": true, - "dist": { - "shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f", - "tarball": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "_shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f", - "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "_from": "wordwrap@0.0.2" + "version": "0.0.2" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/package.json index 65cd3de..615d41f 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/package.json @@ -1,14 +1,38 @@ { - "name": "cliui", - "version": "2.1.0", - "description": "easily create complex multi-column command-line-interfaces", - "main": "index.js", - "scripts": { - "test": "standard && mocha --check-leaks --ui exports --require patched-blanket -R mocoverage" + "_args": [ + [ + "cliui@2.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "cliui@2.1.0", + "_id": "cliui@2.1.0", + "_inBundle": false, + "_integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "_location": "/jade/uglify-js/yargs/cliui", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "cliui@2.1.0", + "name": "cliui", + "escapedName": "cliui", + "rawSpec": "2.1.0", + "saveSpec": null, + "fetchSpec": "2.1.0" }, - "repository": { - "type": "git", - "url": "http://github.com/bcoe/cliui.git" + "_requiredBy": [ + "/jade/uglify-js/yargs" + ], + "_resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "_spec": "2.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "Ben Coe", + "email": "ben@npmjs.com" + }, + "bugs": { + "url": "https://github.com/bcoe/cliui/issues" }, "config": { "blanket": { @@ -22,33 +46,12 @@ "output-reporter": "spec" } }, - "standard": { - "ignore": [ - "**/example/**" - ], - "globals": [ - "it" - ] - }, - "keywords": [ - "cli", - "command-line", - "layout", - "design", - "console", - "wrap", - "table" - ], - "author": { - "name": "Ben Coe", - "email": "ben@npmjs.com" - }, - "license": "ISC", "dependencies": { "center-align": "^0.1.1", "right-align": "^0.1.1", "wordwrap": "0.0.2" }, + "description": "easily create complex multi-column command-line-interfaces", "devDependencies": { "blanket": "^1.1.6", "chai": "^2.2.0", @@ -59,30 +62,33 @@ "patched-blanket": "^1.0.1", "standard": "^3.6.1" }, - "gitHead": "5d6ce466b144db62abefc4b2252c8aa70a741695", - "bugs": { - "url": "https://github.com/bcoe/cliui/issues" + "homepage": "https://github.com/bcoe/cliui#readme", + "keywords": [ + "cli", + "command-line", + "layout", + "design", + "console", + "wrap", + "table" + ], + "license": "ISC", + "main": "index.js", + "name": "cliui", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/bcoe/cliui.git" }, - "homepage": "https://github.com/bcoe/cliui", - "_id": "cliui@2.1.0", - "_shasum": "4b475760ff80264c762c3a1719032e91c7fea0d1", - "_from": "cliui@>=2.1.0 <3.0.0", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.10.36", - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" + "scripts": { + "test": "standard && mocha --check-leaks --ui exports --require patched-blanket -R mocoverage" }, - "dist": { - "shasum": "4b475760ff80264c762c3a1719032e91c7fea0d1", - "tarball": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz" + "standard": { + "ignore": [ + "**/example/**" + ], + "globals": [ + "it" + ] }, - "maintainers": [ - { - "name": "bcoe", - "email": "ben@npmjs.com" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz" + "version": "2.1.0" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/decamelize/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/decamelize/package.json index 4355a9d..61d2f77 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/decamelize/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/decamelize/package.json @@ -1,26 +1,52 @@ { - "name": "decamelize", - "version": "1.2.0", - "description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/decamelize.git" + "_args": [ + [ + "decamelize@1.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "decamelize@1.2.0", + "_id": "decamelize@1.2.0", + "_inBundle": false, + "_integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "_location": "/jade/uglify-js/yargs/decamelize", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "decamelize@1.2.0", + "name": "decamelize", + "escapedName": "decamelize", + "rawSpec": "1.2.0", + "saveSpec": null, + "fetchSpec": "1.2.0" }, + "_requiredBy": [ + "/jade/uglify-js/yargs" + ], + "_resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "_spec": "1.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, + "bugs": { + "url": "https://github.com/sindresorhus/decamelize/issues" + }, + "description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow", + "devDependencies": { + "ava": "*", + "xo": "*" + }, "engines": { "node": ">=0.10.0" }, - "scripts": { - "test": "xo && ava" - }, "files": [ "index.js" ], + "homepage": "https://github.com/sindresorhus/decamelize#readme", "keywords": [ "decamelize", "decamelcase", @@ -34,38 +60,14 @@ "text", "convert" ], - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "gitHead": "95980ab6fb44c40eaca7792bdf93aff7c210c805", - "bugs": { - "url": "https://github.com/sindresorhus/decamelize/issues" - }, - "homepage": "https://github.com/sindresorhus/decamelize#readme", - "_id": "decamelize@1.2.0", - "_shasum": "f6534d15148269b20352e7bee26f501f9a191290", - "_from": "decamelize@>=1.0.0 <2.0.0", - "_npmVersion": "3.8.0", - "_nodeVersion": "4.3.0", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "dist": { - "shasum": "f6534d15148269b20352e7bee26f501f9a191290", - "tarball": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" + "license": "MIT", + "name": "decamelize", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/decamelize.git" }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/decamelize-1.2.0.tgz_1457167749082_0.9810893186368048" + "scripts": { + "test": "xo && ava" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" + "version": "1.2.0" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/window-size/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/window-size/package.json index f23288f..7bf5680 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/window-size/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/node_modules/window-size/package.json @@ -1,53 +1,61 @@ { - "name": "window-size", - "description": "Reliable way to to get the height and width of the terminal/console in a node.js environment.", - "version": "0.1.0", - "homepage": "https://github.com/jonschlinkert/window-size", + "_args": [ + [ + "window-size@0.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "window-size@0.1.0", + "_id": "window-size@0.1.0", + "_inBundle": false, + "_integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "_location": "/jade/uglify-js/yargs/window-size", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "window-size@0.1.0", + "name": "window-size", + "escapedName": "window-size", + "rawSpec": "0.1.0", + "saveSpec": null, + "fetchSpec": "0.1.0" + }, + "_requiredBy": [ + "/jade/uglify-js/yargs" + ], + "_resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "_spec": "0.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jon Schlinkert", "url": "https://github.com/jonschlinkert" }, - "repository": { - "type": "git", - "url": "https://github.com/jonschlinkert/window-size.git" - }, "bugs": { "url": "https://github.com/jonschlinkert/window-size/issues" }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/jonschlinkert/window-size/blob/master/LICENSE-MIT" - } - ], - "main": "index.js", + "description": "Reliable way to to get the height and width of the terminal/console in a node.js environment.", "engines": { "node": ">= 0.8.0" }, + "homepage": "https://github.com/jonschlinkert/window-size", "keywords": [ "window", "console", "terminal", "tty" ], - "_id": "window-size@0.1.0", - "dist": { - "shasum": "5438cd2ea93b202efa3a19fe8887aee7c94f9c9d", - "tarball": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz" - }, - "_from": "window-size@0.1.0", - "_npmVersion": "1.3.24", - "_npmUser": { - "name": "jonschlinkert", - "email": "github@sellside.com" - }, - "maintainers": [ + "licenses": [ { - "name": "jonschlinkert", - "email": "github@sellside.com" + "type": "MIT", + "url": "https://github.com/jonschlinkert/window-size/blob/master/LICENSE-MIT" } ], - "directories": {}, - "_shasum": "5438cd2ea93b202efa3a19fe8887aee7c94f9c9d", - "_resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz" + "main": "index.js", + "name": "window-size", + "repository": { + "type": "git", + "url": "git+https://github.com/jonschlinkert/window-size.git" + }, + "version": "0.1.0" } diff --git a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/package.json b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/package.json index 4a233c1..05d0d25 100644 --- a/node_modules/jade/node_modules/uglify-js/node_modules/yargs/package.json +++ b/node_modules/jade/node_modules/uglify-js/node_modules/yargs/package.json @@ -1,58 +1,40 @@ { - "name": "yargs", - "version": "3.10.0", - "description": "Light-weight option parsing with an argv hash. No optstrings attached.", - "main": "./index.js", - "files": [ - "index.js", - "lib", - "completion.sh.hbs", - "LICENSE" - ], - "dependencies": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" - }, - "devDependencies": { - "chai": "^2.2.0", - "coveralls": "^2.11.2", - "hashish": "0.0.4", - "mocha": "^2.2.1", - "nyc": "^2.2.1", - "standard": "^3.11.1" - }, - "scripts": { - "test": "standard && nyc mocha --check-leaks && nyc report", - "coverage": "nyc report --reporter=text-lcov | coveralls" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/bcoe/yargs.git" - }, - "standard": { - "ignore": [ - "**/example/**" - ], - "globals": [ - "it" + "_args": [ + [ + "yargs@3.10.0", + "/Users/Bryan1/Projects/WebStormProjects/site" ] + ], + "_from": "yargs@3.10.0", + "_id": "yargs@3.10.0", + "_inBundle": false, + "_integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "_location": "/jade/uglify-js/yargs", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "yargs@3.10.0", + "name": "yargs", + "escapedName": "yargs", + "rawSpec": "3.10.0", + "saveSpec": null, + "fetchSpec": "3.10.0" }, - "keywords": [ - "argument", - "args", - "option", - "parser", - "parsing", - "cli", - "command" + "_requiredBy": [ + "/jade/uglify-js" ], + "_resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "_spec": "3.10.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Alex Ford", "email": "Alex.Ford@CodeTunnel.com", "url": "http://CodeTunnel.com" }, + "bugs": { + "url": "https://github.com/bcoe/yargs/issues" + }, "contributors": [ { "name": "Benjamin Coe", @@ -78,42 +60,58 @@ "url": "https://github.com/linclark" } ], - "license": "MIT", + "dependencies": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + }, + "description": "Light-weight option parsing with an argv hash. No optstrings attached.", + "devDependencies": { + "chai": "^2.2.0", + "coveralls": "^2.11.2", + "hashish": "0.0.4", + "mocha": "^2.2.1", + "nyc": "^2.2.1", + "standard": "^3.11.1" + }, "engine": { "node": ">=0.4" }, - "gitHead": "491e6b10e46485a31504e6a1ef21450dff425030", - "bugs": { - "url": "https://github.com/bcoe/yargs/issues" - }, + "files": [ + "index.js", + "lib", + "completion.sh.hbs", + "LICENSE" + ], "homepage": "https://github.com/bcoe/yargs#readme", - "_id": "yargs@3.10.0", - "_shasum": "f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1", - "_from": "yargs@>=3.10.0 <3.11.0", - "_npmVersion": "2.9.0", - "_nodeVersion": "2.0.2", - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" + "keywords": [ + "argument", + "args", + "option", + "parser", + "parsing", + "cli", + "command" + ], + "license": "MIT", + "main": "./index.js", + "name": "yargs", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/bcoe/yargs.git" }, - "dist": { - "shasum": "f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1", - "tarball": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" + "scripts": { + "coverage": "nyc report --reporter=text-lcov | coveralls", + "test": "standard && nyc mocha --check-leaks && nyc report" }, - "maintainers": [ - { - "name": "chevex", - "email": "alex.ford@codetunnel.com" - }, - { - "name": "bcoe", - "email": "bencoe@gmail.com" - }, - { - "name": "nylen", - "email": "jnylen@gmail.com" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" + "standard": { + "ignore": [ + "**/example/**" + ], + "globals": [ + "it" + ] + }, + "version": "3.10.0" } diff --git a/node_modules/jade/node_modules/uglify-js/package.json b/node_modules/jade/node_modules/uglify-js/package.json index d9aaae4..50db7f0 100644 --- a/node_modules/jade/node_modules/uglify-js/package.json +++ b/node_modules/jade/node_modules/uglify-js/package.json @@ -1,92 +1,93 @@ { - "name": "uglify-js", - "description": "JavaScript parser, mangler/compressor and beautifier toolkit", - "homepage": "http://lisperator.net/uglifyjs", + "_args": [ + [ + "uglify-js@2.8.27", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "uglify-js@2.8.27", + "_id": "uglify-js@2.8.27", + "_inBundle": false, + "_integrity": "sha1-R3h/kSsPJC5bmENDvo416V9pTJw=", + "_location": "/jade/uglify-js", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "uglify-js@2.8.27", + "name": "uglify-js", + "escapedName": "uglify-js", + "rawSpec": "2.8.27", + "saveSpec": null, + "fetchSpec": "2.8.27" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.27.tgz", + "_spec": "2.8.27", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Mihai Bazon", "email": "mihai.bazon@gmail.com", "url": "http://lisperator.net/" }, - "license": "BSD-2-Clause", - "version": "2.8.27", - "engines": { - "node": ">=0.8.0" + "bin": { + "uglifyjs": "bin/uglifyjs" }, - "maintainers": [ - { - "name": "alexlamsl", - "email": "alexlamsl@gmail.com" - }, - { - "name": "mishoo", - "email": "mihai.bazon@gmail.com" - }, - { - "name": "rvanvelzen1", - "email": "rvanvelzen1@gmail.com" - } - ], - "repository": { - "type": "git", - "url": "git+https://github.com/mishoo/UglifyJS2.git" + "browserify": { + "transform": [ + "uglify-to-browserify" + ] }, "bugs": { "url": "https://github.com/mishoo/UglifyJS2/issues" }, - "main": "tools/node.js", - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "files": [ - "bin", - "lib", - "tools", - "LICENSE" - ], "dependencies": { "source-map": "~0.5.1", - "yargs": "~3.10.0", - "uglify-to-browserify": "~1.0.0" + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" }, + "description": "JavaScript parser, mangler/compressor and beautifier toolkit", "devDependencies": { "acorn": "~5.0.3", "mocha": "~2.3.4" }, - "optionalDependencies": { - "uglify-to-browserify": "~1.0.0" - }, - "browserify": { - "transform": [ - "uglify-to-browserify" - ] - }, - "scripts": { - "test": "node test/run-tests.js" + "engines": { + "node": ">=0.8.0" }, + "files": [ + "bin", + "lib", + "tools", + "LICENSE" + ], + "homepage": "http://lisperator.net/uglifyjs", "keywords": [ "uglify", "uglify-js", "minify", "minifier" ], - "gitHead": "75e2748b1607c7d524c9d9faa76927bb8691f929", - "_id": "uglify-js@2.8.27", - "_shasum": "47787f912b0f242e5b984343be8e35e95f694c9c", - "_from": "uglify-js@>=2.4.19 <3.0.0", - "_npmVersion": "4.2.0", - "_nodeVersion": "7.10.0", - "_npmUser": { - "name": "alexlamsl", - "email": "alexlamsl@gmail.com" + "license": "BSD-2-Clause", + "main": "tools/node.js", + "maintainers": [ + { + "name": "Mihai Bazon", + "email": "mihai.bazon@gmail.com", + "url": "http://lisperator.net/" + } + ], + "name": "uglify-js", + "optionalDependencies": { + "uglify-to-browserify": "~1.0.0" }, - "dist": { - "shasum": "47787f912b0f242e5b984343be8e35e95f694c9c", - "tarball": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.27.tgz" + "repository": { + "type": "git", + "url": "git+https://github.com/mishoo/UglifyJS2.git" }, - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/uglify-js-2.8.27.tgz_1495191752952_0.8517098107840866" + "scripts": { + "test": "node test/run-tests.js" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.27.tgz" + "version": "2.8.27" } diff --git a/node_modules/jade/node_modules/void-elements/package.json b/node_modules/jade/node_modules/void-elements/package.json index b8306dd..e0bf8e3 100644 --- a/node_modules/jade/node_modules/void-elements/package.json +++ b/node_modules/jade/node_modules/void-elements/package.json @@ -1,57 +1,61 @@ { - "name": "void-elements", - "version": "2.0.1", - "description": "Array of \"void elements\" defined by the HTML specification.", - "main": "index.js", - "scripts": { - "test": "node test", - "prepublish": "node pre-publish.js > index.js" - }, - "keywords": [ - "html", - "void", - "elements" + "_args": [ + [ + "void-elements@2.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "git://github.com/hemanth/void-elements" - }, + "_from": "void-elements@2.0.1", + "_id": "void-elements@2.0.1", + "_inBundle": false, + "_integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "_location": "/jade/void-elements", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "void-elements@2.0.1", + "name": "void-elements", + "escapedName": "void-elements", + "rawSpec": "2.0.1", + "saveSpec": null, + "fetchSpec": "2.0.1" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "_spec": "2.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "hemanth.hm" }, - "engines": { - "node": ">=0.10.0" - }, - "license": "MIT", "bugs": { "url": "https://github.com/hemanth/void-elements/issues" }, - "homepage": "https://github.com/hemanth/void-elements", + "description": "Array of \"void elements\" defined by the HTML specification.", "devDependencies": { "cheerio": "^0.18.0" }, - "_id": "void-elements@2.0.1", - "dist": { - "shasum": "c066afb582bb1cb4128d60ea92392e94d5e9dbec", - "tarball": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz" - }, - "_from": "void-elements@>=2.0.1 <2.1.0", - "_npmVersion": "1.3.11", - "_npmUser": { - "name": "hemanth", - "email": "hemanth.hm@gmail.com" + "engines": { + "node": ">=0.10.0" }, - "maintainers": [ - { - "name": "hemanth", - "email": "hemanth.hm@gmail.com" - }, - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } + "homepage": "https://github.com/hemanth/void-elements", + "keywords": [ + "html", + "void", + "elements" ], - "directories": {}, - "_shasum": "c066afb582bb1cb4128d60ea92392e94d5e9dbec", - "_resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz" + "license": "MIT", + "main": "index.js", + "name": "void-elements", + "repository": { + "type": "git", + "url": "git+https://github.com/hemanth/void-elements.git" + }, + "scripts": { + "prepublish": "node pre-publish.js > index.js", + "test": "node test" + }, + "version": "2.0.1" } diff --git a/node_modules/jade/node_modules/with/node_modules/.bin/acorn b/node_modules/jade/node_modules/with/node_modules/.bin/acorn deleted file mode 100755 index 76d8178..0000000 --- a/node_modules/jade/node_modules/with/node_modules/.bin/acorn +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env node - -var path = require("path"); -var fs = require("fs"); -var acorn = require("../dist/acorn.js"); - -var infile, parsed, tokens, options = {}, silent = false, compact = false, tokenize = false; - -function help(status) { - var print = (status == 0) ? console.log : console.error; - print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]"); - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--help] [--] infile"); - process.exit(status); -} - -for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i]; - if (arg[0] != "-" && !infile) infile = arg; - else if (arg == "--" && !infile && i + 2 == process.argv.length) infile = process.argv[++i]; - else if (arg == "--ecma3") options.ecmaVersion = 3; - else if (arg == "--ecma5") options.ecmaVersion = 5; - else if (arg == "--ecma6") options.ecmaVersion = 6; - else if (arg == "--ecma7") options.ecmaVersion = 7; - else if (arg == "--locations") options.locations = true; - else if (arg == "--allow-hash-bang") options.allowHashBang = true; - else if (arg == "--silent") silent = true; - else if (arg == "--compact") compact = true; - else if (arg == "--help") help(0); - else if (arg == "--tokenize") tokenize = true; - else help(1); -} - -try { - var code = fs.readFileSync(infile, "utf8"); - - if (!tokenize) - parsed = acorn.parse(code, options); - else { - var get = acorn.tokenize(code, options); - tokens = []; - while (true) { - var token = get(); - tokens.push(token); - if (token.type.type == "eof") - break; - } - } -} catch(e) { - console.log(e.message); - process.exit(1); -} - -if (!silent) - console.log(JSON.stringify(tokenize ? tokens : parsed, null, compact ? null : 2)); diff --git a/node_modules/jade/node_modules/with/node_modules/.bin/acorn b/node_modules/jade/node_modules/with/node_modules/.bin/acorn new file mode 120000 index 0000000..cf76760 --- /dev/null +++ b/node_modules/jade/node_modules/with/node_modules/.bin/acorn @@ -0,0 +1 @@ +../acorn/bin/acorn \ No newline at end of file diff --git a/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn b/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn deleted file mode 100755 index db07909..0000000 --- a/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } } - -var _path = require("path"); - -var _fs = require("fs"); - -var _distAcornJs = require("../dist/acorn.js"); - -var acorn = _interopRequireWildcard(_distAcornJs); - -var infile = undefined, - forceFile = undefined, - silent = false, - compact = false, - tokenize = false; -var options = {}; - -function help(status) { - var print = status == 0 ? console.log : console.error; - print("usage: " + (0, _path.basename)(process.argv[1]) + " [--ecma3|--ecma5|--ecma6]"); - print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]"); - process.exit(status); -} - -for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i]; - if ((arg == "-" || arg[0] != "-") && !infile) infile = arg;else if (arg == "--" && !infile && i + 2 == process.argv.length) forceFile = infile = process.argv[++i];else if (arg == "--ecma3") options.ecmaVersion = 3;else if (arg == "--ecma5") options.ecmaVersion = 5;else if (arg == "--ecma6") options.ecmaVersion = 6;else if (arg == "--locations") options.locations = true;else if (arg == "--allow-hash-bang") options.allowHashBang = true;else if (arg == "--silent") silent = true;else if (arg == "--compact") compact = true;else if (arg == "--help") help(0);else if (arg == "--tokenize") tokenize = true;else if (arg == "--module") options.sourceType = 'module';else help(1); -} - -function run(code) { - var result = undefined; - if (!tokenize) { - try { - result = acorn.parse(code, options); - } catch (e) { - console.error(e.message);process.exit(1); - } - } else { - result = []; - var tokenizer = acorn.tokenizer(code, options), - token = undefined; - while (true) { - try { - token = tokenizer.getToken(); - } catch (e) { - console.error(e.message);process.exit(1); - } - result.push(token); - if (token.type == acorn.tokTypes.eof) break; - } - } - if (!silent) console.log(JSON.stringify(result, null, compact ? null : 2)); -} - -if (forceFile || infile && infile != "-") { - run((0, _fs.readFileSync)(infile, "utf8")); -} else { - (function () { - var code = ""; - process.stdin.resume(); - process.stdin.on("data", function (chunk) { - return code += chunk; - }); - process.stdin.on("end", function () { - return run(code); - }); - })(); -} \ No newline at end of file diff --git a/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn b/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn new file mode 120000 index 0000000..cf76760 --- /dev/null +++ b/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/.bin/acorn @@ -0,0 +1 @@ +../acorn/bin/acorn \ No newline at end of file diff --git a/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/package.json b/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/package.json index 5579068..8f4705b 100644 --- a/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/package.json +++ b/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/package.json @@ -1,40 +1,37 @@ { - "name": "acorn", - "description": "ECMAScript parser", - "homepage": "https://github.com/ternjs/acorn", - "main": "dist/acorn.js", - "version": "2.7.0", - "engines": { - "node": ">=0.4.0" - }, - "maintainers": [ - { - "name": "marijn", - "email": "marijnh@gmail.com" - }, - { - "name": "rreverser", - "email": "me@rreverser.com" - } + "_args": [ + [ + "acorn@2.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "git+https://github.com/ternjs/acorn.git" - }, - "license": "MIT", - "scripts": { - "prepublish": "node bin/build-acorn.js", - "test": "node test/run.js" + "_from": "acorn@2.7.0", + "_id": "acorn@2.7.0", + "_inBundle": false, + "_integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=", + "_location": "/jade/with/acorn-globals/acorn", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "acorn@2.7.0", + "name": "acorn", + "escapedName": "acorn", + "rawSpec": "2.7.0", + "saveSpec": null, + "fetchSpec": "2.7.0" }, + "_requiredBy": [ + "/jade/with/acorn-globals" + ], + "_resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", + "_spec": "2.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bin": { "acorn": "./bin/acorn" }, - "devDependencies": { - "babel-core": "^5.6.15", - "babelify": "^6.1.2", - "browserify": "^10.2.4", - "browserify-derequire": "^0.9.4", - "unicode-7.0.0": "~0.1.5" + "bugs": { + "url": "https://github.com/ternjs/acorn/issues" }, "contributors": [ { @@ -164,24 +161,40 @@ "name": "zsjforcn" } ], - "gitHead": "1405436064bff087f14af55a763396aa5c0ca148", - "bugs": { - "url": "https://github.com/ternjs/acorn/issues" + "description": "ECMAScript parser", + "devDependencies": { + "babel-core": "^5.6.15", + "babelify": "^6.1.2", + "browserify": "^10.2.4", + "browserify-derequire": "^0.9.4", + "unicode-7.0.0": "~0.1.5" }, - "_id": "acorn@2.7.0", - "_shasum": "ab6e7d9d886aaca8b085bc3312b79a198433f0e7", - "_from": "acorn@>=2.1.0 <3.0.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "marijn", - "email": "marijnh@gmail.com" + "engines": { + "node": ">=0.4.0" + }, + "homepage": "https://github.com/ternjs/acorn", + "license": "MIT", + "main": "dist/acorn.js", + "maintainers": [ + { + "name": "Marijn Haverbeke", + "email": "marijnh@gmail.com", + "url": "http://marijnhaverbeke.nl" + }, + { + "name": "Ingvar Stepanyan", + "email": "me@rreverser.com", + "url": "http://rreverser.com/" + } + ], + "name": "acorn", + "repository": { + "type": "git", + "url": "git+https://github.com/ternjs/acorn.git" }, - "dist": { - "shasum": "ab6e7d9d886aaca8b085bc3312b79a198433f0e7", - "tarball": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz" + "scripts": { + "prepublish": "node bin/build-acorn.js", + "test": "node test/run.js" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.7.0" } diff --git a/node_modules/jade/node_modules/with/node_modules/acorn-globals/package.json b/node_modules/jade/node_modules/with/node_modules/acorn-globals/package.json index 0977ab0..e2e3006 100644 --- a/node_modules/jade/node_modules/with/node_modules/acorn-globals/package.json +++ b/node_modules/jade/node_modules/with/node_modules/acorn-globals/package.json @@ -1,7 +1,50 @@ { - "name": "acorn-globals", - "version": "1.0.9", + "_args": [ + [ + "acorn-globals@1.0.9", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "acorn-globals@1.0.9", + "_id": "acorn-globals@1.0.9", + "_inBundle": false, + "_integrity": "sha1-VbtemGkVB7dFedBRNBMhfDgMVM8=", + "_location": "/jade/with/acorn-globals", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "acorn-globals@1.0.9", + "name": "acorn-globals", + "escapedName": "acorn-globals", + "rawSpec": "1.0.9", + "saveSpec": null, + "fetchSpec": "1.0.9" + }, + "_requiredBy": [ + "/jade/with" + ], + "_resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz", + "_spec": "1.0.9", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "ForbesLindesay" + }, + "bugs": { + "url": "https://github.com/ForbesLindesay/acorn-globals/issues" + }, + "dependencies": { + "acorn": "^2.1.0" + }, "description": "Detect global variables in JavaScript using acorn", + "devDependencies": { + "testit": "^2.0.2" + }, + "files": [ + "index.js", + "LICENSE" + ], + "homepage": "https://github.com/ForbesLindesay/acorn-globals#readme", "keywords": [ "ast", "variable", @@ -12,55 +55,14 @@ "global", "implicit" ], - "files": [ - "index.js", - "LICENSE" - ], - "dependencies": { - "acorn": "^2.1.0" - }, - "devDependencies": { - "testit": "^2.0.2" - }, - "scripts": { - "test": "node test" - }, + "license": "MIT", + "name": "acorn-globals", "repository": { "type": "git", - "url": "https://github.com/ForbesLindesay/acorn-globals.git" + "url": "git+https://github.com/ForbesLindesay/acorn-globals.git" }, - "author": { - "name": "ForbesLindesay" - }, - "license": "MIT", - "gitHead": "808cab09764b63679138b012602ca1bb51657f97", - "bugs": { - "url": "https://github.com/ForbesLindesay/acorn-globals/issues" - }, - "homepage": "https://github.com/ForbesLindesay/acorn-globals", - "_id": "acorn-globals@1.0.9", - "_shasum": "55bb5e98691507b74579d0513413217c380c54cf", - "_from": "acorn-globals@>=1.0.3 <2.0.0", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.6.2", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - "dist": { - "shasum": "55bb5e98691507b74579d0513413217c380c54cf", - "tarball": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz" + "scripts": { + "test": "node test" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "timothygu", - "email": "timothygu99@gmail.com" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz" + "version": "1.0.9" } diff --git a/node_modules/jade/node_modules/with/node_modules/acorn/package.json b/node_modules/jade/node_modules/with/node_modules/acorn/package.json index 21db95a..cafddbd 100644 --- a/node_modules/jade/node_modules/with/node_modules/acorn/package.json +++ b/node_modules/jade/node_modules/with/node_modules/acorn/package.json @@ -1,35 +1,37 @@ { - "name": "acorn", - "description": "ECMAScript parser", - "homepage": "https://github.com/marijnh/acorn", - "main": "dist/acorn.js", - "version": "1.2.2", - "engines": { - "node": ">=0.4.0" - }, - "maintainers": [ - { - "name": "marijn", - "email": "marijnh@gmail.com" - } + "_args": [ + [ + "acorn@1.2.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "https://github.com/marijnh/acorn.git" - }, - "license": "MIT", - "scripts": { - "test": "node test/run.js", - "prepublish": "bin/prepublish.sh" + "_from": "acorn@1.2.2", + "_id": "acorn@1.2.2", + "_inBundle": false, + "_integrity": "sha1-yM4n3grMdtiW0rH6099YjZ6C8BQ=", + "_location": "/jade/with/acorn", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "acorn@1.2.2", + "name": "acorn", + "escapedName": "acorn", + "rawSpec": "1.2.2", + "saveSpec": null, + "fetchSpec": "1.2.2" }, + "_requiredBy": [ + "/jade/with" + ], + "_resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz", + "_spec": "1.2.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bin": { "acorn": "./bin/acorn" }, - "devDependencies": { - "babelify": "^5.0.4", - "browserify": "^9.0.3", - "browserify-derequire": "^0.9.4", - "unicode-7.0.0": "~0.1.5" + "bugs": { + "url": "https://github.com/marijnh/acorn/issues" }, "contributors": [ { @@ -144,22 +146,39 @@ "name": "zsjforcn" } ], - "gitHead": "0857d8bb9c3c05e6c8fac9e83fddaefc4f43816f", - "bugs": { - "url": "https://github.com/marijnh/acorn/issues" + "description": "ECMAScript parser", + "devDependencies": { + "babelify": "^5.0.4", + "browserify": "^9.0.3", + "browserify-derequire": "^0.9.4", + "unicode-7.0.0": "~0.1.5" }, - "_id": "acorn@1.2.2", - "_shasum": "c8ce27de0acc76d896d2b1fad3df588d9e82f014", - "_from": "acorn@>=1.0.1 <2.0.0", - "_npmVersion": "1.4.21", - "_npmUser": { - "name": "marijn", - "email": "marijnh@gmail.com" + "engines": { + "node": ">=0.4.0" + }, + "homepage": "https://github.com/marijnh/acorn", + "license": "MIT", + "main": "dist/acorn.js", + "maintainers": [ + { + "name": "Marijn Haverbeke", + "email": "marijnh@gmail.com", + "url": "http://marijnhaverbeke.nl" + }, + { + "name": "Ingvar Stepanyan", + "email": "me@rreverser.com", + "url": "http://rreverser.com/" + } + ], + "name": "acorn", + "repository": { + "type": "git", + "url": "git+https://github.com/marijnh/acorn.git" }, - "dist": { - "shasum": "c8ce27de0acc76d896d2b1fad3df588d9e82f014", - "tarball": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz" + "scripts": { + "prepublish": "bin/prepublish.sh", + "test": "node test/run.js" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz" + "version": "1.2.2" } diff --git a/node_modules/jade/node_modules/with/package.json b/node_modules/jade/node_modules/with/package.json index 545169e..127bd43 100644 --- a/node_modules/jade/node_modules/with/package.json +++ b/node_modules/jade/node_modules/with/package.json @@ -1,51 +1,57 @@ { - "name": "with", - "version": "4.0.3", - "description": "Compile time `with` for strict mode JavaScript", - "main": "index.js", - "scripts": { - "test": "mocha test/index.js -R spec" - }, - "repository": { - "type": "git", - "url": "https://github.com/ForbesLindesay/with.git" - }, + "_args": [ + [ + "with@4.0.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "with@4.0.3", + "_id": "with@4.0.3", + "_inBundle": false, + "_integrity": "sha1-7v0VTp550sjTQXtkeo8U2f7M4U4=", + "_location": "/jade/with", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "with@4.0.3", + "name": "with", + "escapedName": "with", + "rawSpec": "4.0.3", + "saveSpec": null, + "fetchSpec": "4.0.3" + }, + "_requiredBy": [ + "/jade" + ], + "_resolved": "https://registry.npmjs.org/with/-/with-4.0.3.tgz", + "_spec": "4.0.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "ForbesLindesay" }, - "license": "MIT", + "bugs": { + "url": "https://github.com/ForbesLindesay/with/issues" + }, "dependencies": { "acorn": "^1.0.1", "acorn-globals": "^1.0.3" }, + "description": "Compile time `with` for strict mode JavaScript", "devDependencies": { "mocha": "~1.12.0", "uglify-js": "^2.4.15" }, - "gitHead": "38351aea899040937ab8c7c9ce43b3ad1d498bed", - "bugs": { - "url": "https://github.com/ForbesLindesay/with/issues" - }, - "homepage": "https://github.com/ForbesLindesay/with", - "_id": "with@4.0.3", - "_shasum": "eefd154e9e79d2c8d3417b647a8f14d9fecce14e", - "_from": "with@>=4.0.0 <4.1.0", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.6.2", - "_npmUser": { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" + "homepage": "https://github.com/ForbesLindesay/with#readme", + "license": "MIT", + "main": "index.js", + "name": "with", + "repository": { + "type": "git", + "url": "git+https://github.com/ForbesLindesay/with.git" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - } - ], - "dist": { - "shasum": "eefd154e9e79d2c8d3417b647a8f14d9fecce14e", - "tarball": "https://registry.npmjs.org/with/-/with-4.0.3.tgz" + "scripts": { + "test": "mocha test/index.js -R spec" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/with/-/with-4.0.3.tgz" + "version": "4.0.3" } diff --git a/node_modules/jade/package.json b/node_modules/jade/package.json index 2aa7686..ef5fb62 100644 --- a/node_modules/jade/package.json +++ b/node_modules/jade/package.json @@ -1,38 +1,51 @@ { - "name": "jade", - "description": "A clean, whitespace-sensitive template language for writing HTML", - "version": "1.11.0", + "_args": [ + [ + "jade@1.11.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "jade@1.11.0", + "_id": "jade@1.11.0", + "_inBundle": false, + "_integrity": "sha1-nIDlOMEtP7lcjZu5VZ+gzAQEBf0=", + "_location": "/jade", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "jade@1.11.0", + "name": "jade", + "escapedName": "jade", + "rawSpec": "1.11.0", + "saveSpec": null, + "fetchSpec": "1.11.0" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/jade/-/jade-1.11.0.tgz", + "_spec": "1.11.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, - "maintainers": [ - { - "name": "forbeslindesay", - "email": "forbes@lindesay.co.uk" - }, - { - "name": "bloodyowl", - "email": "mlbli@me.com" - }, - { - "name": "jbnicolai", - "email": "jappelman@xebia.com" - }, - { - "name": "alubbe", - "email": "npm@lubbe.org" - } - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git://github.com/jadejs/jade.git" - }, - "main": "lib", "bin": { "jade": "./bin/jade.js" }, + "browser": { + "fs": false, + "./lib/filters.js": "./lib/filters-client.js" + }, + "bugs": { + "url": "https://github.com/jadejs/jade/issues" + }, + "component": { + "scripts": { + "jade": "runtime.js" + } + }, "dependencies": { "character-parser": "1.2.1", "clean-css": "^3.1.9", @@ -45,6 +58,7 @@ "void-elements": "~2.0.1", "with": "~4.0.0" }, + "description": "A clean, whitespace-sensitive template language for writing HTML", "devDependencies": { "browserify": "*", "browserify-middleware": "~4.1.0", @@ -80,46 +94,59 @@ "twbs": "0.0.6", "uglify-js": "*" }, - "component": { - "scripts": { - "jade": "runtime.js" + "homepage": "http://jade-lang.com", + "license": "MIT", + "main": "lib", + "maintainers": [ + { + "name": "Forbes Lindesay", + "email": "forbes@lindesay.co.uk" + }, + { + "name": "Matthias Le Brun", + "email": "mlbli@me.com" + }, + { + "name": "Joshua Appelman", + "email": "joshua@jbna.nl" + }, + { + "name": "Jonathan Ong", + "email": "jonathanrichardong@gmail.com" + }, + { + "name": "Alex Kocharin", + "email": "alex@kocharin.ru" + }, + { + "name": "Hemanth", + "email": "hemanth.hm@gmail.com" + }, + { + "name": "Timothy Gu", + "email": "timothygu99@gmail.com" + }, + { + "name": "Andreas Lubbe", + "email": "git@lubbe.org" } + ], + "name": "jade", + "repository": { + "type": "git", + "url": "git://github.com/jadejs/jade.git" }, "scripts": { - "test": "mocha -R spec", - "precoverage": "rimraf coverage && rimraf cov-pt*", - "coverage": "istanbul cover --report none --dir cov-pt0 node_modules/mocha/bin/_mocha -- -R dot", - "postcoverage": "istanbul report --include cov-pt\\*/coverage.json && rimraf cov-pt*", - "coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", - "prepublish": "npm prune && linify transform bin && npm run build", "build": "npm run compile", "compile": "npm run compile-full && npm run compile-runtime", "compile-full": "browserify ./lib/index.js --standalone jade -x ./node_modules/transformers > jade.js", - "compile-runtime": "browserify ./lib/runtime.js --standalone jade > runtime.js" - }, - "browser": { - "fs": false, - "./lib/filters.js": "./lib/filters-client.js" - }, - "homepage": "http://jade-lang.com", - "gitHead": "31966399f86b15159f2ff47dff99fbf4c92fadd5", - "bugs": { - "url": "https://github.com/jadejs/jade/issues" - }, - "_id": "jade@1.11.0", - "_shasum": "9c80e538c12d3fb95c8d9bb9559fa0cc040405fd", - "_from": "jade@>=1.11.0 <2.0.0", - "_npmVersion": "2.11.0", - "_nodeVersion": "2.2.1", - "_npmUser": { - "name": "alubbe", - "email": "npm@lubbe.org" - }, - "dist": { - "shasum": "9c80e538c12d3fb95c8d9bb9559fa0cc040405fd", - "tarball": "https://registry.npmjs.org/jade/-/jade-1.11.0.tgz" + "compile-runtime": "browserify ./lib/runtime.js --standalone jade > runtime.js", + "coverage": "istanbul cover --report none --dir cov-pt0 node_modules/mocha/bin/_mocha -- -R dot", + "coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", + "postcoverage": "istanbul report --include cov-pt\\*/coverage.json && rimraf cov-pt*", + "precoverage": "rimraf coverage && rimraf cov-pt*", + "prepublish": "npm prune && linify transform bin && npm run build", + "test": "mocha -R spec" }, - "deprecated": "Jade has been renamed to pug, please install the latest version of pug instead of jade", - "directories": {}, - "_resolved": "https://registry.npmjs.org/jade/-/jade-1.11.0.tgz" + "version": "1.11.0" } diff --git a/node_modules/jshint/node_modules/lodash/package.json b/node_modules/jshint/node_modules/lodash/package.json index 5a0fe51..7e60bdf 100644 --- a/node_modules/jshint/node_modules/lodash/package.json +++ b/node_modules/jshint/node_modules/lodash/package.json @@ -1,27 +1,33 @@ { - "_from": "lodash@3.7.x", + "_args": [ + [ + "lodash@3.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "lodash@3.7.0", "_id": "lodash@3.7.0", "_inBundle": false, "_integrity": "sha1-Nni9irmVBXwHreg27S7wh9qBHUU=", "_location": "/jshint/lodash", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "lodash@3.7.x", + "raw": "lodash@3.7.0", "name": "lodash", "escapedName": "lodash", - "rawSpec": "3.7.x", + "rawSpec": "3.7.0", "saveSpec": null, - "fetchSpec": "3.7.x" + "fetchSpec": "3.7.0" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/lodash/-/lodash-3.7.0.tgz", - "_shasum": "3678bd8ab995057c07ade836ed2ef087da811d45", - "_spec": "lodash@3.7.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "3.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "John-David Dalton", "email": "john.david.dalton@gmail.com", @@ -30,7 +36,6 @@ "bugs": { "url": "https://github.com/lodash/lodash/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "John-David Dalton", @@ -58,7 +63,6 @@ "url": "https://mathiasbynens.be/" } ], - "deprecated": false, "description": "The modern build of lodash modular utilities.", "homepage": "https://lodash.com/", "icon": "https://lodash.com/icon.svg", diff --git a/node_modules/jshint/node_modules/minimatch/package.json b/node_modules/jshint/node_modules/minimatch/package.json index be9d7a7..88ea0ef 100644 --- a/node_modules/jshint/node_modules/minimatch/package.json +++ b/node_modules/jshint/node_modules/minimatch/package.json @@ -1,27 +1,33 @@ { - "_from": "minimatch@~3.0.2", + "_args": [ + [ + "minimatch@3.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "minimatch@3.0.4", "_id": "minimatch@3.0.4", "_inBundle": false, "_integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "_location": "/jshint/minimatch", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "minimatch@~3.0.2", + "raw": "minimatch@3.0.4", "name": "minimatch", "escapedName": "minimatch", - "rawSpec": "~3.0.2", + "rawSpec": "3.0.4", "saveSpec": null, - "fetchSpec": "~3.0.2" + "fetchSpec": "3.0.4" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "_shasum": "5166e286457f03306064be5497e8dbb0c3d32083", - "_spec": "minimatch@~3.0.2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "3.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,11 +36,9 @@ "bugs": { "url": "https://github.com/isaacs/minimatch/issues" }, - "bundleDependencies": false, "dependencies": { "brace-expansion": "^1.1.7" }, - "deprecated": false, "description": "a glob matcher in javascript", "devDependencies": { "tap": "^10.3.2" diff --git a/node_modules/jshint/package.json b/node_modules/jshint/package.json index e9eef8b..6d602da 100644 --- a/node_modules/jshint/package.json +++ b/node_modules/jshint/package.json @@ -1,5 +1,12 @@ { - "_from": "jshint", + "_args": [ + [ + "jshint@2.9.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "jshint@2.9.5", "_id": "jshint@2.9.5", "_inBundle": false, "_integrity": "sha1-HnJSkVzmgbQIJ+4UJIxG006apiw=", @@ -8,22 +15,20 @@ "brace-expansion": "1.1.11" }, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "jshint", + "raw": "jshint@2.9.5", "name": "jshint", "escapedName": "jshint", - "rawSpec": "", + "rawSpec": "2.9.5", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "2.9.5" }, "_requiredBy": [ - "#DEV:/", - "#USER" + "#DEV:/" ], "_resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz", - "_shasum": "1e7252915ce681b40827ee14248c46d34e9aa62c", - "_spec": "jshint", + "_spec": "2.9.5", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Anton Kovalyov", @@ -36,7 +41,6 @@ "bugs": { "url": "https://github.com/jshint/jshint/issues" }, - "bundleDependencies": false, "dependencies": { "cli": "~1.0.0", "console-browserify": "1.1.x", @@ -47,7 +51,6 @@ "shelljs": "0.3.x", "strip-json-comments": "1.0.x" }, - "deprecated": false, "description": "Static analysis tool for JavaScript", "devDependencies": { "async": "~2.1.2", diff --git a/node_modules/kareem/package.json b/node_modules/kareem/package.json index 8b53d68..34ae0d5 100644 --- a/node_modules/kareem/package.json +++ b/node_modules/kareem/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "kareem@1.5.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "kareem@1.5.0", "_id": "kareem@1.5.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz", - "_shasum": "e3e4101d9dcfde299769daf4b4db64d895d17448", - "_spec": "kareem@1.5.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "1.5.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Valeri Karpov", "email": "val@karpov.io" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/vkarpov15/kareem/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Next-generation take on pre/post function hooks", "devDependencies": { "acquit": "0.4.1", diff --git a/node_modules/lodash.get/package.json b/node_modules/lodash.get/package.json index 9d4aebd..05cb4e9 100644 --- a/node_modules/lodash.get/package.json +++ b/node_modules/lodash.get/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "lodash.get@4.4.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "lodash.get@4.4.2", "_id": "lodash.get@4.4.2", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "_shasum": "2d177f652fa31e939b4438d5341499dfa3825e99", - "_spec": "lodash.get@4.4.2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "4.4.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "John-David Dalton", "email": "john.david.dalton@gmail.com", @@ -30,7 +35,6 @@ "bugs": { "url": "https://github.com/lodash/lodash/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "John-David Dalton", @@ -48,7 +52,6 @@ "url": "https://mathiasbynens.be/" } ], - "deprecated": false, "description": "The lodash method `_.get` exported as a module.", "homepage": "https://lodash.com/", "icon": "https://lodash.com/icon.svg", diff --git a/node_modules/lodash/package.json b/node_modules/lodash/package.json index 307a272..1a00efb 100644 --- a/node_modules/lodash/package.json +++ b/node_modules/lodash/package.json @@ -1,27 +1,32 @@ { - "_from": "lodash@^4.14.0", + "_args": [ + [ + "lodash@4.17.10", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "lodash@4.17.10", "_id": "lodash@4.17.10", "_inBundle": false, "_integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", "_location": "/lodash", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "lodash@^4.14.0", + "raw": "lodash@4.17.10", "name": "lodash", "escapedName": "lodash", - "rawSpec": "^4.14.0", + "rawSpec": "4.17.10", "saveSpec": null, - "fetchSpec": "^4.14.0" + "fetchSpec": "4.17.10" }, "_requiredBy": [ "/async" ], "_resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "_shasum": "1b7793cf7259ea38fb3661d4d38b3260af8ae4e7", - "_spec": "lodash@^4.14.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/async", + "_spec": "4.17.10", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "John-David Dalton", "email": "john.david.dalton@gmail.com", @@ -30,7 +35,6 @@ "bugs": { "url": "https://github.com/lodash/lodash/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "John-David Dalton", @@ -43,7 +47,6 @@ "url": "https://mathiasbynens.be/" } ], - "deprecated": false, "description": "Lodash modular utilities.", "homepage": "https://lodash.com/", "icon": "https://lodash.com/icon.svg", diff --git a/node_modules/lru-cache/package.json b/node_modules/lru-cache/package.json index 1af6d87..bfaebca 100644 --- a/node_modules/lru-cache/package.json +++ b/node_modules/lru-cache/package.json @@ -1,27 +1,32 @@ { - "_from": "lru-cache@2", + "_args": [ + [ + "lru-cache@2.7.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "lru-cache@2.7.3", "_id": "lru-cache@2.7.3", "_inBundle": false, "_integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", "_location": "/lru-cache", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "lru-cache@2", + "raw": "lru-cache@2.7.3", "name": "lru-cache", "escapedName": "lru-cache", - "rawSpec": "2", + "rawSpec": "2.7.3", "saveSpec": null, - "fetchSpec": "2" + "fetchSpec": "2.7.3" }, "_requiredBy": [ "/minimatch" ], "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "_shasum": "6d4524e8b955f95d4f5b58851ce21dd72fb4e952", - "_spec": "lru-cache@2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/minimatch", + "_spec": "2.7.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/isaacs/node-lru-cache/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "A cache object that deletes the least-recently-used items.", "devDependencies": { "tap": "^1.2.0", diff --git a/node_modules/media-typer/HISTORY.md b/node_modules/media-typer/HISTORY.md new file mode 100644 index 0000000..62c2003 --- /dev/null +++ b/node_modules/media-typer/HISTORY.md @@ -0,0 +1,22 @@ +0.3.0 / 2014-09-07 +================== + + * Support Node.js 0.6 + * Throw error when parameter format invalid on parse + +0.2.0 / 2014-06-18 +================== + + * Add `typer.format()` to format media types + +0.1.0 / 2014-06-17 +================== + + * Accept `req` as argument to `parse` + * Accept `res` as argument to `parse` + * Parse media type with extra LWS between type and first parameter + +0.0.0 / 2014-06-13 +================== + + * Initial implementation diff --git a/node_modules/media-typer/LICENSE b/node_modules/media-typer/LICENSE new file mode 100644 index 0000000..b7dce6c --- /dev/null +++ b/node_modules/media-typer/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/media-typer/README.md b/node_modules/media-typer/README.md new file mode 100644 index 0000000..d8df623 --- /dev/null +++ b/node_modules/media-typer/README.md @@ -0,0 +1,81 @@ +# media-typer + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Simple RFC 6838 media type parser + +## Installation + +```sh +$ npm install media-typer +``` + +## API + +```js +var typer = require('media-typer') +``` + +### typer.parse(string) + +```js +var obj = typer.parse('image/svg+xml; charset=utf-8') +``` + +Parse a media type string. This will return an object with the following +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`): + + - `type`: The type of the media type (always lower case). Example: `'image'` + + - `subtype`: The subtype of the media type (always lower case). Example: `'svg'` + + - `suffix`: The suffix of the media type (always lower case). Example: `'xml'` + + - `parameters`: An object of the parameters in the media type (name of parameter always lower case). Example: `{charset: 'utf-8'}` + +### typer.parse(req) + +```js +var obj = typer.parse(req) +``` + +Parse the `content-type` header from the given `req`. Short-cut for +`typer.parse(req.headers['content-type'])`. + +### typer.parse(res) + +```js +var obj = typer.parse(res) +``` + +Parse the `content-type` header set on the given `res`. Short-cut for +`typer.parse(res.getHeader('content-type'))`. + +### typer.format(obj) + +```js +var obj = typer.format({type: 'image', subtype: 'svg', suffix: 'xml'}) +``` + +Format an object into a media type string. This will return a string of the +mime type for the given object. For the properties of the object, see the +documentation for `typer.parse(string)`. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat +[npm-url]: https://npmjs.org/package/media-typer +[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat +[travis-url]: https://travis-ci.org/jshttp/media-typer +[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat +[coveralls-url]: https://coveralls.io/r/jshttp/media-typer +[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat +[downloads-url]: https://npmjs.org/package/media-typer diff --git a/node_modules/media-typer/index.js b/node_modules/media-typer/index.js new file mode 100644 index 0000000..07f7295 --- /dev/null +++ b/node_modules/media-typer/index.js @@ -0,0 +1,270 @@ +/*! + * media-typer + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +/** + * RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7 + * + * parameter = token "=" ( token | quoted-string ) + * token = 1* + * separators = "(" | ")" | "<" | ">" | "@" + * | "," | ";" | ":" | "\" | <"> + * | "/" | "[" | "]" | "?" | "=" + * | "{" | "}" | SP | HT + * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) + * qdtext = > + * quoted-pair = "\" CHAR + * CHAR = + * TEXT = + * LWS = [CRLF] 1*( SP | HT ) + * CRLF = CR LF + * CR = + * LF = + * SP = + * SHT = + * CTL = + * OCTET = + */ +var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g; +var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/ +var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/ + +/** + * RegExp to match quoted-pair in RFC 2616 + * + * quoted-pair = "\" CHAR + * CHAR = + */ +var qescRegExp = /\\([\u0000-\u007f])/g; + +/** + * RegExp to match chars that must be quoted-pair in RFC 2616 + */ +var quoteRegExp = /([\\"])/g; + +/** + * RegExp to match type in RFC 6838 + * + * type-name = restricted-name + * subtype-name = restricted-name + * restricted-name = restricted-name-first *126restricted-name-chars + * restricted-name-first = ALPHA / DIGIT + * restricted-name-chars = ALPHA / DIGIT / "!" / "#" / + * "$" / "&" / "-" / "^" / "_" + * restricted-name-chars =/ "." ; Characters before first dot always + * ; specify a facet name + * restricted-name-chars =/ "+" ; Characters after last plus always + * ; specify a structured syntax suffix + * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z + * DIGIT = %x30-39 ; 0-9 + */ +var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/ +var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/ +var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/; + +/** + * Module exports. + */ + +exports.format = format +exports.parse = parse + +/** + * Format object to media type. + * + * @param {object} obj + * @return {string} + * @api public + */ + +function format(obj) { + if (!obj || typeof obj !== 'object') { + throw new TypeError('argument obj is required') + } + + var parameters = obj.parameters + var subtype = obj.subtype + var suffix = obj.suffix + var type = obj.type + + if (!type || !typeNameRegExp.test(type)) { + throw new TypeError('invalid type') + } + + if (!subtype || !subtypeNameRegExp.test(subtype)) { + throw new TypeError('invalid subtype') + } + + // format as type/subtype + var string = type + '/' + subtype + + // append +suffix + if (suffix) { + if (!typeNameRegExp.test(suffix)) { + throw new TypeError('invalid suffix') + } + + string += '+' + suffix + } + + // append parameters + if (parameters && typeof parameters === 'object') { + var param + var params = Object.keys(parameters).sort() + + for (var i = 0; i < params.length; i++) { + param = params[i] + + if (!tokenRegExp.test(param)) { + throw new TypeError('invalid parameter name') + } + + string += '; ' + param + '=' + qstring(parameters[param]) + } + } + + return string +} + +/** + * Parse media type to object. + * + * @param {string|object} string + * @return {Object} + * @api public + */ + +function parse(string) { + if (!string) { + throw new TypeError('argument string is required') + } + + // support req/res-like objects as argument + if (typeof string === 'object') { + string = getcontenttype(string) + } + + if (typeof string !== 'string') { + throw new TypeError('argument string is required to be a string') + } + + var index = string.indexOf(';') + var type = index !== -1 + ? string.substr(0, index) + : string + + var key + var match + var obj = splitType(type) + var params = {} + var value + + paramRegExp.lastIndex = index + + while (match = paramRegExp.exec(string)) { + if (match.index !== index) { + throw new TypeError('invalid parameter format') + } + + index += match[0].length + key = match[1].toLowerCase() + value = match[2] + + if (value[0] === '"') { + // remove quotes and escapes + value = value + .substr(1, value.length - 2) + .replace(qescRegExp, '$1') + } + + params[key] = value + } + + if (index !== -1 && index !== string.length) { + throw new TypeError('invalid parameter format') + } + + obj.parameters = params + + return obj +} + +/** + * Get content-type from req/res objects. + * + * @param {object} + * @return {Object} + * @api private + */ + +function getcontenttype(obj) { + if (typeof obj.getHeader === 'function') { + // res-like + return obj.getHeader('content-type') + } + + if (typeof obj.headers === 'object') { + // req-like + return obj.headers && obj.headers['content-type'] + } +} + +/** + * Quote a string if necessary. + * + * @param {string} val + * @return {string} + * @api private + */ + +function qstring(val) { + var str = String(val) + + // no need to quote tokens + if (tokenRegExp.test(str)) { + return str + } + + if (str.length > 0 && !textRegExp.test(str)) { + throw new TypeError('invalid parameter value') + } + + return '"' + str.replace(quoteRegExp, '\\$1') + '"' +} + +/** + * Simply "type/subtype+siffx" into parts. + * + * @param {string} string + * @return {Object} + * @api private + */ + +function splitType(string) { + var match = typeRegExp.exec(string.toLowerCase()) + + if (!match) { + throw new TypeError('invalid media type') + } + + var type = match[1] + var subtype = match[2] + var suffix + + // suffix after last + + var index = subtype.lastIndexOf('+') + if (index !== -1) { + suffix = subtype.substr(index + 1) + subtype = subtype.substr(0, index) + } + + var obj = { + type: type, + subtype: subtype, + suffix: suffix + } + + return obj +} diff --git a/node_modules/media-typer/package.json b/node_modules/media-typer/package.json new file mode 100644 index 0000000..45485fb --- /dev/null +++ b/node_modules/media-typer/package.json @@ -0,0 +1,61 @@ +{ + "_from": "media-typer@0.3.0", + "_id": "media-typer@0.3.0", + "_inBundle": false, + "_integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "_location": "/media-typer", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "media-typer@0.3.0", + "name": "media-typer", + "escapedName": "media-typer", + "rawSpec": "0.3.0", + "saveSpec": null, + "fetchSpec": "0.3.0" + }, + "_requiredBy": [ + "/type-is" + ], + "_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "_shasum": "8710d7af0aa626f8fffa1ce00168545263255748", + "_spec": "media-typer@0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/type-is", + "author": { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + "bugs": { + "url": "https://github.com/jshttp/media-typer/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Simple RFC 6838 media type parser and formatter", + "devDependencies": { + "istanbul": "0.3.2", + "mocha": "~1.21.4", + "should": "~4.0.4" + }, + "engines": { + "node": ">= 0.6" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "homepage": "https://github.com/jshttp/media-typer#readme", + "license": "MIT", + "name": "media-typer", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/media-typer.git" + }, + "scripts": { + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "version": "0.3.0" +} diff --git a/node_modules/mime-db/HISTORY.md b/node_modules/mime-db/HISTORY.md new file mode 100644 index 0000000..1cc7a51 --- /dev/null +++ b/node_modules/mime-db/HISTORY.md @@ -0,0 +1,391 @@ +1.36.0 / 2018-08-20 +=================== + + * Add Apple file extensions from IANA + * Add extensions from IANA for `image/*` types + * Add new upstream MIME types + +1.35.0 / 2018-07-15 +=================== + + * Add extension `.owl` to `application/rdf+xml` + * Add new upstream MIME types + - Removes extension `.woff` from `application/font-woff` + +1.34.0 / 2018-06-03 +=================== + + * Add extension `.csl` to `application/vnd.citationstyles.style+xml` + * Add extension `.es` to `application/ecmascript` + * Add new upstream MIME types + * Add `UTF-8` as default charset for `text/turtle` + * Mark all XML-derived types as compressible + +1.33.0 / 2018-02-15 +=================== + + * Add extensions from IANA for `message/*` types + * Add new upstream MIME types + * Fix some incorrect OOXML types + * Remove `application/font-woff2` + +1.32.0 / 2017-11-29 +=================== + + * Add new upstream MIME types + * Update `text/hjson` to registered `application/hjson` + * Add `text/shex` with extension `.shex` + +1.31.0 / 2017-10-25 +=================== + + * Add `application/raml+yaml` with extension `.raml` + * Add `application/wasm` with extension `.wasm` + * Add new `font` type from IANA + * Add new upstream font extensions + * Add new upstream MIME types + * Add extensions for JPEG-2000 images + +1.30.0 / 2017-08-27 +=================== + + * Add `application/vnd.ms-outlook` + * Add `application/x-arj` + * Add extension `.mjs` to `application/javascript` + * Add glTF types and extensions + * Add new upstream MIME types + * Add `text/x-org` + * Add VirtualBox MIME types + * Fix `source` records for `video/*` types that are IANA + * Update `font/opentype` to registered `font/otf` + +1.29.0 / 2017-07-10 +=================== + + * Add `application/fido.trusted-apps+json` + * Add extension `.wadl` to `application/vnd.sun.wadl+xml` + * Add new upstream MIME types + * Add `UTF-8` as default charset for `text/css` + +1.28.0 / 2017-05-14 +=================== + + * Add new upstream MIME types + * Add extension `.gz` to `application/gzip` + * Update extensions `.md` and `.markdown` to be `text/markdown` + +1.27.0 / 2017-03-16 +=================== + + * Add new upstream MIME types + * Add `image/apng` with extension `.apng` + +1.26.0 / 2017-01-14 +=================== + + * Add new upstream MIME types + * Add extension `.geojson` to `application/geo+json` + +1.25.0 / 2016-11-11 +=================== + + * Add new upstream MIME types + +1.24.0 / 2016-09-18 +=================== + + * Add `audio/mp3` + * Add new upstream MIME types + +1.23.0 / 2016-05-01 +=================== + + * Add new upstream MIME types + * Add extension `.3gpp` to `audio/3gpp` + +1.22.0 / 2016-02-15 +=================== + + * Add `text/slim` + * Add extension `.rng` to `application/xml` + * Add new upstream MIME types + * Fix extension of `application/dash+xml` to be `.mpd` + * Update primary extension to `.m4a` for `audio/mp4` + +1.21.0 / 2016-01-06 +=================== + + * Add Google document types + * Add new upstream MIME types + +1.20.0 / 2015-11-10 +=================== + + * Add `text/x-suse-ymp` + * Add new upstream MIME types + +1.19.0 / 2015-09-17 +=================== + + * Add `application/vnd.apple.pkpass` + * Add new upstream MIME types + +1.18.0 / 2015-09-03 +=================== + + * Add new upstream MIME types + +1.17.0 / 2015-08-13 +=================== + + * Add `application/x-msdos-program` + * Add `audio/g711-0` + * Add `image/vnd.mozilla.apng` + * Add extension `.exe` to `application/x-msdos-program` + +1.16.0 / 2015-07-29 +=================== + + * Add `application/vnd.uri-map` + +1.15.0 / 2015-07-13 +=================== + + * Add `application/x-httpd-php` + +1.14.0 / 2015-06-25 +=================== + + * Add `application/scim+json` + * Add `application/vnd.3gpp.ussd+xml` + * Add `application/vnd.biopax.rdf+xml` + * Add `text/x-processing` + +1.13.0 / 2015-06-07 +=================== + + * Add nginx as a source + * Add `application/x-cocoa` + * Add `application/x-java-archive-diff` + * Add `application/x-makeself` + * Add `application/x-perl` + * Add `application/x-pilot` + * Add `application/x-redhat-package-manager` + * Add `application/x-sea` + * Add `audio/x-m4a` + * Add `audio/x-realaudio` + * Add `image/x-jng` + * Add `text/mathml` + +1.12.0 / 2015-06-05 +=================== + + * Add `application/bdoc` + * Add `application/vnd.hyperdrive+json` + * Add `application/x-bdoc` + * Add extension `.rtf` to `text/rtf` + +1.11.0 / 2015-05-31 +=================== + + * Add `audio/wav` + * Add `audio/wave` + * Add extension `.litcoffee` to `text/coffeescript` + * Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data` + * Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install` + +1.10.0 / 2015-05-19 +=================== + + * Add `application/vnd.balsamiq.bmpr` + * Add `application/vnd.microsoft.portable-executable` + * Add `application/x-ns-proxy-autoconfig` + +1.9.1 / 2015-04-19 +================== + + * Remove `.json` extension from `application/manifest+json` + - This is causing bugs downstream + +1.9.0 / 2015-04-19 +================== + + * Add `application/manifest+json` + * Add `application/vnd.micro+json` + * Add `image/vnd.zbrush.pcx` + * Add `image/x-ms-bmp` + +1.8.0 / 2015-03-13 +================== + + * Add `application/vnd.citationstyles.style+xml` + * Add `application/vnd.fastcopy-disk-image` + * Add `application/vnd.gov.sk.xmldatacontainer+xml` + * Add extension `.jsonld` to `application/ld+json` + +1.7.0 / 2015-02-08 +================== + + * Add `application/vnd.gerber` + * Add `application/vnd.msa-disk-image` + +1.6.1 / 2015-02-05 +================== + + * Community extensions ownership transferred from `node-mime` + +1.6.0 / 2015-01-29 +================== + + * Add `application/jose` + * Add `application/jose+json` + * Add `application/json-seq` + * Add `application/jwk+json` + * Add `application/jwk-set+json` + * Add `application/jwt` + * Add `application/rdap+json` + * Add `application/vnd.gov.sk.e-form+xml` + * Add `application/vnd.ims.imsccv1p3` + +1.5.0 / 2014-12-30 +================== + + * Add `application/vnd.oracle.resource+json` + * Fix various invalid MIME type entries + - `application/mbox+xml` + - `application/oscp-response` + - `application/vwg-multiplexed` + - `audio/g721` + +1.4.0 / 2014-12-21 +================== + + * Add `application/vnd.ims.imsccv1p2` + * Fix various invalid MIME type entries + - `application/vnd-acucobol` + - `application/vnd-curl` + - `application/vnd-dart` + - `application/vnd-dxr` + - `application/vnd-fdf` + - `application/vnd-mif` + - `application/vnd-sema` + - `application/vnd-wap-wmlc` + - `application/vnd.adobe.flash-movie` + - `application/vnd.dece-zip` + - `application/vnd.dvb_service` + - `application/vnd.micrografx-igx` + - `application/vnd.sealed-doc` + - `application/vnd.sealed-eml` + - `application/vnd.sealed-mht` + - `application/vnd.sealed-ppt` + - `application/vnd.sealed-tiff` + - `application/vnd.sealed-xls` + - `application/vnd.sealedmedia.softseal-html` + - `application/vnd.sealedmedia.softseal-pdf` + - `application/vnd.wap-slc` + - `application/vnd.wap-wbxml` + - `audio/vnd.sealedmedia.softseal-mpeg` + - `image/vnd-djvu` + - `image/vnd-svf` + - `image/vnd-wap-wbmp` + - `image/vnd.sealed-png` + - `image/vnd.sealedmedia.softseal-gif` + - `image/vnd.sealedmedia.softseal-jpg` + - `model/vnd-dwf` + - `model/vnd.parasolid.transmit-binary` + - `model/vnd.parasolid.transmit-text` + - `text/vnd-a` + - `text/vnd-curl` + - `text/vnd.wap-wml` + * Remove example template MIME types + - `application/example` + - `audio/example` + - `image/example` + - `message/example` + - `model/example` + - `multipart/example` + - `text/example` + - `video/example` + +1.3.1 / 2014-12-16 +================== + + * Fix missing extensions + - `application/json5` + - `text/hjson` + +1.3.0 / 2014-12-07 +================== + + * Add `application/a2l` + * Add `application/aml` + * Add `application/atfx` + * Add `application/atxml` + * Add `application/cdfx+xml` + * Add `application/dii` + * Add `application/json5` + * Add `application/lxf` + * Add `application/mf4` + * Add `application/vnd.apache.thrift.compact` + * Add `application/vnd.apache.thrift.json` + * Add `application/vnd.coffeescript` + * Add `application/vnd.enphase.envoy` + * Add `application/vnd.ims.imsccv1p1` + * Add `text/csv-schema` + * Add `text/hjson` + * Add `text/markdown` + * Add `text/yaml` + +1.2.0 / 2014-11-09 +================== + + * Add `application/cea` + * Add `application/dit` + * Add `application/vnd.gov.sk.e-form+zip` + * Add `application/vnd.tmd.mediaflex.api+xml` + * Type `application/epub+zip` is now IANA-registered + +1.1.2 / 2014-10-23 +================== + + * Rebuild database for `application/x-www-form-urlencoded` change + +1.1.1 / 2014-10-20 +================== + + * Mark `application/x-www-form-urlencoded` as compressible. + +1.1.0 / 2014-09-28 +================== + + * Add `application/font-woff2` + +1.0.3 / 2014-09-25 +================== + + * Fix engine requirement in package + +1.0.2 / 2014-09-25 +================== + + * Add `application/coap-group+json` + * Add `application/dcd` + * Add `application/vnd.apache.thrift.binary` + * Add `image/vnd.tencent.tap` + * Mark all JSON-derived types as compressible + * Update `text/vtt` data + +1.0.1 / 2014-08-30 +================== + + * Fix extension ordering + +1.0.0 / 2014-08-30 +================== + + * Add `application/atf` + * Add `application/merge-patch+json` + * Add `multipart/x-mixed-replace` + * Add `source: 'apache'` metadata + * Add `source: 'iana'` metadata + * Remove badly-assumed charset data diff --git a/node_modules/mime-db/LICENSE b/node_modules/mime-db/LICENSE new file mode 100644 index 0000000..a7ae8ee --- /dev/null +++ b/node_modules/mime-db/LICENSE @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2014 Jonathan Ong me@jongleberry.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/mime-db/README.md b/node_modules/mime-db/README.md new file mode 100644 index 0000000..fed4eeb --- /dev/null +++ b/node_modules/mime-db/README.md @@ -0,0 +1,94 @@ +# mime-db + +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Coverage Status][coveralls-image]][coveralls-url] + +This is a database of all mime types. +It consists of a single, public JSON file and does not include any logic, +allowing it to remain as un-opinionated as possible with an API. +It aggregates data from the following sources: + +- http://www.iana.org/assignments/media-types/media-types.xhtml +- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types +- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types + +## Installation + +```bash +npm install mime-db +``` + +### Database Download + +If you're crazy enough to use this in the browser, you can just grab the +JSON file using [RawGit](https://rawgit.com/). It is recommended to replace +`master` with [a release tag](https://github.com/jshttp/mime-db/tags) as the +JSON format may change in the future. + +``` +https://cdn.rawgit.com/jshttp/mime-db/master/db.json +``` + +## Usage + +```js +var db = require('mime-db'); + +// grab data on .js files +var data = db['application/javascript']; +``` + +## Data Structure + +The JSON file is a map lookup for lowercased mime types. +Each mime type has the following properties: + +- `.source` - where the mime type is defined. + If not set, it's probably a custom media type. + - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) + - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) + - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) +- `.extensions[]` - known extensions associated with this mime type. +- `.compressible` - whether a file of this type can be gzipped. +- `.charset` - the default charset associated with this type, if any. + +If unknown, every property could be `undefined`. + +## Contributing + +To edit the database, only make PRs against `src/custom.json` or +`src/custom-suffix.json`. + +The `src/custom.json` file is a JSON object with the MIME type as the keys +and the values being an object with the following keys: + +- `compressible` - leave out if you don't know, otherwise `true`/`false` to + indicate whether the data represented by the type is typically compressible. +- `extensions` - include an array of file extensions that are associated with + the type. +- `notes` - human-readable notes about the type, typically what the type is. +- `sources` - include an array of URLs of where the MIME type and the associated + extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source); + links to type aggregating sites and Wikipedia are _not acceptable_. + +To update the build, run `npm run build`. + +## Adding Custom Media Types + +The best way to get new media types included in this library is to register +them with the IANA. The community registration procedure is outlined in +[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types +registered with the IANA are automatically pulled into this library. + +[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg +[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg +[npm-url]: https://npmjs.org/package/mime-db +[travis-image]: https://img.shields.io/travis/jshttp/mime-db/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-db +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master +[node-image]: https://img.shields.io/node/v/mime-db.svg +[node-url]: https://nodejs.org/en/download/ diff --git a/node_modules/mime-db/db.json b/node_modules/mime-db/db.json new file mode 100644 index 0000000..fbffff2 --- /dev/null +++ b/node_modules/mime-db/db.json @@ -0,0 +1,7671 @@ +{ + "application/1d-interleaved-parityfec": { + "source": "iana" + }, + "application/3gpdash-qoe-report+xml": { + "source": "iana", + "compressible": true + }, + "application/3gpp-ims+xml": { + "source": "iana", + "compressible": true + }, + "application/a2l": { + "source": "iana" + }, + "application/activemessage": { + "source": "iana" + }, + "application/activity+json": { + "source": "iana", + "compressible": true + }, + "application/alto-costmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-costmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/alto-directory+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcost+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointcostparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointprop+json": { + "source": "iana", + "compressible": true + }, + "application/alto-endpointpropparams+json": { + "source": "iana", + "compressible": true + }, + "application/alto-error+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmap+json": { + "source": "iana", + "compressible": true + }, + "application/alto-networkmapfilter+json": { + "source": "iana", + "compressible": true + }, + "application/aml": { + "source": "iana" + }, + "application/andrew-inset": { + "source": "iana", + "extensions": ["ez"] + }, + "application/applefile": { + "source": "iana" + }, + "application/applixware": { + "source": "apache", + "extensions": ["aw"] + }, + "application/atf": { + "source": "iana" + }, + "application/atfx": { + "source": "iana" + }, + "application/atom+xml": { + "source": "iana", + "compressible": true, + "extensions": ["atom"] + }, + "application/atomcat+xml": { + "source": "iana", + "compressible": true, + "extensions": ["atomcat"] + }, + "application/atomdeleted+xml": { + "source": "iana", + "compressible": true + }, + "application/atomicmail": { + "source": "iana" + }, + "application/atomsvc+xml": { + "source": "iana", + "compressible": true, + "extensions": ["atomsvc"] + }, + "application/atxml": { + "source": "iana" + }, + "application/auth-policy+xml": { + "source": "iana", + "compressible": true + }, + "application/bacnet-xdd+zip": { + "source": "iana", + "compressible": false + }, + "application/batch-smtp": { + "source": "iana" + }, + "application/bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/beep+xml": { + "source": "iana", + "compressible": true + }, + "application/calendar+json": { + "source": "iana", + "compressible": true + }, + "application/calendar+xml": { + "source": "iana", + "compressible": true + }, + "application/call-completion": { + "source": "iana" + }, + "application/cals-1840": { + "source": "iana" + }, + "application/cbor": { + "source": "iana" + }, + "application/cccex": { + "source": "iana" + }, + "application/ccmp+xml": { + "source": "iana", + "compressible": true + }, + "application/ccxml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["ccxml"] + }, + "application/cdfx+xml": { + "source": "iana", + "compressible": true + }, + "application/cdmi-capability": { + "source": "iana", + "extensions": ["cdmia"] + }, + "application/cdmi-container": { + "source": "iana", + "extensions": ["cdmic"] + }, + "application/cdmi-domain": { + "source": "iana", + "extensions": ["cdmid"] + }, + "application/cdmi-object": { + "source": "iana", + "extensions": ["cdmio"] + }, + "application/cdmi-queue": { + "source": "iana", + "extensions": ["cdmiq"] + }, + "application/cdni": { + "source": "iana" + }, + "application/cea": { + "source": "iana" + }, + "application/cea-2018+xml": { + "source": "iana", + "compressible": true + }, + "application/cellml+xml": { + "source": "iana", + "compressible": true + }, + "application/cfw": { + "source": "iana" + }, + "application/clue_info+xml": { + "source": "iana", + "compressible": true + }, + "application/cms": { + "source": "iana" + }, + "application/cnrp+xml": { + "source": "iana", + "compressible": true + }, + "application/coap-group+json": { + "source": "iana", + "compressible": true + }, + "application/coap-payload": { + "source": "iana" + }, + "application/commonground": { + "source": "iana" + }, + "application/conference-info+xml": { + "source": "iana", + "compressible": true + }, + "application/cose": { + "source": "iana" + }, + "application/cose-key": { + "source": "iana" + }, + "application/cose-key-set": { + "source": "iana" + }, + "application/cpl+xml": { + "source": "iana", + "compressible": true + }, + "application/csrattrs": { + "source": "iana" + }, + "application/csta+xml": { + "source": "iana", + "compressible": true + }, + "application/cstadata+xml": { + "source": "iana", + "compressible": true + }, + "application/csvm+json": { + "source": "iana", + "compressible": true + }, + "application/cu-seeme": { + "source": "apache", + "extensions": ["cu"] + }, + "application/cwt": { + "source": "iana" + }, + "application/cybercash": { + "source": "iana" + }, + "application/dart": { + "compressible": true + }, + "application/dash+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mpd"] + }, + "application/dashdelta": { + "source": "iana" + }, + "application/davmount+xml": { + "source": "iana", + "compressible": true, + "extensions": ["davmount"] + }, + "application/dca-rft": { + "source": "iana" + }, + "application/dcd": { + "source": "iana" + }, + "application/dec-dx": { + "source": "iana" + }, + "application/dialog-info+xml": { + "source": "iana", + "compressible": true + }, + "application/dicom": { + "source": "iana" + }, + "application/dicom+json": { + "source": "iana", + "compressible": true + }, + "application/dicom+xml": { + "source": "iana", + "compressible": true + }, + "application/dii": { + "source": "iana" + }, + "application/dit": { + "source": "iana" + }, + "application/dns": { + "source": "iana" + }, + "application/dns+json": { + "source": "iana", + "compressible": true + }, + "application/docbook+xml": { + "source": "apache", + "compressible": true, + "extensions": ["dbk"] + }, + "application/dskpp+xml": { + "source": "iana", + "compressible": true + }, + "application/dssc+der": { + "source": "iana", + "extensions": ["dssc"] + }, + "application/dssc+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xdssc"] + }, + "application/dvcs": { + "source": "iana" + }, + "application/ecmascript": { + "source": "iana", + "compressible": true, + "extensions": ["ecma","es"] + }, + "application/edi-consent": { + "source": "iana" + }, + "application/edi-x12": { + "source": "iana", + "compressible": false + }, + "application/edifact": { + "source": "iana", + "compressible": false + }, + "application/efi": { + "source": "iana" + }, + "application/emergencycalldata.comment+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.control+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.deviceinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.ecall.msd": { + "source": "iana" + }, + "application/emergencycalldata.providerinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.serviceinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.subscriberinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/emergencycalldata.veds+xml": { + "source": "iana", + "compressible": true + }, + "application/emma+xml": { + "source": "iana", + "compressible": true, + "extensions": ["emma"] + }, + "application/emotionml+xml": { + "source": "iana", + "compressible": true + }, + "application/encaprtp": { + "source": "iana" + }, + "application/epp+xml": { + "source": "iana", + "compressible": true + }, + "application/epub+zip": { + "source": "iana", + "compressible": false, + "extensions": ["epub"] + }, + "application/eshop": { + "source": "iana" + }, + "application/exi": { + "source": "iana", + "extensions": ["exi"] + }, + "application/fastinfoset": { + "source": "iana" + }, + "application/fastsoap": { + "source": "iana" + }, + "application/fdt+xml": { + "source": "iana", + "compressible": true + }, + "application/fhir+json": { + "source": "iana", + "compressible": true + }, + "application/fhir+xml": { + "source": "iana", + "compressible": true + }, + "application/fido.trusted-apps+json": { + "compressible": true + }, + "application/fits": { + "source": "iana" + }, + "application/font-sfnt": { + "source": "iana" + }, + "application/font-tdpfr": { + "source": "iana", + "extensions": ["pfr"] + }, + "application/font-woff": { + "source": "iana", + "compressible": false + }, + "application/framework-attributes+xml": { + "source": "iana", + "compressible": true + }, + "application/geo+json": { + "source": "iana", + "compressible": true, + "extensions": ["geojson"] + }, + "application/geo+json-seq": { + "source": "iana" + }, + "application/geopackage+sqlite3": { + "source": "iana" + }, + "application/geoxacml+xml": { + "source": "iana", + "compressible": true + }, + "application/gltf-buffer": { + "source": "iana" + }, + "application/gml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["gml"] + }, + "application/gpx+xml": { + "source": "apache", + "compressible": true, + "extensions": ["gpx"] + }, + "application/gxf": { + "source": "apache", + "extensions": ["gxf"] + }, + "application/gzip": { + "source": "iana", + "compressible": false, + "extensions": ["gz"] + }, + "application/h224": { + "source": "iana" + }, + "application/held+xml": { + "source": "iana", + "compressible": true + }, + "application/hjson": { + "extensions": ["hjson"] + }, + "application/http": { + "source": "iana" + }, + "application/hyperstudio": { + "source": "iana", + "extensions": ["stk"] + }, + "application/ibe-key-request+xml": { + "source": "iana", + "compressible": true + }, + "application/ibe-pkg-reply+xml": { + "source": "iana", + "compressible": true + }, + "application/ibe-pp-data": { + "source": "iana" + }, + "application/iges": { + "source": "iana" + }, + "application/im-iscomposing+xml": { + "source": "iana", + "compressible": true + }, + "application/index": { + "source": "iana" + }, + "application/index.cmd": { + "source": "iana" + }, + "application/index.obj": { + "source": "iana" + }, + "application/index.response": { + "source": "iana" + }, + "application/index.vnd": { + "source": "iana" + }, + "application/inkml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["ink","inkml"] + }, + "application/iotp": { + "source": "iana" + }, + "application/ipfix": { + "source": "iana", + "extensions": ["ipfix"] + }, + "application/ipp": { + "source": "iana" + }, + "application/isup": { + "source": "iana" + }, + "application/its+xml": { + "source": "iana", + "compressible": true + }, + "application/java-archive": { + "source": "apache", + "compressible": false, + "extensions": ["jar","war","ear"] + }, + "application/java-serialized-object": { + "source": "apache", + "compressible": false, + "extensions": ["ser"] + }, + "application/java-vm": { + "source": "apache", + "compressible": false, + "extensions": ["class"] + }, + "application/javascript": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["js","mjs"] + }, + "application/jf2feed+json": { + "source": "iana", + "compressible": true + }, + "application/jose": { + "source": "iana" + }, + "application/jose+json": { + "source": "iana", + "compressible": true + }, + "application/jrd+json": { + "source": "iana", + "compressible": true + }, + "application/json": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["json","map"] + }, + "application/json-patch+json": { + "source": "iana", + "compressible": true + }, + "application/json-seq": { + "source": "iana" + }, + "application/json5": { + "extensions": ["json5"] + }, + "application/jsonml+json": { + "source": "apache", + "compressible": true, + "extensions": ["jsonml"] + }, + "application/jwk+json": { + "source": "iana", + "compressible": true + }, + "application/jwk-set+json": { + "source": "iana", + "compressible": true + }, + "application/jwt": { + "source": "iana" + }, + "application/kpml-request+xml": { + "source": "iana", + "compressible": true + }, + "application/kpml-response+xml": { + "source": "iana", + "compressible": true + }, + "application/ld+json": { + "source": "iana", + "compressible": true, + "extensions": ["jsonld"] + }, + "application/lgr+xml": { + "source": "iana", + "compressible": true + }, + "application/link-format": { + "source": "iana" + }, + "application/load-control+xml": { + "source": "iana", + "compressible": true + }, + "application/lost+xml": { + "source": "iana", + "compressible": true, + "extensions": ["lostxml"] + }, + "application/lostsync+xml": { + "source": "iana", + "compressible": true + }, + "application/lxf": { + "source": "iana" + }, + "application/mac-binhex40": { + "source": "iana", + "extensions": ["hqx"] + }, + "application/mac-compactpro": { + "source": "apache", + "extensions": ["cpt"] + }, + "application/macwriteii": { + "source": "iana" + }, + "application/mads+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mads"] + }, + "application/manifest+json": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["webmanifest"] + }, + "application/marc": { + "source": "iana", + "extensions": ["mrc"] + }, + "application/marcxml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mrcx"] + }, + "application/mathematica": { + "source": "iana", + "extensions": ["ma","nb","mb"] + }, + "application/mathml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mathml"] + }, + "application/mathml-content+xml": { + "source": "iana", + "compressible": true + }, + "application/mathml-presentation+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-associated-procedure-description+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-deregister+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-envelope+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-msk+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-msk-response+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-protection-description+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-reception-report+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-register+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-register-response+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-schedule+xml": { + "source": "iana", + "compressible": true + }, + "application/mbms-user-service-description+xml": { + "source": "iana", + "compressible": true + }, + "application/mbox": { + "source": "iana", + "extensions": ["mbox"] + }, + "application/media-policy-dataset+xml": { + "source": "iana", + "compressible": true + }, + "application/media_control+xml": { + "source": "iana", + "compressible": true + }, + "application/mediaservercontrol+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mscml"] + }, + "application/merge-patch+json": { + "source": "iana", + "compressible": true + }, + "application/metalink+xml": { + "source": "apache", + "compressible": true, + "extensions": ["metalink"] + }, + "application/metalink4+xml": { + "source": "iana", + "compressible": true, + "extensions": ["meta4"] + }, + "application/mets+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mets"] + }, + "application/mf4": { + "source": "iana" + }, + "application/mikey": { + "source": "iana" + }, + "application/mmt-usd+xml": { + "source": "iana", + "compressible": true + }, + "application/mods+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mods"] + }, + "application/moss-keys": { + "source": "iana" + }, + "application/moss-signature": { + "source": "iana" + }, + "application/mosskey-data": { + "source": "iana" + }, + "application/mosskey-request": { + "source": "iana" + }, + "application/mp21": { + "source": "iana", + "extensions": ["m21","mp21"] + }, + "application/mp4": { + "source": "iana", + "extensions": ["mp4s","m4p"] + }, + "application/mpeg4-generic": { + "source": "iana" + }, + "application/mpeg4-iod": { + "source": "iana" + }, + "application/mpeg4-iod-xmt": { + "source": "iana" + }, + "application/mrb-consumer+xml": { + "source": "iana", + "compressible": true + }, + "application/mrb-publish+xml": { + "source": "iana", + "compressible": true + }, + "application/msc-ivr+xml": { + "source": "iana", + "compressible": true + }, + "application/msc-mixer+xml": { + "source": "iana", + "compressible": true + }, + "application/msword": { + "source": "iana", + "compressible": false, + "extensions": ["doc","dot"] + }, + "application/mud+json": { + "source": "iana", + "compressible": true + }, + "application/mxf": { + "source": "iana", + "extensions": ["mxf"] + }, + "application/n-quads": { + "source": "iana" + }, + "application/n-triples": { + "source": "iana" + }, + "application/nasdata": { + "source": "iana" + }, + "application/news-checkgroups": { + "source": "iana" + }, + "application/news-groupinfo": { + "source": "iana" + }, + "application/news-transmission": { + "source": "iana" + }, + "application/nlsml+xml": { + "source": "iana", + "compressible": true + }, + "application/node": { + "source": "iana" + }, + "application/nss": { + "source": "iana" + }, + "application/ocsp-request": { + "source": "iana" + }, + "application/ocsp-response": { + "source": "iana" + }, + "application/octet-stream": { + "source": "iana", + "compressible": false, + "extensions": ["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"] + }, + "application/oda": { + "source": "iana", + "extensions": ["oda"] + }, + "application/odx": { + "source": "iana" + }, + "application/oebps-package+xml": { + "source": "iana", + "compressible": true, + "extensions": ["opf"] + }, + "application/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["ogx"] + }, + "application/omdoc+xml": { + "source": "apache", + "compressible": true, + "extensions": ["omdoc"] + }, + "application/onenote": { + "source": "apache", + "extensions": ["onetoc","onetoc2","onetmp","onepkg"] + }, + "application/oxps": { + "source": "iana", + "extensions": ["oxps"] + }, + "application/p2p-overlay+xml": { + "source": "iana", + "compressible": true + }, + "application/parityfec": { + "source": "iana" + }, + "application/passport": { + "source": "iana" + }, + "application/patch-ops-error+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xer"] + }, + "application/pdf": { + "source": "iana", + "compressible": false, + "extensions": ["pdf"] + }, + "application/pdx": { + "source": "iana" + }, + "application/pgp-encrypted": { + "source": "iana", + "compressible": false, + "extensions": ["pgp"] + }, + "application/pgp-keys": { + "source": "iana" + }, + "application/pgp-signature": { + "source": "iana", + "extensions": ["asc","sig"] + }, + "application/pics-rules": { + "source": "apache", + "extensions": ["prf"] + }, + "application/pidf+xml": { + "source": "iana", + "compressible": true + }, + "application/pidf-diff+xml": { + "source": "iana", + "compressible": true + }, + "application/pkcs10": { + "source": "iana", + "extensions": ["p10"] + }, + "application/pkcs12": { + "source": "iana" + }, + "application/pkcs7-mime": { + "source": "iana", + "extensions": ["p7m","p7c"] + }, + "application/pkcs7-signature": { + "source": "iana", + "extensions": ["p7s"] + }, + "application/pkcs8": { + "source": "iana", + "extensions": ["p8"] + }, + "application/pkcs8-encrypted": { + "source": "iana" + }, + "application/pkix-attr-cert": { + "source": "iana", + "extensions": ["ac"] + }, + "application/pkix-cert": { + "source": "iana", + "extensions": ["cer"] + }, + "application/pkix-crl": { + "source": "iana", + "extensions": ["crl"] + }, + "application/pkix-pkipath": { + "source": "iana", + "extensions": ["pkipath"] + }, + "application/pkixcmp": { + "source": "iana", + "extensions": ["pki"] + }, + "application/pls+xml": { + "source": "iana", + "compressible": true, + "extensions": ["pls"] + }, + "application/poc-settings+xml": { + "source": "iana", + "compressible": true + }, + "application/postscript": { + "source": "iana", + "compressible": true, + "extensions": ["ai","eps","ps"] + }, + "application/ppsp-tracker+json": { + "source": "iana", + "compressible": true + }, + "application/problem+json": { + "source": "iana", + "compressible": true + }, + "application/problem+xml": { + "source": "iana", + "compressible": true + }, + "application/provenance+xml": { + "source": "iana", + "compressible": true + }, + "application/prs.alvestrand.titrax-sheet": { + "source": "iana" + }, + "application/prs.cww": { + "source": "iana", + "extensions": ["cww"] + }, + "application/prs.hpub+zip": { + "source": "iana", + "compressible": false + }, + "application/prs.nprend": { + "source": "iana" + }, + "application/prs.plucker": { + "source": "iana" + }, + "application/prs.rdf-xml-crypt": { + "source": "iana" + }, + "application/prs.xsf+xml": { + "source": "iana", + "compressible": true + }, + "application/pskc+xml": { + "source": "iana", + "compressible": true, + "extensions": ["pskcxml"] + }, + "application/qsig": { + "source": "iana" + }, + "application/raml+yaml": { + "compressible": true, + "extensions": ["raml"] + }, + "application/raptorfec": { + "source": "iana" + }, + "application/rdap+json": { + "source": "iana", + "compressible": true + }, + "application/rdf+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rdf","owl"] + }, + "application/reginfo+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rif"] + }, + "application/relax-ng-compact-syntax": { + "source": "iana", + "extensions": ["rnc"] + }, + "application/remote-printing": { + "source": "iana" + }, + "application/reputon+json": { + "source": "iana", + "compressible": true + }, + "application/resource-lists+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rl"] + }, + "application/resource-lists-diff+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rld"] + }, + "application/rfc+xml": { + "source": "iana", + "compressible": true + }, + "application/riscos": { + "source": "iana" + }, + "application/rlmi+xml": { + "source": "iana", + "compressible": true + }, + "application/rls-services+xml": { + "source": "iana", + "compressible": true, + "extensions": ["rs"] + }, + "application/route-apd+xml": { + "source": "iana", + "compressible": true + }, + "application/route-s-tsid+xml": { + "source": "iana", + "compressible": true + }, + "application/route-usd+xml": { + "source": "iana", + "compressible": true + }, + "application/rpki-ghostbusters": { + "source": "iana", + "extensions": ["gbr"] + }, + "application/rpki-manifest": { + "source": "iana", + "extensions": ["mft"] + }, + "application/rpki-publication": { + "source": "iana" + }, + "application/rpki-roa": { + "source": "iana", + "extensions": ["roa"] + }, + "application/rpki-updown": { + "source": "iana" + }, + "application/rsd+xml": { + "source": "apache", + "compressible": true, + "extensions": ["rsd"] + }, + "application/rss+xml": { + "source": "apache", + "compressible": true, + "extensions": ["rss"] + }, + "application/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "application/rtploopback": { + "source": "iana" + }, + "application/rtx": { + "source": "iana" + }, + "application/samlassertion+xml": { + "source": "iana", + "compressible": true + }, + "application/samlmetadata+xml": { + "source": "iana", + "compressible": true + }, + "application/sbml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["sbml"] + }, + "application/scaip+xml": { + "source": "iana", + "compressible": true + }, + "application/scim+json": { + "source": "iana", + "compressible": true + }, + "application/scvp-cv-request": { + "source": "iana", + "extensions": ["scq"] + }, + "application/scvp-cv-response": { + "source": "iana", + "extensions": ["scs"] + }, + "application/scvp-vp-request": { + "source": "iana", + "extensions": ["spq"] + }, + "application/scvp-vp-response": { + "source": "iana", + "extensions": ["spp"] + }, + "application/sdp": { + "source": "iana", + "extensions": ["sdp"] + }, + "application/secevent+jwt": { + "source": "iana" + }, + "application/senml+cbor": { + "source": "iana" + }, + "application/senml+json": { + "source": "iana", + "compressible": true + }, + "application/senml+xml": { + "source": "iana", + "compressible": true + }, + "application/senml-exi": { + "source": "iana" + }, + "application/sensml+cbor": { + "source": "iana" + }, + "application/sensml+json": { + "source": "iana", + "compressible": true + }, + "application/sensml+xml": { + "source": "iana", + "compressible": true + }, + "application/sensml-exi": { + "source": "iana" + }, + "application/sep+xml": { + "source": "iana", + "compressible": true + }, + "application/sep-exi": { + "source": "iana" + }, + "application/session-info": { + "source": "iana" + }, + "application/set-payment": { + "source": "iana" + }, + "application/set-payment-initiation": { + "source": "iana", + "extensions": ["setpay"] + }, + "application/set-registration": { + "source": "iana" + }, + "application/set-registration-initiation": { + "source": "iana", + "extensions": ["setreg"] + }, + "application/sgml": { + "source": "iana" + }, + "application/sgml-open-catalog": { + "source": "iana" + }, + "application/shf+xml": { + "source": "iana", + "compressible": true, + "extensions": ["shf"] + }, + "application/sieve": { + "source": "iana" + }, + "application/simple-filter+xml": { + "source": "iana", + "compressible": true + }, + "application/simple-message-summary": { + "source": "iana" + }, + "application/simplesymbolcontainer": { + "source": "iana" + }, + "application/slate": { + "source": "iana" + }, + "application/smil": { + "source": "iana" + }, + "application/smil+xml": { + "source": "iana", + "compressible": true, + "extensions": ["smi","smil"] + }, + "application/smpte336m": { + "source": "iana" + }, + "application/soap+fastinfoset": { + "source": "iana" + }, + "application/soap+xml": { + "source": "iana", + "compressible": true + }, + "application/sparql-query": { + "source": "iana", + "extensions": ["rq"] + }, + "application/sparql-results+xml": { + "source": "iana", + "compressible": true, + "extensions": ["srx"] + }, + "application/spirits-event+xml": { + "source": "iana", + "compressible": true + }, + "application/sql": { + "source": "iana" + }, + "application/srgs": { + "source": "iana", + "extensions": ["gram"] + }, + "application/srgs+xml": { + "source": "iana", + "compressible": true, + "extensions": ["grxml"] + }, + "application/sru+xml": { + "source": "iana", + "compressible": true, + "extensions": ["sru"] + }, + "application/ssdl+xml": { + "source": "apache", + "compressible": true, + "extensions": ["ssdl"] + }, + "application/ssml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["ssml"] + }, + "application/stix+json": { + "source": "iana", + "compressible": true + }, + "application/tamp-apex-update": { + "source": "iana" + }, + "application/tamp-apex-update-confirm": { + "source": "iana" + }, + "application/tamp-community-update": { + "source": "iana" + }, + "application/tamp-community-update-confirm": { + "source": "iana" + }, + "application/tamp-error": { + "source": "iana" + }, + "application/tamp-sequence-adjust": { + "source": "iana" + }, + "application/tamp-sequence-adjust-confirm": { + "source": "iana" + }, + "application/tamp-status-query": { + "source": "iana" + }, + "application/tamp-status-response": { + "source": "iana" + }, + "application/tamp-update": { + "source": "iana" + }, + "application/tamp-update-confirm": { + "source": "iana" + }, + "application/tar": { + "compressible": true + }, + "application/taxii+json": { + "source": "iana", + "compressible": true + }, + "application/tei+xml": { + "source": "iana", + "compressible": true, + "extensions": ["tei","teicorpus"] + }, + "application/thraud+xml": { + "source": "iana", + "compressible": true, + "extensions": ["tfi"] + }, + "application/timestamp-query": { + "source": "iana" + }, + "application/timestamp-reply": { + "source": "iana" + }, + "application/timestamped-data": { + "source": "iana", + "extensions": ["tsd"] + }, + "application/tlsrpt+gzip": { + "source": "iana" + }, + "application/tlsrpt+json": { + "source": "iana", + "compressible": true + }, + "application/tnauthlist": { + "source": "iana" + }, + "application/trickle-ice-sdpfrag": { + "source": "iana" + }, + "application/trig": { + "source": "iana" + }, + "application/ttml+xml": { + "source": "iana", + "compressible": true + }, + "application/tve-trigger": { + "source": "iana" + }, + "application/ulpfec": { + "source": "iana" + }, + "application/urc-grpsheet+xml": { + "source": "iana", + "compressible": true + }, + "application/urc-ressheet+xml": { + "source": "iana", + "compressible": true + }, + "application/urc-targetdesc+xml": { + "source": "iana", + "compressible": true + }, + "application/urc-uisocketdesc+xml": { + "source": "iana", + "compressible": true + }, + "application/vcard+json": { + "source": "iana", + "compressible": true + }, + "application/vcard+xml": { + "source": "iana", + "compressible": true + }, + "application/vemmi": { + "source": "iana" + }, + "application/vividence.scriptfile": { + "source": "apache" + }, + "application/vnd.1000minds.decision-model+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp-prose+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp-prose-pc3ch+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp-v2x-local-service-information": { + "source": "iana" + }, + "application/vnd.3gpp.access-transfer-events+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.bsf+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.gmop+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mc-signalling-ear": { + "source": "iana" + }, + "application/vnd.3gpp.mcdata-payload": { + "source": "iana" + }, + "application/vnd.3gpp.mcdata-signalling": { + "source": "iana" + }, + "application/vnd.3gpp.mcptt-affiliation-command+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mcptt-floor-request+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mcptt-info+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mcptt-location-info+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mcptt-mbms-usage-info+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mcptt-signed+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.mid-call+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.pic-bw-large": { + "source": "iana", + "extensions": ["plb"] + }, + "application/vnd.3gpp.pic-bw-small": { + "source": "iana", + "extensions": ["psb"] + }, + "application/vnd.3gpp.pic-bw-var": { + "source": "iana", + "extensions": ["pvb"] + }, + "application/vnd.3gpp.sms": { + "source": "iana" + }, + "application/vnd.3gpp.sms+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.srvcc-ext+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.srvcc-info+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.state-and-event-info+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp.ussd+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp2.bcmcsinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.3gpp2.sms": { + "source": "iana" + }, + "application/vnd.3gpp2.tcap": { + "source": "iana", + "extensions": ["tcap"] + }, + "application/vnd.3lightssoftware.imagescal": { + "source": "iana" + }, + "application/vnd.3m.post-it-notes": { + "source": "iana", + "extensions": ["pwn"] + }, + "application/vnd.accpac.simply.aso": { + "source": "iana", + "extensions": ["aso"] + }, + "application/vnd.accpac.simply.imp": { + "source": "iana", + "extensions": ["imp"] + }, + "application/vnd.acucobol": { + "source": "iana", + "extensions": ["acu"] + }, + "application/vnd.acucorp": { + "source": "iana", + "extensions": ["atc","acutc"] + }, + "application/vnd.adobe.air-application-installer-package+zip": { + "source": "apache", + "compressible": false, + "extensions": ["air"] + }, + "application/vnd.adobe.flash.movie": { + "source": "iana" + }, + "application/vnd.adobe.formscentral.fcdt": { + "source": "iana", + "extensions": ["fcdt"] + }, + "application/vnd.adobe.fxp": { + "source": "iana", + "extensions": ["fxp","fxpl"] + }, + "application/vnd.adobe.partial-upload": { + "source": "iana" + }, + "application/vnd.adobe.xdp+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xdp"] + }, + "application/vnd.adobe.xfdf": { + "source": "iana", + "extensions": ["xfdf"] + }, + "application/vnd.aether.imp": { + "source": "iana" + }, + "application/vnd.afpc.afplinedata": { + "source": "iana" + }, + "application/vnd.afpc.modca": { + "source": "iana" + }, + "application/vnd.ah-barcode": { + "source": "iana" + }, + "application/vnd.ahead.space": { + "source": "iana", + "extensions": ["ahead"] + }, + "application/vnd.airzip.filesecure.azf": { + "source": "iana", + "extensions": ["azf"] + }, + "application/vnd.airzip.filesecure.azs": { + "source": "iana", + "extensions": ["azs"] + }, + "application/vnd.amadeus+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.amazon.ebook": { + "source": "apache", + "extensions": ["azw"] + }, + "application/vnd.amazon.mobi8-ebook": { + "source": "iana" + }, + "application/vnd.americandynamics.acc": { + "source": "iana", + "extensions": ["acc"] + }, + "application/vnd.amiga.ami": { + "source": "iana", + "extensions": ["ami"] + }, + "application/vnd.amundsen.maze+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.android.package-archive": { + "source": "apache", + "compressible": false, + "extensions": ["apk"] + }, + "application/vnd.anki": { + "source": "iana" + }, + "application/vnd.anser-web-certificate-issue-initiation": { + "source": "iana", + "extensions": ["cii"] + }, + "application/vnd.anser-web-funds-transfer-initiation": { + "source": "apache", + "extensions": ["fti"] + }, + "application/vnd.antix.game-component": { + "source": "iana", + "extensions": ["atx"] + }, + "application/vnd.apache.thrift.binary": { + "source": "iana" + }, + "application/vnd.apache.thrift.compact": { + "source": "iana" + }, + "application/vnd.apache.thrift.json": { + "source": "iana" + }, + "application/vnd.api+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.apothekende.reservation+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.apple.installer+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mpkg"] + }, + "application/vnd.apple.keynote": { + "source": "iana", + "extensions": ["keynote"] + }, + "application/vnd.apple.mpegurl": { + "source": "iana", + "extensions": ["m3u8"] + }, + "application/vnd.apple.numbers": { + "source": "iana", + "extensions": ["numbers"] + }, + "application/vnd.apple.pages": { + "source": "iana", + "extensions": ["pages"] + }, + "application/vnd.apple.pkpass": { + "compressible": false, + "extensions": ["pkpass"] + }, + "application/vnd.arastra.swi": { + "source": "iana" + }, + "application/vnd.aristanetworks.swi": { + "source": "iana", + "extensions": ["swi"] + }, + "application/vnd.artisan+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.artsquare": { + "source": "iana" + }, + "application/vnd.astraea-software.iota": { + "source": "iana", + "extensions": ["iota"] + }, + "application/vnd.audiograph": { + "source": "iana", + "extensions": ["aep"] + }, + "application/vnd.autopackage": { + "source": "iana" + }, + "application/vnd.avalon+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.avistar+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.balsamiq.bmml+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.balsamiq.bmpr": { + "source": "iana" + }, + "application/vnd.banana-accounting": { + "source": "iana" + }, + "application/vnd.bbf.usp.msg": { + "source": "iana" + }, + "application/vnd.bbf.usp.msg+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.bekitzur-stech+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.bint.med-content": { + "source": "iana" + }, + "application/vnd.biopax.rdf+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.blink-idb-value-wrapper": { + "source": "iana" + }, + "application/vnd.blueice.multipass": { + "source": "iana", + "extensions": ["mpm"] + }, + "application/vnd.bluetooth.ep.oob": { + "source": "iana" + }, + "application/vnd.bluetooth.le.oob": { + "source": "iana" + }, + "application/vnd.bmi": { + "source": "iana", + "extensions": ["bmi"] + }, + "application/vnd.businessobjects": { + "source": "iana", + "extensions": ["rep"] + }, + "application/vnd.byu.uapi+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.cab-jscript": { + "source": "iana" + }, + "application/vnd.canon-cpdl": { + "source": "iana" + }, + "application/vnd.canon-lips": { + "source": "iana" + }, + "application/vnd.capasystems-pg+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.cendio.thinlinc.clientconf": { + "source": "iana" + }, + "application/vnd.century-systems.tcp_stream": { + "source": "iana" + }, + "application/vnd.chemdraw+xml": { + "source": "iana", + "compressible": true, + "extensions": ["cdxml"] + }, + "application/vnd.chess-pgn": { + "source": "iana" + }, + "application/vnd.chipnuts.karaoke-mmd": { + "source": "iana", + "extensions": ["mmd"] + }, + "application/vnd.cinderella": { + "source": "iana", + "extensions": ["cdy"] + }, + "application/vnd.cirpack.isdn-ext": { + "source": "iana" + }, + "application/vnd.citationstyles.style+xml": { + "source": "iana", + "compressible": true, + "extensions": ["csl"] + }, + "application/vnd.claymore": { + "source": "iana", + "extensions": ["cla"] + }, + "application/vnd.cloanto.rp9": { + "source": "iana", + "extensions": ["rp9"] + }, + "application/vnd.clonk.c4group": { + "source": "iana", + "extensions": ["c4g","c4d","c4f","c4p","c4u"] + }, + "application/vnd.cluetrust.cartomobile-config": { + "source": "iana", + "extensions": ["c11amc"] + }, + "application/vnd.cluetrust.cartomobile-config-pkg": { + "source": "iana", + "extensions": ["c11amz"] + }, + "application/vnd.coffeescript": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.document": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.document-template": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.presentation": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.presentation-template": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.spreadsheet": { + "source": "iana" + }, + "application/vnd.collabio.xodocuments.spreadsheet-template": { + "source": "iana" + }, + "application/vnd.collection+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.doc+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.collection.next+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.comicbook+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.comicbook-rar": { + "source": "iana" + }, + "application/vnd.commerce-battelle": { + "source": "iana" + }, + "application/vnd.commonspace": { + "source": "iana", + "extensions": ["csp"] + }, + "application/vnd.contact.cmsg": { + "source": "iana", + "extensions": ["cdbcmsg"] + }, + "application/vnd.coreos.ignition+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.cosmocaller": { + "source": "iana", + "extensions": ["cmc"] + }, + "application/vnd.crick.clicker": { + "source": "iana", + "extensions": ["clkx"] + }, + "application/vnd.crick.clicker.keyboard": { + "source": "iana", + "extensions": ["clkk"] + }, + "application/vnd.crick.clicker.palette": { + "source": "iana", + "extensions": ["clkp"] + }, + "application/vnd.crick.clicker.template": { + "source": "iana", + "extensions": ["clkt"] + }, + "application/vnd.crick.clicker.wordbank": { + "source": "iana", + "extensions": ["clkw"] + }, + "application/vnd.criticaltools.wbs+xml": { + "source": "iana", + "compressible": true, + "extensions": ["wbs"] + }, + "application/vnd.ctc-posml": { + "source": "iana", + "extensions": ["pml"] + }, + "application/vnd.ctct.ws+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.cups-pdf": { + "source": "iana" + }, + "application/vnd.cups-postscript": { + "source": "iana" + }, + "application/vnd.cups-ppd": { + "source": "iana", + "extensions": ["ppd"] + }, + "application/vnd.cups-raster": { + "source": "iana" + }, + "application/vnd.cups-raw": { + "source": "iana" + }, + "application/vnd.curl": { + "source": "iana" + }, + "application/vnd.curl.car": { + "source": "apache", + "extensions": ["car"] + }, + "application/vnd.curl.pcurl": { + "source": "apache", + "extensions": ["pcurl"] + }, + "application/vnd.cyan.dean.root+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.cybank": { + "source": "iana" + }, + "application/vnd.d2l.coursepackage1p0+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.dart": { + "source": "iana", + "compressible": true, + "extensions": ["dart"] + }, + "application/vnd.data-vision.rdz": { + "source": "iana", + "extensions": ["rdz"] + }, + "application/vnd.datapackage+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.dataresource+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.debian.binary-package": { + "source": "iana" + }, + "application/vnd.dece.data": { + "source": "iana", + "extensions": ["uvf","uvvf","uvd","uvvd"] + }, + "application/vnd.dece.ttml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["uvt","uvvt"] + }, + "application/vnd.dece.unspecified": { + "source": "iana", + "extensions": ["uvx","uvvx"] + }, + "application/vnd.dece.zip": { + "source": "iana", + "extensions": ["uvz","uvvz"] + }, + "application/vnd.denovo.fcselayout-link": { + "source": "iana", + "extensions": ["fe_launch"] + }, + "application/vnd.desmume.movie": { + "source": "iana" + }, + "application/vnd.dir-bi.plate-dl-nosuffix": { + "source": "iana" + }, + "application/vnd.dm.delegation+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dna": { + "source": "iana", + "extensions": ["dna"] + }, + "application/vnd.document+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.dolby.mlp": { + "source": "apache", + "extensions": ["mlp"] + }, + "application/vnd.dolby.mobile.1": { + "source": "iana" + }, + "application/vnd.dolby.mobile.2": { + "source": "iana" + }, + "application/vnd.doremir.scorecloud-binary-document": { + "source": "iana" + }, + "application/vnd.dpgraph": { + "source": "iana", + "extensions": ["dpg"] + }, + "application/vnd.dreamfactory": { + "source": "iana", + "extensions": ["dfac"] + }, + "application/vnd.drive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ds-keypoint": { + "source": "apache", + "extensions": ["kpxx"] + }, + "application/vnd.dtg.local": { + "source": "iana" + }, + "application/vnd.dtg.local.flash": { + "source": "iana" + }, + "application/vnd.dtg.local.html": { + "source": "iana" + }, + "application/vnd.dvb.ait": { + "source": "iana", + "extensions": ["ait"] + }, + "application/vnd.dvb.dvbj": { + "source": "iana" + }, + "application/vnd.dvb.esgcontainer": { + "source": "iana" + }, + "application/vnd.dvb.ipdcdftnotifaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgaccess2": { + "source": "iana" + }, + "application/vnd.dvb.ipdcesgpdd": { + "source": "iana" + }, + "application/vnd.dvb.ipdcroaming": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-base": { + "source": "iana" + }, + "application/vnd.dvb.iptv.alfec-enhancement": { + "source": "iana" + }, + "application/vnd.dvb.notif-aggregate-root+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-container+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-generic+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-ia-msglist+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-ia-registration-request+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-ia-registration-response+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.notif-init+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.dvb.pfr": { + "source": "iana" + }, + "application/vnd.dvb.service": { + "source": "iana", + "extensions": ["svc"] + }, + "application/vnd.dxr": { + "source": "iana" + }, + "application/vnd.dynageo": { + "source": "iana", + "extensions": ["geo"] + }, + "application/vnd.dzr": { + "source": "iana" + }, + "application/vnd.easykaraoke.cdgdownload": { + "source": "iana" + }, + "application/vnd.ecdis-update": { + "source": "iana" + }, + "application/vnd.ecip.rlp": { + "source": "iana" + }, + "application/vnd.ecowin.chart": { + "source": "iana", + "extensions": ["mag"] + }, + "application/vnd.ecowin.filerequest": { + "source": "iana" + }, + "application/vnd.ecowin.fileupdate": { + "source": "iana" + }, + "application/vnd.ecowin.series": { + "source": "iana" + }, + "application/vnd.ecowin.seriesrequest": { + "source": "iana" + }, + "application/vnd.ecowin.seriesupdate": { + "source": "iana" + }, + "application/vnd.efi.img": { + "source": "iana" + }, + "application/vnd.efi.iso": { + "source": "iana" + }, + "application/vnd.emclient.accessrequest+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.enliven": { + "source": "iana", + "extensions": ["nml"] + }, + "application/vnd.enphase.envoy": { + "source": "iana" + }, + "application/vnd.eprints.data+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.epson.esf": { + "source": "iana", + "extensions": ["esf"] + }, + "application/vnd.epson.msf": { + "source": "iana", + "extensions": ["msf"] + }, + "application/vnd.epson.quickanime": { + "source": "iana", + "extensions": ["qam"] + }, + "application/vnd.epson.salt": { + "source": "iana", + "extensions": ["slt"] + }, + "application/vnd.epson.ssf": { + "source": "iana", + "extensions": ["ssf"] + }, + "application/vnd.ericsson.quickcall": { + "source": "iana" + }, + "application/vnd.espass-espass+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.eszigno3+xml": { + "source": "iana", + "compressible": true, + "extensions": ["es3","et3"] + }, + "application/vnd.etsi.aoc+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.asic-e+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.etsi.asic-s+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.etsi.cug+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvcommand+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvdiscovery+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvprofile+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvsad-bc+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvsad-cod+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvsad-npvr+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvservice+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvsync+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.iptvueprofile+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.mcid+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.mheg5": { + "source": "iana" + }, + "application/vnd.etsi.overload-control-policy-dataset+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.pstn+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.sci+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.simservs+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.timestamp-token": { + "source": "iana" + }, + "application/vnd.etsi.tsl+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.etsi.tsl.der": { + "source": "iana" + }, + "application/vnd.eudora.data": { + "source": "iana" + }, + "application/vnd.evolv.ecig.profile": { + "source": "iana" + }, + "application/vnd.evolv.ecig.settings": { + "source": "iana" + }, + "application/vnd.evolv.ecig.theme": { + "source": "iana" + }, + "application/vnd.ezpix-album": { + "source": "iana", + "extensions": ["ez2"] + }, + "application/vnd.ezpix-package": { + "source": "iana", + "extensions": ["ez3"] + }, + "application/vnd.f-secure.mobile": { + "source": "iana" + }, + "application/vnd.fastcopy-disk-image": { + "source": "iana" + }, + "application/vnd.fdf": { + "source": "iana", + "extensions": ["fdf"] + }, + "application/vnd.fdsn.mseed": { + "source": "iana", + "extensions": ["mseed"] + }, + "application/vnd.fdsn.seed": { + "source": "iana", + "extensions": ["seed","dataless"] + }, + "application/vnd.ffsns": { + "source": "iana" + }, + "application/vnd.filmit.zfc": { + "source": "iana" + }, + "application/vnd.fints": { + "source": "iana" + }, + "application/vnd.firemonkeys.cloudcell": { + "source": "iana" + }, + "application/vnd.flographit": { + "source": "iana", + "extensions": ["gph"] + }, + "application/vnd.fluxtime.clip": { + "source": "iana", + "extensions": ["ftc"] + }, + "application/vnd.font-fontforge-sfd": { + "source": "iana" + }, + "application/vnd.framemaker": { + "source": "iana", + "extensions": ["fm","frame","maker","book"] + }, + "application/vnd.frogans.fnc": { + "source": "iana", + "extensions": ["fnc"] + }, + "application/vnd.frogans.ltf": { + "source": "iana", + "extensions": ["ltf"] + }, + "application/vnd.fsc.weblaunch": { + "source": "iana", + "extensions": ["fsc"] + }, + "application/vnd.fujitsu.oasys": { + "source": "iana", + "extensions": ["oas"] + }, + "application/vnd.fujitsu.oasys2": { + "source": "iana", + "extensions": ["oa2"] + }, + "application/vnd.fujitsu.oasys3": { + "source": "iana", + "extensions": ["oa3"] + }, + "application/vnd.fujitsu.oasysgp": { + "source": "iana", + "extensions": ["fg5"] + }, + "application/vnd.fujitsu.oasysprs": { + "source": "iana", + "extensions": ["bh2"] + }, + "application/vnd.fujixerox.art-ex": { + "source": "iana" + }, + "application/vnd.fujixerox.art4": { + "source": "iana" + }, + "application/vnd.fujixerox.ddd": { + "source": "iana", + "extensions": ["ddd"] + }, + "application/vnd.fujixerox.docuworks": { + "source": "iana", + "extensions": ["xdw"] + }, + "application/vnd.fujixerox.docuworks.binder": { + "source": "iana", + "extensions": ["xbd"] + }, + "application/vnd.fujixerox.docuworks.container": { + "source": "iana" + }, + "application/vnd.fujixerox.hbpl": { + "source": "iana" + }, + "application/vnd.fut-misnet": { + "source": "iana" + }, + "application/vnd.futoin+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.fuzzysheet": { + "source": "iana", + "extensions": ["fzs"] + }, + "application/vnd.genomatix.tuxedo": { + "source": "iana", + "extensions": ["txd"] + }, + "application/vnd.geo+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.geocube+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.geogebra.file": { + "source": "iana", + "extensions": ["ggb"] + }, + "application/vnd.geogebra.tool": { + "source": "iana", + "extensions": ["ggt"] + }, + "application/vnd.geometry-explorer": { + "source": "iana", + "extensions": ["gex","gre"] + }, + "application/vnd.geonext": { + "source": "iana", + "extensions": ["gxt"] + }, + "application/vnd.geoplan": { + "source": "iana", + "extensions": ["g2w"] + }, + "application/vnd.geospace": { + "source": "iana", + "extensions": ["g3w"] + }, + "application/vnd.gerber": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt": { + "source": "iana" + }, + "application/vnd.globalplatform.card-content-mgt-response": { + "source": "iana" + }, + "application/vnd.gmx": { + "source": "iana", + "extensions": ["gmx"] + }, + "application/vnd.google-apps.document": { + "compressible": false, + "extensions": ["gdoc"] + }, + "application/vnd.google-apps.presentation": { + "compressible": false, + "extensions": ["gslides"] + }, + "application/vnd.google-apps.spreadsheet": { + "compressible": false, + "extensions": ["gsheet"] + }, + "application/vnd.google-earth.kml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["kml"] + }, + "application/vnd.google-earth.kmz": { + "source": "iana", + "compressible": false, + "extensions": ["kmz"] + }, + "application/vnd.gov.sk.e-form+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.gov.sk.e-form+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.gov.sk.xmldatacontainer+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.grafeq": { + "source": "iana", + "extensions": ["gqf","gqs"] + }, + "application/vnd.gridmp": { + "source": "iana" + }, + "application/vnd.groove-account": { + "source": "iana", + "extensions": ["gac"] + }, + "application/vnd.groove-help": { + "source": "iana", + "extensions": ["ghf"] + }, + "application/vnd.groove-identity-message": { + "source": "iana", + "extensions": ["gim"] + }, + "application/vnd.groove-injector": { + "source": "iana", + "extensions": ["grv"] + }, + "application/vnd.groove-tool-message": { + "source": "iana", + "extensions": ["gtm"] + }, + "application/vnd.groove-tool-template": { + "source": "iana", + "extensions": ["tpl"] + }, + "application/vnd.groove-vcard": { + "source": "iana", + "extensions": ["vcg"] + }, + "application/vnd.hal+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hal+xml": { + "source": "iana", + "compressible": true, + "extensions": ["hal"] + }, + "application/vnd.handheld-entertainment+xml": { + "source": "iana", + "compressible": true, + "extensions": ["zmm"] + }, + "application/vnd.hbci": { + "source": "iana", + "extensions": ["hbci"] + }, + "application/vnd.hc+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hcl-bireports": { + "source": "iana" + }, + "application/vnd.hdt": { + "source": "iana" + }, + "application/vnd.heroku+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hhe.lesson-player": { + "source": "iana", + "extensions": ["les"] + }, + "application/vnd.hp-hpgl": { + "source": "iana", + "extensions": ["hpgl"] + }, + "application/vnd.hp-hpid": { + "source": "iana", + "extensions": ["hpid"] + }, + "application/vnd.hp-hps": { + "source": "iana", + "extensions": ["hps"] + }, + "application/vnd.hp-jlyt": { + "source": "iana", + "extensions": ["jlt"] + }, + "application/vnd.hp-pcl": { + "source": "iana", + "extensions": ["pcl"] + }, + "application/vnd.hp-pclxl": { + "source": "iana", + "extensions": ["pclxl"] + }, + "application/vnd.httphone": { + "source": "iana" + }, + "application/vnd.hydrostatix.sof-data": { + "source": "iana", + "extensions": ["sfd-hdstx"] + }, + "application/vnd.hyper+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hyper-item+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hyperdrive+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.hzn-3d-crossword": { + "source": "iana" + }, + "application/vnd.ibm.afplinedata": { + "source": "iana" + }, + "application/vnd.ibm.electronic-media": { + "source": "iana" + }, + "application/vnd.ibm.minipay": { + "source": "iana", + "extensions": ["mpy"] + }, + "application/vnd.ibm.modcap": { + "source": "iana", + "extensions": ["afp","listafp","list3820"] + }, + "application/vnd.ibm.rights-management": { + "source": "iana", + "extensions": ["irm"] + }, + "application/vnd.ibm.secure-container": { + "source": "iana", + "extensions": ["sc"] + }, + "application/vnd.iccprofile": { + "source": "iana", + "extensions": ["icc","icm"] + }, + "application/vnd.ieee.1905": { + "source": "iana" + }, + "application/vnd.igloader": { + "source": "iana", + "extensions": ["igl"] + }, + "application/vnd.imagemeter.folder+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.imagemeter.image+zip": { + "source": "iana", + "compressible": false + }, + "application/vnd.immervision-ivp": { + "source": "iana", + "extensions": ["ivp"] + }, + "application/vnd.immervision-ivu": { + "source": "iana", + "extensions": ["ivu"] + }, + "application/vnd.ims.imsccv1p1": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p2": { + "source": "iana" + }, + "application/vnd.ims.imsccv1p3": { + "source": "iana" + }, + "application/vnd.ims.lis.v2.result+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolconsumerprofile+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolproxy.id+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.ims.lti.v2.toolsettings.simple+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.informedcontrol.rms+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.informix-visionary": { + "source": "iana" + }, + "application/vnd.infotech.project": { + "source": "iana" + }, + "application/vnd.infotech.project+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.innopath.wamp.notification": { + "source": "iana" + }, + "application/vnd.insors.igm": { + "source": "iana", + "extensions": ["igm"] + }, + "application/vnd.intercon.formnet": { + "source": "iana", + "extensions": ["xpw","xpx"] + }, + "application/vnd.intergeo": { + "source": "iana", + "extensions": ["i2g"] + }, + "application/vnd.intertrust.digibox": { + "source": "iana" + }, + "application/vnd.intertrust.nncp": { + "source": "iana" + }, + "application/vnd.intu.qbo": { + "source": "iana", + "extensions": ["qbo"] + }, + "application/vnd.intu.qfx": { + "source": "iana", + "extensions": ["qfx"] + }, + "application/vnd.iptc.g2.catalogitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.conceptitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.knowledgeitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.newsitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.newsmessage+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.packageitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.iptc.g2.planningitem+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.ipunplugged.rcprofile": { + "source": "iana", + "extensions": ["rcprofile"] + }, + "application/vnd.irepository.package+xml": { + "source": "iana", + "compressible": true, + "extensions": ["irp"] + }, + "application/vnd.is-xpr": { + "source": "iana", + "extensions": ["xpr"] + }, + "application/vnd.isac.fcs": { + "source": "iana", + "extensions": ["fcs"] + }, + "application/vnd.jam": { + "source": "iana", + "extensions": ["jam"] + }, + "application/vnd.japannet-directory-service": { + "source": "iana" + }, + "application/vnd.japannet-jpnstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-payment-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-registration": { + "source": "iana" + }, + "application/vnd.japannet-registration-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-setstore-wakeup": { + "source": "iana" + }, + "application/vnd.japannet-verification": { + "source": "iana" + }, + "application/vnd.japannet-verification-wakeup": { + "source": "iana" + }, + "application/vnd.jcp.javame.midlet-rms": { + "source": "iana", + "extensions": ["rms"] + }, + "application/vnd.jisp": { + "source": "iana", + "extensions": ["jisp"] + }, + "application/vnd.joost.joda-archive": { + "source": "iana", + "extensions": ["joda"] + }, + "application/vnd.jsk.isdn-ngn": { + "source": "iana" + }, + "application/vnd.kahootz": { + "source": "iana", + "extensions": ["ktz","ktr"] + }, + "application/vnd.kde.karbon": { + "source": "iana", + "extensions": ["karbon"] + }, + "application/vnd.kde.kchart": { + "source": "iana", + "extensions": ["chrt"] + }, + "application/vnd.kde.kformula": { + "source": "iana", + "extensions": ["kfo"] + }, + "application/vnd.kde.kivio": { + "source": "iana", + "extensions": ["flw"] + }, + "application/vnd.kde.kontour": { + "source": "iana", + "extensions": ["kon"] + }, + "application/vnd.kde.kpresenter": { + "source": "iana", + "extensions": ["kpr","kpt"] + }, + "application/vnd.kde.kspread": { + "source": "iana", + "extensions": ["ksp"] + }, + "application/vnd.kde.kword": { + "source": "iana", + "extensions": ["kwd","kwt"] + }, + "application/vnd.kenameaapp": { + "source": "iana", + "extensions": ["htke"] + }, + "application/vnd.kidspiration": { + "source": "iana", + "extensions": ["kia"] + }, + "application/vnd.kinar": { + "source": "iana", + "extensions": ["kne","knp"] + }, + "application/vnd.koan": { + "source": "iana", + "extensions": ["skp","skd","skt","skm"] + }, + "application/vnd.kodak-descriptor": { + "source": "iana", + "extensions": ["sse"] + }, + "application/vnd.las.las+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.las.las+xml": { + "source": "iana", + "compressible": true, + "extensions": ["lasxml"] + }, + "application/vnd.leap+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.liberty-request+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.llamagraphics.life-balance.desktop": { + "source": "iana", + "extensions": ["lbd"] + }, + "application/vnd.llamagraphics.life-balance.exchange+xml": { + "source": "iana", + "compressible": true, + "extensions": ["lbe"] + }, + "application/vnd.lotus-1-2-3": { + "source": "iana", + "extensions": ["123"] + }, + "application/vnd.lotus-approach": { + "source": "iana", + "extensions": ["apr"] + }, + "application/vnd.lotus-freelance": { + "source": "iana", + "extensions": ["pre"] + }, + "application/vnd.lotus-notes": { + "source": "iana", + "extensions": ["nsf"] + }, + "application/vnd.lotus-organizer": { + "source": "iana", + "extensions": ["org"] + }, + "application/vnd.lotus-screencam": { + "source": "iana", + "extensions": ["scm"] + }, + "application/vnd.lotus-wordpro": { + "source": "iana", + "extensions": ["lwp"] + }, + "application/vnd.macports.portpkg": { + "source": "iana", + "extensions": ["portpkg"] + }, + "application/vnd.mapbox-vector-tile": { + "source": "iana" + }, + "application/vnd.marlin.drm.actiontoken+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.marlin.drm.conftoken+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.marlin.drm.license+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.marlin.drm.mdcf": { + "source": "iana" + }, + "application/vnd.mason+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.maxmind.maxmind-db": { + "source": "iana" + }, + "application/vnd.mcd": { + "source": "iana", + "extensions": ["mcd"] + }, + "application/vnd.medcalcdata": { + "source": "iana", + "extensions": ["mc1"] + }, + "application/vnd.mediastation.cdkey": { + "source": "iana", + "extensions": ["cdkey"] + }, + "application/vnd.meridian-slingshot": { + "source": "iana" + }, + "application/vnd.mfer": { + "source": "iana", + "extensions": ["mwf"] + }, + "application/vnd.mfmp": { + "source": "iana", + "extensions": ["mfm"] + }, + "application/vnd.micro+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.micrografx.flo": { + "source": "iana", + "extensions": ["flo"] + }, + "application/vnd.micrografx.igx": { + "source": "iana", + "extensions": ["igx"] + }, + "application/vnd.microsoft.portable-executable": { + "source": "iana" + }, + "application/vnd.microsoft.windows.thumbnail-cache": { + "source": "iana" + }, + "application/vnd.miele+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.mif": { + "source": "iana", + "extensions": ["mif"] + }, + "application/vnd.minisoft-hp3000-save": { + "source": "iana" + }, + "application/vnd.mitsubishi.misty-guard.trustweb": { + "source": "iana" + }, + "application/vnd.mobius.daf": { + "source": "iana", + "extensions": ["daf"] + }, + "application/vnd.mobius.dis": { + "source": "iana", + "extensions": ["dis"] + }, + "application/vnd.mobius.mbk": { + "source": "iana", + "extensions": ["mbk"] + }, + "application/vnd.mobius.mqy": { + "source": "iana", + "extensions": ["mqy"] + }, + "application/vnd.mobius.msl": { + "source": "iana", + "extensions": ["msl"] + }, + "application/vnd.mobius.plc": { + "source": "iana", + "extensions": ["plc"] + }, + "application/vnd.mobius.txf": { + "source": "iana", + "extensions": ["txf"] + }, + "application/vnd.mophun.application": { + "source": "iana", + "extensions": ["mpn"] + }, + "application/vnd.mophun.certificate": { + "source": "iana", + "extensions": ["mpc"] + }, + "application/vnd.motorola.flexsuite": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.adsi": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.fis": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.gotap": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.kmr": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.ttc": { + "source": "iana" + }, + "application/vnd.motorola.flexsuite.wem": { + "source": "iana" + }, + "application/vnd.motorola.iprm": { + "source": "iana" + }, + "application/vnd.mozilla.xul+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xul"] + }, + "application/vnd.ms-3mfdocument": { + "source": "iana" + }, + "application/vnd.ms-artgalry": { + "source": "iana", + "extensions": ["cil"] + }, + "application/vnd.ms-asf": { + "source": "iana" + }, + "application/vnd.ms-cab-compressed": { + "source": "iana", + "extensions": ["cab"] + }, + "application/vnd.ms-color.iccprofile": { + "source": "apache" + }, + "application/vnd.ms-excel": { + "source": "iana", + "compressible": false, + "extensions": ["xls","xlm","xla","xlc","xlt","xlw"] + }, + "application/vnd.ms-excel.addin.macroenabled.12": { + "source": "iana", + "extensions": ["xlam"] + }, + "application/vnd.ms-excel.sheet.binary.macroenabled.12": { + "source": "iana", + "extensions": ["xlsb"] + }, + "application/vnd.ms-excel.sheet.macroenabled.12": { + "source": "iana", + "extensions": ["xlsm"] + }, + "application/vnd.ms-excel.template.macroenabled.12": { + "source": "iana", + "extensions": ["xltm"] + }, + "application/vnd.ms-fontobject": { + "source": "iana", + "compressible": true, + "extensions": ["eot"] + }, + "application/vnd.ms-htmlhelp": { + "source": "iana", + "extensions": ["chm"] + }, + "application/vnd.ms-ims": { + "source": "iana", + "extensions": ["ims"] + }, + "application/vnd.ms-lrm": { + "source": "iana", + "extensions": ["lrm"] + }, + "application/vnd.ms-office.activex+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.ms-officetheme": { + "source": "iana", + "extensions": ["thmx"] + }, + "application/vnd.ms-opentype": { + "source": "apache", + "compressible": true + }, + "application/vnd.ms-outlook": { + "compressible": false, + "extensions": ["msg"] + }, + "application/vnd.ms-package.obfuscated-opentype": { + "source": "apache" + }, + "application/vnd.ms-pki.seccat": { + "source": "apache", + "extensions": ["cat"] + }, + "application/vnd.ms-pki.stl": { + "source": "apache", + "extensions": ["stl"] + }, + "application/vnd.ms-playready.initiator+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.ms-powerpoint": { + "source": "iana", + "compressible": false, + "extensions": ["ppt","pps","pot"] + }, + "application/vnd.ms-powerpoint.addin.macroenabled.12": { + "source": "iana", + "extensions": ["ppam"] + }, + "application/vnd.ms-powerpoint.presentation.macroenabled.12": { + "source": "iana", + "extensions": ["pptm"] + }, + "application/vnd.ms-powerpoint.slide.macroenabled.12": { + "source": "iana", + "extensions": ["sldm"] + }, + "application/vnd.ms-powerpoint.slideshow.macroenabled.12": { + "source": "iana", + "extensions": ["ppsm"] + }, + "application/vnd.ms-powerpoint.template.macroenabled.12": { + "source": "iana", + "extensions": ["potm"] + }, + "application/vnd.ms-printdevicecapabilities+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.ms-printing.printticket+xml": { + "source": "apache", + "compressible": true + }, + "application/vnd.ms-printschematicket+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.ms-project": { + "source": "iana", + "extensions": ["mpp","mpt"] + }, + "application/vnd.ms-tnef": { + "source": "iana" + }, + "application/vnd.ms-windows.devicepairing": { + "source": "iana" + }, + "application/vnd.ms-windows.nwprinting.oob": { + "source": "iana" + }, + "application/vnd.ms-windows.printerpairing": { + "source": "iana" + }, + "application/vnd.ms-windows.wsd.oob": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.lic-resp": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-chlg-req": { + "source": "iana" + }, + "application/vnd.ms-wmdrm.meter-resp": { + "source": "iana" + }, + "application/vnd.ms-word.document.macroenabled.12": { + "source": "iana", + "extensions": ["docm"] + }, + "application/vnd.ms-word.template.macroenabled.12": { + "source": "iana", + "extensions": ["dotm"] + }, + "application/vnd.ms-works": { + "source": "iana", + "extensions": ["wps","wks","wcm","wdb"] + }, + "application/vnd.ms-wpl": { + "source": "iana", + "extensions": ["wpl"] + }, + "application/vnd.ms-xpsdocument": { + "source": "iana", + "compressible": false, + "extensions": ["xps"] + }, + "application/vnd.msa-disk-image": { + "source": "iana" + }, + "application/vnd.mseq": { + "source": "iana", + "extensions": ["mseq"] + }, + "application/vnd.msign": { + "source": "iana" + }, + "application/vnd.multiad.creator": { + "source": "iana" + }, + "application/vnd.multiad.creator.cif": { + "source": "iana" + }, + "application/vnd.music-niff": { + "source": "iana" + }, + "application/vnd.musician": { + "source": "iana", + "extensions": ["mus"] + }, + "application/vnd.muvee.style": { + "source": "iana", + "extensions": ["msty"] + }, + "application/vnd.mynfc": { + "source": "iana", + "extensions": ["taglet"] + }, + "application/vnd.ncd.control": { + "source": "iana" + }, + "application/vnd.ncd.reference": { + "source": "iana" + }, + "application/vnd.nearst.inv+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.nervana": { + "source": "iana" + }, + "application/vnd.netfpx": { + "source": "iana" + }, + "application/vnd.neurolanguage.nlu": { + "source": "iana", + "extensions": ["nlu"] + }, + "application/vnd.nimn": { + "source": "iana" + }, + "application/vnd.nintendo.nitro.rom": { + "source": "iana" + }, + "application/vnd.nintendo.snes.rom": { + "source": "iana" + }, + "application/vnd.nitf": { + "source": "iana", + "extensions": ["ntf","nitf"] + }, + "application/vnd.noblenet-directory": { + "source": "iana", + "extensions": ["nnd"] + }, + "application/vnd.noblenet-sealer": { + "source": "iana", + "extensions": ["nns"] + }, + "application/vnd.noblenet-web": { + "source": "iana", + "extensions": ["nnw"] + }, + "application/vnd.nokia.catalogs": { + "source": "iana" + }, + "application/vnd.nokia.conml+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.conml+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.iptv.config+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.isds-radio-presets": { + "source": "iana" + }, + "application/vnd.nokia.landmark+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.landmark+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.landmarkcollection+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.n-gage.ac+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.n-gage.data": { + "source": "iana", + "extensions": ["ngdat"] + }, + "application/vnd.nokia.n-gage.symbian.install": { + "source": "iana", + "extensions": ["n-gage"] + }, + "application/vnd.nokia.ncd": { + "source": "iana" + }, + "application/vnd.nokia.pcd+wbxml": { + "source": "iana" + }, + "application/vnd.nokia.pcd+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.nokia.radio-preset": { + "source": "iana", + "extensions": ["rpst"] + }, + "application/vnd.nokia.radio-presets": { + "source": "iana", + "extensions": ["rpss"] + }, + "application/vnd.novadigm.edm": { + "source": "iana", + "extensions": ["edm"] + }, + "application/vnd.novadigm.edx": { + "source": "iana", + "extensions": ["edx"] + }, + "application/vnd.novadigm.ext": { + "source": "iana", + "extensions": ["ext"] + }, + "application/vnd.ntt-local.content-share": { + "source": "iana" + }, + "application/vnd.ntt-local.file-transfer": { + "source": "iana" + }, + "application/vnd.ntt-local.ogw_remote-access": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_remote": { + "source": "iana" + }, + "application/vnd.ntt-local.sip-ta_tcp_stream": { + "source": "iana" + }, + "application/vnd.oasis.opendocument.chart": { + "source": "iana", + "extensions": ["odc"] + }, + "application/vnd.oasis.opendocument.chart-template": { + "source": "iana", + "extensions": ["otc"] + }, + "application/vnd.oasis.opendocument.database": { + "source": "iana", + "extensions": ["odb"] + }, + "application/vnd.oasis.opendocument.formula": { + "source": "iana", + "extensions": ["odf"] + }, + "application/vnd.oasis.opendocument.formula-template": { + "source": "iana", + "extensions": ["odft"] + }, + "application/vnd.oasis.opendocument.graphics": { + "source": "iana", + "compressible": false, + "extensions": ["odg"] + }, + "application/vnd.oasis.opendocument.graphics-template": { + "source": "iana", + "extensions": ["otg"] + }, + "application/vnd.oasis.opendocument.image": { + "source": "iana", + "extensions": ["odi"] + }, + "application/vnd.oasis.opendocument.image-template": { + "source": "iana", + "extensions": ["oti"] + }, + "application/vnd.oasis.opendocument.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["odp"] + }, + "application/vnd.oasis.opendocument.presentation-template": { + "source": "iana", + "extensions": ["otp"] + }, + "application/vnd.oasis.opendocument.spreadsheet": { + "source": "iana", + "compressible": false, + "extensions": ["ods"] + }, + "application/vnd.oasis.opendocument.spreadsheet-template": { + "source": "iana", + "extensions": ["ots"] + }, + "application/vnd.oasis.opendocument.text": { + "source": "iana", + "compressible": false, + "extensions": ["odt"] + }, + "application/vnd.oasis.opendocument.text-master": { + "source": "iana", + "extensions": ["odm"] + }, + "application/vnd.oasis.opendocument.text-template": { + "source": "iana", + "extensions": ["ott"] + }, + "application/vnd.oasis.opendocument.text-web": { + "source": "iana", + "extensions": ["oth"] + }, + "application/vnd.obn": { + "source": "iana" + }, + "application/vnd.ocf+cbor": { + "source": "iana" + }, + "application/vnd.oftn.l10n+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.contentaccessdownload+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.contentaccessstreaming+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.cspg-hexbinary": { + "source": "iana" + }, + "application/vnd.oipf.dae.svg+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.dae.xhtml+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.mippvcontrolmessage+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.pae.gem": { + "source": "iana" + }, + "application/vnd.oipf.spdiscovery+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.spdlist+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.ueprofile+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oipf.userprofile+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.olpc-sugar": { + "source": "iana", + "extensions": ["xo"] + }, + "application/vnd.oma-scws-config": { + "source": "iana" + }, + "application/vnd.oma-scws-http-request": { + "source": "iana" + }, + "application/vnd.oma-scws-http-response": { + "source": "iana" + }, + "application/vnd.oma.bcast.associated-procedure-parameter+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.drm-trigger+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.imd+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.ltkm": { + "source": "iana" + }, + "application/vnd.oma.bcast.notification+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.provisioningtrigger": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgboot": { + "source": "iana" + }, + "application/vnd.oma.bcast.sgdd+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.sgdu": { + "source": "iana" + }, + "application/vnd.oma.bcast.simple-symbol-container": { + "source": "iana" + }, + "application/vnd.oma.bcast.smartcard-trigger+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.sprov+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.bcast.stkm": { + "source": "iana" + }, + "application/vnd.oma.cab-address-book+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.cab-feature-handler+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.cab-pcc+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.cab-subs-invite+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.cab-user-prefs+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.dcd": { + "source": "iana" + }, + "application/vnd.oma.dcdc": { + "source": "iana" + }, + "application/vnd.oma.dd2+xml": { + "source": "iana", + "compressible": true, + "extensions": ["dd2"] + }, + "application/vnd.oma.drm.risd+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.group-usage-list+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.lwm2m+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.lwm2m+tlv": { + "source": "iana" + }, + "application/vnd.oma.pal+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.poc.detailed-progress-report+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.poc.final-report+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.poc.groups+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.poc.invocation-descriptor+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.poc.optimized-progress-report+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.push": { + "source": "iana" + }, + "application/vnd.oma.scidm.messages+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oma.xcap-directory+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.omads-email+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.omads-file+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.omads-folder+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.omaloc-supl-init": { + "source": "iana" + }, + "application/vnd.onepager": { + "source": "iana" + }, + "application/vnd.onepagertamp": { + "source": "iana" + }, + "application/vnd.onepagertamx": { + "source": "iana" + }, + "application/vnd.onepagertat": { + "source": "iana" + }, + "application/vnd.onepagertatp": { + "source": "iana" + }, + "application/vnd.onepagertatx": { + "source": "iana" + }, + "application/vnd.openblox.game+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openblox.game-binary": { + "source": "iana" + }, + "application/vnd.openeye.oeb": { + "source": "iana" + }, + "application/vnd.openofficeorg.extension": { + "source": "apache", + "extensions": ["oxt"] + }, + "application/vnd.openstreetmap.data+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.custom-properties+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.customxmlproperties+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawing+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.extended-properties+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.comments+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation": { + "source": "iana", + "compressible": false, + "extensions": ["pptx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.presprops+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide": { + "source": "iana", + "extensions": ["sldx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slide+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow": { + "source": "iana", + "extensions": ["ppsx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.tags+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.template": { + "source": "iana", + "extensions": ["potx"] + }, + "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { + "source": "iana", + "compressible": false, + "extensions": ["xlsx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template": { + "source": "iana", + "extensions": ["xltx"] + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.theme+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.themeoverride+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.vmldrawing": { + "source": "iana" + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": { + "source": "iana", + "compressible": false, + "extensions": ["docx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template": { + "source": "iana", + "extensions": ["dotx"] + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-package.core-properties+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.openxmlformats-package.relationships+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oracle.resource+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.orange.indata": { + "source": "iana" + }, + "application/vnd.osa.netdeploy": { + "source": "iana" + }, + "application/vnd.osgeo.mapguide.package": { + "source": "iana", + "extensions": ["mgp"] + }, + "application/vnd.osgi.bundle": { + "source": "iana" + }, + "application/vnd.osgi.dp": { + "source": "iana", + "extensions": ["dp"] + }, + "application/vnd.osgi.subsystem": { + "source": "iana", + "extensions": ["esa"] + }, + "application/vnd.otps.ct-kip+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.oxli.countgraph": { + "source": "iana" + }, + "application/vnd.pagerduty+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.palm": { + "source": "iana", + "extensions": ["pdb","pqa","oprc"] + }, + "application/vnd.panoply": { + "source": "iana" + }, + "application/vnd.paos.xml": { + "source": "iana" + }, + "application/vnd.patentdive": { + "source": "iana" + }, + "application/vnd.pawaafile": { + "source": "iana", + "extensions": ["paw"] + }, + "application/vnd.pcos": { + "source": "iana" + }, + "application/vnd.pg.format": { + "source": "iana", + "extensions": ["str"] + }, + "application/vnd.pg.osasli": { + "source": "iana", + "extensions": ["ei6"] + }, + "application/vnd.piaccess.application-licence": { + "source": "iana" + }, + "application/vnd.picsel": { + "source": "iana", + "extensions": ["efif"] + }, + "application/vnd.pmi.widget": { + "source": "iana", + "extensions": ["wg"] + }, + "application/vnd.poc.group-advertisement+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.pocketlearn": { + "source": "iana", + "extensions": ["plf"] + }, + "application/vnd.powerbuilder6": { + "source": "iana", + "extensions": ["pbd"] + }, + "application/vnd.powerbuilder6-s": { + "source": "iana" + }, + "application/vnd.powerbuilder7": { + "source": "iana" + }, + "application/vnd.powerbuilder7-s": { + "source": "iana" + }, + "application/vnd.powerbuilder75": { + "source": "iana" + }, + "application/vnd.powerbuilder75-s": { + "source": "iana" + }, + "application/vnd.preminet": { + "source": "iana" + }, + "application/vnd.previewsystems.box": { + "source": "iana", + "extensions": ["box"] + }, + "application/vnd.proteus.magazine": { + "source": "iana", + "extensions": ["mgz"] + }, + "application/vnd.psfs": { + "source": "iana" + }, + "application/vnd.publishare-delta-tree": { + "source": "iana", + "extensions": ["qps"] + }, + "application/vnd.pvi.ptid1": { + "source": "iana", + "extensions": ["ptid"] + }, + "application/vnd.pwg-multiplexed": { + "source": "iana" + }, + "application/vnd.pwg-xhtml-print+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.qualcomm.brew-app-res": { + "source": "iana" + }, + "application/vnd.quarantainenet": { + "source": "iana" + }, + "application/vnd.quark.quarkxpress": { + "source": "iana", + "extensions": ["qxd","qxt","qwd","qwt","qxl","qxb"] + }, + "application/vnd.quobject-quoxdocument": { + "source": "iana" + }, + "application/vnd.radisys.moml+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-audit+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-audit-conf+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-audit-conn+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-audit-dialog+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-audit-stream+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-conf+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-base+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-fax-detect+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-fax-sendrecv+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-group+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-speech+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.radisys.msml-dialog-transform+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.rainstor.data": { + "source": "iana" + }, + "application/vnd.rapid": { + "source": "iana" + }, + "application/vnd.rar": { + "source": "iana" + }, + "application/vnd.realvnc.bed": { + "source": "iana", + "extensions": ["bed"] + }, + "application/vnd.recordare.musicxml": { + "source": "iana", + "extensions": ["mxl"] + }, + "application/vnd.recordare.musicxml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["musicxml"] + }, + "application/vnd.renlearn.rlprint": { + "source": "iana" + }, + "application/vnd.restful+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.rig.cryptonote": { + "source": "iana", + "extensions": ["cryptonote"] + }, + "application/vnd.rim.cod": { + "source": "apache", + "extensions": ["cod"] + }, + "application/vnd.rn-realmedia": { + "source": "apache", + "extensions": ["rm"] + }, + "application/vnd.rn-realmedia-vbr": { + "source": "apache", + "extensions": ["rmvb"] + }, + "application/vnd.route66.link66+xml": { + "source": "iana", + "compressible": true, + "extensions": ["link66"] + }, + "application/vnd.rs-274x": { + "source": "iana" + }, + "application/vnd.ruckus.download": { + "source": "iana" + }, + "application/vnd.s3sms": { + "source": "iana" + }, + "application/vnd.sailingtracker.track": { + "source": "iana", + "extensions": ["st"] + }, + "application/vnd.sbm.cid": { + "source": "iana" + }, + "application/vnd.sbm.mid2": { + "source": "iana" + }, + "application/vnd.scribus": { + "source": "iana" + }, + "application/vnd.sealed.3df": { + "source": "iana" + }, + "application/vnd.sealed.csf": { + "source": "iana" + }, + "application/vnd.sealed.doc": { + "source": "iana" + }, + "application/vnd.sealed.eml": { + "source": "iana" + }, + "application/vnd.sealed.mht": { + "source": "iana" + }, + "application/vnd.sealed.net": { + "source": "iana" + }, + "application/vnd.sealed.ppt": { + "source": "iana" + }, + "application/vnd.sealed.tiff": { + "source": "iana" + }, + "application/vnd.sealed.xls": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.html": { + "source": "iana" + }, + "application/vnd.sealedmedia.softseal.pdf": { + "source": "iana" + }, + "application/vnd.seemail": { + "source": "iana", + "extensions": ["see"] + }, + "application/vnd.sema": { + "source": "iana", + "extensions": ["sema"] + }, + "application/vnd.semd": { + "source": "iana", + "extensions": ["semd"] + }, + "application/vnd.semf": { + "source": "iana", + "extensions": ["semf"] + }, + "application/vnd.shana.informed.formdata": { + "source": "iana", + "extensions": ["ifm"] + }, + "application/vnd.shana.informed.formtemplate": { + "source": "iana", + "extensions": ["itp"] + }, + "application/vnd.shana.informed.interchange": { + "source": "iana", + "extensions": ["iif"] + }, + "application/vnd.shana.informed.package": { + "source": "iana", + "extensions": ["ipk"] + }, + "application/vnd.shootproof+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.sigrok.session": { + "source": "iana" + }, + "application/vnd.simtech-mindmapper": { + "source": "iana", + "extensions": ["twd","twds"] + }, + "application/vnd.siren+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.smaf": { + "source": "iana", + "extensions": ["mmf"] + }, + "application/vnd.smart.notebook": { + "source": "iana" + }, + "application/vnd.smart.teacher": { + "source": "iana", + "extensions": ["teacher"] + }, + "application/vnd.software602.filler.form+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.software602.filler.form-xml-zip": { + "source": "iana" + }, + "application/vnd.solent.sdkm+xml": { + "source": "iana", + "compressible": true, + "extensions": ["sdkm","sdkd"] + }, + "application/vnd.spotfire.dxp": { + "source": "iana", + "extensions": ["dxp"] + }, + "application/vnd.spotfire.sfs": { + "source": "iana", + "extensions": ["sfs"] + }, + "application/vnd.sqlite3": { + "source": "iana" + }, + "application/vnd.sss-cod": { + "source": "iana" + }, + "application/vnd.sss-dtf": { + "source": "iana" + }, + "application/vnd.sss-ntf": { + "source": "iana" + }, + "application/vnd.stardivision.calc": { + "source": "apache", + "extensions": ["sdc"] + }, + "application/vnd.stardivision.draw": { + "source": "apache", + "extensions": ["sda"] + }, + "application/vnd.stardivision.impress": { + "source": "apache", + "extensions": ["sdd"] + }, + "application/vnd.stardivision.math": { + "source": "apache", + "extensions": ["smf"] + }, + "application/vnd.stardivision.writer": { + "source": "apache", + "extensions": ["sdw","vor"] + }, + "application/vnd.stardivision.writer-global": { + "source": "apache", + "extensions": ["sgl"] + }, + "application/vnd.stepmania.package": { + "source": "iana", + "extensions": ["smzip"] + }, + "application/vnd.stepmania.stepchart": { + "source": "iana", + "extensions": ["sm"] + }, + "application/vnd.street-stream": { + "source": "iana" + }, + "application/vnd.sun.wadl+xml": { + "source": "iana", + "compressible": true, + "extensions": ["wadl"] + }, + "application/vnd.sun.xml.calc": { + "source": "apache", + "extensions": ["sxc"] + }, + "application/vnd.sun.xml.calc.template": { + "source": "apache", + "extensions": ["stc"] + }, + "application/vnd.sun.xml.draw": { + "source": "apache", + "extensions": ["sxd"] + }, + "application/vnd.sun.xml.draw.template": { + "source": "apache", + "extensions": ["std"] + }, + "application/vnd.sun.xml.impress": { + "source": "apache", + "extensions": ["sxi"] + }, + "application/vnd.sun.xml.impress.template": { + "source": "apache", + "extensions": ["sti"] + }, + "application/vnd.sun.xml.math": { + "source": "apache", + "extensions": ["sxm"] + }, + "application/vnd.sun.xml.writer": { + "source": "apache", + "extensions": ["sxw"] + }, + "application/vnd.sun.xml.writer.global": { + "source": "apache", + "extensions": ["sxg"] + }, + "application/vnd.sun.xml.writer.template": { + "source": "apache", + "extensions": ["stw"] + }, + "application/vnd.sus-calendar": { + "source": "iana", + "extensions": ["sus","susp"] + }, + "application/vnd.svd": { + "source": "iana", + "extensions": ["svd"] + }, + "application/vnd.swiftview-ics": { + "source": "iana" + }, + "application/vnd.symbian.install": { + "source": "apache", + "extensions": ["sis","sisx"] + }, + "application/vnd.syncml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xsm"] + }, + "application/vnd.syncml.dm+wbxml": { + "source": "iana", + "extensions": ["bdm"] + }, + "application/vnd.syncml.dm+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xdm"] + }, + "application/vnd.syncml.dm.notification": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmddf+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.syncml.dmtnds+wbxml": { + "source": "iana" + }, + "application/vnd.syncml.dmtnds+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.syncml.ds.notification": { + "source": "iana" + }, + "application/vnd.tableschema+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.tao.intent-module-archive": { + "source": "iana", + "extensions": ["tao"] + }, + "application/vnd.tcpdump.pcap": { + "source": "iana", + "extensions": ["pcap","cap","dmp"] + }, + "application/vnd.think-cell.ppttc+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.tmd.mediaflex.api+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.tml": { + "source": "iana" + }, + "application/vnd.tmobile-livetv": { + "source": "iana", + "extensions": ["tmo"] + }, + "application/vnd.tri.onesource": { + "source": "iana" + }, + "application/vnd.trid.tpt": { + "source": "iana", + "extensions": ["tpt"] + }, + "application/vnd.triscape.mxs": { + "source": "iana", + "extensions": ["mxs"] + }, + "application/vnd.trueapp": { + "source": "iana", + "extensions": ["tra"] + }, + "application/vnd.truedoc": { + "source": "iana" + }, + "application/vnd.ubisoft.webplayer": { + "source": "iana" + }, + "application/vnd.ufdl": { + "source": "iana", + "extensions": ["ufd","ufdl"] + }, + "application/vnd.uiq.theme": { + "source": "iana", + "extensions": ["utz"] + }, + "application/vnd.umajin": { + "source": "iana", + "extensions": ["umj"] + }, + "application/vnd.unity": { + "source": "iana", + "extensions": ["unityweb"] + }, + "application/vnd.uoml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["uoml"] + }, + "application/vnd.uplanet.alert": { + "source": "iana" + }, + "application/vnd.uplanet.alert-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice": { + "source": "iana" + }, + "application/vnd.uplanet.bearer-choice-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop": { + "source": "iana" + }, + "application/vnd.uplanet.cacheop-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.channel": { + "source": "iana" + }, + "application/vnd.uplanet.channel-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.list": { + "source": "iana" + }, + "application/vnd.uplanet.list-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd": { + "source": "iana" + }, + "application/vnd.uplanet.listcmd-wbxml": { + "source": "iana" + }, + "application/vnd.uplanet.signal": { + "source": "iana" + }, + "application/vnd.uri-map": { + "source": "iana" + }, + "application/vnd.valve.source.material": { + "source": "iana" + }, + "application/vnd.vcx": { + "source": "iana", + "extensions": ["vcx"] + }, + "application/vnd.vd-study": { + "source": "iana" + }, + "application/vnd.vectorworks": { + "source": "iana" + }, + "application/vnd.vel+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.verimatrix.vcas": { + "source": "iana" + }, + "application/vnd.vidsoft.vidconference": { + "source": "iana" + }, + "application/vnd.visio": { + "source": "iana", + "extensions": ["vsd","vst","vss","vsw"] + }, + "application/vnd.visionary": { + "source": "iana", + "extensions": ["vis"] + }, + "application/vnd.vividence.scriptfile": { + "source": "iana" + }, + "application/vnd.vsf": { + "source": "iana", + "extensions": ["vsf"] + }, + "application/vnd.wap.sic": { + "source": "iana" + }, + "application/vnd.wap.slc": { + "source": "iana" + }, + "application/vnd.wap.wbxml": { + "source": "iana", + "extensions": ["wbxml"] + }, + "application/vnd.wap.wmlc": { + "source": "iana", + "extensions": ["wmlc"] + }, + "application/vnd.wap.wmlscriptc": { + "source": "iana", + "extensions": ["wmlsc"] + }, + "application/vnd.webturbo": { + "source": "iana", + "extensions": ["wtb"] + }, + "application/vnd.wfa.p2p": { + "source": "iana" + }, + "application/vnd.wfa.wsc": { + "source": "iana" + }, + "application/vnd.windows.devicepairing": { + "source": "iana" + }, + "application/vnd.wmc": { + "source": "iana" + }, + "application/vnd.wmf.bootstrap": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica": { + "source": "iana" + }, + "application/vnd.wolfram.mathematica.package": { + "source": "iana" + }, + "application/vnd.wolfram.player": { + "source": "iana", + "extensions": ["nbp"] + }, + "application/vnd.wordperfect": { + "source": "iana", + "extensions": ["wpd"] + }, + "application/vnd.wqd": { + "source": "iana", + "extensions": ["wqd"] + }, + "application/vnd.wrq-hp3000-labelled": { + "source": "iana" + }, + "application/vnd.wt.stf": { + "source": "iana", + "extensions": ["stf"] + }, + "application/vnd.wv.csp+wbxml": { + "source": "iana" + }, + "application/vnd.wv.csp+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.wv.ssp+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.xacml+json": { + "source": "iana", + "compressible": true + }, + "application/vnd.xara": { + "source": "iana", + "extensions": ["xar"] + }, + "application/vnd.xfdl": { + "source": "iana", + "extensions": ["xfdl"] + }, + "application/vnd.xfdl.webform": { + "source": "iana" + }, + "application/vnd.xmi+xml": { + "source": "iana", + "compressible": true + }, + "application/vnd.xmpie.cpkg": { + "source": "iana" + }, + "application/vnd.xmpie.dpkg": { + "source": "iana" + }, + "application/vnd.xmpie.plan": { + "source": "iana" + }, + "application/vnd.xmpie.ppkg": { + "source": "iana" + }, + "application/vnd.xmpie.xlim": { + "source": "iana" + }, + "application/vnd.yamaha.hv-dic": { + "source": "iana", + "extensions": ["hvd"] + }, + "application/vnd.yamaha.hv-script": { + "source": "iana", + "extensions": ["hvs"] + }, + "application/vnd.yamaha.hv-voice": { + "source": "iana", + "extensions": ["hvp"] + }, + "application/vnd.yamaha.openscoreformat": { + "source": "iana", + "extensions": ["osf"] + }, + "application/vnd.yamaha.openscoreformat.osfpvg+xml": { + "source": "iana", + "compressible": true, + "extensions": ["osfpvg"] + }, + "application/vnd.yamaha.remote-setup": { + "source": "iana" + }, + "application/vnd.yamaha.smaf-audio": { + "source": "iana", + "extensions": ["saf"] + }, + "application/vnd.yamaha.smaf-phrase": { + "source": "iana", + "extensions": ["spf"] + }, + "application/vnd.yamaha.through-ngn": { + "source": "iana" + }, + "application/vnd.yamaha.tunnel-udpencap": { + "source": "iana" + }, + "application/vnd.yaoweme": { + "source": "iana" + }, + "application/vnd.yellowriver-custom-menu": { + "source": "iana", + "extensions": ["cmp"] + }, + "application/vnd.youtube.yt": { + "source": "iana" + }, + "application/vnd.zul": { + "source": "iana", + "extensions": ["zir","zirz"] + }, + "application/vnd.zzazz.deck+xml": { + "source": "iana", + "compressible": true, + "extensions": ["zaz"] + }, + "application/voicexml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["vxml"] + }, + "application/voucher-cms+json": { + "source": "iana", + "compressible": true + }, + "application/vq-rtcpxr": { + "source": "iana" + }, + "application/wasm": { + "compressible": true, + "extensions": ["wasm"] + }, + "application/watcherinfo+xml": { + "source": "iana", + "compressible": true + }, + "application/webpush-options+json": { + "source": "iana", + "compressible": true + }, + "application/whoispp-query": { + "source": "iana" + }, + "application/whoispp-response": { + "source": "iana" + }, + "application/widget": { + "source": "iana", + "extensions": ["wgt"] + }, + "application/winhlp": { + "source": "apache", + "extensions": ["hlp"] + }, + "application/wita": { + "source": "iana" + }, + "application/wordperfect5.1": { + "source": "iana" + }, + "application/wsdl+xml": { + "source": "iana", + "compressible": true, + "extensions": ["wsdl"] + }, + "application/wspolicy+xml": { + "source": "iana", + "compressible": true, + "extensions": ["wspolicy"] + }, + "application/x-7z-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["7z"] + }, + "application/x-abiword": { + "source": "apache", + "extensions": ["abw"] + }, + "application/x-ace-compressed": { + "source": "apache", + "extensions": ["ace"] + }, + "application/x-amf": { + "source": "apache" + }, + "application/x-apple-diskimage": { + "source": "apache", + "extensions": ["dmg"] + }, + "application/x-arj": { + "compressible": false, + "extensions": ["arj"] + }, + "application/x-authorware-bin": { + "source": "apache", + "extensions": ["aab","x32","u32","vox"] + }, + "application/x-authorware-map": { + "source": "apache", + "extensions": ["aam"] + }, + "application/x-authorware-seg": { + "source": "apache", + "extensions": ["aas"] + }, + "application/x-bcpio": { + "source": "apache", + "extensions": ["bcpio"] + }, + "application/x-bdoc": { + "compressible": false, + "extensions": ["bdoc"] + }, + "application/x-bittorrent": { + "source": "apache", + "extensions": ["torrent"] + }, + "application/x-blorb": { + "source": "apache", + "extensions": ["blb","blorb"] + }, + "application/x-bzip": { + "source": "apache", + "compressible": false, + "extensions": ["bz"] + }, + "application/x-bzip2": { + "source": "apache", + "compressible": false, + "extensions": ["bz2","boz"] + }, + "application/x-cbr": { + "source": "apache", + "extensions": ["cbr","cba","cbt","cbz","cb7"] + }, + "application/x-cdlink": { + "source": "apache", + "extensions": ["vcd"] + }, + "application/x-cfs-compressed": { + "source": "apache", + "extensions": ["cfs"] + }, + "application/x-chat": { + "source": "apache", + "extensions": ["chat"] + }, + "application/x-chess-pgn": { + "source": "apache", + "extensions": ["pgn"] + }, + "application/x-chrome-extension": { + "extensions": ["crx"] + }, + "application/x-cocoa": { + "source": "nginx", + "extensions": ["cco"] + }, + "application/x-compress": { + "source": "apache" + }, + "application/x-conference": { + "source": "apache", + "extensions": ["nsc"] + }, + "application/x-cpio": { + "source": "apache", + "extensions": ["cpio"] + }, + "application/x-csh": { + "source": "apache", + "extensions": ["csh"] + }, + "application/x-deb": { + "compressible": false + }, + "application/x-debian-package": { + "source": "apache", + "extensions": ["deb","udeb"] + }, + "application/x-dgc-compressed": { + "source": "apache", + "extensions": ["dgc"] + }, + "application/x-director": { + "source": "apache", + "extensions": ["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"] + }, + "application/x-doom": { + "source": "apache", + "extensions": ["wad"] + }, + "application/x-dtbncx+xml": { + "source": "apache", + "compressible": true, + "extensions": ["ncx"] + }, + "application/x-dtbook+xml": { + "source": "apache", + "compressible": true, + "extensions": ["dtb"] + }, + "application/x-dtbresource+xml": { + "source": "apache", + "compressible": true, + "extensions": ["res"] + }, + "application/x-dvi": { + "source": "apache", + "compressible": false, + "extensions": ["dvi"] + }, + "application/x-envoy": { + "source": "apache", + "extensions": ["evy"] + }, + "application/x-eva": { + "source": "apache", + "extensions": ["eva"] + }, + "application/x-font-bdf": { + "source": "apache", + "extensions": ["bdf"] + }, + "application/x-font-dos": { + "source": "apache" + }, + "application/x-font-framemaker": { + "source": "apache" + }, + "application/x-font-ghostscript": { + "source": "apache", + "extensions": ["gsf"] + }, + "application/x-font-libgrx": { + "source": "apache" + }, + "application/x-font-linux-psf": { + "source": "apache", + "extensions": ["psf"] + }, + "application/x-font-pcf": { + "source": "apache", + "extensions": ["pcf"] + }, + "application/x-font-snf": { + "source": "apache", + "extensions": ["snf"] + }, + "application/x-font-speedo": { + "source": "apache" + }, + "application/x-font-sunos-news": { + "source": "apache" + }, + "application/x-font-type1": { + "source": "apache", + "extensions": ["pfa","pfb","pfm","afm"] + }, + "application/x-font-vfont": { + "source": "apache" + }, + "application/x-freearc": { + "source": "apache", + "extensions": ["arc"] + }, + "application/x-futuresplash": { + "source": "apache", + "extensions": ["spl"] + }, + "application/x-gca-compressed": { + "source": "apache", + "extensions": ["gca"] + }, + "application/x-glulx": { + "source": "apache", + "extensions": ["ulx"] + }, + "application/x-gnumeric": { + "source": "apache", + "extensions": ["gnumeric"] + }, + "application/x-gramps-xml": { + "source": "apache", + "extensions": ["gramps"] + }, + "application/x-gtar": { + "source": "apache", + "extensions": ["gtar"] + }, + "application/x-gzip": { + "source": "apache" + }, + "application/x-hdf": { + "source": "apache", + "extensions": ["hdf"] + }, + "application/x-httpd-php": { + "compressible": true, + "extensions": ["php"] + }, + "application/x-install-instructions": { + "source": "apache", + "extensions": ["install"] + }, + "application/x-iso9660-image": { + "source": "apache", + "extensions": ["iso"] + }, + "application/x-java-archive-diff": { + "source": "nginx", + "extensions": ["jardiff"] + }, + "application/x-java-jnlp-file": { + "source": "apache", + "compressible": false, + "extensions": ["jnlp"] + }, + "application/x-javascript": { + "compressible": true + }, + "application/x-latex": { + "source": "apache", + "compressible": false, + "extensions": ["latex"] + }, + "application/x-lua-bytecode": { + "extensions": ["luac"] + }, + "application/x-lzh-compressed": { + "source": "apache", + "extensions": ["lzh","lha"] + }, + "application/x-makeself": { + "source": "nginx", + "extensions": ["run"] + }, + "application/x-mie": { + "source": "apache", + "extensions": ["mie"] + }, + "application/x-mobipocket-ebook": { + "source": "apache", + "extensions": ["prc","mobi"] + }, + "application/x-mpegurl": { + "compressible": false + }, + "application/x-ms-application": { + "source": "apache", + "extensions": ["application"] + }, + "application/x-ms-shortcut": { + "source": "apache", + "extensions": ["lnk"] + }, + "application/x-ms-wmd": { + "source": "apache", + "extensions": ["wmd"] + }, + "application/x-ms-wmz": { + "source": "apache", + "extensions": ["wmz"] + }, + "application/x-ms-xbap": { + "source": "apache", + "extensions": ["xbap"] + }, + "application/x-msaccess": { + "source": "apache", + "extensions": ["mdb"] + }, + "application/x-msbinder": { + "source": "apache", + "extensions": ["obd"] + }, + "application/x-mscardfile": { + "source": "apache", + "extensions": ["crd"] + }, + "application/x-msclip": { + "source": "apache", + "extensions": ["clp"] + }, + "application/x-msdos-program": { + "extensions": ["exe"] + }, + "application/x-msdownload": { + "source": "apache", + "extensions": ["exe","dll","com","bat","msi"] + }, + "application/x-msmediaview": { + "source": "apache", + "extensions": ["mvb","m13","m14"] + }, + "application/x-msmetafile": { + "source": "apache", + "extensions": ["wmf","wmz","emf","emz"] + }, + "application/x-msmoney": { + "source": "apache", + "extensions": ["mny"] + }, + "application/x-mspublisher": { + "source": "apache", + "extensions": ["pub"] + }, + "application/x-msschedule": { + "source": "apache", + "extensions": ["scd"] + }, + "application/x-msterminal": { + "source": "apache", + "extensions": ["trm"] + }, + "application/x-mswrite": { + "source": "apache", + "extensions": ["wri"] + }, + "application/x-netcdf": { + "source": "apache", + "extensions": ["nc","cdf"] + }, + "application/x-ns-proxy-autoconfig": { + "compressible": true, + "extensions": ["pac"] + }, + "application/x-nzb": { + "source": "apache", + "extensions": ["nzb"] + }, + "application/x-perl": { + "source": "nginx", + "extensions": ["pl","pm"] + }, + "application/x-pilot": { + "source": "nginx", + "extensions": ["prc","pdb"] + }, + "application/x-pkcs12": { + "source": "apache", + "compressible": false, + "extensions": ["p12","pfx"] + }, + "application/x-pkcs7-certificates": { + "source": "apache", + "extensions": ["p7b","spc"] + }, + "application/x-pkcs7-certreqresp": { + "source": "apache", + "extensions": ["p7r"] + }, + "application/x-rar-compressed": { + "source": "apache", + "compressible": false, + "extensions": ["rar"] + }, + "application/x-redhat-package-manager": { + "source": "nginx", + "extensions": ["rpm"] + }, + "application/x-research-info-systems": { + "source": "apache", + "extensions": ["ris"] + }, + "application/x-sea": { + "source": "nginx", + "extensions": ["sea"] + }, + "application/x-sh": { + "source": "apache", + "compressible": true, + "extensions": ["sh"] + }, + "application/x-shar": { + "source": "apache", + "extensions": ["shar"] + }, + "application/x-shockwave-flash": { + "source": "apache", + "compressible": false, + "extensions": ["swf"] + }, + "application/x-silverlight-app": { + "source": "apache", + "extensions": ["xap"] + }, + "application/x-sql": { + "source": "apache", + "extensions": ["sql"] + }, + "application/x-stuffit": { + "source": "apache", + "compressible": false, + "extensions": ["sit"] + }, + "application/x-stuffitx": { + "source": "apache", + "extensions": ["sitx"] + }, + "application/x-subrip": { + "source": "apache", + "extensions": ["srt"] + }, + "application/x-sv4cpio": { + "source": "apache", + "extensions": ["sv4cpio"] + }, + "application/x-sv4crc": { + "source": "apache", + "extensions": ["sv4crc"] + }, + "application/x-t3vm-image": { + "source": "apache", + "extensions": ["t3"] + }, + "application/x-tads": { + "source": "apache", + "extensions": ["gam"] + }, + "application/x-tar": { + "source": "apache", + "compressible": true, + "extensions": ["tar"] + }, + "application/x-tcl": { + "source": "apache", + "extensions": ["tcl","tk"] + }, + "application/x-tex": { + "source": "apache", + "extensions": ["tex"] + }, + "application/x-tex-tfm": { + "source": "apache", + "extensions": ["tfm"] + }, + "application/x-texinfo": { + "source": "apache", + "extensions": ["texinfo","texi"] + }, + "application/x-tgif": { + "source": "apache", + "extensions": ["obj"] + }, + "application/x-ustar": { + "source": "apache", + "extensions": ["ustar"] + }, + "application/x-virtualbox-hdd": { + "compressible": true, + "extensions": ["hdd"] + }, + "application/x-virtualbox-ova": { + "compressible": true, + "extensions": ["ova"] + }, + "application/x-virtualbox-ovf": { + "compressible": true, + "extensions": ["ovf"] + }, + "application/x-virtualbox-vbox": { + "compressible": true, + "extensions": ["vbox"] + }, + "application/x-virtualbox-vbox-extpack": { + "compressible": false, + "extensions": ["vbox-extpack"] + }, + "application/x-virtualbox-vdi": { + "compressible": true, + "extensions": ["vdi"] + }, + "application/x-virtualbox-vhd": { + "compressible": true, + "extensions": ["vhd"] + }, + "application/x-virtualbox-vmdk": { + "compressible": true, + "extensions": ["vmdk"] + }, + "application/x-wais-source": { + "source": "apache", + "extensions": ["src"] + }, + "application/x-web-app-manifest+json": { + "compressible": true, + "extensions": ["webapp"] + }, + "application/x-www-form-urlencoded": { + "source": "iana", + "compressible": true + }, + "application/x-x509-ca-cert": { + "source": "apache", + "extensions": ["der","crt","pem"] + }, + "application/x-xfig": { + "source": "apache", + "extensions": ["fig"] + }, + "application/x-xliff+xml": { + "source": "apache", + "compressible": true, + "extensions": ["xlf"] + }, + "application/x-xpinstall": { + "source": "apache", + "compressible": false, + "extensions": ["xpi"] + }, + "application/x-xz": { + "source": "apache", + "extensions": ["xz"] + }, + "application/x-zmachine": { + "source": "apache", + "extensions": ["z1","z2","z3","z4","z5","z6","z7","z8"] + }, + "application/x400-bp": { + "source": "iana" + }, + "application/xacml+xml": { + "source": "iana", + "compressible": true + }, + "application/xaml+xml": { + "source": "apache", + "compressible": true, + "extensions": ["xaml"] + }, + "application/xcap-att+xml": { + "source": "iana", + "compressible": true + }, + "application/xcap-caps+xml": { + "source": "iana", + "compressible": true + }, + "application/xcap-diff+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xdf"] + }, + "application/xcap-el+xml": { + "source": "iana", + "compressible": true + }, + "application/xcap-error+xml": { + "source": "iana", + "compressible": true + }, + "application/xcap-ns+xml": { + "source": "iana", + "compressible": true + }, + "application/xcon-conference-info+xml": { + "source": "iana", + "compressible": true + }, + "application/xcon-conference-info-diff+xml": { + "source": "iana", + "compressible": true + }, + "application/xenc+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xenc"] + }, + "application/xhtml+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xhtml","xht"] + }, + "application/xhtml-voice+xml": { + "source": "apache", + "compressible": true + }, + "application/xliff+xml": { + "source": "iana", + "compressible": true + }, + "application/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml","xsl","xsd","rng"] + }, + "application/xml-dtd": { + "source": "iana", + "compressible": true, + "extensions": ["dtd"] + }, + "application/xml-external-parsed-entity": { + "source": "iana" + }, + "application/xml-patch+xml": { + "source": "iana", + "compressible": true + }, + "application/xmpp+xml": { + "source": "iana", + "compressible": true + }, + "application/xop+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xop"] + }, + "application/xproc+xml": { + "source": "apache", + "compressible": true, + "extensions": ["xpl"] + }, + "application/xslt+xml": { + "source": "iana", + "compressible": true, + "extensions": ["xslt"] + }, + "application/xspf+xml": { + "source": "apache", + "compressible": true, + "extensions": ["xspf"] + }, + "application/xv+xml": { + "source": "iana", + "compressible": true, + "extensions": ["mxml","xhvml","xvml","xvm"] + }, + "application/yang": { + "source": "iana", + "extensions": ["yang"] + }, + "application/yang-data+json": { + "source": "iana", + "compressible": true + }, + "application/yang-data+xml": { + "source": "iana", + "compressible": true + }, + "application/yang-patch+json": { + "source": "iana", + "compressible": true + }, + "application/yang-patch+xml": { + "source": "iana", + "compressible": true + }, + "application/yin+xml": { + "source": "iana", + "compressible": true, + "extensions": ["yin"] + }, + "application/zip": { + "source": "iana", + "compressible": false, + "extensions": ["zip"] + }, + "application/zlib": { + "source": "iana" + }, + "application/zstd": { + "source": "iana" + }, + "audio/1d-interleaved-parityfec": { + "source": "iana" + }, + "audio/32kadpcm": { + "source": "iana" + }, + "audio/3gpp": { + "source": "iana", + "compressible": false, + "extensions": ["3gpp"] + }, + "audio/3gpp2": { + "source": "iana" + }, + "audio/aac": { + "source": "iana" + }, + "audio/ac3": { + "source": "iana" + }, + "audio/adpcm": { + "source": "apache", + "extensions": ["adp"] + }, + "audio/amr": { + "source": "iana" + }, + "audio/amr-wb": { + "source": "iana" + }, + "audio/amr-wb+": { + "source": "iana" + }, + "audio/aptx": { + "source": "iana" + }, + "audio/asc": { + "source": "iana" + }, + "audio/atrac-advanced-lossless": { + "source": "iana" + }, + "audio/atrac-x": { + "source": "iana" + }, + "audio/atrac3": { + "source": "iana" + }, + "audio/basic": { + "source": "iana", + "compressible": false, + "extensions": ["au","snd"] + }, + "audio/bv16": { + "source": "iana" + }, + "audio/bv32": { + "source": "iana" + }, + "audio/clearmode": { + "source": "iana" + }, + "audio/cn": { + "source": "iana" + }, + "audio/dat12": { + "source": "iana" + }, + "audio/dls": { + "source": "iana" + }, + "audio/dsr-es201108": { + "source": "iana" + }, + "audio/dsr-es202050": { + "source": "iana" + }, + "audio/dsr-es202211": { + "source": "iana" + }, + "audio/dsr-es202212": { + "source": "iana" + }, + "audio/dv": { + "source": "iana" + }, + "audio/dvi4": { + "source": "iana" + }, + "audio/eac3": { + "source": "iana" + }, + "audio/encaprtp": { + "source": "iana" + }, + "audio/evrc": { + "source": "iana" + }, + "audio/evrc-qcp": { + "source": "iana" + }, + "audio/evrc0": { + "source": "iana" + }, + "audio/evrc1": { + "source": "iana" + }, + "audio/evrcb": { + "source": "iana" + }, + "audio/evrcb0": { + "source": "iana" + }, + "audio/evrcb1": { + "source": "iana" + }, + "audio/evrcnw": { + "source": "iana" + }, + "audio/evrcnw0": { + "source": "iana" + }, + "audio/evrcnw1": { + "source": "iana" + }, + "audio/evrcwb": { + "source": "iana" + }, + "audio/evrcwb0": { + "source": "iana" + }, + "audio/evrcwb1": { + "source": "iana" + }, + "audio/evs": { + "source": "iana" + }, + "audio/fwdred": { + "source": "iana" + }, + "audio/g711-0": { + "source": "iana" + }, + "audio/g719": { + "source": "iana" + }, + "audio/g722": { + "source": "iana" + }, + "audio/g7221": { + "source": "iana" + }, + "audio/g723": { + "source": "iana" + }, + "audio/g726-16": { + "source": "iana" + }, + "audio/g726-24": { + "source": "iana" + }, + "audio/g726-32": { + "source": "iana" + }, + "audio/g726-40": { + "source": "iana" + }, + "audio/g728": { + "source": "iana" + }, + "audio/g729": { + "source": "iana" + }, + "audio/g7291": { + "source": "iana" + }, + "audio/g729d": { + "source": "iana" + }, + "audio/g729e": { + "source": "iana" + }, + "audio/gsm": { + "source": "iana" + }, + "audio/gsm-efr": { + "source": "iana" + }, + "audio/gsm-hr-08": { + "source": "iana" + }, + "audio/ilbc": { + "source": "iana" + }, + "audio/ip-mr_v2.5": { + "source": "iana" + }, + "audio/isac": { + "source": "apache" + }, + "audio/l16": { + "source": "iana" + }, + "audio/l20": { + "source": "iana" + }, + "audio/l24": { + "source": "iana", + "compressible": false + }, + "audio/l8": { + "source": "iana" + }, + "audio/lpc": { + "source": "iana" + }, + "audio/melp": { + "source": "iana" + }, + "audio/melp1200": { + "source": "iana" + }, + "audio/melp2400": { + "source": "iana" + }, + "audio/melp600": { + "source": "iana" + }, + "audio/midi": { + "source": "apache", + "extensions": ["mid","midi","kar","rmi"] + }, + "audio/mobile-xmf": { + "source": "iana" + }, + "audio/mp3": { + "compressible": false, + "extensions": ["mp3"] + }, + "audio/mp4": { + "source": "iana", + "compressible": false, + "extensions": ["m4a","mp4a"] + }, + "audio/mp4a-latm": { + "source": "iana" + }, + "audio/mpa": { + "source": "iana" + }, + "audio/mpa-robust": { + "source": "iana" + }, + "audio/mpeg": { + "source": "iana", + "compressible": false, + "extensions": ["mpga","mp2","mp2a","mp3","m2a","m3a"] + }, + "audio/mpeg4-generic": { + "source": "iana" + }, + "audio/musepack": { + "source": "apache" + }, + "audio/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["oga","ogg","spx"] + }, + "audio/opus": { + "source": "iana" + }, + "audio/parityfec": { + "source": "iana" + }, + "audio/pcma": { + "source": "iana" + }, + "audio/pcma-wb": { + "source": "iana" + }, + "audio/pcmu": { + "source": "iana" + }, + "audio/pcmu-wb": { + "source": "iana" + }, + "audio/prs.sid": { + "source": "iana" + }, + "audio/qcelp": { + "source": "iana" + }, + "audio/raptorfec": { + "source": "iana" + }, + "audio/red": { + "source": "iana" + }, + "audio/rtp-enc-aescm128": { + "source": "iana" + }, + "audio/rtp-midi": { + "source": "iana" + }, + "audio/rtploopback": { + "source": "iana" + }, + "audio/rtx": { + "source": "iana" + }, + "audio/s3m": { + "source": "apache", + "extensions": ["s3m"] + }, + "audio/silk": { + "source": "apache", + "extensions": ["sil"] + }, + "audio/smv": { + "source": "iana" + }, + "audio/smv-qcp": { + "source": "iana" + }, + "audio/smv0": { + "source": "iana" + }, + "audio/sp-midi": { + "source": "iana" + }, + "audio/speex": { + "source": "iana" + }, + "audio/t140c": { + "source": "iana" + }, + "audio/t38": { + "source": "iana" + }, + "audio/telephone-event": { + "source": "iana" + }, + "audio/tone": { + "source": "iana" + }, + "audio/uemclip": { + "source": "iana" + }, + "audio/ulpfec": { + "source": "iana" + }, + "audio/usac": { + "source": "iana" + }, + "audio/vdvi": { + "source": "iana" + }, + "audio/vmr-wb": { + "source": "iana" + }, + "audio/vnd.3gpp.iufp": { + "source": "iana" + }, + "audio/vnd.4sb": { + "source": "iana" + }, + "audio/vnd.audiokoz": { + "source": "iana" + }, + "audio/vnd.celp": { + "source": "iana" + }, + "audio/vnd.cisco.nse": { + "source": "iana" + }, + "audio/vnd.cmles.radio-events": { + "source": "iana" + }, + "audio/vnd.cns.anp1": { + "source": "iana" + }, + "audio/vnd.cns.inf1": { + "source": "iana" + }, + "audio/vnd.dece.audio": { + "source": "iana", + "extensions": ["uva","uvva"] + }, + "audio/vnd.digital-winds": { + "source": "iana", + "extensions": ["eol"] + }, + "audio/vnd.dlna.adts": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.1": { + "source": "iana" + }, + "audio/vnd.dolby.heaac.2": { + "source": "iana" + }, + "audio/vnd.dolby.mlp": { + "source": "iana" + }, + "audio/vnd.dolby.mps": { + "source": "iana" + }, + "audio/vnd.dolby.pl2": { + "source": "iana" + }, + "audio/vnd.dolby.pl2x": { + "source": "iana" + }, + "audio/vnd.dolby.pl2z": { + "source": "iana" + }, + "audio/vnd.dolby.pulse.1": { + "source": "iana" + }, + "audio/vnd.dra": { + "source": "iana", + "extensions": ["dra"] + }, + "audio/vnd.dts": { + "source": "iana", + "extensions": ["dts"] + }, + "audio/vnd.dts.hd": { + "source": "iana", + "extensions": ["dtshd"] + }, + "audio/vnd.dvb.file": { + "source": "iana" + }, + "audio/vnd.everad.plj": { + "source": "iana" + }, + "audio/vnd.hns.audio": { + "source": "iana" + }, + "audio/vnd.lucent.voice": { + "source": "iana", + "extensions": ["lvp"] + }, + "audio/vnd.ms-playready.media.pya": { + "source": "iana", + "extensions": ["pya"] + }, + "audio/vnd.nokia.mobile-xmf": { + "source": "iana" + }, + "audio/vnd.nortel.vbk": { + "source": "iana" + }, + "audio/vnd.nuera.ecelp4800": { + "source": "iana", + "extensions": ["ecelp4800"] + }, + "audio/vnd.nuera.ecelp7470": { + "source": "iana", + "extensions": ["ecelp7470"] + }, + "audio/vnd.nuera.ecelp9600": { + "source": "iana", + "extensions": ["ecelp9600"] + }, + "audio/vnd.octel.sbc": { + "source": "iana" + }, + "audio/vnd.presonus.multitrack": { + "source": "iana" + }, + "audio/vnd.qcelp": { + "source": "iana" + }, + "audio/vnd.rhetorex.32kadpcm": { + "source": "iana" + }, + "audio/vnd.rip": { + "source": "iana", + "extensions": ["rip"] + }, + "audio/vnd.rn-realaudio": { + "compressible": false + }, + "audio/vnd.sealedmedia.softseal.mpeg": { + "source": "iana" + }, + "audio/vnd.vmx.cvsd": { + "source": "iana" + }, + "audio/vnd.wave": { + "compressible": false + }, + "audio/vorbis": { + "source": "iana", + "compressible": false + }, + "audio/vorbis-config": { + "source": "iana" + }, + "audio/wav": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/wave": { + "compressible": false, + "extensions": ["wav"] + }, + "audio/webm": { + "source": "apache", + "compressible": false, + "extensions": ["weba"] + }, + "audio/x-aac": { + "source": "apache", + "compressible": false, + "extensions": ["aac"] + }, + "audio/x-aiff": { + "source": "apache", + "extensions": ["aif","aiff","aifc"] + }, + "audio/x-caf": { + "source": "apache", + "compressible": false, + "extensions": ["caf"] + }, + "audio/x-flac": { + "source": "apache", + "extensions": ["flac"] + }, + "audio/x-m4a": { + "source": "nginx", + "extensions": ["m4a"] + }, + "audio/x-matroska": { + "source": "apache", + "extensions": ["mka"] + }, + "audio/x-mpegurl": { + "source": "apache", + "extensions": ["m3u"] + }, + "audio/x-ms-wax": { + "source": "apache", + "extensions": ["wax"] + }, + "audio/x-ms-wma": { + "source": "apache", + "extensions": ["wma"] + }, + "audio/x-pn-realaudio": { + "source": "apache", + "extensions": ["ram","ra"] + }, + "audio/x-pn-realaudio-plugin": { + "source": "apache", + "extensions": ["rmp"] + }, + "audio/x-realaudio": { + "source": "nginx", + "extensions": ["ra"] + }, + "audio/x-tta": { + "source": "apache" + }, + "audio/x-wav": { + "source": "apache", + "extensions": ["wav"] + }, + "audio/xm": { + "source": "apache", + "extensions": ["xm"] + }, + "chemical/x-cdx": { + "source": "apache", + "extensions": ["cdx"] + }, + "chemical/x-cif": { + "source": "apache", + "extensions": ["cif"] + }, + "chemical/x-cmdf": { + "source": "apache", + "extensions": ["cmdf"] + }, + "chemical/x-cml": { + "source": "apache", + "extensions": ["cml"] + }, + "chemical/x-csml": { + "source": "apache", + "extensions": ["csml"] + }, + "chemical/x-pdb": { + "source": "apache" + }, + "chemical/x-xyz": { + "source": "apache", + "extensions": ["xyz"] + }, + "font/collection": { + "source": "iana", + "extensions": ["ttc"] + }, + "font/otf": { + "source": "iana", + "compressible": true, + "extensions": ["otf"] + }, + "font/sfnt": { + "source": "iana" + }, + "font/ttf": { + "source": "iana", + "extensions": ["ttf"] + }, + "font/woff": { + "source": "iana", + "extensions": ["woff"] + }, + "font/woff2": { + "source": "iana", + "extensions": ["woff2"] + }, + "image/aces": { + "source": "iana", + "extensions": ["exr"] + }, + "image/apng": { + "compressible": false, + "extensions": ["apng"] + }, + "image/avci": { + "source": "iana" + }, + "image/avcs": { + "source": "iana" + }, + "image/bmp": { + "source": "iana", + "compressible": true, + "extensions": ["bmp"] + }, + "image/cgm": { + "source": "iana", + "extensions": ["cgm"] + }, + "image/dicom-rle": { + "source": "iana", + "extensions": ["drle"] + }, + "image/emf": { + "source": "iana", + "extensions": ["emf"] + }, + "image/fits": { + "source": "iana", + "extensions": ["fits"] + }, + "image/g3fax": { + "source": "iana", + "extensions": ["g3"] + }, + "image/gif": { + "source": "iana", + "compressible": false, + "extensions": ["gif"] + }, + "image/heic": { + "source": "iana" + }, + "image/heic-sequence": { + "source": "iana" + }, + "image/heif": { + "source": "iana" + }, + "image/heif-sequence": { + "source": "iana" + }, + "image/ief": { + "source": "iana", + "extensions": ["ief"] + }, + "image/jls": { + "source": "iana", + "extensions": ["jls"] + }, + "image/jp2": { + "source": "iana", + "compressible": false, + "extensions": ["jp2","jpg2"] + }, + "image/jpeg": { + "source": "iana", + "compressible": false, + "extensions": ["jpeg","jpg","jpe"] + }, + "image/jpm": { + "source": "iana", + "compressible": false, + "extensions": ["jpm"] + }, + "image/jpx": { + "source": "iana", + "compressible": false, + "extensions": ["jpx","jpf"] + }, + "image/ktx": { + "source": "iana", + "extensions": ["ktx"] + }, + "image/naplps": { + "source": "iana" + }, + "image/pjpeg": { + "compressible": false + }, + "image/png": { + "source": "iana", + "compressible": false, + "extensions": ["png"] + }, + "image/prs.btif": { + "source": "iana", + "extensions": ["btif"] + }, + "image/prs.pti": { + "source": "iana", + "extensions": ["pti"] + }, + "image/pwg-raster": { + "source": "iana" + }, + "image/sgi": { + "source": "apache", + "extensions": ["sgi"] + }, + "image/svg+xml": { + "source": "iana", + "compressible": true, + "extensions": ["svg","svgz"] + }, + "image/t38": { + "source": "iana", + "extensions": ["t38"] + }, + "image/tiff": { + "source": "iana", + "compressible": false, + "extensions": ["tif","tiff"] + }, + "image/tiff-fx": { + "source": "iana", + "extensions": ["tfx"] + }, + "image/vnd.adobe.photoshop": { + "source": "iana", + "compressible": true, + "extensions": ["psd"] + }, + "image/vnd.airzip.accelerator.azv": { + "source": "iana", + "extensions": ["azv"] + }, + "image/vnd.cns.inf2": { + "source": "iana" + }, + "image/vnd.dece.graphic": { + "source": "iana", + "extensions": ["uvi","uvvi","uvg","uvvg"] + }, + "image/vnd.djvu": { + "source": "iana", + "extensions": ["djvu","djv"] + }, + "image/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "image/vnd.dwg": { + "source": "iana", + "extensions": ["dwg"] + }, + "image/vnd.dxf": { + "source": "iana", + "extensions": ["dxf"] + }, + "image/vnd.fastbidsheet": { + "source": "iana", + "extensions": ["fbs"] + }, + "image/vnd.fpx": { + "source": "iana", + "extensions": ["fpx"] + }, + "image/vnd.fst": { + "source": "iana", + "extensions": ["fst"] + }, + "image/vnd.fujixerox.edmics-mmr": { + "source": "iana", + "extensions": ["mmr"] + }, + "image/vnd.fujixerox.edmics-rlc": { + "source": "iana", + "extensions": ["rlc"] + }, + "image/vnd.globalgraphics.pgb": { + "source": "iana" + }, + "image/vnd.microsoft.icon": { + "source": "iana", + "extensions": ["ico"] + }, + "image/vnd.mix": { + "source": "iana" + }, + "image/vnd.mozilla.apng": { + "source": "iana" + }, + "image/vnd.ms-modi": { + "source": "iana", + "extensions": ["mdi"] + }, + "image/vnd.ms-photo": { + "source": "apache", + "extensions": ["wdp"] + }, + "image/vnd.net-fpx": { + "source": "iana", + "extensions": ["npx"] + }, + "image/vnd.radiance": { + "source": "iana" + }, + "image/vnd.sealed.png": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.gif": { + "source": "iana" + }, + "image/vnd.sealedmedia.softseal.jpg": { + "source": "iana" + }, + "image/vnd.svf": { + "source": "iana" + }, + "image/vnd.tencent.tap": { + "source": "iana", + "extensions": ["tap"] + }, + "image/vnd.valve.source.texture": { + "source": "iana", + "extensions": ["vtf"] + }, + "image/vnd.wap.wbmp": { + "source": "iana", + "extensions": ["wbmp"] + }, + "image/vnd.xiff": { + "source": "iana", + "extensions": ["xif"] + }, + "image/vnd.zbrush.pcx": { + "source": "iana", + "extensions": ["pcx"] + }, + "image/webp": { + "source": "apache", + "extensions": ["webp"] + }, + "image/wmf": { + "source": "iana", + "extensions": ["wmf"] + }, + "image/x-3ds": { + "source": "apache", + "extensions": ["3ds"] + }, + "image/x-cmu-raster": { + "source": "apache", + "extensions": ["ras"] + }, + "image/x-cmx": { + "source": "apache", + "extensions": ["cmx"] + }, + "image/x-freehand": { + "source": "apache", + "extensions": ["fh","fhc","fh4","fh5","fh7"] + }, + "image/x-icon": { + "source": "apache", + "compressible": true, + "extensions": ["ico"] + }, + "image/x-jng": { + "source": "nginx", + "extensions": ["jng"] + }, + "image/x-mrsid-image": { + "source": "apache", + "extensions": ["sid"] + }, + "image/x-ms-bmp": { + "source": "nginx", + "compressible": true, + "extensions": ["bmp"] + }, + "image/x-pcx": { + "source": "apache", + "extensions": ["pcx"] + }, + "image/x-pict": { + "source": "apache", + "extensions": ["pic","pct"] + }, + "image/x-portable-anymap": { + "source": "apache", + "extensions": ["pnm"] + }, + "image/x-portable-bitmap": { + "source": "apache", + "extensions": ["pbm"] + }, + "image/x-portable-graymap": { + "source": "apache", + "extensions": ["pgm"] + }, + "image/x-portable-pixmap": { + "source": "apache", + "extensions": ["ppm"] + }, + "image/x-rgb": { + "source": "apache", + "extensions": ["rgb"] + }, + "image/x-tga": { + "source": "apache", + "extensions": ["tga"] + }, + "image/x-xbitmap": { + "source": "apache", + "extensions": ["xbm"] + }, + "image/x-xcf": { + "compressible": false + }, + "image/x-xpixmap": { + "source": "apache", + "extensions": ["xpm"] + }, + "image/x-xwindowdump": { + "source": "apache", + "extensions": ["xwd"] + }, + "message/cpim": { + "source": "iana" + }, + "message/delivery-status": { + "source": "iana" + }, + "message/disposition-notification": { + "source": "iana", + "extensions": [ + "disposition-notification" + ] + }, + "message/external-body": { + "source": "iana" + }, + "message/feedback-report": { + "source": "iana" + }, + "message/global": { + "source": "iana", + "extensions": ["u8msg"] + }, + "message/global-delivery-status": { + "source": "iana", + "extensions": ["u8dsn"] + }, + "message/global-disposition-notification": { + "source": "iana", + "extensions": ["u8mdn"] + }, + "message/global-headers": { + "source": "iana", + "extensions": ["u8hdr"] + }, + "message/http": { + "source": "iana", + "compressible": false + }, + "message/imdn+xml": { + "source": "iana", + "compressible": true + }, + "message/news": { + "source": "iana" + }, + "message/partial": { + "source": "iana", + "compressible": false + }, + "message/rfc822": { + "source": "iana", + "compressible": true, + "extensions": ["eml","mime"] + }, + "message/s-http": { + "source": "iana" + }, + "message/sip": { + "source": "iana" + }, + "message/sipfrag": { + "source": "iana" + }, + "message/tracking-status": { + "source": "iana" + }, + "message/vnd.si.simp": { + "source": "iana" + }, + "message/vnd.wfa.wsc": { + "source": "iana", + "extensions": ["wsc"] + }, + "model/3mf": { + "source": "iana" + }, + "model/gltf+json": { + "source": "iana", + "compressible": true, + "extensions": ["gltf"] + }, + "model/gltf-binary": { + "source": "iana", + "compressible": true, + "extensions": ["glb"] + }, + "model/iges": { + "source": "iana", + "compressible": false, + "extensions": ["igs","iges"] + }, + "model/mesh": { + "source": "iana", + "compressible": false, + "extensions": ["msh","mesh","silo"] + }, + "model/stl": { + "source": "iana" + }, + "model/vnd.collada+xml": { + "source": "iana", + "compressible": true, + "extensions": ["dae"] + }, + "model/vnd.dwf": { + "source": "iana", + "extensions": ["dwf"] + }, + "model/vnd.flatland.3dml": { + "source": "iana" + }, + "model/vnd.gdl": { + "source": "iana", + "extensions": ["gdl"] + }, + "model/vnd.gs-gdl": { + "source": "apache" + }, + "model/vnd.gs.gdl": { + "source": "iana" + }, + "model/vnd.gtw": { + "source": "iana", + "extensions": ["gtw"] + }, + "model/vnd.moml+xml": { + "source": "iana", + "compressible": true + }, + "model/vnd.mts": { + "source": "iana", + "extensions": ["mts"] + }, + "model/vnd.opengex": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.binary": { + "source": "iana" + }, + "model/vnd.parasolid.transmit.text": { + "source": "iana" + }, + "model/vnd.rosette.annotated-data-model": { + "source": "iana" + }, + "model/vnd.usdz+zip": { + "source": "iana", + "compressible": false + }, + "model/vnd.valve.source.compiled-map": { + "source": "iana" + }, + "model/vnd.vtu": { + "source": "iana", + "extensions": ["vtu"] + }, + "model/vrml": { + "source": "iana", + "compressible": false, + "extensions": ["wrl","vrml"] + }, + "model/x3d+binary": { + "source": "apache", + "compressible": false, + "extensions": ["x3db","x3dbz"] + }, + "model/x3d+fastinfoset": { + "source": "iana" + }, + "model/x3d+vrml": { + "source": "apache", + "compressible": false, + "extensions": ["x3dv","x3dvz"] + }, + "model/x3d+xml": { + "source": "iana", + "compressible": true, + "extensions": ["x3d","x3dz"] + }, + "model/x3d-vrml": { + "source": "iana" + }, + "multipart/alternative": { + "source": "iana", + "compressible": false + }, + "multipart/appledouble": { + "source": "iana" + }, + "multipart/byteranges": { + "source": "iana" + }, + "multipart/digest": { + "source": "iana" + }, + "multipart/encrypted": { + "source": "iana", + "compressible": false + }, + "multipart/form-data": { + "source": "iana", + "compressible": false + }, + "multipart/header-set": { + "source": "iana" + }, + "multipart/mixed": { + "source": "iana", + "compressible": false + }, + "multipart/multilingual": { + "source": "iana" + }, + "multipart/parallel": { + "source": "iana" + }, + "multipart/related": { + "source": "iana", + "compressible": false + }, + "multipart/report": { + "source": "iana" + }, + "multipart/signed": { + "source": "iana", + "compressible": false + }, + "multipart/vnd.bint.med-plus": { + "source": "iana" + }, + "multipart/voice-message": { + "source": "iana" + }, + "multipart/x-mixed-replace": { + "source": "iana" + }, + "text/1d-interleaved-parityfec": { + "source": "iana" + }, + "text/cache-manifest": { + "source": "iana", + "compressible": true, + "extensions": ["appcache","manifest"] + }, + "text/calendar": { + "source": "iana", + "extensions": ["ics","ifb"] + }, + "text/calender": { + "compressible": true + }, + "text/cmd": { + "compressible": true + }, + "text/coffeescript": { + "extensions": ["coffee","litcoffee"] + }, + "text/css": { + "source": "iana", + "charset": "UTF-8", + "compressible": true, + "extensions": ["css"] + }, + "text/csv": { + "source": "iana", + "compressible": true, + "extensions": ["csv"] + }, + "text/csv-schema": { + "source": "iana" + }, + "text/directory": { + "source": "iana" + }, + "text/dns": { + "source": "iana" + }, + "text/ecmascript": { + "source": "iana" + }, + "text/encaprtp": { + "source": "iana" + }, + "text/enriched": { + "source": "iana" + }, + "text/fwdred": { + "source": "iana" + }, + "text/grammar-ref-list": { + "source": "iana" + }, + "text/html": { + "source": "iana", + "compressible": true, + "extensions": ["html","htm","shtml"] + }, + "text/jade": { + "extensions": ["jade"] + }, + "text/javascript": { + "source": "iana", + "compressible": true + }, + "text/jcr-cnd": { + "source": "iana" + }, + "text/jsx": { + "compressible": true, + "extensions": ["jsx"] + }, + "text/less": { + "extensions": ["less"] + }, + "text/markdown": { + "source": "iana", + "compressible": true, + "extensions": ["markdown","md"] + }, + "text/mathml": { + "source": "nginx", + "extensions": ["mml"] + }, + "text/mizar": { + "source": "iana" + }, + "text/n3": { + "source": "iana", + "compressible": true, + "extensions": ["n3"] + }, + "text/parameters": { + "source": "iana" + }, + "text/parityfec": { + "source": "iana" + }, + "text/plain": { + "source": "iana", + "compressible": true, + "extensions": ["txt","text","conf","def","list","log","in","ini"] + }, + "text/provenance-notation": { + "source": "iana" + }, + "text/prs.fallenstein.rst": { + "source": "iana" + }, + "text/prs.lines.tag": { + "source": "iana", + "extensions": ["dsc"] + }, + "text/prs.prop.logic": { + "source": "iana" + }, + "text/raptorfec": { + "source": "iana" + }, + "text/red": { + "source": "iana" + }, + "text/rfc822-headers": { + "source": "iana" + }, + "text/richtext": { + "source": "iana", + "compressible": true, + "extensions": ["rtx"] + }, + "text/rtf": { + "source": "iana", + "compressible": true, + "extensions": ["rtf"] + }, + "text/rtp-enc-aescm128": { + "source": "iana" + }, + "text/rtploopback": { + "source": "iana" + }, + "text/rtx": { + "source": "iana" + }, + "text/sgml": { + "source": "iana", + "extensions": ["sgml","sgm"] + }, + "text/shex": { + "extensions": ["shex"] + }, + "text/slim": { + "extensions": ["slim","slm"] + }, + "text/strings": { + "source": "iana" + }, + "text/stylus": { + "extensions": ["stylus","styl"] + }, + "text/t140": { + "source": "iana" + }, + "text/tab-separated-values": { + "source": "iana", + "compressible": true, + "extensions": ["tsv"] + }, + "text/troff": { + "source": "iana", + "extensions": ["t","tr","roff","man","me","ms"] + }, + "text/turtle": { + "source": "iana", + "charset": "UTF-8", + "extensions": ["ttl"] + }, + "text/ulpfec": { + "source": "iana" + }, + "text/uri-list": { + "source": "iana", + "compressible": true, + "extensions": ["uri","uris","urls"] + }, + "text/vcard": { + "source": "iana", + "compressible": true, + "extensions": ["vcard"] + }, + "text/vnd.a": { + "source": "iana" + }, + "text/vnd.abc": { + "source": "iana" + }, + "text/vnd.ascii-art": { + "source": "iana" + }, + "text/vnd.curl": { + "source": "iana", + "extensions": ["curl"] + }, + "text/vnd.curl.dcurl": { + "source": "apache", + "extensions": ["dcurl"] + }, + "text/vnd.curl.mcurl": { + "source": "apache", + "extensions": ["mcurl"] + }, + "text/vnd.curl.scurl": { + "source": "apache", + "extensions": ["scurl"] + }, + "text/vnd.debian.copyright": { + "source": "iana" + }, + "text/vnd.dmclientscript": { + "source": "iana" + }, + "text/vnd.dvb.subtitle": { + "source": "iana", + "extensions": ["sub"] + }, + "text/vnd.esmertec.theme-descriptor": { + "source": "iana" + }, + "text/vnd.fly": { + "source": "iana", + "extensions": ["fly"] + }, + "text/vnd.fmi.flexstor": { + "source": "iana", + "extensions": ["flx"] + }, + "text/vnd.gml": { + "source": "iana" + }, + "text/vnd.graphviz": { + "source": "iana", + "extensions": ["gv"] + }, + "text/vnd.hgl": { + "source": "iana" + }, + "text/vnd.in3d.3dml": { + "source": "iana", + "extensions": ["3dml"] + }, + "text/vnd.in3d.spot": { + "source": "iana", + "extensions": ["spot"] + }, + "text/vnd.iptc.newsml": { + "source": "iana" + }, + "text/vnd.iptc.nitf": { + "source": "iana" + }, + "text/vnd.latex-z": { + "source": "iana" + }, + "text/vnd.motorola.reflex": { + "source": "iana" + }, + "text/vnd.ms-mediapackage": { + "source": "iana" + }, + "text/vnd.net2phone.commcenter.command": { + "source": "iana" + }, + "text/vnd.radisys.msml-basic-layout": { + "source": "iana" + }, + "text/vnd.si.uricatalogue": { + "source": "iana" + }, + "text/vnd.sun.j2me.app-descriptor": { + "source": "iana", + "extensions": ["jad"] + }, + "text/vnd.trolltech.linguist": { + "source": "iana" + }, + "text/vnd.wap.si": { + "source": "iana" + }, + "text/vnd.wap.sl": { + "source": "iana" + }, + "text/vnd.wap.wml": { + "source": "iana", + "extensions": ["wml"] + }, + "text/vnd.wap.wmlscript": { + "source": "iana", + "extensions": ["wmls"] + }, + "text/vtt": { + "charset": "UTF-8", + "compressible": true, + "extensions": ["vtt"] + }, + "text/x-asm": { + "source": "apache", + "extensions": ["s","asm"] + }, + "text/x-c": { + "source": "apache", + "extensions": ["c","cc","cxx","cpp","h","hh","dic"] + }, + "text/x-component": { + "source": "nginx", + "extensions": ["htc"] + }, + "text/x-fortran": { + "source": "apache", + "extensions": ["f","for","f77","f90"] + }, + "text/x-gwt-rpc": { + "compressible": true + }, + "text/x-handlebars-template": { + "extensions": ["hbs"] + }, + "text/x-java-source": { + "source": "apache", + "extensions": ["java"] + }, + "text/x-jquery-tmpl": { + "compressible": true + }, + "text/x-lua": { + "extensions": ["lua"] + }, + "text/x-markdown": { + "compressible": true, + "extensions": ["mkd"] + }, + "text/x-nfo": { + "source": "apache", + "extensions": ["nfo"] + }, + "text/x-opml": { + "source": "apache", + "extensions": ["opml"] + }, + "text/x-org": { + "compressible": true, + "extensions": ["org"] + }, + "text/x-pascal": { + "source": "apache", + "extensions": ["p","pas"] + }, + "text/x-processing": { + "compressible": true, + "extensions": ["pde"] + }, + "text/x-sass": { + "extensions": ["sass"] + }, + "text/x-scss": { + "extensions": ["scss"] + }, + "text/x-setext": { + "source": "apache", + "extensions": ["etx"] + }, + "text/x-sfv": { + "source": "apache", + "extensions": ["sfv"] + }, + "text/x-suse-ymp": { + "compressible": true, + "extensions": ["ymp"] + }, + "text/x-uuencode": { + "source": "apache", + "extensions": ["uu"] + }, + "text/x-vcalendar": { + "source": "apache", + "extensions": ["vcs"] + }, + "text/x-vcard": { + "source": "apache", + "extensions": ["vcf"] + }, + "text/xml": { + "source": "iana", + "compressible": true, + "extensions": ["xml"] + }, + "text/xml-external-parsed-entity": { + "source": "iana" + }, + "text/yaml": { + "extensions": ["yaml","yml"] + }, + "video/1d-interleaved-parityfec": { + "source": "iana" + }, + "video/3gpp": { + "source": "iana", + "extensions": ["3gp","3gpp"] + }, + "video/3gpp-tt": { + "source": "iana" + }, + "video/3gpp2": { + "source": "iana", + "extensions": ["3g2"] + }, + "video/bmpeg": { + "source": "iana" + }, + "video/bt656": { + "source": "iana" + }, + "video/celb": { + "source": "iana" + }, + "video/dv": { + "source": "iana" + }, + "video/encaprtp": { + "source": "iana" + }, + "video/h261": { + "source": "iana", + "extensions": ["h261"] + }, + "video/h263": { + "source": "iana", + "extensions": ["h263"] + }, + "video/h263-1998": { + "source": "iana" + }, + "video/h263-2000": { + "source": "iana" + }, + "video/h264": { + "source": "iana", + "extensions": ["h264"] + }, + "video/h264-rcdo": { + "source": "iana" + }, + "video/h264-svc": { + "source": "iana" + }, + "video/h265": { + "source": "iana" + }, + "video/iso.segment": { + "source": "iana" + }, + "video/jpeg": { + "source": "iana", + "extensions": ["jpgv"] + }, + "video/jpeg2000": { + "source": "iana" + }, + "video/jpm": { + "source": "apache", + "extensions": ["jpm","jpgm"] + }, + "video/mj2": { + "source": "iana", + "extensions": ["mj2","mjp2"] + }, + "video/mp1s": { + "source": "iana" + }, + "video/mp2p": { + "source": "iana" + }, + "video/mp2t": { + "source": "iana", + "extensions": ["ts"] + }, + "video/mp4": { + "source": "iana", + "compressible": false, + "extensions": ["mp4","mp4v","mpg4"] + }, + "video/mp4v-es": { + "source": "iana" + }, + "video/mpeg": { + "source": "iana", + "compressible": false, + "extensions": ["mpeg","mpg","mpe","m1v","m2v"] + }, + "video/mpeg4-generic": { + "source": "iana" + }, + "video/mpv": { + "source": "iana" + }, + "video/nv": { + "source": "iana" + }, + "video/ogg": { + "source": "iana", + "compressible": false, + "extensions": ["ogv"] + }, + "video/parityfec": { + "source": "iana" + }, + "video/pointer": { + "source": "iana" + }, + "video/quicktime": { + "source": "iana", + "compressible": false, + "extensions": ["qt","mov"] + }, + "video/raptorfec": { + "source": "iana" + }, + "video/raw": { + "source": "iana" + }, + "video/rtp-enc-aescm128": { + "source": "iana" + }, + "video/rtploopback": { + "source": "iana" + }, + "video/rtx": { + "source": "iana" + }, + "video/smpte291": { + "source": "iana" + }, + "video/smpte292m": { + "source": "iana" + }, + "video/ulpfec": { + "source": "iana" + }, + "video/vc1": { + "source": "iana" + }, + "video/vnd.cctv": { + "source": "iana" + }, + "video/vnd.dece.hd": { + "source": "iana", + "extensions": ["uvh","uvvh"] + }, + "video/vnd.dece.mobile": { + "source": "iana", + "extensions": ["uvm","uvvm"] + }, + "video/vnd.dece.mp4": { + "source": "iana" + }, + "video/vnd.dece.pd": { + "source": "iana", + "extensions": ["uvp","uvvp"] + }, + "video/vnd.dece.sd": { + "source": "iana", + "extensions": ["uvs","uvvs"] + }, + "video/vnd.dece.video": { + "source": "iana", + "extensions": ["uvv","uvvv"] + }, + "video/vnd.directv.mpeg": { + "source": "iana" + }, + "video/vnd.directv.mpeg-tts": { + "source": "iana" + }, + "video/vnd.dlna.mpeg-tts": { + "source": "iana" + }, + "video/vnd.dvb.file": { + "source": "iana", + "extensions": ["dvb"] + }, + "video/vnd.fvt": { + "source": "iana", + "extensions": ["fvt"] + }, + "video/vnd.hns.video": { + "source": "iana" + }, + "video/vnd.iptvforum.1dparityfec-1010": { + "source": "iana" + }, + "video/vnd.iptvforum.1dparityfec-2005": { + "source": "iana" + }, + "video/vnd.iptvforum.2dparityfec-1010": { + "source": "iana" + }, + "video/vnd.iptvforum.2dparityfec-2005": { + "source": "iana" + }, + "video/vnd.iptvforum.ttsavc": { + "source": "iana" + }, + "video/vnd.iptvforum.ttsmpeg2": { + "source": "iana" + }, + "video/vnd.motorola.video": { + "source": "iana" + }, + "video/vnd.motorola.videop": { + "source": "iana" + }, + "video/vnd.mpegurl": { + "source": "iana", + "extensions": ["mxu","m4u"] + }, + "video/vnd.ms-playready.media.pyv": { + "source": "iana", + "extensions": ["pyv"] + }, + "video/vnd.nokia.interleaved-multimedia": { + "source": "iana" + }, + "video/vnd.nokia.mp4vr": { + "source": "iana" + }, + "video/vnd.nokia.videovoip": { + "source": "iana" + }, + "video/vnd.objectvideo": { + "source": "iana" + }, + "video/vnd.radgamettools.bink": { + "source": "iana" + }, + "video/vnd.radgamettools.smacker": { + "source": "iana" + }, + "video/vnd.sealed.mpeg1": { + "source": "iana" + }, + "video/vnd.sealed.mpeg4": { + "source": "iana" + }, + "video/vnd.sealed.swf": { + "source": "iana" + }, + "video/vnd.sealedmedia.softseal.mov": { + "source": "iana" + }, + "video/vnd.uvvu.mp4": { + "source": "iana", + "extensions": ["uvu","uvvu"] + }, + "video/vnd.vivo": { + "source": "iana", + "extensions": ["viv"] + }, + "video/vp8": { + "source": "iana" + }, + "video/webm": { + "source": "apache", + "compressible": false, + "extensions": ["webm"] + }, + "video/x-f4v": { + "source": "apache", + "extensions": ["f4v"] + }, + "video/x-fli": { + "source": "apache", + "extensions": ["fli"] + }, + "video/x-flv": { + "source": "apache", + "compressible": false, + "extensions": ["flv"] + }, + "video/x-m4v": { + "source": "apache", + "extensions": ["m4v"] + }, + "video/x-matroska": { + "source": "apache", + "compressible": false, + "extensions": ["mkv","mk3d","mks"] + }, + "video/x-mng": { + "source": "apache", + "extensions": ["mng"] + }, + "video/x-ms-asf": { + "source": "apache", + "extensions": ["asf","asx"] + }, + "video/x-ms-vob": { + "source": "apache", + "extensions": ["vob"] + }, + "video/x-ms-wm": { + "source": "apache", + "extensions": ["wm"] + }, + "video/x-ms-wmv": { + "source": "apache", + "compressible": false, + "extensions": ["wmv"] + }, + "video/x-ms-wmx": { + "source": "apache", + "extensions": ["wmx"] + }, + "video/x-ms-wvx": { + "source": "apache", + "extensions": ["wvx"] + }, + "video/x-msvideo": { + "source": "apache", + "extensions": ["avi"] + }, + "video/x-sgi-movie": { + "source": "apache", + "extensions": ["movie"] + }, + "video/x-smv": { + "source": "apache", + "extensions": ["smv"] + }, + "x-conference/x-cooltalk": { + "source": "apache", + "extensions": ["ice"] + }, + "x-shader/x-fragment": { + "compressible": true + }, + "x-shader/x-vertex": { + "compressible": true + } +} diff --git a/node_modules/mime-db/index.js b/node_modules/mime-db/index.js new file mode 100644 index 0000000..551031f --- /dev/null +++ b/node_modules/mime-db/index.js @@ -0,0 +1,11 @@ +/*! + * mime-db + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + +/** + * Module exports. + */ + +module.exports = require('./db.json') diff --git a/node_modules/mime-db/package.json b/node_modules/mime-db/package.json new file mode 100644 index 0000000..249c503 --- /dev/null +++ b/node_modules/mime-db/package.json @@ -0,0 +1,100 @@ +{ + "_from": "mime-db@~1.36.0", + "_id": "mime-db@1.36.0", + "_inBundle": false, + "_integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==", + "_location": "/mime-db", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "mime-db@~1.36.0", + "name": "mime-db", + "escapedName": "mime-db", + "rawSpec": "~1.36.0", + "saveSpec": null, + "fetchSpec": "~1.36.0" + }, + "_requiredBy": [ + "/mime-types" + ], + "_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "_shasum": "5020478db3c7fe93aad7bbcc4dcf869c43363397", + "_spec": "mime-db@~1.36.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mime-types", + "bugs": { + "url": "https://github.com/jshttp/mime-db/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + }, + { + "name": "Robert Kieffer", + "email": "robert@broofa.com", + "url": "http://github.com/broofa" + } + ], + "deprecated": false, + "description": "Media Type Database", + "devDependencies": { + "bluebird": "3.5.1", + "co": "4.6.0", + "cogent": "1.0.1", + "csv-parse": "2.5.0", + "eslint": "4.19.1", + "eslint-config-standard": "11.0.0", + "eslint-plugin-import": "2.13.0", + "eslint-plugin-node": "6.0.1", + "eslint-plugin-promise": "3.8.0", + "eslint-plugin-standard": "3.1.0", + "gnode": "0.1.2", + "mocha": "1.21.5", + "nyc": "11.8.0", + "raw-body": "2.3.3", + "stream-to-array": "2.3.0" + }, + "engines": { + "node": ">= 0.6" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "db.json", + "index.js" + ], + "homepage": "https://github.com/jshttp/mime-db#readme", + "keywords": [ + "mime", + "db", + "type", + "types", + "database", + "charset", + "charsets" + ], + "license": "MIT", + "name": "mime-db", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-db.git" + }, + "scripts": { + "build": "node scripts/build", + "fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx", + "lint": "eslint .", + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "nyc --reporter=html --reporter=text npm test", + "test-travis": "nyc --reporter=text npm test", + "update": "npm run fetch && npm run build" + }, + "version": "1.36.0" +} diff --git a/node_modules/mime-types/HISTORY.md b/node_modules/mime-types/HISTORY.md new file mode 100644 index 0000000..c3af78d --- /dev/null +++ b/node_modules/mime-types/HISTORY.md @@ -0,0 +1,278 @@ +2.1.20 / 2018-08-26 +=================== + + * deps: mime-db@~1.36.0 + - Add Apple file extensions from IANA + - Add extensions from IANA for `image/*` types + - Add new upstream MIME types + +2.1.19 / 2018-07-17 +=================== + + * deps: mime-db@~1.35.0 + - Add extension `.csl` to `application/vnd.citationstyles.style+xml` + - Add extension `.es` to `application/ecmascript` + - Add extension `.owl` to `application/rdf+xml` + - Add new upstream MIME types + - Add UTF-8 as default charset for `text/turtle` + +2.1.18 / 2018-02-16 +=================== + + * deps: mime-db@~1.33.0 + - Add `application/raml+yaml` with extension `.raml` + - Add `application/wasm` with extension `.wasm` + - Add `text/shex` with extension `.shex` + - Add extensions for JPEG-2000 images + - Add extensions from IANA for `message/*` types + - Add new upstream MIME types + - Update font MIME types + - Update `text/hjson` to registered `application/hjson` + +2.1.17 / 2017-09-01 +=================== + + * deps: mime-db@~1.30.0 + - Add `application/vnd.ms-outlook` + - Add `application/x-arj` + - Add extension `.mjs` to `application/javascript` + - Add glTF types and extensions + - Add new upstream MIME types + - Add `text/x-org` + - Add VirtualBox MIME types + - Fix `source` records for `video/*` types that are IANA + - Update `font/opentype` to registered `font/otf` + +2.1.16 / 2017-07-24 +=================== + + * deps: mime-db@~1.29.0 + - Add `application/fido.trusted-apps+json` + - Add extension `.wadl` to `application/vnd.sun.wadl+xml` + - Add extension `.gz` to `application/gzip` + - Add new upstream MIME types + - Update extensions `.md` and `.markdown` to be `text/markdown` + +2.1.15 / 2017-03-23 +=================== + + * deps: mime-db@~1.27.0 + - Add new mime types + - Add `image/apng` + +2.1.14 / 2017-01-14 +=================== + + * deps: mime-db@~1.26.0 + - Add new mime types + +2.1.13 / 2016-11-18 +=================== + + * deps: mime-db@~1.25.0 + - Add new mime types + +2.1.12 / 2016-09-18 +=================== + + * deps: mime-db@~1.24.0 + - Add new mime types + - Add `audio/mp3` + +2.1.11 / 2016-05-01 +=================== + + * deps: mime-db@~1.23.0 + - Add new mime types + +2.1.10 / 2016-02-15 +=================== + + * deps: mime-db@~1.22.0 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +2.1.9 / 2016-01-06 +================== + + * deps: mime-db@~1.21.0 + - Add new mime types + +2.1.8 / 2015-11-30 +================== + + * deps: mime-db@~1.20.0 + - Add new mime types + +2.1.7 / 2015-09-20 +================== + + * deps: mime-db@~1.19.0 + - Add new mime types + +2.1.6 / 2015-09-03 +================== + + * deps: mime-db@~1.18.0 + - Add new mime types + +2.1.5 / 2015-08-20 +================== + + * deps: mime-db@~1.17.0 + - Add new mime types + +2.1.4 / 2015-07-30 +================== + + * deps: mime-db@~1.16.0 + - Add new mime types + +2.1.3 / 2015-07-13 +================== + + * deps: mime-db@~1.15.0 + - Add new mime types + +2.1.2 / 2015-06-25 +================== + + * deps: mime-db@~1.14.0 + - Add new mime types + +2.1.1 / 2015-06-08 +================== + + * perf: fix deopt during mapping + +2.1.0 / 2015-06-07 +================== + + * Fix incorrectly treating extension-less file name as extension + - i.e. `'path/to/json'` will no longer return `application/json` + * Fix `.charset(type)` to accept parameters + * Fix `.charset(type)` to match case-insensitive + * Improve generation of extension to MIME mapping + * Refactor internals for readability and no argument reassignment + * Prefer `application/*` MIME types from the same source + * Prefer any type over `application/octet-stream` + * deps: mime-db@~1.13.0 + - Add nginx as a source + - Add new mime types + +2.0.14 / 2015-06-06 +=================== + + * deps: mime-db@~1.12.0 + - Add new mime types + +2.0.13 / 2015-05-31 +=================== + + * deps: mime-db@~1.11.0 + - Add new mime types + +2.0.12 / 2015-05-19 +=================== + + * deps: mime-db@~1.10.0 + - Add new mime types + +2.0.11 / 2015-05-05 +=================== + + * deps: mime-db@~1.9.1 + - Add new mime types + +2.0.10 / 2015-03-13 +=================== + + * deps: mime-db@~1.8.0 + - Add new mime types + +2.0.9 / 2015-02-09 +================== + + * deps: mime-db@~1.7.0 + - Add new mime types + - Community extensions ownership transferred from `node-mime` + +2.0.8 / 2015-01-29 +================== + + * deps: mime-db@~1.6.0 + - Add new mime types + +2.0.7 / 2014-12-30 +================== + + * deps: mime-db@~1.5.0 + - Add new mime types + - Fix various invalid MIME type entries + +2.0.6 / 2014-12-30 +================== + + * deps: mime-db@~1.4.0 + - Add new mime types + - Fix various invalid MIME type entries + - Remove example template MIME types + +2.0.5 / 2014-12-29 +================== + + * deps: mime-db@~1.3.1 + - Fix missing extensions + +2.0.4 / 2014-12-10 +================== + + * deps: mime-db@~1.3.0 + - Add new mime types + +2.0.3 / 2014-11-09 +================== + + * deps: mime-db@~1.2.0 + - Add new mime types + +2.0.2 / 2014-09-28 +================== + + * deps: mime-db@~1.1.0 + - Add new mime types + - Add additional compressible + - Update charsets + +2.0.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + +2.0.0 / 2014-09-02 +================== + + * Use `mime-db` + * Remove `.define()` + +1.0.2 / 2014-08-04 +================== + + * Set charset=utf-8 for `text/javascript` + +1.0.1 / 2014-06-24 +================== + + * Add `text/jsx` type + +1.0.0 / 2014-05-12 +================== + + * Return `false` for unknown types + * Set charset=utf-8 for `application/json` + +0.1.0 / 2014-05-02 +================== + + * Initial release diff --git a/node_modules/mime-types/LICENSE b/node_modules/mime-types/LICENSE new file mode 100644 index 0000000..0616607 --- /dev/null +++ b/node_modules/mime-types/LICENSE @@ -0,0 +1,23 @@ +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/mime-types/README.md b/node_modules/mime-types/README.md new file mode 100644 index 0000000..b58cae6 --- /dev/null +++ b/node_modules/mime-types/README.md @@ -0,0 +1,108 @@ +# mime-types + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +The ultimate javascript content-type utility. + +Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except: + +- __No fallbacks.__ Instead of naively returning the first available type, + `mime-types` simply returns `false`, so do + `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. +- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. +- No `.define()` functionality +- Bug fixes for `.lookup(path)` + +Otherwise, the API is compatible with `mime` 1.x. + +## Install + +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + +```sh +$ npm install mime-types +``` + +## Adding Types + +All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db), +so open a PR there if you'd like to add mime types. + +## API + +```js +var mime = require('mime-types') +``` + +All functions return `false` if input is invalid or not found. + +### mime.lookup(path) + +Lookup the content-type associated with a file. + +```js +mime.lookup('json') // 'application/json' +mime.lookup('.md') // 'text/markdown' +mime.lookup('file.html') // 'text/html' +mime.lookup('folder/file.js') // 'application/javascript' +mime.lookup('folder/.htaccess') // false + +mime.lookup('cats') // false +``` + +### mime.contentType(type) + +Create a full content-type header given a content-type or extension. + +```js +mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' +mime.contentType('file.json') // 'application/json; charset=utf-8' + +// from a full path +mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' +``` + +### mime.extension(type) + +Get the default extension for a content-type. + +```js +mime.extension('application/octet-stream') // 'bin' +``` + +### mime.charset(type) + +Lookup the implied default charset of a content-type. + +```js +mime.charset('text/markdown') // 'UTF-8' +``` + +### var type = mime.types[extension] + +A map of content-types by extension. + +### [extensions...] = mime.extensions[type] + +A map of extensions by content-type. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/mime-types.svg +[npm-url]: https://npmjs.org/package/mime-types +[node-version-image]: https://img.shields.io/node/v/mime-types.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg +[travis-url]: https://travis-ci.org/jshttp/mime-types +[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/mime-types +[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg +[downloads-url]: https://npmjs.org/package/mime-types diff --git a/node_modules/mime-types/index.js b/node_modules/mime-types/index.js new file mode 100644 index 0000000..b9f34d5 --- /dev/null +++ b/node_modules/mime-types/index.js @@ -0,0 +1,188 @@ +/*! + * mime-types + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var db = require('mime-db') +var extname = require('path').extname + +/** + * Module variables. + * @private + */ + +var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/ +var TEXT_TYPE_REGEXP = /^text\//i + +/** + * Module exports. + * @public + */ + +exports.charset = charset +exports.charsets = { lookup: charset } +exports.contentType = contentType +exports.extension = extension +exports.extensions = Object.create(null) +exports.lookup = lookup +exports.types = Object.create(null) + +// Populate the extensions/types maps +populateMaps(exports.extensions, exports.types) + +/** + * Get the default charset for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function charset (type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = EXTRACT_TYPE_REGEXP.exec(type) + var mime = match && db[match[1].toLowerCase()] + + if (mime && mime.charset) { + return mime.charset + } + + // default text/* to utf-8 + if (match && TEXT_TYPE_REGEXP.test(match[1])) { + return 'UTF-8' + } + + return false +} + +/** + * Create a full Content-Type header given a MIME type or extension. + * + * @param {string} str + * @return {boolean|string} + */ + +function contentType (str) { + // TODO: should this even be in this module? + if (!str || typeof str !== 'string') { + return false + } + + var mime = str.indexOf('/') === -1 + ? exports.lookup(str) + : str + + if (!mime) { + return false + } + + // TODO: use content-type or other module + if (mime.indexOf('charset') === -1) { + var charset = exports.charset(mime) + if (charset) mime += '; charset=' + charset.toLowerCase() + } + + return mime +} + +/** + * Get the default extension for a MIME type. + * + * @param {string} type + * @return {boolean|string} + */ + +function extension (type) { + if (!type || typeof type !== 'string') { + return false + } + + // TODO: use media-typer + var match = EXTRACT_TYPE_REGEXP.exec(type) + + // get extensions + var exts = match && exports.extensions[match[1].toLowerCase()] + + if (!exts || !exts.length) { + return false + } + + return exts[0] +} + +/** + * Lookup the MIME type for a file path/extension. + * + * @param {string} path + * @return {boolean|string} + */ + +function lookup (path) { + if (!path || typeof path !== 'string') { + return false + } + + // get the extension ("ext" or ".ext" or full path) + var extension = extname('x.' + path) + .toLowerCase() + .substr(1) + + if (!extension) { + return false + } + + return exports.types[extension] || false +} + +/** + * Populate the extensions and types maps. + * @private + */ + +function populateMaps (extensions, types) { + // source preference (least -> most) + var preference = ['nginx', 'apache', undefined, 'iana'] + + Object.keys(db).forEach(function forEachMimeType (type) { + var mime = db[type] + var exts = mime.extensions + + if (!exts || !exts.length) { + return + } + + // mime -> extensions + extensions[type] = exts + + // extension -> mime + for (var i = 0; i < exts.length; i++) { + var extension = exts[i] + + if (types[extension]) { + var from = preference.indexOf(db[types[extension]].source) + var to = preference.indexOf(mime.source) + + if (types[extension] !== 'application/octet-stream' && + (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) { + // skip the remapping + continue + } + } + + // set the extension -> mime + types[extension] = type + } + }) +} diff --git a/node_modules/mime-types/package.json b/node_modules/mime-types/package.json new file mode 100644 index 0000000..ae4c477 --- /dev/null +++ b/node_modules/mime-types/package.json @@ -0,0 +1,86 @@ +{ + "_from": "mime-types@~2.1.18", + "_id": "mime-types@2.1.20", + "_inBundle": false, + "_integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "_location": "/mime-types", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "mime-types@~2.1.18", + "name": "mime-types", + "escapedName": "mime-types", + "rawSpec": "~2.1.18", + "saveSpec": null, + "fetchSpec": "~2.1.18" + }, + "_requiredBy": [ + "/type-is" + ], + "_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "_shasum": "930cb719d571e903738520f8470911548ca2cc19", + "_spec": "mime-types@~2.1.18", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/type-is", + "bugs": { + "url": "https://github.com/jshttp/mime-types/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jeremiah Senkpiel", + "email": "fishrock123@rocketmail.com", + "url": "https://searchbeam.jit.su" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "dependencies": { + "mime-db": "~1.36.0" + }, + "deprecated": false, + "description": "The ultimate javascript content-type utility.", + "devDependencies": { + "eslint": "4.19.1", + "eslint-config-standard": "11.0.0", + "eslint-plugin-import": "2.13.0", + "eslint-plugin-node": "6.0.1", + "eslint-plugin-promise": "3.8.0", + "eslint-plugin-standard": "3.1.0", + "istanbul": "0.4.5", + "mocha": "1.21.5" + }, + "engines": { + "node": ">= 0.6" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "homepage": "https://github.com/jshttp/mime-types#readme", + "keywords": [ + "mime", + "types" + ], + "license": "MIT", + "name": "mime-types", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/mime-types.git" + }, + "scripts": { + "lint": "eslint .", + "test": "mocha --reporter spec test/test.js", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js" + }, + "version": "2.1.20" +} diff --git a/node_modules/mime/.eslintrc.json b/node_modules/mime/.eslintrc.json new file mode 100644 index 0000000..845527f --- /dev/null +++ b/node_modules/mime/.eslintrc.json @@ -0,0 +1,51 @@ +{ + "root": true, + "parserOptions": { + "ecmaVersion": 6 + }, + "env": { + "browser": true, + "commonjs": true, + "node": true, + "mocha": true + }, + "extends": ["eslint:recommended"], + "rules": { + "array-bracket-spacing": ["warn", "never"], + "arrow-body-style": ["warn", "as-needed"], + "arrow-parens": ["warn", "as-needed"], + "arrow-spacing": "warn", + "brace-style": ["warn", "1tbs"], + "camelcase": "warn", + "comma-spacing": ["warn", {"after": true}], + "dot-notation": "warn", + "eqeqeq": ["warn", "smart"], + "indent": ["warn", 2, { + "SwitchCase": 1, + "FunctionDeclaration": {"parameters": 1}, + "MemberExpression": 1, + "CallExpression": {"arguments": 1} + }], + "key-spacing": ["warn", {"beforeColon": false, "afterColon": true, "mode": "minimum"}], + "keyword-spacing": "warn", + "no-console": "off", + "no-empty": "off", + "no-multi-spaces": "warn", + "no-redeclare": "off", + "no-restricted-globals": ["warn", "Promise"], + "no-trailing-spaces": "warn", + "no-undef": "error", + "no-unused-vars": ["warn", {"args": "none"}], + "one-var": ["warn", "never"], + "padded-blocks": ["warn", "never"], + "object-curly-spacing": ["warn", "never"], + "quotes": ["warn", "single"], + "react/prop-types": "off", + "react/jsx-no-bind": "off", + "semi": ["warn", "always"], + "space-before-blocks": ["warn", "always"], + "space-before-function-paren": ["warn", "never"], + "space-in-parens": ["warn", "never"], + "strict": ["warn", "global"] + } +} diff --git a/node_modules/mime/.github/ISSUE_TEMPLATE.md b/node_modules/mime/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..8764eff --- /dev/null +++ b/node_modules/mime/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,6 @@ +### If you have an issue with a specific extension or type + +Locate the definition for your extension/type in the [db.json file](https://github.com/jshttp/mime-db/blob/master/db.json) in the `mime-db` project. Does it look right? + + [ ] No. [File a `mime-db` issue](https://github.com/jshttp/mime-db/issues/new). + [ ] Yes: Go ahead and submit your issue/PR here and I'll look into it. diff --git a/node_modules/mime/.github/PULL_REQUEST_TEMPLATE.md b/node_modules/mime/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..8764eff --- /dev/null +++ b/node_modules/mime/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,6 @@ +### If you have an issue with a specific extension or type + +Locate the definition for your extension/type in the [db.json file](https://github.com/jshttp/mime-db/blob/master/db.json) in the `mime-db` project. Does it look right? + + [ ] No. [File a `mime-db` issue](https://github.com/jshttp/mime-db/issues/new). + [ ] Yes: Go ahead and submit your issue/PR here and I'll look into it. diff --git a/node_modules/mime/.npmignore b/node_modules/mime/.npmignore deleted file mode 100644 index e69de29..0000000 diff --git a/node_modules/mime/.travis.yml b/node_modules/mime/.travis.yml new file mode 100644 index 0000000..71b650d --- /dev/null +++ b/node_modules/mime/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "4" + - "6" + - "8" diff --git a/node_modules/mime/CHANGELOG.md b/node_modules/mime/CHANGELOG.md new file mode 100644 index 0000000..cee455d --- /dev/null +++ b/node_modules/mime/CHANGELOG.md @@ -0,0 +1,225 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +## [2.3.1](https://github.com/broofa/node-mime/compare/v2.3.0...v2.3.1) (2018-04-11) + + +### Bug Fixes + +* fix [#198](https://github.com/broofa/node-mime/issues/198) ([25ca180](https://github.com/broofa/node-mime/commit/25ca180)) + + + + +# [2.3.0](https://github.com/broofa/node-mime/compare/v2.2.2...v2.3.0) (2018-04-11) + + +### Bug Fixes + +* fix [#192](https://github.com/broofa/node-mime/issues/192) ([5c35df6](https://github.com/broofa/node-mime/commit/5c35df6)) + + +### Features + +* add travis-ci testing ([d64160f](https://github.com/broofa/node-mime/commit/d64160f)) + + + + +## [2.2.2](https://github.com/broofa/node-mime/compare/v2.2.1...v2.2.2) (2018-03-30) + + +### Bug Fixes + +* update types files to mime-db@1.32.0 ([85aac16](https://github.com/broofa/node-mime/commit/85aac16)) + + + + +## [2.2.1](https://github.com/broofa/node-mime/compare/v2.2.0...v2.2.1) (2018-03-30) + + +### Bug Fixes + +* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/node-mime/issues/180) ([b5c83fb](https://github.com/broofa/node-mime/commit/b5c83fb)) + + + + +# [2.2.0](https://github.com/broofa/node-mime/compare/v2.1.0...v2.2.0) (2018-01-04) + + +### Features + +* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/node-mime/issues/180) ([10f82ac](https://github.com/broofa/node-mime/commit/10f82ac)) + + + + +# [2.1.0](https://github.com/broofa/node-mime/compare/v2.0.5...v2.1.0) (2017-12-22) + + +### Features + +* Upgrade to mime-db@1.32.0. Fixes [#185](https://github.com/broofa/node-mime/issues/185) ([3f775ba](https://github.com/broofa/node-mime/commit/3f775ba)) + + + + +## [2.0.5](https://github.com/broofa/node-mime/compare/v2.0.1...v2.0.5) (2017-12-22) + + +### Bug Fixes + +* ES5 support (back to node v0.4) ([f14ccb6](https://github.com/broofa/node-mime/commit/f14ccb6)) + + + +# Changelog + +## v2.0.4 (24/11/2017) +- [**closed**] Switch to mime-score module for resolving extension contention issues. [#182](https://github.com/broofa/node-mime/issues/182) +- [**closed**] Update mime-db to 1.31.0 in v1.x branch [#181](https://github.com/broofa/node-mime/issues/181) + +--- + +## v1.5.0 (22/11/2017) +- [**closed**] need ES5 version ready in npm package [#179](https://github.com/broofa/node-mime/issues/179) +- [**closed**] mime-db no trace of iWork - pages / numbers / etc. [#178](https://github.com/broofa/node-mime/issues/178) +- [**closed**] How it works in brownser ? [#176](https://github.com/broofa/node-mime/issues/176) +- [**closed**] Missing `./Mime` [#175](https://github.com/broofa/node-mime/issues/175) +- [**closed**] Vulnerable Regular Expression [#167](https://github.com/broofa/node-mime/issues/167) + +--- + +## v2.0.3 (25/09/2017) +*No changelog for this release.* + +--- + +## v1.4.1 (25/09/2017) +- [**closed**] Issue when bundling with webpack [#172](https://github.com/broofa/node-mime/issues/172) + +--- + +## v2.0.2 (15/09/2017) +- [**V2**] fs.readFileSync is not a function [#165](https://github.com/broofa/node-mime/issues/165) +- [**closed**] The extension for video/quicktime should map to .mov, not .qt [#164](https://github.com/broofa/node-mime/issues/164) +- [**V2**] [v2 Feedback request] Mime class API [#163](https://github.com/broofa/node-mime/issues/163) +- [**V2**] [v2 Feedback request] Resolving conflicts over extensions [#162](https://github.com/broofa/node-mime/issues/162) +- [**V2**] Allow callers to load module with official, full, or no defined types. [#161](https://github.com/broofa/node-mime/issues/161) +- [**V2**] Use "facets" to resolve extension conflicts [#160](https://github.com/broofa/node-mime/issues/160) +- [**V2**] Remove fs and path dependencies [#152](https://github.com/broofa/node-mime/issues/152) +- [**V2**] Default content-type should not be application/octet-stream [#139](https://github.com/broofa/node-mime/issues/139) +- [**V2**] reset mime-types [#124](https://github.com/broofa/node-mime/issues/124) +- [**V2**] Extensionless paths should return null or false [#113](https://github.com/broofa/node-mime/issues/113) + +--- + +## v2.0.1 (14/09/2017) +- [**closed**] Changelog for v2.0 does not mention breaking changes [#171](https://github.com/broofa/node-mime/issues/171) +- [**closed**] MIME breaking with 'class' declaration as it is without 'use strict mode' [#170](https://github.com/broofa/node-mime/issues/170) + +--- + +## v2.0.0 (12/09/2017) +- [**closed**] woff and woff2 [#168](https://github.com/broofa/node-mime/issues/168) + +--- + +## v1.4.0 (28/08/2017) +- [**closed**] support for ac3 voc files [#159](https://github.com/broofa/node-mime/issues/159) +- [**closed**] Help understanding change from application/xml to text/xml [#158](https://github.com/broofa/node-mime/issues/158) +- [**closed**] no longer able to override mimetype [#157](https://github.com/broofa/node-mime/issues/157) +- [**closed**] application/vnd.adobe.photoshop [#147](https://github.com/broofa/node-mime/issues/147) +- [**closed**] Directories should appear as something other than application/octet-stream [#135](https://github.com/broofa/node-mime/issues/135) +- [**closed**] requested features [#131](https://github.com/broofa/node-mime/issues/131) +- [**closed**] Make types.json loading optional? [#129](https://github.com/broofa/node-mime/issues/129) +- [**closed**] Cannot find module './types.json' [#120](https://github.com/broofa/node-mime/issues/120) +- [**V2**] .wav files show up as "audio/x-wav" instead of "audio/x-wave" [#118](https://github.com/broofa/node-mime/issues/118) +- [**closed**] Don't be a pain in the ass for node community [#108](https://github.com/broofa/node-mime/issues/108) +- [**closed**] don't make default_type global [#78](https://github.com/broofa/node-mime/issues/78) +- [**closed**] mime.extension() fails if the content-type is parameterized [#74](https://github.com/broofa/node-mime/issues/74) + +--- + +## v1.3.6 (11/05/2017) +- [**closed**] .md should be text/markdown as of March 2016 [#154](https://github.com/broofa/node-mime/issues/154) +- [**closed**] Error while installing mime [#153](https://github.com/broofa/node-mime/issues/153) +- [**closed**] application/manifest+json [#149](https://github.com/broofa/node-mime/issues/149) +- [**closed**] Dynamic adaptive streaming over HTTP (DASH) file extension typo [#141](https://github.com/broofa/node-mime/issues/141) +- [**closed**] charsets image/png undefined [#140](https://github.com/broofa/node-mime/issues/140) +- [**closed**] Mime-db dependency out of date [#130](https://github.com/broofa/node-mime/issues/130) +- [**closed**] how to support plist? [#126](https://github.com/broofa/node-mime/issues/126) +- [**closed**] how does .types file format look like? [#123](https://github.com/broofa/node-mime/issues/123) +- [**closed**] Feature: support for expanding MIME patterns [#121](https://github.com/broofa/node-mime/issues/121) +- [**closed**] DEBUG_MIME doesn't work [#117](https://github.com/broofa/node-mime/issues/117) + +--- + +## v1.3.4 (06/02/2015) +*No changelog for this release.* + +--- + +## v1.3.3 (06/02/2015) +*No changelog for this release.* + +--- + +## v1.3.1 (05/02/2015) +- [**closed**] Consider adding support for Handlebars .hbs file ending [#111](https://github.com/broofa/node-mime/issues/111) +- [**closed**] Consider adding support for hjson. [#110](https://github.com/broofa/node-mime/issues/110) +- [**closed**] Add mime type for Opus audio files [#94](https://github.com/broofa/node-mime/issues/94) +- [**closed**] Consider making the `Requesting New Types` information more visible [#77](https://github.com/broofa/node-mime/issues/77) + +--- + +## v1.3.0 (05/02/2015) +- [**closed**] Add common name? [#114](https://github.com/broofa/node-mime/issues/114) +- [**closed**] application/x-yaml [#104](https://github.com/broofa/node-mime/issues/104) +- [**closed**] Add mime type for WOFF file format 2.0 [#102](https://github.com/broofa/node-mime/issues/102) +- [**closed**] application/x-msi for .msi [#99](https://github.com/broofa/node-mime/issues/99) +- [**closed**] Add mimetype for gettext translation files [#98](https://github.com/broofa/node-mime/issues/98) +- [**closed**] collaborators [#88](https://github.com/broofa/node-mime/issues/88) +- [**closed**] getting errot in installation of mime module...any1 can help? [#87](https://github.com/broofa/node-mime/issues/87) +- [**closed**] should application/json's charset be utf8? [#86](https://github.com/broofa/node-mime/issues/86) +- [**closed**] Add "license" and "licenses" to package.json [#81](https://github.com/broofa/node-mime/issues/81) +- [**closed**] lookup with extension-less file on Windows returns wrong type [#68](https://github.com/broofa/node-mime/issues/68) + +--- + +## v1.2.11 (15/08/2013) +- [**closed**] Update mime.types [#65](https://github.com/broofa/node-mime/issues/65) +- [**closed**] Publish a new version [#63](https://github.com/broofa/node-mime/issues/63) +- [**closed**] README should state upfront that "application/octet-stream" is default for unknown extension [#55](https://github.com/broofa/node-mime/issues/55) +- [**closed**] Suggested improvement to the charset API [#52](https://github.com/broofa/node-mime/issues/52) + +--- + +## v1.2.10 (25/07/2013) +- [**closed**] Mime type for woff files should be application/font-woff and not application/x-font-woff [#62](https://github.com/broofa/node-mime/issues/62) +- [**closed**] node.types in conflict with mime.types [#51](https://github.com/broofa/node-mime/issues/51) + +--- + +## v1.2.9 (17/01/2013) +- [**closed**] Please update "mime" NPM [#49](https://github.com/broofa/node-mime/issues/49) +- [**closed**] Please add semicolon [#46](https://github.com/broofa/node-mime/issues/46) +- [**closed**] parse full mime types [#43](https://github.com/broofa/node-mime/issues/43) + +--- + +## v1.2.8 (10/01/2013) +- [**closed**] /js directory mime is application/javascript. Is it correct? [#47](https://github.com/broofa/node-mime/issues/47) +- [**closed**] Add mime types for lua code. [#45](https://github.com/broofa/node-mime/issues/45) + +--- + +## v1.2.7 (19/10/2012) +- [**closed**] cannot install 1.2.7 via npm [#41](https://github.com/broofa/node-mime/issues/41) +- [**closed**] Transfer ownership to @broofa [#36](https://github.com/broofa/node-mime/issues/36) +- [**closed**] it's wrong to set charset to UTF-8 for text [#30](https://github.com/broofa/node-mime/issues/30) +- [**closed**] Allow multiple instances of MIME types container [#27](https://github.com/broofa/node-mime/issues/27) diff --git a/node_modules/mime/CONTRIBUTING.md b/node_modules/mime/CONTRIBUTING.md new file mode 100644 index 0000000..dd5c86a --- /dev/null +++ b/node_modules/mime/CONTRIBUTING.md @@ -0,0 +1,5 @@ +1. Commit messages should have a [Conventional Commit](https://conventionalcommits.org/) prefix. +2. If you're editing the `types/*` files, just stop. These are auto-generated from [mime-db](https://github.com/jshttp/mime-db). Go talk to those folks. +3. README edits should be made to [src/README_md.js](src/README_md.js). + +Thanks for helping out with this project. You rock! diff --git a/node_modules/mime/README.md b/node_modules/mime/README.md index 506fbe5..29603d5 100644 --- a/node_modules/mime/README.md +++ b/node_modules/mime/README.md @@ -1,90 +1,188 @@ -# mime + +# Mime -Comprehensive MIME type mapping API based on mime-db module. +A comprehensive, compact MIME type module. -## Install +## Version 2 Notes -Install with [npm](http://github.com/isaacs/npm): +Version 2 is a breaking change from 1.x as the semver implies. Specifically: - npm install mime +* `lookup()` renamed to `getType()` +* `extension()` renamed to `getExtension()` +* `charset()` and `load()` methods have been removed -## Contributing / Testing +If you prefer the legacy version of this module please `npm install mime@^1`. Version 1 docs may be found [here](https://github.com/broofa/node-mime/tree/v1.4.0). - npm run test +## Install -## Command Line +### NPM +``` +npm install mime +``` - mime [path_string] +### Browser -E.g. +It is recommended that you use a bundler such as +[webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to +package your code. However, browser-ready versions are available via wzrd.in. +E.g. For the full version: - > mime scripts/jquery.js - application/javascript + + + + + + + +``` + +A simple example of how to use BSON in `Node.js`: + +```js +// Get BSON parser class +var BSON = require('bson') +// Get the Long type +var Long = BSON.Long; +// Create a bson parser instance +var bson = new BSON(); + +// Serialize document +var doc = { long: Long.fromNumber(100) } + +// Serialize a document +var data = bson.serialize(doc) +console.log('data:', data) + +// Deserialize the resulting Buffer +var doc_2 = bson.deserialize(data) +console.log('doc_2:', doc_2) +``` + +## Installation + +`npm install bson` + +## API + +### BSON types + +For all BSON types documentation, please refer to the following sources: + * [MongoDB BSON Type Reference](https://docs.mongodb.com/manual/reference/bson-types/) + * [BSON Spec](https://bsonspec.org/) + +### BSON serialization and deserialiation + +**`new BSON()`** - Creates a new BSON serializer/deserializer you can use to serialize and deserialize BSON. + +#### BSON.serialize + +The BSON `serialize` method takes a JavaScript object and an optional options object and returns a Node.js Buffer. + + * `BSON.serialize(object, options)` + * @param {Object} object the JavaScript object to serialize. + * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions. + * @param {Boolean} [options.ignoreUndefined=true] + * @return {Buffer} returns a Buffer instance. + +#### BSON.serializeWithBufferAndIndex + +The BSON `serializeWithBufferAndIndex` method takes an object, a target buffer instance and an optional options object and returns the end serialization index in the final buffer. + + * `BSON.serializeWithBufferAndIndex(object, buffer, options)` + * @param {Object} object the JavaScript object to serialize. + * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object. + * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields. + * @param {Number} [options.index=0] the index in the buffer where we wish to start serializing into. + * @return {Number} returns the index pointing to the last written byte in the buffer. + +#### BSON.calculateObjectSize + +The BSON `calculateObjectSize` method takes a JavaScript object and an optional options object and returns the size of the BSON object. + + * `BSON.calculateObjectSize(object, options)` + * @param {Object} object the JavaScript object to serialize. + * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions. + * @param {Boolean} [options.ignoreUndefined=true] + * @return {Buffer} returns a Buffer instance. + +#### BSON.deserialize + +The BSON `deserialize` method takes a Node.js Buffer and an optional options object and returns a deserialized JavaScript object. + + * `BSON.deserialize(buffer, options)` + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Object} returns the deserialized Javascript Object. + +#### BSON.deserializeStream + +The BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and allow more control over deserialization of a Buffer containing concatenated BSON documents. + + * `BSON.deserializeStream(buffer, startIndex, numberOfDocuments, documents, docStartIndex, options)` + * @param {Buffer} buffer the buffer containing the serialized set of BSON documents. + * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start. + * @param {Number} numberOfDocuments number of documents to deserialize. + * @param {Array} documents an array where to store the deserialized documents. + * @param {Number} docStartIndex the index in the documents array from where to start inserting documents. + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents. + +## FAQ + +#### Why does `undefined` get converted to `null`? + +The `undefined` BSON type has been [deprecated for many years](http://bsonspec.org/spec.html), so this library has dropped support for it. Use the `ignoreUndefined` option (for example, from the [driver](http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect) ) to instead remove `undefined` keys. + +#### How do I add custom serialization logic? + +This library looks for `toBSON()` functions on every path, and calls the `toBSON()` function to get the value to serialize. + +```javascript +var bson = new BSON(); + +class CustomSerialize { + toBSON() { + return 42; + } +} + +const obj = { answer: new CustomSerialize() }; +// "{ answer: 42 }" +console.log(bson.deserialize(bson.serialize(obj))); +``` diff --git a/node_modules/mongodb-core/node_modules/bson/bower.json b/node_modules/mongodb-core/node_modules/bson/bower.json new file mode 100644 index 0000000..b32140e --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/bower.json @@ -0,0 +1,25 @@ +{ + "name": "bson", + "description": "A bson parser for node.js and the browser", + "keywords": [ + "mongodb", + "bson", + "parser" + ], + "author": "Christian Amor Kvalheim ", + "main": "./browser_build/bson.js", + "license": "Apache-2.0", + "moduleType": [ + "globals", + "node" + ], + "ignore": [ + "**/.*", + "alternate_parsers", + "benchmarks", + "bower_components", + "node_modules", + "test", + "tools" + ] +} diff --git a/node_modules/mongodb-core/node_modules/bson/browser_build/bson.js b/node_modules/mongodb-core/node_modules/bson/browser_build/bson.js new file mode 100644 index 0000000..a02bf14 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/browser_build/bson.js @@ -0,0 +1,17748 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else { + var a = factory(); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "/"; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(1); + module.exports = __webpack_require__(327); + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {"use strict"; + + __webpack_require__(2); + + __webpack_require__(323); + + __webpack_require__(324); + + if (global._babelPolyfill) { + throw new Error("only one instance of babel-polyfill is allowed"); + } + global._babelPolyfill = true; + + var DEFINE_PROPERTY = "defineProperty"; + function define(O, key, value) { + O[key] || Object[DEFINE_PROPERTY](O, key, { + writable: true, + configurable: true, + value: value + }); + } + + define(String.prototype, "padLeft", "".padStart); + define(String.prototype, "padRight", "".padEnd); + + "pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) { + [][key] && define(Array, key, Function.call.bind([][key])); + }); + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(3); + __webpack_require__(51); + __webpack_require__(52); + __webpack_require__(53); + __webpack_require__(54); + __webpack_require__(56); + __webpack_require__(59); + __webpack_require__(60); + __webpack_require__(61); + __webpack_require__(62); + __webpack_require__(63); + __webpack_require__(64); + __webpack_require__(65); + __webpack_require__(66); + __webpack_require__(67); + __webpack_require__(69); + __webpack_require__(71); + __webpack_require__(73); + __webpack_require__(75); + __webpack_require__(78); + __webpack_require__(79); + __webpack_require__(80); + __webpack_require__(84); + __webpack_require__(86); + __webpack_require__(88); + __webpack_require__(91); + __webpack_require__(92); + __webpack_require__(93); + __webpack_require__(94); + __webpack_require__(96); + __webpack_require__(97); + __webpack_require__(98); + __webpack_require__(99); + __webpack_require__(100); + __webpack_require__(101); + __webpack_require__(102); + __webpack_require__(104); + __webpack_require__(105); + __webpack_require__(106); + __webpack_require__(108); + __webpack_require__(109); + __webpack_require__(110); + __webpack_require__(112); + __webpack_require__(114); + __webpack_require__(115); + __webpack_require__(116); + __webpack_require__(117); + __webpack_require__(118); + __webpack_require__(119); + __webpack_require__(120); + __webpack_require__(121); + __webpack_require__(122); + __webpack_require__(123); + __webpack_require__(124); + __webpack_require__(125); + __webpack_require__(126); + __webpack_require__(131); + __webpack_require__(132); + __webpack_require__(136); + __webpack_require__(137); + __webpack_require__(138); + __webpack_require__(139); + __webpack_require__(141); + __webpack_require__(142); + __webpack_require__(143); + __webpack_require__(144); + __webpack_require__(145); + __webpack_require__(146); + __webpack_require__(147); + __webpack_require__(148); + __webpack_require__(149); + __webpack_require__(150); + __webpack_require__(151); + __webpack_require__(152); + __webpack_require__(153); + __webpack_require__(154); + __webpack_require__(155); + __webpack_require__(157); + __webpack_require__(158); + __webpack_require__(160); + __webpack_require__(161); + __webpack_require__(167); + __webpack_require__(168); + __webpack_require__(170); + __webpack_require__(171); + __webpack_require__(172); + __webpack_require__(176); + __webpack_require__(177); + __webpack_require__(178); + __webpack_require__(179); + __webpack_require__(180); + __webpack_require__(182); + __webpack_require__(183); + __webpack_require__(184); + __webpack_require__(185); + __webpack_require__(188); + __webpack_require__(190); + __webpack_require__(191); + __webpack_require__(192); + __webpack_require__(194); + __webpack_require__(196); + __webpack_require__(198); + __webpack_require__(199); + __webpack_require__(200); + __webpack_require__(202); + __webpack_require__(203); + __webpack_require__(204); + __webpack_require__(205); + __webpack_require__(216); + __webpack_require__(220); + __webpack_require__(221); + __webpack_require__(223); + __webpack_require__(224); + __webpack_require__(228); + __webpack_require__(229); + __webpack_require__(231); + __webpack_require__(232); + __webpack_require__(233); + __webpack_require__(234); + __webpack_require__(235); + __webpack_require__(236); + __webpack_require__(237); + __webpack_require__(238); + __webpack_require__(239); + __webpack_require__(240); + __webpack_require__(241); + __webpack_require__(242); + __webpack_require__(243); + __webpack_require__(244); + __webpack_require__(245); + __webpack_require__(246); + __webpack_require__(247); + __webpack_require__(248); + __webpack_require__(249); + __webpack_require__(251); + __webpack_require__(252); + __webpack_require__(253); + __webpack_require__(254); + __webpack_require__(255); + __webpack_require__(257); + __webpack_require__(258); + __webpack_require__(259); + __webpack_require__(261); + __webpack_require__(262); + __webpack_require__(263); + __webpack_require__(264); + __webpack_require__(265); + __webpack_require__(266); + __webpack_require__(267); + __webpack_require__(268); + __webpack_require__(270); + __webpack_require__(271); + __webpack_require__(273); + __webpack_require__(274); + __webpack_require__(275); + __webpack_require__(276); + __webpack_require__(279); + __webpack_require__(280); + __webpack_require__(282); + __webpack_require__(283); + __webpack_require__(284); + __webpack_require__(285); + __webpack_require__(287); + __webpack_require__(288); + __webpack_require__(289); + __webpack_require__(290); + __webpack_require__(291); + __webpack_require__(292); + __webpack_require__(293); + __webpack_require__(294); + __webpack_require__(295); + __webpack_require__(296); + __webpack_require__(298); + __webpack_require__(299); + __webpack_require__(300); + __webpack_require__(301); + __webpack_require__(302); + __webpack_require__(303); + __webpack_require__(304); + __webpack_require__(305); + __webpack_require__(306); + __webpack_require__(307); + __webpack_require__(308); + __webpack_require__(310); + __webpack_require__(311); + __webpack_require__(312); + __webpack_require__(313); + __webpack_require__(314); + __webpack_require__(315); + __webpack_require__(316); + __webpack_require__(317); + __webpack_require__(318); + __webpack_require__(319); + __webpack_require__(320); + __webpack_require__(321); + __webpack_require__(322); + module.exports = __webpack_require__(9); + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // ECMAScript 6 symbols shim + var global = __webpack_require__(4); + var has = __webpack_require__(5); + var DESCRIPTORS = __webpack_require__(6); + var $export = __webpack_require__(8); + var redefine = __webpack_require__(18); + var META = __webpack_require__(22).KEY; + var $fails = __webpack_require__(7); + var shared = __webpack_require__(23); + var setToStringTag = __webpack_require__(25); + var uid = __webpack_require__(19); + var wks = __webpack_require__(26); + var wksExt = __webpack_require__(27); + var wksDefine = __webpack_require__(28); + var enumKeys = __webpack_require__(29); + var isArray = __webpack_require__(44); + var anObject = __webpack_require__(12); + var isObject = __webpack_require__(13); + var toIObject = __webpack_require__(32); + var toPrimitive = __webpack_require__(16); + var createDesc = __webpack_require__(17); + var _create = __webpack_require__(45); + var gOPNExt = __webpack_require__(48); + var $GOPD = __webpack_require__(50); + var $DP = __webpack_require__(11); + var $keys = __webpack_require__(30); + var gOPD = $GOPD.f; + var dP = $DP.f; + var gOPN = gOPNExt.f; + var $Symbol = global.Symbol; + var $JSON = global.JSON; + var _stringify = $JSON && $JSON.stringify; + var PROTOTYPE = 'prototype'; + var HIDDEN = wks('_hidden'); + var TO_PRIMITIVE = wks('toPrimitive'); + var isEnum = {}.propertyIsEnumerable; + var SymbolRegistry = shared('symbol-registry'); + var AllSymbols = shared('symbols'); + var OPSymbols = shared('op-symbols'); + var ObjectProto = Object[PROTOTYPE]; + var USE_NATIVE = typeof $Symbol == 'function'; + var QObject = global.QObject; + // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 + var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; + + // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 + var setSymbolDesc = DESCRIPTORS && $fails(function () { + return _create(dP({}, 'a', { + get: function () { return dP(this, 'a', { value: 7 }).a; } + })).a != 7; + }) ? function (it, key, D) { + var protoDesc = gOPD(ObjectProto, key); + if (protoDesc) delete ObjectProto[key]; + dP(it, key, D); + if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc); + } : dP; + + var wrap = function (tag) { + var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); + sym._k = tag; + return sym; + }; + + var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) { + return typeof it == 'symbol'; + } : function (it) { + return it instanceof $Symbol; + }; + + var $defineProperty = function defineProperty(it, key, D) { + if (it === ObjectProto) $defineProperty(OPSymbols, key, D); + anObject(it); + key = toPrimitive(key, true); + anObject(D); + if (has(AllSymbols, key)) { + if (!D.enumerable) { + if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {})); + it[HIDDEN][key] = true; + } else { + if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; + D = _create(D, { enumerable: createDesc(0, false) }); + } return setSymbolDesc(it, key, D); + } return dP(it, key, D); + }; + var $defineProperties = function defineProperties(it, P) { + anObject(it); + var keys = enumKeys(P = toIObject(P)); + var i = 0; + var l = keys.length; + var key; + while (l > i) $defineProperty(it, key = keys[i++], P[key]); + return it; + }; + var $create = function create(it, P) { + return P === undefined ? _create(it) : $defineProperties(_create(it), P); + }; + var $propertyIsEnumerable = function propertyIsEnumerable(key) { + var E = isEnum.call(this, key = toPrimitive(key, true)); + if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false; + return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; + }; + var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { + it = toIObject(it); + key = toPrimitive(key, true); + if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return; + var D = gOPD(it, key); + if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; + return D; + }; + var $getOwnPropertyNames = function getOwnPropertyNames(it) { + var names = gOPN(toIObject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); + } return result; + }; + var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { + var IS_OP = it === ObjectProto; + var names = gOPN(IS_OP ? OPSymbols : toIObject(it)); + var result = []; + var i = 0; + var key; + while (names.length > i) { + if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]); + } return result; + }; + + // 19.4.1.1 Symbol([description]) + if (!USE_NATIVE) { + $Symbol = function Symbol() { + if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); + var tag = uid(arguments.length > 0 ? arguments[0] : undefined); + var $set = function (value) { + if (this === ObjectProto) $set.call(OPSymbols, value); + if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, createDesc(1, value)); + }; + if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set }); + return wrap(tag); + }; + redefine($Symbol[PROTOTYPE], 'toString', function toString() { + return this._k; + }); + + $GOPD.f = $getOwnPropertyDescriptor; + $DP.f = $defineProperty; + __webpack_require__(49).f = gOPNExt.f = $getOwnPropertyNames; + __webpack_require__(43).f = $propertyIsEnumerable; + __webpack_require__(42).f = $getOwnPropertySymbols; + + if (DESCRIPTORS && !__webpack_require__(24)) { + redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); + } + + wksExt.f = function (name) { + return wrap(wks(name)); + }; + } + + $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol }); + + for (var es6Symbols = ( + // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 + 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' + ).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]); + + for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]); + + $export($export.S + $export.F * !USE_NATIVE, 'Symbol', { + // 19.4.2.1 Symbol.for(key) + 'for': function (key) { + return has(SymbolRegistry, key += '') + ? SymbolRegistry[key] + : SymbolRegistry[key] = $Symbol(key); + }, + // 19.4.2.5 Symbol.keyFor(sym) + keyFor: function keyFor(sym) { + if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); + for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; + }, + useSetter: function () { setter = true; }, + useSimple: function () { setter = false; } + }); + + $export($export.S + $export.F * !USE_NATIVE, 'Object', { + // 19.1.2.2 Object.create(O [, Properties]) + create: $create, + // 19.1.2.4 Object.defineProperty(O, P, Attributes) + defineProperty: $defineProperty, + // 19.1.2.3 Object.defineProperties(O, Properties) + defineProperties: $defineProperties, + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + // 19.1.2.7 Object.getOwnPropertyNames(O) + getOwnPropertyNames: $getOwnPropertyNames, + // 19.1.2.8 Object.getOwnPropertySymbols(O) + getOwnPropertySymbols: $getOwnPropertySymbols + }); + + // 24.3.2 JSON.stringify(value [, replacer [, space]]) + $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () { + var S = $Symbol(); + // MS Edge converts symbol values to JSON as {} + // WebKit converts symbol values to JSON as null + // V8 throws on boxed symbols + return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; + })), 'JSON', { + stringify: function stringify(it) { + var args = [it]; + var i = 1; + var replacer, $replacer; + while (arguments.length > i) args.push(arguments[i++]); + $replacer = replacer = args[1]; + if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined + if (!isArray(replacer)) replacer = function (key, value) { + if (typeof $replacer == 'function') value = $replacer.call(this, key, value); + if (!isSymbol(value)) return value; + }; + args[1] = replacer; + return _stringify.apply($JSON, args); + } + }); + + // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) + $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); + // 19.4.3.5 Symbol.prototype[@@toStringTag] + setToStringTag($Symbol, 'Symbol'); + // 20.2.1.9 Math[@@toStringTag] + setToStringTag(Math, 'Math', true); + // 24.3.3 JSON[@@toStringTag] + setToStringTag(global.JSON, 'JSON', true); + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); + if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef + + +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + + var hasOwnProperty = {}.hasOwnProperty; + module.exports = function (it, key) { + return hasOwnProperty.call(it, key); + }; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + // Thank's IE8 for his funny defineProperty + module.exports = !__webpack_require__(7)(function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; + }); + + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + + module.exports = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } + }; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var core = __webpack_require__(9); + var hide = __webpack_require__(10); + var redefine = __webpack_require__(18); + var ctx = __webpack_require__(20); + var PROTOTYPE = 'prototype'; + + var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; + var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); + var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); + var key, own, out, exp; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + // export native or passed + out = (own ? target : source)[key]; + // bind timers to global for call from export context + exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // extend global + if (target) redefine(target, key, out, type & $export.U); + // export + if (exports[key] != out) hide(exports, key, exp); + if (IS_PROTO && expProto[key] != out) expProto[key] = out; + } + }; + global.core = core; + // type bitmap + $export.F = 1; // forced + $export.G = 2; // global + $export.S = 4; // static + $export.P = 8; // proto + $export.B = 16; // bind + $export.W = 32; // wrap + $export.U = 64; // safe + $export.R = 128; // real proto method for `library` + module.exports = $export; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + + var core = module.exports = { version: '2.5.7' }; + if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(11); + var createDesc = __webpack_require__(17); + module.exports = __webpack_require__(6) ? function (object, key, value) { + return dP.f(object, key, createDesc(1, value)); + } : function (object, key, value) { + object[key] = value; + return object; + }; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + + var anObject = __webpack_require__(12); + var IE8_DOM_DEFINE = __webpack_require__(14); + var toPrimitive = __webpack_require__(16); + var dP = Object.defineProperty; + + exports.f = __webpack_require__(6) ? Object.defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if (IE8_DOM_DEFINE) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; + }; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(13); + module.exports = function (it) { + if (!isObject(it)) throw TypeError(it + ' is not an object!'); + return it; + }; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + + module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + + module.exports = !__webpack_require__(6) && !__webpack_require__(7)(function () { + return Object.defineProperty(__webpack_require__(15)('div'), 'a', { get: function () { return 7; } }).a != 7; + }); + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(13); + var document = __webpack_require__(4).document; + // typeof document.createElement is 'object' in old IE + var is = isObject(document) && isObject(document.createElement); + module.exports = function (it) { + return is ? document.createElement(it) : {}; + }; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.1.1 ToPrimitive(input [, PreferredType]) + var isObject = __webpack_require__(13); + // instead of the ES6 spec version, we didn't implement @@toPrimitive case + // and the second argument - flag - preferred type is a string + module.exports = function (it, S) { + if (!isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); + }; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports) { + + module.exports = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; + }; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var hide = __webpack_require__(10); + var has = __webpack_require__(5); + var SRC = __webpack_require__(19)('src'); + var TO_STRING = 'toString'; + var $toString = Function[TO_STRING]; + var TPL = ('' + $toString).split(TO_STRING); + + __webpack_require__(9).inspectSource = function (it) { + return $toString.call(it); + }; + + (module.exports = function (O, key, val, safe) { + var isFunction = typeof val == 'function'; + if (isFunction) has(val, 'name') || hide(val, 'name', key); + if (O[key] === val) return; + if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); + if (O === global) { + O[key] = val; + } else if (!safe) { + delete O[key]; + hide(O, key, val); + } else if (O[key]) { + O[key] = val; + } else { + hide(O, key, val); + } + // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative + })(Function.prototype, TO_STRING, function toString() { + return typeof this == 'function' && this[SRC] || $toString.call(this); + }); + + +/***/ }), +/* 19 */ +/***/ (function(module, exports) { + + var id = 0; + var px = Math.random(); + module.exports = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); + }; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + + // optional / simple context binding + var aFunction = __webpack_require__(21); + module.exports = function (fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; + }; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports) { + + module.exports = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; + }; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + + var META = __webpack_require__(19)('meta'); + var isObject = __webpack_require__(13); + var has = __webpack_require__(5); + var setDesc = __webpack_require__(11).f; + var id = 0; + var isExtensible = Object.isExtensible || function () { + return true; + }; + var FREEZE = !__webpack_require__(7)(function () { + return isExtensible(Object.preventExtensions({})); + }); + var setMeta = function (it) { + setDesc(it, META, { value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + } }); + }; + var fastKey = function (it, create) { + // return primitive with prefix + if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMeta(it); + // return object ID + } return it[META].i; + }; + var getWeak = function (it, create) { + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + } return it[META].w; + }; + // add metadata on freeze-family methods calling + var onFreeze = function (it) { + if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); + return it; + }; + var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze + }; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + + var core = __webpack_require__(9); + var global = __webpack_require__(4); + var SHARED = '__core-js_shared__'; + var store = global[SHARED] || (global[SHARED] = {}); + + (module.exports = function (key, value) { + return store[key] || (store[key] = value !== undefined ? value : {}); + })('versions', []).push({ + version: core.version, + mode: __webpack_require__(24) ? 'pure' : 'global', + copyright: '© 2018 Denis Pushkarev (zloirock.ru)' + }); + + +/***/ }), +/* 24 */ +/***/ (function(module, exports) { + + module.exports = false; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + + var def = __webpack_require__(11).f; + var has = __webpack_require__(5); + var TAG = __webpack_require__(26)('toStringTag'); + + module.exports = function (it, tag, stat) { + if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); + }; + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + + var store = __webpack_require__(23)('wks'); + var uid = __webpack_require__(19); + var Symbol = __webpack_require__(4).Symbol; + var USE_SYMBOL = typeof Symbol == 'function'; + + var $exports = module.exports = function (name) { + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); + }; + + $exports.store = store; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + + exports.f = __webpack_require__(26); + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var core = __webpack_require__(9); + var LIBRARY = __webpack_require__(24); + var wksExt = __webpack_require__(27); + var defineProperty = __webpack_require__(11).f; + module.exports = function (name) { + var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); + if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); + }; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + + // all enumerable object keys, includes symbols + var getKeys = __webpack_require__(30); + var gOPS = __webpack_require__(42); + var pIE = __webpack_require__(43); + module.exports = function (it) { + var result = getKeys(it); + var getSymbols = gOPS.f; + if (getSymbols) { + var symbols = getSymbols(it); + var isEnum = pIE.f; + var i = 0; + var key; + while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); + } return result; + }; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.14 / 15.2.3.14 Object.keys(O) + var $keys = __webpack_require__(31); + var enumBugKeys = __webpack_require__(41); + + module.exports = Object.keys || function keys(O) { + return $keys(O, enumBugKeys); + }; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + + var has = __webpack_require__(5); + var toIObject = __webpack_require__(32); + var arrayIndexOf = __webpack_require__(36)(false); + var IE_PROTO = __webpack_require__(40)('IE_PROTO'); + + module.exports = function (object, names) { + var O = toIObject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); + } + return result; + }; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + + // to indexed object, toObject with fallback for non-array-like ES3 strings + var IObject = __webpack_require__(33); + var defined = __webpack_require__(35); + module.exports = function (it) { + return IObject(defined(it)); + }; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + + // fallback for non-array-like ES3 and non-enumerable old V8 strings + var cof = __webpack_require__(34); + // eslint-disable-next-line no-prototype-builtins + module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return cof(it) == 'String' ? it.split('') : Object(it); + }; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + + var toString = {}.toString; + + module.exports = function (it) { + return toString.call(it).slice(8, -1); + }; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + + // 7.2.1 RequireObjectCoercible(argument) + module.exports = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; + }; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + + // false -> Array#indexOf + // true -> Array#includes + var toIObject = __webpack_require__(32); + var toLength = __webpack_require__(37); + var toAbsoluteIndex = __webpack_require__(39); + module.exports = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIObject($this); + var length = toLength(O.length); + var index = toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) if (IS_INCLUDES || index in O) { + if (O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; + }; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.1.15 ToLength + var toInteger = __webpack_require__(38); + var min = Math.min; + module.exports = function (it) { + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 + }; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + + // 7.1.4 ToInteger + var ceil = Math.ceil; + var floor = Math.floor; + module.exports = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); + }; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + + var toInteger = __webpack_require__(38); + var max = Math.max; + var min = Math.min; + module.exports = function (index, length) { + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); + }; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + + var shared = __webpack_require__(23)('keys'); + var uid = __webpack_require__(19); + module.exports = function (key) { + return shared[key] || (shared[key] = uid(key)); + }; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + + // IE 8- don't enum bug keys + module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' + ).split(','); + + +/***/ }), +/* 42 */ +/***/ (function(module, exports) { + + exports.f = Object.getOwnPropertySymbols; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + + exports.f = {}.propertyIsEnumerable; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.2.2 IsArray(argument) + var cof = __webpack_require__(34); + module.exports = Array.isArray || function isArray(arg) { + return cof(arg) == 'Array'; + }; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + var anObject = __webpack_require__(12); + var dPs = __webpack_require__(46); + var enumBugKeys = __webpack_require__(41); + var IE_PROTO = __webpack_require__(40)('IE_PROTO'); + var Empty = function () { /* empty */ }; + var PROTOTYPE = 'prototype'; + + // Create object with fake `null` prototype: use iframe Object with cleared prototype + var createDict = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = __webpack_require__(15)('iframe'); + var i = enumBugKeys.length; + var lt = '<'; + var gt = '>'; + var iframeDocument; + iframe.style.display = 'none'; + __webpack_require__(47).appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); + iframeDocument.close(); + createDict = iframeDocument.F; + while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]]; + return createDict(); + }; + + module.exports = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + Empty[PROTOTYPE] = anObject(O); + result = new Empty(); + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); + }; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(11); + var anObject = __webpack_require__(12); + var getKeys = __webpack_require__(30); + + module.exports = __webpack_require__(6) ? Object.defineProperties : function defineProperties(O, Properties) { + anObject(O); + var keys = getKeys(Properties); + var length = keys.length; + var i = 0; + var P; + while (length > i) dP.f(O, P = keys[i++], Properties[P]); + return O; + }; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + + var document = __webpack_require__(4).document; + module.exports = document && document.documentElement; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + + // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window + var toIObject = __webpack_require__(32); + var gOPN = __webpack_require__(49).f; + var toString = {}.toString; + + var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + + var getWindowNames = function (it) { + try { + return gOPN(it); + } catch (e) { + return windowNames.slice(); + } + }; + + module.exports.f = function getOwnPropertyNames(it) { + return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); + }; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) + var $keys = __webpack_require__(31); + var hiddenKeys = __webpack_require__(41).concat('length', 'prototype'); + + exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return $keys(O, hiddenKeys); + }; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + + var pIE = __webpack_require__(43); + var createDesc = __webpack_require__(17); + var toIObject = __webpack_require__(32); + var toPrimitive = __webpack_require__(16); + var has = __webpack_require__(5); + var IE8_DOM_DEFINE = __webpack_require__(14); + var gOPD = Object.getOwnPropertyDescriptor; + + exports.f = __webpack_require__(6) ? gOPD : function getOwnPropertyDescriptor(O, P) { + O = toIObject(O); + P = toPrimitive(P, true); + if (IE8_DOM_DEFINE) try { + return gOPD(O, P); + } catch (e) { /* empty */ } + if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); + }; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + $export($export.S, 'Object', { create: __webpack_require__(45) }); + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) + $export($export.S + $export.F * !__webpack_require__(6), 'Object', { defineProperty: __webpack_require__(11).f }); + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) + $export($export.S + $export.F * !__webpack_require__(6), 'Object', { defineProperties: __webpack_require__(46) }); + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) + var toIObject = __webpack_require__(32); + var $getOwnPropertyDescriptor = __webpack_require__(50).f; + + __webpack_require__(55)('getOwnPropertyDescriptor', function () { + return function getOwnPropertyDescriptor(it, key) { + return $getOwnPropertyDescriptor(toIObject(it), key); + }; + }); + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + + // most Object methods by ES6 should accept primitives + var $export = __webpack_require__(8); + var core = __webpack_require__(9); + var fails = __webpack_require__(7); + module.exports = function (KEY, exec) { + var fn = (core.Object || {})[KEY] || Object[KEY]; + var exp = {}; + exp[KEY] = exec(fn); + $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); + }; + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.9 Object.getPrototypeOf(O) + var toObject = __webpack_require__(57); + var $getPrototypeOf = __webpack_require__(58); + + __webpack_require__(55)('getPrototypeOf', function () { + return function getPrototypeOf(it) { + return $getPrototypeOf(toObject(it)); + }; + }); + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.1.13 ToObject(argument) + var defined = __webpack_require__(35); + module.exports = function (it) { + return Object(defined(it)); + }; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) + var has = __webpack_require__(5); + var toObject = __webpack_require__(57); + var IE_PROTO = __webpack_require__(40)('IE_PROTO'); + var ObjectProto = Object.prototype; + + module.exports = Object.getPrototypeOf || function (O) { + O = toObject(O); + if (has(O, IE_PROTO)) return O[IE_PROTO]; + if (typeof O.constructor == 'function' && O instanceof O.constructor) { + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; + }; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.14 Object.keys(O) + var toObject = __webpack_require__(57); + var $keys = __webpack_require__(30); + + __webpack_require__(55)('keys', function () { + return function keys(it) { + return $keys(toObject(it)); + }; + }); + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.7 Object.getOwnPropertyNames(O) + __webpack_require__(55)('getOwnPropertyNames', function () { + return __webpack_require__(48).f; + }); + + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.5 Object.freeze(O) + var isObject = __webpack_require__(13); + var meta = __webpack_require__(22).onFreeze; + + __webpack_require__(55)('freeze', function ($freeze) { + return function freeze(it) { + return $freeze && isObject(it) ? $freeze(meta(it)) : it; + }; + }); + + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.17 Object.seal(O) + var isObject = __webpack_require__(13); + var meta = __webpack_require__(22).onFreeze; + + __webpack_require__(55)('seal', function ($seal) { + return function seal(it) { + return $seal && isObject(it) ? $seal(meta(it)) : it; + }; + }); + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.15 Object.preventExtensions(O) + var isObject = __webpack_require__(13); + var meta = __webpack_require__(22).onFreeze; + + __webpack_require__(55)('preventExtensions', function ($preventExtensions) { + return function preventExtensions(it) { + return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it; + }; + }); + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.12 Object.isFrozen(O) + var isObject = __webpack_require__(13); + + __webpack_require__(55)('isFrozen', function ($isFrozen) { + return function isFrozen(it) { + return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true; + }; + }); + + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.13 Object.isSealed(O) + var isObject = __webpack_require__(13); + + __webpack_require__(55)('isSealed', function ($isSealed) { + return function isSealed(it) { + return isObject(it) ? $isSealed ? $isSealed(it) : false : true; + }; + }); + + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.2.11 Object.isExtensible(O) + var isObject = __webpack_require__(13); + + __webpack_require__(55)('isExtensible', function ($isExtensible) { + return function isExtensible(it) { + return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false; + }; + }); + + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.3.1 Object.assign(target, source) + var $export = __webpack_require__(8); + + $export($export.S + $export.F, 'Object', { assign: __webpack_require__(68) }); + + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 19.1.2.1 Object.assign(target, source, ...) + var getKeys = __webpack_require__(30); + var gOPS = __webpack_require__(42); + var pIE = __webpack_require__(43); + var toObject = __webpack_require__(57); + var IObject = __webpack_require__(33); + var $assign = Object.assign; + + // should work with symbols and should have deterministic property order (V8 bug) + module.exports = !$assign || __webpack_require__(7)(function () { + var A = {}; + var B = {}; + // eslint-disable-next-line no-undef + var S = Symbol(); + var K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach(function (k) { B[k] = k; }); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; + }) ? function assign(target, source) { // eslint-disable-line no-unused-vars + var T = toObject(target); + var aLen = arguments.length; + var index = 1; + var getSymbols = gOPS.f; + var isEnum = pIE.f; + while (aLen > index) { + var S = IObject(arguments[index++]); + var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S); + var length = keys.length; + var j = 0; + var key; + while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; + } return T; + } : $assign; + + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.3.10 Object.is(value1, value2) + var $export = __webpack_require__(8); + $export($export.S, 'Object', { is: __webpack_require__(70) }); + + +/***/ }), +/* 70 */ +/***/ (function(module, exports) { + + // 7.2.9 SameValue(x, y) + module.exports = Object.is || function is(x, y) { + // eslint-disable-next-line no-self-compare + return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; + }; + + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.1.3.19 Object.setPrototypeOf(O, proto) + var $export = __webpack_require__(8); + $export($export.S, 'Object', { setPrototypeOf: __webpack_require__(72).set }); + + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + + // Works with __proto__ only. Old v8 can't work with null proto objects. + /* eslint-disable no-proto */ + var isObject = __webpack_require__(13); + var anObject = __webpack_require__(12); + var check = function (O, proto) { + anObject(O); + if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); + }; + module.exports = { + set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line + function (test, buggy, set) { + try { + set = __webpack_require__(20)(Function.call, __webpack_require__(50).f(Object.prototype, '__proto__').set, 2); + set(test, []); + buggy = !(test instanceof Array); + } catch (e) { buggy = true; } + return function setPrototypeOf(O, proto) { + check(O, proto); + if (buggy) O.__proto__ = proto; + else set(O, proto); + return O; + }; + }({}, false) : undefined), + check: check + }; + + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 19.1.3.6 Object.prototype.toString() + var classof = __webpack_require__(74); + var test = {}; + test[__webpack_require__(26)('toStringTag')] = 'z'; + if (test + '' != '[object z]') { + __webpack_require__(18)(Object.prototype, 'toString', function toString() { + return '[object ' + classof(this) + ']'; + }, true); + } + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + + // getting tag from 19.1.3.6 Object.prototype.toString() + var cof = __webpack_require__(34); + var TAG = __webpack_require__(26)('toStringTag'); + // ES3 wrong here + var ARG = cof(function () { return arguments; }()) == 'Arguments'; + + // fallback for IE11 Script Access Denied error + var tryGet = function (it, key) { + try { + return it[key]; + } catch (e) { /* empty */ } + }; + + module.exports = function (it) { + var O, T, B; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T + // builtinTag case + : ARG ? cof(O) + // ES3 arguments fallback + : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; + }; + + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + + // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) + var $export = __webpack_require__(8); + + $export($export.P, 'Function', { bind: __webpack_require__(76) }); + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var aFunction = __webpack_require__(21); + var isObject = __webpack_require__(13); + var invoke = __webpack_require__(77); + var arraySlice = [].slice; + var factories = {}; + + var construct = function (F, len, args) { + if (!(len in factories)) { + for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']'; + // eslint-disable-next-line no-new-func + factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); + } return factories[len](F, args); + }; + + module.exports = Function.bind || function bind(that /* , ...args */) { + var fn = aFunction(this); + var partArgs = arraySlice.call(arguments, 1); + var bound = function (/* args... */) { + var args = partArgs.concat(arraySlice.call(arguments)); + return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that); + }; + if (isObject(fn.prototype)) bound.prototype = fn.prototype; + return bound; + }; + + +/***/ }), +/* 77 */ +/***/ (function(module, exports) { + + // fast apply, http://jsperf.lnkit.com/fast-apply/5 + module.exports = function (fn, args, that) { + var un = that === undefined; + switch (args.length) { + case 0: return un ? fn() + : fn.call(that); + case 1: return un ? fn(args[0]) + : fn.call(that, args[0]); + case 2: return un ? fn(args[0], args[1]) + : fn.call(that, args[0], args[1]); + case 3: return un ? fn(args[0], args[1], args[2]) + : fn.call(that, args[0], args[1], args[2]); + case 4: return un ? fn(args[0], args[1], args[2], args[3]) + : fn.call(that, args[0], args[1], args[2], args[3]); + } return fn.apply(that, args); + }; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(11).f; + var FProto = Function.prototype; + var nameRE = /^\s*function ([^ (]*)/; + var NAME = 'name'; + + // 19.2.4.2 name + NAME in FProto || __webpack_require__(6) && dP(FProto, NAME, { + configurable: true, + get: function () { + try { + return ('' + this).match(nameRE)[1]; + } catch (e) { + return ''; + } + } + }); + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var isObject = __webpack_require__(13); + var getPrototypeOf = __webpack_require__(58); + var HAS_INSTANCE = __webpack_require__(26)('hasInstance'); + var FunctionProto = Function.prototype; + // 19.2.3.6 Function.prototype[@@hasInstance](V) + if (!(HAS_INSTANCE in FunctionProto)) __webpack_require__(11).f(FunctionProto, HAS_INSTANCE, { value: function (O) { + if (typeof this != 'function' || !isObject(O)) return false; + if (!isObject(this.prototype)) return O instanceof this; + // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this: + while (O = getPrototypeOf(O)) if (this.prototype === O) return true; + return false; + } }); + + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var $parseInt = __webpack_require__(81); + // 18.2.5 parseInt(string, radix) + $export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt }); + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + + var $parseInt = __webpack_require__(4).parseInt; + var $trim = __webpack_require__(82).trim; + var ws = __webpack_require__(83); + var hex = /^[-+]?0[xX]/; + + module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) { + var string = $trim(String(str), 3); + return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10)); + } : $parseInt; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var defined = __webpack_require__(35); + var fails = __webpack_require__(7); + var spaces = __webpack_require__(83); + var space = '[' + spaces + ']'; + var non = '\u200b\u0085'; + var ltrim = RegExp('^' + space + space + '*'); + var rtrim = RegExp(space + space + '*$'); + + var exporter = function (KEY, exec, ALIAS) { + var exp = {}; + var FORCE = fails(function () { + return !!spaces[KEY]() || non[KEY]() != non; + }); + var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY]; + if (ALIAS) exp[ALIAS] = fn; + $export($export.P + $export.F * FORCE, 'String', exp); + }; + + // 1 -> String#trimLeft + // 2 -> String#trimRight + // 3 -> String#trim + var trim = exporter.trim = function (string, TYPE) { + string = String(defined(string)); + if (TYPE & 1) string = string.replace(ltrim, ''); + if (TYPE & 2) string = string.replace(rtrim, ''); + return string; + }; + + module.exports = exporter; + + +/***/ }), +/* 83 */ +/***/ (function(module, exports) { + + module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var $parseFloat = __webpack_require__(85); + // 18.2.4 parseFloat(string) + $export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat }); + + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + + var $parseFloat = __webpack_require__(4).parseFloat; + var $trim = __webpack_require__(82).trim; + + module.exports = 1 / $parseFloat(__webpack_require__(83) + '-0') !== -Infinity ? function parseFloat(str) { + var string = $trim(String(str), 3); + var result = $parseFloat(string); + return result === 0 && string.charAt(0) == '-' ? -0 : result; + } : $parseFloat; + + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var global = __webpack_require__(4); + var has = __webpack_require__(5); + var cof = __webpack_require__(34); + var inheritIfRequired = __webpack_require__(87); + var toPrimitive = __webpack_require__(16); + var fails = __webpack_require__(7); + var gOPN = __webpack_require__(49).f; + var gOPD = __webpack_require__(50).f; + var dP = __webpack_require__(11).f; + var $trim = __webpack_require__(82).trim; + var NUMBER = 'Number'; + var $Number = global[NUMBER]; + var Base = $Number; + var proto = $Number.prototype; + // Opera ~12 has broken Object#toString + var BROKEN_COF = cof(__webpack_require__(45)(proto)) == NUMBER; + var TRIM = 'trim' in String.prototype; + + // 7.1.3 ToNumber(argument) + var toNumber = function (argument) { + var it = toPrimitive(argument, false); + if (typeof it == 'string' && it.length > 2) { + it = TRIM ? it.trim() : $trim(it, 3); + var first = it.charCodeAt(0); + var third, radix, maxCode; + if (first === 43 || first === 45) { + third = it.charCodeAt(2); + if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix + } else if (first === 48) { + switch (it.charCodeAt(1)) { + case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i + case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i + default: return +it; + } + for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) { + code = digits.charCodeAt(i); + // parseInt parses a string to a first unavailable symbol + // but ToNumber should return NaN if a string contains unavailable symbols + if (code < 48 || code > maxCode) return NaN; + } return parseInt(digits, radix); + } + } return +it; + }; + + if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { + $Number = function Number(value) { + var it = arguments.length < 1 ? 0 : value; + var that = this; + return that instanceof $Number + // check on 1..constructor(foo) case + && (BROKEN_COF ? fails(function () { proto.valueOf.call(that); }) : cof(that) != NUMBER) + ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it); + }; + for (var keys = __webpack_require__(6) ? gOPN(Base) : ( + // ES3: + 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + + // ES6 (in case, if modules with ES6 Number statics required before): + 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger' + ).split(','), j = 0, key; keys.length > j; j++) { + if (has(Base, key = keys[j]) && !has($Number, key)) { + dP($Number, key, gOPD(Base, key)); + } + } + $Number.prototype = proto; + proto.constructor = $Number; + __webpack_require__(18)(global, NUMBER, $Number); + } + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(13); + var setPrototypeOf = __webpack_require__(72).set; + module.exports = function (that, target, C) { + var S = target.constructor; + var P; + if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) { + setPrototypeOf(that, P); + } return that; + }; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toInteger = __webpack_require__(38); + var aNumberValue = __webpack_require__(89); + var repeat = __webpack_require__(90); + var $toFixed = 1.0.toFixed; + var floor = Math.floor; + var data = [0, 0, 0, 0, 0, 0]; + var ERROR = 'Number.toFixed: incorrect invocation!'; + var ZERO = '0'; + + var multiply = function (n, c) { + var i = -1; + var c2 = c; + while (++i < 6) { + c2 += n * data[i]; + data[i] = c2 % 1e7; + c2 = floor(c2 / 1e7); + } + }; + var divide = function (n) { + var i = 6; + var c = 0; + while (--i >= 0) { + c += data[i]; + data[i] = floor(c / n); + c = (c % n) * 1e7; + } + }; + var numToString = function () { + var i = 6; + var s = ''; + while (--i >= 0) { + if (s !== '' || i === 0 || data[i] !== 0) { + var t = String(data[i]); + s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t; + } + } return s; + }; + var pow = function (x, n, acc) { + return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc); + }; + var log = function (x) { + var n = 0; + var x2 = x; + while (x2 >= 4096) { + n += 12; + x2 /= 4096; + } + while (x2 >= 2) { + n += 1; + x2 /= 2; + } return n; + }; + + $export($export.P + $export.F * (!!$toFixed && ( + 0.00008.toFixed(3) !== '0.000' || + 0.9.toFixed(0) !== '1' || + 1.255.toFixed(2) !== '1.25' || + 1000000000000000128.0.toFixed(0) !== '1000000000000000128' + ) || !__webpack_require__(7)(function () { + // V8 ~ Android 4.3- + $toFixed.call({}); + })), 'Number', { + toFixed: function toFixed(fractionDigits) { + var x = aNumberValue(this, ERROR); + var f = toInteger(fractionDigits); + var s = ''; + var m = ZERO; + var e, z, j, k; + if (f < 0 || f > 20) throw RangeError(ERROR); + // eslint-disable-next-line no-self-compare + if (x != x) return 'NaN'; + if (x <= -1e21 || x >= 1e21) return String(x); + if (x < 0) { + s = '-'; + x = -x; + } + if (x > 1e-21) { + e = log(x * pow(2, 69, 1)) - 69; + z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1); + z *= 0x10000000000000; + e = 52 - e; + if (e > 0) { + multiply(0, z); + j = f; + while (j >= 7) { + multiply(1e7, 0); + j -= 7; + } + multiply(pow(10, j, 1), 0); + j = e - 1; + while (j >= 23) { + divide(1 << 23); + j -= 23; + } + divide(1 << j); + multiply(1, 1); + divide(2); + m = numToString(); + } else { + multiply(0, z); + multiply(1 << -e, 0); + m = numToString() + repeat.call(ZERO, f); + } + } + if (f > 0) { + k = m.length; + m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f)); + } else { + m = s + m; + } return m; + } + }); + + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + + var cof = __webpack_require__(34); + module.exports = function (it, msg) { + if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg); + return +it; + }; + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var toInteger = __webpack_require__(38); + var defined = __webpack_require__(35); + + module.exports = function repeat(count) { + var str = String(defined(this)); + var res = ''; + var n = toInteger(count); + if (n < 0 || n == Infinity) throw RangeError("Count can't be negative"); + for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str; + return res; + }; + + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $fails = __webpack_require__(7); + var aNumberValue = __webpack_require__(89); + var $toPrecision = 1.0.toPrecision; + + $export($export.P + $export.F * ($fails(function () { + // IE7- + return $toPrecision.call(1, undefined) !== '1'; + }) || !$fails(function () { + // V8 ~ Android 4.3- + $toPrecision.call({}); + })), 'Number', { + toPrecision: function toPrecision(precision) { + var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!'); + return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision); + } + }); + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.1 Number.EPSILON + var $export = __webpack_require__(8); + + $export($export.S, 'Number', { EPSILON: Math.pow(2, -52) }); + + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.2 Number.isFinite(number) + var $export = __webpack_require__(8); + var _isFinite = __webpack_require__(4).isFinite; + + $export($export.S, 'Number', { + isFinite: function isFinite(it) { + return typeof it == 'number' && _isFinite(it); + } + }); + + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.3 Number.isInteger(number) + var $export = __webpack_require__(8); + + $export($export.S, 'Number', { isInteger: __webpack_require__(95) }); + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.3 Number.isInteger(number) + var isObject = __webpack_require__(13); + var floor = Math.floor; + module.exports = function isInteger(it) { + return !isObject(it) && isFinite(it) && floor(it) === it; + }; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.4 Number.isNaN(number) + var $export = __webpack_require__(8); + + $export($export.S, 'Number', { + isNaN: function isNaN(number) { + // eslint-disable-next-line no-self-compare + return number != number; + } + }); + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.5 Number.isSafeInteger(number) + var $export = __webpack_require__(8); + var isInteger = __webpack_require__(95); + var abs = Math.abs; + + $export($export.S, 'Number', { + isSafeInteger: function isSafeInteger(number) { + return isInteger(number) && abs(number) <= 0x1fffffffffffff; + } + }); + + +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.6 Number.MAX_SAFE_INTEGER + var $export = __webpack_require__(8); + + $export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff }); + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.1.2.10 Number.MIN_SAFE_INTEGER + var $export = __webpack_require__(8); + + $export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff }); + + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var $parseFloat = __webpack_require__(85); + // 20.1.2.12 Number.parseFloat(string) + $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat }); + + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var $parseInt = __webpack_require__(81); + // 20.1.2.13 Number.parseInt(string, radix) + $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt }); + + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.3 Math.acosh(x) + var $export = __webpack_require__(8); + var log1p = __webpack_require__(103); + var sqrt = Math.sqrt; + var $acosh = Math.acosh; + + $export($export.S + $export.F * !($acosh + // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509 + && Math.floor($acosh(Number.MAX_VALUE)) == 710 + // Tor Browser bug: Math.acosh(Infinity) -> NaN + && $acosh(Infinity) == Infinity + ), 'Math', { + acosh: function acosh(x) { + return (x = +x) < 1 ? NaN : x > 94906265.62425156 + ? Math.log(x) + Math.LN2 + : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1)); + } + }); + + +/***/ }), +/* 103 */ +/***/ (function(module, exports) { + + // 20.2.2.20 Math.log1p(x) + module.exports = Math.log1p || function log1p(x) { + return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x); + }; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.5 Math.asinh(x) + var $export = __webpack_require__(8); + var $asinh = Math.asinh; + + function asinh(x) { + return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1)); + } + + // Tor Browser bug: Math.asinh(0) -> -0 + $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh }); + + +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.7 Math.atanh(x) + var $export = __webpack_require__(8); + var $atanh = Math.atanh; + + // Tor Browser bug: Math.atanh(-0) -> 0 + $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', { + atanh: function atanh(x) { + return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2; + } + }); + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.9 Math.cbrt(x) + var $export = __webpack_require__(8); + var sign = __webpack_require__(107); + + $export($export.S, 'Math', { + cbrt: function cbrt(x) { + return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3); + } + }); + + +/***/ }), +/* 107 */ +/***/ (function(module, exports) { + + // 20.2.2.28 Math.sign(x) + module.exports = Math.sign || function sign(x) { + // eslint-disable-next-line no-self-compare + return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1; + }; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.11 Math.clz32(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + clz32: function clz32(x) { + return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32; + } + }); + + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.12 Math.cosh(x) + var $export = __webpack_require__(8); + var exp = Math.exp; + + $export($export.S, 'Math', { + cosh: function cosh(x) { + return (exp(x = +x) + exp(-x)) / 2; + } + }); + + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.14 Math.expm1(x) + var $export = __webpack_require__(8); + var $expm1 = __webpack_require__(111); + + $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 }); + + +/***/ }), +/* 111 */ +/***/ (function(module, exports) { + + // 20.2.2.14 Math.expm1(x) + var $expm1 = Math.expm1; + module.exports = (!$expm1 + // Old FF bug + || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168 + // Tor Browser bug + || $expm1(-2e-17) != -2e-17 + ) ? function expm1(x) { + return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1; + } : $expm1; + + +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.16 Math.fround(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { fround: __webpack_require__(113) }); + + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.16 Math.fround(x) + var sign = __webpack_require__(107); + var pow = Math.pow; + var EPSILON = pow(2, -52); + var EPSILON32 = pow(2, -23); + var MAX32 = pow(2, 127) * (2 - EPSILON32); + var MIN32 = pow(2, -126); + + var roundTiesToEven = function (n) { + return n + 1 / EPSILON - 1 / EPSILON; + }; + + module.exports = Math.fround || function fround(x) { + var $abs = Math.abs(x); + var $sign = sign(x); + var a, result; + if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32; + a = (1 + EPSILON32 / EPSILON) * $abs; + result = a - (a - $abs); + // eslint-disable-next-line no-self-compare + if (result > MAX32 || result != result) return $sign * Infinity; + return $sign * result; + }; + + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) + var $export = __webpack_require__(8); + var abs = Math.abs; + + $export($export.S, 'Math', { + hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars + var sum = 0; + var i = 0; + var aLen = arguments.length; + var larg = 0; + var arg, div; + while (i < aLen) { + arg = abs(arguments[i++]); + if (larg < arg) { + div = larg / arg; + sum = sum * div * div + 1; + larg = arg; + } else if (arg > 0) { + div = arg / larg; + sum += div * div; + } else sum += arg; + } + return larg === Infinity ? Infinity : larg * Math.sqrt(sum); + } + }); + + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.18 Math.imul(x, y) + var $export = __webpack_require__(8); + var $imul = Math.imul; + + // some WebKit versions fails with big numbers, some has wrong arity + $export($export.S + $export.F * __webpack_require__(7)(function () { + return $imul(0xffffffff, 5) != -5 || $imul.length != 2; + }), 'Math', { + imul: function imul(x, y) { + var UINT16 = 0xffff; + var xn = +x; + var yn = +y; + var xl = UINT16 & xn; + var yl = UINT16 & yn; + return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0); + } + }); + + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.21 Math.log10(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + log10: function log10(x) { + return Math.log(x) * Math.LOG10E; + } + }); + + +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.20 Math.log1p(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { log1p: __webpack_require__(103) }); + + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.22 Math.log2(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + log2: function log2(x) { + return Math.log(x) / Math.LN2; + } + }); + + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.28 Math.sign(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { sign: __webpack_require__(107) }); + + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.30 Math.sinh(x) + var $export = __webpack_require__(8); + var expm1 = __webpack_require__(111); + var exp = Math.exp; + + // V8 near Chromium 38 has a problem with very small numbers + $export($export.S + $export.F * __webpack_require__(7)(function () { + return !Math.sinh(-2e-17) != -2e-17; + }), 'Math', { + sinh: function sinh(x) { + return Math.abs(x = +x) < 1 + ? (expm1(x) - expm1(-x)) / 2 + : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2); + } + }); + + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.33 Math.tanh(x) + var $export = __webpack_require__(8); + var expm1 = __webpack_require__(111); + var exp = Math.exp; + + $export($export.S, 'Math', { + tanh: function tanh(x) { + var a = expm1(x = +x); + var b = expm1(-x); + return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x)); + } + }); + + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.2.2.34 Math.trunc(x) + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + trunc: function trunc(it) { + return (it > 0 ? Math.floor : Math.ceil)(it); + } + }); + + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var toAbsoluteIndex = __webpack_require__(39); + var fromCharCode = String.fromCharCode; + var $fromCodePoint = String.fromCodePoint; + + // length should be 1, old FF problem + $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { + // 21.1.2.2 String.fromCodePoint(...codePoints) + fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars + var res = []; + var aLen = arguments.length; + var i = 0; + var code; + while (aLen > i) { + code = +arguments[i++]; + if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point'); + res.push(code < 0x10000 + ? fromCharCode(code) + : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00) + ); + } return res.join(''); + } + }); + + +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var toIObject = __webpack_require__(32); + var toLength = __webpack_require__(37); + + $export($export.S, 'String', { + // 21.1.2.4 String.raw(callSite, ...substitutions) + raw: function raw(callSite) { + var tpl = toIObject(callSite.raw); + var len = toLength(tpl.length); + var aLen = arguments.length; + var res = []; + var i = 0; + while (len > i) { + res.push(String(tpl[i++])); + if (i < aLen) res.push(String(arguments[i])); + } return res.join(''); + } + }); + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 21.1.3.25 String.prototype.trim() + __webpack_require__(82)('trim', function ($trim) { + return function trim() { + return $trim(this, 3); + }; + }); + + +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $at = __webpack_require__(127)(true); + + // 21.1.3.27 String.prototype[@@iterator]() + __webpack_require__(128)(String, 'String', function (iterated) { + this._t = String(iterated); // target + this._i = 0; // next index + // 21.1.5.2.1 %StringIteratorPrototype%.next() + }, function () { + var O = this._t; + var index = this._i; + var point; + if (index >= O.length) return { value: undefined, done: true }; + point = $at(O, index); + this._i += point.length; + return { value: point, done: false }; + }); + + +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + + var toInteger = __webpack_require__(38); + var defined = __webpack_require__(35); + // true -> String#at + // false -> String#codePointAt + module.exports = function (TO_STRING) { + return function (that, pos) { + var s = String(defined(that)); + var i = toInteger(pos); + var l = s.length; + var a, b; + if (i < 0 || i >= l) return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; + }; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var LIBRARY = __webpack_require__(24); + var $export = __webpack_require__(8); + var redefine = __webpack_require__(18); + var hide = __webpack_require__(10); + var Iterators = __webpack_require__(129); + var $iterCreate = __webpack_require__(130); + var setToStringTag = __webpack_require__(25); + var getPrototypeOf = __webpack_require__(58); + var ITERATOR = __webpack_require__(26)('iterator'); + var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` + var FF_ITERATOR = '@@iterator'; + var KEYS = 'keys'; + var VALUES = 'values'; + + var returnThis = function () { return this; }; + + module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { + $iterCreate(Constructor, NAME, next); + var getMethod = function (kind) { + if (!BUGGY && kind in proto) return proto[kind]; + switch (kind) { + case KEYS: return function keys() { return new Constructor(this, kind); }; + case VALUES: return function values() { return new Constructor(this, kind); }; + } return function entries() { return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator'; + var DEF_VALUES = DEFAULT == VALUES; + var VALUES_BUG = false; + var proto = Base.prototype; + var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; + var $default = $native || getMethod(DEFAULT); + var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; + var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; + var methods, key, IteratorPrototype; + // Fix native + if ($anyNative) { + IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); + if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if (DEF_VALUES && $native && $native.name !== VALUES) { + VALUES_BUG = true; + $default = function values() { return $native.call(this); }; + } + // Define iterator + if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if (DEFAULT) { + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if (FORCED) for (key in methods) { + if (!(key in proto)) redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; + }; + + +/***/ }), +/* 129 */ +/***/ (function(module, exports) { + + module.exports = {}; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var create = __webpack_require__(45); + var descriptor = __webpack_require__(17); + var setToStringTag = __webpack_require__(25); + var IteratorPrototype = {}; + + // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() + __webpack_require__(10)(IteratorPrototype, __webpack_require__(26)('iterator'), function () { return this; }); + + module.exports = function (Constructor, NAME, next) { + Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); + setToStringTag(Constructor, NAME + ' Iterator'); + }; + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $at = __webpack_require__(127)(false); + $export($export.P, 'String', { + // 21.1.3.3 String.prototype.codePointAt(pos) + codePointAt: function codePointAt(pos) { + return $at(this, pos); + } + }); + + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + + // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) + 'use strict'; + var $export = __webpack_require__(8); + var toLength = __webpack_require__(37); + var context = __webpack_require__(133); + var ENDS_WITH = 'endsWith'; + var $endsWith = ''[ENDS_WITH]; + + $export($export.P + $export.F * __webpack_require__(135)(ENDS_WITH), 'String', { + endsWith: function endsWith(searchString /* , endPosition = @length */) { + var that = context(this, searchString, ENDS_WITH); + var endPosition = arguments.length > 1 ? arguments[1] : undefined; + var len = toLength(that.length); + var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len); + var search = String(searchString); + return $endsWith + ? $endsWith.call(that, search, end) + : that.slice(end - search.length, end) === search; + } + }); + + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + + // helper for String#{startsWith, endsWith, includes} + var isRegExp = __webpack_require__(134); + var defined = __webpack_require__(35); + + module.exports = function (that, searchString, NAME) { + if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!"); + return String(defined(that)); + }; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.2.8 IsRegExp(argument) + var isObject = __webpack_require__(13); + var cof = __webpack_require__(34); + var MATCH = __webpack_require__(26)('match'); + module.exports = function (it) { + var isRegExp; + return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); + }; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + + var MATCH = __webpack_require__(26)('match'); + module.exports = function (KEY) { + var re = /./; + try { + '/./'[KEY](re); + } catch (e) { + try { + re[MATCH] = false; + return !'/./'[KEY](re); + } catch (f) { /* empty */ } + } return true; + }; + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + + // 21.1.3.7 String.prototype.includes(searchString, position = 0) + 'use strict'; + var $export = __webpack_require__(8); + var context = __webpack_require__(133); + var INCLUDES = 'includes'; + + $export($export.P + $export.F * __webpack_require__(135)(INCLUDES), 'String', { + includes: function includes(searchString /* , position = 0 */) { + return !!~context(this, searchString, INCLUDES) + .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + + $export($export.P, 'String', { + // 21.1.3.13 String.prototype.repeat(count) + repeat: __webpack_require__(90) + }); + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + + // 21.1.3.18 String.prototype.startsWith(searchString [, position ]) + 'use strict'; + var $export = __webpack_require__(8); + var toLength = __webpack_require__(37); + var context = __webpack_require__(133); + var STARTS_WITH = 'startsWith'; + var $startsWith = ''[STARTS_WITH]; + + $export($export.P + $export.F * __webpack_require__(135)(STARTS_WITH), 'String', { + startsWith: function startsWith(searchString /* , position = 0 */) { + var that = context(this, searchString, STARTS_WITH); + var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length)); + var search = String(searchString); + return $startsWith + ? $startsWith.call(that, search, index) + : that.slice(index, index + search.length) === search; + } + }); + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.2 String.prototype.anchor(name) + __webpack_require__(140)('anchor', function (createHTML) { + return function anchor(name) { + return createHTML(this, 'a', 'name', name); + }; + }); + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var fails = __webpack_require__(7); + var defined = __webpack_require__(35); + var quot = /"/g; + // B.2.3.2.1 CreateHTML(string, tag, attribute, value) + var createHTML = function (string, tag, attribute, value) { + var S = String(defined(string)); + var p1 = '<' + tag; + if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"'; + return p1 + '>' + S + ''; + }; + module.exports = function (NAME, exec) { + var O = {}; + O[NAME] = exec(createHTML); + $export($export.P + $export.F * fails(function () { + var test = ''[NAME]('"'); + return test !== test.toLowerCase() || test.split('"').length > 3; + }), 'String', O); + }; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.3 String.prototype.big() + __webpack_require__(140)('big', function (createHTML) { + return function big() { + return createHTML(this, 'big', '', ''); + }; + }); + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.4 String.prototype.blink() + __webpack_require__(140)('blink', function (createHTML) { + return function blink() { + return createHTML(this, 'blink', '', ''); + }; + }); + + +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.5 String.prototype.bold() + __webpack_require__(140)('bold', function (createHTML) { + return function bold() { + return createHTML(this, 'b', '', ''); + }; + }); + + +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.6 String.prototype.fixed() + __webpack_require__(140)('fixed', function (createHTML) { + return function fixed() { + return createHTML(this, 'tt', '', ''); + }; + }); + + +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.7 String.prototype.fontcolor(color) + __webpack_require__(140)('fontcolor', function (createHTML) { + return function fontcolor(color) { + return createHTML(this, 'font', 'color', color); + }; + }); + + +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.8 String.prototype.fontsize(size) + __webpack_require__(140)('fontsize', function (createHTML) { + return function fontsize(size) { + return createHTML(this, 'font', 'size', size); + }; + }); + + +/***/ }), +/* 147 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.9 String.prototype.italics() + __webpack_require__(140)('italics', function (createHTML) { + return function italics() { + return createHTML(this, 'i', '', ''); + }; + }); + + +/***/ }), +/* 148 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.10 String.prototype.link(url) + __webpack_require__(140)('link', function (createHTML) { + return function link(url) { + return createHTML(this, 'a', 'href', url); + }; + }); + + +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.11 String.prototype.small() + __webpack_require__(140)('small', function (createHTML) { + return function small() { + return createHTML(this, 'small', '', ''); + }; + }); + + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.12 String.prototype.strike() + __webpack_require__(140)('strike', function (createHTML) { + return function strike() { + return createHTML(this, 'strike', '', ''); + }; + }); + + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.13 String.prototype.sub() + __webpack_require__(140)('sub', function (createHTML) { + return function sub() { + return createHTML(this, 'sub', '', ''); + }; + }); + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // B.2.3.14 String.prototype.sup() + __webpack_require__(140)('sup', function (createHTML) { + return function sup() { + return createHTML(this, 'sup', '', ''); + }; + }); + + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.3.3.1 / 15.9.4.4 Date.now() + var $export = __webpack_require__(8); + + $export($export.S, 'Date', { now: function () { return new Date().getTime(); } }); + + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var toPrimitive = __webpack_require__(16); + + $export($export.P + $export.F * __webpack_require__(7)(function () { + return new Date(NaN).toJSON() !== null + || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1; + }), 'Date', { + // eslint-disable-next-line no-unused-vars + toJSON: function toJSON(key) { + var O = toObject(this); + var pv = toPrimitive(O); + return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString(); + } + }); + + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + + // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() + var $export = __webpack_require__(8); + var toISOString = __webpack_require__(156); + + // PhantomJS / old WebKit has a broken implementations + $export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'Date', { + toISOString: toISOString + }); + + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() + var fails = __webpack_require__(7); + var getTime = Date.prototype.getTime; + var $toISOString = Date.prototype.toISOString; + + var lz = function (num) { + return num > 9 ? num : '0' + num; + }; + + // PhantomJS / old WebKit has a broken implementations + module.exports = (fails(function () { + return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z'; + }) || !fails(function () { + $toISOString.call(new Date(NaN)); + })) ? function toISOString() { + if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value'); + var d = this; + var y = d.getUTCFullYear(); + var m = d.getUTCMilliseconds(); + var s = y < 0 ? '-' : y > 9999 ? '+' : ''; + return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) + + '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) + + 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) + + ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; + } : $toISOString; + + +/***/ }), +/* 157 */ +/***/ (function(module, exports, __webpack_require__) { + + var DateProto = Date.prototype; + var INVALID_DATE = 'Invalid Date'; + var TO_STRING = 'toString'; + var $toString = DateProto[TO_STRING]; + var getTime = DateProto.getTime; + if (new Date(NaN) + '' != INVALID_DATE) { + __webpack_require__(18)(DateProto, TO_STRING, function toString() { + var value = getTime.call(this); + // eslint-disable-next-line no-self-compare + return value === value ? $toString.call(this) : INVALID_DATE; + }); + } + + +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + + var TO_PRIMITIVE = __webpack_require__(26)('toPrimitive'); + var proto = Date.prototype; + + if (!(TO_PRIMITIVE in proto)) __webpack_require__(10)(proto, TO_PRIMITIVE, __webpack_require__(159)); + + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var anObject = __webpack_require__(12); + var toPrimitive = __webpack_require__(16); + var NUMBER = 'number'; + + module.exports = function (hint) { + if (hint !== 'string' && hint !== NUMBER && hint !== 'default') throw TypeError('Incorrect hint'); + return toPrimitive(anObject(this), hint != NUMBER); + }; + + +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) + var $export = __webpack_require__(8); + + $export($export.S, 'Array', { isArray: __webpack_require__(44) }); + + +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var ctx = __webpack_require__(20); + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var call = __webpack_require__(162); + var isArrayIter = __webpack_require__(163); + var toLength = __webpack_require__(37); + var createProperty = __webpack_require__(164); + var getIterFn = __webpack_require__(165); + + $export($export.S + $export.F * !__webpack_require__(166)(function (iter) { Array.from(iter); }), 'Array', { + // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) + from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { + var O = toObject(arrayLike); + var C = typeof this == 'function' ? this : Array; + var aLen = arguments.length; + var mapfn = aLen > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + var index = 0; + var iterFn = getIterFn(O); + var length, result, step, iterator; + if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); + // if object isn't iterable or it's array with default iterator - use simple case + if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) { + for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { + createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); + } + } else { + length = toLength(O.length); + for (result = new C(length); length > index; index++) { + createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); + } + } + result.length = index; + return result; + } + }); + + +/***/ }), +/* 162 */ +/***/ (function(module, exports, __webpack_require__) { + + // call something on iterator step with safe closing on error + var anObject = __webpack_require__(12); + module.exports = function (iterator, fn, value, entries) { + try { + return entries ? fn(anObject(value)[0], value[1]) : fn(value); + // 7.4.6 IteratorClose(iterator, completion) + } catch (e) { + var ret = iterator['return']; + if (ret !== undefined) anObject(ret.call(iterator)); + throw e; + } + }; + + +/***/ }), +/* 163 */ +/***/ (function(module, exports, __webpack_require__) { + + // check on default Array iterator + var Iterators = __webpack_require__(129); + var ITERATOR = __webpack_require__(26)('iterator'); + var ArrayProto = Array.prototype; + + module.exports = function (it) { + return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); + }; + + +/***/ }), +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $defineProperty = __webpack_require__(11); + var createDesc = __webpack_require__(17); + + module.exports = function (object, index, value) { + if (index in object) $defineProperty.f(object, index, createDesc(0, value)); + else object[index] = value; + }; + + +/***/ }), +/* 165 */ +/***/ (function(module, exports, __webpack_require__) { + + var classof = __webpack_require__(74); + var ITERATOR = __webpack_require__(26)('iterator'); + var Iterators = __webpack_require__(129); + module.exports = __webpack_require__(9).getIteratorMethod = function (it) { + if (it != undefined) return it[ITERATOR] + || it['@@iterator'] + || Iterators[classof(it)]; + }; + + +/***/ }), +/* 166 */ +/***/ (function(module, exports, __webpack_require__) { + + var ITERATOR = __webpack_require__(26)('iterator'); + var SAFE_CLOSING = false; + + try { + var riter = [7][ITERATOR](); + riter['return'] = function () { SAFE_CLOSING = true; }; + // eslint-disable-next-line no-throw-literal + Array.from(riter, function () { throw 2; }); + } catch (e) { /* empty */ } + + module.exports = function (exec, skipClosing) { + if (!skipClosing && !SAFE_CLOSING) return false; + var safe = false; + try { + var arr = [7]; + var iter = arr[ITERATOR](); + iter.next = function () { return { done: safe = true }; }; + arr[ITERATOR] = function () { return iter; }; + exec(arr); + } catch (e) { /* empty */ } + return safe; + }; + + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var createProperty = __webpack_require__(164); + + // WebKit Array.of isn't generic + $export($export.S + $export.F * __webpack_require__(7)(function () { + function F() { /* empty */ } + return !(Array.of.call(F) instanceof F); + }), 'Array', { + // 22.1.2.3 Array.of( ...items) + of: function of(/* ...args */) { + var index = 0; + var aLen = arguments.length; + var result = new (typeof this == 'function' ? this : Array)(aLen); + while (aLen > index) createProperty(result, index, arguments[index++]); + result.length = aLen; + return result; + } + }); + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 22.1.3.13 Array.prototype.join(separator) + var $export = __webpack_require__(8); + var toIObject = __webpack_require__(32); + var arrayJoin = [].join; + + // fallback for not array-like strings + $export($export.P + $export.F * (__webpack_require__(33) != Object || !__webpack_require__(169)(arrayJoin)), 'Array', { + join: function join(separator) { + return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator); + } + }); + + +/***/ }), +/* 169 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var fails = __webpack_require__(7); + + module.exports = function (method, arg) { + return !!method && fails(function () { + // eslint-disable-next-line no-useless-call + arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null); + }); + }; + + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var html = __webpack_require__(47); + var cof = __webpack_require__(34); + var toAbsoluteIndex = __webpack_require__(39); + var toLength = __webpack_require__(37); + var arraySlice = [].slice; + + // fallback for not array-like ES3 strings and DOM objects + $export($export.P + $export.F * __webpack_require__(7)(function () { + if (html) arraySlice.call(html); + }), 'Array', { + slice: function slice(begin, end) { + var len = toLength(this.length); + var klass = cof(this); + end = end === undefined ? len : end; + if (klass == 'Array') return arraySlice.call(this, begin, end); + var start = toAbsoluteIndex(begin, len); + var upTo = toAbsoluteIndex(end, len); + var size = toLength(upTo - start); + var cloned = new Array(size); + var i = 0; + for (; i < size; i++) cloned[i] = klass == 'String' + ? this.charAt(start + i) + : this[start + i]; + return cloned; + } + }); + + +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var aFunction = __webpack_require__(21); + var toObject = __webpack_require__(57); + var fails = __webpack_require__(7); + var $sort = [].sort; + var test = [1, 2, 3]; + + $export($export.P + $export.F * (fails(function () { + // IE8- + test.sort(undefined); + }) || !fails(function () { + // V8 bug + test.sort(null); + // Old WebKit + }) || !__webpack_require__(169)($sort)), 'Array', { + // 22.1.3.25 Array.prototype.sort(comparefn) + sort: function sort(comparefn) { + return comparefn === undefined + ? $sort.call(toObject(this)) + : $sort.call(toObject(this), aFunction(comparefn)); + } + }); + + +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $forEach = __webpack_require__(173)(0); + var STRICT = __webpack_require__(169)([].forEach, true); + + $export($export.P + $export.F * !STRICT, 'Array', { + // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) + forEach: function forEach(callbackfn /* , thisArg */) { + return $forEach(this, callbackfn, arguments[1]); + } + }); + + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + + // 0 -> Array#forEach + // 1 -> Array#map + // 2 -> Array#filter + // 3 -> Array#some + // 4 -> Array#every + // 5 -> Array#find + // 6 -> Array#findIndex + var ctx = __webpack_require__(20); + var IObject = __webpack_require__(33); + var toObject = __webpack_require__(57); + var toLength = __webpack_require__(37); + var asc = __webpack_require__(174); + module.exports = function (TYPE, $create) { + var IS_MAP = TYPE == 1; + var IS_FILTER = TYPE == 2; + var IS_SOME = TYPE == 3; + var IS_EVERY = TYPE == 4; + var IS_FIND_INDEX = TYPE == 6; + var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; + var create = $create || asc; + return function ($this, callbackfn, that) { + var O = toObject($this); + var self = IObject(O); + var f = ctx(callbackfn, that, 3); + var length = toLength(self.length); + var index = 0; + var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; + var val, res; + for (;length > index; index++) if (NO_HOLES || index in self) { + val = self[index]; + res = f(val, index, O); + if (TYPE) { + if (IS_MAP) result[index] = res; // map + else if (res) switch (TYPE) { + case 3: return true; // some + case 5: return val; // find + case 6: return index; // findIndex + case 2: result.push(val); // filter + } else if (IS_EVERY) return false; // every + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; + }; + }; + + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + + // 9.4.2.3 ArraySpeciesCreate(originalArray, length) + var speciesConstructor = __webpack_require__(175); + + module.exports = function (original, length) { + return new (speciesConstructor(original))(length); + }; + + +/***/ }), +/* 175 */ +/***/ (function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(13); + var isArray = __webpack_require__(44); + var SPECIES = __webpack_require__(26)('species'); + + module.exports = function (original) { + var C; + if (isArray(original)) { + C = original.constructor; + // cross-realm fallback + if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; + if (isObject(C)) { + C = C[SPECIES]; + if (C === null) C = undefined; + } + } return C === undefined ? Array : C; + }; + + +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $map = __webpack_require__(173)(1); + + $export($export.P + $export.F * !__webpack_require__(169)([].map, true), 'Array', { + // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg]) + map: function map(callbackfn /* , thisArg */) { + return $map(this, callbackfn, arguments[1]); + } + }); + + +/***/ }), +/* 177 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $filter = __webpack_require__(173)(2); + + $export($export.P + $export.F * !__webpack_require__(169)([].filter, true), 'Array', { + // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg]) + filter: function filter(callbackfn /* , thisArg */) { + return $filter(this, callbackfn, arguments[1]); + } + }); + + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $some = __webpack_require__(173)(3); + + $export($export.P + $export.F * !__webpack_require__(169)([].some, true), 'Array', { + // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg]) + some: function some(callbackfn /* , thisArg */) { + return $some(this, callbackfn, arguments[1]); + } + }); + + +/***/ }), +/* 179 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $every = __webpack_require__(173)(4); + + $export($export.P + $export.F * !__webpack_require__(169)([].every, true), 'Array', { + // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg]) + every: function every(callbackfn /* , thisArg */) { + return $every(this, callbackfn, arguments[1]); + } + }); + + +/***/ }), +/* 180 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $reduce = __webpack_require__(181); + + $export($export.P + $export.F * !__webpack_require__(169)([].reduce, true), 'Array', { + // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) + reduce: function reduce(callbackfn /* , initialValue */) { + return $reduce(this, callbackfn, arguments.length, arguments[1], false); + } + }); + + +/***/ }), +/* 181 */ +/***/ (function(module, exports, __webpack_require__) { + + var aFunction = __webpack_require__(21); + var toObject = __webpack_require__(57); + var IObject = __webpack_require__(33); + var toLength = __webpack_require__(37); + + module.exports = function (that, callbackfn, aLen, memo, isRight) { + aFunction(callbackfn); + var O = toObject(that); + var self = IObject(O); + var length = toLength(O.length); + var index = isRight ? length - 1 : 0; + var i = isRight ? -1 : 1; + if (aLen < 2) for (;;) { + if (index in self) { + memo = self[index]; + index += i; + break; + } + index += i; + if (isRight ? index < 0 : length <= index) { + throw TypeError('Reduce of empty array with no initial value'); + } + } + for (;isRight ? index >= 0 : length > index; index += i) if (index in self) { + memo = callbackfn(memo, self[index], index, O); + } + return memo; + }; + + +/***/ }), +/* 182 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $reduce = __webpack_require__(181); + + $export($export.P + $export.F * !__webpack_require__(169)([].reduceRight, true), 'Array', { + // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue]) + reduceRight: function reduceRight(callbackfn /* , initialValue */) { + return $reduce(this, callbackfn, arguments.length, arguments[1], true); + } + }); + + +/***/ }), +/* 183 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $indexOf = __webpack_require__(36)(false); + var $native = [].indexOf; + var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0; + + $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(169)($native)), 'Array', { + // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) + indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { + return NEGATIVE_ZERO + // convert -0 to +0 + ? $native.apply(this, arguments) || 0 + : $indexOf(this, searchElement, arguments[1]); + } + }); + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toIObject = __webpack_require__(32); + var toInteger = __webpack_require__(38); + var toLength = __webpack_require__(37); + var $native = [].lastIndexOf; + var NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0; + + $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(169)($native)), 'Array', { + // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) + lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { + // convert -0 to +0 + if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0; + var O = toIObject(this); + var length = toLength(O.length); + var index = length - 1; + if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1])); + if (index < 0) index = length + index; + for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0; + return -1; + } + }); + + +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) + var $export = __webpack_require__(8); + + $export($export.P, 'Array', { copyWithin: __webpack_require__(186) }); + + __webpack_require__(187)('copyWithin'); + + +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) + 'use strict'; + var toObject = __webpack_require__(57); + var toAbsoluteIndex = __webpack_require__(39); + var toLength = __webpack_require__(37); + + module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { + var O = toObject(this); + var len = toLength(O.length); + var to = toAbsoluteIndex(target, len); + var from = toAbsoluteIndex(start, len); + var end = arguments.length > 2 ? arguments[2] : undefined; + var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to); + var inc = 1; + if (from < to && to < from + count) { + inc = -1; + from += count - 1; + to += count - 1; + } + while (count-- > 0) { + if (from in O) O[to] = O[from]; + else delete O[to]; + to += inc; + from += inc; + } return O; + }; + + +/***/ }), +/* 187 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.3.31 Array.prototype[@@unscopables] + var UNSCOPABLES = __webpack_require__(26)('unscopables'); + var ArrayProto = Array.prototype; + if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(10)(ArrayProto, UNSCOPABLES, {}); + module.exports = function (key) { + ArrayProto[UNSCOPABLES][key] = true; + }; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) + var $export = __webpack_require__(8); + + $export($export.P, 'Array', { fill: __webpack_require__(189) }); + + __webpack_require__(187)('fill'); + + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { + + // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) + 'use strict'; + var toObject = __webpack_require__(57); + var toAbsoluteIndex = __webpack_require__(39); + var toLength = __webpack_require__(37); + module.exports = function fill(value /* , start = 0, end = @length */) { + var O = toObject(this); + var length = toLength(O.length); + var aLen = arguments.length; + var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length); + var end = aLen > 2 ? arguments[2] : undefined; + var endPos = end === undefined ? length : toAbsoluteIndex(end, length); + while (endPos > index) O[index++] = value; + return O; + }; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) + var $export = __webpack_require__(8); + var $find = __webpack_require__(173)(5); + var KEY = 'find'; + var forced = true; + // Shouldn't skip holes + if (KEY in []) Array(1)[KEY](function () { forced = false; }); + $export($export.P + $export.F * forced, 'Array', { + find: function find(callbackfn /* , that = undefined */) { + return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + __webpack_require__(187)(KEY); + + +/***/ }), +/* 191 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) + var $export = __webpack_require__(8); + var $find = __webpack_require__(173)(6); + var KEY = 'findIndex'; + var forced = true; + // Shouldn't skip holes + if (KEY in []) Array(1)[KEY](function () { forced = false; }); + $export($export.P + $export.F * forced, 'Array', { + findIndex: function findIndex(callbackfn /* , that = undefined */) { + return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } + }); + __webpack_require__(187)(KEY); + + +/***/ }), +/* 192 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(193)('Array'); + + +/***/ }), +/* 193 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var global = __webpack_require__(4); + var dP = __webpack_require__(11); + var DESCRIPTORS = __webpack_require__(6); + var SPECIES = __webpack_require__(26)('species'); + + module.exports = function (KEY) { + var C = global[KEY]; + if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, { + configurable: true, + get: function () { return this; } + }); + }; + + +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var addToUnscopables = __webpack_require__(187); + var step = __webpack_require__(195); + var Iterators = __webpack_require__(129); + var toIObject = __webpack_require__(32); + + // 22.1.3.4 Array.prototype.entries() + // 22.1.3.13 Array.prototype.keys() + // 22.1.3.29 Array.prototype.values() + // 22.1.3.30 Array.prototype[@@iterator]() + module.exports = __webpack_require__(128)(Array, 'Array', function (iterated, kind) { + this._t = toIObject(iterated); // target + this._i = 0; // next index + this._k = kind; // kind + // 22.1.5.2.1 %ArrayIteratorPrototype%.next() + }, function () { + var O = this._t; + var kind = this._k; + var index = this._i++; + if (!O || index >= O.length) { + this._t = undefined; + return step(1); + } + if (kind == 'keys') return step(0, index); + if (kind == 'values') return step(0, O[index]); + return step(0, [index, O[index]]); + }, 'values'); + + // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) + Iterators.Arguments = Iterators.Array; + + addToUnscopables('keys'); + addToUnscopables('values'); + addToUnscopables('entries'); + + +/***/ }), +/* 195 */ +/***/ (function(module, exports) { + + module.exports = function (done, value) { + return { value: value, done: !!done }; + }; + + +/***/ }), +/* 196 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var inheritIfRequired = __webpack_require__(87); + var dP = __webpack_require__(11).f; + var gOPN = __webpack_require__(49).f; + var isRegExp = __webpack_require__(134); + var $flags = __webpack_require__(197); + var $RegExp = global.RegExp; + var Base = $RegExp; + var proto = $RegExp.prototype; + var re1 = /a/g; + var re2 = /a/g; + // "new" creates a new object, old webkit buggy here + var CORRECT_NEW = new $RegExp(re1) !== re1; + + if (__webpack_require__(6) && (!CORRECT_NEW || __webpack_require__(7)(function () { + re2[__webpack_require__(26)('match')] = false; + // RegExp constructor can alter flags and IsRegExp works correct with @@match + return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i'; + }))) { + $RegExp = function RegExp(p, f) { + var tiRE = this instanceof $RegExp; + var piRE = isRegExp(p); + var fiU = f === undefined; + return !tiRE && piRE && p.constructor === $RegExp && fiU ? p + : inheritIfRequired(CORRECT_NEW + ? new Base(piRE && !fiU ? p.source : p, f) + : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f) + , tiRE ? this : proto, $RegExp); + }; + var proxy = function (key) { + key in $RegExp || dP($RegExp, key, { + configurable: true, + get: function () { return Base[key]; }, + set: function (it) { Base[key] = it; } + }); + }; + for (var keys = gOPN(Base), i = 0; keys.length > i;) proxy(keys[i++]); + proto.constructor = $RegExp; + $RegExp.prototype = proto; + __webpack_require__(18)(global, 'RegExp', $RegExp); + } + + __webpack_require__(193)('RegExp'); + + +/***/ }), +/* 197 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 21.2.5.3 get RegExp.prototype.flags + var anObject = __webpack_require__(12); + module.exports = function () { + var that = anObject(this); + var result = ''; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.unicode) result += 'u'; + if (that.sticky) result += 'y'; + return result; + }; + + +/***/ }), +/* 198 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + __webpack_require__(199); + var anObject = __webpack_require__(12); + var $flags = __webpack_require__(197); + var DESCRIPTORS = __webpack_require__(6); + var TO_STRING = 'toString'; + var $toString = /./[TO_STRING]; + + var define = function (fn) { + __webpack_require__(18)(RegExp.prototype, TO_STRING, fn, true); + }; + + // 21.2.5.14 RegExp.prototype.toString() + if (__webpack_require__(7)(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) { + define(function toString() { + var R = anObject(this); + return '/'.concat(R.source, '/', + 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined); + }); + // FF44- RegExp#toString has a wrong name + } else if ($toString.name != TO_STRING) { + define(function toString() { + return $toString.call(this); + }); + } + + +/***/ }), +/* 199 */ +/***/ (function(module, exports, __webpack_require__) { + + // 21.2.5.3 get RegExp.prototype.flags() + if (__webpack_require__(6) && /./g.flags != 'g') __webpack_require__(11).f(RegExp.prototype, 'flags', { + configurable: true, + get: __webpack_require__(197) + }); + + +/***/ }), +/* 200 */ +/***/ (function(module, exports, __webpack_require__) { + + // @@match logic + __webpack_require__(201)('match', 1, function (defined, MATCH, $match) { + // 21.1.3.11 String.prototype.match(regexp) + return [function match(regexp) { + 'use strict'; + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[MATCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); + }, $match]; + }); + + +/***/ }), +/* 201 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var hide = __webpack_require__(10); + var redefine = __webpack_require__(18); + var fails = __webpack_require__(7); + var defined = __webpack_require__(35); + var wks = __webpack_require__(26); + + module.exports = function (KEY, length, exec) { + var SYMBOL = wks(KEY); + var fns = exec(defined, SYMBOL, ''[KEY]); + var strfn = fns[0]; + var rxfn = fns[1]; + if (fails(function () { + var O = {}; + O[SYMBOL] = function () { return 7; }; + return ''[KEY](O) != 7; + })) { + redefine(String.prototype, KEY, strfn); + hide(RegExp.prototype, SYMBOL, length == 2 + // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) + // 21.2.5.11 RegExp.prototype[@@split](string, limit) + ? function (string, arg) { return rxfn.call(string, this, arg); } + // 21.2.5.6 RegExp.prototype[@@match](string) + // 21.2.5.9 RegExp.prototype[@@search](string) + : function (string) { return rxfn.call(string, this); } + ); + } + }; + + +/***/ }), +/* 202 */ +/***/ (function(module, exports, __webpack_require__) { + + // @@replace logic + __webpack_require__(201)('replace', 2, function (defined, REPLACE, $replace) { + // 21.1.3.14 String.prototype.replace(searchValue, replaceValue) + return [function replace(searchValue, replaceValue) { + 'use strict'; + var O = defined(this); + var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; + return fn !== undefined + ? fn.call(searchValue, O, replaceValue) + : $replace.call(String(O), searchValue, replaceValue); + }, $replace]; + }); + + +/***/ }), +/* 203 */ +/***/ (function(module, exports, __webpack_require__) { + + // @@search logic + __webpack_require__(201)('search', 1, function (defined, SEARCH, $search) { + // 21.1.3.15 String.prototype.search(regexp) + return [function search(regexp) { + 'use strict'; + var O = defined(this); + var fn = regexp == undefined ? undefined : regexp[SEARCH]; + return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); + }, $search]; + }); + + +/***/ }), +/* 204 */ +/***/ (function(module, exports, __webpack_require__) { + + // @@split logic + __webpack_require__(201)('split', 2, function (defined, SPLIT, $split) { + 'use strict'; + var isRegExp = __webpack_require__(134); + var _split = $split; + var $push = [].push; + var $SPLIT = 'split'; + var LENGTH = 'length'; + var LAST_INDEX = 'lastIndex'; + if ( + 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || + 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || + 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || + '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || + '.'[$SPLIT](/()()/)[LENGTH] > 1 || + ''[$SPLIT](/.?/)[LENGTH] + ) { + var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group + // based on es5-shim implementation, need to rework it + $split = function (separator, limit) { + var string = String(this); + if (separator === undefined && limit === 0) return []; + // If `separator` is not a regex, use native split + if (!isRegExp(separator)) return _split.call(string, separator, limit); + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') + + (separator.sticky ? 'y' : ''); + var lastLastIndex = 0; + var splitLimit = limit === undefined ? 4294967295 : limit >>> 0; + // Make `global` and avoid `lastIndex` issues by working with a copy + var separatorCopy = new RegExp(separator.source, flags + 'g'); + var separator2, match, lastIndex, lastLength, i; + // Doesn't need flags gy, but they don't hurt + if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + while (match = separatorCopy.exec(string)) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0][LENGTH]; + if (lastIndex > lastLastIndex) { + output.push(string.slice(lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG + // eslint-disable-next-line no-loop-func + if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () { + for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined; + }); + if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); + lastLength = match[0][LENGTH]; + lastLastIndex = lastIndex; + if (output[LENGTH] >= splitLimit) break; + } + if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop + } + if (lastLastIndex === string[LENGTH]) { + if (lastLength || !separatorCopy.test('')) output.push(''); + } else output.push(string.slice(lastLastIndex)); + return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output; + }; + // Chakra, V8 + } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { + $split = function (separator, limit) { + return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit); + }; + } + // 21.1.3.17 String.prototype.split(separator, limit) + return [function split(separator, limit) { + var O = defined(this); + var fn = separator == undefined ? undefined : separator[SPLIT]; + return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit); + }, $split]; + }); + + +/***/ }), +/* 205 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var LIBRARY = __webpack_require__(24); + var global = __webpack_require__(4); + var ctx = __webpack_require__(20); + var classof = __webpack_require__(74); + var $export = __webpack_require__(8); + var isObject = __webpack_require__(13); + var aFunction = __webpack_require__(21); + var anInstance = __webpack_require__(206); + var forOf = __webpack_require__(207); + var speciesConstructor = __webpack_require__(208); + var task = __webpack_require__(209).set; + var microtask = __webpack_require__(210)(); + var newPromiseCapabilityModule = __webpack_require__(211); + var perform = __webpack_require__(212); + var userAgent = __webpack_require__(213); + var promiseResolve = __webpack_require__(214); + var PROMISE = 'Promise'; + var TypeError = global.TypeError; + var process = global.process; + var versions = process && process.versions; + var v8 = versions && versions.v8 || ''; + var $Promise = global[PROMISE]; + var isNode = classof(process) == 'process'; + var empty = function () { /* empty */ }; + var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; + var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f; + + var USE_NATIVE = !!function () { + try { + // correct subclassing with @@species support + var promise = $Promise.resolve(1); + var FakePromise = (promise.constructor = {})[__webpack_require__(26)('species')] = function (exec) { + exec(empty, empty); + }; + // unhandled rejections tracking support, NodeJS Promise without it fails @@species test + return (isNode || typeof PromiseRejectionEvent == 'function') + && promise.then(empty) instanceof FakePromise + // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables + // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 + // we can't detect it synchronously, so just check versions + && v8.indexOf('6.6') !== 0 + && userAgent.indexOf('Chrome/66') === -1; + } catch (e) { /* empty */ } + }(); + + // helpers + var isThenable = function (it) { + var then; + return isObject(it) && typeof (then = it.then) == 'function' ? then : false; + }; + var notify = function (promise, isReject) { + if (promise._n) return; + promise._n = true; + var chain = promise._c; + microtask(function () { + var value = promise._v; + var ok = promise._s == 1; + var i = 0; + var run = function (reaction) { + var handler = ok ? reaction.ok : reaction.fail; + var resolve = reaction.resolve; + var reject = reaction.reject; + var domain = reaction.domain; + var result, then, exited; + try { + if (handler) { + if (!ok) { + if (promise._h == 2) onHandleUnhandled(promise); + promise._h = 1; + } + if (handler === true) result = value; + else { + if (domain) domain.enter(); + result = handler(value); // may throw + if (domain) { + domain.exit(); + exited = true; + } + } + if (result === reaction.promise) { + reject(TypeError('Promise-chain cycle')); + } else if (then = isThenable(result)) { + then.call(result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch (e) { + if (domain && !exited) domain.exit(); + reject(e); + } + }; + while (chain.length > i) run(chain[i++]); // variable length - can't use forEach + promise._c = []; + promise._n = false; + if (isReject && !promise._h) onUnhandled(promise); + }); + }; + var onUnhandled = function (promise) { + task.call(global, function () { + var value = promise._v; + var unhandled = isUnhandled(promise); + var result, handler, console; + if (unhandled) { + result = perform(function () { + if (isNode) { + process.emit('unhandledRejection', value, promise); + } else if (handler = global.onunhandledrejection) { + handler({ promise: promise, reason: value }); + } else if ((console = global.console) && console.error) { + console.error('Unhandled promise rejection', value); + } + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + promise._h = isNode || isUnhandled(promise) ? 2 : 1; + } promise._a = undefined; + if (unhandled && result.e) throw result.v; + }); + }; + var isUnhandled = function (promise) { + return promise._h !== 1 && (promise._a || promise._c).length === 0; + }; + var onHandleUnhandled = function (promise) { + task.call(global, function () { + var handler; + if (isNode) { + process.emit('rejectionHandled', promise); + } else if (handler = global.onrejectionhandled) { + handler({ promise: promise, reason: promise._v }); + } + }); + }; + var $reject = function (value) { + var promise = this; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + promise._v = value; + promise._s = 2; + if (!promise._a) promise._a = promise._c.slice(); + notify(promise, true); + }; + var $resolve = function (value) { + var promise = this; + var then; + if (promise._d) return; + promise._d = true; + promise = promise._w || promise; // unwrap + try { + if (promise === value) throw TypeError("Promise can't be resolved itself"); + if (then = isThenable(value)) { + microtask(function () { + var wrapper = { _w: promise, _d: false }; // wrap + try { + then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); + } catch (e) { + $reject.call(wrapper, e); + } + }); + } else { + promise._v = value; + promise._s = 1; + notify(promise, false); + } + } catch (e) { + $reject.call({ _w: promise, _d: false }, e); // wrap + } + }; + + // constructor polyfill + if (!USE_NATIVE) { + // 25.4.3.1 Promise(executor) + $Promise = function Promise(executor) { + anInstance(this, $Promise, PROMISE, '_h'); + aFunction(executor); + Internal.call(this); + try { + executor(ctx($resolve, this, 1), ctx($reject, this, 1)); + } catch (err) { + $reject.call(this, err); + } + }; + // eslint-disable-next-line no-unused-vars + Internal = function Promise(executor) { + this._c = []; // <- awaiting reactions + this._a = undefined; // <- checked in isUnhandled reactions + this._s = 0; // <- state + this._d = false; // <- done + this._v = undefined; // <- value + this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled + this._n = false; // <- notify + }; + Internal.prototype = __webpack_require__(215)($Promise.prototype, { + // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) + then: function then(onFulfilled, onRejected) { + var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); + reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; + reaction.fail = typeof onRejected == 'function' && onRejected; + reaction.domain = isNode ? process.domain : undefined; + this._c.push(reaction); + if (this._a) this._a.push(reaction); + if (this._s) notify(this, false); + return reaction.promise; + }, + // 25.4.5.1 Promise.prototype.catch(onRejected) + 'catch': function (onRejected) { + return this.then(undefined, onRejected); + } + }); + OwnPromiseCapability = function () { + var promise = new Internal(); + this.promise = promise; + this.resolve = ctx($resolve, promise, 1); + this.reject = ctx($reject, promise, 1); + }; + newPromiseCapabilityModule.f = newPromiseCapability = function (C) { + return C === $Promise || C === Wrapper + ? new OwnPromiseCapability(C) + : newGenericPromiseCapability(C); + }; + } + + $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise }); + __webpack_require__(25)($Promise, PROMISE); + __webpack_require__(193)(PROMISE); + Wrapper = __webpack_require__(9)[PROMISE]; + + // statics + $export($export.S + $export.F * !USE_NATIVE, PROMISE, { + // 25.4.4.5 Promise.reject(r) + reject: function reject(r) { + var capability = newPromiseCapability(this); + var $$reject = capability.reject; + $$reject(r); + return capability.promise; + } + }); + $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { + // 25.4.4.6 Promise.resolve(x) + resolve: function resolve(x) { + return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x); + } + }); + $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(166)(function (iter) { + $Promise.all(iter)['catch'](empty); + })), PROMISE, { + // 25.4.4.1 Promise.all(iterable) + all: function all(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = perform(function () { + var values = []; + var index = 0; + var remaining = 1; + forOf(iterable, false, function (promise) { + var $index = index++; + var alreadyCalled = false; + values.push(undefined); + remaining++; + C.resolve(promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[$index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if (result.e) reject(result.v); + return capability.promise; + }, + // 25.4.4.4 Promise.race(iterable) + race: function race(iterable) { + var C = this; + var capability = newPromiseCapability(C); + var reject = capability.reject; + var result = perform(function () { + forOf(iterable, false, function (promise) { + C.resolve(promise).then(capability.resolve, reject); + }); + }); + if (result.e) reject(result.v); + return capability.promise; + } + }); + + +/***/ }), +/* 206 */ +/***/ (function(module, exports) { + + module.exports = function (it, Constructor, name, forbiddenField) { + if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) { + throw TypeError(name + ': incorrect invocation!'); + } return it; + }; + + +/***/ }), +/* 207 */ +/***/ (function(module, exports, __webpack_require__) { + + var ctx = __webpack_require__(20); + var call = __webpack_require__(162); + var isArrayIter = __webpack_require__(163); + var anObject = __webpack_require__(12); + var toLength = __webpack_require__(37); + var getIterFn = __webpack_require__(165); + var BREAK = {}; + var RETURN = {}; + var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { + var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable); + var f = ctx(fn, that, entries ? 2 : 1); + var index = 0; + var length, step, iterator, result; + if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); + // fast case for arrays with default iterator + if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) { + result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); + if (result === BREAK || result === RETURN) return result; + } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { + result = call(iterator, f, step.value, entries); + if (result === BREAK || result === RETURN) return result; + } + }; + exports.BREAK = BREAK; + exports.RETURN = RETURN; + + +/***/ }), +/* 208 */ +/***/ (function(module, exports, __webpack_require__) { + + // 7.3.20 SpeciesConstructor(O, defaultConstructor) + var anObject = __webpack_require__(12); + var aFunction = __webpack_require__(21); + var SPECIES = __webpack_require__(26)('species'); + module.exports = function (O, D) { + var C = anObject(O).constructor; + var S; + return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); + }; + + +/***/ }), +/* 209 */ +/***/ (function(module, exports, __webpack_require__) { + + var ctx = __webpack_require__(20); + var invoke = __webpack_require__(77); + var html = __webpack_require__(47); + var cel = __webpack_require__(15); + var global = __webpack_require__(4); + var process = global.process; + var setTask = global.setImmediate; + var clearTask = global.clearImmediate; + var MessageChannel = global.MessageChannel; + var Dispatch = global.Dispatch; + var counter = 0; + var queue = {}; + var ONREADYSTATECHANGE = 'onreadystatechange'; + var defer, channel, port; + var run = function () { + var id = +this; + // eslint-disable-next-line no-prototype-builtins + if (queue.hasOwnProperty(id)) { + var fn = queue[id]; + delete queue[id]; + fn(); + } + }; + var listener = function (event) { + run.call(event.data); + }; + // Node.js 0.9+ & IE10+ has setImmediate, otherwise: + if (!setTask || !clearTask) { + setTask = function setImmediate(fn) { + var args = []; + var i = 1; + while (arguments.length > i) args.push(arguments[i++]); + queue[++counter] = function () { + // eslint-disable-next-line no-new-func + invoke(typeof fn == 'function' ? fn : Function(fn), args); + }; + defer(counter); + return counter; + }; + clearTask = function clearImmediate(id) { + delete queue[id]; + }; + // Node.js 0.8- + if (__webpack_require__(34)(process) == 'process') { + defer = function (id) { + process.nextTick(ctx(run, id, 1)); + }; + // Sphere (JS game engine) Dispatch API + } else if (Dispatch && Dispatch.now) { + defer = function (id) { + Dispatch.now(ctx(run, id, 1)); + }; + // Browsers with MessageChannel, includes WebWorkers + } else if (MessageChannel) { + channel = new MessageChannel(); + port = channel.port2; + channel.port1.onmessage = listener; + defer = ctx(port.postMessage, port, 1); + // Browsers with postMessage, skip WebWorkers + // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' + } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) { + defer = function (id) { + global.postMessage(id + '', '*'); + }; + global.addEventListener('message', listener, false); + // IE8- + } else if (ONREADYSTATECHANGE in cel('script')) { + defer = function (id) { + html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () { + html.removeChild(this); + run.call(id); + }; + }; + // Rest old browsers + } else { + defer = function (id) { + setTimeout(ctx(run, id, 1), 0); + }; + } + } + module.exports = { + set: setTask, + clear: clearTask + }; + + +/***/ }), +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var macrotask = __webpack_require__(209).set; + var Observer = global.MutationObserver || global.WebKitMutationObserver; + var process = global.process; + var Promise = global.Promise; + var isNode = __webpack_require__(34)(process) == 'process'; + + module.exports = function () { + var head, last, notify; + + var flush = function () { + var parent, fn; + if (isNode && (parent = process.domain)) parent.exit(); + while (head) { + fn = head.fn; + head = head.next; + try { + fn(); + } catch (e) { + if (head) notify(); + else last = undefined; + throw e; + } + } last = undefined; + if (parent) parent.enter(); + }; + + // Node.js + if (isNode) { + notify = function () { + process.nextTick(flush); + }; + // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 + } else if (Observer && !(global.navigator && global.navigator.standalone)) { + var toggle = true; + var node = document.createTextNode(''); + new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new + notify = function () { + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if (Promise && Promise.resolve) { + // Promise.resolve without an argument throws an error in LG WebOS 2 + var promise = Promise.resolve(undefined); + notify = function () { + promise.then(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessag + // - onreadystatechange + // - setTimeout + } else { + notify = function () { + // strange IE + webpack dev server bug - use .call(global) + macrotask.call(global, flush); + }; + } + + return function (fn) { + var task = { fn: fn, next: undefined }; + if (last) last.next = task; + if (!head) { + head = task; + notify(); + } last = task; + }; + }; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 25.4.1.5 NewPromiseCapability(C) + var aFunction = __webpack_require__(21); + + function PromiseCapability(C) { + var resolve, reject; + this.promise = new C(function ($$resolve, $$reject) { + if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); + resolve = $$resolve; + reject = $$reject; + }); + this.resolve = aFunction(resolve); + this.reject = aFunction(reject); + } + + module.exports.f = function (C) { + return new PromiseCapability(C); + }; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports) { + + module.exports = function (exec) { + try { + return { e: false, v: exec() }; + } catch (e) { + return { e: true, v: e }; + } + }; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var navigator = global.navigator; + + module.exports = navigator && navigator.userAgent || ''; + + +/***/ }), +/* 214 */ +/***/ (function(module, exports, __webpack_require__) { + + var anObject = __webpack_require__(12); + var isObject = __webpack_require__(13); + var newPromiseCapability = __webpack_require__(211); + + module.exports = function (C, x) { + anObject(C); + if (isObject(x) && x.constructor === C) return x; + var promiseCapability = newPromiseCapability.f(C); + var resolve = promiseCapability.resolve; + resolve(x); + return promiseCapability.promise; + }; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + + var redefine = __webpack_require__(18); + module.exports = function (target, src, safe) { + for (var key in src) redefine(target, key, src[key], safe); + return target; + }; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var strong = __webpack_require__(217); + var validate = __webpack_require__(218); + var MAP = 'Map'; + + // 23.1 Map Objects + module.exports = __webpack_require__(219)(MAP, function (get) { + return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; + }, { + // 23.1.3.6 Map.prototype.get(key) + get: function get(key) { + var entry = strong.getEntry(validate(this, MAP), key); + return entry && entry.v; + }, + // 23.1.3.9 Map.prototype.set(key, value) + set: function set(key, value) { + return strong.def(validate(this, MAP), key === 0 ? 0 : key, value); + } + }, strong, true); + + +/***/ }), +/* 217 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var dP = __webpack_require__(11).f; + var create = __webpack_require__(45); + var redefineAll = __webpack_require__(215); + var ctx = __webpack_require__(20); + var anInstance = __webpack_require__(206); + var forOf = __webpack_require__(207); + var $iterDefine = __webpack_require__(128); + var step = __webpack_require__(195); + var setSpecies = __webpack_require__(193); + var DESCRIPTORS = __webpack_require__(6); + var fastKey = __webpack_require__(22).fastKey; + var validate = __webpack_require__(218); + var SIZE = DESCRIPTORS ? '_s' : 'size'; + + var getEntry = function (that, key) { + // fast case + var index = fastKey(key); + var entry; + if (index !== 'F') return that._i[index]; + // frozen object case + for (entry = that._f; entry; entry = entry.n) { + if (entry.k == key) return entry; + } + }; + + module.exports = { + getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { + var C = wrapper(function (that, iterable) { + anInstance(that, C, NAME, '_i'); + that._t = NAME; // collection type + that._i = create(null); // index + that._f = undefined; // first entry + that._l = undefined; // last entry + that[SIZE] = 0; // size + if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); + }); + redefineAll(C.prototype, { + // 23.1.3.1 Map.prototype.clear() + // 23.2.3.2 Set.prototype.clear() + clear: function clear() { + for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { + entry.r = true; + if (entry.p) entry.p = entry.p.n = undefined; + delete data[entry.i]; + } + that._f = that._l = undefined; + that[SIZE] = 0; + }, + // 23.1.3.3 Map.prototype.delete(key) + // 23.2.3.4 Set.prototype.delete(value) + 'delete': function (key) { + var that = validate(this, NAME); + var entry = getEntry(that, key); + if (entry) { + var next = entry.n; + var prev = entry.p; + delete that._i[entry.i]; + entry.r = true; + if (prev) prev.n = next; + if (next) next.p = prev; + if (that._f == entry) that._f = next; + if (that._l == entry) that._l = prev; + that[SIZE]--; + } return !!entry; + }, + // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) + // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) + forEach: function forEach(callbackfn /* , that = undefined */) { + validate(this, NAME); + var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); + var entry; + while (entry = entry ? entry.n : this._f) { + f(entry.v, entry.k, this); + // revert to the last existing entry + while (entry && entry.r) entry = entry.p; + } + }, + // 23.1.3.7 Map.prototype.has(key) + // 23.2.3.7 Set.prototype.has(value) + has: function has(key) { + return !!getEntry(validate(this, NAME), key); + } + }); + if (DESCRIPTORS) dP(C.prototype, 'size', { + get: function () { + return validate(this, NAME)[SIZE]; + } + }); + return C; + }, + def: function (that, key, value) { + var entry = getEntry(that, key); + var prev, index; + // change existing entry + if (entry) { + entry.v = value; + // create new entry + } else { + that._l = entry = { + i: index = fastKey(key, true), // <- index + k: key, // <- key + v: value, // <- value + p: prev = that._l, // <- previous entry + n: undefined, // <- next entry + r: false // <- removed + }; + if (!that._f) that._f = entry; + if (prev) prev.n = entry; + that[SIZE]++; + // add to index + if (index !== 'F') that._i[index] = entry; + } return that; + }, + getEntry: getEntry, + setStrong: function (C, NAME, IS_MAP) { + // add .keys, .values, .entries, [@@iterator] + // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 + $iterDefine(C, NAME, function (iterated, kind) { + this._t = validate(iterated, NAME); // target + this._k = kind; // kind + this._l = undefined; // previous + }, function () { + var that = this; + var kind = that._k; + var entry = that._l; + // revert to the last existing entry + while (entry && entry.r) entry = entry.p; + // get next entry + if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { + // or finish the iteration + that._t = undefined; + return step(1); + } + // return step by kind + if (kind == 'keys') return step(0, entry.k); + if (kind == 'values') return step(0, entry.v); + return step(0, [entry.k, entry.v]); + }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); + + // add [@@species], 23.1.2.2, 23.2.2.2 + setSpecies(NAME); + } + }; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(13); + module.exports = function (it, TYPE) { + if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); + return it; + }; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var global = __webpack_require__(4); + var $export = __webpack_require__(8); + var redefine = __webpack_require__(18); + var redefineAll = __webpack_require__(215); + var meta = __webpack_require__(22); + var forOf = __webpack_require__(207); + var anInstance = __webpack_require__(206); + var isObject = __webpack_require__(13); + var fails = __webpack_require__(7); + var $iterDetect = __webpack_require__(166); + var setToStringTag = __webpack_require__(25); + var inheritIfRequired = __webpack_require__(87); + + module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { + var Base = global[NAME]; + var C = Base; + var ADDER = IS_MAP ? 'set' : 'add'; + var proto = C && C.prototype; + var O = {}; + var fixMethod = function (KEY) { + var fn = proto[KEY]; + redefine(proto, KEY, + KEY == 'delete' ? function (a) { + return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'has' ? function has(a) { + return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'get' ? function get(a) { + return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); + } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; } + : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; } + ); + }; + if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () { + new C().entries().next(); + }))) { + // create collection constructor + C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); + redefineAll(C.prototype, methods); + meta.NEED = true; + } else { + var instance = new C(); + // early implementations not supports chaining + var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; + // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false + var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); }); + // most early implementations doesn't supports iterables, most modern - not close it correctly + var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new + // for early implementations -0 and +0 not the same + var BUGGY_ZERO = !IS_WEAK && fails(function () { + // V8 ~ Chromium 42- fails only with 5+ elements + var $instance = new C(); + var index = 5; + while (index--) $instance[ADDER](index, index); + return !$instance.has(-0); + }); + if (!ACCEPT_ITERABLES) { + C = wrapper(function (target, iterable) { + anInstance(target, C, NAME); + var that = inheritIfRequired(new Base(), target, C); + if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); + return that; + }); + C.prototype = proto; + proto.constructor = C; + } + if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { + fixMethod('delete'); + fixMethod('has'); + IS_MAP && fixMethod('get'); + } + if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); + // weak collections should not contains .clear method + if (IS_WEAK && proto.clear) delete proto.clear; + } + + setToStringTag(C, NAME); + + O[NAME] = C; + $export($export.G + $export.W + $export.F * (C != Base), O); + + if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); + + return C; + }; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var strong = __webpack_require__(217); + var validate = __webpack_require__(218); + var SET = 'Set'; + + // 23.2 Set Objects + module.exports = __webpack_require__(219)(SET, function (get) { + return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; + }, { + // 23.2.3.1 Set.prototype.add(value) + add: function add(value) { + return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value); + } + }, strong); + + +/***/ }), +/* 221 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var each = __webpack_require__(173)(0); + var redefine = __webpack_require__(18); + var meta = __webpack_require__(22); + var assign = __webpack_require__(68); + var weak = __webpack_require__(222); + var isObject = __webpack_require__(13); + var fails = __webpack_require__(7); + var validate = __webpack_require__(218); + var WEAK_MAP = 'WeakMap'; + var getWeak = meta.getWeak; + var isExtensible = Object.isExtensible; + var uncaughtFrozenStore = weak.ufstore; + var tmp = {}; + var InternalMap; + + var wrapper = function (get) { + return function WeakMap() { + return get(this, arguments.length > 0 ? arguments[0] : undefined); + }; + }; + + var methods = { + // 23.3.3.3 WeakMap.prototype.get(key) + get: function get(key) { + if (isObject(key)) { + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key); + return data ? data[this._i] : undefined; + } + }, + // 23.3.3.5 WeakMap.prototype.set(key, value) + set: function set(key, value) { + return weak.def(validate(this, WEAK_MAP), key, value); + } + }; + + // 23.3 WeakMap Objects + var $WeakMap = module.exports = __webpack_require__(219)(WEAK_MAP, wrapper, methods, weak, true, true); + + // IE11 WeakMap frozen keys fix + if (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) { + InternalMap = weak.getConstructor(wrapper, WEAK_MAP); + assign(InternalMap.prototype, methods); + meta.NEED = true; + each(['delete', 'has', 'get', 'set'], function (key) { + var proto = $WeakMap.prototype; + var method = proto[key]; + redefine(proto, key, function (a, b) { + // store frozen objects on internal weakmap shim + if (isObject(a) && !isExtensible(a)) { + if (!this._f) this._f = new InternalMap(); + var result = this._f[key](a, b); + return key == 'set' ? this : result; + // store all the rest on native weakmap + } return method.call(this, a, b); + }); + }); + } + + +/***/ }), +/* 222 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var redefineAll = __webpack_require__(215); + var getWeak = __webpack_require__(22).getWeak; + var anObject = __webpack_require__(12); + var isObject = __webpack_require__(13); + var anInstance = __webpack_require__(206); + var forOf = __webpack_require__(207); + var createArrayMethod = __webpack_require__(173); + var $has = __webpack_require__(5); + var validate = __webpack_require__(218); + var arrayFind = createArrayMethod(5); + var arrayFindIndex = createArrayMethod(6); + var id = 0; + + // fallback for uncaught frozen keys + var uncaughtFrozenStore = function (that) { + return that._l || (that._l = new UncaughtFrozenStore()); + }; + var UncaughtFrozenStore = function () { + this.a = []; + }; + var findUncaughtFrozen = function (store, key) { + return arrayFind(store.a, function (it) { + return it[0] === key; + }); + }; + UncaughtFrozenStore.prototype = { + get: function (key) { + var entry = findUncaughtFrozen(this, key); + if (entry) return entry[1]; + }, + has: function (key) { + return !!findUncaughtFrozen(this, key); + }, + set: function (key, value) { + var entry = findUncaughtFrozen(this, key); + if (entry) entry[1] = value; + else this.a.push([key, value]); + }, + 'delete': function (key) { + var index = arrayFindIndex(this.a, function (it) { + return it[0] === key; + }); + if (~index) this.a.splice(index, 1); + return !!~index; + } + }; + + module.exports = { + getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { + var C = wrapper(function (that, iterable) { + anInstance(that, C, NAME, '_i'); + that._t = NAME; // collection type + that._i = id++; // collection id + that._l = undefined; // leak store for uncaught frozen objects + if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); + }); + redefineAll(C.prototype, { + // 23.3.3.2 WeakMap.prototype.delete(key) + // 23.4.3.3 WeakSet.prototype.delete(value) + 'delete': function (key) { + if (!isObject(key)) return false; + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key); + return data && $has(data, this._i) && delete data[this._i]; + }, + // 23.3.3.4 WeakMap.prototype.has(key) + // 23.4.3.4 WeakSet.prototype.has(value) + has: function has(key) { + if (!isObject(key)) return false; + var data = getWeak(key); + if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key); + return data && $has(data, this._i); + } + }); + return C; + }, + def: function (that, key, value) { + var data = getWeak(anObject(key), true); + if (data === true) uncaughtFrozenStore(that).set(key, value); + else data[that._i] = value; + return that; + }, + ufstore: uncaughtFrozenStore + }; + + +/***/ }), +/* 223 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var weak = __webpack_require__(222); + var validate = __webpack_require__(218); + var WEAK_SET = 'WeakSet'; + + // 23.4 WeakSet Objects + __webpack_require__(219)(WEAK_SET, function (get) { + return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; + }, { + // 23.4.3.1 WeakSet.prototype.add(value) + add: function add(value) { + return weak.def(validate(this, WEAK_SET), value, true); + } + }, weak, false, true); + + +/***/ }), +/* 224 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var $typed = __webpack_require__(225); + var buffer = __webpack_require__(226); + var anObject = __webpack_require__(12); + var toAbsoluteIndex = __webpack_require__(39); + var toLength = __webpack_require__(37); + var isObject = __webpack_require__(13); + var ArrayBuffer = __webpack_require__(4).ArrayBuffer; + var speciesConstructor = __webpack_require__(208); + var $ArrayBuffer = buffer.ArrayBuffer; + var $DataView = buffer.DataView; + var $isView = $typed.ABV && ArrayBuffer.isView; + var $slice = $ArrayBuffer.prototype.slice; + var VIEW = $typed.VIEW; + var ARRAY_BUFFER = 'ArrayBuffer'; + + $export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer }); + + $export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, { + // 24.1.3.1 ArrayBuffer.isView(arg) + isView: function isView(it) { + return $isView && $isView(it) || isObject(it) && VIEW in it; + } + }); + + $export($export.P + $export.U + $export.F * __webpack_require__(7)(function () { + return !new $ArrayBuffer(2).slice(1, undefined).byteLength; + }), ARRAY_BUFFER, { + // 24.1.4.3 ArrayBuffer.prototype.slice(start, end) + slice: function slice(start, end) { + if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix + var len = anObject(this).byteLength; + var first = toAbsoluteIndex(start, len); + var fin = toAbsoluteIndex(end === undefined ? len : end, len); + var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(fin - first)); + var viewS = new $DataView(this); + var viewT = new $DataView(result); + var index = 0; + while (first < fin) { + viewT.setUint8(index++, viewS.getUint8(first++)); + } return result; + } + }); + + __webpack_require__(193)(ARRAY_BUFFER); + + +/***/ }), +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + + var global = __webpack_require__(4); + var hide = __webpack_require__(10); + var uid = __webpack_require__(19); + var TYPED = uid('typed_array'); + var VIEW = uid('view'); + var ABV = !!(global.ArrayBuffer && global.DataView); + var CONSTR = ABV; + var i = 0; + var l = 9; + var Typed; + + var TypedArrayConstructors = ( + 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array' + ).split(','); + + while (i < l) { + if (Typed = global[TypedArrayConstructors[i++]]) { + hide(Typed.prototype, TYPED, true); + hide(Typed.prototype, VIEW, true); + } else CONSTR = false; + } + + module.exports = { + ABV: ABV, + CONSTR: CONSTR, + TYPED: TYPED, + VIEW: VIEW + }; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var global = __webpack_require__(4); + var DESCRIPTORS = __webpack_require__(6); + var LIBRARY = __webpack_require__(24); + var $typed = __webpack_require__(225); + var hide = __webpack_require__(10); + var redefineAll = __webpack_require__(215); + var fails = __webpack_require__(7); + var anInstance = __webpack_require__(206); + var toInteger = __webpack_require__(38); + var toLength = __webpack_require__(37); + var toIndex = __webpack_require__(227); + var gOPN = __webpack_require__(49).f; + var dP = __webpack_require__(11).f; + var arrayFill = __webpack_require__(189); + var setToStringTag = __webpack_require__(25); + var ARRAY_BUFFER = 'ArrayBuffer'; + var DATA_VIEW = 'DataView'; + var PROTOTYPE = 'prototype'; + var WRONG_LENGTH = 'Wrong length!'; + var WRONG_INDEX = 'Wrong index!'; + var $ArrayBuffer = global[ARRAY_BUFFER]; + var $DataView = global[DATA_VIEW]; + var Math = global.Math; + var RangeError = global.RangeError; + // eslint-disable-next-line no-shadow-restricted-names + var Infinity = global.Infinity; + var BaseBuffer = $ArrayBuffer; + var abs = Math.abs; + var pow = Math.pow; + var floor = Math.floor; + var log = Math.log; + var LN2 = Math.LN2; + var BUFFER = 'buffer'; + var BYTE_LENGTH = 'byteLength'; + var BYTE_OFFSET = 'byteOffset'; + var $BUFFER = DESCRIPTORS ? '_b' : BUFFER; + var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH; + var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET; + + // IEEE754 conversions based on https://github.com/feross/ieee754 + function packIEEE754(value, mLen, nBytes) { + var buffer = new Array(nBytes); + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0; + var i = 0; + var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; + var e, m, c; + value = abs(value); + // eslint-disable-next-line no-self-compare + if (value != value || value === Infinity) { + // eslint-disable-next-line no-self-compare + m = value != value ? 1 : 0; + e = eMax; + } else { + e = floor(log(value) / LN2); + if (value * (c = pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * pow(2, mLen); + e = e + eBias; + } else { + m = value * pow(2, eBias - 1) * pow(2, mLen); + e = 0; + } + } + for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8); + e = e << mLen | m; + eLen += mLen; + for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8); + buffer[--i] |= s * 128; + return buffer; + } + function unpackIEEE754(buffer, mLen, nBytes) { + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = eLen - 7; + var i = nBytes - 1; + var s = buffer[i--]; + var e = s & 127; + var m; + s >>= 7; + for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8); + m = e & (1 << -nBits) - 1; + e >>= -nBits; + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8); + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : s ? -Infinity : Infinity; + } else { + m = m + pow(2, mLen); + e = e - eBias; + } return (s ? -1 : 1) * m * pow(2, e - mLen); + } + + function unpackI32(bytes) { + return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]; + } + function packI8(it) { + return [it & 0xff]; + } + function packI16(it) { + return [it & 0xff, it >> 8 & 0xff]; + } + function packI32(it) { + return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff]; + } + function packF64(it) { + return packIEEE754(it, 52, 8); + } + function packF32(it) { + return packIEEE754(it, 23, 4); + } + + function addGetter(C, key, internal) { + dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } }); + } + + function get(view, bytes, index, isLittleEndian) { + var numIndex = +index; + var intIndex = toIndex(numIndex); + if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX); + var store = view[$BUFFER]._b; + var start = intIndex + view[$OFFSET]; + var pack = store.slice(start, start + bytes); + return isLittleEndian ? pack : pack.reverse(); + } + function set(view, bytes, index, conversion, value, isLittleEndian) { + var numIndex = +index; + var intIndex = toIndex(numIndex); + if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX); + var store = view[$BUFFER]._b; + var start = intIndex + view[$OFFSET]; + var pack = conversion(+value); + for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1]; + } + + if (!$typed.ABV) { + $ArrayBuffer = function ArrayBuffer(length) { + anInstance(this, $ArrayBuffer, ARRAY_BUFFER); + var byteLength = toIndex(length); + this._b = arrayFill.call(new Array(byteLength), 0); + this[$LENGTH] = byteLength; + }; + + $DataView = function DataView(buffer, byteOffset, byteLength) { + anInstance(this, $DataView, DATA_VIEW); + anInstance(buffer, $ArrayBuffer, DATA_VIEW); + var bufferLength = buffer[$LENGTH]; + var offset = toInteger(byteOffset); + if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!'); + byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); + if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH); + this[$BUFFER] = buffer; + this[$OFFSET] = offset; + this[$LENGTH] = byteLength; + }; + + if (DESCRIPTORS) { + addGetter($ArrayBuffer, BYTE_LENGTH, '_l'); + addGetter($DataView, BUFFER, '_b'); + addGetter($DataView, BYTE_LENGTH, '_l'); + addGetter($DataView, BYTE_OFFSET, '_o'); + } + + redefineAll($DataView[PROTOTYPE], { + getInt8: function getInt8(byteOffset) { + return get(this, 1, byteOffset)[0] << 24 >> 24; + }, + getUint8: function getUint8(byteOffset) { + return get(this, 1, byteOffset)[0]; + }, + getInt16: function getInt16(byteOffset /* , littleEndian */) { + var bytes = get(this, 2, byteOffset, arguments[1]); + return (bytes[1] << 8 | bytes[0]) << 16 >> 16; + }, + getUint16: function getUint16(byteOffset /* , littleEndian */) { + var bytes = get(this, 2, byteOffset, arguments[1]); + return bytes[1] << 8 | bytes[0]; + }, + getInt32: function getInt32(byteOffset /* , littleEndian */) { + return unpackI32(get(this, 4, byteOffset, arguments[1])); + }, + getUint32: function getUint32(byteOffset /* , littleEndian */) { + return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0; + }, + getFloat32: function getFloat32(byteOffset /* , littleEndian */) { + return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4); + }, + getFloat64: function getFloat64(byteOffset /* , littleEndian */) { + return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8); + }, + setInt8: function setInt8(byteOffset, value) { + set(this, 1, byteOffset, packI8, value); + }, + setUint8: function setUint8(byteOffset, value) { + set(this, 1, byteOffset, packI8, value); + }, + setInt16: function setInt16(byteOffset, value /* , littleEndian */) { + set(this, 2, byteOffset, packI16, value, arguments[2]); + }, + setUint16: function setUint16(byteOffset, value /* , littleEndian */) { + set(this, 2, byteOffset, packI16, value, arguments[2]); + }, + setInt32: function setInt32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packI32, value, arguments[2]); + }, + setUint32: function setUint32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packI32, value, arguments[2]); + }, + setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { + set(this, 4, byteOffset, packF32, value, arguments[2]); + }, + setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { + set(this, 8, byteOffset, packF64, value, arguments[2]); + } + }); + } else { + if (!fails(function () { + $ArrayBuffer(1); + }) || !fails(function () { + new $ArrayBuffer(-1); // eslint-disable-line no-new + }) || fails(function () { + new $ArrayBuffer(); // eslint-disable-line no-new + new $ArrayBuffer(1.5); // eslint-disable-line no-new + new $ArrayBuffer(NaN); // eslint-disable-line no-new + return $ArrayBuffer.name != ARRAY_BUFFER; + })) { + $ArrayBuffer = function ArrayBuffer(length) { + anInstance(this, $ArrayBuffer); + return new BaseBuffer(toIndex(length)); + }; + var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE]; + for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) { + if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]); + } + if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer; + } + // iOS Safari 7.x bug + var view = new $DataView(new $ArrayBuffer(2)); + var $setInt8 = $DataView[PROTOTYPE].setInt8; + view.setInt8(0, 2147483648); + view.setInt8(1, 2147483649); + if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], { + setInt8: function setInt8(byteOffset, value) { + $setInt8.call(this, byteOffset, value << 24 >> 24); + }, + setUint8: function setUint8(byteOffset, value) { + $setInt8.call(this, byteOffset, value << 24 >> 24); + } + }, true); + } + setToStringTag($ArrayBuffer, ARRAY_BUFFER); + setToStringTag($DataView, DATA_VIEW); + hide($DataView[PROTOTYPE], $typed.VIEW, true); + exports[ARRAY_BUFFER] = $ArrayBuffer; + exports[DATA_VIEW] = $DataView; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/ecma262/#sec-toindex + var toInteger = __webpack_require__(38); + var toLength = __webpack_require__(37); + module.exports = function (it) { + if (it === undefined) return 0; + var number = toInteger(it); + var length = toLength(number); + if (number !== length) throw RangeError('Wrong length!'); + return length; + }; + + +/***/ }), +/* 228 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + $export($export.G + $export.W + $export.F * !__webpack_require__(225).ABV, { + DataView: __webpack_require__(226).DataView + }); + + +/***/ }), +/* 229 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Int8', 1, function (init) { + return function Int8Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + if (__webpack_require__(6)) { + var LIBRARY = __webpack_require__(24); + var global = __webpack_require__(4); + var fails = __webpack_require__(7); + var $export = __webpack_require__(8); + var $typed = __webpack_require__(225); + var $buffer = __webpack_require__(226); + var ctx = __webpack_require__(20); + var anInstance = __webpack_require__(206); + var propertyDesc = __webpack_require__(17); + var hide = __webpack_require__(10); + var redefineAll = __webpack_require__(215); + var toInteger = __webpack_require__(38); + var toLength = __webpack_require__(37); + var toIndex = __webpack_require__(227); + var toAbsoluteIndex = __webpack_require__(39); + var toPrimitive = __webpack_require__(16); + var has = __webpack_require__(5); + var classof = __webpack_require__(74); + var isObject = __webpack_require__(13); + var toObject = __webpack_require__(57); + var isArrayIter = __webpack_require__(163); + var create = __webpack_require__(45); + var getPrototypeOf = __webpack_require__(58); + var gOPN = __webpack_require__(49).f; + var getIterFn = __webpack_require__(165); + var uid = __webpack_require__(19); + var wks = __webpack_require__(26); + var createArrayMethod = __webpack_require__(173); + var createArrayIncludes = __webpack_require__(36); + var speciesConstructor = __webpack_require__(208); + var ArrayIterators = __webpack_require__(194); + var Iterators = __webpack_require__(129); + var $iterDetect = __webpack_require__(166); + var setSpecies = __webpack_require__(193); + var arrayFill = __webpack_require__(189); + var arrayCopyWithin = __webpack_require__(186); + var $DP = __webpack_require__(11); + var $GOPD = __webpack_require__(50); + var dP = $DP.f; + var gOPD = $GOPD.f; + var RangeError = global.RangeError; + var TypeError = global.TypeError; + var Uint8Array = global.Uint8Array; + var ARRAY_BUFFER = 'ArrayBuffer'; + var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER; + var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; + var PROTOTYPE = 'prototype'; + var ArrayProto = Array[PROTOTYPE]; + var $ArrayBuffer = $buffer.ArrayBuffer; + var $DataView = $buffer.DataView; + var arrayForEach = createArrayMethod(0); + var arrayFilter = createArrayMethod(2); + var arraySome = createArrayMethod(3); + var arrayEvery = createArrayMethod(4); + var arrayFind = createArrayMethod(5); + var arrayFindIndex = createArrayMethod(6); + var arrayIncludes = createArrayIncludes(true); + var arrayIndexOf = createArrayIncludes(false); + var arrayValues = ArrayIterators.values; + var arrayKeys = ArrayIterators.keys; + var arrayEntries = ArrayIterators.entries; + var arrayLastIndexOf = ArrayProto.lastIndexOf; + var arrayReduce = ArrayProto.reduce; + var arrayReduceRight = ArrayProto.reduceRight; + var arrayJoin = ArrayProto.join; + var arraySort = ArrayProto.sort; + var arraySlice = ArrayProto.slice; + var arrayToString = ArrayProto.toString; + var arrayToLocaleString = ArrayProto.toLocaleString; + var ITERATOR = wks('iterator'); + var TAG = wks('toStringTag'); + var TYPED_CONSTRUCTOR = uid('typed_constructor'); + var DEF_CONSTRUCTOR = uid('def_constructor'); + var ALL_CONSTRUCTORS = $typed.CONSTR; + var TYPED_ARRAY = $typed.TYPED; + var VIEW = $typed.VIEW; + var WRONG_LENGTH = 'Wrong length!'; + + var $map = createArrayMethod(1, function (O, length) { + return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length); + }); + + var LITTLE_ENDIAN = fails(function () { + // eslint-disable-next-line no-undef + return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1; + }); + + var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () { + new Uint8Array(1).set({}); + }); + + var toOffset = function (it, BYTES) { + var offset = toInteger(it); + if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!'); + return offset; + }; + + var validate = function (it) { + if (isObject(it) && TYPED_ARRAY in it) return it; + throw TypeError(it + ' is not a typed array!'); + }; + + var allocate = function (C, length) { + if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) { + throw TypeError('It is not a typed array constructor!'); + } return new C(length); + }; + + var speciesFromList = function (O, list) { + return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list); + }; + + var fromList = function (C, list) { + var index = 0; + var length = list.length; + var result = allocate(C, length); + while (length > index) result[index] = list[index++]; + return result; + }; + + var addGetter = function (it, key, internal) { + dP(it, key, { get: function () { return this._d[internal]; } }); + }; + + var $from = function from(source /* , mapfn, thisArg */) { + var O = toObject(source); + var aLen = arguments.length; + var mapfn = aLen > 1 ? arguments[1] : undefined; + var mapping = mapfn !== undefined; + var iterFn = getIterFn(O); + var i, length, values, result, step, iterator; + if (iterFn != undefined && !isArrayIter(iterFn)) { + for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) { + values.push(step.value); + } O = values; + } + if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2); + for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) { + result[i] = mapping ? mapfn(O[i], i) : O[i]; + } + return result; + }; + + var $of = function of(/* ...items */) { + var index = 0; + var length = arguments.length; + var result = allocate(this, length); + while (length > index) result[index] = arguments[index++]; + return result; + }; + + // iOS Safari 6.x fails here + var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); }); + + var $toLocaleString = function toLocaleString() { + return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments); + }; + + var proto = { + copyWithin: function copyWithin(target, start /* , end */) { + return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined); + }, + every: function every(callbackfn /* , thisArg */) { + return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }, + fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars + return arrayFill.apply(validate(this), arguments); + }, + filter: function filter(callbackfn /* , thisArg */) { + return speciesFromList(this, arrayFilter(validate(this), callbackfn, + arguments.length > 1 ? arguments[1] : undefined)); + }, + find: function find(predicate /* , thisArg */) { + return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }, + findIndex: function findIndex(predicate /* , thisArg */) { + return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined); + }, + forEach: function forEach(callbackfn /* , thisArg */) { + arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }, + indexOf: function indexOf(searchElement /* , fromIndex */) { + return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); + }, + includes: function includes(searchElement /* , fromIndex */) { + return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); + }, + join: function join(separator) { // eslint-disable-line no-unused-vars + return arrayJoin.apply(validate(this), arguments); + }, + lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars + return arrayLastIndexOf.apply(validate(this), arguments); + }, + map: function map(mapfn /* , thisArg */) { + return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined); + }, + reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars + return arrayReduce.apply(validate(this), arguments); + }, + reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars + return arrayReduceRight.apply(validate(this), arguments); + }, + reverse: function reverse() { + var that = this; + var length = validate(that).length; + var middle = Math.floor(length / 2); + var index = 0; + var value; + while (index < middle) { + value = that[index]; + that[index++] = that[--length]; + that[length] = value; + } return that; + }, + some: function some(callbackfn /* , thisArg */) { + return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); + }, + sort: function sort(comparefn) { + return arraySort.call(validate(this), comparefn); + }, + subarray: function subarray(begin, end) { + var O = validate(this); + var length = O.length; + var $begin = toAbsoluteIndex(begin, length); + return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))( + O.buffer, + O.byteOffset + $begin * O.BYTES_PER_ELEMENT, + toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin) + ); + } + }; + + var $slice = function slice(start, end) { + return speciesFromList(this, arraySlice.call(validate(this), start, end)); + }; + + var $set = function set(arrayLike /* , offset */) { + validate(this); + var offset = toOffset(arguments[1], 1); + var length = this.length; + var src = toObject(arrayLike); + var len = toLength(src.length); + var index = 0; + if (len + offset > length) throw RangeError(WRONG_LENGTH); + while (index < len) this[offset + index] = src[index++]; + }; + + var $iterators = { + entries: function entries() { + return arrayEntries.call(validate(this)); + }, + keys: function keys() { + return arrayKeys.call(validate(this)); + }, + values: function values() { + return arrayValues.call(validate(this)); + } + }; + + var isTAIndex = function (target, key) { + return isObject(target) + && target[TYPED_ARRAY] + && typeof key != 'symbol' + && key in target + && String(+key) == String(key); + }; + var $getDesc = function getOwnPropertyDescriptor(target, key) { + return isTAIndex(target, key = toPrimitive(key, true)) + ? propertyDesc(2, target[key]) + : gOPD(target, key); + }; + var $setDesc = function defineProperty(target, key, desc) { + if (isTAIndex(target, key = toPrimitive(key, true)) + && isObject(desc) + && has(desc, 'value') + && !has(desc, 'get') + && !has(desc, 'set') + // TODO: add validation descriptor w/o calling accessors + && !desc.configurable + && (!has(desc, 'writable') || desc.writable) + && (!has(desc, 'enumerable') || desc.enumerable) + ) { + target[key] = desc.value; + return target; + } return dP(target, key, desc); + }; + + if (!ALL_CONSTRUCTORS) { + $GOPD.f = $getDesc; + $DP.f = $setDesc; + } + + $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', { + getOwnPropertyDescriptor: $getDesc, + defineProperty: $setDesc + }); + + if (fails(function () { arrayToString.call({}); })) { + arrayToString = arrayToLocaleString = function toString() { + return arrayJoin.call(this); + }; + } + + var $TypedArrayPrototype$ = redefineAll({}, proto); + redefineAll($TypedArrayPrototype$, $iterators); + hide($TypedArrayPrototype$, ITERATOR, $iterators.values); + redefineAll($TypedArrayPrototype$, { + slice: $slice, + set: $set, + constructor: function () { /* noop */ }, + toString: arrayToString, + toLocaleString: $toLocaleString + }); + addGetter($TypedArrayPrototype$, 'buffer', 'b'); + addGetter($TypedArrayPrototype$, 'byteOffset', 'o'); + addGetter($TypedArrayPrototype$, 'byteLength', 'l'); + addGetter($TypedArrayPrototype$, 'length', 'e'); + dP($TypedArrayPrototype$, TAG, { + get: function () { return this[TYPED_ARRAY]; } + }); + + // eslint-disable-next-line max-statements + module.exports = function (KEY, BYTES, wrapper, CLAMPED) { + CLAMPED = !!CLAMPED; + var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array'; + var GETTER = 'get' + KEY; + var SETTER = 'set' + KEY; + var TypedArray = global[NAME]; + var Base = TypedArray || {}; + var TAC = TypedArray && getPrototypeOf(TypedArray); + var FORCED = !TypedArray || !$typed.ABV; + var O = {}; + var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE]; + var getter = function (that, index) { + var data = that._d; + return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN); + }; + var setter = function (that, index, value) { + var data = that._d; + if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff; + data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN); + }; + var addElement = function (that, index) { + dP(that, index, { + get: function () { + return getter(this, index); + }, + set: function (value) { + return setter(this, index, value); + }, + enumerable: true + }); + }; + if (FORCED) { + TypedArray = wrapper(function (that, data, $offset, $length) { + anInstance(that, TypedArray, NAME, '_d'); + var index = 0; + var offset = 0; + var buffer, byteLength, length, klass; + if (!isObject(data)) { + length = toIndex(data); + byteLength = length * BYTES; + buffer = new $ArrayBuffer(byteLength); + } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) { + buffer = data; + offset = toOffset($offset, BYTES); + var $len = data.byteLength; + if ($length === undefined) { + if ($len % BYTES) throw RangeError(WRONG_LENGTH); + byteLength = $len - offset; + if (byteLength < 0) throw RangeError(WRONG_LENGTH); + } else { + byteLength = toLength($length) * BYTES; + if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH); + } + length = byteLength / BYTES; + } else if (TYPED_ARRAY in data) { + return fromList(TypedArray, data); + } else { + return $from.call(TypedArray, data); + } + hide(that, '_d', { + b: buffer, + o: offset, + l: byteLength, + e: length, + v: new $DataView(buffer) + }); + while (index < length) addElement(that, index++); + }); + TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$); + hide(TypedArrayPrototype, 'constructor', TypedArray); + } else if (!fails(function () { + TypedArray(1); + }) || !fails(function () { + new TypedArray(-1); // eslint-disable-line no-new + }) || !$iterDetect(function (iter) { + new TypedArray(); // eslint-disable-line no-new + new TypedArray(null); // eslint-disable-line no-new + new TypedArray(1.5); // eslint-disable-line no-new + new TypedArray(iter); // eslint-disable-line no-new + }, true)) { + TypedArray = wrapper(function (that, data, $offset, $length) { + anInstance(that, TypedArray, NAME); + var klass; + // `ws` module bug, temporarily remove validation length for Uint8Array + // https://github.com/websockets/ws/pull/645 + if (!isObject(data)) return new Base(toIndex(data)); + if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) { + return $length !== undefined + ? new Base(data, toOffset($offset, BYTES), $length) + : $offset !== undefined + ? new Base(data, toOffset($offset, BYTES)) + : new Base(data); + } + if (TYPED_ARRAY in data) return fromList(TypedArray, data); + return $from.call(TypedArray, data); + }); + arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) { + if (!(key in TypedArray)) hide(TypedArray, key, Base[key]); + }); + TypedArray[PROTOTYPE] = TypedArrayPrototype; + if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray; + } + var $nativeIterator = TypedArrayPrototype[ITERATOR]; + var CORRECT_ITER_NAME = !!$nativeIterator + && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined); + var $iterator = $iterators.values; + hide(TypedArray, TYPED_CONSTRUCTOR, true); + hide(TypedArrayPrototype, TYPED_ARRAY, NAME); + hide(TypedArrayPrototype, VIEW, true); + hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray); + + if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) { + dP(TypedArrayPrototype, TAG, { + get: function () { return NAME; } + }); + } + + O[NAME] = TypedArray; + + $export($export.G + $export.W + $export.F * (TypedArray != Base), O); + + $export($export.S, NAME, { + BYTES_PER_ELEMENT: BYTES + }); + + $export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, { + from: $from, + of: $of + }); + + if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES); + + $export($export.P, NAME, proto); + + setSpecies(NAME); + + $export($export.P + $export.F * FORCED_SET, NAME, { set: $set }); + + $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators); + + if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString; + + $export($export.P + $export.F * fails(function () { + new TypedArray(1).slice(); + }), NAME, { slice: $slice }); + + $export($export.P + $export.F * (fails(function () { + return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString(); + }) || !fails(function () { + TypedArrayPrototype.toLocaleString.call([1, 2]); + })), NAME, { toLocaleString: $toLocaleString }); + + Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator; + if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator); + }; + } else module.exports = function () { /* empty */ }; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Uint8', 1, function (init) { + return function Uint8Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Uint8', 1, function (init) { + return function Uint8ClampedArray(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }, true); + + +/***/ }), +/* 233 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Int16', 2, function (init) { + return function Int16Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Uint16', 2, function (init) { + return function Uint16Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Int32', 4, function (init) { + return function Int32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 236 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Uint32', 4, function (init) { + return function Uint32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 237 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Float32', 4, function (init) { + return function Float32Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(230)('Float64', 8, function (init) { + return function Float64Array(data, byteOffset, length) { + return init(this, data, byteOffset, length); + }; + }); + + +/***/ }), +/* 239 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.1 Reflect.apply(target, thisArgument, argumentsList) + var $export = __webpack_require__(8); + var aFunction = __webpack_require__(21); + var anObject = __webpack_require__(12); + var rApply = (__webpack_require__(4).Reflect || {}).apply; + var fApply = Function.apply; + // MS Edge argumentsList argument is optional + $export($export.S + $export.F * !__webpack_require__(7)(function () { + rApply(function () { /* empty */ }); + }), 'Reflect', { + apply: function apply(target, thisArgument, argumentsList) { + var T = aFunction(target); + var L = anObject(argumentsList); + return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L); + } + }); + + +/***/ }), +/* 240 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.2 Reflect.construct(target, argumentsList [, newTarget]) + var $export = __webpack_require__(8); + var create = __webpack_require__(45); + var aFunction = __webpack_require__(21); + var anObject = __webpack_require__(12); + var isObject = __webpack_require__(13); + var fails = __webpack_require__(7); + var bind = __webpack_require__(76); + var rConstruct = (__webpack_require__(4).Reflect || {}).construct; + + // MS Edge supports only 2 arguments and argumentsList argument is optional + // FF Nightly sets third argument as `new.target`, but does not create `this` from it + var NEW_TARGET_BUG = fails(function () { + function F() { /* empty */ } + return !(rConstruct(function () { /* empty */ }, [], F) instanceof F); + }); + var ARGS_BUG = !fails(function () { + rConstruct(function () { /* empty */ }); + }); + + $export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', { + construct: function construct(Target, args /* , newTarget */) { + aFunction(Target); + anObject(args); + var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]); + if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget); + if (Target == newTarget) { + // w/o altered newTarget, optimization for 0-4 arguments + switch (args.length) { + case 0: return new Target(); + case 1: return new Target(args[0]); + case 2: return new Target(args[0], args[1]); + case 3: return new Target(args[0], args[1], args[2]); + case 4: return new Target(args[0], args[1], args[2], args[3]); + } + // w/o altered newTarget, lot of arguments case + var $args = [null]; + $args.push.apply($args, args); + return new (bind.apply(Target, $args))(); + } + // with altered newTarget, not support built-in constructors + var proto = newTarget.prototype; + var instance = create(isObject(proto) ? proto : Object.prototype); + var result = Function.apply.call(Target, instance, args); + return isObject(result) ? result : instance; + } + }); + + +/***/ }), +/* 241 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes) + var dP = __webpack_require__(11); + var $export = __webpack_require__(8); + var anObject = __webpack_require__(12); + var toPrimitive = __webpack_require__(16); + + // MS Edge has broken Reflect.defineProperty - throwing instead of returning false + $export($export.S + $export.F * __webpack_require__(7)(function () { + // eslint-disable-next-line no-undef + Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 }); + }), 'Reflect', { + defineProperty: function defineProperty(target, propertyKey, attributes) { + anObject(target); + propertyKey = toPrimitive(propertyKey, true); + anObject(attributes); + try { + dP.f(target, propertyKey, attributes); + return true; + } catch (e) { + return false; + } + } + }); + + +/***/ }), +/* 242 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.4 Reflect.deleteProperty(target, propertyKey) + var $export = __webpack_require__(8); + var gOPD = __webpack_require__(50).f; + var anObject = __webpack_require__(12); + + $export($export.S, 'Reflect', { + deleteProperty: function deleteProperty(target, propertyKey) { + var desc = gOPD(anObject(target), propertyKey); + return desc && !desc.configurable ? false : delete target[propertyKey]; + } + }); + + +/***/ }), +/* 243 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // 26.1.5 Reflect.enumerate(target) + var $export = __webpack_require__(8); + var anObject = __webpack_require__(12); + var Enumerate = function (iterated) { + this._t = anObject(iterated); // target + this._i = 0; // next index + var keys = this._k = []; // keys + var key; + for (key in iterated) keys.push(key); + }; + __webpack_require__(130)(Enumerate, 'Object', function () { + var that = this; + var keys = that._k; + var key; + do { + if (that._i >= keys.length) return { value: undefined, done: true }; + } while (!((key = keys[that._i++]) in that._t)); + return { value: key, done: false }; + }); + + $export($export.S, 'Reflect', { + enumerate: function enumerate(target) { + return new Enumerate(target); + } + }); + + +/***/ }), +/* 244 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.6 Reflect.get(target, propertyKey [, receiver]) + var gOPD = __webpack_require__(50); + var getPrototypeOf = __webpack_require__(58); + var has = __webpack_require__(5); + var $export = __webpack_require__(8); + var isObject = __webpack_require__(13); + var anObject = __webpack_require__(12); + + function get(target, propertyKey /* , receiver */) { + var receiver = arguments.length < 3 ? target : arguments[2]; + var desc, proto; + if (anObject(target) === receiver) return target[propertyKey]; + if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value') + ? desc.value + : desc.get !== undefined + ? desc.get.call(receiver) + : undefined; + if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver); + } + + $export($export.S, 'Reflect', { get: get }); + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey) + var gOPD = __webpack_require__(50); + var $export = __webpack_require__(8); + var anObject = __webpack_require__(12); + + $export($export.S, 'Reflect', { + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) { + return gOPD.f(anObject(target), propertyKey); + } + }); + + +/***/ }), +/* 246 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.8 Reflect.getPrototypeOf(target) + var $export = __webpack_require__(8); + var getProto = __webpack_require__(58); + var anObject = __webpack_require__(12); + + $export($export.S, 'Reflect', { + getPrototypeOf: function getPrototypeOf(target) { + return getProto(anObject(target)); + } + }); + + +/***/ }), +/* 247 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.9 Reflect.has(target, propertyKey) + var $export = __webpack_require__(8); + + $export($export.S, 'Reflect', { + has: function has(target, propertyKey) { + return propertyKey in target; + } + }); + + +/***/ }), +/* 248 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.10 Reflect.isExtensible(target) + var $export = __webpack_require__(8); + var anObject = __webpack_require__(12); + var $isExtensible = Object.isExtensible; + + $export($export.S, 'Reflect', { + isExtensible: function isExtensible(target) { + anObject(target); + return $isExtensible ? $isExtensible(target) : true; + } + }); + + +/***/ }), +/* 249 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.11 Reflect.ownKeys(target) + var $export = __webpack_require__(8); + + $export($export.S, 'Reflect', { ownKeys: __webpack_require__(250) }); + + +/***/ }), +/* 250 */ +/***/ (function(module, exports, __webpack_require__) { + + // all object keys, includes non-enumerable and symbols + var gOPN = __webpack_require__(49); + var gOPS = __webpack_require__(42); + var anObject = __webpack_require__(12); + var Reflect = __webpack_require__(4).Reflect; + module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) { + var keys = gOPN.f(anObject(it)); + var getSymbols = gOPS.f; + return getSymbols ? keys.concat(getSymbols(it)) : keys; + }; + + +/***/ }), +/* 251 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.12 Reflect.preventExtensions(target) + var $export = __webpack_require__(8); + var anObject = __webpack_require__(12); + var $preventExtensions = Object.preventExtensions; + + $export($export.S, 'Reflect', { + preventExtensions: function preventExtensions(target) { + anObject(target); + try { + if ($preventExtensions) $preventExtensions(target); + return true; + } catch (e) { + return false; + } + } + }); + + +/***/ }), +/* 252 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.13 Reflect.set(target, propertyKey, V [, receiver]) + var dP = __webpack_require__(11); + var gOPD = __webpack_require__(50); + var getPrototypeOf = __webpack_require__(58); + var has = __webpack_require__(5); + var $export = __webpack_require__(8); + var createDesc = __webpack_require__(17); + var anObject = __webpack_require__(12); + var isObject = __webpack_require__(13); + + function set(target, propertyKey, V /* , receiver */) { + var receiver = arguments.length < 4 ? target : arguments[3]; + var ownDesc = gOPD.f(anObject(target), propertyKey); + var existingDescriptor, proto; + if (!ownDesc) { + if (isObject(proto = getPrototypeOf(target))) { + return set(proto, propertyKey, V, receiver); + } + ownDesc = createDesc(0); + } + if (has(ownDesc, 'value')) { + if (ownDesc.writable === false || !isObject(receiver)) return false; + if (existingDescriptor = gOPD.f(receiver, propertyKey)) { + if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false; + existingDescriptor.value = V; + dP.f(receiver, propertyKey, existingDescriptor); + } else dP.f(receiver, propertyKey, createDesc(0, V)); + return true; + } + return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true); + } + + $export($export.S, 'Reflect', { set: set }); + + +/***/ }), +/* 253 */ +/***/ (function(module, exports, __webpack_require__) { + + // 26.1.14 Reflect.setPrototypeOf(target, proto) + var $export = __webpack_require__(8); + var setProto = __webpack_require__(72); + + if (setProto) $export($export.S, 'Reflect', { + setPrototypeOf: function setPrototypeOf(target, proto) { + setProto.check(target, proto); + try { + setProto.set(target, proto); + return true; + } catch (e) { + return false; + } + } + }); + + +/***/ }), +/* 254 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/tc39/Array.prototype.includes + var $export = __webpack_require__(8); + var $includes = __webpack_require__(36)(true); + + $export($export.P, 'Array', { + includes: function includes(el /* , fromIndex = 0 */) { + return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); + } + }); + + __webpack_require__(187)('includes'); + + +/***/ }), +/* 255 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap + var $export = __webpack_require__(8); + var flattenIntoArray = __webpack_require__(256); + var toObject = __webpack_require__(57); + var toLength = __webpack_require__(37); + var aFunction = __webpack_require__(21); + var arraySpeciesCreate = __webpack_require__(174); + + $export($export.P, 'Array', { + flatMap: function flatMap(callbackfn /* , thisArg */) { + var O = toObject(this); + var sourceLen, A; + aFunction(callbackfn); + sourceLen = toLength(O.length); + A = arraySpeciesCreate(O, 0); + flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]); + return A; + } + }); + + __webpack_require__(187)('flatMap'); + + +/***/ }), +/* 256 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray + var isArray = __webpack_require__(44); + var isObject = __webpack_require__(13); + var toLength = __webpack_require__(37); + var ctx = __webpack_require__(20); + var IS_CONCAT_SPREADABLE = __webpack_require__(26)('isConcatSpreadable'); + + function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) { + var targetIndex = start; + var sourceIndex = 0; + var mapFn = mapper ? ctx(mapper, thisArg, 3) : false; + var element, spreadable; + + while (sourceIndex < sourceLen) { + if (sourceIndex in source) { + element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex]; + + spreadable = false; + if (isObject(element)) { + spreadable = element[IS_CONCAT_SPREADABLE]; + spreadable = spreadable !== undefined ? !!spreadable : isArray(element); + } + + if (spreadable && depth > 0) { + targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1; + } else { + if (targetIndex >= 0x1fffffffffffff) throw TypeError(); + target[targetIndex] = element; + } + + targetIndex++; + } + sourceIndex++; + } + return targetIndex; + } + + module.exports = flattenIntoArray; + + +/***/ }), +/* 257 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatten + var $export = __webpack_require__(8); + var flattenIntoArray = __webpack_require__(256); + var toObject = __webpack_require__(57); + var toLength = __webpack_require__(37); + var toInteger = __webpack_require__(38); + var arraySpeciesCreate = __webpack_require__(174); + + $export($export.P, 'Array', { + flatten: function flatten(/* depthArg = 1 */) { + var depthArg = arguments[0]; + var O = toObject(this); + var sourceLen = toLength(O.length); + var A = arraySpeciesCreate(O, 0); + flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg)); + return A; + } + }); + + __webpack_require__(187)('flatten'); + + +/***/ }), +/* 258 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/mathiasbynens/String.prototype.at + var $export = __webpack_require__(8); + var $at = __webpack_require__(127)(true); + + $export($export.P, 'String', { + at: function at(pos) { + return $at(this, pos); + } + }); + + +/***/ }), +/* 259 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/tc39/proposal-string-pad-start-end + var $export = __webpack_require__(8); + var $pad = __webpack_require__(260); + var userAgent = __webpack_require__(213); + + // https://github.com/zloirock/core-js/issues/280 + $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', { + padStart: function padStart(maxLength /* , fillString = ' ' */) { + return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true); + } + }); + + +/***/ }), +/* 260 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-string-pad-start-end + var toLength = __webpack_require__(37); + var repeat = __webpack_require__(90); + var defined = __webpack_require__(35); + + module.exports = function (that, maxLength, fillString, left) { + var S = String(defined(that)); + var stringLength = S.length; + var fillStr = fillString === undefined ? ' ' : String(fillString); + var intMaxLength = toLength(maxLength); + if (intMaxLength <= stringLength || fillStr == '') return S; + var fillLen = intMaxLength - stringLength; + var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length)); + if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen); + return left ? stringFiller + S : S + stringFiller; + }; + + +/***/ }), +/* 261 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/tc39/proposal-string-pad-start-end + var $export = __webpack_require__(8); + var $pad = __webpack_require__(260); + var userAgent = __webpack_require__(213); + + // https://github.com/zloirock/core-js/issues/280 + $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', { + padEnd: function padEnd(maxLength /* , fillString = ' ' */) { + return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false); + } + }); + + +/***/ }), +/* 262 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/sebmarkbage/ecmascript-string-left-right-trim + __webpack_require__(82)('trimLeft', function ($trim) { + return function trimLeft() { + return $trim(this, 1); + }; + }, 'trimStart'); + + +/***/ }), +/* 263 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/sebmarkbage/ecmascript-string-left-right-trim + __webpack_require__(82)('trimRight', function ($trim) { + return function trimRight() { + return $trim(this, 2); + }; + }, 'trimEnd'); + + +/***/ }), +/* 264 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/String.prototype.matchAll/ + var $export = __webpack_require__(8); + var defined = __webpack_require__(35); + var toLength = __webpack_require__(37); + var isRegExp = __webpack_require__(134); + var getFlags = __webpack_require__(197); + var RegExpProto = RegExp.prototype; + + var $RegExpStringIterator = function (regexp, string) { + this._r = regexp; + this._s = string; + }; + + __webpack_require__(130)($RegExpStringIterator, 'RegExp String', function next() { + var match = this._r.exec(this._s); + return { value: match, done: match === null }; + }); + + $export($export.P, 'String', { + matchAll: function matchAll(regexp) { + defined(this); + if (!isRegExp(regexp)) throw TypeError(regexp + ' is not a regexp!'); + var S = String(this); + var flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp); + var rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags); + rx.lastIndex = toLength(regexp.lastIndex); + return new $RegExpStringIterator(rx, S); + } + }); + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(28)('asyncIterator'); + + +/***/ }), +/* 266 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(28)('observable'); + + +/***/ }), +/* 267 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-object-getownpropertydescriptors + var $export = __webpack_require__(8); + var ownKeys = __webpack_require__(250); + var toIObject = __webpack_require__(32); + var gOPD = __webpack_require__(50); + var createProperty = __webpack_require__(164); + + $export($export.S, 'Object', { + getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { + var O = toIObject(object); + var getDesc = gOPD.f; + var keys = ownKeys(O); + var result = {}; + var i = 0; + var key, desc; + while (keys.length > i) { + desc = getDesc(O, key = keys[i++]); + if (desc !== undefined) createProperty(result, key, desc); + } + return result; + } + }); + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-object-values-entries + var $export = __webpack_require__(8); + var $values = __webpack_require__(269)(false); + + $export($export.S, 'Object', { + values: function values(it) { + return $values(it); + } + }); + + +/***/ }), +/* 269 */ +/***/ (function(module, exports, __webpack_require__) { + + var getKeys = __webpack_require__(30); + var toIObject = __webpack_require__(32); + var isEnum = __webpack_require__(43).f; + module.exports = function (isEntries) { + return function (it) { + var O = toIObject(it); + var keys = getKeys(O); + var length = keys.length; + var i = 0; + var result = []; + var key; + while (length > i) if (isEnum.call(O, key = keys[i++])) { + result.push(isEntries ? [key, O[key]] : O[key]); + } return result; + }; + }; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-object-values-entries + var $export = __webpack_require__(8); + var $entries = __webpack_require__(269)(true); + + $export($export.S, 'Object', { + entries: function entries(it) { + return $entries(it); + } + }); + + +/***/ }), +/* 271 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var aFunction = __webpack_require__(21); + var $defineProperty = __webpack_require__(11); + + // B.2.2.2 Object.prototype.__defineGetter__(P, getter) + __webpack_require__(6) && $export($export.P + __webpack_require__(272), 'Object', { + __defineGetter__: function __defineGetter__(P, getter) { + $defineProperty.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true }); + } + }); + + +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // Forced replacement prototype accessors methods + module.exports = __webpack_require__(24) || !__webpack_require__(7)(function () { + var K = Math.random(); + // In FF throws only define methods + // eslint-disable-next-line no-undef, no-useless-call + __defineSetter__.call(null, K, function () { /* empty */ }); + delete __webpack_require__(4)[K]; + }); + + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var aFunction = __webpack_require__(21); + var $defineProperty = __webpack_require__(11); + + // B.2.2.3 Object.prototype.__defineSetter__(P, setter) + __webpack_require__(6) && $export($export.P + __webpack_require__(272), 'Object', { + __defineSetter__: function __defineSetter__(P, setter) { + $defineProperty.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true }); + } + }); + + +/***/ }), +/* 274 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var toPrimitive = __webpack_require__(16); + var getPrototypeOf = __webpack_require__(58); + var getOwnPropertyDescriptor = __webpack_require__(50).f; + + // B.2.2.4 Object.prototype.__lookupGetter__(P) + __webpack_require__(6) && $export($export.P + __webpack_require__(272), 'Object', { + __lookupGetter__: function __lookupGetter__(P) { + var O = toObject(this); + var K = toPrimitive(P, true); + var D; + do { + if (D = getOwnPropertyDescriptor(O, K)) return D.get; + } while (O = getPrototypeOf(O)); + } + }); + + +/***/ }), +/* 275 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + var $export = __webpack_require__(8); + var toObject = __webpack_require__(57); + var toPrimitive = __webpack_require__(16); + var getPrototypeOf = __webpack_require__(58); + var getOwnPropertyDescriptor = __webpack_require__(50).f; + + // B.2.2.5 Object.prototype.__lookupSetter__(P) + __webpack_require__(6) && $export($export.P + __webpack_require__(272), 'Object', { + __lookupSetter__: function __lookupSetter__(P) { + var O = toObject(this); + var K = toPrimitive(P, true); + var D; + do { + if (D = getOwnPropertyDescriptor(O, K)) return D.set; + } while (O = getPrototypeOf(O)); + } + }); + + +/***/ }), +/* 276 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/DavidBruant/Map-Set.prototype.toJSON + var $export = __webpack_require__(8); + + $export($export.P + $export.R, 'Map', { toJSON: __webpack_require__(277)('Map') }); + + +/***/ }), +/* 277 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/DavidBruant/Map-Set.prototype.toJSON + var classof = __webpack_require__(74); + var from = __webpack_require__(278); + module.exports = function (NAME) { + return function toJSON() { + if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic"); + return from(this); + }; + }; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports, __webpack_require__) { + + var forOf = __webpack_require__(207); + + module.exports = function (iter, ITERATOR) { + var result = []; + forOf(iter, false, result.push, result, ITERATOR); + return result; + }; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/DavidBruant/Map-Set.prototype.toJSON + var $export = __webpack_require__(8); + + $export($export.P + $export.R, 'Set', { toJSON: __webpack_require__(277)('Set') }); + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of + __webpack_require__(281)('Map'); + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/proposal-setmap-offrom/ + var $export = __webpack_require__(8); + + module.exports = function (COLLECTION) { + $export($export.S, COLLECTION, { of: function of() { + var length = arguments.length; + var A = new Array(length); + while (length--) A[length] = arguments[length]; + return new this(A); + } }); + }; + + +/***/ }), +/* 282 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of + __webpack_require__(281)('Set'); + + +/***/ }), +/* 283 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of + __webpack_require__(281)('WeakMap'); + + +/***/ }), +/* 284 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of + __webpack_require__(281)('WeakSet'); + + +/***/ }), +/* 285 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from + __webpack_require__(286)('Map'); + + +/***/ }), +/* 286 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://tc39.github.io/proposal-setmap-offrom/ + var $export = __webpack_require__(8); + var aFunction = __webpack_require__(21); + var ctx = __webpack_require__(20); + var forOf = __webpack_require__(207); + + module.exports = function (COLLECTION) { + $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) { + var mapFn = arguments[1]; + var mapping, A, n, cb; + aFunction(this); + mapping = mapFn !== undefined; + if (mapping) aFunction(mapFn); + if (source == undefined) return new this(); + A = []; + if (mapping) { + n = 0; + cb = ctx(mapFn, arguments[2], 2); + forOf(source, false, function (nextItem) { + A.push(cb(nextItem, n++)); + }); + } else { + forOf(source, false, A.push, A); + } + return new this(A); + } }); + }; + + +/***/ }), +/* 287 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from + __webpack_require__(286)('Set'); + + +/***/ }), +/* 288 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from + __webpack_require__(286)('WeakMap'); + + +/***/ }), +/* 289 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from + __webpack_require__(286)('WeakSet'); + + +/***/ }), +/* 290 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-global + var $export = __webpack_require__(8); + + $export($export.G, { global: __webpack_require__(4) }); + + +/***/ }), +/* 291 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-global + var $export = __webpack_require__(8); + + $export($export.S, 'System', { global: __webpack_require__(4) }); + + +/***/ }), +/* 292 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/ljharb/proposal-is-error + var $export = __webpack_require__(8); + var cof = __webpack_require__(34); + + $export($export.S, 'Error', { + isError: function isError(it) { + return cof(it) === 'Error'; + } + }); + + +/***/ }), +/* 293 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + clamp: function clamp(x, lower, upper) { + return Math.min(upper, Math.max(lower, x)); + } + }); + + +/***/ }), +/* 294 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { DEG_PER_RAD: Math.PI / 180 }); + + +/***/ }), +/* 295 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + var RAD_PER_DEG = 180 / Math.PI; + + $export($export.S, 'Math', { + degrees: function degrees(radians) { + return radians * RAD_PER_DEG; + } + }); + + +/***/ }), +/* 296 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + var scale = __webpack_require__(297); + var fround = __webpack_require__(113); + + $export($export.S, 'Math', { + fscale: function fscale(x, inLow, inHigh, outLow, outHigh) { + return fround(scale(x, inLow, inHigh, outLow, outHigh)); + } + }); + + +/***/ }), +/* 297 */ +/***/ (function(module, exports) { + + // https://rwaldron.github.io/proposal-math-extensions/ + module.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) { + if ( + arguments.length === 0 + // eslint-disable-next-line no-self-compare + || x != x + // eslint-disable-next-line no-self-compare + || inLow != inLow + // eslint-disable-next-line no-self-compare + || inHigh != inHigh + // eslint-disable-next-line no-self-compare + || outLow != outLow + // eslint-disable-next-line no-self-compare + || outHigh != outHigh + ) return NaN; + if (x === Infinity || x === -Infinity) return x; + return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow; + }; + + +/***/ }), +/* 298 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + iaddh: function iaddh(x0, x1, y0, y1) { + var $x0 = x0 >>> 0; + var $x1 = x1 >>> 0; + var $y0 = y0 >>> 0; + return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0; + } + }); + + +/***/ }), +/* 299 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + isubh: function isubh(x0, x1, y0, y1) { + var $x0 = x0 >>> 0; + var $x1 = x1 >>> 0; + var $y0 = y0 >>> 0; + return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0; + } + }); + + +/***/ }), +/* 300 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + imulh: function imulh(u, v) { + var UINT16 = 0xffff; + var $u = +u; + var $v = +v; + var u0 = $u & UINT16; + var v0 = $v & UINT16; + var u1 = $u >> 16; + var v1 = $v >> 16; + var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); + return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16); + } + }); + + +/***/ }), +/* 301 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { RAD_PER_DEG: 180 / Math.PI }); + + +/***/ }), +/* 302 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + var DEG_PER_RAD = Math.PI / 180; + + $export($export.S, 'Math', { + radians: function radians(degrees) { + return degrees * DEG_PER_RAD; + } + }); + + +/***/ }), +/* 303 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://rwaldron.github.io/proposal-math-extensions/ + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { scale: __webpack_require__(297) }); + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://gist.github.com/BrendanEich/4294d5c212a6d2254703 + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { + umulh: function umulh(u, v) { + var UINT16 = 0xffff; + var $u = +u; + var $v = +v; + var u0 = $u & UINT16; + var v0 = $v & UINT16; + var u1 = $u >>> 16; + var v1 = $v >>> 16; + var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16); + return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16); + } + }); + + +/***/ }), +/* 305 */ +/***/ (function(module, exports, __webpack_require__) { + + // http://jfbastien.github.io/papers/Math.signbit.html + var $export = __webpack_require__(8); + + $export($export.S, 'Math', { signbit: function signbit(x) { + // eslint-disable-next-line no-self-compare + return (x = +x) != x ? x : x == 0 ? 1 / x == Infinity : x > 0; + } }); + + +/***/ }), +/* 306 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/tc39/proposal-promise-finally + 'use strict'; + var $export = __webpack_require__(8); + var core = __webpack_require__(9); + var global = __webpack_require__(4); + var speciesConstructor = __webpack_require__(208); + var promiseResolve = __webpack_require__(214); + + $export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) { + var C = speciesConstructor(this, core.Promise || global.Promise); + var isFunction = typeof onFinally == 'function'; + return this.then( + isFunction ? function (x) { + return promiseResolve(C, onFinally()).then(function () { return x; }); + } : onFinally, + isFunction ? function (e) { + return promiseResolve(C, onFinally()).then(function () { throw e; }); + } : onFinally + ); + } }); + + +/***/ }), +/* 307 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/tc39/proposal-promise-try + var $export = __webpack_require__(8); + var newPromiseCapability = __webpack_require__(211); + var perform = __webpack_require__(212); + + $export($export.S, 'Promise', { 'try': function (callbackfn) { + var promiseCapability = newPromiseCapability.f(this); + var result = perform(callbackfn); + (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); + return promiseCapability.promise; + } }); + + +/***/ }), +/* 308 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var toMetaKey = metadata.key; + var ordinaryDefineOwnMetadata = metadata.set; + + metadata.exp({ defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey) { + ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey)); + } }); + + +/***/ }), +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + + var Map = __webpack_require__(216); + var $export = __webpack_require__(8); + var shared = __webpack_require__(23)('metadata'); + var store = shared.store || (shared.store = new (__webpack_require__(221))()); + + var getOrCreateMetadataMap = function (target, targetKey, create) { + var targetMetadata = store.get(target); + if (!targetMetadata) { + if (!create) return undefined; + store.set(target, targetMetadata = new Map()); + } + var keyMetadata = targetMetadata.get(targetKey); + if (!keyMetadata) { + if (!create) return undefined; + targetMetadata.set(targetKey, keyMetadata = new Map()); + } return keyMetadata; + }; + var ordinaryHasOwnMetadata = function (MetadataKey, O, P) { + var metadataMap = getOrCreateMetadataMap(O, P, false); + return metadataMap === undefined ? false : metadataMap.has(MetadataKey); + }; + var ordinaryGetOwnMetadata = function (MetadataKey, O, P) { + var metadataMap = getOrCreateMetadataMap(O, P, false); + return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey); + }; + var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) { + getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue); + }; + var ordinaryOwnMetadataKeys = function (target, targetKey) { + var metadataMap = getOrCreateMetadataMap(target, targetKey, false); + var keys = []; + if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); }); + return keys; + }; + var toMetaKey = function (it) { + return it === undefined || typeof it == 'symbol' ? it : String(it); + }; + var exp = function (O) { + $export($export.S, 'Reflect', O); + }; + + module.exports = { + store: store, + map: getOrCreateMetadataMap, + has: ordinaryHasOwnMetadata, + get: ordinaryGetOwnMetadata, + set: ordinaryDefineOwnMetadata, + keys: ordinaryOwnMetadataKeys, + key: toMetaKey, + exp: exp + }; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var toMetaKey = metadata.key; + var getOrCreateMetadataMap = metadata.map; + var store = metadata.store; + + metadata.exp({ deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) { + var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2]); + var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false); + if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false; + if (metadataMap.size) return true; + var targetMetadata = store.get(target); + targetMetadata['delete'](targetKey); + return !!targetMetadata.size || store['delete'](target); + } }); + + +/***/ }), +/* 311 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var getPrototypeOf = __webpack_require__(58); + var ordinaryHasOwnMetadata = metadata.has; + var ordinaryGetOwnMetadata = metadata.get; + var toMetaKey = metadata.key; + + var ordinaryGetMetadata = function (MetadataKey, O, P) { + var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P); + var parent = getPrototypeOf(O); + return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined; + }; + + metadata.exp({ getMetadata: function getMetadata(metadataKey, target /* , targetKey */) { + return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2])); + } }); + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + + var Set = __webpack_require__(220); + var from = __webpack_require__(278); + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var getPrototypeOf = __webpack_require__(58); + var ordinaryOwnMetadataKeys = metadata.keys; + var toMetaKey = metadata.key; + + var ordinaryMetadataKeys = function (O, P) { + var oKeys = ordinaryOwnMetadataKeys(O, P); + var parent = getPrototypeOf(O); + if (parent === null) return oKeys; + var pKeys = ordinaryMetadataKeys(parent, P); + return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys; + }; + + metadata.exp({ getMetadataKeys: function getMetadataKeys(target /* , targetKey */) { + return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1])); + } }); + + +/***/ }), +/* 313 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var ordinaryGetOwnMetadata = metadata.get; + var toMetaKey = metadata.key; + + metadata.exp({ getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) { + return ordinaryGetOwnMetadata(metadataKey, anObject(target) + , arguments.length < 3 ? undefined : toMetaKey(arguments[2])); + } }); + + +/***/ }), +/* 314 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var ordinaryOwnMetadataKeys = metadata.keys; + var toMetaKey = metadata.key; + + metadata.exp({ getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) { + return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1])); + } }); + + +/***/ }), +/* 315 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var getPrototypeOf = __webpack_require__(58); + var ordinaryHasOwnMetadata = metadata.has; + var toMetaKey = metadata.key; + + var ordinaryHasMetadata = function (MetadataKey, O, P) { + var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) return true; + var parent = getPrototypeOf(O); + return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false; + }; + + metadata.exp({ hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) { + return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2])); + } }); + + +/***/ }), +/* 316 */ +/***/ (function(module, exports, __webpack_require__) { + + var metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var ordinaryHasOwnMetadata = metadata.has; + var toMetaKey = metadata.key; + + metadata.exp({ hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) { + return ordinaryHasOwnMetadata(metadataKey, anObject(target) + , arguments.length < 3 ? undefined : toMetaKey(arguments[2])); + } }); + + +/***/ }), +/* 317 */ +/***/ (function(module, exports, __webpack_require__) { + + var $metadata = __webpack_require__(309); + var anObject = __webpack_require__(12); + var aFunction = __webpack_require__(21); + var toMetaKey = $metadata.key; + var ordinaryDefineOwnMetadata = $metadata.set; + + $metadata.exp({ metadata: function metadata(metadataKey, metadataValue) { + return function decorator(target, targetKey) { + ordinaryDefineOwnMetadata( + metadataKey, metadataValue, + (targetKey !== undefined ? anObject : aFunction)(target), + toMetaKey(targetKey) + ); + }; + } }); + + +/***/ }), +/* 318 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask + var $export = __webpack_require__(8); + var microtask = __webpack_require__(210)(); + var process = __webpack_require__(4).process; + var isNode = __webpack_require__(34)(process) == 'process'; + + $export($export.G, { + asap: function asap(fn) { + var domain = isNode && process.domain; + microtask(domain ? domain.bind(fn) : fn); + } + }); + + +/***/ }), +/* 319 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + // https://github.com/zenparsing/es-observable + var $export = __webpack_require__(8); + var global = __webpack_require__(4); + var core = __webpack_require__(9); + var microtask = __webpack_require__(210)(); + var OBSERVABLE = __webpack_require__(26)('observable'); + var aFunction = __webpack_require__(21); + var anObject = __webpack_require__(12); + var anInstance = __webpack_require__(206); + var redefineAll = __webpack_require__(215); + var hide = __webpack_require__(10); + var forOf = __webpack_require__(207); + var RETURN = forOf.RETURN; + + var getMethod = function (fn) { + return fn == null ? undefined : aFunction(fn); + }; + + var cleanupSubscription = function (subscription) { + var cleanup = subscription._c; + if (cleanup) { + subscription._c = undefined; + cleanup(); + } + }; + + var subscriptionClosed = function (subscription) { + return subscription._o === undefined; + }; + + var closeSubscription = function (subscription) { + if (!subscriptionClosed(subscription)) { + subscription._o = undefined; + cleanupSubscription(subscription); + } + }; + + var Subscription = function (observer, subscriber) { + anObject(observer); + this._c = undefined; + this._o = observer; + observer = new SubscriptionObserver(this); + try { + var cleanup = subscriber(observer); + var subscription = cleanup; + if (cleanup != null) { + if (typeof cleanup.unsubscribe === 'function') cleanup = function () { subscription.unsubscribe(); }; + else aFunction(cleanup); + this._c = cleanup; + } + } catch (e) { + observer.error(e); + return; + } if (subscriptionClosed(this)) cleanupSubscription(this); + }; + + Subscription.prototype = redefineAll({}, { + unsubscribe: function unsubscribe() { closeSubscription(this); } + }); + + var SubscriptionObserver = function (subscription) { + this._s = subscription; + }; + + SubscriptionObserver.prototype = redefineAll({}, { + next: function next(value) { + var subscription = this._s; + if (!subscriptionClosed(subscription)) { + var observer = subscription._o; + try { + var m = getMethod(observer.next); + if (m) return m.call(observer, value); + } catch (e) { + try { + closeSubscription(subscription); + } finally { + throw e; + } + } + } + }, + error: function error(value) { + var subscription = this._s; + if (subscriptionClosed(subscription)) throw value; + var observer = subscription._o; + subscription._o = undefined; + try { + var m = getMethod(observer.error); + if (!m) throw value; + value = m.call(observer, value); + } catch (e) { + try { + cleanupSubscription(subscription); + } finally { + throw e; + } + } cleanupSubscription(subscription); + return value; + }, + complete: function complete(value) { + var subscription = this._s; + if (!subscriptionClosed(subscription)) { + var observer = subscription._o; + subscription._o = undefined; + try { + var m = getMethod(observer.complete); + value = m ? m.call(observer, value) : undefined; + } catch (e) { + try { + cleanupSubscription(subscription); + } finally { + throw e; + } + } cleanupSubscription(subscription); + return value; + } + } + }); + + var $Observable = function Observable(subscriber) { + anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber); + }; + + redefineAll($Observable.prototype, { + subscribe: function subscribe(observer) { + return new Subscription(observer, this._f); + }, + forEach: function forEach(fn) { + var that = this; + return new (core.Promise || global.Promise)(function (resolve, reject) { + aFunction(fn); + var subscription = that.subscribe({ + next: function (value) { + try { + return fn(value); + } catch (e) { + reject(e); + subscription.unsubscribe(); + } + }, + error: reject, + complete: resolve + }); + }); + } + }); + + redefineAll($Observable, { + from: function from(x) { + var C = typeof this === 'function' ? this : $Observable; + var method = getMethod(anObject(x)[OBSERVABLE]); + if (method) { + var observable = anObject(method.call(x)); + return observable.constructor === C ? observable : new C(function (observer) { + return observable.subscribe(observer); + }); + } + return new C(function (observer) { + var done = false; + microtask(function () { + if (!done) { + try { + if (forOf(x, false, function (it) { + observer.next(it); + if (done) return RETURN; + }) === RETURN) return; + } catch (e) { + if (done) throw e; + observer.error(e); + return; + } observer.complete(); + } + }); + return function () { done = true; }; + }); + }, + of: function of() { + for (var i = 0, l = arguments.length, items = new Array(l); i < l;) items[i] = arguments[i++]; + return new (typeof this === 'function' ? this : $Observable)(function (observer) { + var done = false; + microtask(function () { + if (!done) { + for (var j = 0; j < items.length; ++j) { + observer.next(items[j]); + if (done) return; + } observer.complete(); + } + }); + return function () { done = true; }; + }); + } + }); + + hide($Observable.prototype, OBSERVABLE, function () { return this; }); + + $export($export.G, { Observable: $Observable }); + + __webpack_require__(193)('Observable'); + + +/***/ }), +/* 320 */ +/***/ (function(module, exports, __webpack_require__) { + + // ie9- setTimeout & setInterval additional parameters fix + var global = __webpack_require__(4); + var $export = __webpack_require__(8); + var userAgent = __webpack_require__(213); + var slice = [].slice; + var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check + var wrap = function (set) { + return function (fn, time /* , ...args */) { + var boundArgs = arguments.length > 2; + var args = boundArgs ? slice.call(arguments, 2) : false; + return set(boundArgs ? function () { + // eslint-disable-next-line no-new-func + (typeof fn == 'function' ? fn : Function(fn)).apply(this, args); + } : fn, time); + }; + }; + $export($export.G + $export.B + $export.F * MSIE, { + setTimeout: wrap(global.setTimeout), + setInterval: wrap(global.setInterval) + }); + + +/***/ }), +/* 321 */ +/***/ (function(module, exports, __webpack_require__) { + + var $export = __webpack_require__(8); + var $task = __webpack_require__(209); + $export($export.G + $export.B, { + setImmediate: $task.set, + clearImmediate: $task.clear + }); + + +/***/ }), +/* 322 */ +/***/ (function(module, exports, __webpack_require__) { + + var $iterators = __webpack_require__(194); + var getKeys = __webpack_require__(30); + var redefine = __webpack_require__(18); + var global = __webpack_require__(4); + var hide = __webpack_require__(10); + var Iterators = __webpack_require__(129); + var wks = __webpack_require__(26); + var ITERATOR = wks('iterator'); + var TO_STRING_TAG = wks('toStringTag'); + var ArrayValues = Iterators.Array; + + var DOMIterables = { + CSSRuleList: true, // TODO: Not spec compliant, should be false. + CSSStyleDeclaration: false, + CSSValueList: false, + ClientRectList: false, + DOMRectList: false, + DOMStringList: false, + DOMTokenList: true, + DataTransferItemList: false, + FileList: false, + HTMLAllCollection: false, + HTMLCollection: false, + HTMLFormElement: false, + HTMLSelectElement: false, + MediaList: true, // TODO: Not spec compliant, should be false. + MimeTypeArray: false, + NamedNodeMap: false, + NodeList: true, + PaintRequestList: false, + Plugin: false, + PluginArray: false, + SVGLengthList: false, + SVGNumberList: false, + SVGPathSegList: false, + SVGPointList: false, + SVGStringList: false, + SVGTransformList: false, + SourceBufferList: false, + StyleSheetList: true, // TODO: Not spec compliant, should be false. + TextTrackCueList: false, + TextTrackList: false, + TouchList: false + }; + + for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) { + var NAME = collections[i]; + var explicit = DOMIterables[NAME]; + var Collection = global[NAME]; + var proto = Collection && Collection.prototype; + var key; + if (proto) { + if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues); + if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = ArrayValues; + if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true); + } + } + + +/***/ }), +/* 323 */ +/***/ (function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {/** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + + !(function(global) { + "use strict"; + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + + var inModule = typeof module === "object"; + var runtime = global.regeneratorRuntime; + if (runtime) { + if (inModule) { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } + + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = inModule ? module.exports : {}; + + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); + + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); + + return generator; + } + runtime.wrap = wrap; + + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; + } + } + + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; + + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; + + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } + + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; + + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } + + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; + + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; + + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + runtime.awrap = function(arg) { + return { __await: arg }; + }; + + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); + } + + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. If the Promise is rejected, however, the + // result for this iteration will be rejected with the same + // reason. Note that rejections of yielded Promises are not + // thrown back into the generator function, as is the case + // when an awaited Promise is rejected. This difference in + // behavior between yield and await is important, because it + // allows the consumer to decide what to do with the yielded + // rejection (swallow it and continue, manually .throw it back + // into the generator, abandon iteration, whatever). With + // await, by contrast, there is no opportunity to examine the + // rejection reason outside the generator function, so the + // only option is to throw it from the await expression, and + // let the generator function handle the exception. + result.value = unwrapped; + resolve(result); + }, reject); + } + } + + if (typeof global.process === "object" && global.process.domain) { + invoke = global.process.domain.bind(invoke); + } + + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } + + return previousPromise = + // If enqueue has been called before, then we want to wait until + // all previous Promises have been resolved before calling invoke, + // so that results are always delivered in the correct order. If + // enqueue has not been called before, then it is important to + // call invoke immediately, without waiting on a callback to fire, + // so that the async generator function has the opportunity to do + // any necessary setup in a predictable way. This predictability + // is why the Promise constructor synchronously invokes its + // executor callback, and why async functions synchronously + // execute code before the first await. Since we implement simple + // async functions in terms of async generators, it is especially + // important to get this right, even though it requires care. + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); + } + + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } + + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + runtime.AsyncIterator = AsyncIterator; + + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); + + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; + + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } + + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } + + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } + + context.method = method; + context.arg = arg; + + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } + } + + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; + + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } + + context.dispatchException(context.arg); + + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } + + state = GenStateExecuting; + + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; + + if (record.arg === ContinueSentinel) { + continue; + } + + return { + value: record.arg, + done: context.done + }; + + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } + + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } + + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); + } + + return ContinueSentinel; + } + + var record = tryCatch(method, delegate.iterator, context.arg); + + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + + var info = record.arg; + + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } + + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + + } else { + // Re-yield the result returned by the delegate method. + return info; + } + + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } + + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); + + Gp[toStringTagSymbol] = "Generator"; + + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; + + Gp.toString = function() { + return "[object Generator]"; + }; + + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; + + if (1 in locs) { + entry.catchLoc = locs[1]; + } + + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } + + this.tryEntries.push(entry); + } + + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } + + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } + + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); + + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } + + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; + }; + }; + + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } + + if (typeof iterable.next === "function") { + return iterable; + } + + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } + + next.value = undefined; + next.done = true; + + return next; + }; + + return next.next = next; + } + } + + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; + + function doneResult() { + return { value: undefined, done: true }; + } + + Context.prototype = { + constructor: Context, + + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + + this.method = "next"; + this.arg = undefined; + + this.tryEntries.forEach(resetTryEntry); + + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; + } + } + } + }, + + stop: function() { + this.done = true; + + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } + + return this.rval; + }, + + dispatchException: function(exception) { + if (this.done) { + throw exception; + } + + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; + } + + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; + + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } + + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); + + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } + + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, + + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } + + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } + + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; + + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } + + return this.complete(record); + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + + return ContinueSentinel; + }, + + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; + } + } + }, + + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; + } + } + + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, + + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + + return ContinueSentinel; + } + }; + })( + // Among the various tricks for obtaining a reference to the global + // object, this seems to be the most reliable technique that does not + // use indirect eval (which violates Content Security Policy). + typeof global === "object" ? global : + typeof window === "object" ? window : + typeof self === "object" ? self : this + ); + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 324 */ +/***/ (function(module, exports, __webpack_require__) { + + __webpack_require__(325); + module.exports = __webpack_require__(9).RegExp.escape; + + +/***/ }), +/* 325 */ +/***/ (function(module, exports, __webpack_require__) { + + // https://github.com/benjamingr/RexExp.escape + var $export = __webpack_require__(8); + var $re = __webpack_require__(326)(/[\\^$*+?.()|[\]{}]/g, '\\$&'); + + $export($export.S, 'RegExp', { escape: function escape(it) { return $re(it); } }); + + +/***/ }), +/* 326 */ +/***/ (function(module, exports) { + + module.exports = function (regExp, replace) { + var replacer = replace === Object(replace) ? function (part) { + return replace[part]; + } : replace; + return function (it) { + return String(it).replace(regExp, replacer); + }; + }; + + +/***/ }), +/* 327 */ +/***/ (function(module, exports, __webpack_require__) { + + var BSON = __webpack_require__(328), + Binary = __webpack_require__(350), + Code = __webpack_require__(345), + DBRef = __webpack_require__(349), + Decimal128 = __webpack_require__(346), + Double = __webpack_require__(335), + Int32 = __webpack_require__(344), + Long = __webpack_require__(334), + Map = __webpack_require__(333), + MaxKey = __webpack_require__(348), + MinKey = __webpack_require__(347), + ObjectId = __webpack_require__(337), + BSONRegExp = __webpack_require__(342), + Symbol = __webpack_require__(343), + Timestamp = __webpack_require__(336); + + // BSON MAX VALUES + BSON.BSON_INT32_MAX = 0x7fffffff; + BSON.BSON_INT32_MIN = -0x80000000; + + BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; + BSON.BSON_INT64_MIN = -Math.pow(2, 63); + + // JS MAX PRECISE VALUES + BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. + BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + + // Add BSON types to function creation + BSON.Binary = Binary; + BSON.Code = Code; + BSON.DBRef = DBRef; + BSON.Decimal128 = Decimal128; + BSON.Double = Double; + BSON.Int32 = Int32; + BSON.Long = Long; + BSON.Map = Map; + BSON.MaxKey = MaxKey; + BSON.MinKey = MinKey; + BSON.ObjectId = ObjectId; + BSON.ObjectID = ObjectId; + BSON.BSONRegExp = BSONRegExp; + BSON.Symbol = Symbol; + BSON.Timestamp = Timestamp; + + // Return the BSON + module.exports = BSON; + +/***/ }), +/* 328 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var Map = __webpack_require__(333), + Long = __webpack_require__(334), + Double = __webpack_require__(335), + Timestamp = __webpack_require__(336), + ObjectID = __webpack_require__(337), + BSONRegExp = __webpack_require__(342), + Symbol = __webpack_require__(343), + Int32 = __webpack_require__(344), + Code = __webpack_require__(345), + Decimal128 = __webpack_require__(346), + MinKey = __webpack_require__(347), + MaxKey = __webpack_require__(348), + DBRef = __webpack_require__(349), + Binary = __webpack_require__(350); + + // Parts of the parser + var deserialize = __webpack_require__(351), + serializer = __webpack_require__(352), + calculateObjectSize = __webpack_require__(355); + + /** + * @ignore + * @api private + */ + // Default Max Size + var MAXSIZE = 1024 * 1024 * 17; + + // Current Internal Temporary Serialization Buffer + var buffer = new Buffer(MAXSIZE); + + var BSON = function () {}; + + /** + * Serialize a Javascript object. + * + * @param {Object} object the Javascript object to serialize. + * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @param {Number} [options.minInternalBufferSize=1024*1024*17] minimum size of the internal temporary serialization buffer **(default:1024*1024*17)**. + * @return {Buffer} returns the Buffer object containing the serialized object. + * @api public + */ + BSON.prototype.serialize = function serialize(object, options) { + options = options || {}; + // Unpack the options + var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + var minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE; + + // Resize the internal serialization buffer if needed + if (buffer.length < minInternalBufferSize) { + buffer = new Buffer(minInternalBufferSize); + } + + // Attempt to serialize + var serializationIndex = serializer(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []); + // Create the final buffer + var finishedBuffer = new Buffer(serializationIndex); + // Copy into the finished buffer + buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length); + // Return the buffer + return finishedBuffer; + }; + + /** + * Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization. + * + * @param {Object} object the Javascript object to serialize. + * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object. + * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @param {Number} [options.index] the index in the buffer where we wish to start serializing into. + * @return {Number} returns the index pointing to the last written byte in the buffer. + * @api public + */ + BSON.prototype.serializeWithBufferAndIndex = function (object, finalBuffer, options) { + options = options || {}; + // Unpack the options + var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + var startIndex = typeof options.index === 'number' ? options.index : 0; + + // Attempt to serialize + var serializationIndex = serializer(finalBuffer, object, checkKeys, startIndex || 0, 0, serializeFunctions, ignoreUndefined); + + // Return the index + return serializationIndex - 1; + }; + + /** + * Deserialize data as BSON. + * + * @param {Buffer} buffer the buffer containing the serialized set of BSON documents. + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Object} returns the deserialized Javascript Object. + * @api public + */ + BSON.prototype.deserialize = function (buffer, options) { + return deserialize(buffer, options); + }; + + /** + * Calculate the bson size for a passed in Javascript object. + * + * @param {Object} object the Javascript object to calculate the BSON byte size for. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @return {Number} returns the number of bytes the BSON object will take up. + * @api public + */ + BSON.prototype.calculateObjectSize = function (object, options) { + options = options || {}; + + var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + + return calculateObjectSize(object, serializeFunctions, ignoreUndefined); + }; + + /** + * Deserialize stream data as BSON documents. + * + * @param {Buffer} data the buffer containing the serialized set of BSON documents. + * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start. + * @param {Number} numberOfDocuments number of documents to deserialize. + * @param {Array} documents an array where to store the deserialized documents. + * @param {Number} docStartIndex the index in the documents array from where to start inserting documents. + * @param {Object} [options] additional options used for the deserialization. + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents. + * @api public + */ + BSON.prototype.deserializeStream = function (data, startIndex, numberOfDocuments, documents, docStartIndex, options) { + options = options != null ? options : {}; + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = data[index] | data[index + 1] << 8 | data[index + 2] << 16 | data[index + 3] << 24; + // Update options with index + options['index'] = index; + // Parse the document at this point + documents[docStartIndex + i] = this.deserialize(data, options); + // Adjust index by the document size + index = index + size; + } + + // Return object containing end index of parsing and list of documents + return index; + }; + + /** + * @ignore + * @api private + */ + // BSON MAX VALUES + BSON.BSON_INT32_MAX = 0x7fffffff; + BSON.BSON_INT32_MIN = -0x80000000; + + BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; + BSON.BSON_INT64_MIN = -Math.pow(2, 63); + + // JS MAX PRECISE VALUES + BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. + BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + + // Internal long versions + // var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. + // var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + + /** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ + BSON.BSON_DATA_NUMBER = 1; + /** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ + BSON.BSON_DATA_STRING = 2; + /** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ + BSON.BSON_DATA_OBJECT = 3; + /** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ + BSON.BSON_DATA_ARRAY = 4; + /** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ + BSON.BSON_DATA_BINARY = 5; + /** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ + BSON.BSON_DATA_OID = 7; + /** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ + BSON.BSON_DATA_BOOLEAN = 8; + /** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ + BSON.BSON_DATA_DATE = 9; + /** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ + BSON.BSON_DATA_NULL = 10; + /** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ + BSON.BSON_DATA_REGEXP = 11; + /** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ + BSON.BSON_DATA_CODE = 13; + /** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ + BSON.BSON_DATA_SYMBOL = 14; + /** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ + BSON.BSON_DATA_CODE_W_SCOPE = 15; + /** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ + BSON.BSON_DATA_INT = 16; + /** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ + BSON.BSON_DATA_TIMESTAMP = 17; + /** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ + BSON.BSON_DATA_LONG = 18; + /** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ + BSON.BSON_DATA_MIN_KEY = 0xff; + /** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ + BSON.BSON_DATA_MAX_KEY = 0x7f; + + /** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ + BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ + BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; + /** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ + BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + /** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ + BSON.BSON_BINARY_SUBTYPE_UUID = 3; + /** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ + BSON.BSON_BINARY_SUBTYPE_MD5 = 4; + /** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ + BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + + // Return BSON + module.exports = BSON; + module.exports.Code = Code; + module.exports.Map = Map; + module.exports.Symbol = Symbol; + module.exports.BSON = BSON; + module.exports.DBRef = DBRef; + module.exports.Binary = Binary; + module.exports.ObjectID = ObjectID; + module.exports.Long = Long; + module.exports.Timestamp = Timestamp; + module.exports.Double = Double; + module.exports.Int32 = Int32; + module.exports.MinKey = MinKey; + module.exports.MaxKey = MaxKey; + module.exports.BSONRegExp = BSONRegExp; + module.exports.Decimal128 = Decimal128; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }), +/* 329 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + /* eslint-disable no-proto */ + + 'use strict' + + var base64 = __webpack_require__(330) + var ieee754 = __webpack_require__(331) + var isArray = __webpack_require__(332) + + exports.Buffer = Buffer + exports.SlowBuffer = SlowBuffer + exports.INSPECT_MAX_BYTES = 50 + + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ + Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + + /* + * Export kMaxLength after typed array support is determined. + */ + exports.kMaxLength = kMaxLength() + + function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } + } + + function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff + } + + function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that + } + + /** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + + function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) + } + + Buffer.poolSize = 8192 // not used by this implementation + + // TODO: Legacy, not needed anymore. Remove in next major version. + Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr + } + + function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) + } + + /** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ + Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } + } + + function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } + } + + function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) + } + + /** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ + Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) + } + + function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that + } + + /** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ + Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) + } + /** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ + Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) + } + + function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that + } + + function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that + } + + function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that + } + + function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') + } + + function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 + } + + function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) + } + + Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) + } + + Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + } + + Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } + } + + Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer + } + + function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } + } + Buffer.byteLength = byteLength + + function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } + } + + // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect + // Buffer instances. + Buffer.prototype._isBuffer = true + + function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i + } + + Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this + } + + Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this + } + + Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this + } + + Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) + } + + Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 + } + + Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' + } + + Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 + } + + // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, + // OR the last index of `val` in `buffer` at offset <= `byteOffset`. + // + // Arguments: + // - buffer - a Buffer to search + // - val - a string, Buffer, or number + // - byteOffset - an index into `buffer`; will be clamped to an int32 + // - encoding - an optional encoding, relevant is val is a string + // - dir - true for indexOf, false for lastIndexOf + function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') + } + + function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 + } + + Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 + } + + Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) + } + + Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) + } + + function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i + } + + function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + } + + function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) + } + + function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) + } + + function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) + } + + function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + } + + Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } + } + + Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } + } + + function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } + } + + function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) + } + + // Based on http://stackoverflow.com/a/22747272/680742, the browser with + // the lowest limit is Chrome, with 0x10000 args. + // We go 1 magnitude less, for safety + var MAX_ARGUMENTS_LENGTH = 0x1000 + + function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res + } + + function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret + } + + function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret + } + + function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out + } + + function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res + } + + Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf + } + + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') + } + + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val + } + + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val + } + + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] + } + + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) + } + + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] + } + + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) + } + + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) + } + + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) + } + + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) + } + + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) + } + + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) + } + + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) + } + + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) + } + + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) + } + + function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + } + + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 + } + + function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } + } + + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 + } + + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 + } + + function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } + } + + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 + } + + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 + } + + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 + } + + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 + } + + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 + } + + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 + } + + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 + } + + function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') + } + + function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 + } + + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) + } + + function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) + } + + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len + } + + // Usage: + // buffer.fill(number[, offset[, end]]) + // buffer.fill(buffer[, offset[, end]]) + // buffer.fill(string[, offset[, end]][, encoding]) + Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this + } + + // HELPER FUNCTIONS + // ================ + + var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + + function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str + } + + function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') + } + + function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) + } + + function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes + } + + function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray + } + + function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray + } + + function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) + } + + function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i + } + + function isnan (val) { + return val !== val // eslint-disable-line no-self-compare + } + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 330 */ +/***/ (function(module, exports) { + + 'use strict' + + exports.byteLength = byteLength + exports.toByteArray = toByteArray + exports.fromByteArray = fromByteArray + + var lookup = [] + var revLookup = [] + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i + } + + // Support decoding URL-safe base64 strings, as Node.js does. + // See: https://en.wikipedia.org/wiki/Base64#URL_applications + revLookup['-'.charCodeAt(0)] = 62 + revLookup['_'.charCodeAt(0)] = 63 + + function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] + } + + // base64 is 4/3 + up to two characters of the original data + function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen + } + + function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen + } + + function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr + } + + function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] + } + + function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') + } + + function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') + } + + +/***/ }), +/* 331 */ +/***/ (function(module, exports) { + + exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) + } + + exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 + } + + +/***/ }), +/* 332 */ +/***/ (function(module, exports) { + + var toString = {}.toString; + + module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; + }; + + +/***/ }), +/* 333 */ +/***/ (function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + + // We have an ES6 Map available, return the native instance + + if (typeof global.Map !== 'undefined') { + module.exports = global.Map; + module.exports.Map = global.Map; + } else { + // We will return a polyfill + var Map = function (array) { + this._keys = []; + this._values = {}; + + for (var i = 0; i < array.length; i++) { + if (array[i] == null) continue; // skip null and undefined + var entry = array[i]; + var key = entry[0]; + var value = entry[1]; + // Add the key to the list of keys in order + this._keys.push(key); + // Add the key and value to the values dictionary with a point + // to the location in the ordered keys list + this._values[key] = { v: value, i: this._keys.length - 1 }; + } + }; + + Map.prototype.clear = function () { + this._keys = []; + this._values = {}; + }; + + Map.prototype.delete = function (key) { + var value = this._values[key]; + if (value == null) return false; + // Delete entry + delete this._values[key]; + // Remove the key from the ordered keys list + this._keys.splice(value.i, 1); + return true; + }; + + Map.prototype.entries = function () { + var self = this; + var index = 0; + + return { + next: function () { + var key = self._keys[index++]; + return { + value: key !== undefined ? [key, self._values[key].v] : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + Map.prototype.forEach = function (callback, self) { + self = self || this; + + for (var i = 0; i < this._keys.length; i++) { + var key = this._keys[i]; + // Call the forEach callback + callback.call(self, this._values[key].v, key, self); + } + }; + + Map.prototype.get = function (key) { + return this._values[key] ? this._values[key].v : undefined; + }; + + Map.prototype.has = function (key) { + return this._values[key] != null; + }; + + Map.prototype.keys = function () { + var self = this; + var index = 0; + + return { + next: function () { + var key = self._keys[index++]; + return { + value: key !== undefined ? key : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + Map.prototype.set = function (key, value) { + if (this._values[key]) { + this._values[key].v = value; + return this; + } + + // Add the key to the list of keys in order + this._keys.push(key); + // Add the key and value to the values dictionary with a point + // to the location in the ordered keys list + this._values[key] = { v: value, i: this._keys.length - 1 }; + return this; + }; + + Map.prototype.values = function () { + var self = this; + var index = 0; + + return { + next: function () { + var key = self._keys[index++]; + return { + value: key !== undefined ? self._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + // Last ismaster + Object.defineProperty(Map.prototype, 'size', { + enumerable: true, + get: function () { + return this._keys.length; + } + }); + + module.exports = Map; + module.exports.Map = Map; + } + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 334 */ +/***/ (function(module, exports) { + + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // Copyright 2009 Google Inc. All Rights Reserved + + /** + * Defines a Long class for representing a 64-bit two's-complement + * integer value, which faithfully simulates the behavior of a Java "Long". This + * implementation is derived from LongLib in GWT. + * + * Constructs a 64-bit two's-complement integer, given its low and high 32-bit + * values as *signed* integers. See the from* functions below for more + * convenient ways of constructing Longs. + * + * The internal representation of a Long is the two given signed, 32-bit values. + * We use 32-bit pieces because these are the size of integers on which + * Javascript performs bit-operations. For operations like addition and + * multiplication, we split each number into 16-bit pieces, which can easily be + * multiplied within Javascript's floating-point representation without overflow + * or change in sign. + * + * In the algorithms below, we frequently reduce the negative case to the + * positive case by negating the input(s) and then post-processing the result. + * Note that we must ALWAYS check specially whether those values are MIN_VALUE + * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as + * a positive number, it overflows back into a negative). Not handling this + * case would often result in infinite recursion. + * + * @class + * @param {number} low the low (signed) 32 bits of the Long. + * @param {number} high the high (signed) 32 bits of the Long. + * @return {Long} + */ + function Long(low, high) { + if (!(this instanceof Long)) return new Long(low, high); + + this._bsontype = 'Long'; + /** + * @type {number} + * @ignore + */ + this.low_ = low | 0; // force into 32 signed bits. + + /** + * @type {number} + * @ignore + */ + this.high_ = high | 0; // force into 32 signed bits. + } + + /** + * Return the int value. + * + * @method + * @return {number} the value, assuming it is a 32-bit integer. + */ + Long.prototype.toInt = function () { + return this.low_; + }; + + /** + * Return the Number value. + * + * @method + * @return {number} the closest floating-point representation to this value. + */ + Long.prototype.toNumber = function () { + return this.high_ * Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned(); + }; + + /** + * Return the JSON value. + * + * @method + * @return {string} the JSON representation. + */ + Long.prototype.toJSON = function () { + return this.toString(); + }; + + /** + * Return the String value. + * + * @method + * @param {number} [opt_radix] the radix in which the text should be written. + * @return {string} the textual representation of this value. + */ + Long.prototype.toString = function (opt_radix) { + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (this.isZero()) { + return '0'; + } + + if (this.isNegative()) { + if (this.equals(Long.MIN_VALUE)) { + // We need to change the Long value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixLong = Long.fromNumber(radix); + var div = this.div(radixLong); + var rem = div.multiply(radixLong).subtract(this); + return div.toString(radix) + rem.toInt().toString(radix); + } else { + return '-' + this.negate().toString(radix); + } + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Math.pow(radix, 6)); + + rem = this; + var result = ''; + + while (!rem.isZero()) { + var remDiv = rem.div(radixToPower); + var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); + var digits = intval.toString(radix); + + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } else { + while (digits.length < 6) { + digits = '0' + digits; + } + result = '' + digits + result; + } + } + }; + + /** + * Return the high 32-bits value. + * + * @method + * @return {number} the high 32-bits as a signed value. + */ + Long.prototype.getHighBits = function () { + return this.high_; + }; + + /** + * Return the low 32-bits value. + * + * @method + * @return {number} the low 32-bits as a signed value. + */ + Long.prototype.getLowBits = function () { + return this.low_; + }; + + /** + * Return the low unsigned 32-bits value. + * + * @method + * @return {number} the low 32-bits as an unsigned value. + */ + Long.prototype.getLowBitsUnsigned = function () { + return this.low_ >= 0 ? this.low_ : Long.TWO_PWR_32_DBL_ + this.low_; + }; + + /** + * Returns the number of bits needed to represent the absolute value of this Long. + * + * @method + * @return {number} Returns the number of bits needed to represent the absolute value of this Long. + */ + Long.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + if (this.equals(Long.MIN_VALUE)) { + return 64; + } else { + return this.negate().getNumBitsAbs(); + } + } else { + var val = this.high_ !== 0 ? this.high_ : this.low_; + for (var bit = 31; bit > 0; bit--) { + if ((val & 1 << bit) !== 0) { + break; + } + } + return this.high_ !== 0 ? bit + 33 : bit + 1; + } + }; + + /** + * Return whether this value is zero. + * + * @method + * @return {boolean} whether this value is zero. + */ + Long.prototype.isZero = function () { + return this.high_ === 0 && this.low_ === 0; + }; + + /** + * Return whether this value is negative. + * + * @method + * @return {boolean} whether this value is negative. + */ + Long.prototype.isNegative = function () { + return this.high_ < 0; + }; + + /** + * Return whether this value is odd. + * + * @method + * @return {boolean} whether this value is odd. + */ + Long.prototype.isOdd = function () { + return (this.low_ & 1) === 1; + }; + + /** + * Return whether this Long equals the other + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long equals the other + */ + Long.prototype.equals = function (other) { + return this.high_ === other.high_ && this.low_ === other.low_; + }; + + /** + * Return whether this Long does not equal the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long does not equal the other. + */ + Long.prototype.notEquals = function (other) { + return this.high_ !== other.high_ || this.low_ !== other.low_; + }; + + /** + * Return whether this Long is less than the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is less than the other. + */ + Long.prototype.lessThan = function (other) { + return this.compare(other) < 0; + }; + + /** + * Return whether this Long is less than or equal to the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is less than or equal to the other. + */ + Long.prototype.lessThanOrEqual = function (other) { + return this.compare(other) <= 0; + }; + + /** + * Return whether this Long is greater than the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is greater than the other. + */ + Long.prototype.greaterThan = function (other) { + return this.compare(other) > 0; + }; + + /** + * Return whether this Long is greater than or equal to the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is greater than or equal to the other. + */ + Long.prototype.greaterThanOrEqual = function (other) { + return this.compare(other) >= 0; + }; + + /** + * Compares this Long with the given one. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater. + */ + Long.prototype.compare = function (other) { + if (this.equals(other)) { + return 0; + } + + var thisNeg = this.isNegative(); + var otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) { + return -1; + } + if (!thisNeg && otherNeg) { + return 1; + } + + // at this point, the signs are the same, so subtraction will not overflow + if (this.subtract(other).isNegative()) { + return -1; + } else { + return 1; + } + }; + + /** + * The negation of this value. + * + * @method + * @return {Long} the negation of this value. + */ + Long.prototype.negate = function () { + if (this.equals(Long.MIN_VALUE)) { + return Long.MIN_VALUE; + } else { + return this.not().add(Long.ONE); + } + }; + + /** + * Returns the sum of this and the given Long. + * + * @method + * @param {Long} other Long to add to this one. + * @return {Long} the sum of this and the given Long. + */ + Long.prototype.add = function (other) { + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 + b48; + c48 &= 0xffff; + return Long.fromBits(c16 << 16 | c00, c48 << 16 | c32); + }; + + /** + * Returns the difference of this and the given Long. + * + * @method + * @param {Long} other Long to subtract from this. + * @return {Long} the difference of this and the given Long. + */ + Long.prototype.subtract = function (other) { + return this.add(other.negate()); + }; + + /** + * Returns the product of this and the given Long. + * + * @method + * @param {Long} other Long to multiply with this. + * @return {Long} the product of this and the other. + */ + Long.prototype.multiply = function (other) { + if (this.isZero()) { + return Long.ZERO; + } else if (other.isZero()) { + return Long.ZERO; + } + + if (this.equals(Long.MIN_VALUE)) { + return other.isOdd() ? Long.MIN_VALUE : Long.ZERO; + } else if (other.equals(Long.MIN_VALUE)) { + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().multiply(other.negate()); + } else { + return this.negate().multiply(other).negate(); + } + } else if (other.isNegative()) { + return this.multiply(other.negate()).negate(); + } + + // If both Longs are small, use float multiplication + if (this.lessThan(Long.TWO_PWR_24_) && other.lessThan(Long.TWO_PWR_24_)) { + return Long.fromNumber(this.toNumber() * other.toNumber()); + } + + // Divide each Long into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xffff; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xffff; + return Long.fromBits(c16 << 16 | c00, c48 << 16 | c32); + }; + + /** + * Returns this Long divided by the given one. + * + * @method + * @param {Long} other Long by which to divide. + * @return {Long} this Long divided by the given one. + */ + Long.prototype.div = function (other) { + if (other.isZero()) { + throw Error('division by zero'); + } else if (this.isZero()) { + return Long.ZERO; + } + + if (this.equals(Long.MIN_VALUE)) { + if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) { + return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + } else if (other.equals(Long.MIN_VALUE)) { + return Long.ONE; + } else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shiftRight(1); + var approx = halfThis.div(other).shiftLeft(1); + if (approx.equals(Long.ZERO)) { + return other.isNegative() ? Long.ONE : Long.NEG_ONE; + } else { + var rem = this.subtract(other.multiply(approx)); + var result = approx.add(rem.div(other)); + return result; + } + } + } else if (other.equals(Long.MIN_VALUE)) { + return Long.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().div(other.negate()); + } else { + return this.negate().div(other).negate(); + } + } else if (other.isNegative()) { + return this.div(other.negate()).negate(); + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + var res = Long.ZERO; + rem = this; + while (rem.greaterThanOrEqual(other)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2); + var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + var approxRes = Long.fromNumber(approx); + var approxRem = approxRes.multiply(other); + while (approxRem.isNegative() || approxRem.greaterThan(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx); + approxRem = approxRes.multiply(other); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) { + approxRes = Long.ONE; + } + + res = res.add(approxRes); + rem = rem.subtract(approxRem); + } + return res; + }; + + /** + * Returns this Long modulo the given one. + * + * @method + * @param {Long} other Long by which to mod. + * @return {Long} this Long modulo the given one. + */ + Long.prototype.modulo = function (other) { + return this.subtract(this.div(other).multiply(other)); + }; + + /** + * The bitwise-NOT of this value. + * + * @method + * @return {Long} the bitwise-NOT of this value. + */ + Long.prototype.not = function () { + return Long.fromBits(~this.low_, ~this.high_); + }; + + /** + * Returns the bitwise-AND of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to AND. + * @return {Long} the bitwise-AND of this and the other. + */ + Long.prototype.and = function (other) { + return Long.fromBits(this.low_ & other.low_, this.high_ & other.high_); + }; + + /** + * Returns the bitwise-OR of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to OR. + * @return {Long} the bitwise-OR of this and the other. + */ + Long.prototype.or = function (other) { + return Long.fromBits(this.low_ | other.low_, this.high_ | other.high_); + }; + + /** + * Returns the bitwise-XOR of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to XOR. + * @return {Long} the bitwise-XOR of this and the other. + */ + Long.prototype.xor = function (other) { + return Long.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_); + }; + + /** + * Returns this Long with bits shifted to the left by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the left by the given amount. + */ + Long.prototype.shiftLeft = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var low = this.low_; + if (numBits < 32) { + var high = this.high_; + return Long.fromBits(low << numBits, high << numBits | low >>> 32 - numBits); + } else { + return Long.fromBits(0, low << numBits - 32); + } + } + }; + + /** + * Returns this Long with bits shifted to the right by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the right by the given amount. + */ + Long.prototype.shiftRight = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Long.fromBits(low >>> numBits | high << 32 - numBits, high >> numBits); + } else { + return Long.fromBits(high >> numBits - 32, high >= 0 ? 0 : -1); + } + } + }; + + /** + * Returns this Long with bits shifted to the right by the given amount, with the new top bits matching the current sign bit. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the right by the given amount, with zeros placed into the new leading bits. + */ + Long.prototype.shiftRightUnsigned = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Long.fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits); + } else if (numBits === 32) { + return Long.fromBits(high, 0); + } else { + return Long.fromBits(high >>> numBits - 32, 0); + } + } + }; + + /** + * Returns a Long representing the given (32-bit) integer value. + * + * @method + * @param {number} value the 32-bit integer in question. + * @return {Long} the corresponding Long value. + */ + Long.fromInt = function (value) { + if (-128 <= value && value < 128) { + var cachedObj = Long.INT_CACHE_[value]; + if (cachedObj) { + return cachedObj; + } + } + + var obj = new Long(value | 0, value < 0 ? -1 : 0); + if (-128 <= value && value < 128) { + Long.INT_CACHE_[value] = obj; + } + return obj; + }; + + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * + * @method + * @param {number} value the number in question. + * @return {Long} the corresponding Long value. + */ + Long.fromNumber = function (value) { + if (isNaN(value) || !isFinite(value)) { + return Long.ZERO; + } else if (value <= -Long.TWO_PWR_63_DBL_) { + return Long.MIN_VALUE; + } else if (value + 1 >= Long.TWO_PWR_63_DBL_) { + return Long.MAX_VALUE; + } else if (value < 0) { + return Long.fromNumber(-value).negate(); + } else { + return new Long(value % Long.TWO_PWR_32_DBL_ | 0, value / Long.TWO_PWR_32_DBL_ | 0); + } + }; + + /** + * Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits. + * + * @method + * @param {number} lowBits the low 32-bits. + * @param {number} highBits the high 32-bits. + * @return {Long} the corresponding Long value. + */ + Long.fromBits = function (lowBits, highBits) { + return new Long(lowBits, highBits); + }; + + /** + * Returns a Long representation of the given string, written using the given radix. + * + * @method + * @param {string} str the textual representation of the Long. + * @param {number} opt_radix the radix in which the text is written. + * @return {Long} the corresponding Long value. + */ + Long.fromString = function (str, opt_radix) { + if (str.length === 0) { + throw Error('number format error: empty string'); + } + + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (str.charAt(0) === '-') { + return Long.fromString(str.substring(1), radix).negate(); + } else if (str.indexOf('-') >= 0) { + throw Error('number format error: interior "-" character: ' + str); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Math.pow(radix, 8)); + + var result = Long.ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i); + var value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.multiply(power).add(Long.fromNumber(value)); + } else { + result = result.multiply(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + return result; + }; + + // NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the + // from* methods on which they depend. + + /** + * A cache of the Long representations of small integer values. + * @type {Object} + * @ignore + */ + Long.INT_CACHE_ = {}; + + // NOTE: the compiler should inline these constant values below and then remove + // these variables, so there should be no runtime penalty for these. + + /** + * Number used repeated below in calculations. This must appear before the + * first call to any from* function below. + * @type {number} + * @ignore + */ + Long.TWO_PWR_16_DBL_ = 1 << 16; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_24_DBL_ = 1 << 24; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_32_DBL_ = Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_31_DBL_ = Long.TWO_PWR_32_DBL_ / 2; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_48_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_64_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_; + + /** + * @type {number} + * @ignore + */ + Long.TWO_PWR_63_DBL_ = Long.TWO_PWR_64_DBL_ / 2; + + /** @type {Long} */ + Long.ZERO = Long.fromInt(0); + + /** @type {Long} */ + Long.ONE = Long.fromInt(1); + + /** @type {Long} */ + Long.NEG_ONE = Long.fromInt(-1); + + /** @type {Long} */ + Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0); + + /** @type {Long} */ + Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0); + + /** + * @type {Long} + * @ignore + */ + Long.TWO_PWR_24_ = Long.fromInt(1 << 24); + + /** + * Expose. + */ + module.exports = Long; + module.exports.Long = Long; + +/***/ }), +/* 335 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON Double type. + * + * @class + * @param {number} value the number we want to represent as a double. + * @return {Double} + */ + function Double(value) { + if (!(this instanceof Double)) return new Double(value); + + this._bsontype = 'Double'; + this.value = value; + } + + /** + * Access the number value. + * + * @method + * @return {number} returns the wrapped double number. + */ + Double.prototype.valueOf = function () { + return this.value; + }; + + /** + * @ignore + */ + Double.prototype.toJSON = function () { + return this.value; + }; + + module.exports = Double; + module.exports.Double = Double; + +/***/ }), +/* 336 */ +/***/ (function(module, exports) { + + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // Copyright 2009 Google Inc. All Rights Reserved + + /** + * This type is for INTERNAL use in MongoDB only and should not be used in applications. + * The appropriate corresponding type is the JavaScript Date type. + * + * Defines a Timestamp class for representing a 64-bit two's-complement + * integer value, which faithfully simulates the behavior of a Java "Timestamp". This + * implementation is derived from TimestampLib in GWT. + * + * Constructs a 64-bit two's-complement integer, given its low and high 32-bit + * values as *signed* integers. See the from* functions below for more + * convenient ways of constructing Timestamps. + * + * The internal representation of a Timestamp is the two given signed, 32-bit values. + * We use 32-bit pieces because these are the size of integers on which + * Javascript performs bit-operations. For operations like addition and + * multiplication, we split each number into 16-bit pieces, which can easily be + * multiplied within Javascript's floating-point representation without overflow + * or change in sign. + * + * In the algorithms below, we frequently reduce the negative case to the + * positive case by negating the input(s) and then post-processing the result. + * Note that we must ALWAYS check specially whether those values are MIN_VALUE + * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as + * a positive number, it overflows back into a negative). Not handling this + * case would often result in infinite recursion. + * + * @class + * @param {number} low the low (signed) 32 bits of the Timestamp. + * @param {number} high the high (signed) 32 bits of the Timestamp. + */ + function Timestamp(low, high) { + if (!(this instanceof Timestamp)) return new Timestamp(low, high); + this._bsontype = 'Timestamp'; + /** + * @type {number} + * @ignore + */ + this.low_ = low | 0; // force into 32 signed bits. + + /** + * @type {number} + * @ignore + */ + this.high_ = high | 0; // force into 32 signed bits. + } + + /** + * Return the int value. + * + * @return {number} the value, assuming it is a 32-bit integer. + */ + Timestamp.prototype.toInt = function () { + return this.low_; + }; + + /** + * Return the Number value. + * + * @method + * @return {number} the closest floating-point representation to this value. + */ + Timestamp.prototype.toNumber = function () { + return this.high_ * Timestamp.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned(); + }; + + /** + * Return the JSON value. + * + * @method + * @return {string} the JSON representation. + */ + Timestamp.prototype.toJSON = function () { + return this.toString(); + }; + + /** + * Return the String value. + * + * @method + * @param {number} [opt_radix] the radix in which the text should be written. + * @return {string} the textual representation of this value. + */ + Timestamp.prototype.toString = function (opt_radix) { + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (this.isZero()) { + return '0'; + } + + if (this.isNegative()) { + if (this.equals(Timestamp.MIN_VALUE)) { + // We need to change the Timestamp value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixTimestamp = Timestamp.fromNumber(radix); + var div = this.div(radixTimestamp); + var rem = div.multiply(radixTimestamp).subtract(this); + return div.toString(radix) + rem.toInt().toString(radix); + } else { + return '-' + this.negate().toString(radix); + } + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Timestamp.fromNumber(Math.pow(radix, 6)); + + rem = this; + var result = ''; + + while (!rem.isZero()) { + var remDiv = rem.div(radixToPower); + var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); + var digits = intval.toString(radix); + + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } else { + while (digits.length < 6) { + digits = '0' + digits; + } + result = '' + digits + result; + } + } + }; + + /** + * Return the high 32-bits value. + * + * @method + * @return {number} the high 32-bits as a signed value. + */ + Timestamp.prototype.getHighBits = function () { + return this.high_; + }; + + /** + * Return the low 32-bits value. + * + * @method + * @return {number} the low 32-bits as a signed value. + */ + Timestamp.prototype.getLowBits = function () { + return this.low_; + }; + + /** + * Return the low unsigned 32-bits value. + * + * @method + * @return {number} the low 32-bits as an unsigned value. + */ + Timestamp.prototype.getLowBitsUnsigned = function () { + return this.low_ >= 0 ? this.low_ : Timestamp.TWO_PWR_32_DBL_ + this.low_; + }; + + /** + * Returns the number of bits needed to represent the absolute value of this Timestamp. + * + * @method + * @return {number} Returns the number of bits needed to represent the absolute value of this Timestamp. + */ + Timestamp.prototype.getNumBitsAbs = function () { + if (this.isNegative()) { + if (this.equals(Timestamp.MIN_VALUE)) { + return 64; + } else { + return this.negate().getNumBitsAbs(); + } + } else { + var val = this.high_ !== 0 ? this.high_ : this.low_; + for (var bit = 31; bit > 0; bit--) { + if ((val & 1 << bit) !== 0) { + break; + } + } + return this.high_ !== 0 ? bit + 33 : bit + 1; + } + }; + + /** + * Return whether this value is zero. + * + * @method + * @return {boolean} whether this value is zero. + */ + Timestamp.prototype.isZero = function () { + return this.high_ === 0 && this.low_ === 0; + }; + + /** + * Return whether this value is negative. + * + * @method + * @return {boolean} whether this value is negative. + */ + Timestamp.prototype.isNegative = function () { + return this.high_ < 0; + }; + + /** + * Return whether this value is odd. + * + * @method + * @return {boolean} whether this value is odd. + */ + Timestamp.prototype.isOdd = function () { + return (this.low_ & 1) === 1; + }; + + /** + * Return whether this Timestamp equals the other + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp equals the other + */ + Timestamp.prototype.equals = function (other) { + return this.high_ === other.high_ && this.low_ === other.low_; + }; + + /** + * Return whether this Timestamp does not equal the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp does not equal the other. + */ + Timestamp.prototype.notEquals = function (other) { + return this.high_ !== other.high_ || this.low_ !== other.low_; + }; + + /** + * Return whether this Timestamp is less than the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is less than the other. + */ + Timestamp.prototype.lessThan = function (other) { + return this.compare(other) < 0; + }; + + /** + * Return whether this Timestamp is less than or equal to the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is less than or equal to the other. + */ + Timestamp.prototype.lessThanOrEqual = function (other) { + return this.compare(other) <= 0; + }; + + /** + * Return whether this Timestamp is greater than the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is greater than the other. + */ + Timestamp.prototype.greaterThan = function (other) { + return this.compare(other) > 0; + }; + + /** + * Return whether this Timestamp is greater than or equal to the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is greater than or equal to the other. + */ + Timestamp.prototype.greaterThanOrEqual = function (other) { + return this.compare(other) >= 0; + }; + + /** + * Compares this Timestamp with the given one. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater. + */ + Timestamp.prototype.compare = function (other) { + if (this.equals(other)) { + return 0; + } + + var thisNeg = this.isNegative(); + var otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) { + return -1; + } + if (!thisNeg && otherNeg) { + return 1; + } + + // at this point, the signs are the same, so subtraction will not overflow + if (this.subtract(other).isNegative()) { + return -1; + } else { + return 1; + } + }; + + /** + * The negation of this value. + * + * @method + * @return {Timestamp} the negation of this value. + */ + Timestamp.prototype.negate = function () { + if (this.equals(Timestamp.MIN_VALUE)) { + return Timestamp.MIN_VALUE; + } else { + return this.not().add(Timestamp.ONE); + } + }; + + /** + * Returns the sum of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to add to this one. + * @return {Timestamp} the sum of this and the given Timestamp. + */ + Timestamp.prototype.add = function (other) { + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 + b48; + c48 &= 0xffff; + return Timestamp.fromBits(c16 << 16 | c00, c48 << 16 | c32); + }; + + /** + * Returns the difference of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to subtract from this. + * @return {Timestamp} the difference of this and the given Timestamp. + */ + Timestamp.prototype.subtract = function (other) { + return this.add(other.negate()); + }; + + /** + * Returns the product of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to multiply with this. + * @return {Timestamp} the product of this and the other. + */ + Timestamp.prototype.multiply = function (other) { + if (this.isZero()) { + return Timestamp.ZERO; + } else if (other.isZero()) { + return Timestamp.ZERO; + } + + if (this.equals(Timestamp.MIN_VALUE)) { + return other.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO; + } else if (other.equals(Timestamp.MIN_VALUE)) { + return this.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().multiply(other.negate()); + } else { + return this.negate().multiply(other).negate(); + } + } else if (other.isNegative()) { + return this.multiply(other.negate()).negate(); + } + + // If both Timestamps are small, use float multiplication + if (this.lessThan(Timestamp.TWO_PWR_24_) && other.lessThan(Timestamp.TWO_PWR_24_)) { + return Timestamp.fromNumber(this.toNumber() * other.toNumber()); + } + + // Divide each Timestamp into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xffff; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xffff; + return Timestamp.fromBits(c16 << 16 | c00, c48 << 16 | c32); + }; + + /** + * Returns this Timestamp divided by the given one. + * + * @method + * @param {Timestamp} other Timestamp by which to divide. + * @return {Timestamp} this Timestamp divided by the given one. + */ + Timestamp.prototype.div = function (other) { + if (other.isZero()) { + throw Error('division by zero'); + } else if (this.isZero()) { + return Timestamp.ZERO; + } + + if (this.equals(Timestamp.MIN_VALUE)) { + if (other.equals(Timestamp.ONE) || other.equals(Timestamp.NEG_ONE)) { + return Timestamp.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + } else if (other.equals(Timestamp.MIN_VALUE)) { + return Timestamp.ONE; + } else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shiftRight(1); + var approx = halfThis.div(other).shiftLeft(1); + if (approx.equals(Timestamp.ZERO)) { + return other.isNegative() ? Timestamp.ONE : Timestamp.NEG_ONE; + } else { + var rem = this.subtract(other.multiply(approx)); + var result = approx.add(rem.div(other)); + return result; + } + } + } else if (other.equals(Timestamp.MIN_VALUE)) { + return Timestamp.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().div(other.negate()); + } else { + return this.negate().div(other).negate(); + } + } else if (other.isNegative()) { + return this.div(other.negate()).negate(); + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + var res = Timestamp.ZERO; + rem = this; + while (rem.greaterThanOrEqual(other)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2); + var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + var approxRes = Timestamp.fromNumber(approx); + var approxRem = approxRes.multiply(other); + while (approxRem.isNegative() || approxRem.greaterThan(rem)) { + approx -= delta; + approxRes = Timestamp.fromNumber(approx); + approxRem = approxRes.multiply(other); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) { + approxRes = Timestamp.ONE; + } + + res = res.add(approxRes); + rem = rem.subtract(approxRem); + } + return res; + }; + + /** + * Returns this Timestamp modulo the given one. + * + * @method + * @param {Timestamp} other Timestamp by which to mod. + * @return {Timestamp} this Timestamp modulo the given one. + */ + Timestamp.prototype.modulo = function (other) { + return this.subtract(this.div(other).multiply(other)); + }; + + /** + * The bitwise-NOT of this value. + * + * @method + * @return {Timestamp} the bitwise-NOT of this value. + */ + Timestamp.prototype.not = function () { + return Timestamp.fromBits(~this.low_, ~this.high_); + }; + + /** + * Returns the bitwise-AND of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to AND. + * @return {Timestamp} the bitwise-AND of this and the other. + */ + Timestamp.prototype.and = function (other) { + return Timestamp.fromBits(this.low_ & other.low_, this.high_ & other.high_); + }; + + /** + * Returns the bitwise-OR of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to OR. + * @return {Timestamp} the bitwise-OR of this and the other. + */ + Timestamp.prototype.or = function (other) { + return Timestamp.fromBits(this.low_ | other.low_, this.high_ | other.high_); + }; + + /** + * Returns the bitwise-XOR of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to XOR. + * @return {Timestamp} the bitwise-XOR of this and the other. + */ + Timestamp.prototype.xor = function (other) { + return Timestamp.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_); + }; + + /** + * Returns this Timestamp with bits shifted to the left by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the left by the given amount. + */ + Timestamp.prototype.shiftLeft = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var low = this.low_; + if (numBits < 32) { + var high = this.high_; + return Timestamp.fromBits(low << numBits, high << numBits | low >>> 32 - numBits); + } else { + return Timestamp.fromBits(0, low << numBits - 32); + } + } + }; + + /** + * Returns this Timestamp with bits shifted to the right by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the right by the given amount. + */ + Timestamp.prototype.shiftRight = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Timestamp.fromBits(low >>> numBits | high << 32 - numBits, high >> numBits); + } else { + return Timestamp.fromBits(high >> numBits - 32, high >= 0 ? 0 : -1); + } + } + }; + + /** + * Returns this Timestamp with bits shifted to the right by the given amount, with the new top bits matching the current sign bit. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the right by the given amount, with zeros placed into the new leading bits. + */ + Timestamp.prototype.shiftRightUnsigned = function (numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Timestamp.fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits); + } else if (numBits === 32) { + return Timestamp.fromBits(high, 0); + } else { + return Timestamp.fromBits(high >>> numBits - 32, 0); + } + } + }; + + /** + * Returns a Timestamp representing the given (32-bit) integer value. + * + * @method + * @param {number} value the 32-bit integer in question. + * @return {Timestamp} the corresponding Timestamp value. + */ + Timestamp.fromInt = function (value) { + if (-128 <= value && value < 128) { + var cachedObj = Timestamp.INT_CACHE_[value]; + if (cachedObj) { + return cachedObj; + } + } + + var obj = new Timestamp(value | 0, value < 0 ? -1 : 0); + if (-128 <= value && value < 128) { + Timestamp.INT_CACHE_[value] = obj; + } + return obj; + }; + + /** + * Returns a Timestamp representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * + * @method + * @param {number} value the number in question. + * @return {Timestamp} the corresponding Timestamp value. + */ + Timestamp.fromNumber = function (value) { + if (isNaN(value) || !isFinite(value)) { + return Timestamp.ZERO; + } else if (value <= -Timestamp.TWO_PWR_63_DBL_) { + return Timestamp.MIN_VALUE; + } else if (value + 1 >= Timestamp.TWO_PWR_63_DBL_) { + return Timestamp.MAX_VALUE; + } else if (value < 0) { + return Timestamp.fromNumber(-value).negate(); + } else { + return new Timestamp(value % Timestamp.TWO_PWR_32_DBL_ | 0, value / Timestamp.TWO_PWR_32_DBL_ | 0); + } + }; + + /** + * Returns a Timestamp representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits. + * + * @method + * @param {number} lowBits the low 32-bits. + * @param {number} highBits the high 32-bits. + * @return {Timestamp} the corresponding Timestamp value. + */ + Timestamp.fromBits = function (lowBits, highBits) { + return new Timestamp(lowBits, highBits); + }; + + /** + * Returns a Timestamp representation of the given string, written using the given radix. + * + * @method + * @param {string} str the textual representation of the Timestamp. + * @param {number} opt_radix the radix in which the text is written. + * @return {Timestamp} the corresponding Timestamp value. + */ + Timestamp.fromString = function (str, opt_radix) { + if (str.length === 0) { + throw Error('number format error: empty string'); + } + + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (str.charAt(0) === '-') { + return Timestamp.fromString(str.substring(1), radix).negate(); + } else if (str.indexOf('-') >= 0) { + throw Error('number format error: interior "-" character: ' + str); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Timestamp.fromNumber(Math.pow(radix, 8)); + + var result = Timestamp.ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i); + var value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Timestamp.fromNumber(Math.pow(radix, size)); + result = result.multiply(power).add(Timestamp.fromNumber(value)); + } else { + result = result.multiply(radixToPower); + result = result.add(Timestamp.fromNumber(value)); + } + } + return result; + }; + + // NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the + // from* methods on which they depend. + + /** + * A cache of the Timestamp representations of small integer values. + * @type {Object} + * @ignore + */ + Timestamp.INT_CACHE_ = {}; + + // NOTE: the compiler should inline these constant values below and then remove + // these variables, so there should be no runtime penalty for these. + + /** + * Number used repeated below in calculations. This must appear before the + * first call to any from* function below. + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_16_DBL_ = 1 << 16; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_24_DBL_ = 1 << 24; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_32_DBL_ = Timestamp.TWO_PWR_16_DBL_ * Timestamp.TWO_PWR_16_DBL_; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_31_DBL_ = Timestamp.TWO_PWR_32_DBL_ / 2; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_48_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_16_DBL_; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_64_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_32_DBL_; + + /** + * @type {number} + * @ignore + */ + Timestamp.TWO_PWR_63_DBL_ = Timestamp.TWO_PWR_64_DBL_ / 2; + + /** @type {Timestamp} */ + Timestamp.ZERO = Timestamp.fromInt(0); + + /** @type {Timestamp} */ + Timestamp.ONE = Timestamp.fromInt(1); + + /** @type {Timestamp} */ + Timestamp.NEG_ONE = Timestamp.fromInt(-1); + + /** @type {Timestamp} */ + Timestamp.MAX_VALUE = Timestamp.fromBits(0xffffffff | 0, 0x7fffffff | 0); + + /** @type {Timestamp} */ + Timestamp.MIN_VALUE = Timestamp.fromBits(0, 0x80000000 | 0); + + /** + * @type {Timestamp} + * @ignore + */ + Timestamp.TWO_PWR_24_ = Timestamp.fromInt(1 << 24); + + /** + * Expose. + */ + module.exports = Timestamp; + module.exports.Timestamp = Timestamp; + +/***/ }), +/* 337 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer, process) {// Custom inspect property name / symbol. + var inspect = 'inspect'; + + /** + * Machine id. + * + * Create a random 3-byte value (i.e. unique for this + * process). Other drivers use a md5 of the machine id here, but + * that would mean an asyc call to gethostname, so we don't bother. + * @ignore + */ + var MACHINE_ID = parseInt(Math.random() * 0xffffff, 10); + + // Regular expression that checks for hex value + var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); + + // Check if buffer exists + try { + if (Buffer && Buffer.from) { + var hasBufferType = true; + inspect = __webpack_require__(339).inspect.custom || 'inspect'; + } + } catch (err) { + hasBufferType = false; + } + + /** + * Create a new ObjectID instance + * + * @class + * @param {(string|number)} id Can be a 24 byte hex string, 12 byte binary string or a Number. + * @property {number} generationTime The generation time of this ObjectId instance + * @return {ObjectID} instance of ObjectID. + */ + var ObjectID = function ObjectID(id) { + // Duck-typing to support ObjectId from different npm packages + if (id instanceof ObjectID) return id; + if (!(this instanceof ObjectID)) return new ObjectID(id); + + this._bsontype = 'ObjectID'; + + // The most common usecase (blank id, new objectId instance) + if (id == null || typeof id === 'number') { + // Generate a new id + this.id = this.generate(id); + // If we are caching the hex string + if (ObjectID.cacheHexString) this.__id = this.toString('hex'); + // Return the object + return; + } + + // Check if the passed in id is valid + var valid = ObjectID.isValid(id); + + // Throw an error if it's not a valid setup + if (!valid && id != null) { + throw new Error('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } else if (valid && typeof id === 'string' && id.length === 24 && hasBufferType) { + return new ObjectID(new Buffer(id, 'hex')); + } else if (valid && typeof id === 'string' && id.length === 24) { + return ObjectID.createFromHexString(id); + } else if (id != null && id.length === 12) { + // assume 12 byte string + this.id = id; + } else if (id != null && id.toHexString) { + // Duck-typing to support ObjectId from different npm packages + return id; + } else { + throw new Error('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + + if (ObjectID.cacheHexString) this.__id = this.toString('hex'); + }; + + // Allow usage of ObjectId as well as ObjectID + // var ObjectId = ObjectID; + + // Precomputed hex table enables speedy hex string conversion + var hexTable = []; + for (var i = 0; i < 256; i++) { + hexTable[i] = (i <= 15 ? '0' : '') + i.toString(16); + } + + /** + * Return the ObjectID id as a 24 byte hex string representation + * + * @method + * @return {string} return the 24 byte hex string representation. + */ + ObjectID.prototype.toHexString = function () { + if (ObjectID.cacheHexString && this.__id) return this.__id; + + var hexString = ''; + if (!this.id || !this.id.length) { + throw new Error('invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [' + JSON.stringify(this.id) + ']'); + } + + if (this.id instanceof _Buffer) { + hexString = convertToHex(this.id); + if (ObjectID.cacheHexString) this.__id = hexString; + return hexString; + } + + for (var i = 0; i < this.id.length; i++) { + hexString += hexTable[this.id.charCodeAt(i)]; + } + + if (ObjectID.cacheHexString) this.__id = hexString; + return hexString; + }; + + /** + * Update the ObjectID index used in generating new ObjectID's on the driver + * + * @method + * @return {number} returns next index value. + * @ignore + */ + ObjectID.prototype.get_inc = function () { + return ObjectID.index = (ObjectID.index + 1) % 0xffffff; + }; + + /** + * Update the ObjectID index used in generating new ObjectID's on the driver + * + * @method + * @return {number} returns next index value. + * @ignore + */ + ObjectID.prototype.getInc = function () { + return this.get_inc(); + }; + + /** + * Generate a 12 byte id buffer used in ObjectID's + * + * @method + * @param {number} [time] optional parameter allowing to pass in a second based timestamp. + * @return {Buffer} return the 12 byte id buffer string. + */ + ObjectID.prototype.generate = function (time) { + if ('number' !== typeof time) { + time = ~~(Date.now() / 1000); + } + + // Use pid + var pid = (typeof process === 'undefined' || process.pid === 1 ? Math.floor(Math.random() * 100000) : process.pid) % 0xffff; + var inc = this.get_inc(); + // Buffer used + var buffer = new Buffer(12); + // Encode time + buffer[3] = time & 0xff; + buffer[2] = time >> 8 & 0xff; + buffer[1] = time >> 16 & 0xff; + buffer[0] = time >> 24 & 0xff; + // Encode machine + buffer[6] = MACHINE_ID & 0xff; + buffer[5] = MACHINE_ID >> 8 & 0xff; + buffer[4] = MACHINE_ID >> 16 & 0xff; + // Encode pid + buffer[8] = pid & 0xff; + buffer[7] = pid >> 8 & 0xff; + // Encode index + buffer[11] = inc & 0xff; + buffer[10] = inc >> 8 & 0xff; + buffer[9] = inc >> 16 & 0xff; + // Return the buffer + return buffer; + }; + + /** + * Converts the id into a 24 byte hex string for printing + * + * @param {String} format The Buffer toString format parameter. + * @return {String} return the 24 byte hex string representation. + * @ignore + */ + ObjectID.prototype.toString = function (format) { + // Is the id a buffer then use the buffer toString method to return the format + if (this.id && this.id.copy) { + return this.id.toString(typeof format === 'string' ? format : 'hex'); + } + + // if(this.buffer ) + return this.toHexString(); + }; + + /** + * Converts to a string representation of this Id. + * + * @return {String} return the 24 byte hex string representation. + * @ignore + */ + ObjectID.prototype[inspect] = ObjectID.prototype.toString; + + /** + * Converts to its JSON representation. + * + * @return {String} return the 24 byte hex string representation. + * @ignore + */ + ObjectID.prototype.toJSON = function () { + return this.toHexString(); + }; + + /** + * Compares the equality of this ObjectID with `otherID`. + * + * @method + * @param {object} otherID ObjectID instance to compare against. + * @return {boolean} the result of comparing two ObjectID's + */ + ObjectID.prototype.equals = function equals(otherId) { + // var id; + + if (otherId instanceof ObjectID) { + return this.toString() === otherId.toString(); + } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 12 && this.id instanceof _Buffer) { + return otherId === this.id.toString('binary'); + } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 12) { + return otherId === this.id; + } else if (otherId != null && (otherId instanceof ObjectID || otherId.toHexString)) { + return otherId.toHexString() === this.toHexString(); + } else { + return false; + } + }; + + /** + * Returns the generation date (accurate up to the second) that this ID was generated. + * + * @method + * @return {date} the generation date + */ + ObjectID.prototype.getTimestamp = function () { + var timestamp = new Date(); + var time = this.id[3] | this.id[2] << 8 | this.id[1] << 16 | this.id[0] << 24; + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; + }; + + /** + * @ignore + */ + ObjectID.index = ~~(Math.random() * 0xffffff); + + /** + * @ignore + */ + ObjectID.createPk = function createPk() { + return new ObjectID(); + }; + + /** + * Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID. + * + * @method + * @param {number} time an integer number representing a number of seconds. + * @return {ObjectID} return the created ObjectID + */ + ObjectID.createFromTime = function createFromTime(time) { + var buffer = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer[3] = time & 0xff; + buffer[2] = time >> 8 & 0xff; + buffer[1] = time >> 16 & 0xff; + buffer[0] = time >> 24 & 0xff; + // Return the new objectId + return new ObjectID(buffer); + }; + + // Lookup tables + //var encodeLookup = '0123456789abcdef'.split(''); + var decodeLookup = []; + i = 0; + while (i < 10) decodeLookup[0x30 + i] = i++; + while (i < 16) decodeLookup[0x41 - 10 + i] = decodeLookup[0x61 - 10 + i] = i++; + + var _Buffer = Buffer; + var convertToHex = function (bytes) { + return bytes.toString('hex'); + }; + + /** + * Creates an ObjectID from a hex string representation of an ObjectID. + * + * @method + * @param {string} hexString create a ObjectID from a passed in 24 byte hexstring. + * @return {ObjectID} return the created ObjectID + */ + ObjectID.createFromHexString = function createFromHexString(string) { + // Throw an error if it's not a valid setup + if (typeof string === 'undefined' || string != null && string.length !== 24) { + throw new Error('Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'); + } + + // Use Buffer.from method if available + if (hasBufferType) return new ObjectID(new Buffer(string, 'hex')); + + // Calculate lengths + var array = new _Buffer(12); + var n = 0; + var i = 0; + + while (i < 24) { + array[n++] = decodeLookup[string.charCodeAt(i++)] << 4 | decodeLookup[string.charCodeAt(i++)]; + } + + return new ObjectID(array); + }; + + /** + * Checks if a value is a valid bson ObjectId + * + * @method + * @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise. + */ + ObjectID.isValid = function isValid(id) { + if (id == null) return false; + + if (typeof id === 'number') { + return true; + } + + if (typeof id === 'string') { + return id.length === 12 || id.length === 24 && checkForHexRegExp.test(id); + } + + if (id instanceof ObjectID) { + return true; + } + + if (id instanceof _Buffer) { + return true; + } + + // Duck-Typing detection of ObjectId like objects + if (id.toHexString) { + return id.id.length === 12 || id.id.length === 24 && checkForHexRegExp.test(id.id); + } + + return false; + }; + + /** + * @ignore + */ + Object.defineProperty(ObjectID.prototype, 'generationTime', { + enumerable: true, + get: function () { + return this.id[3] | this.id[2] << 8 | this.id[1] << 16 | this.id[0] << 24; + }, + set: function (value) { + // Encode time into first 4 bytes + this.id[3] = value & 0xff; + this.id[2] = value >> 8 & 0xff; + this.id[1] = value >> 16 & 0xff; + this.id[0] = value >> 24 & 0xff; + } + }); + + /** + * Expose. + */ + module.exports = ObjectID; + module.exports.ObjectID = ObjectID; + module.exports.ObjectId = ObjectID; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer, __webpack_require__(338))) + +/***/ }), +/* 338 */ +/***/ (function(module, exports) { + + // shim for using process in browser + var process = module.exports = {}; + + // cached from whatever global is present so that test runners that stub it + // don't break things. But we need to wrap it in a try catch in case it is + // wrapped in strict mode code which doesn't define any globals. It's inside a + // function because try/catches deoptimize in certain engines. + + var cachedSetTimeout; + var cachedClearTimeout; + + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); + } + (function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } + } ()) + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + + // v8 likes predictible objects + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; // empty string to avoid regexp issues + process.versions = {}; + + function noop() {} + + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + process.prependListener = noop; + process.prependOnceListener = noop; + + process.listeners = function (name) { return [] } + + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + + process.cwd = function () { return '/' }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function() { return 0; }; + + +/***/ }), +/* 339 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var formatRegExp = /%[sdj%]/g; + exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; + }; + + + // Mark that a method should not be used. + // Returns a modified function which warns once by default. + // If --no-deprecation is set, then it is a no-op. + exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; + }; + + + var debugs = {}; + var debugEnviron; + exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; + }; + + + /** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ + /* legacy: obj, showHidden, depth, colors*/ + function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); + } + exports.inspect = inspect; + + + // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics + inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] + }; + + // Don't use 'blue' not visible on cmd.exe + inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' + }; + + + function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } + } + + + function stylizeNoColor(str, styleType) { + return str; + } + + + function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; + } + + + function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); + } + + + function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); + } + + + function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; + } + + + function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; + } + + + function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; + } + + + function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; + } + + + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { + return Array.isArray(ar); + } + exports.isArray = isArray; + + function isBoolean(arg) { + return typeof arg === 'boolean'; + } + exports.isBoolean = isBoolean; + + function isNull(arg) { + return arg === null; + } + exports.isNull = isNull; + + function isNullOrUndefined(arg) { + return arg == null; + } + exports.isNullOrUndefined = isNullOrUndefined; + + function isNumber(arg) { + return typeof arg === 'number'; + } + exports.isNumber = isNumber; + + function isString(arg) { + return typeof arg === 'string'; + } + exports.isString = isString; + + function isSymbol(arg) { + return typeof arg === 'symbol'; + } + exports.isSymbol = isSymbol; + + function isUndefined(arg) { + return arg === void 0; + } + exports.isUndefined = isUndefined; + + function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; + } + exports.isRegExp = isRegExp; + + function isObject(arg) { + return typeof arg === 'object' && arg !== null; + } + exports.isObject = isObject; + + function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; + } + exports.isDate = isDate; + + function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); + } + exports.isError = isError; + + function isFunction(arg) { + return typeof arg === 'function'; + } + exports.isFunction = isFunction; + + function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; + } + exports.isPrimitive = isPrimitive; + + exports.isBuffer = __webpack_require__(340); + + function objectToString(o) { + return Object.prototype.toString.call(o); + } + + + function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); + } + + + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + + // 26 Feb 16:19:34 + function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); + } + + + // log is just a thin wrapper to console.log that prepends a timestamp + exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); + }; + + + /** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ + exports.inherits = __webpack_require__(341); + + exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; + }; + + function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(338))) + +/***/ }), +/* 340 */ +/***/ (function(module, exports) { + + module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; + } + +/***/ }), +/* 341 */ +/***/ (function(module, exports) { + + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; + } else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON RegExp type. + * + * @class + * @return {BSONRegExp} A MinKey instance + */ + function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) return new BSONRegExp(); + + // Execute + this._bsontype = 'BSONRegExp'; + this.pattern = pattern || ''; + this.options = options || ''; + + // Validate options + for (var i = 0; i < this.options.length; i++) { + if (!(this.options[i] === 'i' || this.options[i] === 'm' || this.options[i] === 'x' || this.options[i] === 'l' || this.options[i] === 's' || this.options[i] === 'u')) { + throw new Error('the regular expression options [' + this.options[i] + '] is not supported'); + } + } + } + + module.exports = BSONRegExp; + module.exports.BSONRegExp = BSONRegExp; + +/***/ }), +/* 343 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {// Custom inspect property name / symbol. + var inspect = Buffer ? __webpack_require__(339).inspect.custom || 'inspect' : 'inspect'; + + /** + * A class representation of the BSON Symbol type. + * + * @class + * @deprecated + * @param {string} value the string representing the symbol. + * @return {Symbol} + */ + function Symbol(value) { + if (!(this instanceof Symbol)) return new Symbol(value); + this._bsontype = 'Symbol'; + this.value = value; + } + + /** + * Access the wrapped string value. + * + * @method + * @return {String} returns the wrapped string. + */ + Symbol.prototype.valueOf = function () { + return this.value; + }; + + /** + * @ignore + */ + Symbol.prototype.toString = function () { + return this.value; + }; + + /** + * @ignore + */ + Symbol.prototype[inspect] = function () { + return this.value; + }; + + /** + * @ignore + */ + Symbol.prototype.toJSON = function () { + return this.value; + }; + + module.exports = Symbol; + module.exports.Symbol = Symbol; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }), +/* 344 */ +/***/ (function(module, exports) { + + /** + * A class representation of a BSON Int32 type. + * + * @class + * @param {number} value the number we want to represent as an int32. + * @return {Int32} + */ + var Int32 = function (value) { + if (!(this instanceof Int32)) return new Int32(value); + + this._bsontype = 'Int32'; + this.value = value; + }; + + /** + * Access the number value. + * + * @method + * @return {number} returns the wrapped int32 number. + */ + Int32.prototype.valueOf = function () { + return this.value; + }; + + /** + * @ignore + */ + Int32.prototype.toJSON = function () { + return this.value; + }; + + module.exports = Int32; + module.exports.Int32 = Int32; + +/***/ }), +/* 345 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON Code type. + * + * @class + * @param {(string|function)} code a string or function. + * @param {Object} [scope] an optional scope for the function. + * @return {Code} + */ + var Code = function Code(code, scope) { + if (!(this instanceof Code)) return new Code(code, scope); + this._bsontype = 'Code'; + this.code = code; + this.scope = scope; + }; + + /** + * @ignore + */ + Code.prototype.toJSON = function () { + return { scope: this.scope, code: this.code }; + }; + + module.exports = Code; + module.exports.Code = Code; + +/***/ }), +/* 346 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var Long = __webpack_require__(334); + + var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/; + var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i; + var PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i; + + var EXPONENT_MAX = 6111; + var EXPONENT_MIN = -6176; + var EXPONENT_BIAS = 6176; + var MAX_DIGITS = 34; + + // Nan value bits as 32 bit values (due to lack of longs) + var NAN_BUFFER = [0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].reverse(); + // Infinity value bits 32 bit values (due to lack of longs) + var INF_NEGATIVE_BUFFER = [0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].reverse(); + var INF_POSITIVE_BUFFER = [0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00].reverse(); + + var EXPONENT_REGEX = /^([-+])?(\d+)?$/; + + // Detect if the value is a digit + var isDigit = function (value) { + return !isNaN(parseInt(value, 10)); + }; + + // Divide two uint128 values + var divideu128 = function (value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + var i = 0; + + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + + for (i = 0; i <= 3; i++) { + // Adjust remainder to match value of next dividend + _rem = _rem.shiftLeft(32); + // Add the divided to _rem + _rem = _rem.add(new Long(value.parts[i], 0)); + value.parts[i] = _rem.div(DIVISOR).low_; + _rem = _rem.modulo(DIVISOR); + } + + return { quotient: value, rem: _rem }; + }; + + // Multiply two Long values and return the 128 bit value + var multiply64x2 = function (left, right) { + if (!left && !right) { + return { high: Long.fromNumber(0), low: Long.fromNumber(0) }; + } + + var leftHigh = left.shiftRightUnsigned(32); + var leftLow = new Long(left.getLowBits(), 0); + var rightHigh = right.shiftRightUnsigned(32); + var rightLow = new Long(right.getLowBits(), 0); + + var productHigh = leftHigh.multiply(rightHigh); + var productMid = leftHigh.multiply(rightLow); + var productMid2 = leftLow.multiply(rightHigh); + var productLow = leftLow.multiply(rightLow); + + productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); + productMid = new Long(productMid.getLowBits(), 0).add(productMid2).add(productLow.shiftRightUnsigned(32)); + + productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); + productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0)); + + // Return the 128 bit result + return { high: productHigh, low: productLow }; + }; + + var lessThan = function (left, right) { + // Make values unsigned + var uhleft = left.high_ >>> 0; + var uhright = right.high_ >>> 0; + + // Compare high bits first + if (uhleft < uhright) { + return true; + } else if (uhleft === uhright) { + var ulleft = left.low_ >>> 0; + var ulright = right.low_ >>> 0; + if (ulleft < ulright) return true; + } + + return false; + }; + + // var longtoHex = function(value) { + // var buffer = new Buffer(8); + // var index = 0; + // // Encode the low 64 bits of the decimal + // // Encode low bits + // buffer[index++] = value.low_ & 0xff; + // buffer[index++] = (value.low_ >> 8) & 0xff; + // buffer[index++] = (value.low_ >> 16) & 0xff; + // buffer[index++] = (value.low_ >> 24) & 0xff; + // // Encode high bits + // buffer[index++] = value.high_ & 0xff; + // buffer[index++] = (value.high_ >> 8) & 0xff; + // buffer[index++] = (value.high_ >> 16) & 0xff; + // buffer[index++] = (value.high_ >> 24) & 0xff; + // return buffer.reverse().toString('hex'); + // }; + + // var int32toHex = function(value) { + // var buffer = new Buffer(4); + // var index = 0; + // // Encode the low 64 bits of the decimal + // // Encode low bits + // buffer[index++] = value & 0xff; + // buffer[index++] = (value >> 8) & 0xff; + // buffer[index++] = (value >> 16) & 0xff; + // buffer[index++] = (value >> 24) & 0xff; + // return buffer.reverse().toString('hex'); + // }; + + /** + * A class representation of the BSON Decimal128 type. + * + * @class + * @param {Buffer} bytes a buffer containing the raw Decimal128 bytes. + * @return {Double} + */ + var Decimal128 = function (bytes) { + this._bsontype = 'Decimal128'; + this.bytes = bytes; + }; + + /** + * Create a Decimal128 instance from a string representation + * + * @method + * @param {string} string a numeric string representation. + * @return {Decimal128} returns a Decimal128 instance. + */ + Decimal128.fromString = function (string) { + // Parse state tracking + var isNegative = false; + var sawRadix = false; + var foundNonZero = false; + + // Total number of significant digits (no leading or trailing zero) + var significantDigits = 0; + // Total number of significand digits read + var nDigitsRead = 0; + // Total number of digits (no leading zeros) + var nDigits = 0; + // The number of the digits after radix + var radixPosition = 0; + // The index of the first non-zero in *str* + var firstNonZero = 0; + + // Digits Array + var digits = [0]; + // The number of digits in digits + var nDigitsStored = 0; + // Insertion pointer for digits + var digitsInsert = 0; + // The index of the first non-zero digit + var firstDigit = 0; + // The index of the last digit + var lastDigit = 0; + + // Exponent + var exponent = 0; + // loop index over array + var i = 0; + // The high 17 digits of the significand + var significandHigh = [0, 0]; + // The low 17 digits of the significand + var significandLow = [0, 0]; + // The biased exponent + var biasedExponent = 0; + + // Read index + var index = 0; + + // Trim the string + string = string.trim(); + + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (string.length >= 7000) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Results + var stringMatch = string.match(PARSE_STRING_REGEXP); + var infMatch = string.match(PARSE_INF_REGEXP); + var nanMatch = string.match(PARSE_NAN_REGEXP); + + // Validate the string + if (!stringMatch && !infMatch && !nanMatch || string.length === 0) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Check if we have an illegal exponent format + if (stringMatch && stringMatch[4] && stringMatch[2] === undefined) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Get the negative or positive sign + if (string[index] === '+' || string[index] === '-') { + isNegative = string[index++] === '-'; + } + + // Check if user passed Infinity or NaN + if (!isDigit(string[index]) && string[index] !== '.') { + if (string[index] === 'i' || string[index] === 'I') { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } else if (string[index] === 'N') { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + } + + // Read all the digits + while (isDigit(string[index]) || string[index] === '.') { + if (string[index] === '.') { + if (sawRadix) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + sawRadix = true; + index = index + 1; + continue; + } + + if (nDigitsStored < 34) { + if (string[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + + foundNonZero = true; + + // Only store 34 digits + digits[digitsInsert++] = parseInt(string[index], 10); + nDigitsStored = nDigitsStored + 1; + } + } + + if (foundNonZero) { + nDigits = nDigits + 1; + } + + if (sawRadix) { + radixPosition = radixPosition + 1; + } + + nDigitsRead = nDigitsRead + 1; + index = index + 1; + } + + if (sawRadix && !nDigitsRead) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Read exponent if exists + if (string[index] === 'e' || string[index] === 'E') { + // Read exponent digits + var match = string.substr(++index).match(EXPONENT_REGEX); + + // No digits read + if (!match || !match[2]) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + // Get exponent + exponent = parseInt(match[0], 10); + + // Adjust the index + index = index + match[0].length; + } + + // Return not a number + if (string[index]) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + // Done reading input + // Find first non-zero digit in digits + firstDigit = 0; + + if (!nDigitsStored) { + firstDigit = 0; + lastDigit = 0; + digits[0] = 0; + nDigits = 1; + nDigitsStored = 1; + significantDigits = 0; + } else { + lastDigit = nDigitsStored - 1; + significantDigits = nDigits; + + if (exponent !== 0 && significantDigits !== 1) { + while (string[firstNonZero + significantDigits - 1] === '0') { + significantDigits = significantDigits - 1; + } + } + } + + // Normalization of exponent + // Correct exponent based on radix position, and shift significand as needed + // to represent user input + + // Overflow prevention + if (exponent <= radixPosition && radixPosition - exponent > 1 << 14) { + exponent = EXPONENT_MIN; + } else { + exponent = exponent - radixPosition; + } + + // Attempt to normalize the exponent + while (exponent > EXPONENT_MAX) { + // Shift exponent to significand and decrease + lastDigit = lastDigit + 1; + + if (lastDigit - firstDigit > MAX_DIGITS) { + // Check if we have a zero then just hard clamp, otherwise fail + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } else { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + + exponent = exponent - 1; + } + + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit + if (lastDigit === 0) { + exponent = EXPONENT_MIN; + significantDigits = 0; + break; + } + + if (nDigitsStored < nDigits) { + // adjust to match digits not stored + nDigits = nDigits - 1; + } else { + // adjust to round + lastDigit = lastDigit - 1; + } + + if (exponent < EXPONENT_MAX) { + exponent = exponent + 1; + } else { + // Check if we have a zero then just hard clamp, otherwise fail + digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } else { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits && string[significantDigits] !== '0') { + var endOfString = nDigitsRead; + + // If we have seen a radix point, 'string' is 1 longer than we have + // documented with ndigits_read, so inc the position of the first nonzero + // digit and the position that digits are read to. + if (sawRadix && exponent === EXPONENT_MIN) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + + var roundDigit = parseInt(string[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + + if (roundDigit >= 5) { + roundBit = 1; + + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1; + + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(string[i], 10)) { + roundBit = 1; + break; + } + } + } + } + + if (roundBit) { + var dIdx = lastDigit; + + for (; dIdx >= 0; dIdx--) { + if (++digits[dIdx] > 9) { + digits[dIdx] = 0; + + // overflowed most significant digit + if (dIdx === 0) { + if (exponent < EXPONENT_MAX) { + exponent = exponent + 1; + digits[dIdx] = 1; + } else { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } else { + break; + } + } + } + } + + // Encode significand + // The high 17 digits of the significand + significandHigh = Long.fromNumber(0); + // The low 17 digits of the significand + significandLow = Long.fromNumber(0); + + // read a zero + if (significantDigits === 0) { + significandHigh = Long.fromNumber(0); + significandLow = Long.fromNumber(0); + } else if (lastDigit - firstDigit < 17) { + dIdx = firstDigit; + significandLow = Long.fromNumber(digits[dIdx++]); + significandHigh = new Long(0, 0); + + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(Long.fromNumber(10)); + significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); + } + } else { + dIdx = firstDigit; + significandHigh = Long.fromNumber(digits[dIdx++]); + + for (; dIdx <= lastDigit - 17; dIdx++) { + significandHigh = significandHigh.multiply(Long.fromNumber(10)); + significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx])); + } + + significandLow = Long.fromNumber(digits[dIdx++]); + + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(Long.fromNumber(10)); + significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); + } + } + + var significand = multiply64x2(significandHigh, Long.fromString('100000000000000000')); + + significand.low = significand.low.add(significandLow); + + if (lessThan(significand.low, significandLow)) { + significand.high = significand.high.add(Long.fromNumber(1)); + } + + // Biased exponent + biasedExponent = exponent + EXPONENT_BIAS; + var dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) }; + + // Encode combination, exponent, and significand. + if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber)) { + // Encode '11' into bits 1 to 3 + dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61)); + dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47))); + dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff))); + } else { + dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49)); + dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff))); + } + + dec.low = significand.low; + + // Encode sign + if (isNegative) { + dec.high = dec.high.or(Long.fromString('9223372036854775808')); + } + + // Encode into a buffer + var buffer = new Buffer(16); + index = 0; + + // Encode the low 64 bits of the decimal + // Encode low bits + buffer[index++] = dec.low.low_ & 0xff; + buffer[index++] = dec.low.low_ >> 8 & 0xff; + buffer[index++] = dec.low.low_ >> 16 & 0xff; + buffer[index++] = dec.low.low_ >> 24 & 0xff; + // Encode high bits + buffer[index++] = dec.low.high_ & 0xff; + buffer[index++] = dec.low.high_ >> 8 & 0xff; + buffer[index++] = dec.low.high_ >> 16 & 0xff; + buffer[index++] = dec.low.high_ >> 24 & 0xff; + + // Encode the high 64 bits of the decimal + // Encode low bits + buffer[index++] = dec.high.low_ & 0xff; + buffer[index++] = dec.high.low_ >> 8 & 0xff; + buffer[index++] = dec.high.low_ >> 16 & 0xff; + buffer[index++] = dec.high.low_ >> 24 & 0xff; + // Encode high bits + buffer[index++] = dec.high.high_ & 0xff; + buffer[index++] = dec.high.high_ >> 8 & 0xff; + buffer[index++] = dec.high.high_ >> 16 & 0xff; + buffer[index++] = dec.high.high_ >> 24 & 0xff; + + // Return the new Decimal128 + return new Decimal128(buffer); + }; + + // Extract least significant 5 bits + var COMBINATION_MASK = 0x1f; + // Extract least significant 14 bits + var EXPONENT_MASK = 0x3fff; + // Value of combination field for Inf + var COMBINATION_INFINITY = 30; + // Value of combination field for NaN + var COMBINATION_NAN = 31; + // Value of combination field for NaN + // var COMBINATION_SNAN = 32; + // decimal128 exponent bias + EXPONENT_BIAS = 6176; + + /** + * Create a string representation of the raw Decimal128 value + * + * @method + * @return {string} returns a Decimal128 string representation. + */ + Decimal128.prototype.toString = function () { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + + // bits 0 - 31 + var high; + // bits 32 - 63 + var midh; + // bits 64 - 95 + var midl; + // bits 96 - 127 + var low; + // bits 1 - 5 + var combination; + // decoded biased exponent (14 bits) + var biased_exponent; + // the number of significand digits + var significand_digits = 0; + // the base-10 digits in the significand + var significand = new Array(36); + for (var i = 0; i < significand.length; i++) significand[i] = 0; + // read pointer into significand + var index = 0; + + // unbiased exponent + var exponent; + // the exponent if scientific notation is used + var scientific_exponent; + + // true if the number is zero + var is_zero = false; + + // the most signifcant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: new Array(4) }; + // indexing variables + i; + var j, k; + + // Output string + var string = []; + + // Unpack index + index = 0; + + // Buffer reference + var buffer = this.bytes; + + // Unpack the low 64bits into a long + low = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + midl = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + + // Unpack the high 64bits into a long + midh = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + high = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + + // Unpack index + index = 0; + + // Create the state of the decimal + var dec = { + low: new Long(low, midl), + high: new Long(midh, high) + }; + + if (dec.high.lessThan(Long.ZERO)) { + string.push('-'); + } + + // Decode combination field and exponent + combination = high >> 26 & COMBINATION_MASK; + + if (combination >> 3 === 3) { + // Check for 'special' values + if (combination === COMBINATION_INFINITY) { + return string.join('') + 'Infinity'; + } else if (combination === COMBINATION_NAN) { + return 'NaN'; + } else { + biased_exponent = high >> 15 & EXPONENT_MASK; + significand_msb = 0x08 + (high >> 14 & 0x01); + } + } else { + significand_msb = high >> 14 & 0x07; + biased_exponent = high >> 17 & EXPONENT_MASK; + } + + exponent = biased_exponent - EXPONENT_BIAS; + + // Create string of significand digits + + // Convert the 114-bit binary number represented by + // (significand_high, significand_low) to at most 34 decimal + // digits through modulo and division. + significand128.parts[0] = (high & 0x3fff) + ((significand_msb & 0xf) << 14); + significand128.parts[1] = midh; + significand128.parts[2] = midl; + significand128.parts[3] = low; + + if (significand128.parts[0] === 0 && significand128.parts[1] === 0 && significand128.parts[2] === 0 && significand128.parts[3] === 0) { + is_zero = true; + } else { + for (k = 3; k >= 0; k--) { + var least_digits = 0; + // Peform the divide + var result = divideu128(significand128); + significand128 = result.quotient; + least_digits = result.rem.low_; + + // We now have the 9 least significant digits (in base 2). + // Convert and output to string. + if (!least_digits) continue; + + for (j = 8; j >= 0; j--) { + // significand[k * 9 + j] = Math.round(least_digits % 10); + significand[k * 9 + j] = least_digits % 10; + // least_digits = Math.round(least_digits / 10); + least_digits = Math.floor(least_digits / 10); + } + } + } + + // Output format options: + // Scientific - [-]d.dddE(+/-)dd or [-]dE(+/-)dd + // Regular - ddd.ddd + + if (is_zero) { + significand_digits = 1; + significand[index] = 0; + } else { + significand_digits = 36; + i = 0; + + while (!significand[index]) { + i++; + significand_digits = significand_digits - 1; + index = index + 1; + } + } + + scientific_exponent = significand_digits - 1 + exponent; + + // The scientific exponent checks are dictated by the string conversion + // specification and are somewhat arbitrary cutoffs. + // + // We must check exponent > 0, because if this is the case, the number + // has trailing zeros. However, we *cannot* output these trailing zeros, + // because doing so would change the precision of the value, and would + // change stored data if the string converted number is round tripped. + + if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) { + // Scientific format + string.push(significand[index++]); + significand_digits = significand_digits - 1; + + if (significand_digits) { + string.push('.'); + } + + for (i = 0; i < significand_digits; i++) { + string.push(significand[index++]); + } + + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push('+' + scientific_exponent); + } else { + string.push(scientific_exponent); + } + } else { + // Regular format with no decimal place + if (exponent >= 0) { + for (i = 0; i < significand_digits; i++) { + string.push(significand[index++]); + } + } else { + var radix_position = significand_digits + exponent; + + // non-zero digits before radix + if (radix_position > 0) { + for (i = 0; i < radix_position; i++) { + string.push(significand[index++]); + } + } else { + string.push('0'); + } + + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + + for (i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push(significand[index++]); + } + } + } + + return string.join(''); + }; + + Decimal128.prototype.toJSON = function () { + return { $numberDecimal: this.toString() }; + }; + + module.exports = Decimal128; + module.exports.Decimal128 = Decimal128; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }), +/* 347 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON MinKey type. + * + * @class + * @return {MinKey} A MinKey instance + */ + function MinKey() { + if (!(this instanceof MinKey)) return new MinKey(); + + this._bsontype = 'MinKey'; + } + + module.exports = MinKey; + module.exports.MinKey = MinKey; + +/***/ }), +/* 348 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON MaxKey type. + * + * @class + * @return {MaxKey} A MaxKey instance + */ + function MaxKey() { + if (!(this instanceof MaxKey)) return new MaxKey(); + + this._bsontype = 'MaxKey'; + } + + module.exports = MaxKey; + module.exports.MaxKey = MaxKey; + +/***/ }), +/* 349 */ +/***/ (function(module, exports) { + + /** + * A class representation of the BSON DBRef type. + * + * @class + * @param {string} namespace the collection name. + * @param {ObjectID} oid the reference ObjectID. + * @param {string} [db] optional db name, if omitted the reference is local to the current db. + * @return {DBRef} + */ + function DBRef(namespace, oid, db) { + if (!(this instanceof DBRef)) return new DBRef(namespace, oid, db); + + this._bsontype = 'DBRef'; + this.namespace = namespace; + this.oid = oid; + this.db = db; + } + + /** + * @ignore + * @api private + */ + DBRef.prototype.toJSON = function () { + return { + $ref: this.namespace, + $id: this.oid, + $db: this.db == null ? '' : this.db + }; + }; + + module.exports = DBRef; + module.exports.DBRef = DBRef; + +/***/ }), +/* 350 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {/** + * Module dependencies. + * @ignore + */ + + // Test if we're in Node via presence of "global" not absence of "window" + // to support hybrid environments like Electron + if (typeof global !== 'undefined') { + var Buffer = __webpack_require__(329).Buffer; // TODO just use global Buffer + } + + /** + * A class representation of the BSON Binary type. + * + * Sub types + * - **BSON.BSON_BINARY_SUBTYPE_DEFAULT**, default BSON type. + * - **BSON.BSON_BINARY_SUBTYPE_FUNCTION**, BSON function type. + * - **BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY**, BSON byte array type. + * - **BSON.BSON_BINARY_SUBTYPE_UUID**, BSON uuid type. + * - **BSON.BSON_BINARY_SUBTYPE_MD5**, BSON md5 type. + * - **BSON.BSON_BINARY_SUBTYPE_USER_DEFINED**, BSON user defined type. + * + * @class + * @param {Buffer} buffer a buffer object containing the binary data. + * @param {Number} [subType] the option binary type. + * @return {Binary} + */ + function Binary(buffer, subType) { + if (!(this instanceof Binary)) return new Binary(buffer, subType); + + if (buffer != null && !(typeof buffer === 'string') && !Buffer.isBuffer(buffer) && !(buffer instanceof Uint8Array) && !Array.isArray(buffer)) { + throw new Error('only String, Buffer, Uint8Array or Array accepted'); + } + + this._bsontype = 'Binary'; + + if (buffer instanceof Number) { + this.sub_type = buffer; + this.position = 0; + } else { + this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType; + this.position = 0; + } + + if (buffer != null && !(buffer instanceof Number)) { + // Only accept Buffer, Uint8Array or Arrays + if (typeof buffer === 'string') { + // Different ways of writing the length of the string for the different types + if (typeof Buffer !== 'undefined') { + this.buffer = new Buffer(buffer); + } else if (typeof Uint8Array !== 'undefined' || Object.prototype.toString.call(buffer) === '[object Array]') { + this.buffer = writeStringToArray(buffer); + } else { + throw new Error('only String, Buffer, Uint8Array or Array accepted'); + } + } else { + this.buffer = buffer; + } + this.position = buffer.length; + } else { + if (typeof Buffer !== 'undefined') { + this.buffer = new Buffer(Binary.BUFFER_SIZE); + } else if (typeof Uint8Array !== 'undefined') { + this.buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE)); + } else { + this.buffer = new Array(Binary.BUFFER_SIZE); + } + // Set position to start of buffer + this.position = 0; + } + } + + /** + * Updates this binary with byte_value. + * + * @method + * @param {string} byte_value a single byte we wish to write. + */ + Binary.prototype.put = function put(byte_value) { + // If it's a string and a has more than one character throw an error + if (byte_value['length'] != null && typeof byte_value !== 'number' && byte_value.length !== 1) throw new Error('only accepts single character String, Uint8Array or Array'); + if (typeof byte_value !== 'number' && byte_value < 0 || byte_value > 255) throw new Error('only accepts number in a valid unsigned byte range 0-255'); + + // Decode the byte value once + var decoded_byte = null; + if (typeof byte_value === 'string') { + decoded_byte = byte_value.charCodeAt(0); + } else if (byte_value['length'] != null) { + decoded_byte = byte_value[0]; + } else { + decoded_byte = byte_value; + } + + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decoded_byte; + } else { + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + // Create additional overflow buffer + var buffer = new Buffer(Binary.BUFFER_SIZE + this.buffer.length); + // Combine the two buffers together + this.buffer.copy(buffer, 0, 0, this.buffer.length); + this.buffer = buffer; + this.buffer[this.position++] = decoded_byte; + } else { + buffer = null; + // Create a new buffer (typed or normal array) + if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') { + buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE + this.buffer.length)); + } else { + buffer = new Array(Binary.BUFFER_SIZE + this.buffer.length); + } + + // We need to copy all the content to the new array + for (var i = 0; i < this.buffer.length; i++) { + buffer[i] = this.buffer[i]; + } + + // Reassign the buffer + this.buffer = buffer; + // Write the byte + this.buffer[this.position++] = decoded_byte; + } + } + }; + + /** + * Writes a buffer or string to the binary. + * + * @method + * @param {(Buffer|string)} string a string or buffer to be written to the Binary BSON object. + * @param {number} offset specify the binary of where to write the content. + * @return {null} + */ + Binary.prototype.write = function write(string, offset) { + offset = typeof offset === 'number' ? offset : this.position; + + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + string.length) { + var buffer = null; + // If we are in node.js + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + buffer = new Buffer(this.buffer.length + string.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + } else if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') { + // Create a new buffer + buffer = new Uint8Array(new ArrayBuffer(this.buffer.length + string.length)); + // Copy the content + for (var i = 0; i < this.position; i++) { + buffer[i] = this.buffer[i]; + } + } + + // Assign the new buffer + this.buffer = buffer; + } + + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(string) && Buffer.isBuffer(this.buffer)) { + string.copy(this.buffer, offset, 0, string.length); + this.position = offset + string.length > this.position ? offset + string.length : this.position; + // offset = string.length + } else if (typeof Buffer !== 'undefined' && typeof string === 'string' && Buffer.isBuffer(this.buffer)) { + this.buffer.write(string, offset, 'binary'); + this.position = offset + string.length > this.position ? offset + string.length : this.position; + // offset = string.length; + } else if (Object.prototype.toString.call(string) === '[object Uint8Array]' || Object.prototype.toString.call(string) === '[object Array]' && typeof string !== 'string') { + for (i = 0; i < string.length; i++) { + this.buffer[offset++] = string[i]; + } + + this.position = offset > this.position ? offset : this.position; + } else if (typeof string === 'string') { + for (i = 0; i < string.length; i++) { + this.buffer[offset++] = string.charCodeAt(i); + } + + this.position = offset > this.position ? offset : this.position; + } + }; + + /** + * Reads **length** bytes starting at **position**. + * + * @method + * @param {number} position read from the given position in the Binary. + * @param {number} length the number of bytes to read. + * @return {Buffer} + */ + Binary.prototype.read = function read(position, length) { + length = length && length > 0 ? length : this.position; + + // Let's return the data based on the type we have + if (this.buffer['slice']) { + return this.buffer.slice(position, position + length); + } else { + // Create a buffer to keep the result + var buffer = typeof Uint8Array !== 'undefined' ? new Uint8Array(new ArrayBuffer(length)) : new Array(length); + for (var i = 0; i < length; i++) { + buffer[i] = this.buffer[position++]; + } + } + // Return the buffer + return buffer; + }; + + /** + * Returns the value of this binary as a string. + * + * @method + * @return {string} + */ + Binary.prototype.value = function value(asRaw) { + asRaw = asRaw == null ? false : asRaw; + + // Optimize to serialize for the situation where the data == size of buffer + if (asRaw && typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer) && this.buffer.length === this.position) return this.buffer; + + // If it's a node.js buffer object + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + return asRaw ? this.buffer.slice(0, this.position) : this.buffer.toString('binary', 0, this.position); + } else { + if (asRaw) { + // we support the slice command use it + if (this.buffer['slice'] != null) { + return this.buffer.slice(0, this.position); + } else { + // Create a new buffer to copy content to + var newBuffer = Object.prototype.toString.call(this.buffer) === '[object Uint8Array]' ? new Uint8Array(new ArrayBuffer(this.position)) : new Array(this.position); + // Copy content + for (var i = 0; i < this.position; i++) { + newBuffer[i] = this.buffer[i]; + } + // Return the buffer + return newBuffer; + } + } else { + return convertArraytoUtf8BinaryString(this.buffer, 0, this.position); + } + } + }; + + /** + * Length. + * + * @method + * @return {number} the length of the binary. + */ + Binary.prototype.length = function length() { + return this.position; + }; + + /** + * @ignore + */ + Binary.prototype.toJSON = function () { + return this.buffer != null ? this.buffer.toString('base64') : ''; + }; + + /** + * @ignore + */ + Binary.prototype.toString = function (format) { + return this.buffer != null ? this.buffer.slice(0, this.position).toString(format) : ''; + }; + + /** + * Binary default subtype + * @ignore + */ + var BSON_BINARY_SUBTYPE_DEFAULT = 0; + + /** + * @ignore + */ + var writeStringToArray = function (data) { + // Create a buffer + var buffer = typeof Uint8Array !== 'undefined' ? new Uint8Array(new ArrayBuffer(data.length)) : new Array(data.length); + // Write the content to the buffer + for (var i = 0; i < data.length; i++) { + buffer[i] = data.charCodeAt(i); + } + // Write the string to the buffer + return buffer; + }; + + /** + * Convert Array ot Uint8Array to Binary String + * + * @ignore + */ + var convertArraytoUtf8BinaryString = function (byteArray, startIndex, endIndex) { + var result = ''; + for (var i = startIndex; i < endIndex; i++) { + result = result + String.fromCharCode(byteArray[i]); + } + return result; + }; + + Binary.BUFFER_SIZE = 256; + + /** + * Default BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_DEFAULT = 0; + /** + * Function BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_FUNCTION = 1; + /** + * Byte Array BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_BYTE_ARRAY = 2; + /** + * OLD UUID BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_UUID_OLD = 3; + /** + * UUID BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_UUID = 4; + /** + * MD5 BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_MD5 = 5; + /** + * User BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ + Binary.SUBTYPE_USER_DEFINED = 128; + + /** + * Expose. + */ + module.exports = Binary; + module.exports.Binary = Binary; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var Long = __webpack_require__(334).Long, + Double = __webpack_require__(335).Double, + Timestamp = __webpack_require__(336).Timestamp, + ObjectID = __webpack_require__(337).ObjectID, + Symbol = __webpack_require__(343).Symbol, + Code = __webpack_require__(345).Code, + MinKey = __webpack_require__(347).MinKey, + MaxKey = __webpack_require__(348).MaxKey, + Decimal128 = __webpack_require__(346), + Int32 = __webpack_require__(344), + DBRef = __webpack_require__(349).DBRef, + BSONRegExp = __webpack_require__(342).BSONRegExp, + Binary = __webpack_require__(350).Binary; + + var deserialize = function (buffer, options, isArray) { + options = options == null ? {} : options; + var index = options && options.index ? options.index : 0; + // Read the document size + var size = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; + + // Ensure buffer is valid size + if (size < 5 || buffer.length < size || size + index > buffer.length) { + throw new Error('corrupt bson message'); + } + + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); + } + + // Start deserializtion + return deserializeObject(buffer, index, options, isArray); + }; + + var deserializeObject = function (buffer, index, options, isArray) { + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + var cacheFunctionsCrc32 = options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32']; + + if (!cacheFunctionsCrc32) var crc32 = null; + + var fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw']; + + // Return raw bson buffer instead of parsing it + var raw = options['raw'] == null ? false : options['raw']; + + // Return BSONRegExp objects instead of native regular expressions + var bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false; + + // Controls the promotion of values vs wrapper classes + var promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers']; + var promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs']; + var promoteValues = options['promoteValues'] == null ? true : options['promoteValues']; + + // Set the start index + var startIndex = index; + + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) throw new Error('corrupt bson message < 5 bytes long'); + + // Read the document size + var size = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + + // Ensure buffer is valid size + if (size < 5 || size > buffer.length) throw new Error('corrupt bson message'); + + // Create holding object + var object = isArray ? [] : {}; + // Used for arrays to skip having to perform utf8 decoding + var arrayIndex = 0; + + var done = false; + + // While we have more left data left keep parsing + // while (buffer[index + 1] !== 0) { + while (!done) { + // Read the type + var elementType = buffer[index++]; + // If we get a zero it's the last byte, exit + if (elementType === 0) break; + + // Get the start search index + var i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + + index = i + 1; + + if (elementType === BSON.BSON_DATA_STRING) { + var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + if (stringSize <= 0 || stringSize > buffer.length - index || buffer[index + stringSize - 1] !== 0) throw new Error('bad string length in bson'); + object[name] = buffer.toString('utf8', index, index + stringSize - 1); + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_OID) { + var oid = new Buffer(12); + buffer.copy(oid, 0, index, index + 12); + object[name] = new ObjectID(oid); + index = index + 12; + } else if (elementType === BSON.BSON_DATA_INT && promoteValues === false) { + object[name] = new Int32(buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24); + } else if (elementType === BSON.BSON_DATA_INT) { + object[name] = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + } else if (elementType === BSON.BSON_DATA_NUMBER && promoteValues === false) { + object[name] = new Double(buffer.readDoubleLE(index)); + index = index + 8; + } else if (elementType === BSON.BSON_DATA_NUMBER) { + object[name] = buffer.readDoubleLE(index); + index = index + 8; + } else if (elementType === BSON.BSON_DATA_DATE) { + var lowBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + var highBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + object[name] = new Date(new Long(lowBits, highBits).toNumber()); + } else if (elementType === BSON.BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) throw new Error('illegal boolean type value'); + object[name] = buffer[index++] === 1; + } else if (elementType === BSON.BSON_DATA_OBJECT) { + var _index = index; + var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; + if (objectSize <= 0 || objectSize > buffer.length - index) throw new Error('bad embedded document length in bson'); + + // We have a raw value + if (raw) { + object[name] = buffer.slice(index, index + objectSize); + } else { + object[name] = deserializeObject(buffer, _index, options, false); + } + + index = index + objectSize; + } else if (elementType === BSON.BSON_DATA_ARRAY) { + _index = index; + objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; + var arrayOptions = options; + + // Stop index + var stopIndex = index + objectSize; + + // All elements of array to be returned as raw bson + if (fieldsAsRaw && fieldsAsRaw[name]) { + arrayOptions = {}; + for (var n in options) arrayOptions[n] = options[n]; + arrayOptions['raw'] = true; + } + + object[name] = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + + if (buffer[index - 1] !== 0) throw new Error('invalid array terminator byte'); + if (index !== stopIndex) throw new Error('corrupted array bson'); + } else if (elementType === BSON.BSON_DATA_UNDEFINED) { + object[name] = undefined; + } else if (elementType === BSON.BSON_DATA_NULL) { + object[name] = null; + } else if (elementType === BSON.BSON_DATA_LONG) { + // Unpack the low and high bits + lowBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + highBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + object[name] = long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) ? long.toNumber() : long; + } else { + object[name] = long; + } + } else if (elementType === BSON.BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = new Buffer(16); + // Copy the next 16 bytes into the bytes buffer + buffer.copy(bytes, 0, index, index + 16); + // Update index + index = index + 16; + // Assign the new Decimal128 value + var decimal128 = new Decimal128(bytes); + // If we have an alternative mapper use that + object[name] = decimal128.toObject ? decimal128.toObject() : decimal128; + } else if (elementType === BSON.BSON_DATA_BINARY) { + var binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + var totalBinarySize = binarySize; + var subType = buffer[index++]; + + // Did we have a negative binary size, throw + if (binarySize < 0) throw new Error('Negative binary type element size found'); + + // Is the length longer than the document + if (binarySize > buffer.length) throw new Error('Binary type size larger than document size'); + + // Decode as raw Buffer object if options specifies it + if (buffer['slice'] != null) { + // If we have subtype 2 skip the 4 bytes for the size + if (subType === Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + if (binarySize < 0) throw new Error('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) throw new Error('Binary type with subtype 0x02 contains to long binary size'); + if (binarySize < totalBinarySize - 4) throw new Error('Binary type with subtype 0x02 contains to short binary size'); + } + + if (promoteBuffers && promoteValues) { + object[name] = buffer.slice(index, index + binarySize); + } else { + object[name] = new Binary(buffer.slice(index, index + binarySize), subType); + } + } else { + var _buffer = typeof Uint8Array !== 'undefined' ? new Uint8Array(new ArrayBuffer(binarySize)) : new Array(binarySize); + // If we have subtype 2 skip the 4 bytes for the size + if (subType === Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + if (binarySize < 0) throw new Error('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) throw new Error('Binary type with subtype 0x02 contains to long binary size'); + if (binarySize < totalBinarySize - 4) throw new Error('Binary type with subtype 0x02 contains to short binary size'); + } + + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + + if (promoteBuffers && promoteValues) { + object[name] = _buffer; + } else { + object[name] = new Binary(_buffer, subType); + } + } + + // Update the index + index = index + binarySize; + } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === false) { + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + var source = buffer.toString('utf8', index, i); + // Create the regexp + index = i + 1; + + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // For each option add the corresponding one for javascript + var optionsArray = new Array(regExpOptions.length); + + // Parse options + for (i = 0; i < regExpOptions.length; i++) { + switch (regExpOptions[i]) { + case 'm': + optionsArray[i] = 'm'; + break; + case 's': + optionsArray[i] = 'g'; + break; + case 'i': + optionsArray[i] = 'i'; + break; + } + } + + object[name] = new RegExp(source, optionsArray.join('')); + } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === true) { + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + source = buffer.toString('utf8', index, i); + index = i + 1; + + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // Set the object + object[name] = new BSONRegExp(source, regExpOptions); + } else if (elementType === BSON.BSON_DATA_SYMBOL) { + stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + if (stringSize <= 0 || stringSize > buffer.length - index || buffer[index + stringSize - 1] !== 0) throw new Error('bad string length in bson'); + object[name] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1)); + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_TIMESTAMP) { + lowBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + highBits = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + object[name] = new Timestamp(lowBits, highBits); + } else if (elementType === BSON.BSON_DATA_MIN_KEY) { + object[name] = new MinKey(); + } else if (elementType === BSON.BSON_DATA_MAX_KEY) { + object[name] = new MaxKey(); + } else if (elementType === BSON.BSON_DATA_CODE) { + stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + if (stringSize <= 0 || stringSize > buffer.length - index || buffer[index + stringSize - 1] !== 0) throw new Error('bad string length in bson'); + var functionString = buffer.toString('utf8', index, index + stringSize - 1); + + // If we are evaluating the functions + if (evalFunctions) { + // If we have cache enabled let's look for the md5 of the function in the cache + if (cacheFunctions) { + var hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString; + // Got to do this to avoid V8 deoptimizing the call due to finding eval + object[name] = isolateEvalWithHash(functionCache, hash, functionString, object); + } else { + object[name] = isolateEval(functionString); + } + } else { + object[name] = new Code(functionString); + } + + // Update parse index position + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_CODE_W_SCOPE) { + var totalSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + + // Element cannot be shorter than totalSize + stringSize + documentSize + terminator + if (totalSize < 4 + 4 + 4 + 1) { + throw new Error('code_w_scope total size shorter minimum expected length'); + } + + // Get the code string size + stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + // Check if we have a valid string + if (stringSize <= 0 || stringSize > buffer.length - index || buffer[index + stringSize - 1] !== 0) throw new Error('bad string length in bson'); + + // Javascript function + functionString = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Parse the element + _index = index; + // Decode the size of the object document + objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; + // Decode the scope object + var scopeObject = deserializeObject(buffer, _index, options, false); + // Adjust the index + index = index + objectSize; + + // Check if field length is to short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new Error('code_w_scope total size is to short, truncating scope'); + } + + // Check if totalSize field is to long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new Error('code_w_scope total size is to long, clips outer document'); + } + + // If we are evaluating the functions + if (evalFunctions) { + // If we have cache enabled let's look for the md5 of the function in the cache + if (cacheFunctions) { + hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString; + // Got to do this to avoid V8 deoptimizing the call due to finding eval + object[name] = isolateEvalWithHash(functionCache, hash, functionString, object); + } else { + object[name] = isolateEval(functionString); + } + + object[name].scope = scopeObject; + } else { + object[name] = new Code(functionString, scopeObject); + } + } else if (elementType === BSON.BSON_DATA_DBPOINTER) { + // Get the code string size + stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; + // Check if we have a valid string + if (stringSize <= 0 || stringSize > buffer.length - index || buffer[index + stringSize - 1] !== 0) throw new Error('bad string length in bson'); + // Namespace + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + + // Read the oid + var oidBuffer = new Buffer(12); + buffer.copy(oidBuffer, 0, index, index + 12); + oid = new ObjectID(oidBuffer); + + // Update the index + index = index + 12; + + // Split the namespace + var parts = namespace.split('.'); + var db = parts.shift(); + var collection = parts.join('.'); + // Upgrade to DBRef type + object[name] = new DBRef(collection, oid, db); + } else { + throw new Error('Detected unknown BSON type ' + elementType.toString(16) + ' for fieldname "' + name + '", are you using the latest BSON parser'); + } + } + + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) throw new Error('corrupt array bson'); + throw new Error('corrupt object bson'); + } + + // Check if we have a db ref object + if (object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']); + return object; + }; + + /** + * Ensure eval is isolated. + * + * @ignore + * @api private + */ + var isolateEvalWithHash = function (functionCache, hash, functionString, object) { + // Contains the value we are going to set + var value = null; + + // Check for cache hit, eval if missing and return cached function + if (functionCache[hash] == null) { + eval('value = ' + functionString); + functionCache[hash] = value; + } + // Set the object + return functionCache[hash].bind(object); + }; + + /** + * Ensure eval is isolated. + * + * @ignore + * @api private + */ + var isolateEval = function (functionString) { + // Contains the value we are going to set + var value = null; + // Eval the function + eval('value = ' + functionString); + return value; + }; + + var BSON = {}; + + /** + * Contains the function cache if we have that enable to allow for avoiding the eval step on each deserialization, comparison is by md5 + * + * @ignore + * @api private + */ + var functionCache = BSON.functionCache = {}; + + /** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ + BSON.BSON_DATA_NUMBER = 1; + /** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ + BSON.BSON_DATA_STRING = 2; + /** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ + BSON.BSON_DATA_OBJECT = 3; + /** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ + BSON.BSON_DATA_ARRAY = 4; + /** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ + BSON.BSON_DATA_BINARY = 5; + /** + * Binary BSON Type + * + * @classconstant BSON_DATA_UNDEFINED + **/ + BSON.BSON_DATA_UNDEFINED = 6; + /** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ + BSON.BSON_DATA_OID = 7; + /** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ + BSON.BSON_DATA_BOOLEAN = 8; + /** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ + BSON.BSON_DATA_DATE = 9; + /** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ + BSON.BSON_DATA_NULL = 10; + /** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ + BSON.BSON_DATA_REGEXP = 11; + /** + * Code BSON Type + * + * @classconstant BSON_DATA_DBPOINTER + **/ + BSON.BSON_DATA_DBPOINTER = 12; + /** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ + BSON.BSON_DATA_CODE = 13; + /** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ + BSON.BSON_DATA_SYMBOL = 14; + /** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ + BSON.BSON_DATA_CODE_W_SCOPE = 15; + /** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ + BSON.BSON_DATA_INT = 16; + /** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ + BSON.BSON_DATA_TIMESTAMP = 17; + /** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ + BSON.BSON_DATA_LONG = 18; + /** + * Long BSON Type + * + * @classconstant BSON_DATA_DECIMAL128 + **/ + BSON.BSON_DATA_DECIMAL128 = 19; + /** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ + BSON.BSON_DATA_MIN_KEY = 0xff; + /** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ + BSON.BSON_DATA_MAX_KEY = 0x7f; + + /** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ + BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ + BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; + /** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ + BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + /** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ + BSON.BSON_BINARY_SUBTYPE_UUID = 3; + /** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ + BSON.BSON_BINARY_SUBTYPE_MD5 = 4; + /** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ + BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + + // BSON MAX VALUES + BSON.BSON_INT32_MAX = 0x7fffffff; + BSON.BSON_INT32_MIN = -0x80000000; + + BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; + BSON.BSON_INT64_MIN = -Math.pow(2, 63); + + // JS MAX PRECISE VALUES + BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. + BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + + // Internal long versions + var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. + var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + + module.exports = deserialize; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }), +/* 352 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var writeIEEE754 = __webpack_require__(353).writeIEEE754, + Long = __webpack_require__(334).Long, + MinKey = __webpack_require__(347).MinKey, + Map = __webpack_require__(333), + Binary = __webpack_require__(350).Binary; + + const normalizedFunctionString = __webpack_require__(354).normalizedFunctionString; + + // try { + // var _Buffer = Uint8Array; + // } catch (e) { + // _Buffer = Buffer; + // } + + var regexp = /\x00/; // eslint-disable-line no-control-regex + + // To ensure that 0.4 of node works correctly + var isDate = function isDate(d) { + return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]'; + }; + + var isRegExp = function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; + }; + + var serializeString = function (buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON.BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = size + 1 >> 24 & 0xff; + buffer[index + 2] = size + 1 >> 16 & 0xff; + buffer[index + 1] = size + 1 >> 8 & 0xff; + buffer[index] = size + 1 & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; + }; + + var serializeNumber = function (buffer, key, value, index, isArray) { + // We have an integer value + if (Math.floor(value) === value && value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + // If the value fits in 32 bits encode as int, if it fits in a double + // encode it as a double, otherwise long + if (value >= BSON.BSON_INT32_MIN && value <= BSON.BSON_INT32_MAX) { + // Set int type 32 bits or less + buffer[index++] = BSON.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = value >> 8 & 0xff; + buffer[index++] = value >> 16 & 0xff; + buffer[index++] = value >> 24 & 0xff; + } else if (value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + } else { + // Set long type + buffer[index++] = BSON.BSON_DATA_LONG; + // Number of written bytes + numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var longVal = Long.fromNumber(value); + var lowBits = longVal.getLowBits(); + var highBits = longVal.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = lowBits >> 8 & 0xff; + buffer[index++] = lowBits >> 16 & 0xff; + buffer[index++] = lowBits >> 24 & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = highBits >> 8 & 0xff; + buffer[index++] = highBits >> 16 & 0xff; + buffer[index++] = highBits >> 24 & 0xff; + } + } else { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + } + + return index; + }; + + var serializeNull = function (buffer, key, value, index, isArray) { + // Set long type + buffer[index++] = BSON.BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + }; + + var serializeBoolean = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; + }; + + var serializeDate = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = lowBits >> 8 & 0xff; + buffer[index++] = lowBits >> 16 & 0xff; + buffer[index++] = lowBits >> 24 & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = highBits >> 8 & 0xff; + buffer[index++] = highBits >> 16 & 0xff; + buffer[index++] = highBits >> 24 & 0xff; + return index; + }; + + var serializeRegExp = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.global) buffer[index++] = 0x73; // s + if (value.ignoreCase) buffer[index++] = 0x69; // i + if (value.multiline) buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; + }; + + var serializeBSONRegExp = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + + // Adjust the index + index = index + buffer.write(value.pattern, index, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = index + buffer.write(value.options.split('').sort().join(''), index, 'utf8'); + // Add ending zero + buffer[index++] = 0x00; + return index; + }; + + var serializeMinMax = function (buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON.BSON_DATA_NULL; + } else if (value instanceof MinKey) { + buffer[index++] = BSON.BSON_DATA_MIN_KEY; + } else { + buffer[index++] = BSON.BSON_DATA_MAX_KEY; + } + + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; + }; + + var serializeObjectId = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, 'binary'); + } else if (value.id && value.id.copy) { + value.id.copy(buffer, index, 0, 12); + } else { + throw new Error('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + + // Ajust index + return index + 12; + }; + + var serializeBuffer = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = size >> 8 & 0xff; + buffer[index++] = size >> 16 & 0xff; + buffer[index++] = size >> 24 & 0xff; + // Write the default subtype + buffer[index++] = BSON.BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + value.copy(buffer, index, 0, size); + // Adjust the index + index = index + size; + return index; + }; + + var serializeObject = function (buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray, path) { + for (var i = 0; i < path.length; i++) { + if (path[i] === value) throw new Error('cyclic dependency detected'); + } + + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON.BSON_DATA_ARRAY : BSON.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path); + // Pop stack + path.pop(); + // Write size + return endIndex; + }; + + var serializeDecimal128 = function (buffer, key, value, index, isArray) { + buffer[index++] = BSON.BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + value.bytes.copy(buffer, index, 0, 16); + return index + 16; + }; + + var serializeLong = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = value._bsontype === 'Long' ? BSON.BSON_DATA_LONG : BSON.BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = lowBits >> 8 & 0xff; + buffer[index++] = lowBits >> 16 & 0xff; + buffer[index++] = lowBits >> 24 & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = highBits >> 8 & 0xff; + buffer[index++] = highBits >> 16 & 0xff; + buffer[index++] = highBits >> 24 & 0xff; + return index; + }; + + var serializeInt32 = function (buffer, key, value, index, isArray) { + // Set int type 32 bits or less + buffer[index++] = BSON.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = value >> 8 & 0xff; + buffer[index++] = value >> 16 & 0xff; + buffer[index++] = value >> 24 & 0xff; + return index; + }; + + var serializeDouble = function (buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + return index; + }; + + var serializeFunction = function (buffer, key, value, index, checkKeys, depth, isArray) { + buffer[index++] = BSON.BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + + // Write the string + var size = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = size >> 8 & 0xff; + buffer[index + 2] = size >> 16 & 0xff; + buffer[index + 3] = size >> 24 & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; + }; + + var serializeCode = function (buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, isArray) { + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Starting index + var startIndex = index; + + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = codeSize >> 8 & 0xff; + buffer[index + 2] = codeSize >> 16 & 0xff; + buffer[index + 3] = codeSize >> 24 & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + + // + // Serialize the scope value + var endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined); + index = endIndex - 1; + + // Writ the total + var totalSize = endIndex - startIndex; + + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = totalSize >> 8 & 0xff; + buffer[startIndex++] = totalSize >> 16 & 0xff; + buffer[startIndex++] = totalSize >> 24 & 0xff; + // Write trailing zero + buffer[index++] = 0; + } else { + buffer[index++] = BSON.BSON_DATA_CODE; + // Number of written bytes + numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = size >> 8 & 0xff; + buffer[index + 2] = size >> 16 & 0xff; + buffer[index + 3] = size >> 24 & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + + return index; + }; + + var serializeBinary = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = size >> 8 & 0xff; + buffer[index++] = size >> 16 & 0xff; + buffer[index++] = size >> 24 & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = size >> 8 & 0xff; + buffer[index++] = size >> 16 & 0xff; + buffer[index++] = size >> 24 & 0xff; + } + + // Write the data to the object + data.copy(buffer, index, 0, value.position); + // Adjust the index + index = index + value.position; + return index; + }; + + var serializeSymbol = function (buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = size >> 8 & 0xff; + buffer[index + 2] = size >> 16 & 0xff; + buffer[index + 3] = size >> 24 & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; + }; + + var serializeDBRef = function (buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray ? buffer.write(key, index, 'utf8') : buffer.write(key, index, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + var startIndex = index; + var endIndex; + + // Serialize object + if (null != value.db) { + endIndex = serializeInto(buffer, { + $ref: value.namespace, + $id: value.oid, + $db: value.db + }, false, index, depth + 1, serializeFunctions); + } else { + endIndex = serializeInto(buffer, { + $ref: value.namespace, + $id: value.oid + }, false, index, depth + 1, serializeFunctions); + } + + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = size >> 8 & 0xff; + buffer[startIndex++] = size >> 16 & 0xff; + buffer[startIndex++] = size >> 24 & 0xff; + // Set index + return endIndex; + }; + + var serializeInto = function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) { + startingIndex = startingIndex || 0; + path = path || []; + + // Push the object to the path + path.push(object); + + // Start place to serialize into + var index = startingIndex + 4; + // var self = this; + + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = '' + i; + var value = object[i]; + + // Is there an override value + if (value && value.toBSON) { + if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function'); + value = value.toBSON(); + } + + var type = typeof value; + if (type === 'string') { + index = serializeString(buffer, key, value, index, true); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true, path); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions, true); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, true); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + } + } else if (object instanceof Map) { + var iterator = object.entries(); + var done = false; + + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = entry.done; + // Are we done, then skip and terminate + if (done) continue; + + // Get the entry values + key = entry.value[0]; + value = entry.value[1]; + + // Check the type of the value + type = typeof value; + + // Check the key and throw error if it's illegal + if (key !== '$db' && key !== '$ref' && key !== '$id') { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + // } else if (value === undefined && ignoreUndefined === true) { + } else if (value === null || value === undefined && ignoreUndefined === false) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + } + } else { + // Did we provide a custom serialization method + if (object.toBSON) { + if (typeof object.toBSON !== 'function') throw new Error('toBSON is not a function'); + object = object.toBSON(); + if (object != null && typeof object !== 'object') throw new Error('toBSON function did not return an object'); + } + + // Iterate over all the keys + for (key in object) { + value = object[key]; + // Is there an override value + if (value && value.toBSON) { + if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function'); + value = value.toBSON(); + } + + // Check the type of the value + type = typeof value; + + // Check the key and throw error if it's illegal + if (key !== '$db' && key !== '$ref' && key !== '$id') { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } else if (value === undefined) { + if (ignoreUndefined === false) index = serializeNull(buffer, key, value, index); + } else if (value === null) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, false, path); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + } + } + + // Remove the path + path.pop(); + + // Final padding byte for object + buffer[index++] = 0x00; + + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = size >> 8 & 0xff; + buffer[startingIndex++] = size >> 16 & 0xff; + buffer[startingIndex++] = size >> 24 & 0xff; + return index; + }; + + var BSON = {}; + + /** + * Contains the function cache if we have that enable to allow for avoiding the eval step on each deserialization, comparison is by md5 + * + * @ignore + * @api private + */ + // var functionCache = (BSON.functionCache = {}); + + /** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ + BSON.BSON_DATA_NUMBER = 1; + /** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ + BSON.BSON_DATA_STRING = 2; + /** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ + BSON.BSON_DATA_OBJECT = 3; + /** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ + BSON.BSON_DATA_ARRAY = 4; + /** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ + BSON.BSON_DATA_BINARY = 5; + /** + * ObjectID BSON Type, deprecated + * + * @classconstant BSON_DATA_UNDEFINED + **/ + BSON.BSON_DATA_UNDEFINED = 6; + /** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ + BSON.BSON_DATA_OID = 7; + /** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ + BSON.BSON_DATA_BOOLEAN = 8; + /** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ + BSON.BSON_DATA_DATE = 9; + /** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ + BSON.BSON_DATA_NULL = 10; + /** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ + BSON.BSON_DATA_REGEXP = 11; + /** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ + BSON.BSON_DATA_CODE = 13; + /** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ + BSON.BSON_DATA_SYMBOL = 14; + /** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ + BSON.BSON_DATA_CODE_W_SCOPE = 15; + /** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ + BSON.BSON_DATA_INT = 16; + /** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ + BSON.BSON_DATA_TIMESTAMP = 17; + /** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ + BSON.BSON_DATA_LONG = 18; + /** + * Long BSON Type + * + * @classconstant BSON_DATA_DECIMAL128 + **/ + BSON.BSON_DATA_DECIMAL128 = 19; + /** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ + BSON.BSON_DATA_MIN_KEY = 0xff; + /** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ + BSON.BSON_DATA_MAX_KEY = 0x7f; + /** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ + BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; + /** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ + BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; + /** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ + BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; + /** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ + BSON.BSON_BINARY_SUBTYPE_UUID = 3; + /** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ + BSON.BSON_BINARY_SUBTYPE_MD5 = 4; + /** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ + BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + + // BSON MAX VALUES + BSON.BSON_INT32_MAX = 0x7fffffff; + BSON.BSON_INT32_MIN = -0x80000000; + + BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; + BSON.BSON_INT64_MIN = -Math.pow(2, 63); + + // JS MAX PRECISE VALUES + BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. + BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + + // Internal long versions + // var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. + // var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + + module.exports = serializeInto; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }), +/* 353 */ +/***/ (function(module, exports) { + + // Copyright (c) 2008, Fair Oaks Labs, Inc. + // All rights reserved. + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are met: + // + // * Redistributions of source code must retain the above copyright notice, + // this list of conditions and the following disclaimer. + // + // * Redistributions in binary form must reproduce the above copyright notice, + // this list of conditions and the following disclaimer in the documentation + // and/or other materials provided with the distribution. + // + // * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors + // may be used to endorse or promote products derived from this software + // without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + // POSSIBILITY OF SUCH DAMAGE. + // + // + // Modifications to writeIEEE754 to support negative zeroes made by Brian White + + var readIEEE754 = function (buffer, offset, endian, mLen, nBytes) { + var e, + m, + bBE = endian === 'big', + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + nBits = -7, + i = bBE ? 0 : nBytes - 1, + d = bBE ? 1 : -1, + s = buffer[offset + i]; + + i += d; + + e = s & (1 << -nBits) - 1; + s >>= -nBits; + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + + m = e & (1 << -nBits) - 1; + e >>= -nBits; + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : (s ? -1 : 1) * Infinity; + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); + }; + + var writeIEEE754 = function (buffer, value, offset, endian, mLen, nBytes) { + var e, + m, + c, + bBE = endian === 'big', + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, + i = bBE ? nBytes - 1 : 0, + d = bBE ? -1 : 1, + s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + + e = e << mLen | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + + buffer[offset + i - d] |= s * 128; + }; + + exports.readIEEE754 = readIEEE754; + exports.writeIEEE754 = writeIEEE754; + +/***/ }), +/* 354 */ +/***/ (function(module, exports) { + + 'use strict'; + + /** + * Normalizes our expected stringified form of a function across versions of node + * @param {Function} fn The function to stringify + */ + + function normalizedFunctionString(fn) { + return fn.toString().replace(/function *\(/, 'function ('); + } + + module.exports = { + normalizedFunctionString: normalizedFunctionString + }; + +/***/ }), +/* 355 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; + + var Long = __webpack_require__(334).Long, + Double = __webpack_require__(335).Double, + Timestamp = __webpack_require__(336).Timestamp, + ObjectID = __webpack_require__(337).ObjectID, + Symbol = __webpack_require__(343).Symbol, + BSONRegExp = __webpack_require__(342).BSONRegExp, + Code = __webpack_require__(345).Code, + Decimal128 = __webpack_require__(346), + MinKey = __webpack_require__(347).MinKey, + MaxKey = __webpack_require__(348).MaxKey, + DBRef = __webpack_require__(349).DBRef, + Binary = __webpack_require__(350).Binary; + + var normalizedFunctionString = __webpack_require__(354).normalizedFunctionString; + + // To ensure that 0.4 of node works correctly + var isDate = function isDate(d) { + return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]'; + }; + + var calculateObjectSize = function calculateObjectSize(object, serializeFunctions, ignoreUndefined) { + var totalLength = 4 + 1; + + if (Array.isArray(object)) { + for (var i = 0; i < object.length; i++) { + totalLength += calculateElement(i.toString(), object[i], serializeFunctions, true, ignoreUndefined); + } + } else { + // If we have toBSON defined, override the current object + if (object.toBSON) { + object = object.toBSON(); + } + + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + + return totalLength; + }; + + /** + * @ignore + * @api private + */ + function calculateElement(name, value, serializeFunctions, isArray, ignoreUndefined) { + // If we have toBSON defined, override the current object + if (value && value.toBSON) { + value = value.toBSON(); + } + + switch (typeof value) { + case 'string': + return 1 + Buffer.byteLength(name, 'utf8') + 1 + 4 + Buffer.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + if (value >= BSON.BSON_INT32_MIN && value <= BSON.BSON_INT32_MAX) { + // 32 bit + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } else { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } else { + // 64 bit + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if (value == null || value instanceof MinKey || value instanceof MaxKey || value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + } else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } else if (value instanceof Date || isDate(value)) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.length; + } else if (value instanceof Long || value instanceof Double || value instanceof Timestamp || value['_bsontype'] === 'Long' || value['_bsontype'] === 'Double' || value['_bsontype'] === 'Timestamp') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } else if (value instanceof Decimal128 || value['_bsontype'] === 'Decimal128') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } else if (value instanceof Code || value['_bsontype'] === 'Code') { + // Calculate size depending on the availability of a scope + if (value.scope != null && Object.keys(value.scope).length > 0) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + 4 + 4 + Buffer.byteLength(value.code.toString(), 'utf8') + 1 + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined); + } else { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + 4 + Buffer.byteLength(value.code.toString(), 'utf8') + 1; + } + } else if (value instanceof Binary || value['_bsontype'] === 'Binary') { + // Check what kind of subtype we have + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1 + 4); + } else { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1); + } + } else if (value instanceof Symbol || value['_bsontype'] === 'Symbol') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + Buffer.byteLength(value.value, 'utf8') + 4 + 1 + 1; + } else if (value instanceof DBRef || value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = { + $ref: value.namespace, + $id: value.oid + }; + + // Add db reference if it exists + if (null != value.db) { + ordered_values['$db'] = value.db; + } + + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined); + } else if (value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + Buffer.byteLength(value.source, 'utf8') + 1 + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1; + } else if (value instanceof BSONRegExp || value['_bsontype'] === 'BSONRegExp') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + Buffer.byteLength(value.pattern, 'utf8') + 1 + Buffer.byteLength(value.options, 'utf8') + 1; + } else { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + calculateObjectSize(value, serializeFunctions, ignoreUndefined) + 1; + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if (value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]' || String.call(value) === '[object RegExp]') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + Buffer.byteLength(value.source, 'utf8') + 1 + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1; + } else { + if (serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + 4 + 4 + Buffer.byteLength(normalizedFunctionString(value), 'utf8') + 1 + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined); + } else if (serializeFunctions) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1 + 4 + Buffer.byteLength(normalizedFunctionString(value), 'utf8') + 1; + } + } + } + + return 0; + } + + var BSON = {}; + + // BSON MAX VALUES + BSON.BSON_INT32_MAX = 0x7fffffff; + BSON.BSON_INT32_MIN = -0x80000000; + + // JS MAX PRECISE VALUES + BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. + BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + + module.exports = calculateObjectSize; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(329).Buffer)) + +/***/ }) +/******/ ]) +}); +; \ No newline at end of file diff --git a/node_modules/mongodb-core/node_modules/bson/browser_build/package.json b/node_modules/mongodb-core/node_modules/bson/browser_build/package.json new file mode 100644 index 0000000..980db7f --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/browser_build/package.json @@ -0,0 +1,8 @@ +{ "name" : "bson" +, "description" : "A bson parser for node.js and the browser" +, "main": "../" +, "directories" : { "lib" : "../lib/bson" } +, "engines" : { "node" : ">=0.6.0" } +, "licenses" : [ { "type" : "Apache License, Version 2.0" + , "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ] +} diff --git a/node_modules/mongodb-core/node_modules/bson/index.js b/node_modules/mongodb-core/node_modules/bson/index.js new file mode 100644 index 0000000..6502552 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/index.js @@ -0,0 +1,46 @@ +var BSON = require('./lib/bson/bson'), + Binary = require('./lib/bson/binary'), + Code = require('./lib/bson/code'), + DBRef = require('./lib/bson/db_ref'), + Decimal128 = require('./lib/bson/decimal128'), + Double = require('./lib/bson/double'), + Int32 = require('./lib/bson/int_32'), + Long = require('./lib/bson/long'), + Map = require('./lib/bson/map'), + MaxKey = require('./lib/bson/max_key'), + MinKey = require('./lib/bson/min_key'), + ObjectId = require('./lib/bson/objectid'), + BSONRegExp = require('./lib/bson/regexp'), + Symbol = require('./lib/bson/symbol'), + Timestamp = require('./lib/bson/timestamp'); + +// BSON MAX VALUES +BSON.BSON_INT32_MAX = 0x7fffffff; +BSON.BSON_INT32_MIN = -0x80000000; + +BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; +BSON.BSON_INT64_MIN = -Math.pow(2, 63); + +// JS MAX PRECISE VALUES +BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. +BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + +// Add BSON types to function creation +BSON.Binary = Binary; +BSON.Code = Code; +BSON.DBRef = DBRef; +BSON.Decimal128 = Decimal128; +BSON.Double = Double; +BSON.Int32 = Int32; +BSON.Long = Long; +BSON.Map = Map; +BSON.MaxKey = MaxKey; +BSON.MinKey = MinKey; +BSON.ObjectId = ObjectId; +BSON.ObjectID = ObjectId; +BSON.BSONRegExp = BSONRegExp; +BSON.Symbol = Symbol; +BSON.Timestamp = Timestamp; + +// Return the BSON +module.exports = BSON; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/binary.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/binary.js new file mode 100644 index 0000000..f3f695d --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/binary.js @@ -0,0 +1,382 @@ +/** + * Module dependencies. + * @ignore + */ + +// Test if we're in Node via presence of "global" not absence of "window" +// to support hybrid environments like Electron +if (typeof global !== 'undefined') { + var Buffer = require('buffer').Buffer; // TODO just use global Buffer +} + +/** + * A class representation of the BSON Binary type. + * + * Sub types + * - **BSON.BSON_BINARY_SUBTYPE_DEFAULT**, default BSON type. + * - **BSON.BSON_BINARY_SUBTYPE_FUNCTION**, BSON function type. + * - **BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY**, BSON byte array type. + * - **BSON.BSON_BINARY_SUBTYPE_UUID**, BSON uuid type. + * - **BSON.BSON_BINARY_SUBTYPE_MD5**, BSON md5 type. + * - **BSON.BSON_BINARY_SUBTYPE_USER_DEFINED**, BSON user defined type. + * + * @class + * @param {Buffer} buffer a buffer object containing the binary data. + * @param {Number} [subType] the option binary type. + * @return {Binary} + */ +function Binary(buffer, subType) { + if (!(this instanceof Binary)) return new Binary(buffer, subType); + + if ( + buffer != null && + !(typeof buffer === 'string') && + !Buffer.isBuffer(buffer) && + !(buffer instanceof Uint8Array) && + !Array.isArray(buffer) + ) { + throw new Error('only String, Buffer, Uint8Array or Array accepted'); + } + + this._bsontype = 'Binary'; + + if (buffer instanceof Number) { + this.sub_type = buffer; + this.position = 0; + } else { + this.sub_type = subType == null ? BSON_BINARY_SUBTYPE_DEFAULT : subType; + this.position = 0; + } + + if (buffer != null && !(buffer instanceof Number)) { + // Only accept Buffer, Uint8Array or Arrays + if (typeof buffer === 'string') { + // Different ways of writing the length of the string for the different types + if (typeof Buffer !== 'undefined') { + this.buffer = new Buffer(buffer); + } else if ( + typeof Uint8Array !== 'undefined' || + Object.prototype.toString.call(buffer) === '[object Array]' + ) { + this.buffer = writeStringToArray(buffer); + } else { + throw new Error('only String, Buffer, Uint8Array or Array accepted'); + } + } else { + this.buffer = buffer; + } + this.position = buffer.length; + } else { + if (typeof Buffer !== 'undefined') { + this.buffer = new Buffer(Binary.BUFFER_SIZE); + } else if (typeof Uint8Array !== 'undefined') { + this.buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE)); + } else { + this.buffer = new Array(Binary.BUFFER_SIZE); + } + // Set position to start of buffer + this.position = 0; + } +} + +/** + * Updates this binary with byte_value. + * + * @method + * @param {string} byte_value a single byte we wish to write. + */ +Binary.prototype.put = function put(byte_value) { + // If it's a string and a has more than one character throw an error + if (byte_value['length'] != null && typeof byte_value !== 'number' && byte_value.length !== 1) + throw new Error('only accepts single character String, Uint8Array or Array'); + if ((typeof byte_value !== 'number' && byte_value < 0) || byte_value > 255) + throw new Error('only accepts number in a valid unsigned byte range 0-255'); + + // Decode the byte value once + var decoded_byte = null; + if (typeof byte_value === 'string') { + decoded_byte = byte_value.charCodeAt(0); + } else if (byte_value['length'] != null) { + decoded_byte = byte_value[0]; + } else { + decoded_byte = byte_value; + } + + if (this.buffer.length > this.position) { + this.buffer[this.position++] = decoded_byte; + } else { + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + // Create additional overflow buffer + var buffer = new Buffer(Binary.BUFFER_SIZE + this.buffer.length); + // Combine the two buffers together + this.buffer.copy(buffer, 0, 0, this.buffer.length); + this.buffer = buffer; + this.buffer[this.position++] = decoded_byte; + } else { + buffer = null; + // Create a new buffer (typed or normal array) + if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') { + buffer = new Uint8Array(new ArrayBuffer(Binary.BUFFER_SIZE + this.buffer.length)); + } else { + buffer = new Array(Binary.BUFFER_SIZE + this.buffer.length); + } + + // We need to copy all the content to the new array + for (var i = 0; i < this.buffer.length; i++) { + buffer[i] = this.buffer[i]; + } + + // Reassign the buffer + this.buffer = buffer; + // Write the byte + this.buffer[this.position++] = decoded_byte; + } + } +}; + +/** + * Writes a buffer or string to the binary. + * + * @method + * @param {(Buffer|string)} string a string or buffer to be written to the Binary BSON object. + * @param {number} offset specify the binary of where to write the content. + * @return {null} + */ +Binary.prototype.write = function write(string, offset) { + offset = typeof offset === 'number' ? offset : this.position; + + // If the buffer is to small let's extend the buffer + if (this.buffer.length < offset + string.length) { + var buffer = null; + // If we are in node.js + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + buffer = new Buffer(this.buffer.length + string.length); + this.buffer.copy(buffer, 0, 0, this.buffer.length); + } else if (Object.prototype.toString.call(this.buffer) === '[object Uint8Array]') { + // Create a new buffer + buffer = new Uint8Array(new ArrayBuffer(this.buffer.length + string.length)); + // Copy the content + for (var i = 0; i < this.position; i++) { + buffer[i] = this.buffer[i]; + } + } + + // Assign the new buffer + this.buffer = buffer; + } + + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(string) && Buffer.isBuffer(this.buffer)) { + string.copy(this.buffer, offset, 0, string.length); + this.position = offset + string.length > this.position ? offset + string.length : this.position; + // offset = string.length + } else if ( + typeof Buffer !== 'undefined' && + typeof string === 'string' && + Buffer.isBuffer(this.buffer) + ) { + this.buffer.write(string, offset, 'binary'); + this.position = offset + string.length > this.position ? offset + string.length : this.position; + // offset = string.length; + } else if ( + Object.prototype.toString.call(string) === '[object Uint8Array]' || + (Object.prototype.toString.call(string) === '[object Array]' && typeof string !== 'string') + ) { + for (i = 0; i < string.length; i++) { + this.buffer[offset++] = string[i]; + } + + this.position = offset > this.position ? offset : this.position; + } else if (typeof string === 'string') { + for (i = 0; i < string.length; i++) { + this.buffer[offset++] = string.charCodeAt(i); + } + + this.position = offset > this.position ? offset : this.position; + } +}; + +/** + * Reads **length** bytes starting at **position**. + * + * @method + * @param {number} position read from the given position in the Binary. + * @param {number} length the number of bytes to read. + * @return {Buffer} + */ +Binary.prototype.read = function read(position, length) { + length = length && length > 0 ? length : this.position; + + // Let's return the data based on the type we have + if (this.buffer['slice']) { + return this.buffer.slice(position, position + length); + } else { + // Create a buffer to keep the result + var buffer = + typeof Uint8Array !== 'undefined' + ? new Uint8Array(new ArrayBuffer(length)) + : new Array(length); + for (var i = 0; i < length; i++) { + buffer[i] = this.buffer[position++]; + } + } + // Return the buffer + return buffer; +}; + +/** + * Returns the value of this binary as a string. + * + * @method + * @return {string} + */ +Binary.prototype.value = function value(asRaw) { + asRaw = asRaw == null ? false : asRaw; + + // Optimize to serialize for the situation where the data == size of buffer + if ( + asRaw && + typeof Buffer !== 'undefined' && + Buffer.isBuffer(this.buffer) && + this.buffer.length === this.position + ) + return this.buffer; + + // If it's a node.js buffer object + if (typeof Buffer !== 'undefined' && Buffer.isBuffer(this.buffer)) { + return asRaw + ? this.buffer.slice(0, this.position) + : this.buffer.toString('binary', 0, this.position); + } else { + if (asRaw) { + // we support the slice command use it + if (this.buffer['slice'] != null) { + return this.buffer.slice(0, this.position); + } else { + // Create a new buffer to copy content to + var newBuffer = + Object.prototype.toString.call(this.buffer) === '[object Uint8Array]' + ? new Uint8Array(new ArrayBuffer(this.position)) + : new Array(this.position); + // Copy content + for (var i = 0; i < this.position; i++) { + newBuffer[i] = this.buffer[i]; + } + // Return the buffer + return newBuffer; + } + } else { + return convertArraytoUtf8BinaryString(this.buffer, 0, this.position); + } + } +}; + +/** + * Length. + * + * @method + * @return {number} the length of the binary. + */ +Binary.prototype.length = function length() { + return this.position; +}; + +/** + * @ignore + */ +Binary.prototype.toJSON = function() { + return this.buffer != null ? this.buffer.toString('base64') : ''; +}; + +/** + * @ignore + */ +Binary.prototype.toString = function(format) { + return this.buffer != null ? this.buffer.slice(0, this.position).toString(format) : ''; +}; + +/** + * Binary default subtype + * @ignore + */ +var BSON_BINARY_SUBTYPE_DEFAULT = 0; + +/** + * @ignore + */ +var writeStringToArray = function(data) { + // Create a buffer + var buffer = + typeof Uint8Array !== 'undefined' + ? new Uint8Array(new ArrayBuffer(data.length)) + : new Array(data.length); + // Write the content to the buffer + for (var i = 0; i < data.length; i++) { + buffer[i] = data.charCodeAt(i); + } + // Write the string to the buffer + return buffer; +}; + +/** + * Convert Array ot Uint8Array to Binary String + * + * @ignore + */ +var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) { + var result = ''; + for (var i = startIndex; i < endIndex; i++) { + result = result + String.fromCharCode(byteArray[i]); + } + return result; +}; + +Binary.BUFFER_SIZE = 256; + +/** + * Default BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_DEFAULT = 0; +/** + * Function BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_FUNCTION = 1; +/** + * Byte Array BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_BYTE_ARRAY = 2; +/** + * OLD UUID BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_UUID_OLD = 3; +/** + * UUID BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_UUID = 4; +/** + * MD5 BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_MD5 = 5; +/** + * User BSON type + * + * @classconstant SUBTYPE_DEFAULT + **/ +Binary.SUBTYPE_USER_DEFINED = 128; + +/** + * Expose. + */ +module.exports = Binary; +module.exports.Binary = Binary; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/bson.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/bson.js new file mode 100644 index 0000000..956f152 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/bson.js @@ -0,0 +1,385 @@ +'use strict'; + +var Map = require('./map'), + Long = require('./long'), + Double = require('./double'), + Timestamp = require('./timestamp'), + ObjectID = require('./objectid'), + BSONRegExp = require('./regexp'), + Symbol = require('./symbol'), + Int32 = require('./int_32'), + Code = require('./code'), + Decimal128 = require('./decimal128'), + MinKey = require('./min_key'), + MaxKey = require('./max_key'), + DBRef = require('./db_ref'), + Binary = require('./binary'); + +// Parts of the parser +var deserialize = require('./parser/deserializer'), + serializer = require('./parser/serializer'), + calculateObjectSize = require('./parser/calculate_size'); + +/** + * @ignore + * @api private + */ +// Default Max Size +var MAXSIZE = 1024 * 1024 * 17; + +// Current Internal Temporary Serialization Buffer +var buffer = new Buffer(MAXSIZE); + +var BSON = function() {}; + +/** + * Serialize a Javascript object. + * + * @param {Object} object the Javascript object to serialize. + * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @param {Number} [options.minInternalBufferSize=1024*1024*17] minimum size of the internal temporary serialization buffer **(default:1024*1024*17)**. + * @return {Buffer} returns the Buffer object containing the serialized object. + * @api public + */ +BSON.prototype.serialize = function serialize(object, options) { + options = options || {}; + // Unpack the options + var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + var serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + var minInternalBufferSize = + typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE; + + // Resize the internal serialization buffer if needed + if (buffer.length < minInternalBufferSize) { + buffer = new Buffer(minInternalBufferSize); + } + + // Attempt to serialize + var serializationIndex = serializer( + buffer, + object, + checkKeys, + 0, + 0, + serializeFunctions, + ignoreUndefined, + [] + ); + // Create the final buffer + var finishedBuffer = new Buffer(serializationIndex); + // Copy into the finished buffer + buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length); + // Return the buffer + return finishedBuffer; +}; + +/** + * Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization. + * + * @param {Object} object the Javascript object to serialize. + * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object. + * @param {Boolean} [options.checkKeys] the serializer will check if keys are valid. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @param {Number} [options.index] the index in the buffer where we wish to start serializing into. + * @return {Number} returns the index pointing to the last written byte in the buffer. + * @api public + */ +BSON.prototype.serializeWithBufferAndIndex = function(object, finalBuffer, options) { + options = options || {}; + // Unpack the options + var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false; + var serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + var startIndex = typeof options.index === 'number' ? options.index : 0; + + // Attempt to serialize + var serializationIndex = serializer( + finalBuffer, + object, + checkKeys, + startIndex || 0, + 0, + serializeFunctions, + ignoreUndefined + ); + + // Return the index + return serializationIndex - 1; +}; + +/** + * Deserialize data as BSON. + * + * @param {Buffer} buffer the buffer containing the serialized set of BSON documents. + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Object} returns the deserialized Javascript Object. + * @api public + */ +BSON.prototype.deserialize = function(buffer, options) { + return deserialize(buffer, options); +}; + +/** + * Calculate the bson size for a passed in Javascript object. + * + * @param {Object} object the Javascript object to calculate the BSON byte size for. + * @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions **(default:false)**. + * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields **(default:true)**. + * @return {Number} returns the number of bytes the BSON object will take up. + * @api public + */ +BSON.prototype.calculateObjectSize = function(object, options) { + options = options || {}; + + var serializeFunctions = + typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false; + var ignoreUndefined = + typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true; + + return calculateObjectSize(object, serializeFunctions, ignoreUndefined); +}; + +/** + * Deserialize stream data as BSON documents. + * + * @param {Buffer} data the buffer containing the serialized set of BSON documents. + * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start. + * @param {Number} numberOfDocuments number of documents to deserialize. + * @param {Array} documents an array where to store the deserialized documents. + * @param {Number} docStartIndex the index in the documents array from where to start inserting documents. + * @param {Object} [options] additional options used for the deserialization. + * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized. + * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse. + * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function. + * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits + * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance. + * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types. + * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer. + * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances. + * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents. + * @api public + */ +BSON.prototype.deserializeStream = function( + data, + startIndex, + numberOfDocuments, + documents, + docStartIndex, + options +) { + options = options != null ? options : {}; + var index = startIndex; + // Loop over all documents + for (var i = 0; i < numberOfDocuments; i++) { + // Find size of the document + var size = + data[index] | (data[index + 1] << 8) | (data[index + 2] << 16) | (data[index + 3] << 24); + // Update options with index + options['index'] = index; + // Parse the document at this point + documents[docStartIndex + i] = this.deserialize(data, options); + // Adjust index by the document size + index = index + size; + } + + // Return object containing end index of parsing and list of documents + return index; +}; + +/** + * @ignore + * @api private + */ +// BSON MAX VALUES +BSON.BSON_INT32_MAX = 0x7fffffff; +BSON.BSON_INT32_MIN = -0x80000000; + +BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; +BSON.BSON_INT64_MIN = -Math.pow(2, 63); + +// JS MAX PRECISE VALUES +BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. +BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + +// Internal long versions +// var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. +// var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + +/** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ +BSON.BSON_DATA_NUMBER = 1; +/** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ +BSON.BSON_DATA_STRING = 2; +/** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ +BSON.BSON_DATA_OBJECT = 3; +/** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ +BSON.BSON_DATA_ARRAY = 4; +/** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ +BSON.BSON_DATA_BINARY = 5; +/** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ +BSON.BSON_DATA_OID = 7; +/** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ +BSON.BSON_DATA_BOOLEAN = 8; +/** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ +BSON.BSON_DATA_DATE = 9; +/** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ +BSON.BSON_DATA_NULL = 10; +/** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ +BSON.BSON_DATA_REGEXP = 11; +/** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ +BSON.BSON_DATA_CODE = 13; +/** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ +BSON.BSON_DATA_SYMBOL = 14; +/** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ +BSON.BSON_DATA_CODE_W_SCOPE = 15; +/** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ +BSON.BSON_DATA_INT = 16; +/** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ +BSON.BSON_DATA_TIMESTAMP = 17; +/** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ +BSON.BSON_DATA_LONG = 18; +/** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ +BSON.BSON_DATA_MIN_KEY = 0xff; +/** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ +BSON.BSON_DATA_MAX_KEY = 0x7f; + +/** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ +BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ +BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ +BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ +BSON.BSON_BINARY_SUBTYPE_UUID = 3; +/** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ +BSON.BSON_BINARY_SUBTYPE_MD5 = 4; +/** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ +BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + +// Return BSON +module.exports = BSON; +module.exports.Code = Code; +module.exports.Map = Map; +module.exports.Symbol = Symbol; +module.exports.BSON = BSON; +module.exports.DBRef = DBRef; +module.exports.Binary = Binary; +module.exports.ObjectID = ObjectID; +module.exports.Long = Long; +module.exports.Timestamp = Timestamp; +module.exports.Double = Double; +module.exports.Int32 = Int32; +module.exports.MinKey = MinKey; +module.exports.MaxKey = MaxKey; +module.exports.BSONRegExp = BSONRegExp; +module.exports.Decimal128 = Decimal128; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/code.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/code.js new file mode 100644 index 0000000..c2984cd --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/code.js @@ -0,0 +1,24 @@ +/** + * A class representation of the BSON Code type. + * + * @class + * @param {(string|function)} code a string or function. + * @param {Object} [scope] an optional scope for the function. + * @return {Code} + */ +var Code = function Code(code, scope) { + if (!(this instanceof Code)) return new Code(code, scope); + this._bsontype = 'Code'; + this.code = code; + this.scope = scope; +}; + +/** + * @ignore + */ +Code.prototype.toJSON = function() { + return { scope: this.scope, code: this.code }; +}; + +module.exports = Code; +module.exports.Code = Code; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/db_ref.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/db_ref.js new file mode 100644 index 0000000..f95795b --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/db_ref.js @@ -0,0 +1,32 @@ +/** + * A class representation of the BSON DBRef type. + * + * @class + * @param {string} namespace the collection name. + * @param {ObjectID} oid the reference ObjectID. + * @param {string} [db] optional db name, if omitted the reference is local to the current db. + * @return {DBRef} + */ +function DBRef(namespace, oid, db) { + if (!(this instanceof DBRef)) return new DBRef(namespace, oid, db); + + this._bsontype = 'DBRef'; + this.namespace = namespace; + this.oid = oid; + this.db = db; +} + +/** + * @ignore + * @api private + */ +DBRef.prototype.toJSON = function() { + return { + $ref: this.namespace, + $id: this.oid, + $db: this.db == null ? '' : this.db + }; +}; + +module.exports = DBRef; +module.exports.DBRef = DBRef; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/decimal128.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/decimal128.js new file mode 100644 index 0000000..1dc2f00 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/decimal128.js @@ -0,0 +1,818 @@ +'use strict'; + +var Long = require('./long'); + +var PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/; +var PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i; +var PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i; + +var EXPONENT_MAX = 6111; +var EXPONENT_MIN = -6176; +var EXPONENT_BIAS = 6176; +var MAX_DIGITS = 34; + +// Nan value bits as 32 bit values (due to lack of longs) +var NAN_BUFFER = [ + 0x7c, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 +].reverse(); +// Infinity value bits 32 bit values (due to lack of longs) +var INF_NEGATIVE_BUFFER = [ + 0xf8, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 +].reverse(); +var INF_POSITIVE_BUFFER = [ + 0x78, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00 +].reverse(); + +var EXPONENT_REGEX = /^([-+])?(\d+)?$/; + +// Detect if the value is a digit +var isDigit = function(value) { + return !isNaN(parseInt(value, 10)); +}; + +// Divide two uint128 values +var divideu128 = function(value) { + var DIVISOR = Long.fromNumber(1000 * 1000 * 1000); + var _rem = Long.fromNumber(0); + var i = 0; + + if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) { + return { quotient: value, rem: _rem }; + } + + for (i = 0; i <= 3; i++) { + // Adjust remainder to match value of next dividend + _rem = _rem.shiftLeft(32); + // Add the divided to _rem + _rem = _rem.add(new Long(value.parts[i], 0)); + value.parts[i] = _rem.div(DIVISOR).low_; + _rem = _rem.modulo(DIVISOR); + } + + return { quotient: value, rem: _rem }; +}; + +// Multiply two Long values and return the 128 bit value +var multiply64x2 = function(left, right) { + if (!left && !right) { + return { high: Long.fromNumber(0), low: Long.fromNumber(0) }; + } + + var leftHigh = left.shiftRightUnsigned(32); + var leftLow = new Long(left.getLowBits(), 0); + var rightHigh = right.shiftRightUnsigned(32); + var rightLow = new Long(right.getLowBits(), 0); + + var productHigh = leftHigh.multiply(rightHigh); + var productMid = leftHigh.multiply(rightLow); + var productMid2 = leftLow.multiply(rightHigh); + var productLow = leftLow.multiply(rightLow); + + productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); + productMid = new Long(productMid.getLowBits(), 0) + .add(productMid2) + .add(productLow.shiftRightUnsigned(32)); + + productHigh = productHigh.add(productMid.shiftRightUnsigned(32)); + productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0)); + + // Return the 128 bit result + return { high: productHigh, low: productLow }; +}; + +var lessThan = function(left, right) { + // Make values unsigned + var uhleft = left.high_ >>> 0; + var uhright = right.high_ >>> 0; + + // Compare high bits first + if (uhleft < uhright) { + return true; + } else if (uhleft === uhright) { + var ulleft = left.low_ >>> 0; + var ulright = right.low_ >>> 0; + if (ulleft < ulright) return true; + } + + return false; +}; + +// var longtoHex = function(value) { +// var buffer = new Buffer(8); +// var index = 0; +// // Encode the low 64 bits of the decimal +// // Encode low bits +// buffer[index++] = value.low_ & 0xff; +// buffer[index++] = (value.low_ >> 8) & 0xff; +// buffer[index++] = (value.low_ >> 16) & 0xff; +// buffer[index++] = (value.low_ >> 24) & 0xff; +// // Encode high bits +// buffer[index++] = value.high_ & 0xff; +// buffer[index++] = (value.high_ >> 8) & 0xff; +// buffer[index++] = (value.high_ >> 16) & 0xff; +// buffer[index++] = (value.high_ >> 24) & 0xff; +// return buffer.reverse().toString('hex'); +// }; + +// var int32toHex = function(value) { +// var buffer = new Buffer(4); +// var index = 0; +// // Encode the low 64 bits of the decimal +// // Encode low bits +// buffer[index++] = value & 0xff; +// buffer[index++] = (value >> 8) & 0xff; +// buffer[index++] = (value >> 16) & 0xff; +// buffer[index++] = (value >> 24) & 0xff; +// return buffer.reverse().toString('hex'); +// }; + +/** + * A class representation of the BSON Decimal128 type. + * + * @class + * @param {Buffer} bytes a buffer containing the raw Decimal128 bytes. + * @return {Double} + */ +var Decimal128 = function(bytes) { + this._bsontype = 'Decimal128'; + this.bytes = bytes; +}; + +/** + * Create a Decimal128 instance from a string representation + * + * @method + * @param {string} string a numeric string representation. + * @return {Decimal128} returns a Decimal128 instance. + */ +Decimal128.fromString = function(string) { + // Parse state tracking + var isNegative = false; + var sawRadix = false; + var foundNonZero = false; + + // Total number of significant digits (no leading or trailing zero) + var significantDigits = 0; + // Total number of significand digits read + var nDigitsRead = 0; + // Total number of digits (no leading zeros) + var nDigits = 0; + // The number of the digits after radix + var radixPosition = 0; + // The index of the first non-zero in *str* + var firstNonZero = 0; + + // Digits Array + var digits = [0]; + // The number of digits in digits + var nDigitsStored = 0; + // Insertion pointer for digits + var digitsInsert = 0; + // The index of the first non-zero digit + var firstDigit = 0; + // The index of the last digit + var lastDigit = 0; + + // Exponent + var exponent = 0; + // loop index over array + var i = 0; + // The high 17 digits of the significand + var significandHigh = [0, 0]; + // The low 17 digits of the significand + var significandLow = [0, 0]; + // The biased exponent + var biasedExponent = 0; + + // Read index + var index = 0; + + // Trim the string + string = string.trim(); + + // Naively prevent against REDOS attacks. + // TODO: implementing a custom parsing for this, or refactoring the regex would yield + // further gains. + if (string.length >= 7000) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Results + var stringMatch = string.match(PARSE_STRING_REGEXP); + var infMatch = string.match(PARSE_INF_REGEXP); + var nanMatch = string.match(PARSE_NAN_REGEXP); + + // Validate the string + if ((!stringMatch && !infMatch && !nanMatch) || string.length === 0) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Check if we have an illegal exponent format + if (stringMatch && stringMatch[4] && stringMatch[2] === undefined) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Get the negative or positive sign + if (string[index] === '+' || string[index] === '-') { + isNegative = string[index++] === '-'; + } + + // Check if user passed Infinity or NaN + if (!isDigit(string[index]) && string[index] !== '.') { + if (string[index] === 'i' || string[index] === 'I') { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } else if (string[index] === 'N') { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + } + + // Read all the digits + while (isDigit(string[index]) || string[index] === '.') { + if (string[index] === '.') { + if (sawRadix) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + sawRadix = true; + index = index + 1; + continue; + } + + if (nDigitsStored < 34) { + if (string[index] !== '0' || foundNonZero) { + if (!foundNonZero) { + firstNonZero = nDigitsRead; + } + + foundNonZero = true; + + // Only store 34 digits + digits[digitsInsert++] = parseInt(string[index], 10); + nDigitsStored = nDigitsStored + 1; + } + } + + if (foundNonZero) { + nDigits = nDigits + 1; + } + + if (sawRadix) { + radixPosition = radixPosition + 1; + } + + nDigitsRead = nDigitsRead + 1; + index = index + 1; + } + + if (sawRadix && !nDigitsRead) { + throw new Error('' + string + ' not a valid Decimal128 string'); + } + + // Read exponent if exists + if (string[index] === 'e' || string[index] === 'E') { + // Read exponent digits + var match = string.substr(++index).match(EXPONENT_REGEX); + + // No digits read + if (!match || !match[2]) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + // Get exponent + exponent = parseInt(match[0], 10); + + // Adjust the index + index = index + match[0].length; + } + + // Return not a number + if (string[index]) { + return new Decimal128(new Buffer(NAN_BUFFER)); + } + + // Done reading input + // Find first non-zero digit in digits + firstDigit = 0; + + if (!nDigitsStored) { + firstDigit = 0; + lastDigit = 0; + digits[0] = 0; + nDigits = 1; + nDigitsStored = 1; + significantDigits = 0; + } else { + lastDigit = nDigitsStored - 1; + significantDigits = nDigits; + + if (exponent !== 0 && significantDigits !== 1) { + while (string[firstNonZero + significantDigits - 1] === '0') { + significantDigits = significantDigits - 1; + } + } + } + + // Normalization of exponent + // Correct exponent based on radix position, and shift significand as needed + // to represent user input + + // Overflow prevention + if (exponent <= radixPosition && radixPosition - exponent > 1 << 14) { + exponent = EXPONENT_MIN; + } else { + exponent = exponent - radixPosition; + } + + // Attempt to normalize the exponent + while (exponent > EXPONENT_MAX) { + // Shift exponent to significand and decrease + lastDigit = lastDigit + 1; + + if (lastDigit - firstDigit > MAX_DIGITS) { + // Check if we have a zero then just hard clamp, otherwise fail + var digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } else { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + + exponent = exponent - 1; + } + + while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) { + // Shift last digit + if (lastDigit === 0) { + exponent = EXPONENT_MIN; + significantDigits = 0; + break; + } + + if (nDigitsStored < nDigits) { + // adjust to match digits not stored + nDigits = nDigits - 1; + } else { + // adjust to round + lastDigit = lastDigit - 1; + } + + if (exponent < EXPONENT_MAX) { + exponent = exponent + 1; + } else { + // Check if we have a zero then just hard clamp, otherwise fail + digitsString = digits.join(''); + if (digitsString.match(/^0+$/)) { + exponent = EXPONENT_MAX; + break; + } else { + return new Decimal128(new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER)); + } + } + } + + // Round + // We've normalized the exponent, but might still need to round. + if (lastDigit - firstDigit + 1 < significantDigits && string[significantDigits] !== '0') { + var endOfString = nDigitsRead; + + // If we have seen a radix point, 'string' is 1 longer than we have + // documented with ndigits_read, so inc the position of the first nonzero + // digit and the position that digits are read to. + if (sawRadix && exponent === EXPONENT_MIN) { + firstNonZero = firstNonZero + 1; + endOfString = endOfString + 1; + } + + var roundDigit = parseInt(string[firstNonZero + lastDigit + 1], 10); + var roundBit = 0; + + if (roundDigit >= 5) { + roundBit = 1; + + if (roundDigit === 5) { + roundBit = digits[lastDigit] % 2 === 1; + + for (i = firstNonZero + lastDigit + 2; i < endOfString; i++) { + if (parseInt(string[i], 10)) { + roundBit = 1; + break; + } + } + } + } + + if (roundBit) { + var dIdx = lastDigit; + + for (; dIdx >= 0; dIdx--) { + if (++digits[dIdx] > 9) { + digits[dIdx] = 0; + + // overflowed most significant digit + if (dIdx === 0) { + if (exponent < EXPONENT_MAX) { + exponent = exponent + 1; + digits[dIdx] = 1; + } else { + return new Decimal128( + new Buffer(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER) + ); + } + } + } else { + break; + } + } + } + } + + // Encode significand + // The high 17 digits of the significand + significandHigh = Long.fromNumber(0); + // The low 17 digits of the significand + significandLow = Long.fromNumber(0); + + // read a zero + if (significantDigits === 0) { + significandHigh = Long.fromNumber(0); + significandLow = Long.fromNumber(0); + } else if (lastDigit - firstDigit < 17) { + dIdx = firstDigit; + significandLow = Long.fromNumber(digits[dIdx++]); + significandHigh = new Long(0, 0); + + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(Long.fromNumber(10)); + significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); + } + } else { + dIdx = firstDigit; + significandHigh = Long.fromNumber(digits[dIdx++]); + + for (; dIdx <= lastDigit - 17; dIdx++) { + significandHigh = significandHigh.multiply(Long.fromNumber(10)); + significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx])); + } + + significandLow = Long.fromNumber(digits[dIdx++]); + + for (; dIdx <= lastDigit; dIdx++) { + significandLow = significandLow.multiply(Long.fromNumber(10)); + significandLow = significandLow.add(Long.fromNumber(digits[dIdx])); + } + } + + var significand = multiply64x2(significandHigh, Long.fromString('100000000000000000')); + + significand.low = significand.low.add(significandLow); + + if (lessThan(significand.low, significandLow)) { + significand.high = significand.high.add(Long.fromNumber(1)); + } + + // Biased exponent + biasedExponent = exponent + EXPONENT_BIAS; + var dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) }; + + // Encode combination, exponent, and significand. + if ( + significand.high + .shiftRightUnsigned(49) + .and(Long.fromNumber(1)) + .equals(Long.fromNumber) + ) { + // Encode '11' into bits 1 to 3 + dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61)); + dec.high = dec.high.or( + Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47)) + ); + dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff))); + } else { + dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49)); + dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff))); + } + + dec.low = significand.low; + + // Encode sign + if (isNegative) { + dec.high = dec.high.or(Long.fromString('9223372036854775808')); + } + + // Encode into a buffer + var buffer = new Buffer(16); + index = 0; + + // Encode the low 64 bits of the decimal + // Encode low bits + buffer[index++] = dec.low.low_ & 0xff; + buffer[index++] = (dec.low.low_ >> 8) & 0xff; + buffer[index++] = (dec.low.low_ >> 16) & 0xff; + buffer[index++] = (dec.low.low_ >> 24) & 0xff; + // Encode high bits + buffer[index++] = dec.low.high_ & 0xff; + buffer[index++] = (dec.low.high_ >> 8) & 0xff; + buffer[index++] = (dec.low.high_ >> 16) & 0xff; + buffer[index++] = (dec.low.high_ >> 24) & 0xff; + + // Encode the high 64 bits of the decimal + // Encode low bits + buffer[index++] = dec.high.low_ & 0xff; + buffer[index++] = (dec.high.low_ >> 8) & 0xff; + buffer[index++] = (dec.high.low_ >> 16) & 0xff; + buffer[index++] = (dec.high.low_ >> 24) & 0xff; + // Encode high bits + buffer[index++] = dec.high.high_ & 0xff; + buffer[index++] = (dec.high.high_ >> 8) & 0xff; + buffer[index++] = (dec.high.high_ >> 16) & 0xff; + buffer[index++] = (dec.high.high_ >> 24) & 0xff; + + // Return the new Decimal128 + return new Decimal128(buffer); +}; + +// Extract least significant 5 bits +var COMBINATION_MASK = 0x1f; +// Extract least significant 14 bits +var EXPONENT_MASK = 0x3fff; +// Value of combination field for Inf +var COMBINATION_INFINITY = 30; +// Value of combination field for NaN +var COMBINATION_NAN = 31; +// Value of combination field for NaN +// var COMBINATION_SNAN = 32; +// decimal128 exponent bias +EXPONENT_BIAS = 6176; + +/** + * Create a string representation of the raw Decimal128 value + * + * @method + * @return {string} returns a Decimal128 string representation. + */ +Decimal128.prototype.toString = function() { + // Note: bits in this routine are referred to starting at 0, + // from the sign bit, towards the coefficient. + + // bits 0 - 31 + var high; + // bits 32 - 63 + var midh; + // bits 64 - 95 + var midl; + // bits 96 - 127 + var low; + // bits 1 - 5 + var combination; + // decoded biased exponent (14 bits) + var biased_exponent; + // the number of significand digits + var significand_digits = 0; + // the base-10 digits in the significand + var significand = new Array(36); + for (var i = 0; i < significand.length; i++) significand[i] = 0; + // read pointer into significand + var index = 0; + + // unbiased exponent + var exponent; + // the exponent if scientific notation is used + var scientific_exponent; + + // true if the number is zero + var is_zero = false; + + // the most signifcant significand bits (50-46) + var significand_msb; + // temporary storage for significand decoding + var significand128 = { parts: new Array(4) }; + // indexing variables + i; + var j, k; + + // Output string + var string = []; + + // Unpack index + index = 0; + + // Buffer reference + var buffer = this.bytes; + + // Unpack the low 64bits into a long + low = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + midl = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + + // Unpack the high 64bits into a long + midh = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + high = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + + // Unpack index + index = 0; + + // Create the state of the decimal + var dec = { + low: new Long(low, midl), + high: new Long(midh, high) + }; + + if (dec.high.lessThan(Long.ZERO)) { + string.push('-'); + } + + // Decode combination field and exponent + combination = (high >> 26) & COMBINATION_MASK; + + if (combination >> 3 === 3) { + // Check for 'special' values + if (combination === COMBINATION_INFINITY) { + return string.join('') + 'Infinity'; + } else if (combination === COMBINATION_NAN) { + return 'NaN'; + } else { + biased_exponent = (high >> 15) & EXPONENT_MASK; + significand_msb = 0x08 + ((high >> 14) & 0x01); + } + } else { + significand_msb = (high >> 14) & 0x07; + biased_exponent = (high >> 17) & EXPONENT_MASK; + } + + exponent = biased_exponent - EXPONENT_BIAS; + + // Create string of significand digits + + // Convert the 114-bit binary number represented by + // (significand_high, significand_low) to at most 34 decimal + // digits through modulo and division. + significand128.parts[0] = (high & 0x3fff) + ((significand_msb & 0xf) << 14); + significand128.parts[1] = midh; + significand128.parts[2] = midl; + significand128.parts[3] = low; + + if ( + significand128.parts[0] === 0 && + significand128.parts[1] === 0 && + significand128.parts[2] === 0 && + significand128.parts[3] === 0 + ) { + is_zero = true; + } else { + for (k = 3; k >= 0; k--) { + var least_digits = 0; + // Peform the divide + var result = divideu128(significand128); + significand128 = result.quotient; + least_digits = result.rem.low_; + + // We now have the 9 least significant digits (in base 2). + // Convert and output to string. + if (!least_digits) continue; + + for (j = 8; j >= 0; j--) { + // significand[k * 9 + j] = Math.round(least_digits % 10); + significand[k * 9 + j] = least_digits % 10; + // least_digits = Math.round(least_digits / 10); + least_digits = Math.floor(least_digits / 10); + } + } + } + + // Output format options: + // Scientific - [-]d.dddE(+/-)dd or [-]dE(+/-)dd + // Regular - ddd.ddd + + if (is_zero) { + significand_digits = 1; + significand[index] = 0; + } else { + significand_digits = 36; + i = 0; + + while (!significand[index]) { + i++; + significand_digits = significand_digits - 1; + index = index + 1; + } + } + + scientific_exponent = significand_digits - 1 + exponent; + + // The scientific exponent checks are dictated by the string conversion + // specification and are somewhat arbitrary cutoffs. + // + // We must check exponent > 0, because if this is the case, the number + // has trailing zeros. However, we *cannot* output these trailing zeros, + // because doing so would change the precision of the value, and would + // change stored data if the string converted number is round tripped. + + if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) { + // Scientific format + string.push(significand[index++]); + significand_digits = significand_digits - 1; + + if (significand_digits) { + string.push('.'); + } + + for (i = 0; i < significand_digits; i++) { + string.push(significand[index++]); + } + + // Exponent + string.push('E'); + if (scientific_exponent > 0) { + string.push('+' + scientific_exponent); + } else { + string.push(scientific_exponent); + } + } else { + // Regular format with no decimal place + if (exponent >= 0) { + for (i = 0; i < significand_digits; i++) { + string.push(significand[index++]); + } + } else { + var radix_position = significand_digits + exponent; + + // non-zero digits before radix + if (radix_position > 0) { + for (i = 0; i < radix_position; i++) { + string.push(significand[index++]); + } + } else { + string.push('0'); + } + + string.push('.'); + // add leading zeros after radix + while (radix_position++ < 0) { + string.push('0'); + } + + for (i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) { + string.push(significand[index++]); + } + } + } + + return string.join(''); +}; + +Decimal128.prototype.toJSON = function() { + return { $numberDecimal: this.toString() }; +}; + +module.exports = Decimal128; +module.exports.Decimal128 = Decimal128; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/double.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/double.js new file mode 100644 index 0000000..523c21f --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/double.js @@ -0,0 +1,33 @@ +/** + * A class representation of the BSON Double type. + * + * @class + * @param {number} value the number we want to represent as a double. + * @return {Double} + */ +function Double(value) { + if (!(this instanceof Double)) return new Double(value); + + this._bsontype = 'Double'; + this.value = value; +} + +/** + * Access the number value. + * + * @method + * @return {number} returns the wrapped double number. + */ +Double.prototype.valueOf = function() { + return this.value; +}; + +/** + * @ignore + */ +Double.prototype.toJSON = function() { + return this.value; +}; + +module.exports = Double; +module.exports.Double = Double; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/float_parser.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/float_parser.js new file mode 100644 index 0000000..0054a2f --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/float_parser.js @@ -0,0 +1,124 @@ +// Copyright (c) 2008, Fair Oaks Labs, Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// +// Modifications to writeIEEE754 to support negative zeroes made by Brian White + +var readIEEE754 = function(buffer, offset, endian, mLen, nBytes) { + var e, + m, + bBE = endian === 'big', + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + nBits = -7, + i = bBE ? 0 : nBytes - 1, + d = bBE ? 1 : -1, + s = buffer[offset + i]; + + i += d; + + e = s & ((1 << -nBits) - 1); + s >>= -nBits; + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + + m = e & ((1 << -nBits) - 1); + e >>= -nBits; + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : (s ? -1 : 1) * Infinity; + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); +}; + +var writeIEEE754 = function(buffer, value, offset, endian, mLen, nBytes) { + var e, + m, + c, + bBE = endian === 'big', + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, + i = bBE ? nBytes - 1 : 0, + d = bBE ? -1 : 1, + s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + + buffer[offset + i - d] |= s * 128; +}; + +exports.readIEEE754 = readIEEE754; +exports.writeIEEE754 = writeIEEE754; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/int_32.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/int_32.js new file mode 100644 index 0000000..85dbdec --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/int_32.js @@ -0,0 +1,33 @@ +/** + * A class representation of a BSON Int32 type. + * + * @class + * @param {number} value the number we want to represent as an int32. + * @return {Int32} + */ +var Int32 = function(value) { + if (!(this instanceof Int32)) return new Int32(value); + + this._bsontype = 'Int32'; + this.value = value; +}; + +/** + * Access the number value. + * + * @method + * @return {number} returns the wrapped int32 number. + */ +Int32.prototype.valueOf = function() { + return this.value; +}; + +/** + * @ignore + */ +Int32.prototype.toJSON = function() { + return this.value; +}; + +module.exports = Int32; +module.exports.Int32 = Int32; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/long.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/long.js new file mode 100644 index 0000000..78215aa --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/long.js @@ -0,0 +1,851 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2009 Google Inc. All Rights Reserved + +/** + * Defines a Long class for representing a 64-bit two's-complement + * integer value, which faithfully simulates the behavior of a Java "Long". This + * implementation is derived from LongLib in GWT. + * + * Constructs a 64-bit two's-complement integer, given its low and high 32-bit + * values as *signed* integers. See the from* functions below for more + * convenient ways of constructing Longs. + * + * The internal representation of a Long is the two given signed, 32-bit values. + * We use 32-bit pieces because these are the size of integers on which + * Javascript performs bit-operations. For operations like addition and + * multiplication, we split each number into 16-bit pieces, which can easily be + * multiplied within Javascript's floating-point representation without overflow + * or change in sign. + * + * In the algorithms below, we frequently reduce the negative case to the + * positive case by negating the input(s) and then post-processing the result. + * Note that we must ALWAYS check specially whether those values are MIN_VALUE + * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as + * a positive number, it overflows back into a negative). Not handling this + * case would often result in infinite recursion. + * + * @class + * @param {number} low the low (signed) 32 bits of the Long. + * @param {number} high the high (signed) 32 bits of the Long. + * @return {Long} + */ +function Long(low, high) { + if (!(this instanceof Long)) return new Long(low, high); + + this._bsontype = 'Long'; + /** + * @type {number} + * @ignore + */ + this.low_ = low | 0; // force into 32 signed bits. + + /** + * @type {number} + * @ignore + */ + this.high_ = high | 0; // force into 32 signed bits. +} + +/** + * Return the int value. + * + * @method + * @return {number} the value, assuming it is a 32-bit integer. + */ +Long.prototype.toInt = function() { + return this.low_; +}; + +/** + * Return the Number value. + * + * @method + * @return {number} the closest floating-point representation to this value. + */ +Long.prototype.toNumber = function() { + return this.high_ * Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned(); +}; + +/** + * Return the JSON value. + * + * @method + * @return {string} the JSON representation. + */ +Long.prototype.toJSON = function() { + return this.toString(); +}; + +/** + * Return the String value. + * + * @method + * @param {number} [opt_radix] the radix in which the text should be written. + * @return {string} the textual representation of this value. + */ +Long.prototype.toString = function(opt_radix) { + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (this.isZero()) { + return '0'; + } + + if (this.isNegative()) { + if (this.equals(Long.MIN_VALUE)) { + // We need to change the Long value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixLong = Long.fromNumber(radix); + var div = this.div(radixLong); + var rem = div.multiply(radixLong).subtract(this); + return div.toString(radix) + rem.toInt().toString(radix); + } else { + return '-' + this.negate().toString(radix); + } + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Math.pow(radix, 6)); + + rem = this; + var result = ''; + + while (!rem.isZero()) { + var remDiv = rem.div(radixToPower); + var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); + var digits = intval.toString(radix); + + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } else { + while (digits.length < 6) { + digits = '0' + digits; + } + result = '' + digits + result; + } + } +}; + +/** + * Return the high 32-bits value. + * + * @method + * @return {number} the high 32-bits as a signed value. + */ +Long.prototype.getHighBits = function() { + return this.high_; +}; + +/** + * Return the low 32-bits value. + * + * @method + * @return {number} the low 32-bits as a signed value. + */ +Long.prototype.getLowBits = function() { + return this.low_; +}; + +/** + * Return the low unsigned 32-bits value. + * + * @method + * @return {number} the low 32-bits as an unsigned value. + */ +Long.prototype.getLowBitsUnsigned = function() { + return this.low_ >= 0 ? this.low_ : Long.TWO_PWR_32_DBL_ + this.low_; +}; + +/** + * Returns the number of bits needed to represent the absolute value of this Long. + * + * @method + * @return {number} Returns the number of bits needed to represent the absolute value of this Long. + */ +Long.prototype.getNumBitsAbs = function() { + if (this.isNegative()) { + if (this.equals(Long.MIN_VALUE)) { + return 64; + } else { + return this.negate().getNumBitsAbs(); + } + } else { + var val = this.high_ !== 0 ? this.high_ : this.low_; + for (var bit = 31; bit > 0; bit--) { + if ((val & (1 << bit)) !== 0) { + break; + } + } + return this.high_ !== 0 ? bit + 33 : bit + 1; + } +}; + +/** + * Return whether this value is zero. + * + * @method + * @return {boolean} whether this value is zero. + */ +Long.prototype.isZero = function() { + return this.high_ === 0 && this.low_ === 0; +}; + +/** + * Return whether this value is negative. + * + * @method + * @return {boolean} whether this value is negative. + */ +Long.prototype.isNegative = function() { + return this.high_ < 0; +}; + +/** + * Return whether this value is odd. + * + * @method + * @return {boolean} whether this value is odd. + */ +Long.prototype.isOdd = function() { + return (this.low_ & 1) === 1; +}; + +/** + * Return whether this Long equals the other + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long equals the other + */ +Long.prototype.equals = function(other) { + return this.high_ === other.high_ && this.low_ === other.low_; +}; + +/** + * Return whether this Long does not equal the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long does not equal the other. + */ +Long.prototype.notEquals = function(other) { + return this.high_ !== other.high_ || this.low_ !== other.low_; +}; + +/** + * Return whether this Long is less than the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is less than the other. + */ +Long.prototype.lessThan = function(other) { + return this.compare(other) < 0; +}; + +/** + * Return whether this Long is less than or equal to the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is less than or equal to the other. + */ +Long.prototype.lessThanOrEqual = function(other) { + return this.compare(other) <= 0; +}; + +/** + * Return whether this Long is greater than the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is greater than the other. + */ +Long.prototype.greaterThan = function(other) { + return this.compare(other) > 0; +}; + +/** + * Return whether this Long is greater than or equal to the other. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} whether this Long is greater than or equal to the other. + */ +Long.prototype.greaterThanOrEqual = function(other) { + return this.compare(other) >= 0; +}; + +/** + * Compares this Long with the given one. + * + * @method + * @param {Long} other Long to compare against. + * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater. + */ +Long.prototype.compare = function(other) { + if (this.equals(other)) { + return 0; + } + + var thisNeg = this.isNegative(); + var otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) { + return -1; + } + if (!thisNeg && otherNeg) { + return 1; + } + + // at this point, the signs are the same, so subtraction will not overflow + if (this.subtract(other).isNegative()) { + return -1; + } else { + return 1; + } +}; + +/** + * The negation of this value. + * + * @method + * @return {Long} the negation of this value. + */ +Long.prototype.negate = function() { + if (this.equals(Long.MIN_VALUE)) { + return Long.MIN_VALUE; + } else { + return this.not().add(Long.ONE); + } +}; + +/** + * Returns the sum of this and the given Long. + * + * @method + * @param {Long} other Long to add to this one. + * @return {Long} the sum of this and the given Long. + */ +Long.prototype.add = function(other) { + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 + b48; + c48 &= 0xffff; + return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32); +}; + +/** + * Returns the difference of this and the given Long. + * + * @method + * @param {Long} other Long to subtract from this. + * @return {Long} the difference of this and the given Long. + */ +Long.prototype.subtract = function(other) { + return this.add(other.negate()); +}; + +/** + * Returns the product of this and the given Long. + * + * @method + * @param {Long} other Long to multiply with this. + * @return {Long} the product of this and the other. + */ +Long.prototype.multiply = function(other) { + if (this.isZero()) { + return Long.ZERO; + } else if (other.isZero()) { + return Long.ZERO; + } + + if (this.equals(Long.MIN_VALUE)) { + return other.isOdd() ? Long.MIN_VALUE : Long.ZERO; + } else if (other.equals(Long.MIN_VALUE)) { + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().multiply(other.negate()); + } else { + return this.negate() + .multiply(other) + .negate(); + } + } else if (other.isNegative()) { + return this.multiply(other.negate()).negate(); + } + + // If both Longs are small, use float multiplication + if (this.lessThan(Long.TWO_PWR_24_) && other.lessThan(Long.TWO_PWR_24_)) { + return Long.fromNumber(this.toNumber() * other.toNumber()); + } + + // Divide each Long into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xffff; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xffff; + return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32); +}; + +/** + * Returns this Long divided by the given one. + * + * @method + * @param {Long} other Long by which to divide. + * @return {Long} this Long divided by the given one. + */ +Long.prototype.div = function(other) { + if (other.isZero()) { + throw Error('division by zero'); + } else if (this.isZero()) { + return Long.ZERO; + } + + if (this.equals(Long.MIN_VALUE)) { + if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) { + return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + } else if (other.equals(Long.MIN_VALUE)) { + return Long.ONE; + } else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shiftRight(1); + var approx = halfThis.div(other).shiftLeft(1); + if (approx.equals(Long.ZERO)) { + return other.isNegative() ? Long.ONE : Long.NEG_ONE; + } else { + var rem = this.subtract(other.multiply(approx)); + var result = approx.add(rem.div(other)); + return result; + } + } + } else if (other.equals(Long.MIN_VALUE)) { + return Long.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().div(other.negate()); + } else { + return this.negate() + .div(other) + .negate(); + } + } else if (other.isNegative()) { + return this.div(other.negate()).negate(); + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + var res = Long.ZERO; + rem = this; + while (rem.greaterThanOrEqual(other)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2); + var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + var approxRes = Long.fromNumber(approx); + var approxRem = approxRes.multiply(other); + while (approxRem.isNegative() || approxRem.greaterThan(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx); + approxRem = approxRes.multiply(other); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) { + approxRes = Long.ONE; + } + + res = res.add(approxRes); + rem = rem.subtract(approxRem); + } + return res; +}; + +/** + * Returns this Long modulo the given one. + * + * @method + * @param {Long} other Long by which to mod. + * @return {Long} this Long modulo the given one. + */ +Long.prototype.modulo = function(other) { + return this.subtract(this.div(other).multiply(other)); +}; + +/** + * The bitwise-NOT of this value. + * + * @method + * @return {Long} the bitwise-NOT of this value. + */ +Long.prototype.not = function() { + return Long.fromBits(~this.low_, ~this.high_); +}; + +/** + * Returns the bitwise-AND of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to AND. + * @return {Long} the bitwise-AND of this and the other. + */ +Long.prototype.and = function(other) { + return Long.fromBits(this.low_ & other.low_, this.high_ & other.high_); +}; + +/** + * Returns the bitwise-OR of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to OR. + * @return {Long} the bitwise-OR of this and the other. + */ +Long.prototype.or = function(other) { + return Long.fromBits(this.low_ | other.low_, this.high_ | other.high_); +}; + +/** + * Returns the bitwise-XOR of this Long and the given one. + * + * @method + * @param {Long} other the Long with which to XOR. + * @return {Long} the bitwise-XOR of this and the other. + */ +Long.prototype.xor = function(other) { + return Long.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_); +}; + +/** + * Returns this Long with bits shifted to the left by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the left by the given amount. + */ +Long.prototype.shiftLeft = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var low = this.low_; + if (numBits < 32) { + var high = this.high_; + return Long.fromBits(low << numBits, (high << numBits) | (low >>> (32 - numBits))); + } else { + return Long.fromBits(0, low << (numBits - 32)); + } + } +}; + +/** + * Returns this Long with bits shifted to the right by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the right by the given amount. + */ +Long.prototype.shiftRight = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >> numBits); + } else { + return Long.fromBits(high >> (numBits - 32), high >= 0 ? 0 : -1); + } + } +}; + +/** + * Returns this Long with bits shifted to the right by the given amount, with the new top bits matching the current sign bit. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Long} this shifted to the right by the given amount, with zeros placed into the new leading bits. + */ +Long.prototype.shiftRightUnsigned = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits); + } else if (numBits === 32) { + return Long.fromBits(high, 0); + } else { + return Long.fromBits(high >>> (numBits - 32), 0); + } + } +}; + +/** + * Returns a Long representing the given (32-bit) integer value. + * + * @method + * @param {number} value the 32-bit integer in question. + * @return {Long} the corresponding Long value. + */ +Long.fromInt = function(value) { + if (-128 <= value && value < 128) { + var cachedObj = Long.INT_CACHE_[value]; + if (cachedObj) { + return cachedObj; + } + } + + var obj = new Long(value | 0, value < 0 ? -1 : 0); + if (-128 <= value && value < 128) { + Long.INT_CACHE_[value] = obj; + } + return obj; +}; + +/** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * + * @method + * @param {number} value the number in question. + * @return {Long} the corresponding Long value. + */ +Long.fromNumber = function(value) { + if (isNaN(value) || !isFinite(value)) { + return Long.ZERO; + } else if (value <= -Long.TWO_PWR_63_DBL_) { + return Long.MIN_VALUE; + } else if (value + 1 >= Long.TWO_PWR_63_DBL_) { + return Long.MAX_VALUE; + } else if (value < 0) { + return Long.fromNumber(-value).negate(); + } else { + return new Long((value % Long.TWO_PWR_32_DBL_) | 0, (value / Long.TWO_PWR_32_DBL_) | 0); + } +}; + +/** + * Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits. + * + * @method + * @param {number} lowBits the low 32-bits. + * @param {number} highBits the high 32-bits. + * @return {Long} the corresponding Long value. + */ +Long.fromBits = function(lowBits, highBits) { + return new Long(lowBits, highBits); +}; + +/** + * Returns a Long representation of the given string, written using the given radix. + * + * @method + * @param {string} str the textual representation of the Long. + * @param {number} opt_radix the radix in which the text is written. + * @return {Long} the corresponding Long value. + */ +Long.fromString = function(str, opt_radix) { + if (str.length === 0) { + throw Error('number format error: empty string'); + } + + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (str.charAt(0) === '-') { + return Long.fromString(str.substring(1), radix).negate(); + } else if (str.indexOf('-') >= 0) { + throw Error('number format error: interior "-" character: ' + str); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Math.pow(radix, 8)); + + var result = Long.ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i); + var value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Math.pow(radix, size)); + result = result.multiply(power).add(Long.fromNumber(value)); + } else { + result = result.multiply(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + return result; +}; + +// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the +// from* methods on which they depend. + +/** + * A cache of the Long representations of small integer values. + * @type {Object} + * @ignore + */ +Long.INT_CACHE_ = {}; + +// NOTE: the compiler should inline these constant values below and then remove +// these variables, so there should be no runtime penalty for these. + +/** + * Number used repeated below in calculations. This must appear before the + * first call to any from* function below. + * @type {number} + * @ignore + */ +Long.TWO_PWR_16_DBL_ = 1 << 16; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_24_DBL_ = 1 << 24; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_32_DBL_ = Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_31_DBL_ = Long.TWO_PWR_32_DBL_ / 2; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_48_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_64_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_; + +/** + * @type {number} + * @ignore + */ +Long.TWO_PWR_63_DBL_ = Long.TWO_PWR_64_DBL_ / 2; + +/** @type {Long} */ +Long.ZERO = Long.fromInt(0); + +/** @type {Long} */ +Long.ONE = Long.fromInt(1); + +/** @type {Long} */ +Long.NEG_ONE = Long.fromInt(-1); + +/** @type {Long} */ +Long.MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0); + +/** @type {Long} */ +Long.MIN_VALUE = Long.fromBits(0, 0x80000000 | 0); + +/** + * @type {Long} + * @ignore + */ +Long.TWO_PWR_24_ = Long.fromInt(1 << 24); + +/** + * Expose. + */ +module.exports = Long; +module.exports.Long = Long; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/map.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/map.js new file mode 100644 index 0000000..7edb4f2 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/map.js @@ -0,0 +1,128 @@ +'use strict'; + +// We have an ES6 Map available, return the native instance +if (typeof global.Map !== 'undefined') { + module.exports = global.Map; + module.exports.Map = global.Map; +} else { + // We will return a polyfill + var Map = function(array) { + this._keys = []; + this._values = {}; + + for (var i = 0; i < array.length; i++) { + if (array[i] == null) continue; // skip null and undefined + var entry = array[i]; + var key = entry[0]; + var value = entry[1]; + // Add the key to the list of keys in order + this._keys.push(key); + // Add the key and value to the values dictionary with a point + // to the location in the ordered keys list + this._values[key] = { v: value, i: this._keys.length - 1 }; + } + }; + + Map.prototype.clear = function() { + this._keys = []; + this._values = {}; + }; + + Map.prototype.delete = function(key) { + var value = this._values[key]; + if (value == null) return false; + // Delete entry + delete this._values[key]; + // Remove the key from the ordered keys list + this._keys.splice(value.i, 1); + return true; + }; + + Map.prototype.entries = function() { + var self = this; + var index = 0; + + return { + next: function() { + var key = self._keys[index++]; + return { + value: key !== undefined ? [key, self._values[key].v] : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + Map.prototype.forEach = function(callback, self) { + self = self || this; + + for (var i = 0; i < this._keys.length; i++) { + var key = this._keys[i]; + // Call the forEach callback + callback.call(self, this._values[key].v, key, self); + } + }; + + Map.prototype.get = function(key) { + return this._values[key] ? this._values[key].v : undefined; + }; + + Map.prototype.has = function(key) { + return this._values[key] != null; + }; + + Map.prototype.keys = function() { + var self = this; + var index = 0; + + return { + next: function() { + var key = self._keys[index++]; + return { + value: key !== undefined ? key : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + Map.prototype.set = function(key, value) { + if (this._values[key]) { + this._values[key].v = value; + return this; + } + + // Add the key to the list of keys in order + this._keys.push(key); + // Add the key and value to the values dictionary with a point + // to the location in the ordered keys list + this._values[key] = { v: value, i: this._keys.length - 1 }; + return this; + }; + + Map.prototype.values = function() { + var self = this; + var index = 0; + + return { + next: function() { + var key = self._keys[index++]; + return { + value: key !== undefined ? self._values[key].v : undefined, + done: key !== undefined ? false : true + }; + } + }; + }; + + // Last ismaster + Object.defineProperty(Map.prototype, 'size', { + enumerable: true, + get: function() { + return this._keys.length; + } + }); + + module.exports = Map; + module.exports.Map = Map; +} diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/max_key.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/max_key.js new file mode 100644 index 0000000..eebca7b --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/max_key.js @@ -0,0 +1,14 @@ +/** + * A class representation of the BSON MaxKey type. + * + * @class + * @return {MaxKey} A MaxKey instance + */ +function MaxKey() { + if (!(this instanceof MaxKey)) return new MaxKey(); + + this._bsontype = 'MaxKey'; +} + +module.exports = MaxKey; +module.exports.MaxKey = MaxKey; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/min_key.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/min_key.js new file mode 100644 index 0000000..15f4522 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/min_key.js @@ -0,0 +1,14 @@ +/** + * A class representation of the BSON MinKey type. + * + * @class + * @return {MinKey} A MinKey instance + */ +function MinKey() { + if (!(this instanceof MinKey)) return new MinKey(); + + this._bsontype = 'MinKey'; +} + +module.exports = MinKey; +module.exports.MinKey = MinKey; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/objectid.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/objectid.js new file mode 100644 index 0000000..f76ecbb --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/objectid.js @@ -0,0 +1,387 @@ +// Custom inspect property name / symbol. +var inspect = 'inspect'; + +/** + * Machine id. + * + * Create a random 3-byte value (i.e. unique for this + * process). Other drivers use a md5 of the machine id here, but + * that would mean an asyc call to gethostname, so we don't bother. + * @ignore + */ +var MACHINE_ID = parseInt(Math.random() * 0xffffff, 10); + +// Regular expression that checks for hex value +var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$'); + +// Check if buffer exists +try { + if (Buffer && Buffer.from) { + var hasBufferType = true; + inspect = require('util').inspect.custom || 'inspect'; + } +} catch (err) { + hasBufferType = false; +} + +/** +* Create a new ObjectID instance +* +* @class +* @param {(string|number)} id Can be a 24 byte hex string, 12 byte binary string or a Number. +* @property {number} generationTime The generation time of this ObjectId instance +* @return {ObjectID} instance of ObjectID. +*/ +var ObjectID = function ObjectID(id) { + // Duck-typing to support ObjectId from different npm packages + if (id instanceof ObjectID) return id; + if (!(this instanceof ObjectID)) return new ObjectID(id); + + this._bsontype = 'ObjectID'; + + // The most common usecase (blank id, new objectId instance) + if (id == null || typeof id === 'number') { + // Generate a new id + this.id = this.generate(id); + // If we are caching the hex string + if (ObjectID.cacheHexString) this.__id = this.toString('hex'); + // Return the object + return; + } + + // Check if the passed in id is valid + var valid = ObjectID.isValid(id); + + // Throw an error if it's not a valid setup + if (!valid && id != null) { + throw new Error( + 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters' + ); + } else if (valid && typeof id === 'string' && id.length === 24 && hasBufferType) { + return new ObjectID(new Buffer(id, 'hex')); + } else if (valid && typeof id === 'string' && id.length === 24) { + return ObjectID.createFromHexString(id); + } else if (id != null && id.length === 12) { + // assume 12 byte string + this.id = id; + } else if (id != null && id.toHexString) { + // Duck-typing to support ObjectId from different npm packages + return id; + } else { + throw new Error( + 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters' + ); + } + + if (ObjectID.cacheHexString) this.__id = this.toString('hex'); +}; + +// Allow usage of ObjectId as well as ObjectID +// var ObjectId = ObjectID; + +// Precomputed hex table enables speedy hex string conversion +var hexTable = []; +for (var i = 0; i < 256; i++) { + hexTable[i] = (i <= 15 ? '0' : '') + i.toString(16); +} + +/** +* Return the ObjectID id as a 24 byte hex string representation +* +* @method +* @return {string} return the 24 byte hex string representation. +*/ +ObjectID.prototype.toHexString = function() { + if (ObjectID.cacheHexString && this.__id) return this.__id; + + var hexString = ''; + if (!this.id || !this.id.length) { + throw new Error( + 'invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is [' + + JSON.stringify(this.id) + + ']' + ); + } + + if (this.id instanceof _Buffer) { + hexString = convertToHex(this.id); + if (ObjectID.cacheHexString) this.__id = hexString; + return hexString; + } + + for (var i = 0; i < this.id.length; i++) { + hexString += hexTable[this.id.charCodeAt(i)]; + } + + if (ObjectID.cacheHexString) this.__id = hexString; + return hexString; +}; + +/** +* Update the ObjectID index used in generating new ObjectID's on the driver +* +* @method +* @return {number} returns next index value. +* @ignore +*/ +ObjectID.prototype.get_inc = function() { + return (ObjectID.index = (ObjectID.index + 1) % 0xffffff); +}; + +/** +* Update the ObjectID index used in generating new ObjectID's on the driver +* +* @method +* @return {number} returns next index value. +* @ignore +*/ +ObjectID.prototype.getInc = function() { + return this.get_inc(); +}; + +/** +* Generate a 12 byte id buffer used in ObjectID's +* +* @method +* @param {number} [time] optional parameter allowing to pass in a second based timestamp. +* @return {Buffer} return the 12 byte id buffer string. +*/ +ObjectID.prototype.generate = function(time) { + if ('number' !== typeof time) { + time = ~~(Date.now() / 1000); + } + + // Use pid + var pid = + (typeof process === 'undefined' || process.pid === 1 + ? Math.floor(Math.random() * 100000) + : process.pid) % 0xffff; + var inc = this.get_inc(); + // Buffer used + var buffer = new Buffer(12); + // Encode time + buffer[3] = time & 0xff; + buffer[2] = (time >> 8) & 0xff; + buffer[1] = (time >> 16) & 0xff; + buffer[0] = (time >> 24) & 0xff; + // Encode machine + buffer[6] = MACHINE_ID & 0xff; + buffer[5] = (MACHINE_ID >> 8) & 0xff; + buffer[4] = (MACHINE_ID >> 16) & 0xff; + // Encode pid + buffer[8] = pid & 0xff; + buffer[7] = (pid >> 8) & 0xff; + // Encode index + buffer[11] = inc & 0xff; + buffer[10] = (inc >> 8) & 0xff; + buffer[9] = (inc >> 16) & 0xff; + // Return the buffer + return buffer; +}; + +/** +* Converts the id into a 24 byte hex string for printing +* +* @param {String} format The Buffer toString format parameter. +* @return {String} return the 24 byte hex string representation. +* @ignore +*/ +ObjectID.prototype.toString = function(format) { + // Is the id a buffer then use the buffer toString method to return the format + if (this.id && this.id.copy) { + return this.id.toString(typeof format === 'string' ? format : 'hex'); + } + + // if(this.buffer ) + return this.toHexString(); +}; + +/** +* Converts to a string representation of this Id. +* +* @return {String} return the 24 byte hex string representation. +* @ignore +*/ +ObjectID.prototype[inspect] = ObjectID.prototype.toString; + +/** +* Converts to its JSON representation. +* +* @return {String} return the 24 byte hex string representation. +* @ignore +*/ +ObjectID.prototype.toJSON = function() { + return this.toHexString(); +}; + +/** +* Compares the equality of this ObjectID with `otherID`. +* +* @method +* @param {object} otherID ObjectID instance to compare against. +* @return {boolean} the result of comparing two ObjectID's +*/ +ObjectID.prototype.equals = function equals(otherId) { + // var id; + + if (otherId instanceof ObjectID) { + return this.toString() === otherId.toString(); + } else if ( + typeof otherId === 'string' && + ObjectID.isValid(otherId) && + otherId.length === 12 && + this.id instanceof _Buffer + ) { + return otherId === this.id.toString('binary'); + } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 24) { + return otherId.toLowerCase() === this.toHexString(); + } else if (typeof otherId === 'string' && ObjectID.isValid(otherId) && otherId.length === 12) { + return otherId === this.id; + } else if (otherId != null && (otherId instanceof ObjectID || otherId.toHexString)) { + return otherId.toHexString() === this.toHexString(); + } else { + return false; + } +}; + +/** +* Returns the generation date (accurate up to the second) that this ID was generated. +* +* @method +* @return {date} the generation date +*/ +ObjectID.prototype.getTimestamp = function() { + var timestamp = new Date(); + var time = this.id[3] | (this.id[2] << 8) | (this.id[1] << 16) | (this.id[0] << 24); + timestamp.setTime(Math.floor(time) * 1000); + return timestamp; +}; + +/** +* @ignore +*/ +ObjectID.index = ~~(Math.random() * 0xffffff); + +/** +* @ignore +*/ +ObjectID.createPk = function createPk() { + return new ObjectID(); +}; + +/** +* Creates an ObjectID from a second based number, with the rest of the ObjectID zeroed out. Used for comparisons or sorting the ObjectID. +* +* @method +* @param {number} time an integer number representing a number of seconds. +* @return {ObjectID} return the created ObjectID +*/ +ObjectID.createFromTime = function createFromTime(time) { + var buffer = new Buffer([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + // Encode time into first 4 bytes + buffer[3] = time & 0xff; + buffer[2] = (time >> 8) & 0xff; + buffer[1] = (time >> 16) & 0xff; + buffer[0] = (time >> 24) & 0xff; + // Return the new objectId + return new ObjectID(buffer); +}; + +// Lookup tables +//var encodeLookup = '0123456789abcdef'.split(''); +var decodeLookup = []; +i = 0; +while (i < 10) decodeLookup[0x30 + i] = i++; +while (i < 16) decodeLookup[0x41 - 10 + i] = decodeLookup[0x61 - 10 + i] = i++; + +var _Buffer = Buffer; +var convertToHex = function(bytes) { + return bytes.toString('hex'); +}; + +/** +* Creates an ObjectID from a hex string representation of an ObjectID. +* +* @method +* @param {string} hexString create a ObjectID from a passed in 24 byte hexstring. +* @return {ObjectID} return the created ObjectID +*/ +ObjectID.createFromHexString = function createFromHexString(string) { + // Throw an error if it's not a valid setup + if (typeof string === 'undefined' || (string != null && string.length !== 24)) { + throw new Error( + 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters' + ); + } + + // Use Buffer.from method if available + if (hasBufferType) return new ObjectID(new Buffer(string, 'hex')); + + // Calculate lengths + var array = new _Buffer(12); + var n = 0; + var i = 0; + + while (i < 24) { + array[n++] = (decodeLookup[string.charCodeAt(i++)] << 4) | decodeLookup[string.charCodeAt(i++)]; + } + + return new ObjectID(array); +}; + +/** +* Checks if a value is a valid bson ObjectId +* +* @method +* @return {boolean} return true if the value is a valid bson ObjectId, return false otherwise. +*/ +ObjectID.isValid = function isValid(id) { + if (id == null) return false; + + if (typeof id === 'number') { + return true; + } + + if (typeof id === 'string') { + return id.length === 12 || (id.length === 24 && checkForHexRegExp.test(id)); + } + + if (id instanceof ObjectID) { + return true; + } + + if (id instanceof _Buffer) { + return true; + } + + // Duck-Typing detection of ObjectId like objects + if (id.toHexString) { + return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id)); + } + + return false; +}; + +/** +* @ignore +*/ +Object.defineProperty(ObjectID.prototype, 'generationTime', { + enumerable: true, + get: function() { + return this.id[3] | (this.id[2] << 8) | (this.id[1] << 16) | (this.id[0] << 24); + }, + set: function(value) { + // Encode time into first 4 bytes + this.id[3] = value & 0xff; + this.id[2] = (value >> 8) & 0xff; + this.id[1] = (value >> 16) & 0xff; + this.id[0] = (value >> 24) & 0xff; + } +}); + +/** + * Expose. + */ +module.exports = ObjectID; +module.exports.ObjectID = ObjectID; +module.exports.ObjectId = ObjectID; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/calculate_size.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/calculate_size.js new file mode 100644 index 0000000..f174519 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/calculate_size.js @@ -0,0 +1,255 @@ +'use strict'; + +var Long = require('../long').Long, + Double = require('../double').Double, + Timestamp = require('../timestamp').Timestamp, + ObjectID = require('../objectid').ObjectID, + Symbol = require('../symbol').Symbol, + BSONRegExp = require('../regexp').BSONRegExp, + Code = require('../code').Code, + Decimal128 = require('../decimal128'), + MinKey = require('../min_key').MinKey, + MaxKey = require('../max_key').MaxKey, + DBRef = require('../db_ref').DBRef, + Binary = require('../binary').Binary; + +var normalizedFunctionString = require('./utils').normalizedFunctionString; + +// To ensure that 0.4 of node works correctly +var isDate = function isDate(d) { + return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]'; +}; + +var calculateObjectSize = function calculateObjectSize( + object, + serializeFunctions, + ignoreUndefined +) { + var totalLength = 4 + 1; + + if (Array.isArray(object)) { + for (var i = 0; i < object.length; i++) { + totalLength += calculateElement( + i.toString(), + object[i], + serializeFunctions, + true, + ignoreUndefined + ); + } + } else { + // If we have toBSON defined, override the current object + if (object.toBSON) { + object = object.toBSON(); + } + + // Calculate size + for (var key in object) { + totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined); + } + } + + return totalLength; +}; + +/** + * @ignore + * @api private + */ +function calculateElement(name, value, serializeFunctions, isArray, ignoreUndefined) { + // If we have toBSON defined, override the current object + if (value && value.toBSON) { + value = value.toBSON(); + } + + switch (typeof value) { + case 'string': + return 1 + Buffer.byteLength(name, 'utf8') + 1 + 4 + Buffer.byteLength(value, 'utf8') + 1; + case 'number': + if (Math.floor(value) === value && value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + if (value >= BSON.BSON_INT32_MIN && value <= BSON.BSON_INT32_MAX) { + // 32 bit + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (4 + 1); + } else { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + } else { + // 64 bit + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } + case 'undefined': + if (isArray || !ignoreUndefined) + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + return 0; + case 'boolean': + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 1); + case 'object': + if ( + value == null || + value instanceof MinKey || + value instanceof MaxKey || + value['_bsontype'] === 'MinKey' || + value['_bsontype'] === 'MaxKey' + ) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + 1; + } else if (value instanceof ObjectID || value['_bsontype'] === 'ObjectID') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1); + } else if (value instanceof Date || isDate(value)) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.length + ); + } else if ( + value instanceof Long || + value instanceof Double || + value instanceof Timestamp || + value['_bsontype'] === 'Long' || + value['_bsontype'] === 'Double' || + value['_bsontype'] === 'Timestamp' + ) { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1); + } else if (value instanceof Decimal128 || value['_bsontype'] === 'Decimal128') { + return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (16 + 1); + } else if (value instanceof Code || value['_bsontype'] === 'Code') { + // Calculate size depending on the availability of a scope + if (value.scope != null && Object.keys(value.scope).length > 0) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + Buffer.byteLength(value.code.toString(), 'utf8') + + 1 + + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined) + ); + } else { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + Buffer.byteLength(value.code.toString(), 'utf8') + + 1 + ); + } + } else if (value instanceof Binary || value['_bsontype'] === 'Binary') { + // Check what kind of subtype we have + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + (value.position + 1 + 4 + 1 + 4) + ); + } else { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (value.position + 1 + 4 + 1) + ); + } + } else if (value instanceof Symbol || value['_bsontype'] === 'Symbol') { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + Buffer.byteLength(value.value, 'utf8') + + 4 + + 1 + + 1 + ); + } else if (value instanceof DBRef || value['_bsontype'] === 'DBRef') { + // Set up correct object for serialization + var ordered_values = { + $ref: value.namespace, + $id: value.oid + }; + + // Add db reference if it exists + if (null != value.db) { + ordered_values['$db'] = value.db; + } + + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + calculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined) + ); + } else if ( + value instanceof RegExp || + Object.prototype.toString.call(value) === '[object RegExp]' + ) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + Buffer.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1 + ); + } else if (value instanceof BSONRegExp || value['_bsontype'] === 'BSONRegExp') { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + Buffer.byteLength(value.pattern, 'utf8') + + 1 + + Buffer.byteLength(value.options, 'utf8') + + 1 + ); + } else { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + calculateObjectSize(value, serializeFunctions, ignoreUndefined) + + 1 + ); + } + case 'function': + // WTF for 0.4.X where typeof /someregexp/ === 'function' + if ( + value instanceof RegExp || + Object.prototype.toString.call(value) === '[object RegExp]' || + String.call(value) === '[object RegExp]' + ) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + Buffer.byteLength(value.source, 'utf8') + + 1 + + (value.global ? 1 : 0) + + (value.ignoreCase ? 1 : 0) + + (value.multiline ? 1 : 0) + + 1 + ); + } else { + if (serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + 4 + + Buffer.byteLength(normalizedFunctionString(value), 'utf8') + + 1 + + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined) + ); + } else if (serializeFunctions) { + return ( + (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + + 1 + + 4 + + Buffer.byteLength(normalizedFunctionString(value), 'utf8') + + 1 + ); + } + } + } + + return 0; +} + +var BSON = {}; + +// BSON MAX VALUES +BSON.BSON_INT32_MAX = 0x7fffffff; +BSON.BSON_INT32_MIN = -0x80000000; + +// JS MAX PRECISE VALUES +BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. +BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + +module.exports = calculateObjectSize; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/deserializer.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/deserializer.js new file mode 100644 index 0000000..b7f45d7 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/deserializer.js @@ -0,0 +1,780 @@ +'use strict'; + +var Long = require('../long').Long, + Double = require('../double').Double, + Timestamp = require('../timestamp').Timestamp, + ObjectID = require('../objectid').ObjectID, + Symbol = require('../symbol').Symbol, + Code = require('../code').Code, + MinKey = require('../min_key').MinKey, + MaxKey = require('../max_key').MaxKey, + Decimal128 = require('../decimal128'), + Int32 = require('../int_32'), + DBRef = require('../db_ref').DBRef, + BSONRegExp = require('../regexp').BSONRegExp, + Binary = require('../binary').Binary; + +var deserialize = function(buffer, options, isArray) { + options = options == null ? {} : options; + var index = options && options.index ? options.index : 0; + // Read the document size + var size = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + + // Ensure buffer is valid size + if (size < 5 || buffer.length < size || size + index > buffer.length) { + throw new Error('corrupt bson message'); + } + + // Illegal end value + if (buffer[index + size - 1] !== 0) { + throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00"); + } + + // Start deserializtion + return deserializeObject(buffer, index, options, isArray); +}; + +var deserializeObject = function(buffer, index, options, isArray) { + var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions']; + var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions']; + var cacheFunctionsCrc32 = + options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32']; + + if (!cacheFunctionsCrc32) var crc32 = null; + + var fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw']; + + // Return raw bson buffer instead of parsing it + var raw = options['raw'] == null ? false : options['raw']; + + // Return BSONRegExp objects instead of native regular expressions + var bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false; + + // Controls the promotion of values vs wrapper classes + var promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers']; + var promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs']; + var promoteValues = options['promoteValues'] == null ? true : options['promoteValues']; + + // Set the start index + var startIndex = index; + + // Validate that we have at least 4 bytes of buffer + if (buffer.length < 5) throw new Error('corrupt bson message < 5 bytes long'); + + // Read the document size + var size = + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24); + + // Ensure buffer is valid size + if (size < 5 || size > buffer.length) throw new Error('corrupt bson message'); + + // Create holding object + var object = isArray ? [] : {}; + // Used for arrays to skip having to perform utf8 decoding + var arrayIndex = 0; + + var done = false; + + // While we have more left data left keep parsing + // while (buffer[index + 1] !== 0) { + while (!done) { + // Read the type + var elementType = buffer[index++]; + // If we get a zero it's the last byte, exit + if (elementType === 0) break; + + // Get the start search index + var i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + var name = isArray ? arrayIndex++ : buffer.toString('utf8', index, i); + + index = i + 1; + + if (elementType === BSON.BSON_DATA_STRING) { + var stringSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if ( + stringSize <= 0 || + stringSize > buffer.length - index || + buffer[index + stringSize - 1] !== 0 + ) + throw new Error('bad string length in bson'); + object[name] = buffer.toString('utf8', index, index + stringSize - 1); + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_OID) { + var oid = new Buffer(12); + buffer.copy(oid, 0, index, index + 12); + object[name] = new ObjectID(oid); + index = index + 12; + } else if (elementType === BSON.BSON_DATA_INT && promoteValues === false) { + object[name] = new Int32( + buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24) + ); + } else if (elementType === BSON.BSON_DATA_INT) { + object[name] = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + } else if (elementType === BSON.BSON_DATA_NUMBER && promoteValues === false) { + object[name] = new Double(buffer.readDoubleLE(index)); + index = index + 8; + } else if (elementType === BSON.BSON_DATA_NUMBER) { + object[name] = buffer.readDoubleLE(index); + index = index + 8; + } else if (elementType === BSON.BSON_DATA_DATE) { + var lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + var highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + object[name] = new Date(new Long(lowBits, highBits).toNumber()); + } else if (elementType === BSON.BSON_DATA_BOOLEAN) { + if (buffer[index] !== 0 && buffer[index] !== 1) throw new Error('illegal boolean type value'); + object[name] = buffer[index++] === 1; + } else if (elementType === BSON.BSON_DATA_OBJECT) { + var _index = index; + var objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + if (objectSize <= 0 || objectSize > buffer.length - index) + throw new Error('bad embedded document length in bson'); + + // We have a raw value + if (raw) { + object[name] = buffer.slice(index, index + objectSize); + } else { + object[name] = deserializeObject(buffer, _index, options, false); + } + + index = index + objectSize; + } else if (elementType === BSON.BSON_DATA_ARRAY) { + _index = index; + objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + var arrayOptions = options; + + // Stop index + var stopIndex = index + objectSize; + + // All elements of array to be returned as raw bson + if (fieldsAsRaw && fieldsAsRaw[name]) { + arrayOptions = {}; + for (var n in options) arrayOptions[n] = options[n]; + arrayOptions['raw'] = true; + } + + object[name] = deserializeObject(buffer, _index, arrayOptions, true); + index = index + objectSize; + + if (buffer[index - 1] !== 0) throw new Error('invalid array terminator byte'); + if (index !== stopIndex) throw new Error('corrupted array bson'); + } else if (elementType === BSON.BSON_DATA_UNDEFINED) { + object[name] = undefined; + } else if (elementType === BSON.BSON_DATA_NULL) { + object[name] = null; + } else if (elementType === BSON.BSON_DATA_LONG) { + // Unpack the low and high bits + lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + var long = new Long(lowBits, highBits); + // Promote the long if possible + if (promoteLongs && promoteValues === true) { + object[name] = + long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) + ? long.toNumber() + : long; + } else { + object[name] = long; + } + } else if (elementType === BSON.BSON_DATA_DECIMAL128) { + // Buffer to contain the decimal bytes + var bytes = new Buffer(16); + // Copy the next 16 bytes into the bytes buffer + buffer.copy(bytes, 0, index, index + 16); + // Update index + index = index + 16; + // Assign the new Decimal128 value + var decimal128 = new Decimal128(bytes); + // If we have an alternative mapper use that + object[name] = decimal128.toObject ? decimal128.toObject() : decimal128; + } else if (elementType === BSON.BSON_DATA_BINARY) { + var binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + var totalBinarySize = binarySize; + var subType = buffer[index++]; + + // Did we have a negative binary size, throw + if (binarySize < 0) throw new Error('Negative binary type element size found'); + + // Is the length longer than the document + if (binarySize > buffer.length) throw new Error('Binary type size larger than document size'); + + // Decode as raw Buffer object if options specifies it + if (buffer['slice'] != null) { + // If we have subtype 2 skip the 4 bytes for the size + if (subType === Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if (binarySize < 0) + throw new Error('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new Error('Binary type with subtype 0x02 contains to long binary size'); + if (binarySize < totalBinarySize - 4) + throw new Error('Binary type with subtype 0x02 contains to short binary size'); + } + + if (promoteBuffers && promoteValues) { + object[name] = buffer.slice(index, index + binarySize); + } else { + object[name] = new Binary(buffer.slice(index, index + binarySize), subType); + } + } else { + var _buffer = + typeof Uint8Array !== 'undefined' + ? new Uint8Array(new ArrayBuffer(binarySize)) + : new Array(binarySize); + // If we have subtype 2 skip the 4 bytes for the size + if (subType === Binary.SUBTYPE_BYTE_ARRAY) { + binarySize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if (binarySize < 0) + throw new Error('Negative binary type element size found for subtype 0x02'); + if (binarySize > totalBinarySize - 4) + throw new Error('Binary type with subtype 0x02 contains to long binary size'); + if (binarySize < totalBinarySize - 4) + throw new Error('Binary type with subtype 0x02 contains to short binary size'); + } + + // Copy the data + for (i = 0; i < binarySize; i++) { + _buffer[i] = buffer[index + i]; + } + + if (promoteBuffers && promoteValues) { + object[name] = _buffer; + } else { + object[name] = new Binary(_buffer, subType); + } + } + + // Update the index + index = index + binarySize; + } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === false) { + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + var source = buffer.toString('utf8', index, i); + // Create the regexp + index = i + 1; + + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + var regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // For each option add the corresponding one for javascript + var optionsArray = new Array(regExpOptions.length); + + // Parse options + for (i = 0; i < regExpOptions.length; i++) { + switch (regExpOptions[i]) { + case 'm': + optionsArray[i] = 'm'; + break; + case 's': + optionsArray[i] = 'g'; + break; + case 'i': + optionsArray[i] = 'i'; + break; + } + } + + object[name] = new RegExp(source, optionsArray.join('')); + } else if (elementType === BSON.BSON_DATA_REGEXP && bsonRegExp === true) { + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + source = buffer.toString('utf8', index, i); + index = i + 1; + + // Get the start search index + i = index; + // Locate the end of the c string + while (buffer[i] !== 0x00 && i < buffer.length) { + i++; + } + // If are at the end of the buffer there is a problem with the document + if (i >= buffer.length) throw new Error('Bad BSON Document: illegal CString'); + // Return the C string + regExpOptions = buffer.toString('utf8', index, i); + index = i + 1; + + // Set the object + object[name] = new BSONRegExp(source, regExpOptions); + } else if (elementType === BSON.BSON_DATA_SYMBOL) { + stringSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if ( + stringSize <= 0 || + stringSize > buffer.length - index || + buffer[index + stringSize - 1] !== 0 + ) + throw new Error('bad string length in bson'); + object[name] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1)); + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_TIMESTAMP) { + lowBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + highBits = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + object[name] = new Timestamp(lowBits, highBits); + } else if (elementType === BSON.BSON_DATA_MIN_KEY) { + object[name] = new MinKey(); + } else if (elementType === BSON.BSON_DATA_MAX_KEY) { + object[name] = new MaxKey(); + } else if (elementType === BSON.BSON_DATA_CODE) { + stringSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + if ( + stringSize <= 0 || + stringSize > buffer.length - index || + buffer[index + stringSize - 1] !== 0 + ) + throw new Error('bad string length in bson'); + var functionString = buffer.toString('utf8', index, index + stringSize - 1); + + // If we are evaluating the functions + if (evalFunctions) { + // If we have cache enabled let's look for the md5 of the function in the cache + if (cacheFunctions) { + var hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString; + // Got to do this to avoid V8 deoptimizing the call due to finding eval + object[name] = isolateEvalWithHash(functionCache, hash, functionString, object); + } else { + object[name] = isolateEval(functionString); + } + } else { + object[name] = new Code(functionString); + } + + // Update parse index position + index = index + stringSize; + } else if (elementType === BSON.BSON_DATA_CODE_W_SCOPE) { + var totalSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + + // Element cannot be shorter than totalSize + stringSize + documentSize + terminator + if (totalSize < 4 + 4 + 4 + 1) { + throw new Error('code_w_scope total size shorter minimum expected length'); + } + + // Get the code string size + stringSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + // Check if we have a valid string + if ( + stringSize <= 0 || + stringSize > buffer.length - index || + buffer[index + stringSize - 1] !== 0 + ) + throw new Error('bad string length in bson'); + + // Javascript function + functionString = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + // Parse the element + _index = index; + // Decode the size of the object document + objectSize = + buffer[index] | + (buffer[index + 1] << 8) | + (buffer[index + 2] << 16) | + (buffer[index + 3] << 24); + // Decode the scope object + var scopeObject = deserializeObject(buffer, _index, options, false); + // Adjust the index + index = index + objectSize; + + // Check if field length is to short + if (totalSize < 4 + 4 + objectSize + stringSize) { + throw new Error('code_w_scope total size is to short, truncating scope'); + } + + // Check if totalSize field is to long + if (totalSize > 4 + 4 + objectSize + stringSize) { + throw new Error('code_w_scope total size is to long, clips outer document'); + } + + // If we are evaluating the functions + if (evalFunctions) { + // If we have cache enabled let's look for the md5 of the function in the cache + if (cacheFunctions) { + hash = cacheFunctionsCrc32 ? crc32(functionString) : functionString; + // Got to do this to avoid V8 deoptimizing the call due to finding eval + object[name] = isolateEvalWithHash(functionCache, hash, functionString, object); + } else { + object[name] = isolateEval(functionString); + } + + object[name].scope = scopeObject; + } else { + object[name] = new Code(functionString, scopeObject); + } + } else if (elementType === BSON.BSON_DATA_DBPOINTER) { + // Get the code string size + stringSize = + buffer[index++] | + (buffer[index++] << 8) | + (buffer[index++] << 16) | + (buffer[index++] << 24); + // Check if we have a valid string + if ( + stringSize <= 0 || + stringSize > buffer.length - index || + buffer[index + stringSize - 1] !== 0 + ) + throw new Error('bad string length in bson'); + // Namespace + var namespace = buffer.toString('utf8', index, index + stringSize - 1); + // Update parse index position + index = index + stringSize; + + // Read the oid + var oidBuffer = new Buffer(12); + buffer.copy(oidBuffer, 0, index, index + 12); + oid = new ObjectID(oidBuffer); + + // Update the index + index = index + 12; + + // Split the namespace + var parts = namespace.split('.'); + var db = parts.shift(); + var collection = parts.join('.'); + // Upgrade to DBRef type + object[name] = new DBRef(collection, oid, db); + } else { + throw new Error( + 'Detected unknown BSON type ' + + elementType.toString(16) + + ' for fieldname "' + + name + + '", are you using the latest BSON parser' + ); + } + } + + // Check if the deserialization was against a valid array/object + if (size !== index - startIndex) { + if (isArray) throw new Error('corrupt array bson'); + throw new Error('corrupt object bson'); + } + + // Check if we have a db ref object + if (object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']); + return object; +}; + +/** + * Ensure eval is isolated. + * + * @ignore + * @api private + */ +var isolateEvalWithHash = function(functionCache, hash, functionString, object) { + // Contains the value we are going to set + var value = null; + + // Check for cache hit, eval if missing and return cached function + if (functionCache[hash] == null) { + eval('value = ' + functionString); + functionCache[hash] = value; + } + // Set the object + return functionCache[hash].bind(object); +}; + +/** + * Ensure eval is isolated. + * + * @ignore + * @api private + */ +var isolateEval = function(functionString) { + // Contains the value we are going to set + var value = null; + // Eval the function + eval('value = ' + functionString); + return value; +}; + +var BSON = {}; + +/** + * Contains the function cache if we have that enable to allow for avoiding the eval step on each deserialization, comparison is by md5 + * + * @ignore + * @api private + */ +var functionCache = (BSON.functionCache = {}); + +/** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ +BSON.BSON_DATA_NUMBER = 1; +/** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ +BSON.BSON_DATA_STRING = 2; +/** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ +BSON.BSON_DATA_OBJECT = 3; +/** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ +BSON.BSON_DATA_ARRAY = 4; +/** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ +BSON.BSON_DATA_BINARY = 5; +/** + * Binary BSON Type + * + * @classconstant BSON_DATA_UNDEFINED + **/ +BSON.BSON_DATA_UNDEFINED = 6; +/** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ +BSON.BSON_DATA_OID = 7; +/** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ +BSON.BSON_DATA_BOOLEAN = 8; +/** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ +BSON.BSON_DATA_DATE = 9; +/** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ +BSON.BSON_DATA_NULL = 10; +/** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ +BSON.BSON_DATA_REGEXP = 11; +/** + * Code BSON Type + * + * @classconstant BSON_DATA_DBPOINTER + **/ +BSON.BSON_DATA_DBPOINTER = 12; +/** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ +BSON.BSON_DATA_CODE = 13; +/** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ +BSON.BSON_DATA_SYMBOL = 14; +/** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ +BSON.BSON_DATA_CODE_W_SCOPE = 15; +/** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ +BSON.BSON_DATA_INT = 16; +/** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ +BSON.BSON_DATA_TIMESTAMP = 17; +/** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ +BSON.BSON_DATA_LONG = 18; +/** + * Long BSON Type + * + * @classconstant BSON_DATA_DECIMAL128 + **/ +BSON.BSON_DATA_DECIMAL128 = 19; +/** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ +BSON.BSON_DATA_MIN_KEY = 0xff; +/** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ +BSON.BSON_DATA_MAX_KEY = 0x7f; + +/** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ +BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ +BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ +BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ +BSON.BSON_BINARY_SUBTYPE_UUID = 3; +/** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ +BSON.BSON_BINARY_SUBTYPE_MD5 = 4; +/** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ +BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + +// BSON MAX VALUES +BSON.BSON_INT32_MAX = 0x7fffffff; +BSON.BSON_INT32_MIN = -0x80000000; + +BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; +BSON.BSON_INT64_MIN = -Math.pow(2, 63); + +// JS MAX PRECISE VALUES +BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. +BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + +// Internal long versions +var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. +var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + +module.exports = deserialize; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js new file mode 100644 index 0000000..bd3e12a --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/serializer.js @@ -0,0 +1,1183 @@ +'use strict'; + +var writeIEEE754 = require('../float_parser').writeIEEE754, + Long = require('../long').Long, + MinKey = require('../min_key').MinKey, + Map = require('../map'), + Binary = require('../binary').Binary; + +var normalizedFunctionString = require('./utils').normalizedFunctionString; + +// try { +// var _Buffer = Uint8Array; +// } catch (e) { +// _Buffer = Buffer; +// } + +var regexp = /\x00/; // eslint-disable-line no-control-regex +var ignoreKeys = ['$db', '$ref', '$id', '$clusterTime']; + +// To ensure that 0.4 of node works correctly +var isDate = function isDate(d) { + return typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]'; +}; + +var isRegExp = function isRegExp(d) { + return Object.prototype.toString.call(d) === '[object RegExp]'; +}; + +var serializeString = function(buffer, key, value, index, isArray) { + // Encode String type + buffer[index++] = BSON.BSON_DATA_STRING; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes + 1; + buffer[index - 1] = 0; + // Write the string + var size = buffer.write(value, index + 4, 'utf8'); + // Write the size of the string to buffer + buffer[index + 3] = ((size + 1) >> 24) & 0xff; + buffer[index + 2] = ((size + 1) >> 16) & 0xff; + buffer[index + 1] = ((size + 1) >> 8) & 0xff; + buffer[index] = (size + 1) & 0xff; + // Update index + index = index + 4 + size; + // Write zero + buffer[index++] = 0; + return index; +}; + +var serializeNumber = function(buffer, key, value, index, isArray) { + // We have an integer value + if (Math.floor(value) === value && value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + // If the value fits in 32 bits encode as int, if it fits in a double + // encode it as a double, otherwise long + if (value >= BSON.BSON_INT32_MIN && value <= BSON.BSON_INT32_MAX) { + // Set int type 32 bits or less + buffer[index++] = BSON.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + } else if (value >= BSON.JS_INT_MIN && value <= BSON.JS_INT_MAX) { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + } else { + // Set long type + buffer[index++] = BSON.BSON_DATA_LONG; + // Number of written bytes + numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var longVal = Long.fromNumber(value); + var lowBits = longVal.getLowBits(); + var highBits = longVal.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + } + } else { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + } + + return index; +}; + +var serializeNull = function(buffer, key, value, index, isArray) { + // Set long type + buffer[index++] = BSON.BSON_DATA_NULL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +}; + +var serializeBoolean = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BOOLEAN; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Encode the boolean value + buffer[index++] = value ? 1 : 0; + return index; +}; + +var serializeDate = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_DATE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the date + var dateInMilis = Long.fromNumber(value.getTime()); + var lowBits = dateInMilis.getLowBits(); + var highBits = dateInMilis.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +}; + +var serializeRegExp = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + if (value.source && value.source.match(regexp) != null) { + throw Error('value ' + value.source + ' must not contain null bytes'); + } + // Adjust the index + index = index + buffer.write(value.source, index, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the parameters + if (value.global) buffer[index++] = 0x73; // s + if (value.ignoreCase) buffer[index++] = 0x69; // i + if (value.multiline) buffer[index++] = 0x6d; // m + // Add ending zero + buffer[index++] = 0x00; + return index; +}; + +var serializeBSONRegExp = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_REGEXP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Check the pattern for 0 bytes + if (value.pattern.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('pattern ' + value.pattern + ' must not contain null bytes'); + } + + // Adjust the index + index = index + buffer.write(value.pattern, index, 'utf8'); + // Write zero + buffer[index++] = 0x00; + // Write the options + index = + index + + buffer.write( + value.options + .split('') + .sort() + .join(''), + index, + 'utf8' + ); + // Add ending zero + buffer[index++] = 0x00; + return index; +}; + +var serializeMinMax = function(buffer, key, value, index, isArray) { + // Write the type of either min or max key + if (value === null) { + buffer[index++] = BSON.BSON_DATA_NULL; + } else if (value instanceof MinKey) { + buffer[index++] = BSON.BSON_DATA_MIN_KEY; + } else { + buffer[index++] = BSON.BSON_DATA_MAX_KEY; + } + + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + return index; +}; + +var serializeObjectId = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_OID; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Write the objectId into the shared buffer + if (typeof value.id === 'string') { + buffer.write(value.id, index, 'binary'); + } else if (value.id && value.id.copy) { + value.id.copy(buffer, index, 0, 12); + } else { + throw new Error('object [' + JSON.stringify(value) + '] is not a valid ObjectId'); + } + + // Ajust index + return index + 12; +}; + +var serializeBuffer = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Get size of the buffer (current write point) + var size = value.length; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the default subtype + buffer[index++] = BSON.BSON_BINARY_SUBTYPE_DEFAULT; + // Copy the content form the binary field to the buffer + value.copy(buffer, index, 0, size); + // Adjust the index + index = index + size; + return index; +}; + +var serializeObject = function( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + isArray, + path +) { + for (var i = 0; i < path.length; i++) { + if (path[i] === value) throw new Error('cyclic dependency detected'); + } + + // Push value to stack + path.push(value); + // Write the type + buffer[index++] = Array.isArray(value) ? BSON.BSON_DATA_ARRAY : BSON.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + var endIndex = serializeInto( + buffer, + value, + checkKeys, + index, + depth + 1, + serializeFunctions, + ignoreUndefined, + path + ); + // Pop stack + path.pop(); + // Write size + return endIndex; +}; + +var serializeDecimal128 = function(buffer, key, value, index, isArray) { + buffer[index++] = BSON.BSON_DATA_DECIMAL128; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the data from the value + value.bytes.copy(buffer, index, 0, 16); + return index + 16; +}; + +var serializeLong = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = value._bsontype === 'Long' ? BSON.BSON_DATA_LONG : BSON.BSON_DATA_TIMESTAMP; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the date + var lowBits = value.getLowBits(); + var highBits = value.getHighBits(); + // Encode low bits + buffer[index++] = lowBits & 0xff; + buffer[index++] = (lowBits >> 8) & 0xff; + buffer[index++] = (lowBits >> 16) & 0xff; + buffer[index++] = (lowBits >> 24) & 0xff; + // Encode high bits + buffer[index++] = highBits & 0xff; + buffer[index++] = (highBits >> 8) & 0xff; + buffer[index++] = (highBits >> 16) & 0xff; + buffer[index++] = (highBits >> 24) & 0xff; + return index; +}; + +var serializeInt32 = function(buffer, key, value, index, isArray) { + // Set int type 32 bits or less + buffer[index++] = BSON.BSON_DATA_INT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the int value + buffer[index++] = value & 0xff; + buffer[index++] = (value >> 8) & 0xff; + buffer[index++] = (value >> 16) & 0xff; + buffer[index++] = (value >> 24) & 0xff; + return index; +}; + +var serializeDouble = function(buffer, key, value, index, isArray) { + // Encode as double + buffer[index++] = BSON.BSON_DATA_NUMBER; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write float + writeIEEE754(buffer, value, index, 'little', 52, 8); + // Ajust index + index = index + 8; + return index; +}; + +var serializeFunction = function(buffer, key, value, index, checkKeys, depth, isArray) { + buffer[index++] = BSON.BSON_DATA_CODE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + var functionString = normalizedFunctionString(value); + + // Write the string + var size = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + return index; +}; + +var serializeCode = function( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + isArray +) { + if (value.scope && typeof value.scope === 'object') { + // Write the type + buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + // Starting index + var startIndex = index; + + // Serialize the function + // Get the function string + var functionString = typeof value.code === 'string' ? value.code : value.code.toString(); + // Index adjustment + index = index + 4; + // Write string into buffer + var codeSize = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = codeSize & 0xff; + buffer[index + 1] = (codeSize >> 8) & 0xff; + buffer[index + 2] = (codeSize >> 16) & 0xff; + buffer[index + 3] = (codeSize >> 24) & 0xff; + // Write end 0 + buffer[index + 4 + codeSize - 1] = 0; + // Write the + index = index + codeSize + 4; + + // + // Serialize the scope value + var endIndex = serializeInto( + buffer, + value.scope, + checkKeys, + index, + depth + 1, + serializeFunctions, + ignoreUndefined + ); + index = endIndex - 1; + + // Writ the total + var totalSize = endIndex - startIndex; + + // Write the total size of the object + buffer[startIndex++] = totalSize & 0xff; + buffer[startIndex++] = (totalSize >> 8) & 0xff; + buffer[startIndex++] = (totalSize >> 16) & 0xff; + buffer[startIndex++] = (totalSize >> 24) & 0xff; + // Write trailing zero + buffer[index++] = 0; + } else { + buffer[index++] = BSON.BSON_DATA_CODE; + // Number of written bytes + numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Function string + functionString = value.code.toString(); + // Write the string + var size = buffer.write(functionString, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0; + } + + return index; +}; + +var serializeBinary = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_BINARY; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Extract the buffer + var data = value.value(true); + // Calculate size + var size = value.position; + // Add the deprecated 02 type 4 bytes of size to total + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) size = size + 4; + // Write the size of the string to buffer + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + // Write the subtype to the buffer + buffer[index++] = value.sub_type; + + // If we have binary type 2 the 4 first bytes are the size + if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) { + size = size - 4; + buffer[index++] = size & 0xff; + buffer[index++] = (size >> 8) & 0xff; + buffer[index++] = (size >> 16) & 0xff; + buffer[index++] = (size >> 24) & 0xff; + } + + // Write the data to the object + data.copy(buffer, index, 0, value.position); + // Adjust the index + index = index + value.position; + return index; +}; + +var serializeSymbol = function(buffer, key, value, index, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_SYMBOL; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + // Write the string + var size = buffer.write(value.value, index + 4, 'utf8') + 1; + // Write the size of the string to buffer + buffer[index] = size & 0xff; + buffer[index + 1] = (size >> 8) & 0xff; + buffer[index + 2] = (size >> 16) & 0xff; + buffer[index + 3] = (size >> 24) & 0xff; + // Update index + index = index + 4 + size - 1; + // Write zero + buffer[index++] = 0x00; + return index; +}; + +var serializeDBRef = function(buffer, key, value, index, depth, serializeFunctions, isArray) { + // Write the type + buffer[index++] = BSON.BSON_DATA_OBJECT; + // Number of written bytes + var numberOfWrittenBytes = !isArray + ? buffer.write(key, index, 'utf8') + : buffer.write(key, index, 'ascii'); + + // Encode the name + index = index + numberOfWrittenBytes; + buffer[index++] = 0; + + var startIndex = index; + var endIndex; + + // Serialize object + if (null != value.db) { + endIndex = serializeInto( + buffer, + { + $ref: value.namespace, + $id: value.oid, + $db: value.db + }, + false, + index, + depth + 1, + serializeFunctions + ); + } else { + endIndex = serializeInto( + buffer, + { + $ref: value.namespace, + $id: value.oid + }, + false, + index, + depth + 1, + serializeFunctions + ); + } + + // Calculate object size + var size = endIndex - startIndex; + // Write the size + buffer[startIndex++] = size & 0xff; + buffer[startIndex++] = (size >> 8) & 0xff; + buffer[startIndex++] = (size >> 16) & 0xff; + buffer[startIndex++] = (size >> 24) & 0xff; + // Set index + return endIndex; +}; + +var serializeInto = function serializeInto( + buffer, + object, + checkKeys, + startingIndex, + depth, + serializeFunctions, + ignoreUndefined, + path +) { + startingIndex = startingIndex || 0; + path = path || []; + + // Push the object to the path + path.push(object); + + // Start place to serialize into + var index = startingIndex + 4; + // var self = this; + + // Special case isArray + if (Array.isArray(object)) { + // Get object keys + for (var i = 0; i < object.length; i++) { + var key = '' + i; + var value = object[i]; + + // Is there an override value + if (value && value.toBSON) { + if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function'); + value = value.toBSON(); + } + + var type = typeof value; + if (type === 'string') { + index = serializeString(buffer, key, value, index, true); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index, true); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index, true); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index, true); + } else if (value === undefined) { + index = serializeNull(buffer, key, value, index, true); + } else if (value === null) { + index = serializeNull(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index, true); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index, true); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index, true); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + true, + path + ); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index, true); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + true + ); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + true + ); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, true); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index, true); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index, true); + } + } + } else if (object instanceof Map) { + var iterator = object.entries(); + var done = false; + + while (!done) { + // Unpack the next entry + var entry = iterator.next(); + done = entry.done; + // Are we done, then skip and terminate + if (done) continue; + + // Get the entry values + key = entry.value[0]; + value = entry.value[1]; + + // Check the type of the value + type = typeof value; + + // Check the key and throw error if it's illegal + if (typeof key === 'string' && ignoreKeys.indexOf(key) === -1) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + // } else if (value === undefined && ignoreUndefined === true) { + } else if (value === null || (value === undefined && ignoreUndefined === false)) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + false, + path + ); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined + ); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + } + } else { + // Did we provide a custom serialization method + if (object.toBSON) { + if (typeof object.toBSON !== 'function') throw new Error('toBSON is not a function'); + object = object.toBSON(); + if (object != null && typeof object !== 'object') + throw new Error('toBSON function did not return an object'); + } + + // Iterate over all the keys + for (key in object) { + value = object[key]; + // Is there an override value + if (value && value.toBSON) { + if (typeof value.toBSON !== 'function') throw new Error('toBSON is not a function'); + value = value.toBSON(); + } + + // Check the type of the value + type = typeof value; + + // Check the key and throw error if it's illegal + if (typeof key === 'string' && ignoreKeys.indexOf(key) === -1) { + if (key.match(regexp) != null) { + // The BSON spec doesn't allow keys with null bytes because keys are + // null-terminated. + throw Error('key ' + key + ' must not contain null bytes'); + } + + if (checkKeys) { + if ('$' === key[0]) { + throw Error('key ' + key + " must not start with '$'"); + } else if (~key.indexOf('.')) { + throw Error('key ' + key + " must not contain '.'"); + } + } + } + + if (type === 'string') { + index = serializeString(buffer, key, value, index); + } else if (type === 'number') { + index = serializeNumber(buffer, key, value, index); + } else if (type === 'boolean') { + index = serializeBoolean(buffer, key, value, index); + } else if (value instanceof Date || isDate(value)) { + index = serializeDate(buffer, key, value, index); + } else if (value === undefined) { + if (ignoreUndefined === false) index = serializeNull(buffer, key, value, index); + } else if (value === null) { + index = serializeNull(buffer, key, value, index); + } else if (value['_bsontype'] === 'ObjectID') { + index = serializeObjectId(buffer, key, value, index); + } else if (Buffer.isBuffer(value)) { + index = serializeBuffer(buffer, key, value, index); + } else if (value instanceof RegExp || isRegExp(value)) { + index = serializeRegExp(buffer, key, value, index); + } else if (type === 'object' && value['_bsontype'] == null) { + index = serializeObject( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined, + false, + path + ); + } else if (type === 'object' && value['_bsontype'] === 'Decimal128') { + index = serializeDecimal128(buffer, key, value, index); + } else if (value['_bsontype'] === 'Long' || value['_bsontype'] === 'Timestamp') { + index = serializeLong(buffer, key, value, index); + } else if (value['_bsontype'] === 'Double') { + index = serializeDouble(buffer, key, value, index); + } else if (value['_bsontype'] === 'Code') { + index = serializeCode( + buffer, + key, + value, + index, + checkKeys, + depth, + serializeFunctions, + ignoreUndefined + ); + } else if (typeof value === 'function' && serializeFunctions) { + index = serializeFunction(buffer, key, value, index, checkKeys, depth, serializeFunctions); + } else if (value['_bsontype'] === 'Binary') { + index = serializeBinary(buffer, key, value, index); + } else if (value['_bsontype'] === 'Symbol') { + index = serializeSymbol(buffer, key, value, index); + } else if (value['_bsontype'] === 'DBRef') { + index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions); + } else if (value['_bsontype'] === 'BSONRegExp') { + index = serializeBSONRegExp(buffer, key, value, index); + } else if (value['_bsontype'] === 'Int32') { + index = serializeInt32(buffer, key, value, index); + } else if (value['_bsontype'] === 'MinKey' || value['_bsontype'] === 'MaxKey') { + index = serializeMinMax(buffer, key, value, index); + } + } + } + + // Remove the path + path.pop(); + + // Final padding byte for object + buffer[index++] = 0x00; + + // Final size + var size = index - startingIndex; + // Write the size of the object + buffer[startingIndex++] = size & 0xff; + buffer[startingIndex++] = (size >> 8) & 0xff; + buffer[startingIndex++] = (size >> 16) & 0xff; + buffer[startingIndex++] = (size >> 24) & 0xff; + return index; +}; + +var BSON = {}; + +/** + * Contains the function cache if we have that enable to allow for avoiding the eval step on each deserialization, comparison is by md5 + * + * @ignore + * @api private + */ +// var functionCache = (BSON.functionCache = {}); + +/** + * Number BSON Type + * + * @classconstant BSON_DATA_NUMBER + **/ +BSON.BSON_DATA_NUMBER = 1; +/** + * String BSON Type + * + * @classconstant BSON_DATA_STRING + **/ +BSON.BSON_DATA_STRING = 2; +/** + * Object BSON Type + * + * @classconstant BSON_DATA_OBJECT + **/ +BSON.BSON_DATA_OBJECT = 3; +/** + * Array BSON Type + * + * @classconstant BSON_DATA_ARRAY + **/ +BSON.BSON_DATA_ARRAY = 4; +/** + * Binary BSON Type + * + * @classconstant BSON_DATA_BINARY + **/ +BSON.BSON_DATA_BINARY = 5; +/** + * ObjectID BSON Type, deprecated + * + * @classconstant BSON_DATA_UNDEFINED + **/ +BSON.BSON_DATA_UNDEFINED = 6; +/** + * ObjectID BSON Type + * + * @classconstant BSON_DATA_OID + **/ +BSON.BSON_DATA_OID = 7; +/** + * Boolean BSON Type + * + * @classconstant BSON_DATA_BOOLEAN + **/ +BSON.BSON_DATA_BOOLEAN = 8; +/** + * Date BSON Type + * + * @classconstant BSON_DATA_DATE + **/ +BSON.BSON_DATA_DATE = 9; +/** + * null BSON Type + * + * @classconstant BSON_DATA_NULL + **/ +BSON.BSON_DATA_NULL = 10; +/** + * RegExp BSON Type + * + * @classconstant BSON_DATA_REGEXP + **/ +BSON.BSON_DATA_REGEXP = 11; +/** + * Code BSON Type + * + * @classconstant BSON_DATA_CODE + **/ +BSON.BSON_DATA_CODE = 13; +/** + * Symbol BSON Type + * + * @classconstant BSON_DATA_SYMBOL + **/ +BSON.BSON_DATA_SYMBOL = 14; +/** + * Code with Scope BSON Type + * + * @classconstant BSON_DATA_CODE_W_SCOPE + **/ +BSON.BSON_DATA_CODE_W_SCOPE = 15; +/** + * 32 bit Integer BSON Type + * + * @classconstant BSON_DATA_INT + **/ +BSON.BSON_DATA_INT = 16; +/** + * Timestamp BSON Type + * + * @classconstant BSON_DATA_TIMESTAMP + **/ +BSON.BSON_DATA_TIMESTAMP = 17; +/** + * Long BSON Type + * + * @classconstant BSON_DATA_LONG + **/ +BSON.BSON_DATA_LONG = 18; +/** + * Long BSON Type + * + * @classconstant BSON_DATA_DECIMAL128 + **/ +BSON.BSON_DATA_DECIMAL128 = 19; +/** + * MinKey BSON Type + * + * @classconstant BSON_DATA_MIN_KEY + **/ +BSON.BSON_DATA_MIN_KEY = 0xff; +/** + * MaxKey BSON Type + * + * @classconstant BSON_DATA_MAX_KEY + **/ +BSON.BSON_DATA_MAX_KEY = 0x7f; +/** + * Binary Default Type + * + * @classconstant BSON_BINARY_SUBTYPE_DEFAULT + **/ +BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0; +/** + * Binary Function Type + * + * @classconstant BSON_BINARY_SUBTYPE_FUNCTION + **/ +BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1; +/** + * Binary Byte Array Type + * + * @classconstant BSON_BINARY_SUBTYPE_BYTE_ARRAY + **/ +BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2; +/** + * Binary UUID Type + * + * @classconstant BSON_BINARY_SUBTYPE_UUID + **/ +BSON.BSON_BINARY_SUBTYPE_UUID = 3; +/** + * Binary MD5 Type + * + * @classconstant BSON_BINARY_SUBTYPE_MD5 + **/ +BSON.BSON_BINARY_SUBTYPE_MD5 = 4; +/** + * Binary User Defined Type + * + * @classconstant BSON_BINARY_SUBTYPE_USER_DEFINED + **/ +BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128; + +// BSON MAX VALUES +BSON.BSON_INT32_MAX = 0x7fffffff; +BSON.BSON_INT32_MIN = -0x80000000; + +BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1; +BSON.BSON_INT64_MIN = -Math.pow(2, 63); + +// JS MAX PRECISE VALUES +BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double. +BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double. + +// Internal long versions +// var JS_INT_MAX_LONG = Long.fromNumber(0x20000000000000); // Any integer up to 2^53 can be precisely represented by a double. +// var JS_INT_MIN_LONG = Long.fromNumber(-0x20000000000000); // Any integer down to -2^53 can be precisely represented by a double. + +module.exports = serializeInto; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/utils.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/utils.js new file mode 100644 index 0000000..6b8395f --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/parser/utils.js @@ -0,0 +1,14 @@ +'use strict'; + +/** + * Normalizes our expected stringified form of a function across versions of node + * @param {Function} fn The function to stringify + */ +function normalizedFunctionString(fn) { + return fn.toString().replace(/function *\(/, 'function ('); +} + +module.exports = { + normalizedFunctionString: normalizedFunctionString +}; + diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/regexp.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/regexp.js new file mode 100644 index 0000000..108f016 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/regexp.js @@ -0,0 +1,33 @@ +/** + * A class representation of the BSON RegExp type. + * + * @class + * @return {BSONRegExp} A MinKey instance + */ +function BSONRegExp(pattern, options) { + if (!(this instanceof BSONRegExp)) return new BSONRegExp(); + + // Execute + this._bsontype = 'BSONRegExp'; + this.pattern = pattern || ''; + this.options = options || ''; + + // Validate options + for (var i = 0; i < this.options.length; i++) { + if ( + !( + this.options[i] === 'i' || + this.options[i] === 'm' || + this.options[i] === 'x' || + this.options[i] === 'l' || + this.options[i] === 's' || + this.options[i] === 'u' + ) + ) { + throw new Error('the regular expression options [' + this.options[i] + '] is not supported'); + } + } +} + +module.exports = BSONRegExp; +module.exports.BSONRegExp = BSONRegExp; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/symbol.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/symbol.js new file mode 100644 index 0000000..ba20cab --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/symbol.js @@ -0,0 +1,50 @@ +// Custom inspect property name / symbol. +var inspect = Buffer ? require('util').inspect.custom || 'inspect' : 'inspect'; + +/** + * A class representation of the BSON Symbol type. + * + * @class + * @deprecated + * @param {string} value the string representing the symbol. + * @return {Symbol} + */ +function Symbol(value) { + if (!(this instanceof Symbol)) return new Symbol(value); + this._bsontype = 'Symbol'; + this.value = value; +} + +/** + * Access the wrapped string value. + * + * @method + * @return {String} returns the wrapped string. + */ +Symbol.prototype.valueOf = function() { + return this.value; +}; + +/** + * @ignore + */ +Symbol.prototype.toString = function() { + return this.value; +}; + +/** + * @ignore + */ +Symbol.prototype[inspect] = function() { + return this.value; +}; + +/** + * @ignore + */ +Symbol.prototype.toJSON = function() { + return this.value; +}; + +module.exports = Symbol; +module.exports.Symbol = Symbol; diff --git a/node_modules/mongodb-core/node_modules/bson/lib/bson/timestamp.js b/node_modules/mongodb-core/node_modules/bson/lib/bson/timestamp.js new file mode 100644 index 0000000..dc61a6c --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/lib/bson/timestamp.js @@ -0,0 +1,854 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2009 Google Inc. All Rights Reserved + +/** + * This type is for INTERNAL use in MongoDB only and should not be used in applications. + * The appropriate corresponding type is the JavaScript Date type. + * + * Defines a Timestamp class for representing a 64-bit two's-complement + * integer value, which faithfully simulates the behavior of a Java "Timestamp". This + * implementation is derived from TimestampLib in GWT. + * + * Constructs a 64-bit two's-complement integer, given its low and high 32-bit + * values as *signed* integers. See the from* functions below for more + * convenient ways of constructing Timestamps. + * + * The internal representation of a Timestamp is the two given signed, 32-bit values. + * We use 32-bit pieces because these are the size of integers on which + * Javascript performs bit-operations. For operations like addition and + * multiplication, we split each number into 16-bit pieces, which can easily be + * multiplied within Javascript's floating-point representation without overflow + * or change in sign. + * + * In the algorithms below, we frequently reduce the negative case to the + * positive case by negating the input(s) and then post-processing the result. + * Note that we must ALWAYS check specially whether those values are MIN_VALUE + * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as + * a positive number, it overflows back into a negative). Not handling this + * case would often result in infinite recursion. + * + * @class + * @param {number} low the low (signed) 32 bits of the Timestamp. + * @param {number} high the high (signed) 32 bits of the Timestamp. + */ +function Timestamp(low, high) { + if (!(this instanceof Timestamp)) return new Timestamp(low, high); + this._bsontype = 'Timestamp'; + /** + * @type {number} + * @ignore + */ + this.low_ = low | 0; // force into 32 signed bits. + + /** + * @type {number} + * @ignore + */ + this.high_ = high | 0; // force into 32 signed bits. +} + +/** + * Return the int value. + * + * @return {number} the value, assuming it is a 32-bit integer. + */ +Timestamp.prototype.toInt = function() { + return this.low_; +}; + +/** + * Return the Number value. + * + * @method + * @return {number} the closest floating-point representation to this value. + */ +Timestamp.prototype.toNumber = function() { + return this.high_ * Timestamp.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned(); +}; + +/** + * Return the JSON value. + * + * @method + * @return {string} the JSON representation. + */ +Timestamp.prototype.toJSON = function() { + return this.toString(); +}; + +/** + * Return the String value. + * + * @method + * @param {number} [opt_radix] the radix in which the text should be written. + * @return {string} the textual representation of this value. + */ +Timestamp.prototype.toString = function(opt_radix) { + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (this.isZero()) { + return '0'; + } + + if (this.isNegative()) { + if (this.equals(Timestamp.MIN_VALUE)) { + // We need to change the Timestamp value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixTimestamp = Timestamp.fromNumber(radix); + var div = this.div(radixTimestamp); + var rem = div.multiply(radixTimestamp).subtract(this); + return div.toString(radix) + rem.toInt().toString(radix); + } else { + return '-' + this.negate().toString(radix); + } + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Timestamp.fromNumber(Math.pow(radix, 6)); + + rem = this; + var result = ''; + + while (!rem.isZero()) { + var remDiv = rem.div(radixToPower); + var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); + var digits = intval.toString(radix); + + rem = remDiv; + if (rem.isZero()) { + return digits + result; + } else { + while (digits.length < 6) { + digits = '0' + digits; + } + result = '' + digits + result; + } + } +}; + +/** + * Return the high 32-bits value. + * + * @method + * @return {number} the high 32-bits as a signed value. + */ +Timestamp.prototype.getHighBits = function() { + return this.high_; +}; + +/** + * Return the low 32-bits value. + * + * @method + * @return {number} the low 32-bits as a signed value. + */ +Timestamp.prototype.getLowBits = function() { + return this.low_; +}; + +/** + * Return the low unsigned 32-bits value. + * + * @method + * @return {number} the low 32-bits as an unsigned value. + */ +Timestamp.prototype.getLowBitsUnsigned = function() { + return this.low_ >= 0 ? this.low_ : Timestamp.TWO_PWR_32_DBL_ + this.low_; +}; + +/** + * Returns the number of bits needed to represent the absolute value of this Timestamp. + * + * @method + * @return {number} Returns the number of bits needed to represent the absolute value of this Timestamp. + */ +Timestamp.prototype.getNumBitsAbs = function() { + if (this.isNegative()) { + if (this.equals(Timestamp.MIN_VALUE)) { + return 64; + } else { + return this.negate().getNumBitsAbs(); + } + } else { + var val = this.high_ !== 0 ? this.high_ : this.low_; + for (var bit = 31; bit > 0; bit--) { + if ((val & (1 << bit)) !== 0) { + break; + } + } + return this.high_ !== 0 ? bit + 33 : bit + 1; + } +}; + +/** + * Return whether this value is zero. + * + * @method + * @return {boolean} whether this value is zero. + */ +Timestamp.prototype.isZero = function() { + return this.high_ === 0 && this.low_ === 0; +}; + +/** + * Return whether this value is negative. + * + * @method + * @return {boolean} whether this value is negative. + */ +Timestamp.prototype.isNegative = function() { + return this.high_ < 0; +}; + +/** + * Return whether this value is odd. + * + * @method + * @return {boolean} whether this value is odd. + */ +Timestamp.prototype.isOdd = function() { + return (this.low_ & 1) === 1; +}; + +/** + * Return whether this Timestamp equals the other + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp equals the other + */ +Timestamp.prototype.equals = function(other) { + return this.high_ === other.high_ && this.low_ === other.low_; +}; + +/** + * Return whether this Timestamp does not equal the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp does not equal the other. + */ +Timestamp.prototype.notEquals = function(other) { + return this.high_ !== other.high_ || this.low_ !== other.low_; +}; + +/** + * Return whether this Timestamp is less than the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is less than the other. + */ +Timestamp.prototype.lessThan = function(other) { + return this.compare(other) < 0; +}; + +/** + * Return whether this Timestamp is less than or equal to the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is less than or equal to the other. + */ +Timestamp.prototype.lessThanOrEqual = function(other) { + return this.compare(other) <= 0; +}; + +/** + * Return whether this Timestamp is greater than the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is greater than the other. + */ +Timestamp.prototype.greaterThan = function(other) { + return this.compare(other) > 0; +}; + +/** + * Return whether this Timestamp is greater than or equal to the other. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} whether this Timestamp is greater than or equal to the other. + */ +Timestamp.prototype.greaterThanOrEqual = function(other) { + return this.compare(other) >= 0; +}; + +/** + * Compares this Timestamp with the given one. + * + * @method + * @param {Timestamp} other Timestamp to compare against. + * @return {boolean} 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater. + */ +Timestamp.prototype.compare = function(other) { + if (this.equals(other)) { + return 0; + } + + var thisNeg = this.isNegative(); + var otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) { + return -1; + } + if (!thisNeg && otherNeg) { + return 1; + } + + // at this point, the signs are the same, so subtraction will not overflow + if (this.subtract(other).isNegative()) { + return -1; + } else { + return 1; + } +}; + +/** + * The negation of this value. + * + * @method + * @return {Timestamp} the negation of this value. + */ +Timestamp.prototype.negate = function() { + if (this.equals(Timestamp.MIN_VALUE)) { + return Timestamp.MIN_VALUE; + } else { + return this.not().add(Timestamp.ONE); + } +}; + +/** + * Returns the sum of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to add to this one. + * @return {Timestamp} the sum of this and the given Timestamp. + */ +Timestamp.prototype.add = function(other) { + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 + b48; + c48 &= 0xffff; + return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32); +}; + +/** + * Returns the difference of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to subtract from this. + * @return {Timestamp} the difference of this and the given Timestamp. + */ +Timestamp.prototype.subtract = function(other) { + return this.add(other.negate()); +}; + +/** + * Returns the product of this and the given Timestamp. + * + * @method + * @param {Timestamp} other Timestamp to multiply with this. + * @return {Timestamp} the product of this and the other. + */ +Timestamp.prototype.multiply = function(other) { + if (this.isZero()) { + return Timestamp.ZERO; + } else if (other.isZero()) { + return Timestamp.ZERO; + } + + if (this.equals(Timestamp.MIN_VALUE)) { + return other.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO; + } else if (other.equals(Timestamp.MIN_VALUE)) { + return this.isOdd() ? Timestamp.MIN_VALUE : Timestamp.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().multiply(other.negate()); + } else { + return this.negate() + .multiply(other) + .negate(); + } + } else if (other.isNegative()) { + return this.multiply(other.negate()).negate(); + } + + // If both Timestamps are small, use float multiplication + if (this.lessThan(Timestamp.TWO_PWR_24_) && other.lessThan(Timestamp.TWO_PWR_24_)) { + return Timestamp.fromNumber(this.toNumber() * other.toNumber()); + } + + // Divide each Timestamp into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high_ >>> 16; + var a32 = this.high_ & 0xffff; + var a16 = this.low_ >>> 16; + var a00 = this.low_ & 0xffff; + + var b48 = other.high_ >>> 16; + var b32 = other.high_ & 0xffff; + var b16 = other.low_ >>> 16; + var b00 = other.low_ & 0xffff; + + var c48 = 0, + c32 = 0, + c16 = 0, + c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xffff; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xffff; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xffff; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xffff; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xffff; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xffff; + return Timestamp.fromBits((c16 << 16) | c00, (c48 << 16) | c32); +}; + +/** + * Returns this Timestamp divided by the given one. + * + * @method + * @param {Timestamp} other Timestamp by which to divide. + * @return {Timestamp} this Timestamp divided by the given one. + */ +Timestamp.prototype.div = function(other) { + if (other.isZero()) { + throw Error('division by zero'); + } else if (this.isZero()) { + return Timestamp.ZERO; + } + + if (this.equals(Timestamp.MIN_VALUE)) { + if (other.equals(Timestamp.ONE) || other.equals(Timestamp.NEG_ONE)) { + return Timestamp.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + } else if (other.equals(Timestamp.MIN_VALUE)) { + return Timestamp.ONE; + } else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shiftRight(1); + var approx = halfThis.div(other).shiftLeft(1); + if (approx.equals(Timestamp.ZERO)) { + return other.isNegative() ? Timestamp.ONE : Timestamp.NEG_ONE; + } else { + var rem = this.subtract(other.multiply(approx)); + var result = approx.add(rem.div(other)); + return result; + } + } + } else if (other.equals(Timestamp.MIN_VALUE)) { + return Timestamp.ZERO; + } + + if (this.isNegative()) { + if (other.isNegative()) { + return this.negate().div(other.negate()); + } else { + return this.negate() + .div(other) + .negate(); + } + } else if (other.isNegative()) { + return this.div(other.negate()).negate(); + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + var res = Timestamp.ZERO; + rem = this; + while (rem.greaterThanOrEqual(other)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2); + var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + var approxRes = Timestamp.fromNumber(approx); + var approxRem = approxRes.multiply(other); + while (approxRem.isNegative() || approxRem.greaterThan(rem)) { + approx -= delta; + approxRes = Timestamp.fromNumber(approx); + approxRem = approxRes.multiply(other); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) { + approxRes = Timestamp.ONE; + } + + res = res.add(approxRes); + rem = rem.subtract(approxRem); + } + return res; +}; + +/** + * Returns this Timestamp modulo the given one. + * + * @method + * @param {Timestamp} other Timestamp by which to mod. + * @return {Timestamp} this Timestamp modulo the given one. + */ +Timestamp.prototype.modulo = function(other) { + return this.subtract(this.div(other).multiply(other)); +}; + +/** + * The bitwise-NOT of this value. + * + * @method + * @return {Timestamp} the bitwise-NOT of this value. + */ +Timestamp.prototype.not = function() { + return Timestamp.fromBits(~this.low_, ~this.high_); +}; + +/** + * Returns the bitwise-AND of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to AND. + * @return {Timestamp} the bitwise-AND of this and the other. + */ +Timestamp.prototype.and = function(other) { + return Timestamp.fromBits(this.low_ & other.low_, this.high_ & other.high_); +}; + +/** + * Returns the bitwise-OR of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to OR. + * @return {Timestamp} the bitwise-OR of this and the other. + */ +Timestamp.prototype.or = function(other) { + return Timestamp.fromBits(this.low_ | other.low_, this.high_ | other.high_); +}; + +/** + * Returns the bitwise-XOR of this Timestamp and the given one. + * + * @method + * @param {Timestamp} other the Timestamp with which to XOR. + * @return {Timestamp} the bitwise-XOR of this and the other. + */ +Timestamp.prototype.xor = function(other) { + return Timestamp.fromBits(this.low_ ^ other.low_, this.high_ ^ other.high_); +}; + +/** + * Returns this Timestamp with bits shifted to the left by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the left by the given amount. + */ +Timestamp.prototype.shiftLeft = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var low = this.low_; + if (numBits < 32) { + var high = this.high_; + return Timestamp.fromBits(low << numBits, (high << numBits) | (low >>> (32 - numBits))); + } else { + return Timestamp.fromBits(0, low << (numBits - 32)); + } + } +}; + +/** + * Returns this Timestamp with bits shifted to the right by the given amount. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the right by the given amount. + */ +Timestamp.prototype.shiftRight = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Timestamp.fromBits((low >>> numBits) | (high << (32 - numBits)), high >> numBits); + } else { + return Timestamp.fromBits(high >> (numBits - 32), high >= 0 ? 0 : -1); + } + } +}; + +/** + * Returns this Timestamp with bits shifted to the right by the given amount, with the new top bits matching the current sign bit. + * + * @method + * @param {number} numBits the number of bits by which to shift. + * @return {Timestamp} this shifted to the right by the given amount, with zeros placed into the new leading bits. + */ +Timestamp.prototype.shiftRightUnsigned = function(numBits) { + numBits &= 63; + if (numBits === 0) { + return this; + } else { + var high = this.high_; + if (numBits < 32) { + var low = this.low_; + return Timestamp.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits); + } else if (numBits === 32) { + return Timestamp.fromBits(high, 0); + } else { + return Timestamp.fromBits(high >>> (numBits - 32), 0); + } + } +}; + +/** + * Returns a Timestamp representing the given (32-bit) integer value. + * + * @method + * @param {number} value the 32-bit integer in question. + * @return {Timestamp} the corresponding Timestamp value. + */ +Timestamp.fromInt = function(value) { + if (-128 <= value && value < 128) { + var cachedObj = Timestamp.INT_CACHE_[value]; + if (cachedObj) { + return cachedObj; + } + } + + var obj = new Timestamp(value | 0, value < 0 ? -1 : 0); + if (-128 <= value && value < 128) { + Timestamp.INT_CACHE_[value] = obj; + } + return obj; +}; + +/** + * Returns a Timestamp representing the given value, provided that it is a finite number. Otherwise, zero is returned. + * + * @method + * @param {number} value the number in question. + * @return {Timestamp} the corresponding Timestamp value. + */ +Timestamp.fromNumber = function(value) { + if (isNaN(value) || !isFinite(value)) { + return Timestamp.ZERO; + } else if (value <= -Timestamp.TWO_PWR_63_DBL_) { + return Timestamp.MIN_VALUE; + } else if (value + 1 >= Timestamp.TWO_PWR_63_DBL_) { + return Timestamp.MAX_VALUE; + } else if (value < 0) { + return Timestamp.fromNumber(-value).negate(); + } else { + return new Timestamp( + (value % Timestamp.TWO_PWR_32_DBL_) | 0, + (value / Timestamp.TWO_PWR_32_DBL_) | 0 + ); + } +}; + +/** + * Returns a Timestamp representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits. + * + * @method + * @param {number} lowBits the low 32-bits. + * @param {number} highBits the high 32-bits. + * @return {Timestamp} the corresponding Timestamp value. + */ +Timestamp.fromBits = function(lowBits, highBits) { + return new Timestamp(lowBits, highBits); +}; + +/** + * Returns a Timestamp representation of the given string, written using the given radix. + * + * @method + * @param {string} str the textual representation of the Timestamp. + * @param {number} opt_radix the radix in which the text is written. + * @return {Timestamp} the corresponding Timestamp value. + */ +Timestamp.fromString = function(str, opt_radix) { + if (str.length === 0) { + throw Error('number format error: empty string'); + } + + var radix = opt_radix || 10; + if (radix < 2 || 36 < radix) { + throw Error('radix out of range: ' + radix); + } + + if (str.charAt(0) === '-') { + return Timestamp.fromString(str.substring(1), radix).negate(); + } else if (str.indexOf('-') >= 0) { + throw Error('number format error: interior "-" character: ' + str); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Timestamp.fromNumber(Math.pow(radix, 8)); + + var result = Timestamp.ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i); + var value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Timestamp.fromNumber(Math.pow(radix, size)); + result = result.multiply(power).add(Timestamp.fromNumber(value)); + } else { + result = result.multiply(radixToPower); + result = result.add(Timestamp.fromNumber(value)); + } + } + return result; +}; + +// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the +// from* methods on which they depend. + +/** + * A cache of the Timestamp representations of small integer values. + * @type {Object} + * @ignore + */ +Timestamp.INT_CACHE_ = {}; + +// NOTE: the compiler should inline these constant values below and then remove +// these variables, so there should be no runtime penalty for these. + +/** + * Number used repeated below in calculations. This must appear before the + * first call to any from* function below. + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_16_DBL_ = 1 << 16; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_24_DBL_ = 1 << 24; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_32_DBL_ = Timestamp.TWO_PWR_16_DBL_ * Timestamp.TWO_PWR_16_DBL_; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_31_DBL_ = Timestamp.TWO_PWR_32_DBL_ / 2; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_48_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_16_DBL_; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_64_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_32_DBL_; + +/** + * @type {number} + * @ignore + */ +Timestamp.TWO_PWR_63_DBL_ = Timestamp.TWO_PWR_64_DBL_ / 2; + +/** @type {Timestamp} */ +Timestamp.ZERO = Timestamp.fromInt(0); + +/** @type {Timestamp} */ +Timestamp.ONE = Timestamp.fromInt(1); + +/** @type {Timestamp} */ +Timestamp.NEG_ONE = Timestamp.fromInt(-1); + +/** @type {Timestamp} */ +Timestamp.MAX_VALUE = Timestamp.fromBits(0xffffffff | 0, 0x7fffffff | 0); + +/** @type {Timestamp} */ +Timestamp.MIN_VALUE = Timestamp.fromBits(0, 0x80000000 | 0); + +/** + * @type {Timestamp} + * @ignore + */ +Timestamp.TWO_PWR_24_ = Timestamp.fromInt(1 << 24); + +/** + * Expose. + */ +module.exports = Timestamp; +module.exports.Timestamp = Timestamp; diff --git a/node_modules/mongodb-core/node_modules/bson/package.json b/node_modules/mongodb-core/node_modules/bson/package.json new file mode 100644 index 0000000..b1ff650 --- /dev/null +++ b/node_modules/mongodb-core/node_modules/bson/package.json @@ -0,0 +1,87 @@ +{ + "_from": "bson@^1.1.0", + "_id": "bson@1.1.0", + "_inBundle": false, + "_integrity": "sha512-9Aeai9TacfNtWXOYarkFJRW2CWo+dRon+fuLZYJmvLV3+MiUp0bEI6IAZfXEIg7/Pl/7IWlLaDnhzTsD81etQA==", + "_location": "/mongodb-core/bson", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "bson@^1.1.0", + "name": "bson", + "escapedName": "bson", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/mongodb-core" + ], + "_resolved": "https://registry.npmjs.org/bson/-/bson-1.1.0.tgz", + "_shasum": "bee57d1fb6a87713471af4e32bcae36de814b5b0", + "_spec": "bson@^1.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb-core", + "author": { + "name": "Christian Amor Kvalheim", + "email": "christkv@gmail.com" + }, + "browser": "lib/bson/bson.js", + "bugs": { + "url": "https://github.com/mongodb/js-bson/issues" + }, + "bundleDependencies": false, + "config": { + "native": false + }, + "contributors": [], + "deprecated": false, + "description": "A bson parser for node.js and the browser", + "devDependencies": { + "babel-core": "^6.14.0", + "babel-loader": "^6.2.5", + "babel-polyfill": "^6.13.0", + "babel-preset-es2015": "^6.14.0", + "babel-preset-stage-0": "^6.5.0", + "babel-register": "^6.14.0", + "benchmark": "1.0.0", + "colors": "1.1.0", + "conventional-changelog-cli": "^1.3.5", + "nodeunit": "0.9.0", + "webpack": "^1.13.2", + "webpack-polyfills-plugin": "0.0.9" + }, + "directories": { + "lib": "./lib/bson" + }, + "engines": { + "node": ">=0.6.19" + }, + "files": [ + "lib", + "index.js", + "browser_build", + "bower.json" + ], + "homepage": "https://github.com/mongodb/js-bson#readme", + "keywords": [ + "mongodb", + "bson", + "parser" + ], + "license": "Apache-2.0", + "main": "./index", + "name": "bson", + "repository": { + "type": "git", + "url": "git+https://github.com/mongodb/js-bson.git" + }, + "scripts": { + "build": "webpack --config ./webpack.dist.config.js", + "changelog": "conventional-changelog -p angular -i HISTORY.md -s", + "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'", + "lint": "eslint lib test", + "test": "nodeunit ./test/node" + }, + "version": "1.1.0" +} diff --git a/node_modules/mongodb-core/package.json b/node_modules/mongodb-core/package.json index bcbe165..a080d87 100644 --- a/node_modules/mongodb-core/package.json +++ b/node_modules/mongodb-core/package.json @@ -1,57 +1,58 @@ { - "_from": "mongodb-core@2.1.18", - "_id": "mongodb-core@2.1.18", + "_from": "mongodb-core@3.1.3", + "_id": "mongodb-core@3.1.3", "_inBundle": false, - "_integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=", + "_integrity": "sha512-dISiV3zHGJTwZpg0xDhi9zCqFGMhA5kDPByHlcaEp09NSKfzHJ7XQbqVrL7qhki1U9PZHsmRfbFzco+6b1h2wA==", "_location": "/mongodb-core", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "mongodb-core@2.1.18", + "raw": "mongodb-core@3.1.3", "name": "mongodb-core", "escapedName": "mongodb-core", - "rawSpec": "2.1.18", + "rawSpec": "3.1.3", "saveSpec": null, - "fetchSpec": "2.1.18" + "fetchSpec": "3.1.3" }, "_requiredBy": [ "/mongodb" ], - "_resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz", - "_shasum": "4c46139bdf3a1f032ded91db49f38eec01659050", - "_spec": "mongodb-core@2.1.18", + "_resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.3.tgz", + "_shasum": "b036bce5290b383fe507238965bef748dd8adb75", + "_spec": "mongodb-core@3.1.3", "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb", "author": { "name": "Christian Kvalheim" }, "bugs": { - "url": "https://github.com/christkv/mongodb-core/issues" + "url": "https://github.com/mongodb-js/mongodb-core/issues" }, "bundleDependencies": false, "dependencies": { - "bson": "~1.0.4", - "require_optional": "~1.0.0" + "bson": "^1.1.0", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "deprecated": false, "description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications", "devDependencies": { - "co": "^4.5.4", - "coveralls": "^2.11.6", - "es6-promise": "^3.0.2", - "gleak": "0.5.0", - "integra": "0.1.8", - "jsdoc": "3.3.0-alpha8", - "mkdirp": "0.5.0", - "mongodb-topology-manager": "1.0.x", - "mongodb-version-manager": "github:christkv/mongodb-version-manager#master", - "nyc": "^5.5.0", - "optimist": "latest", - "request": "2.65.0", - "rimraf": "2.2.6", - "semver": "4.1.0" + "chai": "^4.1.2", + "chai-subset": "^1.6.0", + "co": "^4.6.0", + "eslint": "^4.6.1", + "eslint-plugin-prettier": "^2.2.0", + "jsdoc": "3.5.4", + "mongodb-extjson": "^2.1.2", + "mongodb-mock-server": "^1.0.0", + "mongodb-test-runner": "^1.1.18", + "prettier": "~1.12.0", + "sinon": "^6.0.0", + "snappy": "^6.0.1", + "standard-version": "^4.4.0" }, - "homepage": "https://github.com/christkv/mongodb-core", + "homepage": "https://github.com/mongodb-js/mongodb-core", "keywords": [ "mongodb", "core" @@ -59,18 +60,27 @@ "license": "Apache-2.0", "main": "index.js", "name": "mongodb-core", + "optionalDependencies": { + "saslprep": "^1.0.0" + }, "peerOptionalDependencies": { - "kerberos": "~0.0", - "bson-ext": "1.0.5" + "kerberos": "^1.0.0", + "mongodb-extjson": "^2.1.2", + "snappy": "^6.0.1", + "bson-ext": "^2.0.0" }, "repository": { "type": "git", - "url": "git://github.com/christkv/mongodb-core.git" + "url": "git://github.com/mongodb-js/mongodb-core.git" }, "scripts": { + "atlas": "node ./test/atlas.js", + "changelog": "conventional-changelog -p angular -i HISTORY.md -s", "coverage": "nyc node test/runner.js -t functional -l && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls", - "lint": "eslint lib", - "test": "node test/runner.js -t functional" + "format": "prettier --print-width 100 --tab-width 2 --single-quote --write index.js 'test/**/*.js' 'lib/**/*.js'", + "lint": "eslint index.js lib test", + "release": "standard-version -i HISTORY.md", + "test": "npm run lint && mongodb-test-runner -t 60000 test/tests" }, - "version": "2.1.18" + "version": "3.1.3" } diff --git a/node_modules/mongodb-core/yarn.lock b/node_modules/mongodb-core/yarn.lock new file mode 100644 index 0000000..b2a1532 --- /dev/null +++ b/node_modules/mongodb-core/yarn.lock @@ -0,0 +1,3433 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@sinonjs/commons@^1.0.1": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.0.2.tgz#3e0ac737781627b8844257fadc3d803997d0526e" + dependencies: + type-detect "4.0.8" + +"@sinonjs/formatio@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" + dependencies: + samsam "1.3.0" + +"@sinonjs/samsam@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-2.0.0.tgz#9163742ac35c12d3602dece74317643b35db6a80" + +JSONStream@^1.0.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.4.tgz#615bb2adb0cd34c8f4c447b5f6512fa1d8f16a2e" + dependencies: + jsonparse "^1.2.0" + through ">=2.2.7 <3" + +acorn-jsx@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" + dependencies: + acorn "^3.0.4" + +acorn@^3.0.4: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + +acorn@^5.5.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.2.tgz#91fa871883485d06708800318404e72bfb26dcc5" + +ajv-keywords@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" + +ajv@^5.2.3, ajv@^5.3.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ampersand-events@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ampersand-events/-/ampersand-events-2.0.2.tgz#f402bc2e18305fabd995dbdcd3b7057bbdd7d347" + dependencies: + ampersand-version "^1.0.2" + lodash "^4.6.1" + +ampersand-state@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/ampersand-state/-/ampersand-state-5.0.3.tgz#33402ea604375af64a249f664a0312c1160da475" + dependencies: + ampersand-events "^2.0.1" + ampersand-version "^1.0.0" + array-next "~0.0.1" + key-tree-store "^1.3.0" + lodash "^4.12.0" + +ampersand-version@^1.0.0, ampersand-version@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/ampersand-version/-/ampersand-version-1.0.2.tgz#ff8f3d4ceac4d32ccd83f6bd6697397f7b59e2c0" + dependencies: + find-root "^0.1.1" + through2 "^0.6.3" + +ansi-escapes@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + dependencies: + color-convert "^1.9.0" + +ansi@^0.3.0, ansi@~0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + dependencies: + sprintf-js "~1.0.2" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-ify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" + +array-next@~0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/array-next/-/array-next-0.0.1.tgz#e5e4660a4c27fda8151ff7764275d00900062be1" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +arrify@^1.0.0, arrify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assertion-error@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + +async@^1.4.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@^2.1.2: + version "2.6.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" + dependencies: + lodash "^4.17.10" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" + +babel-code-frame@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babylon@~7.0.0-beta.19: + version "7.0.0-beta.47" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.47.tgz#6d1fa44f0abec41ab7c780481e62fd9aafbdea80" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base64-js@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + dependencies: + tweetnacl "^0.14.3" + +bindings@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7" + +bl@^1.0.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" + dependencies: + readable-stream "^2.3.5" + safe-buffer "^5.1.1" + +bluebird@^3.5.1, bluebird@~3.5.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" + +boolbase@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +bson@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.0.tgz#bee57d1fb6a87713471af4e32bcae36de814b5b0" + +bson@^2.0.7: + version "2.0.8" + resolved "https://registry.yarnpkg.com/bson/-/bson-2.0.8.tgz#e3bcc115e486bdcb222de7568c43b0b43292761e" + +bson@~1.0.4: + version "1.0.9" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.9.tgz#12319f8323b1254739b7c6bef8d3e89ae05a2f57" + +buffer-alloc-unsafe@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" + +buffer-alloc@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" + dependencies: + buffer-alloc-unsafe "^1.1.0" + buffer-fill "^1.0.0" + +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + +buffer-fill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + +buffer-shims@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +buffer@^3.0.1: + version "3.6.0" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-3.6.0.tgz#a72c936f77b96bf52f5f7e7b467180628551defb" + dependencies: + base64-js "0.0.8" + ieee754 "^1.1.4" + isarray "^1.0.0" + +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + dependencies: + callsites "^0.2.0" + +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +catharsis@~0.8.9: + version "0.8.9" + resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" + dependencies: + underscore-contrib "~0.3.0" + +caw@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/caw/-/caw-2.0.1.tgz#6c3ca071fc194720883c2dc5da9b074bfc7e9e95" + dependencies: + get-proxy "^2.0.0" + isurl "^1.0.0-alpha5" + tunnel-agent "^0.6.0" + url-to-options "^1.0.1" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chai-subset@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/chai-subset/-/chai-subset-1.6.0.tgz#a5d0ca14e329a79596ed70058b6646bd6988cfe9" + +chai@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" + dependencies: + assertion-error "^1.0.1" + check-error "^1.0.1" + deep-eql "^3.0.0" + get-func-name "^2.0.0" + pathval "^1.0.0" + type-detect "^4.0.0" + +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0, chalk@^2.1.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + +check-error@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + +cheerio@^0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" + dependencies: + css-select "~1.2.0" + dom-serializer "~0.1.0" + entities "~1.1.1" + htmlparser2 "^3.9.1" + lodash.assignin "^4.0.9" + lodash.bind "^4.1.4" + lodash.defaults "^4.0.1" + lodash.filter "^4.4.0" + lodash.flatten "^4.2.0" + lodash.foreach "^4.3.0" + lodash.map "^4.4.0" + lodash.merge "^4.4.0" + lodash.pick "^4.2.1" + lodash.reduce "^4.4.0" + lodash.reject "^4.4.0" + lodash.some "^4.4.0" + +chownr@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" + +circular-json@^0.3.1: + version "0.3.3" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" + +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" + dependencies: + restore-cursor "^2.0.0" + +cli-width@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +cliui@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +color-convert@^1.9.0: + version "1.9.2" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.2.tgz#49881b8fba67df12a96bdf3f56c0aab9e7913147" + dependencies: + color-name "1.1.1" + +color-name@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.1.tgz#4b1415304cf50028ea81643643bd82ea05803689" + +combined-stream@1.0.6, combined-stream@~1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + dependencies: + delayed-stream "~1.0.0" + +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +commander@~2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4" + dependencies: + graceful-readlink ">= 1.0.0" + +compare-func@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" + dependencies: + array-ify "^1.0.0" + dot-prop "^3.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@^1.4.10, concat-stream@^1.6.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +config-chain@^1.1.11: + version "1.1.11" + resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2" + dependencies: + ini "^1.3.4" + proto-list "~1.2.1" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +content-disposition@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +conventional-changelog-angular@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.6.tgz#b27f2b315c16d0a1f23eb181309d0e6a4698ea0f" + dependencies: + compare-func "^1.3.1" + q "^1.5.1" + +conventional-changelog-atom@^0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.2.8.tgz#8037693455990e3256f297320a45fa47ee553a14" + dependencies: + q "^1.5.1" + +conventional-changelog-codemirror@^0.3.8: + version "0.3.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.8.tgz#a1982c8291f4ee4d6f2f62817c6b2ecd2c4b7b47" + dependencies: + q "^1.5.1" + +conventional-changelog-core@^2.0.11: + version "2.0.11" + resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-2.0.11.tgz#19b5fbd55a9697773ed6661f4e32030ed7e30287" + dependencies: + conventional-changelog-writer "^3.0.9" + conventional-commits-parser "^2.1.7" + dateformat "^3.0.0" + get-pkg-repo "^1.0.0" + git-raw-commits "^1.3.6" + git-remote-origin-url "^2.0.0" + git-semver-tags "^1.3.6" + lodash "^4.2.1" + normalize-package-data "^2.3.5" + q "^1.5.1" + read-pkg "^1.1.0" + read-pkg-up "^1.0.1" + through2 "^2.0.0" + +conventional-changelog-ember@^0.3.12: + version "0.3.12" + resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.3.12.tgz#b7d31851756d0fcb49b031dffeb6afa93b202400" + dependencies: + q "^1.5.1" + +conventional-changelog-eslint@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.9.tgz#b13cc7e4b472c819450ede031ff1a75c0e3d07d3" + dependencies: + q "^1.5.1" + +conventional-changelog-express@^0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.3.6.tgz#4a6295cb11785059fb09202180d0e59c358b9c2c" + dependencies: + q "^1.5.1" + +conventional-changelog-jquery@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" + dependencies: + q "^1.4.1" + +conventional-changelog-jscs@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" + dependencies: + q "^1.4.1" + +conventional-changelog-jshint@^0.3.8: + version "0.3.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.8.tgz#9051c1ac0767abaf62a31f74d2fe8790e8acc6c8" + dependencies: + compare-func "^1.3.1" + q "^1.5.1" + +conventional-changelog-preset-loader@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.8.tgz#40bb0f142cd27d16839ec6c74ee8db418099b373" + +conventional-changelog-writer@^3.0.9: + version "3.0.9" + resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-3.0.9.tgz#4aecdfef33ff2a53bb0cf3b8071ce21f0e994634" + dependencies: + compare-func "^1.3.1" + conventional-commits-filter "^1.1.6" + dateformat "^3.0.0" + handlebars "^4.0.2" + json-stringify-safe "^5.0.1" + lodash "^4.2.1" + meow "^4.0.0" + semver "^5.5.0" + split "^1.0.0" + through2 "^2.0.0" + +conventional-changelog@^1.1.0: + version "1.1.24" + resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.24.tgz#3d94c29c960f5261c002678315b756cdd3d7d1f0" + dependencies: + conventional-changelog-angular "^1.6.6" + conventional-changelog-atom "^0.2.8" + conventional-changelog-codemirror "^0.3.8" + conventional-changelog-core "^2.0.11" + conventional-changelog-ember "^0.3.12" + conventional-changelog-eslint "^1.0.9" + conventional-changelog-express "^0.3.6" + conventional-changelog-jquery "^0.1.0" + conventional-changelog-jscs "^0.1.0" + conventional-changelog-jshint "^0.3.8" + conventional-changelog-preset-loader "^1.1.8" + +conventional-commits-filter@^1.1.1, conventional-commits-filter@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz#4389cd8e58fe89750c0b5fb58f1d7f0cc8ad3831" + dependencies: + is-subset "^0.1.1" + modify-values "^1.0.0" + +conventional-commits-parser@^2.1.1, conventional-commits-parser@^2.1.7: + version "2.1.7" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.7.tgz#eca45ed6140d72ba9722ee4132674d639e644e8e" + dependencies: + JSONStream "^1.0.4" + is-text-path "^1.0.0" + lodash "^4.2.1" + meow "^4.0.0" + split2 "^2.0.0" + through2 "^2.0.0" + trim-off-newlines "^1.0.0" + +conventional-recommended-bump@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/conventional-recommended-bump/-/conventional-recommended-bump-1.2.1.tgz#1b7137efb5091f99fe009e2fe9ddb7cc490e9375" + dependencies: + concat-stream "^1.4.10" + conventional-commits-filter "^1.1.1" + conventional-commits-parser "^2.1.1" + git-raw-commits "^1.3.0" + git-semver-tags "^1.3.0" + meow "^3.3.0" + object-assign "^4.0.1" + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cross-spawn@^5.0.1, cross-spawn@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + +css-select@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" + dependencies: + boolbase "~1.0.0" + css-what "2.1" + domutils "1.5.1" + nth-check "~1.0.1" + +css-what@2.1: + version "2.1.0" + resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.0.tgz#9467d032c38cfaefb9f2d79501253062f87fa1bd" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +dargs@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" + dependencies: + number-is-nan "^1.0.0" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +dateformat@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" + +debug@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +debug@^2.2.0: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +debug@^3.0.1, debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +decamelize-keys@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" + dependencies: + decamelize "^1.1.0" + map-obj "^1.0.0" + +decamelize@^1.0.0, decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +decompress-response@^3.2.0, decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + dependencies: + mimic-response "^1.0.0" + +decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1" + dependencies: + file-type "^5.2.0" + is-stream "^1.1.0" + tar-stream "^1.5.2" + +decompress-tarbz2@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" + dependencies: + decompress-tar "^4.1.0" + file-type "^6.1.0" + is-stream "^1.1.0" + seek-bzip "^1.0.5" + unbzip2-stream "^1.0.9" + +decompress-targz@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" + dependencies: + decompress-tar "^4.1.1" + file-type "^5.2.0" + is-stream "^1.1.0" + +decompress-unzip@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69" + dependencies: + file-type "^3.8.0" + get-stream "^2.2.0" + pify "^2.3.0" + yauzl "^2.4.2" + +decompress@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/decompress/-/decompress-4.2.0.tgz#7aedd85427e5a92dacfe55674a7c505e96d01f9d" + dependencies: + decompress-tar "^4.0.0" + decompress-tarbz2 "^4.0.0" + decompress-targz "^4.0.0" + decompress-unzip "^4.0.1" + graceful-fs "^4.1.10" + make-dir "^1.0.0" + pify "^2.3.0" + strip-dirs "^2.0.0" + +deep-eql@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + dependencies: + type-detect "^4.0.0" + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +del@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + +diff@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + +diff@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + +docopt@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11" + +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + dependencies: + esutils "^2.0.2" + +dom-serializer@0, dom-serializer@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" + dependencies: + domelementtype "~1.1.1" + entities "~1.1.1" + +domelementtype@1, domelementtype@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" + +domelementtype@~1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" + +domhandler@^2.3.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803" + dependencies: + domelementtype "1" + +domutils@1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" + dependencies: + dom-serializer "0" + domelementtype "1" + +domutils@^1.5.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" + dependencies: + dom-serializer "0" + domelementtype "1" + +dot-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" + dependencies: + is-obj "^1.0.0" + +dotgitignore@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-1.0.3.tgz#a442cbde7dc20dff51cdb849e4c5a64568c07923" + dependencies: + find-up "^2.1.0" + minimatch "^3.0.4" + +downcache@^0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/downcache/-/downcache-0.0.9.tgz#790bb0424689136115ce93f2aa15946c6d806d0e" + dependencies: + extend "^3.0.0" + graceful-fs "^4.1.3" + limiter "^1.1.0" + mkdirp "^0.5.1" + npmlog "^2.0.3" + request "^2.69.0" + rimraf "^2.5.2" + +download@^6.2.5: + version "6.2.5" + resolved "https://registry.yarnpkg.com/download/-/download-6.2.5.tgz#acd6a542e4cd0bb42ca70cfc98c9e43b07039714" + dependencies: + caw "^2.0.0" + content-disposition "^0.5.2" + decompress "^4.0.0" + ext-name "^5.0.0" + file-type "5.2.0" + filenamify "^2.0.0" + get-stream "^3.0.0" + got "^7.0.0" + make-dir "^1.0.0" + p-event "^1.0.0" + pify "^3.0.0" + +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + dependencies: + once "^1.4.0" + +entities@^1.1.1, entities@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" + +error-ex@^1.2.0, error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + dependencies: + is-arrayish "^0.2.1" + +es6-promise@3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.2.1.tgz#ec56233868032909207170c39448e24449dd1fc4" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +eslint-plugin-prettier@^2.2.0: + version "2.6.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.2.tgz#71998c60aedfa2141f7bfcbf9d1c459bf98b4fad" + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + +eslint-scope@^3.7.1: + version "3.7.3" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.3.tgz#bb507200d3d17f60247636160b4826284b108535" + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^4.6.1: + version "4.19.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" + dependencies: + ajv "^5.3.0" + babel-code-frame "^6.22.0" + chalk "^2.1.0" + concat-stream "^1.6.0" + cross-spawn "^5.1.0" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^3.7.1" + eslint-visitor-keys "^1.0.0" + espree "^3.5.4" + esquery "^1.0.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.0.1" + ignore "^3.3.3" + imurmurhash "^0.1.4" + inquirer "^3.0.6" + is-resolvable "^1.0.0" + js-yaml "^3.9.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + regexpp "^1.0.1" + require-uncached "^1.0.3" + semver "^5.3.0" + strip-ansi "^4.0.0" + strip-json-comments "~2.0.1" + table "4.0.2" + text-table "~0.2.0" + +espree@^3.5.4: + version "3.5.4" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" + dependencies: + acorn "^5.5.0" + acorn-jsx "^3.0.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + +esquery@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" + dependencies: + estraverse "^4.0.0" + +esrecurse@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" + dependencies: + estraverse "^4.1.0" + +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +expand-template@^1.0.2: + version "1.1.1" + resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.1.tgz#981f188c0c3a87d2e28f559bc541426ff94f21dd" + +ext-list@^2.0.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/ext-list/-/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37" + dependencies: + mime-db "^1.28.0" + +ext-name@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ext-name/-/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6" + dependencies: + ext-list "^2.0.0" + sort-keys-length "^1.0.0" + +extend@^3.0.0, extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + +external-editor@^2.0.4: + version "2.2.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" + dependencies: + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" + +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + dependencies: + pend "~1.2.0" + +figures@^1.5.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + dependencies: + escape-string-regexp "^1.0.5" + +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + +file-type@5.2.0, file-type@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" + +file-type@^3.8.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" + +file-type@^6.1.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" + +filename-reserved-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229" + +filenamify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-2.1.0.tgz#88faf495fb1b47abfd612300002a16228c677ee9" + dependencies: + filename-reserved-regex "^2.0.0" + strip-outer "^1.0.0" + trim-repeated "^1.0.0" + +find-root@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/find-root/-/find-root-0.1.2.tgz#98d2267cff1916ccaf2743b3a0eea81d79d7dcd1" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^2.0.0, find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + dependencies: + locate-path "^2.0.0" + +flat-cache@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" + dependencies: + asynckit "^0.4.0" + combined-stream "1.0.6" + mime-types "^2.1.12" + +fs-access@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" + dependencies: + null-check "^1.0.0" + +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + +fs-extra@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + +fs-extra@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + +gauge@~1.2.5: + version "1.2.7" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.2.7.tgz#e9cec5483d3d4ee0ef44b60a7d99e4935e136d93" + dependencies: + ansi "^0.3.0" + has-unicode "^2.0.0" + lodash.pad "^4.1.0" + lodash.padend "^4.1.0" + lodash.padstart "^4.1.0" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + +get-mongodb-version@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/get-mongodb-version/-/get-mongodb-version-1.0.0.tgz#a524d3bb53e1e857fce09b740d2401e475562aa3" + dependencies: + debug "^2.2.0" + lodash.startswith "^4.2.1" + minimist "^1.1.1" + mongodb "^2.0.39" + which "^1.1.1" + +get-pkg-repo@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" + dependencies: + hosted-git-info "^2.1.4" + meow "^3.3.0" + normalize-package-data "^2.3.0" + parse-github-repo-url "^1.3.0" + through2 "^2.0.0" + +get-proxy@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/get-proxy/-/get-proxy-2.1.0.tgz#349f2b4d91d44c4d4d4e9cba2ad90143fac5ef93" + dependencies: + npm-conf "^1.1.0" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +get-stream@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" + dependencies: + object-assign "^4.0.1" + pinkie-promise "^2.0.0" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +git-raw-commits@^1.3.0, git-raw-commits@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.3.6.tgz#27c35a32a67777c1ecd412a239a6c19d71b95aff" + dependencies: + dargs "^4.0.1" + lodash.template "^4.0.2" + meow "^4.0.0" + split2 "^2.0.0" + through2 "^2.0.0" + +git-remote-origin-url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" + dependencies: + gitconfiglocal "^1.0.0" + pify "^2.3.0" + +git-semver-tags@^1.3.0, git-semver-tags@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.3.6.tgz#357ea01f7280794fe0927f2806bee6414d2caba5" + dependencies: + meow "^4.0.0" + semver "^5.5.0" + +gitconfiglocal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" + dependencies: + ini "^1.3.2" + +github-from-package@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" + +glob@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^11.0.1: + version "11.7.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" + +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +got@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" + dependencies: + decompress-response "^3.2.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-plain-obj "^1.1.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + isurl "^1.0.0-alpha5" + lowercase-keys "^1.0.0" + p-cancelable "^0.3.0" + p-timeout "^1.1.1" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + url-parse-lax "^1.0.0" + url-to-options "^1.0.1" + +graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +handlebars@^4.0.2: + version "4.0.11" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@~5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.0.tgz#44657f5688a22cfd4b72486e81b3a3fb11742c29" + dependencies: + ajv "^5.3.0" + har-schema "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + +has-symbol-support-x@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" + +has-to-string-tag-x@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + dependencies: + has-symbol-support-x "^1.4.1" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +he@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" + +hosted-git-info@^2.1.4: + version "2.7.1" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" + +htmlparser2@^3.9.1: + version "3.9.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" + dependencies: + domelementtype "^1.3.0" + domhandler "^2.3.0" + domutils "^1.5.1" + entities "^1.1.1" + inherits "^2.0.1" + readable-stream "^2.0.2" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +iconv-lite@^0.4.17: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ieee754@^1.1.4: + version "1.1.12" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b" + +ignore@^3.3.3: + version "3.3.10" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@^1.3.2, ini@^1.3.4, ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.0.4" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-natural-number@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" + +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + +is-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" + +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + +is-path-in-cwd@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52" + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + dependencies: + path-is-inside "^1.0.1" + +is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + +is-resolvable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" + +is-retry-allowed@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + +is-stream@^1.0.0, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-subset@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" + +is-text-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" + dependencies: + text-extensions "^1.0.0" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@^1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +isurl@^1.0.0-alpha5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" + dependencies: + has-to-string-tag-x "^1.2.0" + is-object "^1.0.1" + +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + +js-yaml@^3.9.1: + version "3.12.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js2xmlparser@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" + dependencies: + xmlcreate "^1.0.1" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +jsdoc@3.5.4: + version "3.5.4" + resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.4.tgz#ceeef7c4bac4335cb10ff41e3a0f58939a534428" + dependencies: + babylon "~7.0.0-beta.19" + bluebird "~3.5.0" + catharsis "~0.8.9" + escape-string-regexp "~1.0.5" + js2xmlparser "~3.0.0" + klaw "~2.0.0" + marked "~0.3.6" + mkdirp "~0.5.1" + requizzle "~0.2.1" + strip-json-comments "~2.0.1" + taffydb "2.6.2" + underscore "~1.8.3" + +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonparse@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +just-extend@^1.1.27: + version "1.1.27" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" + +kerberos@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/kerberos/-/kerberos-1.0.0.tgz#b8e490349a30ccd5f2dc675f1fae7c681cf3c495" + dependencies: + bindings "^1.3.0" + nan "^2.10.0" + prebuild-install "^5.0.0" + +key-tree-store@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/key-tree-store/-/key-tree-store-1.3.0.tgz#5ea29afc2529a425938437d6955b714ce6a9791f" + +kind-of@^3.0.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +klaw@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + optionalDependencies: + graceful-fs "^4.1.9" + +klaw@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" + dependencies: + graceful-fs "^4.1.9" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +limiter@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.3.tgz#32e2eb55b2324076943e5d04c1185ffb387968ef" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash._reinterpolate@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + +lodash.assignin@^4.0.9: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" + +lodash.bind@^4.1.4: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + dependencies: + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" + +lodash.defaults@^4.0.0, lodash.defaults@^4.0.1, lodash.defaults@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + +lodash.difference@^4.1.1: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c" + +lodash.filter@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" + +lodash.flatten@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" + +lodash.foreach@^4.3.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" + +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.map@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" + +lodash.merge@^4.4.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" + +lodash.pad@^4.1.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/lodash.pad/-/lodash.pad-4.5.1.tgz#4330949a833a7c8da22cc20f6a26c4d59debba70" + +lodash.padend@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padend/-/lodash.padend-4.6.1.tgz#53ccba047d06e158d311f45da625f4e49e6f166e" + +lodash.padstart@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b" + +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + +lodash.reduce@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + +lodash.reject@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" + +lodash.some@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" + +lodash.startswith@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.startswith/-/lodash.startswith-4.2.1.tgz#c598c4adce188a27e53145731cdc6c0e7177600c" + +lodash.template@^4.0.2: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" + dependencies: + lodash._reinterpolate "~3.0.0" + lodash.templatesettings "^4.0.0" + +lodash.templatesettings@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" + dependencies: + lodash._reinterpolate "~3.0.0" + +lodash@^4.12.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: + version "4.17.10" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" + +lolex@^2.3.2, lolex@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.7.1.tgz#e40a8c4d1f14b536aa03e42a537c7adbaf0c20be" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lowercase-keys@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" + +lru-cache@^4.0.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +make-dir@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" + dependencies: + pify "^3.0.0" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" + +marked@~0.3.6: + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" + +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + dependencies: + mimic-fn "^1.0.0" + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +meow@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/meow/-/meow-4.0.1.tgz#d48598f6f4b1472f35bf6317a95945ace347f975" + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist "^1.1.3" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + +metamocha@^1.2.5: + version "1.3.2" + resolved "https://registry.yarnpkg.com/metamocha/-/metamocha-1.3.2.tgz#13703deafd53c1ad77e1bfad37f2196cc3cecac0" + dependencies: + mocha "^3.5.3" + +mime-db@^1.28.0: + version "1.36.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397" + +mime-db@~1.35.0: + version "1.35.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.35.0.tgz#0569d657466491283709663ad379a99b90d9ab47" + +mime-types@^2.1.12, mime-types@~2.1.19: + version "2.1.19" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.19.tgz#71e464537a7ef81c15f2db9d97e913fc0ff606f0" + dependencies: + mime-db "~1.35.0" + +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + +mimic-response@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + +minimatch@^3.0.2, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +mkdirp@0.5.1, mkdirp@^0.5.1, mkdirp@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.6.8" + diff "3.2.0" + escape-string-regexp "1.0.5" + glob "7.1.1" + growl "1.9.2" + he "1.1.1" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +modify-values@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" + +mongodb-core@2.1.20: + version "2.1.20" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.20.tgz#fece8dd76b59ee7d7f2d313b65322c160492d8f1" + dependencies: + bson "~1.0.4" + require_optional "~1.0.0" + +mongodb-core@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-3.1.2.tgz#c85055a2691ac3661951e557a0d6482796ad5c42" + dependencies: + bson "^1.1.0" + require_optional "^1.0.1" + optionalDependencies: + saslprep "^1.0.0" + +mongodb-download-url@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/mongodb-download-url/-/mongodb-download-url-0.3.3.tgz#e3a8a548f13eb20f5a0cdf863cbc063421a3934c" + dependencies: + async "^2.1.2" + debug "^2.2.0" + lodash.defaults "^4.0.0" + minimist "^1.2.0" + mongodb-version-list "^1.0.0" + request "^2.65.0" + semver "^5.0.3" + +mongodb-extjson@^2.1.2: + version "2.1.4" + resolved "https://registry.yarnpkg.com/mongodb-extjson/-/mongodb-extjson-2.1.4.tgz#c7eae23bbeea9646b8f2c302764aa9540c20fe56" + dependencies: + bson "^2.0.7" + +mongodb-mock-server@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mongodb-mock-server/-/mongodb-mock-server-1.0.0.tgz#6dec212d22cc116cfd2257c8f9be3fa4dd34123d" + dependencies: + snappy "^6.0.1" + +mongodb-test-runner@^1.1.18: + version "1.3.4" + resolved "https://registry.yarnpkg.com/mongodb-test-runner/-/mongodb-test-runner-1.3.4.tgz#63dfdaa357499f07f5087570d0fdc6ef305126b4" + dependencies: + metamocha "^1.2.5" + mongodb-topology-manager "^2.0.0" + mongodb-version-manager "^1.0.7" + semver "^5.4.1" + yargs "^8.0.2" + +mongodb-topology-manager@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mongodb-topology-manager/-/mongodb-topology-manager-2.1.0.tgz#5dee0d517d1474f3003d96cc20c7a41ea9d263e9" + dependencies: + bluebird "^3.5.1" + co "^4.6.0" + kerberos "^1.0.0" + mkdirp "^0.5.1" + mongodb-core "^3.1.2" + rimraf "^2.6.2" + +mongodb-version-list@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mongodb-version-list/-/mongodb-version-list-1.0.0.tgz#f25031cfcdd6f145b1de8fce2a4ebec0288bb4a4" + dependencies: + cheerio "^0.22.0" + debug "^2.2.0" + downcache "^0.0.9" + fs-extra "^1.0.0" + minimist "^1.1.1" + semver "^5.0.1" + +mongodb-version-manager@^1.0.7: + version "1.1.3" + resolved "https://registry.yarnpkg.com/mongodb-version-manager/-/mongodb-version-manager-1.1.3.tgz#7cf543a9b33b663d09cf6f8ca91264b408418209" + dependencies: + ampersand-state "^5.0.1" + async "^2.1.2" + chalk "^2.1.0" + debug "^3.0.1" + docopt "^0.6.2" + download "^6.2.5" + figures "^2.0.0" + fs-extra "^4.0.2" + get-mongodb-version "^1.0.0" + lodash.defaults "^4.2.0" + lodash.difference "^4.1.1" + mongodb-download-url "^0.3.3" + mongodb-version-list "^1.0.0" + semver "^5.3.0" + tildify "^1.2.0" + untildify "^3.0.2" + +mongodb@^2.0.39: + version "2.2.36" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.36.tgz#1c573680b2849fb0f47acbba3dc5fa228de975f5" + dependencies: + es6-promise "3.2.1" + mongodb-core "2.1.20" + readable-stream "2.2.7" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" + +nan@^2.10.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + +nise@^1.4.2: + version "1.4.3" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.4.3.tgz#d1996e8d15256ceff1a0a1596e0c72bff370e37c" + dependencies: + "@sinonjs/formatio" "^2.0.0" + just-extend "^1.1.27" + lolex "^2.3.2" + path-to-regexp "^1.7.0" + text-encoding "^0.6.4" + +node-abi@^2.2.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.4.3.tgz#43666b7b17e57863e572409edbb82115ac7af28b" + dependencies: + semver "^5.4.1" + +noop-logger@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" + +normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: + version "2.4.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +npm-conf@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/npm-conf/-/npm-conf-1.1.3.tgz#256cc47bd0e218c259c4e9550bf413bc2192aff9" + dependencies: + config-chain "^1.1.11" + pify "^3.0.0" + +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + +npmlog@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-2.0.4.tgz#98b52530f2514ca90d09ec5b22c8846722375692" + dependencies: + ansi "~0.3.1" + are-we-there-yet "~1.1.2" + gauge "~1.2.5" + +npmlog@^4.0.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +nth-check@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4" + dependencies: + boolbase "~1.0.0" + +null-check@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + +object-assign@^4.0.1, object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-homedir@^1.0.0, os-homedir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-locale@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" + dependencies: + execa "^0.7.0" + lcid "^1.0.0" + mem "^1.1.0" + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + +p-event@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-event/-/p-event-1.3.0.tgz#8e6b4f4f65c72bc5b6fe28b75eda874f96a4a085" + dependencies: + p-timeout "^1.1.1" + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + dependencies: + p-try "^1.0.0" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + dependencies: + p-limit "^1.1.0" + +p-timeout@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386" + dependencies: + p-finally "^1.0.0" + +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + +parse-github-repo-url@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-is-inside@^1.0.1, path-is-inside@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + +path-to-regexp@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" + dependencies: + isarray "0.0.1" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: + pify "^2.0.0" + +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + dependencies: + pify "^3.0.0" + +pathval@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" + +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +pify@^2.0.0, pify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" + +prebuild-install@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.0.0.tgz#bc1a24636beaf0af7945c0a84d4b9249bf191b6b" + dependencies: + detect-libc "^1.0.3" + expand-template "^1.0.2" + github-from-package "0.0.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + node-abi "^2.2.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + os-homedir "^1.0.1" + pump "^2.0.1" + rc "^1.2.7" + simple-get "^2.7.0" + tar-fs "^1.13.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + +prettier@~1.12.0: + version "1.12.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + +progress@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" + +proto-list@~1.2.1: + version "1.2.4" + resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +psl@^1.1.24: + version "1.1.29" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" + +pump@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +q@^1.4.1, q@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" + +qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" + +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + +read-pkg-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" + dependencies: + find-up "^2.0.0" + read-pkg "^3.0.0" + +read-pkg@^1.0.0, read-pkg@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" + dependencies: + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + +readable-stream@2.2.7: + version "2.2.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.7.tgz#07057acbe2467b22042d36f98c5ad507054e95b1" + dependencies: + buffer-shims "~1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~1.0.0" + util-deprecate "~1.0.1" + +"readable-stream@>=1.0.33-1 <1.1.0-0": + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" + dependencies: + indent-string "^3.0.0" + strip-indent "^2.0.0" + +regexpp@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@^2.65.0, request@^2.69.0: + version "2.88.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.0" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.4.3" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + +require-uncached@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + +require_optional@^1.0.1, require_optional@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" + dependencies: + resolve-from "^2.0.0" + semver "^5.1.0" + +requizzle@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" + dependencies: + underscore "~1.6.0" + +resolve-from@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" + +resolve-from@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" + +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" + dependencies: + onetime "^2.0.0" + signal-exit "^3.0.2" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" + dependencies: + is-promise "^2.1.0" + +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" + +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + +samsam@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" + +saslprep@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.1.tgz#b644e0ba25b156b652f3cb90df7542f896049ba6" + +seek-bzip@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc" + dependencies: + commander "~2.8.1" + +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: + version "5.5.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" + +set-blocking@^2.0.0, set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +simple-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" + +simple-get@^2.7.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" + dependencies: + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" + +sinon@^6.0.0: + version "6.1.5" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-6.1.5.tgz#41451502d43cd5ffb9d051fbf507952400e81d09" + dependencies: + "@sinonjs/commons" "^1.0.1" + "@sinonjs/formatio" "^2.0.0" + "@sinonjs/samsam" "^2.0.0" + diff "^3.5.0" + lodash.get "^4.4.2" + lolex "^2.7.1" + nise "^1.4.2" + supports-color "^5.4.0" + type-detect "^4.0.8" + +slice-ansi@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" + dependencies: + is-fullwidth-code-point "^2.0.0" + +snappy@^6.0.1: + version "6.0.4" + resolved "https://registry.yarnpkg.com/snappy/-/snappy-6.0.4.tgz#8914f84a273270868828f3e2f10f61631aceabe5" + dependencies: + bindings "^1.3.0" + nan "^2.10.0" + +sort-keys-length@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sort-keys-length/-/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188" + dependencies: + sort-keys "^1.0.0" + +sort-keys@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" + dependencies: + is-plain-obj "^1.0.0" + +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +spdx-correct@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82" + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9" + +spdx-expression-parse@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87" + +split2@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-2.2.0.tgz#186b2575bcf83e85b7d18465756238ee4ee42493" + dependencies: + through2 "^2.0.2" + +split@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" + dependencies: + through "2" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +sshpk@^1.7.0: + version "1.14.2" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.14.2.tgz#c6fc61648a3d9c4e764fd3fcdf4ea105e492ba98" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + safer-buffer "^2.0.2" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +standard-version@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/standard-version/-/standard-version-4.4.0.tgz#99de7a0709e6cafddf9c5984dd342c8cfe66e79f" + dependencies: + chalk "^1.1.3" + conventional-changelog "^1.1.0" + conventional-recommended-bump "^1.0.0" + dotgitignore "^1.0.3" + figures "^1.5.0" + fs-access "^1.0.0" + semver "^5.1.0" + yargs "^8.0.1" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-dirs@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5" + dependencies: + is-natural-number "^4.0.1" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +strip-outer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" + dependencies: + escape-string-regexp "^1.0.2" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^5.3.0, supports-color@^5.4.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + dependencies: + has-flag "^3.0.0" + +table@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" + dependencies: + ajv "^5.2.3" + ajv-keywords "^2.1.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" + +taffydb@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" + +tar-fs@^1.13.0: + version "1.16.3" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" + dependencies: + chownr "^1.0.1" + mkdirp "^0.5.1" + pump "^1.0.0" + tar-stream "^1.1.2" + +tar-stream@^1.1.2, tar-stream@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.1.tgz#f84ef1696269d6223ca48f6e1eeede3f7e81f395" + dependencies: + bl "^1.0.0" + buffer-alloc "^1.1.0" + end-of-stream "^1.0.0" + fs-constants "^1.0.0" + readable-stream "^2.3.0" + to-buffer "^1.1.0" + xtend "^4.0.0" + +text-encoding@^0.6.4: + version "0.6.4" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" + +text-extensions@^1.0.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" + +text-table@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + +through2@^0.6.3: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@^2.0.0, through2@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" + dependencies: + readable-stream "^2.1.5" + xtend "~4.0.1" + +through@2, "through@>=2.2.7 <3", through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +tildify@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + dependencies: + os-homedir "^1.0.0" + +timed-out@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +to-buffer@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" + +tough-cookie@~2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" + dependencies: + psl "^1.1.24" + punycode "^1.4.1" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + +trim-off-newlines@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" + +trim-repeated@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" + dependencies: + escape-string-regexp "^1.0.2" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +uglify-js@^2.6: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +unbzip2-stream@^1.0.9: + version "1.2.5" + resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.2.5.tgz#73a033a567bbbde59654b193c44d48a7e4f43c47" + dependencies: + buffer "^3.0.1" + through "^2.3.6" + +underscore-contrib@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" + dependencies: + underscore "1.6.0" + +underscore@1.6.0, underscore@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" + +underscore@~1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + +untildify@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-3.0.3.tgz#1e7b42b140bcfd922b22e70ca1265bfe3634c7c9" + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + dependencies: + prepend-http "^1.0.1" + +url-to-options@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + +which-pm-runs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" + +which@^1.1.1, which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + dependencies: + isexe "^2.0.0" + +wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + dependencies: + string-width "^1.0.2 || 2" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + +xmlcreate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +y18n@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yargs-parser@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9" + dependencies: + camelcase "^4.1.0" + +yargs@^8.0.1, yargs@^8.0.2: + version "8.0.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360" + dependencies: + camelcase "^4.1.0" + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + read-pkg-up "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^7.0.0" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" + +yauzl@^2.4.2: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" diff --git a/node_modules/mongodb/.evergreen/_config.template.yml b/node_modules/mongodb/.evergreen/_config.template.yml new file mode 100644 index 0000000..93b8ff9 --- /dev/null +++ b/node_modules/mongodb/.evergreen/_config.template.yml @@ -0,0 +1,157 @@ +# When a task that used to pass starts to fail +# Go through all versions that may have been skipped to detect +# when the task started failing +stepback: true + +# Mark a failure as a system/bootstrap failure (purple box) rather then a task +# failure by default. +# Actual testing tasks are marked with `type: test` +command_type: system + +# Protect ourself against rogue test case, or curl gone wild, that runs forever +# Good rule of thumb: the averageish length a task takes, times 5 +# That roughly accounts for variable system performance for various buildvariants +exec_timeout_secs: 1800 # 6 minutes is the longest we'll ever run + +# What to do when evergreen hits the timeout (`post:` tasks are run automatically) +timeout: + - command: shell.exec + params: + script: | + ls -la + +functions: + "fetch source": + # Executes git clone and applies the submitted patch, if any + - command: git.get_project + params: + directory: "src" + # Applies the submitted patch, if any + # Deprecated. Should be removed. But still needed for certain agents (ZAP) + - command: git.apply_patch + # Make an evergreen exapanstion file with dynamic values + - command: shell.exec + params: + working_dir: "src" + script: | + # Get the current unique version of this checkout + if [ "${is_patch}" = "true" ]; then + CURRENT_VERSION=$(git describe)-patch-${version_id} + else + CURRENT_VERSION=latest + fi + + export DRIVERS_TOOLS="$(pwd)/../drivers-tools" + export PROJECT_DIRECTORY="$(pwd)" + export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" + export UPLOAD_BUCKET="${project}" + + cat < expansion.yml + CURRENT_VERSION: "$CURRENT_VERSION" + DRIVERS_TOOLS: "$DRIVERS_TOOLS" + MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME" + MONGODB_BINARIES: "$MONGODB_BINARIES" + UPLOAD_BUCKET: "$UPLOAD_BUCKET" + PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" + PREPARE_SHELL: | + set -o errexit + set -o xtrace + export DRIVERS_TOOLS="$DRIVERS_TOOLS" + export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" + export MONGODB_BINARIES="$MONGODB_BINARIES" + export UPLOAD_BUCKET="$UPLOAD_BUCKET" + export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" + + export TMPDIR="$MONGO_ORCHESTRATION_HOME/db" + export PATH="$MONGODB_BINARIES:$PATH" + export PROJECT="${project}" + EOT + # See what we've done + cat expansion.yml + + # Load the expansion file to make an evergreen variable with the current unique version + - command: expansions.update + params: + file: src/expansion.yml + + "prepare resources": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + rm -rf $DRIVERS_TOOLS + git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS + + "run tests": + - command: shell.exec + type: test + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + + "cleanup": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + rm -rf $DRIVERS_TOOLS || true + + "fix absolute paths": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do + perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename + done + + # "windows fix": + # - command: shell.exec + # params: + # script: | + # ${PREPARE_SHELL} + # for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + # cat $i | tr -d '\r' > $i.new + # mv $i.new $i + # done + # # Copy client certificate because symlinks do not work on Windows. + # cp ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem + + "make files executable": + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + chmod +x $i + done + + "install dependencies": + - command: shell.exec + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + NODE_LTS_NAME=${NODE_LTS_NAME} sh ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + + "run atlas tests": + - command: shell.exec + params: + working_dir: "src" + silent: true + script: | + # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) + NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh + +pre: + - func: "fetch source" + - func: "prepare resources" + # - func: "windows fix" + - func: "fix absolute paths" + - func: "make files executable" + - func: "install dependencies" + +post: + - func: "cleanup" diff --git a/node_modules/mongodb/.evergreen/config.yml b/node_modules/mongodb/.evergreen/config.yml new file mode 100644 index 0000000..6a32dfc --- /dev/null +++ b/node_modules/mongodb/.evergreen/config.yml @@ -0,0 +1,590 @@ +stepback: true +command_type: system +exec_timeout_secs: 1800 +timeout: + - command: shell.exec + params: + script: | + ls -la +functions: + fetch source: + - command: git.get_project + params: + directory: src + - command: git.apply_patch + - command: shell.exec + params: + working_dir: src + script: | + # Get the current unique version of this checkout + if [ "${is_patch}" = "true" ]; then + CURRENT_VERSION=$(git describe)-patch-${version_id} + else + CURRENT_VERSION=latest + fi + + export DRIVERS_TOOLS="$(pwd)/../drivers-tools" + export PROJECT_DIRECTORY="$(pwd)" + export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" + export UPLOAD_BUCKET="${project}" + + cat < expansion.yml + CURRENT_VERSION: "$CURRENT_VERSION" + DRIVERS_TOOLS: "$DRIVERS_TOOLS" + MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME" + MONGODB_BINARIES: "$MONGODB_BINARIES" + UPLOAD_BUCKET: "$UPLOAD_BUCKET" + PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" + PREPARE_SHELL: | + set -o errexit + set -o xtrace + export DRIVERS_TOOLS="$DRIVERS_TOOLS" + export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" + export MONGODB_BINARIES="$MONGODB_BINARIES" + export UPLOAD_BUCKET="$UPLOAD_BUCKET" + export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" + + export TMPDIR="$MONGO_ORCHESTRATION_HOME/db" + export PATH="$MONGODB_BINARIES:$PATH" + export PROJECT="${project}" + EOT + # See what we've done + cat expansion.yml + - command: expansions.update + params: + file: src/expansion.yml + prepare resources: + - command: shell.exec + params: + script: > + ${PREPARE_SHELL} + + rm -rf $DRIVERS_TOOLS + + git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git + $DRIVERS_TOOLS + run tests: + - command: shell.exec + type: test + params: + working_dir: src + script: > + ${PREPARE_SHELL} + + MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} AUTH=${AUTH} + SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh + ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + cleanup: + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + rm -rf $DRIVERS_TOOLS || true + fix absolute paths: + - command: shell.exec + params: + script: | + ${PREPARE_SHELL} + for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do + perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename + done + make files executable: + - command: shell.exec + params: + script: > + ${PREPARE_SHELL} + + for i in $(find ${DRIVERS_TOOLS}/.evergreen + ${PROJECT_DIRECTORY}/.evergreen -name \*.sh); do + chmod +x $i + done + install dependencies: + - command: shell.exec + params: + working_dir: src + script: > + ${PREPARE_SHELL} + + NODE_LTS_NAME=${NODE_LTS_NAME} sh + ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh + run atlas tests: + - command: shell.exec + params: + working_dir: src + silent: true + script: > + # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) + + NODE_LTS_NAME='${NODE_LTS_NAME}' ATLAS_REPL='${atlas_repl}' + ATLAS_SHRD='${atlas_shrd}' ATLAS_FREE='${atlas_free}' + ATLAS_TLS11='${atlas_tls11}' ATLAS_TLS12='${atlas_tls12}' sh + ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh +pre: + - func: fetch source + - func: prepare resources + - func: fix absolute paths + - func: make files executable + - func: install dependencies +post: + - func: cleanup +tasks: + - name: test-latest-server + tags: + - latest + - server + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: server + - name: test-latest-replica_set + tags: + - latest + - replica_set + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: replica_set + - name: test-latest-sharded_cluster + tags: + - latest + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: latest + TOPOLOGY: sharded_cluster + - name: test-4.0-server + tags: + - '4.0' + - server + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: server + - name: test-4.0-replica_set + tags: + - '4.0' + - replica_set + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: replica_set + - name: test-4.0-sharded_cluster + tags: + - '4.0' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '4.0' + TOPOLOGY: sharded_cluster + - name: test-3.6-server + tags: + - '3.6' + - server + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: server + - name: test-3.6-replica_set + tags: + - '3.6' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: replica_set + - name: test-3.6-sharded_cluster + tags: + - '3.6' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.6' + TOPOLOGY: sharded_cluster + - name: test-3.4-server + tags: + - '3.4' + - server + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: server + - name: test-3.4-replica_set + tags: + - '3.4' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: replica_set + - name: test-3.4-sharded_cluster + tags: + - '3.4' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.4' + TOPOLOGY: sharded_cluster + - name: test-3.2-server + tags: + - '3.2' + - server + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: server + - name: test-3.2-replica_set + tags: + - '3.2' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: replica_set + - name: test-3.2-sharded_cluster + tags: + - '3.2' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.2' + TOPOLOGY: sharded_cluster + - name: test-3.0-server + tags: + - '3.0' + - server + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: server + - name: test-3.0-replica_set + tags: + - '3.0' + - replica_set + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: replica_set + - name: test-3.0-sharded_cluster + tags: + - '3.0' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '3.0' + TOPOLOGY: sharded_cluster + - name: test-2.6-server + tags: + - '2.6' + - server + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: server + - name: test-2.6-replica_set + tags: + - '2.6' + - replica_set + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: replica_set + - name: test-2.6-sharded_cluster + tags: + - '2.6' + - sharded_cluster + commands: + - func: run tests + vars: + VERSION: '2.6' + TOPOLOGY: sharded_cluster +buildvariants: + - name: linux-64-amzn-test-carbon + display_name: Amazon Linux (Enterprise) Node Carbon + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_0 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - test-3.2-server + - test-3.2-replica_set + - test-3.2-sharded_cluster + - test-3.0-server + - test-3.0-replica_set + - test-3.0-sharded_cluster + - test-2.6-server + - test-2.6-replica_set + - test-2.6-sharded_cluster + - name: linux-64-amzn-test-boron + display_name: Amazon Linux (Enterprise) Node Boron + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: linux-64-amzn-test-argon + display_name: Amazon Linux (Enterprise) Node Argon + run_on: linux-64-amzn-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: ubuntu-14.04-carbon + display_name: Ubuntu 14.04 Node Carbon + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: ubuntu-14.04-boron + display_name: Ubuntu 14.04 Node Boron + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: ubuntu-14.04-argon + display_name: Ubuntu 14.04 Node Argon + run_on: ubuntu1404-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: rhel70-carbon + display_name: RHEL 7.0 Node Carbon + run_on: rhel70-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: rhel70-boron + display_name: RHEL 7.0 Node Boron + run_on: rhel70-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: rhel70-argon + display_name: RHEL 7.0 Node Argon + run_on: rhel70-small + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: debian71-test-carbon + display_name: Debian 7.1 Node Carbon + run_on: debian71-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: debian71-test-boron + display_name: Debian 7.1 Node Boron + run_on: debian71-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: debian71-test-argon + display_name: Debian 7.1 Node Argon + run_on: debian71-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: archlinux-test-carbon + display_name: Archlinux Node Carbon + run_on: archlinux-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: archlinux-test-boron + display_name: Archlinux Node Boron + run_on: archlinux-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: archlinux-test-argon + display_name: Archlinux Node Argon + run_on: archlinux-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: macos-1012-carbon + display_name: macOS 10.12 Node Carbon + run_on: macos-1012 + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_0 + - name: macos-1012-boron + display_name: macOS 10.12 Node Boron + run_on: macos-1012 + expansions: + NODE_LTS_NAME: boron + tasks: *ref_0 + - name: macos-1012-argon + display_name: macOS 10.12 Node Argon + run_on: macos-1012 + expansions: + NODE_LTS_NAME: argon + tasks: *ref_0 + - name: ubuntu-16.04-carbon + display_name: Ubuntu 16.04 Node Carbon + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_1 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - test-3.2-server + - test-3.2-replica_set + - test-3.2-sharded_cluster + - name: ubuntu-16.04-boron + display_name: Ubuntu 16.04 Node Boron + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: ubuntu-16.04-argon + display_name: Ubuntu 16.04 Node Argon + run_on: ubuntu1604-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: suse12-x86-64-test-carbon + display_name: SUSE 12 (x86_64) Node Carbon + run_on: suse12-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_1 + - name: suse12-x86-64-test-boron + display_name: SUSE 12 (x86_64) Node Boron + run_on: suse12-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: suse12-x86-64-test-argon + display_name: SUSE 12 (x86_64) Node Argon + run_on: suse12-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: rhel71-power8-test-carbon + display_name: RHEL 7.1 (POWER8) Node Carbon + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_1 + - name: rhel71-power8-test-boron + display_name: RHEL 7.1 (POWER8) Node Boron + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_1 + - name: rhel71-power8-test-argon + display_name: RHEL 7.1 (POWER8) Node Argon + run_on: rhel71-power8-test + expansions: + NODE_LTS_NAME: argon + tasks: *ref_1 + - name: debian81-test-carbon + display_name: Debian 8.1 Node Carbon + run_on: debian81-test + expansions: + NODE_LTS_NAME: carbon + tasks: &ref_2 + - test-latest-server + - test-latest-replica_set + - test-latest-sharded_cluster + - test-4.0-server + - test-4.0-replica_set + - test-4.0-sharded_cluster + - test-3.6-server + - test-3.6-replica_set + - test-3.6-sharded_cluster + - test-3.4-server + - test-3.4-replica_set + - test-3.4-sharded_cluster + - name: debian81-test-boron + display_name: Debian 8.1 Node Boron + run_on: debian81-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: suse12-zseries-test-carbon + display_name: SUSE 12 (zSeries) Node Carbon + run_on: suse12-zseries-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: suse12-zseries-test-boron + display_name: SUSE 12 (zSeries) Node Boron + run_on: suse12-zseries-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-arm64-small-carbon + display_name: Ubuntu 16.04 (ARM64) Node Carbon + run_on: ubuntu1604-arm64-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-arm64-small-boron + display_name: Ubuntu 16.04 (ARM64) Node Boron + run_on: ubuntu1604-arm64-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-power8-test-carbon + display_name: Ubuntu 16.04 (POWER8) Node Carbon + run_on: ubuntu1604-power8-test + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-power8-test-boron + display_name: Ubuntu 16.04 (POWER8) Node Boron + run_on: ubuntu1604-power8-test + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 + - name: ubuntu1604-zseries-small-carbon + display_name: Ubuntu 16.04 (zSeries) Node Carbon + run_on: ubuntu1604-zseries-small + expansions: + NODE_LTS_NAME: carbon + tasks: *ref_2 + - name: ubuntu1604-zseries-small-boron + display_name: Ubuntu 16.04 (zSeries) Node Boron + run_on: ubuntu1604-zseries-small + expansions: + NODE_LTS_NAME: boron + tasks: *ref_2 diff --git a/node_modules/mongodb/.evergreen/generate_evergreen_tasks.js b/node_modules/mongodb/.evergreen/generate_evergreen_tasks.js new file mode 100644 index 0000000..3b43e4f --- /dev/null +++ b/node_modules/mongodb/.evergreen/generate_evergreen_tasks.js @@ -0,0 +1,204 @@ +'use strict'; + +const semver = require('semver'); +const fs = require('fs'); +const yaml = require('js-yaml'); + +const MONGODB_VERSIONS = ['latest', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6']; +const NODE_VERSIONS = ['carbon', 'boron', 'argon']; +const TOPOLOGIES = ['server', 'replica_set', 'sharded_cluster']; +const OPERATING_SYSTEMS = [ + { + name: 'linux-64-amzn-test', + display_name: 'Amazon Linux (Enterprise)', + run_on: 'linux-64-amzn-test' + }, + { + name: 'ubuntu-14.04', + display_name: 'Ubuntu 14.04', + run_on: 'ubuntu1404-test' + }, + { + name: 'rhel70', + display_name: 'RHEL 7.0', + run_on: 'rhel70-small' + }, + { + name: 'debian71-test', + display_name: 'Debian 7.1', + run_on: 'debian71-test' + }, + + // OSes that support versions of MongoDB without SSL. + { + name: 'archlinux-test', + display_name: 'Archlinux', + run_on: 'archlinux-test', + auth: false + }, + { + name: 'macos-1012', + display_name: 'macOS 10.12', + run_on: 'macos-1012', + auth: false + }, + + // >= 3.2 + { + name: 'ubuntu-16.04', + display_name: 'Ubuntu 16.04', + run_on: 'ubuntu1604-test', + mongoVersion: '>=3.2' + }, + { + name: 'suse12-x86-64-test', + display_name: 'SUSE 12 (x86_64)', + run_on: 'suse12-test', + mongoVersion: '>=3.2' + }, + { + name: 'rhel71-power8-test', + display_name: 'RHEL 7.1 (POWER8)', + run_on: 'rhel71-power8-test', + mongoVersion: '>=3.2' + }, + + // >= 3.4 + { + name: 'debian81-test', + display_name: 'Debian 8.1', + run_on: 'debian81-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + // reenable when these are actually running 7.2, or we release a 7.4 rpm + // { + // name: 'rhel72-zseries-test', + // display_name: 'RHEL 7.2 (zSeries)', + // run_on: 'rhel72-zseries-test', + // mongoVersion: '>=3.4', + // nodeVersion: 'boron' + // }, + { + name: 'suse12-zseries-test', + display_name: 'SUSE 12 (zSeries)', + run_on: 'suse12-zseries-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-arm64-small', + display_name: 'Ubuntu 16.04 (ARM64)', + run_on: 'ubuntu1604-arm64-small', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-power8-test', + display_name: 'Ubuntu 16.04 (POWER8)', + run_on: 'ubuntu1604-power8-test', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + { + name: 'ubuntu1604-zseries-small', + display_name: 'Ubuntu 16.04 (zSeries)', + run_on: 'ubuntu1604-zseries-small', + mongoVersion: '>=3.4', + nodeVersion: 'boron' + }, + + // Windows. reenable this when nvm supports windows, or we settle on an alternative tool + // { + // name: 'windows-64-vs2010-test', + // display_name: 'Windows (VS2010)', + // run_on: 'windows-64-vs2010-test' + // }, + // { + // name: 'windows-64-vs2013-test', + // display_name: 'Windows (VS2013)', + // run_on: 'windows-64-vs2013-test' + // }, + // { + // name: 'windows-64-vs2015-test', + // display_name: 'Windows (VS2015)', + // run_on: 'windows-64-vs2015-test' + // } +].map(osConfig => Object.assign({ + mongoVersion: '>=2.6', + nodeVersion: 'argon', + auth: false + }, osConfig) +); + +const TASKS = []; + +function makeTask({ mongoVersion, topology }) { + return { + name: `test-${mongoVersion}-${topology}`, + tags: [mongoVersion, topology], + commands: [ + { + func: 'run tests', + vars: { + VERSION: mongoVersion, + TOPOLOGY: topology + } + } + ] + }; +} + +MONGODB_VERSIONS.forEach(mongoVersion => { + TOPOLOGIES.forEach(topology => { + TASKS.push(makeTask({ mongoVersion, topology })); + }); +}); + +const BUILD_VARIANTS = []; + +const getTaskList = (() => { + const memo = {}; + return function(mongoVersion) { + const key = mongoVersion; + + if (memo[key]) { + return memo[key]; + } + + const ret = TASKS.filter(task => { + const { VERSION } = task.commands[0].vars; + + if (VERSION === 'latest') { + return true; + } + + return semver.satisfies(semver.coerce(VERSION), mongoVersion); + }).map(x => x.name); + + memo[key] = ret; + return ret; + } +})(); + +OPERATING_SYSTEMS.forEach( + ({ name: osName, display_name: osDisplayName, run_on, mongoVersion = '>=2.6', nodeVersion = 'argon' }) => { + const nodeVersions = NODE_VERSIONS.filter(nv => nv >= nodeVersion); + const tasks = getTaskList(mongoVersion); + + nodeVersions.forEach(NODE_LTS_NAME => { + const nodeLtsDisplayName = `Node ${NODE_LTS_NAME[0].toUpperCase()}${NODE_LTS_NAME.substr(1)}`; + const name = `${osName}-${NODE_LTS_NAME}`; + const display_name = `${osDisplayName} ${nodeLtsDisplayName}`; + const expansions = { NODE_LTS_NAME }; + BUILD_VARIANTS.push({ name, display_name, run_on, expansions, tasks }); + }); + } +); + +const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/_config.template.yml`, 'utf8')) + +fileData.tasks = (fileData.tasks || []).concat(TASKS); +fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS); + +fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData), 'utf8'); diff --git a/node_modules/mongodb/.evergreen/install-dependencies.sh b/node_modules/mongodb/.evergreen/install-dependencies.sh new file mode 100644 index 0000000..5ea5f72 --- /dev/null +++ b/node_modules/mongodb/.evergreen/install-dependencies.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +NODE_LTS_NAME=${NODE_LTS_NAME:-carbon} +NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" +NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm" +NPM_TMP_DIR="${NODE_ARTIFATS_PATH}/tmp" + +# this needs to be explicitly exported for the nvm install below +export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" + +# create node artifacts path if needed +mkdir -p ${NODE_ARTIFACTS_PATH} +mkdir -p ${NPM_CACHE_DIR} +mkdir -p "${NPM_TMP_DIR}" + +# install Node.js +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash +[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" +nvm install --lts=${NODE_LTS_NAME} + +# setup npm cache in a local directory +cat < .npmrc +devdir=${NPM_CACHE_DIR}/.node-gyp +init-module=${NPM_CACHE_DIR}/.npm-init.js +cache=${NPM_CACHE_DIR} +tmp=${NPM_TMP_DIR} +EOT + +# install node dependencies +npm install diff --git a/node_modules/mongodb/.evergreen/run-tests.sh b/node_modules/mongodb/.evergreen/run-tests.sh new file mode 100755 index 0000000..713f54b --- /dev/null +++ b/node_modules/mongodb/.evergreen/run-tests.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +# Supported/used environment variables: +# AUTH Set to enable authentication. Defaults to "noauth" +# SSL Set to enable SSL. Defaults to "nossl" +# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) +# MARCH Machine Architecture. Defaults to lowercase uname -m + +AUTH=${AUTH:-noauth} +SSL=${SSL:-nossl} +MONGODB_URI=${MONGODB_URI:-} +DRIVERS_TOOLS=${DRIVERS_TOOLS:-} +MONGODB_VERSION=${MONGODB_VERSION:-} + +# install MongoDB +# Functions to fetch MongoDB binaries +. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh + +get_distro +if [ -z "$MONGODB_DOWNLOAD_URL" ]; then + get_mongodb_download_url_for "$DISTRO" "$MONGODB_VERSION" +fi +# Even though we have the MONGODB_DOWNLOAD_URL, we still call this to get the proper EXTRACT variable +get_mongodb_download_url_for "$DISTRO" +download_and_extract "$MONGODB_DOWNLOAD_URL" "$EXTRACT" + +# run tests +echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI" + +export PATH="/opt/mongodbtoolchain/v2/bin:$PATH" +NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" +export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +MONGODB_VERSION=${MONGODB_VERSION} MONGODB_ENVIRONMENT=${TOPOLOGY} npm test -- --local diff --git a/node_modules/mongodb/CHANGES_3.0.0.md b/node_modules/mongodb/CHANGES_3.0.0.md new file mode 100644 index 0000000..66cd5d7 --- /dev/null +++ b/node_modules/mongodb/CHANGES_3.0.0.md @@ -0,0 +1,316 @@ +## Features + +The following are new features added in MongoDB 3.6 and supported in the Node.js driver. + +### Retryable Writes + +Support has been added for retryable writes through the connection string. MongoDB 3.6 +will utilize server sessions to allow some write commands to specify a transaction ID to enforce +at-most-once semantics for the write operation(s) and allow for retrying the operation if the driver +fails to obtain a write result (e.g. network error or "not master" error after a replica set +failover)Full details can be found in the [Retryable Writes Specification](https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.rst). + + +### DNS Seedlist Support + +Support has been added for DNS Seedlists. Users may now configure a single domain to return a list +of host names. Full details can be found in the [Seedlist Discovery Specification](https://github.com/mongodb/specifications/blob/master/source/initial-dns-seedlist-discovery/initial-dns-seedlist-discovery.rst). + +### Change Streams + +Support has been added for creating a stream to track changes to a particular collection. This is a +new feature in MongoDB 3.6. Full details can be found in the [Change Stream Specification](https://github.com/mongodb/specifications/blob/master/source/change-streams.rst) as +well as [examples in the test directory](https://github.com/mongodb/node-mongodb-native/blob/3.0.0/test/functional/operation_changestream_example_tests.js). + +### Sessions + +Version 3.6 of the server introduces the concept of logical sessions for clients. In this driver, +`MongoClient` now tracks all sessions created on the client, and explicitly cleans them up upon +client close. More information can be found in the [Driver Sessions Specification](https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst). + +## API Changes + +We removed the following API methods. + +- `Db.prototype.authenticate` +- `Db.prototype.logout` +- `Db.prototype.open` +- `Db.prototype.db` +- `Db.prototype.close` +- `Admin.prototype.authenticate` +- `Admin.prototype.logout` +- `Admin.prototype.profilingLevel` +- `Admin.prototype.setProfilingLevel` +- `Admin.prototype.profilingInfo` +- `Cursor.prototype.nextObject` + +We've added the following API methods. +- `MongoClient.prototype.logout` +- `MongoClient.prototype.isConnected` +- `MongoClient.prototype.db` +- `MongoClient.prototype.close` +- `MongoClient.prototype.connect` +- `Db.prototype.profilingLevel` +- `Db.prototype.setProfilingLevel` +- `Db.prototype.profilingInfo` + +In core we have removed the possibility of authenticating multiple credentials against the same +connection pool. This is to avoid problems with MongoDB 3.6 or higher where all users will reside in +the admin database and thus database level authentication is no longer supported. + +The legacy construct + +```js +var db = var Db('test', new Server('localhost', 27017)); +db.open((err, db) => { + // Authenticate + db.admin().authenticate('root', 'root', (err, success) => { + .... + }); +}); +``` + +is replaced with + +```js +new MongoClient(new Server('localhost', 27017), { + user: 'root' + , password: 'root' + , authSource: 'adming'}).connect((err, client) => { + .... + }) +``` + +`MongoClient.connect` works as expected but it returns the MongoClient instance instead of a +database object. + +The legacy operation + +```js +MongoClient.connect('mongodb://localhost:27017/test', (err, db) => { + // Database returned +}); +``` + +is replaced with + +```js +MongoClient.connect('mongodb://localhost:27017/test', (err, client) => { + // Client returned + var db = client.db('test'); +}); +``` + +The database specified in the connection string will be set as the default database of the +returned client. The default database is now used if no parameter is passed to +`MongoClient.prototype.db`, for example: + +```js +MongoClient.connect('mongodb://localhost:27017/test') + .then(client => client.db().collection('foo').insert({ a: 42 }) + .then(() => ...) + .catch(err => ...); +``` + +## Other Changes + +Below are more updates to the driver in the 3.0.0 release. + +### Connection String + +Following [changes to the MongoDB connection string specification](https://github.com/mongodb/specifications/commit/4631ccd4f825fb1a3aba204510023f9b4d193a05), +authentication and hostname details in connection strings must now be URL-encoded. These changes +reduce ambiguity in connection strings. + +For example, whereas before `mongodb://u$ername:pa$$w{}rd@/tmp/mongodb-27017.sock/test` would have +been a valid connection string (with username `u$ername`, password `pa$$w{}rd`, host `/tmp/mongodb-27017.sock` +and auth database `test`), the connection string for those details would now have to be provided to +MongoClient as `mongodb://u%24ername:pa%24%24w%7B%7Drd@%2Ftmp%2Fmongodb-27017.sock/test`. + +Unsupported URL options in a connection string now log a warning instead of throwing an error. + +For more information about connection strings, read the [connection string specification](https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst). + + +### `BulkWriteResult` & `BulkWriteError` + +When errors occured with bulk write operations in the past, the driver would callback or reject with +the first write error, as well as passing the resulting `BulkWriteResult`. For example: + +```js +MongoClient.connect('mongodb://localhost', function(err, client) { + const collection = client.db('foo').collection('test-collection') + + collection + .insert({ id: 1 }) + .then(() => collection.insertMany([ { id: 1 }, { id: 1 } ])) + .then(result => /* deal with errors in `result */) + .catch(err => /* no error is thrown for bulk errors */); +}); +``` + +becomes: + +```js +MongoClient.connect('mongodb://localhost', function(err, client) { + const collection = client.db('foo').collection('test-collection') + + collection + .insert({ id: 1 }) + .then(() => collection.insertMany([ { id: 1 }, { id: 1 } ])) + .then(() => /* this will not be called in the event of a bulk write error */) + .catch(err => /* deal with errors in `err` */); +}); +``` + +Where the result of the failed operation is a `BulkWriteError` which has a child value `result` +which is the original `BulkWriteResult`. Similarly, the callback form no longer calls back with an +`(Error, BulkWriteResult)`, but instead just a `(BulkWriteError)`. + +### `mapReduce` inlined results + +When `Collection.prototype.mapReduce` is invoked with a callback that includes `out: 'inline'`, +it would diverge from the `Promise`-based variant by returning additional data as positional +arguments to the callback (`(err, result, stats, ...)`). This is no longer the case, both variants +of the method will now return a single object for all results - a single value for the default case, +and an object similar to the existing `Promise` form for cases where there is more data to pass to +the user. + +### Find + +`find` and `findOne` no longer support the `fields` parameter. You can achieve the same results as +the `fields` parameter by using `Cursor.prototype.project` or by passing the `projection` property +in on the options object . Additionally, `find` does not support individual options like `skip` and +`limit` as positional parameters. You must either pass in these parameters in the `options` object, +or add them via `Cursor` methods like `Cursor.prototype.skip`. + +2.x syntax: + +```js +const cursor = coll.find({ a: 42 }, { someField: 1 }); +``` + +3.x syntax: + +``` +const cursor = coll.find({ a: 42 }).project({ someField: 1 }); + +/* OR */ + +const cursor = coll.find({ a: 42 }, { projection: { someField: 1 } }); +``` + + +### `Collection.prototype.aggregate` + +`Collection.prototype.aggregate` no longer accepts variadic arguments. While this +was originally added to improve compatibility with the mongo shell, it has never +been a documented feature, and has led to more bugs and maintenance burden. +Pipeline stages are now only accepted as an `Array` of stages as the first argument. + +2.x syntax: + +```js +collection.prototype.aggregate( + {$match: {a: 1}}, + {$project: {b: 1, _id: 0}}, + function (err, result) { + ... + } +); +``` + +3.x syntax + +```js +collection.prototype.aggregate( + [ + {$match: {a: 1}}, + {$project: {b: 1, _id: 0}} + ], + function (err, cursor) { + ... + } +); +``` + +`Collection.prototype.aggregate` now returns a cursor if a callback is provided. It used to return +the resulting documents which is the same as calling `cursor.toArray()` on the cursor we now pass to +the callback. + +2.x syntax + +```js +collection.prototype.aggregate( + [ + {$match: {a: 1}}, + {$project: {b: 1, _id: 0}} + ], + function (err, result) { + console.log(result); + } +); +``` + +3.x syntax + +```js +collection.prototype.aggregate( + [ + {$match: {a: 1}}, + {$project: {b: 1, _id: 0}} + ], + function (err, cursor) { + cursor.toArray(function(err, result) { + console.log(result); + }); + } +); +``` + +Support added for `comment` in the aggregation command. Support also added for a `hint` field in the +aggregation `options`. + +If you use aggregation and try to use the `explain` flag while you have a `readConcern` or +`writeConcern`, your query will now fail. + +### `updateOne` & `updateMany` + +The driver now ensures that updated documents contain atomic operators. For instance, if a user +tries to update an existing document but passes in no operations (such as `$set`, `$unset`, or +`$rename`), the driver will now error: + +```js + +let testCollection = db.collection('test'); +testCollection.updateOne({_id: 'test'}, {}); +// An error is returned: The update operation document must contain at least one atomic operator. +``` + +### `keepAlive` + +Wherever it occurs, the option `keepAlive` has been changed. `keepAlive` is now a boolean that enables/disables `keepAlive`, while `keepAliveInitialDelay` specifies how long to wait before initiating keepAlive. This brings the API in line with [NodeJS's socket api](https://nodejs.org/dist/latest-v9.x/docs/api/all.html#net_socket_setkeepalive_enable_initialdelay) + +### `insertMany` + +Now `insertMany` returns `insertedIds` in a map of the index of the inserted document to the id of the inserted document: + +```js +{ + "0": 2, + "1": 3 +} +``` + +Previously an array of ids was returned: `[ 2, 3 ]`. This change occurs with both ordered and unordered `insertMany` calls, see the [CRUD specifications](https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#results) for more details. + +### `geoNear` command helper + +The functionality of the geoNear command is duplicated elsewhere in the language, in the `$near`/`$nearSphere` query operators on unsharded collections, and in the `$geoNear` aggregation stage on all collections. Maintaining this command increases our test surface, and creates additional work when adding features that must be supported on all read commands. As a result, the command will be fully +removed in the MongoDB 4.0 release, and we are choosing to remove it in this +major release of the node driver. + +### Tests + +We have updated all of the tests to use [Mocha](https://mochajs.org) and a new test runner, [`mongodb-test-runner`](https://github.com/mongodb-js/mongodb-test-runner), which +sets up topologies for the test scenarios. diff --git a/node_modules/mongodb/CODE_OF_CONDUCT.md b/node_modules/mongodb/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..cd87e95 --- /dev/null +++ b/node_modules/mongodb/CODE_OF_CONDUCT.md @@ -0,0 +1,80 @@ +## Code of Conduct + +### Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, +body size, disability, ethnicity, gender identity and expression, level of +experience, nationality, personal appearance, race, religion, or sexual +identity and orientation. + +Please also take a moment to review [MongoDB's core values][mdb-core-values]. + +### Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +### Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +### Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an +appointed representative at an online or offline event. Representation of a +project may be further defined and clarified by project maintainers. + +### Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team, or by +[contacting GitHub][github-report-abuse]. All complaints will be reviewed +and investigated and will result in a response that is deemed necessary and +appropriate to the circumstances. The project team is obligated to maintain +confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +### Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version [1.4][version]. + + +[github-report-abuse]: https://github.com/contact/report-abuse +[homepage]: https://www.contributor-covenant.org/ +[mdb-core-values]: https://www.mongodb.com/company/ +[version]: https://www.contributor-covenant.org/version/1/4/ diff --git a/node_modules/mongodb/CONTRIBUTING.md b/node_modules/mongodb/CONTRIBUTING.md new file mode 100644 index 0000000..5994b0b --- /dev/null +++ b/node_modules/mongodb/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish +to make via issue, pull request, or any other method with the owners of this +repository before making a change. + +Please note we have a [code of conduct][code-of-conduct], +please follow it in all your interactions with the project. + +## Commit messages + +Please follow the [Angular commit style][angular-commit-style]. +This helps the team automate [HISTORY.md](HISTORY.md) generation. + +## Pull Request Process + +1. Update the README.md or similar documentation with details of changes you + wish to make, if applicable. +2. Add any appropriate tests. +3. Make your code or other changes. +4. Review guidelines such as + [How to write the perfect pull request][github-perfect-pr], thanks! + + +[angular-commit-style]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits +[changelog]: CHANGELOG.md +[code-of-conduct]: CODE_OF_CONDUCT.md +[github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/ +[mdb-core-values]: https://www.mongodb.com/company/ diff --git a/node_modules/mongodb/HISTORY.md b/node_modules/mongodb/HISTORY.md index 3c5bd16..367d10c 100644 --- a/node_modules/mongodb/HISTORY.md +++ b/node_modules/mongodb/HISTORY.md @@ -1,44 +1,385 @@ - -## [2.2.34](https://github.com/mongodb/node-mongodb-native/compare/v2.2.33...v2.2.34) (2018-01-03) +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +## [3.1.4](https://github.com/mongodb/node-mongodb-native/compare/v3.1.3...v3.1.4) (2018-08-25) ### Bug Fixes -* **collection:** allow { upsert: 1 } for findOneAndUpdate() and update() ([#1580](https://github.com/mongodb/node-mongodb-native/issues/1580)) ([0f338c8](https://github.com/mongodb/node-mongodb-native/commit/0f338c8)), closes [Automattic/mongoose#5839](https://github.com/Automattic/mongoose/issues/5839) -* **GridFS:** fix TypeError: doc.data.length is not a function ([811de0c](https://github.com/mongodb/node-mongodb-native/commit/811de0c)) -* **import:** adds missing import to lib/authenticate.js ([10db9a2](https://github.com/mongodb/node-mongodb-native/commit/10db9a2)) -* **list-collections:** ensure default of primary ReadPreference ([0935306](https://github.com/mongodb/node-mongodb-native/commit/0935306)) +* **buffer:** use safe-buffer polyfill to maintain compatibility ([327da95](https://github.com/mongodb/node-mongodb-native/commit/327da95)) +* **change-stream:** properly support resumablity in stream mode ([c43a34b](https://github.com/mongodb/node-mongodb-native/commit/c43a34b)) +* **connect:** correct replacement of topology on connect callback ([918a1e0](https://github.com/mongodb/node-mongodb-native/commit/918a1e0)) +* **cursor:** remove deprecated notice on forEach ([a474158](https://github.com/mongodb/node-mongodb-native/commit/a474158)) +* **url-parser:** bail early on validation when using domain socket ([3cb3da3](https://github.com/mongodb/node-mongodb-native/commit/3cb3da3)) ### Features -* **ssl:** adds missing ssl options ssl options for `ciphers` and `ecdhCurve` ([bd4fb53](https://github.com/mongodb/node-mongodb-native/commit/bd4fb53)) -* **url parser:** add dns seedlist support ([2d357bc](https://github.com/mongodb/node-mongodb-native/commit/2d357bc)) -* **core**: update mongodb-core to 2.1.18 +* **client-ops:** allow bypassing creation of topologies on connect ([fe39b93](https://github.com/mongodb/node-mongodb-native/commit/fe39b93)) +* **core:** update mongodb-core to 3.1.3 ([a029047](https://github.com/mongodb/node-mongodb-native/commit/a029047)) +* **test:** use connection strings for all calls to `newClient` ([1dac18f](https://github.com/mongodb/node-mongodb-native/commit/1dac18f)) -2.2.33 2017-10-12 ------------------ -* update to mongodb-core 2.1.17 -2.2.32 2017-10-11 ------------------ -* update to mongodb-core 2.1.16 -* ensure that the `cursor` key is always present in aggregation commands -* `Cursor.prototype.hasNext` now propagates errors when using callback -* allow passing `noCursorTimeout` as an option to `find()` -* bubble up `reconnectFailed` event from Server topology + +## [3.1.3](https://github.com/mongodb/node-mongodb-native/compare/v3.1.2...v3.1.3) (2018-08-13) + + +### Features + +* **core:** update to mongodb-core 3.1.2 ([337cb79](https://github.com/mongodb/node-mongodb-native/commit/337cb79)) + + + + +## [3.1.2](https://github.com/mongodb/node-mongodb-native/compare/v3.0.6...v3.1.2) (2018-08-13) + + +### Bug Fixes + +* **aggregte:** support user-provided `batchSize` ([ad10dee](https://github.com/mongodb/node-mongodb-native/commit/ad10dee)) +* **buffer:** replace deprecated Buffer constructor ([759dd85](https://github.com/mongodb/node-mongodb-native/commit/759dd85)) +* **bulk:** fixing retryable writes for mass-change ops ([0604036](https://github.com/mongodb/node-mongodb-native/commit/0604036)) +* **bulk:** handle MongoWriteConcernErrors ([12ff392](https://github.com/mongodb/node-mongodb-native/commit/12ff392)) +* **change_stream:** do not check isGetMore if error[mongoErrorContextSymbol] is undefined ([#1720](https://github.com/mongodb/node-mongodb-native/issues/1720)) ([844c2c8](https://github.com/mongodb/node-mongodb-native/commit/844c2c8)) +* **change-stream:** fix change stream resuming with promises ([3063f00](https://github.com/mongodb/node-mongodb-native/commit/3063f00)) +* **client-ops:** return transform map to map rather than function ([cfb7d83](https://github.com/mongodb/node-mongodb-native/commit/cfb7d83)) +* **collection:** correctly shallow clone passed in options ([7727700](https://github.com/mongodb/node-mongodb-native/commit/7727700)) +* **collection:** countDocuments throws error when query doesn't match docs ([09c7d8e](https://github.com/mongodb/node-mongodb-native/commit/09c7d8e)) +* **collection:** depend on `resolveReadPreference` for inheritance ([a649e35](https://github.com/mongodb/node-mongodb-native/commit/a649e35)) +* **collection:** ensure findAndModify always use readPreference primary ([86344f4](https://github.com/mongodb/node-mongodb-native/commit/86344f4)) +* **collection:** isCapped returns false instead of undefined ([b8471f1](https://github.com/mongodb/node-mongodb-native/commit/b8471f1)) +* **collection:** only send bypassDocumentValidation if true ([fdb828b](https://github.com/mongodb/node-mongodb-native/commit/fdb828b)) +* **count-documents:** return callback on error case ([fca1185](https://github.com/mongodb/node-mongodb-native/commit/fca1185)) +* **cursor:** cursor count with collation fix ([71879c3](https://github.com/mongodb/node-mongodb-native/commit/71879c3)) +* **cursor:** cursor hasNext returns false when exhausted ([184b817](https://github.com/mongodb/node-mongodb-native/commit/184b817)) +* **cursor:** cursor.count not respecting parent readPreference ([5a9fdf0](https://github.com/mongodb/node-mongodb-native/commit/5a9fdf0)) +* **cursor:** set readPreference for cursor.count ([13d776f](https://github.com/mongodb/node-mongodb-native/commit/13d776f)) +* **db:** don't send session down to createIndex command ([559c195](https://github.com/mongodb/node-mongodb-native/commit/559c195)) +* **db:** throw readable error when creating `_id` with background: true ([b3ff3ed](https://github.com/mongodb/node-mongodb-native/commit/b3ff3ed)) +* **db_ops:** call collection.find() with correct parameters ([#1795](https://github.com/mongodb/node-mongodb-native/issues/1795)) ([36e92f1](https://github.com/mongodb/node-mongodb-native/commit/36e92f1)) +* **db_ops:** fix two incorrectly named variables ([15dc808](https://github.com/mongodb/node-mongodb-native/commit/15dc808)) +* **findOneAndUpdate:** ensure that update documents contain atomic operators ([eb68074](https://github.com/mongodb/node-mongodb-native/commit/eb68074)) +* **index:** export MongoNetworkError ([98ab29e](https://github.com/mongodb/node-mongodb-native/commit/98ab29e)) +* **mongo_client:** translate options for connectWithUrl ([78f6977](https://github.com/mongodb/node-mongodb-native/commit/78f6977)) +* **mongo-client:** pass arguments to ctor when new keyword is used ([d6c3417](https://github.com/mongodb/node-mongodb-native/commit/d6c3417)) +* **mongos:** bubble up close events after the first one ([#1713](https://github.com/mongodb/node-mongodb-native/issues/1713)) ([3e91d77](https://github.com/mongodb/node-mongodb-native/commit/3e91d77)), closes [Automattic/mongoose#6249](https://github.com/Automattic/mongoose/issues/6249) [#1685](https://github.com/mongodb/node-mongodb-native/issues/1685) +* **parallelCollectionScan:** do not use implicit sessions on cursors ([2de470a](https://github.com/mongodb/node-mongodb-native/commit/2de470a)) +* **retryWrites:** fixes more bulk ops to not use retryWrites ([69e5254](https://github.com/mongodb/node-mongodb-native/commit/69e5254)) +* **server:** remove unnecessary print statement ([2bcbc12](https://github.com/mongodb/node-mongodb-native/commit/2bcbc12)) +* **teardown:** properly destroy a topology when initial connect fails ([b8d2f1d](https://github.com/mongodb/node-mongodb-native/commit/b8d2f1d)) +* **topology-base:** sending `endSessions` is always skipped now ([a276cbe](https://github.com/mongodb/node-mongodb-native/commit/a276cbe)) +* **txns:** omit writeConcern when in a transaction ([b88c938](https://github.com/mongodb/node-mongodb-native/commit/b88c938)) +* **utils:** restructure inheritance rules for read preferences ([6a7dac1](https://github.com/mongodb/node-mongodb-native/commit/6a7dac1)) + + +### Features + +* **auth:** add support for SCRAM-SHA-256 ([f53195d](https://github.com/mongodb/node-mongodb-native/commit/f53195d)) +* **changeStream:** Adding new 4.0 ChangeStream features ([2cb4894](https://github.com/mongodb/node-mongodb-native/commit/2cb4894)) +* **changeStream:** allow resuming on getMore errors ([4ba5adc](https://github.com/mongodb/node-mongodb-native/commit/4ba5adc)) +* **changeStream:** expanding changeStream resumable errors ([49fbafd](https://github.com/mongodb/node-mongodb-native/commit/49fbafd)) +* **ChangeStream:** update default startAtOperationTime ([50a9f65](https://github.com/mongodb/node-mongodb-native/commit/50a9f65)) +* **collection:** add colleciton level document mapping/unmapping ([d03335e](https://github.com/mongodb/node-mongodb-native/commit/d03335e)) +* **collection:** Implement new count API ([a5240ae](https://github.com/mongodb/node-mongodb-native/commit/a5240ae)) +* **Collection:** warn if callback is not function in find and findOne ([cddaba0](https://github.com/mongodb/node-mongodb-native/commit/cddaba0)) +* **core:** bump core dependency to v3.1.0 ([4937240](https://github.com/mongodb/node-mongodb-native/commit/4937240)) +* **cursor:** new cursor.transformStream method ([397fcd2](https://github.com/mongodb/node-mongodb-native/commit/397fcd2)) +* **deprecation:** create deprecation function ([4f907a0](https://github.com/mongodb/node-mongodb-native/commit/4f907a0)) +* **deprecation:** wrap deprecated functions ([a5d0f1d](https://github.com/mongodb/node-mongodb-native/commit/a5d0f1d)) +* **GridFS:** add option to disable md5 in file upload ([704a88e](https://github.com/mongodb/node-mongodb-native/commit/704a88e)) +* **listCollections:** add support for nameOnly option ([d2d0367](https://github.com/mongodb/node-mongodb-native/commit/d2d0367)) +* **parallelCollectionScan:** does not allow user to pass a session ([4da9e03](https://github.com/mongodb/node-mongodb-native/commit/4da9e03)) +* **read-preference:** add transaction to inheritance rules ([18ca41d](https://github.com/mongodb/node-mongodb-native/commit/18ca41d)) +* **read-preference:** unify means of read preference resolution ([#1738](https://github.com/mongodb/node-mongodb-native/issues/1738)) ([2995e11](https://github.com/mongodb/node-mongodb-native/commit/2995e11)) +* **urlParser:** use core URL parser ([c1c5d8d](https://github.com/mongodb/node-mongodb-native/commit/c1c5d8d)) +* **withSession:** add top level helper for session lifetime ([9976b86](https://github.com/mongodb/node-mongodb-native/commit/9976b86)) + + +### Reverts + +* **collection:** reverting collection-mapping features ([7298c76](https://github.com/mongodb/node-mongodb-native/commit/7298c76)), closes [#1698](https://github.com/mongodb/node-mongodb-native/issues/1698) [mongodb/js-bson#253](https://github.com/mongodb/js-bson/issues/253) + + + + +# [3.1.0](https://github.com/mongodb/node-mongodb-native/compare/v3.0.6...v3.1.0) (2018-06-27) + + +### Bug Fixes + +* **aggregte:** support user-provided `batchSize` ([ad10dee](https://github.com/mongodb/node-mongodb-native/commit/ad10dee)) +* **bulk:** fixing retryable writes for mass-change ops ([0604036](https://github.com/mongodb/node-mongodb-native/commit/0604036)) +* **bulk:** handle MongoWriteConcernErrors ([12ff392](https://github.com/mongodb/node-mongodb-native/commit/12ff392)) +* **change_stream:** do not check isGetMore if error[mongoErrorContextSymbol] is undefined ([#1720](https://github.com/mongodb/node-mongodb-native/issues/1720)) ([844c2c8](https://github.com/mongodb/node-mongodb-native/commit/844c2c8)) +* **change-stream:** fix change stream resuming with promises ([3063f00](https://github.com/mongodb/node-mongodb-native/commit/3063f00)) +* **collection:** depend on `resolveReadPreference` for inheritance ([a649e35](https://github.com/mongodb/node-mongodb-native/commit/a649e35)) +* **collection:** only send bypassDocumentValidation if true ([fdb828b](https://github.com/mongodb/node-mongodb-native/commit/fdb828b)) +* **cursor:** cursor count with collation fix ([71879c3](https://github.com/mongodb/node-mongodb-native/commit/71879c3)) +* **cursor:** cursor hasNext returns false when exhausted ([184b817](https://github.com/mongodb/node-mongodb-native/commit/184b817)) +* **cursor:** cursor.count not respecting parent readPreference ([5a9fdf0](https://github.com/mongodb/node-mongodb-native/commit/5a9fdf0)) +* **db:** don't send session down to createIndex command ([559c195](https://github.com/mongodb/node-mongodb-native/commit/559c195)) +* **db:** throw readable error when creating `_id` with background: true ([b3ff3ed](https://github.com/mongodb/node-mongodb-native/commit/b3ff3ed)) +* **findOneAndUpdate:** ensure that update documents contain atomic operators ([eb68074](https://github.com/mongodb/node-mongodb-native/commit/eb68074)) +* **index:** export MongoNetworkError ([98ab29e](https://github.com/mongodb/node-mongodb-native/commit/98ab29e)) +* **mongo-client:** pass arguments to ctor when new keyword is used ([d6c3417](https://github.com/mongodb/node-mongodb-native/commit/d6c3417)) +* **mongos:** bubble up close events after the first one ([#1713](https://github.com/mongodb/node-mongodb-native/issues/1713)) ([3e91d77](https://github.com/mongodb/node-mongodb-native/commit/3e91d77)), closes [Automattic/mongoose#6249](https://github.com/Automattic/mongoose/issues/6249) [#1685](https://github.com/mongodb/node-mongodb-native/issues/1685) +* **parallelCollectionScan:** do not use implicit sessions on cursors ([2de470a](https://github.com/mongodb/node-mongodb-native/commit/2de470a)) +* **retryWrites:** fixes more bulk ops to not use retryWrites ([69e5254](https://github.com/mongodb/node-mongodb-native/commit/69e5254)) +* **topology-base:** sending `endSessions` is always skipped now ([a276cbe](https://github.com/mongodb/node-mongodb-native/commit/a276cbe)) +* **txns:** omit writeConcern when in a transaction ([b88c938](https://github.com/mongodb/node-mongodb-native/commit/b88c938)) +* **utils:** restructure inheritance rules for read preferences ([6a7dac1](https://github.com/mongodb/node-mongodb-native/commit/6a7dac1)) + + +### Features + +* **auth:** add support for SCRAM-SHA-256 ([f53195d](https://github.com/mongodb/node-mongodb-native/commit/f53195d)) +* **changeStream:** Adding new 4.0 ChangeStream features ([2cb4894](https://github.com/mongodb/node-mongodb-native/commit/2cb4894)) +* **changeStream:** allow resuming on getMore errors ([4ba5adc](https://github.com/mongodb/node-mongodb-native/commit/4ba5adc)) +* **changeStream:** expanding changeStream resumable errors ([49fbafd](https://github.com/mongodb/node-mongodb-native/commit/49fbafd)) +* **ChangeStream:** update default startAtOperationTime ([50a9f65](https://github.com/mongodb/node-mongodb-native/commit/50a9f65)) +* **collection:** add colleciton level document mapping/unmapping ([d03335e](https://github.com/mongodb/node-mongodb-native/commit/d03335e)) +* **collection:** Implement new count API ([a5240ae](https://github.com/mongodb/node-mongodb-native/commit/a5240ae)) +* **Collection:** warn if callback is not function in find and findOne ([cddaba0](https://github.com/mongodb/node-mongodb-native/commit/cddaba0)) +* **core:** bump core dependency to v3.1.0 ([855bfdb](https://github.com/mongodb/node-mongodb-native/commit/855bfdb)) +* **cursor:** new cursor.transformStream method ([397fcd2](https://github.com/mongodb/node-mongodb-native/commit/397fcd2)) +* **GridFS:** add option to disable md5 in file upload ([704a88e](https://github.com/mongodb/node-mongodb-native/commit/704a88e)) +* **listCollections:** add support for nameOnly option ([d2d0367](https://github.com/mongodb/node-mongodb-native/commit/d2d0367)) +* **parallelCollectionScan:** does not allow user to pass a session ([4da9e03](https://github.com/mongodb/node-mongodb-native/commit/4da9e03)) +* **read-preference:** add transaction to inheritance rules ([18ca41d](https://github.com/mongodb/node-mongodb-native/commit/18ca41d)) +* **read-preference:** unify means of read preference resolution ([#1738](https://github.com/mongodb/node-mongodb-native/issues/1738)) ([2995e11](https://github.com/mongodb/node-mongodb-native/commit/2995e11)) +* **urlParser:** use core URL parser ([c1c5d8d](https://github.com/mongodb/node-mongodb-native/commit/c1c5d8d)) +* **withSession:** add top level helper for session lifetime ([9976b86](https://github.com/mongodb/node-mongodb-native/commit/9976b86)) + + +### Reverts + +* **collection:** reverting collection-mapping features ([7298c76](https://github.com/mongodb/node-mongodb-native/commit/7298c76)), closes [#1698](https://github.com/mongodb/node-mongodb-native/issues/1698) [mongodb/js-bson#253](https://github.com/mongodb/js-bson/issues/253) + + + + +## [3.0.6](https://github.com/mongodb/node-mongodb-native/compare/v3.0.5...v3.0.6) (2018-04-09) + + +### Bug Fixes + +* **db:** ensure `dropDatabase` always uses primary read preference ([e62e5c9](https://github.com/mongodb/node-mongodb-native/commit/e62e5c9)) +* **driverBench:** driverBench has default options object now ([c557817](https://github.com/mongodb/node-mongodb-native/commit/c557817)) + + +### Features + +* **command-monitoring:** support enabling command monitoring ([5903680](https://github.com/mongodb/node-mongodb-native/commit/5903680)) +* **core:** update to mongodb-core v3.0.6 ([cfdd0ae](https://github.com/mongodb/node-mongodb-native/commit/cfdd0ae)) +* **driverBench:** Implementing DriverBench ([d10fbad](https://github.com/mongodb/node-mongodb-native/commit/d10fbad)) + + + + +## [3.0.5](https://github.com/mongodb/node-mongodb-native/compare/v3.0.4...v3.0.5) (2018-03-23) + + +### Bug Fixes + +* **AggregationCursor:** adding session tracking to AggregationCursor ([baca5b7](https://github.com/mongodb/node-mongodb-native/commit/baca5b7)) +* **Collection:** fix session leak in parallelCollectonScan ([3331ec9](https://github.com/mongodb/node-mongodb-native/commit/3331ec9)) +* **comments:** adding fixes for PR comments ([ee110ac](https://github.com/mongodb/node-mongodb-native/commit/ee110ac)) +* **url_parser:** support a default database on mongodb+srv uris ([6d39b2a](https://github.com/mongodb/node-mongodb-native/commit/6d39b2a)) + + +### Features + +* **sessions:** adding implicit cursor session support ([a81245b](https://github.com/mongodb/node-mongodb-native/commit/a81245b)) + + + + +## [3.0.4](https://github.com/mongodb/node-mongodb-native/compare/v3.0.2...v3.0.4) (2018-03-05) + + +### Bug Fixes + +* **collection:** fix error when calling remove with no args ([#1657](https://github.com/mongodb/node-mongodb-native/issues/1657)) ([4c9b0f8](https://github.com/mongodb/node-mongodb-native/commit/4c9b0f8)) +* **executeOperation:** don't mutate options passed to commands ([934a43a](https://github.com/mongodb/node-mongodb-native/commit/934a43a)) +* **jsdoc:** mark db.collection callback as optional + typo fix ([#1658](https://github.com/mongodb/node-mongodb-native/issues/1658)) ([c519b9b](https://github.com/mongodb/node-mongodb-native/commit/c519b9b)) +* **sessions:** move active session tracking to topology base ([#1665](https://github.com/mongodb/node-mongodb-native/issues/1665)) ([b1f296f](https://github.com/mongodb/node-mongodb-native/commit/b1f296f)) +* **utils:** fixes executeOperation to clean up sessions ([04e6ef6](https://github.com/mongodb/node-mongodb-native/commit/04e6ef6)) + + +### Features + +* **default-db:** use dbName from uri if none provided ([23b1938](https://github.com/mongodb/node-mongodb-native/commit/23b1938)) +* **mongodb-core:** update to mongodb-core 3.0.4 ([1fdbaa5](https://github.com/mongodb/node-mongodb-native/commit/1fdbaa5)) + + + + +## [3.0.3](https://github.com/mongodb/node-mongodb-native/compare/v3.0.2...v3.0.3) (2018-02-23) + + +### Bug Fixes + +* **collection:** fix error when calling remove with no args ([#1657](https://github.com/mongodb/node-mongodb-native/issues/1657)) ([4c9b0f8](https://github.com/mongodb/node-mongodb-native/commit/4c9b0f8)) +* **executeOperation:** don't mutate options passed to commands ([934a43a](https://github.com/mongodb/node-mongodb-native/commit/934a43a)) +* **jsdoc:** mark db.collection callback as optional + typo fix ([#1658](https://github.com/mongodb/node-mongodb-native/issues/1658)) ([c519b9b](https://github.com/mongodb/node-mongodb-native/commit/c519b9b)) +* **sessions:** move active session tracking to topology base ([#1665](https://github.com/mongodb/node-mongodb-native/issues/1665)) ([b1f296f](https://github.com/mongodb/node-mongodb-native/commit/b1f296f)) + + + + +## [3.0.2](https://github.com/mongodb/node-mongodb-native/compare/v3.0.1...v3.0.2) (2018-01-29) + + +### Bug Fixes + +* **collection:** ensure dynamic require of `db` is wrapped in parentheses ([efa78f0](https://github.com/mongodb/node-mongodb-native/commit/efa78f0)) +* **db:** only callback with MongoError NODE-1293 ([#1652](https://github.com/mongodb/node-mongodb-native/issues/1652)) ([45bc722](https://github.com/mongodb/node-mongodb-native/commit/45bc722)) +* **topology base:** allow more than 10 event listeners ([#1630](https://github.com/mongodb/node-mongodb-native/issues/1630)) ([d9fb750](https://github.com/mongodb/node-mongodb-native/commit/d9fb750)) +* **url parser:** preserve auth creds when composing conn string ([#1640](https://github.com/mongodb/node-mongodb-native/issues/1640)) ([eddca5e](https://github.com/mongodb/node-mongodb-native/commit/eddca5e)) + + +### Features + +* **bulk:** forward 'checkKeys' option for ordered and unordered bulk operations ([421a6b2](https://github.com/mongodb/node-mongodb-native/commit/421a6b2)) +* **collection:** expose `dbName` property of collection ([6fd05c1](https://github.com/mongodb/node-mongodb-native/commit/6fd05c1)) + + + + +## [3.0.1](https://github.com/mongodb/node-mongodb-native/compare/v3.0.0...v3.0.1) (2017-12-24) + +* update mongodb-core to 3.0.1 + + +# [3.0.0](https://github.com/mongodb/node-mongodb-native/compare/v3.0.0-rc0...v3.0.0) (2017-12-24) + + +### Bug Fixes + +* **aggregate:** remove support for inline results for aggregate ([#1620](https://github.com/mongodb/node-mongodb-native/issues/1620)) ([84457ec](https://github.com/mongodb/node-mongodb-native/commit/84457ec)) +* **topologies:** unify topologies connect API ([#1615](https://github.com/mongodb/node-mongodb-native/issues/1615)) ([0fb4658](https://github.com/mongodb/node-mongodb-native/commit/0fb4658)) + + +### Features + +* **keepAlive:** make keepAlive options consistent ([#1612](https://github.com/mongodb/node-mongodb-native/issues/1612)) ([f608f44](https://github.com/mongodb/node-mongodb-native/commit/f608f44)) + + +### BREAKING CHANGES + +* **topologies:** Function signature for `.connect` method on replset and mongos has changed. You shouldn't have been using this anyway, but if you were, you only should pass `options` and `callback`. + +Part of NODE-1089 +* **keepAlive:** option `keepAlive` is now split into boolean `keepAlive` and +number `keepAliveInitialDelay` + +Fixes NODE-998 + + + + +# [3.0.0-rc0](https://github.com/mongodb/node-mongodb-native/compare/v2.2.31...v3.0.0-rc0) (2017-12-05) + + +### Bug Fixes + +* **aggregation:** ensure that the `cursor` key is always present ([f16f314](https://github.com/mongodb/node-mongodb-native/commit/f16f314)) +* **apm:** give users access to raw server responses ([88b206b](https://github.com/mongodb/node-mongodb-native/commit/88b206b)) +* **apm:** only rebuilt cursor if reply is non-null ([96052c8](https://github.com/mongodb/node-mongodb-native/commit/96052c8)) +* **apm:** rebuild lost `cursor` info on pre-OP_QUERY responses ([4242d49](https://github.com/mongodb/node-mongodb-native/commit/4242d49)) +* **bulk-unordered:** add check for ignoreUndefined ([f38641a](https://github.com/mongodb/node-mongodb-native/commit/f38641a)) +* **change stream examples:** use timeouts, cleanup ([c5fec5f](https://github.com/mongodb/node-mongodb-native/commit/c5fec5f)) +* **change-streams:** ensure a majority read concern on initial agg ([23011e9](https://github.com/mongodb/node-mongodb-native/commit/23011e9)) +* **changeStreams:** fixing node4 issue with util.inherits ([#1587](https://github.com/mongodb/node-mongodb-native/issues/1587)) ([168bb3d](https://github.com/mongodb/node-mongodb-native/commit/168bb3d)) +* **collection:** allow { upsert: 1 } for findOneAndUpdate() and update() ([5bcedd6](https://github.com/mongodb/node-mongodb-native/commit/5bcedd6)) +* **collection:** allow passing `noCursorTimeout` as an option to `find()` ([e9c4ffc](https://github.com/mongodb/node-mongodb-native/commit/e9c4ffc)) +* **collection:** make the parameters of findOne very explicit ([3054f1a](https://github.com/mongodb/node-mongodb-native/commit/3054f1a)) +* **cursor:** `hasNext` should propagate errors when using callback ([6339625](https://github.com/mongodb/node-mongodb-native/commit/6339625)) +* **cursor:** close readable on `null` response for dead cursor ([6aca2c5](https://github.com/mongodb/node-mongodb-native/commit/6aca2c5)) +* **dns txt records:** check options are set ([e5caf4f](https://github.com/mongodb/node-mongodb-native/commit/e5caf4f)) +* **docs:** Represent each valid option in docs in both places ([fde6e5d](https://github.com/mongodb/node-mongodb-native/commit/fde6e5d)) +* **grid-store:** add missing callback ([66a9a05](https://github.com/mongodb/node-mongodb-native/commit/66a9a05)) +* **grid-store:** move into callback scope ([b53f65f](https://github.com/mongodb/node-mongodb-native/commit/b53f65f)) +* **GridFS:** fix TypeError: doc.data.length is not a function ([#1570](https://github.com/mongodb/node-mongodb-native/issues/1570)) ([22a4628](https://github.com/mongodb/node-mongodb-native/commit/22a4628)) +* **list-collections:** ensure default of primary ReadPreference ([4a0cfeb](https://github.com/mongodb/node-mongodb-native/commit/4a0cfeb)) +* **mongo client:** close client before calling done ([c828aab](https://github.com/mongodb/node-mongodb-native/commit/c828aab)) +* **mongo client:** do not connect if url parse error ([cd10084](https://github.com/mongodb/node-mongodb-native/commit/cd10084)) +* **mongo client:** send error to cb ([eafc9e2](https://github.com/mongodb/node-mongodb-native/commit/eafc9e2)) +* **mongo-client:** move to inside of callback ([68b0fca](https://github.com/mongodb/node-mongodb-native/commit/68b0fca)) +* **mongo-client:** options should not be passed to `connect` ([474ac65](https://github.com/mongodb/node-mongodb-native/commit/474ac65)) +* **tests:** migrate 2.x tests to 3.x ([3a5232a](https://github.com/mongodb/node-mongodb-native/commit/3a5232a)) +* **updateOne/updateMany:** ensure that update documents contain atomic operators ([8b4255a](https://github.com/mongodb/node-mongodb-native/commit/8b4255a)) +* **url parser:** add check for options as cb ([52b6039](https://github.com/mongodb/node-mongodb-native/commit/52b6039)) +* **url parser:** compare srv address and parent domains ([daa186d](https://github.com/mongodb/node-mongodb-native/commit/daa186d)) +* **url parser:** compare string from first period on ([9e5d77e](https://github.com/mongodb/node-mongodb-native/commit/9e5d77e)) +* **url parser:** default to ssl true for mongodb+srv ([0fbca4b](https://github.com/mongodb/node-mongodb-native/commit/0fbca4b)) +* **url parser:** error when multiple hostnames used ([c1aa681](https://github.com/mongodb/node-mongodb-native/commit/c1aa681)) +* **url parser:** keep original uri options and default to ssl true ([e876a72](https://github.com/mongodb/node-mongodb-native/commit/e876a72)) +* **url parser:** log instead of throw error for unsupported url options ([155de2d](https://github.com/mongodb/node-mongodb-native/commit/155de2d)) +* **url parser:** make sure uri has 3 parts ([aa9871b](https://github.com/mongodb/node-mongodb-native/commit/aa9871b)) +* **url parser:** only 1 txt record allowed with 2 possible options ([d9f4218](https://github.com/mongodb/node-mongodb-native/commit/d9f4218)) +* **url parser:** only check for multiple hostnames with srv protocol ([5542bcc](https://github.com/mongodb/node-mongodb-native/commit/5542bcc)) +* **url parser:** remove .only from test ([642e39e](https://github.com/mongodb/node-mongodb-native/commit/642e39e)) +* **url parser:** return callback ([6096afc](https://github.com/mongodb/node-mongodb-native/commit/6096afc)) +* **url parser:** support single text record with multiple strings ([356fa57](https://github.com/mongodb/node-mongodb-native/commit/356fa57)) +* **url parser:** try catch bug, not actually returning from try loop ([758892b](https://github.com/mongodb/node-mongodb-native/commit/758892b)) +* **url parser:** use warn instead of info ([40ed27d](https://github.com/mongodb/node-mongodb-native/commit/40ed27d)) +* **url-parser:** remove comment, send error to cb ([d44420b](https://github.com/mongodb/node-mongodb-native/commit/d44420b)) + + +### Features + +* **aggregate:** support hit field for aggregate command ([aa7da15](https://github.com/mongodb/node-mongodb-native/commit/aa7da15)) +* **aggregation:** adds support for comment in aggregation command ([#1571](https://github.com/mongodb/node-mongodb-native/issues/1571)) ([4ac475c](https://github.com/mongodb/node-mongodb-native/commit/4ac475c)) +* **aggregation:** fail aggregation on explain + readConcern/writeConcern ([e0ca1b4](https://github.com/mongodb/node-mongodb-native/commit/e0ca1b4)) +* **causal-consistency:** support `afterClusterTime` in readConcern ([a9097f7](https://github.com/mongodb/node-mongodb-native/commit/a9097f7)) +* **change-streams:** add support for change streams ([c02d25c](https://github.com/mongodb/node-mongodb-native/commit/c02d25c)) +* **collection:** updating find API ([f26362d](https://github.com/mongodb/node-mongodb-native/commit/f26362d)) +* **execute-operation:** implementation for common op execution ([67c344f](https://github.com/mongodb/node-mongodb-native/commit/67c344f)) +* **listDatabases:** add support for nameOnly option to listDatabases ([eb79b5a](https://github.com/mongodb/node-mongodb-native/commit/eb79b5a)) +* **maxTimeMS:** adding maxTimeMS option to createIndexes and dropIndexes ([90d4a63](https://github.com/mongodb/node-mongodb-native/commit/90d4a63)) +* **mongo-client:** implement `MongoClient.prototype.startSession` ([bce5adf](https://github.com/mongodb/node-mongodb-native/commit/bce5adf)) +* **retryable-writes:** add support for `retryWrites` cs option ([2321870](https://github.com/mongodb/node-mongodb-native/commit/2321870)) +* **sessions:** MongoClient will now track sessions and release ([6829f47](https://github.com/mongodb/node-mongodb-native/commit/6829f47)) +* **sessions:** support passing sessions via objects in all methods ([a531f05](https://github.com/mongodb/node-mongodb-native/commit/a531f05)) +* **shared:** add helper utilities for assertion and suite setup ([b6cc34e](https://github.com/mongodb/node-mongodb-native/commit/b6cc34e)) +* **ssl:** adds missing ssl options ssl options for `ciphers` and `ecdhCurve` ([441b7b1](https://github.com/mongodb/node-mongodb-native/commit/441b7b1)) +* **test-shared:** add `notEqual` assertion ([41d93fd](https://github.com/mongodb/node-mongodb-native/commit/41d93fd)) +* **test-shared:** add `strictEqual` assertion method ([cad8e19](https://github.com/mongodb/node-mongodb-native/commit/cad8e19)) +* **topologies:** expose underlaying `logicalSessionTimeoutMinutes' ([1609a37](https://github.com/mongodb/node-mongodb-native/commit/1609a37)) +* **url parser:** better error message for slash in hostname ([457bc29](https://github.com/mongodb/node-mongodb-native/commit/457bc29)) + + +### BREAKING CHANGES + +* **aggregation:** If you use aggregation, and try to use the explain flag while you +have a readConcern or writeConcern, your query will fail +* **collection:** `find` and `findOne` no longer support the `fields` parameter. +You can achieve the same results as the `fields` parameter by +either using `Cursor.prototype.project`, or by passing the `projection` +property in on the `options` object. Additionally, `find` does not +support individual options like `skip` and `limit` as positional +parameters. You must pass in these parameters in the `options` object + + + +3.0.0 2017-??-?? +---------------- +* NODE-1043 URI-escaping authentication and hostname details in connection string 2.2.31 2017-08-08 ----------------- -* update mongodb-core to 2.1.15 +* update mongodb-core to 2.2.15 * allow auth option in MongoClient.connect * remove duplicate option `promoteLongs` from MongoClient's `connect` * bulk operations should not throw an error on empty batch 2.2.30 2017-07-07 ----------------- -* Update mongodb-core to 2.1.14 +* Update mongodb-core to 2.2.14 * MongoClient * add `appname` to list of valid option names * added test for passing appname as option diff --git a/node_modules/mongodb/README.md b/node_modules/mongodb/README.md index 3b8fa37..6768183 100644 --- a/node_modules/mongodb/README.md +++ b/node_modules/mongodb/README.md @@ -1,4 +1,4 @@ -[![NPM](https://nodei.co/npm/mongodb.png?downloads=true&downloadRank=true)](https://nodei.co/npm/mongodb/) [![NPM](https://nodei.co/npm-dl/mongodb.png?months=6&height=3)](https://nodei.co/npm/mongodb/) +[![npm](https://nodei.co/npm/mongodb.png?downloads=true&downloadRank=true)](https://nodei.co/npm/mongodb/) [![npm](https://nodei.co/npm-dl/mongodb.png?months=6&height=3)](https://nodei.co/npm/mongodb/) [![Build Status](https://secure.travis-ci.org/mongodb/node-mongodb-native.svg?branch=2.1)](http://travis-ci.org/mongodb/node-mongodb-native) [![Coverage Status](https://coveralls.io/repos/github/mongodb/node-mongodb-native/badge.svg?branch=2.1)](https://coveralls.io/github/mongodb/node-mongodb-native?branch=2.1) @@ -8,25 +8,24 @@ The official [MongoDB](https://www.mongodb.com/) driver for Node.js. Provides a high-level API on top of [mongodb-core](https://www.npmjs.com/package/mongodb-core) that is meant for end users. +**NOTE: v3.x was recently released with breaking API changes. You can find a list of changes [here](CHANGES_3.0.0.md).** + ## MongoDB Node.JS Driver | what | where | |---------------|------------------------------------------------| -| documentation | http://mongodb.github.io/node-mongodb-native/ | -| api-doc | http://mongodb.github.io/node-mongodb-native/2.2/api/ | +| documentation | http://mongodb.github.io/node-mongodb-native | +| api-doc | http://mongodb.github.io/node-mongodb-native/3.1/api | | source | https://github.com/mongodb/node-mongodb-native | -| mongodb | http://www.mongodb.org/ | - -### Blogs of Engineers involved in the driver -- Christian Kvalheim [@christkv](https://twitter.com/christkv) +| mongodb | http://www.mongodb.org | ### Bugs / Feature Requests -Think you’ve found a bug? Want to see a new feature in node-mongodb-native? Please open a +Think you’ve found a bug? Want to see a new feature in `node-mongodb-native`? Please open a case in our issue management tool, JIRA: -- Create an account and login . -- Navigate to the NODE project . +- Create an account and login [jira.mongodb.org](https://jira.mongodb.org). +- Navigate to the NODE project [jira.mongodb.org/browse/NODE](https://jira.mongodb.org/browse/NODE). - Click **Create Issue** - Please provide as much information as possible about the issue type and how to reproduce it. Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the @@ -34,68 +33,68 @@ Core Server (i.e. SERVER) project are **public**. ### Questions and Bug Reports - * mailing list: https://groups.google.com/forum/#!forum/node-mongodb-native - * jira: http://jira.mongodb.org/ + * Mailing List: [groups.google.com/forum/#!forum/node-mongodb-native](https://groups.google.com/forum/#!forum/node-mongodb-native) + * JIRA: [jira.mongodb.org](http://jira.mongodb.org) ### Change Log -http://jira.mongodb.org/browse/NODE +Change history can be found in [`HISTORY.md`](HISTORY.md). # Installation -The recommended way to get started using the Node.js 2.0 driver is by using the `NPM` (Node Package Manager) to install the dependency in your project. +The recommended way to get started using the Node.js 3.0 driver is by using the `npm` (Node Package Manager) to install the dependency in your project. ## MongoDB Driver -Given that you have created your own project using `npm init` we install the mongodb driver and it's dependencies by executing the following `NPM` command. +Given that you have created your own project using `npm init` we install the MongoDB driver and its dependencies by executing the following `npm` command. -``` +```bash npm install mongodb --save ``` This will download the MongoDB driver and add a dependency entry in your `package.json` file. +You can also use the [Yarn](https://yarnpkg.com/en) package manager. + ## Troubleshooting -The MongoDB driver depends on several other packages. These are. +The MongoDB driver depends on several other packages. These are: -* mongodb-core -* bson -* kerberos -* node-gyp +* [mongodb-core](https://github.com/mongodb-js/mongodb-core) +* [bson](https://github.com/mongodb/js-bson) +* [kerberos](https://github.com/mongodb-js/kerberos) +* [node-gyp](https://github.com/nodejs/node-gyp) -The `kerberos` package is a C++ extension that requires a build environment to be installed on your system. You must be able to build node.js itself to be able to compile and install the `kerberos` module. Furthermore the `kerberos` module requires the MIT Kerberos package to correctly compile on UNIX operating systems. Consult your UNIX operation system package manager what libraries to install. +The `kerberos` package is a C++ extension that requires a build environment to be installed on your system. You must be able to build Node.js itself in order to compile and install the `kerberos` module. Furthermore, the `kerberos` module requires the MIT Kerberos package to correctly compile on UNIX operating systems. Consult your UNIX operation system package manager for what libraries to install. -{{% note class="important" %}} -Windows already contains the SSPI API used for Kerberos authentication. However you will need to install a full compiler tool chain using visual studio C++ to correctly install the kerberos extension. -{{% /note %}} +**Windows already contains the SSPI API used for Kerberos authentication. However, you will need to install a full compiler tool chain using Visual Studio C++ to correctly install the Kerberos extension.** ### Diagnosing on UNIX -If you don’t have the build essentials it won’t build. In the case of linux you will need gcc and g++, node.js with all the headers and python. The easiest way to figure out what’s missing is by trying to build the kerberos project. You can do this by performing the following steps. +If you don’t have the build-essentials, this module won’t build. In the case of Linux, you will need gcc, g++, Node.js with all the headers and Python. The easiest way to figure out what’s missing is by trying to build the Kerberos project. You can do this by performing the following steps. -``` -git clone https://github.com/christkv/kerberos.git +```bash +git clone https://github.com/mongodb-js/kerberos cd kerberos npm install ``` -If all the steps complete you have the right toolchain installed. If you get node-gyp not found you need to install it globally by doing. +If all the steps complete, you have the right toolchain installed. If you get the error "node-gyp not found," you need to install `node-gyp` globally: -``` +```bash npm install -g node-gyp ``` -If correctly compiles and runs the tests you are golden. We can now try to install the mongod driver by performing the following command. +If it correctly compiles and runs the tests you are golden. We can now try to install the `mongod` driver by performing the following command. -``` +```bash cd yourproject npm install mongodb --save ``` If it still fails the next step is to examine the npm log. Rerun the command but in this case in verbose mode. -``` +```bash npm --loglevel verbose install mongodb ``` @@ -103,21 +102,21 @@ This will print out all the steps npm is performing while trying to install the ### Diagnosing on Windows -A known compiler tool chain known to work for compiling `kerberos` on windows is the following. +A compiler tool chain known to work for compiling `kerberos` on Windows is the following. -* Visual Studio c++ 2010 (do not use higher versions) +* Visual Studio C++ 2010 (do not use higher versions) * Windows 7 64bit SDK * Python 2.7 or higher -Open visual studio command prompt. Ensure node.exe is in your path and install node-gyp. +Open the Visual Studio command prompt. Ensure `node.exe` is in your path and install `node-gyp`. -``` +```bash npm install -g node-gyp ``` -Next you will have to build the project manually to test it. Use any tool you use with git and grab the repo. +Next, you will have to build the project manually to test it. Clone the repo, install dependencies and rebuild: -``` +```bash git clone https://github.com/christkv/kerberos.git cd kerberos npm install @@ -128,104 +127,96 @@ This should rebuild the driver successfully if you have everything set up correc ### Other possible issues -Your python installation might be hosed making gyp break. I always recommend that you test your deployment environment first by trying to build node itself on the server in question as this should unearth any issues with broken packages (and there are a lot of broken packages out there). +Your Python installation might be hosed making gyp break. Test your deployment environment first by trying to build Node.js itself on the server in question, as this should unearth any issues with broken packages (and there are a lot of broken packages out there). -Another thing is to ensure your user has write permission to wherever the node modules are being installed. +Another tip is to ensure your user has write permission to wherever the Node.js modules are being installed. -QuickStart -========== -The quick start guide will show you how to setup a simple application using node.js and MongoDB. Its scope is only how to set up the driver and perform the simple crud operations. For more in depth coverage we encourage reading the tutorials. +## Quick Start -Create the package.json file ----------------------------- -Let's create a directory where our application will live. In our case we will put this under our projects directory. +This guide will show you how to set up a simple application using Node.js and MongoDB. Its scope is only how to set up the driver and perform the simple CRUD operations. For more in-depth coverage, see the [tutorials](docs/reference/content/tutorials/main.md). -``` +### Create the `package.json` file + +First, create a directory where your application will live. + +```bash mkdir myproject cd myproject ``` -Enter the following command and answer the questions to create the initial structure for your new project +Enter the following command and answer the questions to create the initial structure for your new project: -``` +```bash npm init ``` -Next we need to edit the generated package.json file to add the dependency for the MongoDB driver. The package.json file below is just an example and your will look different depending on how you answered the questions after entering `npm init` +Next, install the driver dependency. -``` -{ - "name": "myproject", - "version": "1.0.0", - "description": "My first project", - "main": "index.js", - "repository": { - "type": "git", - "url": "git://github.com/christkv/myfirstproject.git" - }, - "dependencies": { - "mongodb": "~2.0" - }, - "author": "Christian Kvalheim", - "license": "Apache 2.0", - "bugs": { - "url": "https://github.com/christkv/myfirstproject/issues" - }, - "homepage": "https://github.com/christkv/myfirstproject" -} +```bash +npm install mongodb --save ``` -Save the file and return to the shell or command prompt and use **NPM** to install all the dependencies. +You should see **NPM** download a lot of files. Once it's done you'll find all the downloaded packages under the **node_modules** directory. -``` -npm install -``` +### Start a MongoDB Server -You should see **NPM** download a lot of files. Once it's done you'll find all the downloaded packages under the **node_modules** directory. +For complete MongoDB installation instructions, see [the manual](https://docs.mongodb.org/manual/installation/). -Booting up a MongoDB Server ---------------------------- -Let's boot up a MongoDB server instance. Download the right MongoDB version from [MongoDB](http://www.mongodb.org), open a new shell or command line and ensure the **mongod** command is in the shell or command line path. Now let's create a database directory (in our case under **/data**). +1. Download the right MongoDB version from [MongoDB](https://www.mongodb.org/downloads) +2. Create a database directory (in this case under **/data**). +3. Install and start a ``mongod`` process. -``` -mongod --dbpath=/data --port 27017 +```bash +mongod --dbpath=/data ``` You should see the **mongod** process start up and print some status information. -Connecting to MongoDB ---------------------- -Let's create a new **app.js** file that we will use to show the basic CRUD operations using the MongoDB driver. +### Connect to MongoDB + +Create a new **app.js** file and add the following code to try out some basic CRUD +operations using the MongoDB driver. -First let's add code to connect to the server and the database **myproject**. +Add code to connect to the server and the database **myproject**: ```js -var MongoClient = require('mongodb').MongoClient - , assert = require('assert'); +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); // Connection URL -var url = 'mongodb://localhost:27017/myproject'; -// Use connect method to connect to the Server -MongoClient.connect(url, function(err, db) { +const url = 'mongodb://localhost:27017'; + +// Database Name +const dbName = 'myproject'; + +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { assert.equal(null, err); - console.log("Connected correctly to server"); + console.log("Connected successfully to server"); - db.close(); + const db = client.db(dbName); + + client.close(); }); ``` -Given that you booted up the **mongod** process earlier the application should connect successfully and print **Connected correctly to server** to the console. +Run your app from the command line with: + +```bash +node app.js +``` + +The application should print **Connected successfully to server** to the console. -Let's Add some code to show the different CRUD operations available. +### Insert a Document -Inserting a Document --------------------- -Let's create a function that will insert some documents for us. +Add to **app.js** the following function which uses the **insertMany** +method to add three documents to the **documents** collection. ```js -var insertDocuments = function(db, callback) { +const insertDocuments = function(db, callback) { // Get the documents collection - var collection = db.collection('documents'); + const collection = db.collection('documents'); // Insert some documents collection.insertMany([ {a : 1}, {a : 2}, {a : 3} @@ -233,58 +224,129 @@ var insertDocuments = function(db, callback) { assert.equal(err, null); assert.equal(3, result.result.n); assert.equal(3, result.ops.length); - console.log("Inserted 3 documents into the document collection"); + console.log("Inserted 3 documents into the collection"); callback(result); }); } ``` -The insert command will return a results object that contains several fields that might be useful. +The **insert** command returns an object with the following fields: * **result** Contains the result document from MongoDB * **ops** Contains the documents inserted with added **_id** fields * **connection** Contains the connection used to perform the insert -Let's add call the **insertDocuments** command to the **MongoClient.connect** method callback. +Add the following code to call the **insertDocuments** function: ```js -var MongoClient = require('mongodb').MongoClient - , assert = require('assert'); +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); // Connection URL -var url = 'mongodb://localhost:27017/myproject'; -// Use connect method to connect to the Server -MongoClient.connect(url, function(err, db) { +const url = 'mongodb://localhost:27017'; + +// Database Name +const dbName = 'myproject'; + +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { assert.equal(null, err); - console.log("Connected correctly to server"); + console.log("Connected successfully to server"); + + const db = client.db(dbName); insertDocuments(db, function() { - db.close(); + client.close(); }); }); ``` -We can now run the update **app.js** file. +Run the updated **app.js** file: -``` +```bash node app.js ``` -You should see the following output after running the **app.js** file. +The operation returns the following output: + +```bash +Connected successfully to server +Inserted 3 documents into the collection +``` + +### Find All Documents + +Add a query that returns all the documents. + +```js +const findDocuments = function(db, callback) { + // Get the documents collection + const collection = db.collection('documents'); + // Find some documents + collection.find({}).toArray(function(err, docs) { + assert.equal(err, null); + console.log("Found the following records"); + console.log(docs) + callback(docs); + }); +} +``` + +This query returns all the documents in the **documents** collection. Add the **findDocument** method to the **MongoClient.connect** callback: + +```js +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); + +// Connection URL +const url = 'mongodb://localhost:27017'; + +// Database Name +const dbName = 'myproject'; +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + const db = client.db(dbName); + + insertDocuments(db, function() { + findDocuments(db, function() { + client.close(); + }); + }); +}); ``` -Connected correctly to server -Inserted 3 documents into the document collection + +### Find Documents with a Query Filter + +Add a query filter to find only documents which meet the query criteria. + +```js +const findDocuments = function(db, callback) { + // Get the documents collection + const collection = db.collection('documents'); + // Find some documents + collection.find({'a': 3}).toArray(function(err, docs) { + assert.equal(err, null); + console.log("Found the following records"); + console.log(docs); + callback(docs); + }); +} ``` -Updating a document -------------------- -Let's look at how to do a simple document update by adding a new field **b** to the document that has the field **a** set to **2**. +Only the documents which match ``'a' : 3`` should be returned. + +### Update a document + +The following operation updates a document in the **documents** collection. ```js -var updateDocument = function(db, callback) { +const updateDocument = function(db, callback) { // Get the documents collection - var collection = db.collection('documents'); + const collection = db.collection('documents'); // Update document where a is 2, set b equal to 1 collection.updateOne({ a : 2 } , { $set: { b : 1 } }, function(err, result) { @@ -296,120 +358,129 @@ var updateDocument = function(db, callback) { } ``` -The method will update the first document where the field **a** is equal to **2** by adding a new field **b** to the document set to **1**. Let's update the callback function from **MongoClient.connect** to include the update method. +The method updates the first document where the field **a** is equal to **2** by adding a new field **b** to the document set to **1**. Next, update the callback function from **MongoClient.connect** to include the update method. ```js -var MongoClient = require('mongodb').MongoClient - , assert = require('assert'); +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); // Connection URL -var url = 'mongodb://localhost:27017/myproject'; -// Use connect method to connect to the Server -MongoClient.connect(url, function(err, db) { +const url = 'mongodb://localhost:27017'; + +// Database Name +const dbName = 'myproject'; + +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { assert.equal(null, err); - console.log("Connected correctly to server"); + console.log("Connected successfully to server"); + + const db = client.db(dbName); insertDocuments(db, function() { updateDocument(db, function() { - db.close(); + client.close(); }); }); }); ``` -Delete a document ------------------ -Next lets delete the document where the field **a** equals to **3**. +### Remove a document + +Remove the document where the field **a** is equal to **3**. ```js -var deleteDocument = function(db, callback) { +const removeDocument = function(db, callback) { // Get the documents collection - var collection = db.collection('documents'); + const collection = db.collection('documents'); // Delete document where a is 3 collection.deleteOne({ a : 3 }, function(err, result) { assert.equal(err, null); assert.equal(1, result.result.n); console.log("Removed the document with the field a equal to 3"); callback(result); - }); + }); } ``` -This will delete the first document where the field **a** equals to **3**. Let's add the method to the **MongoClient -.connect** callback function. +Add the new method to the **MongoClient.connect** callback function. ```js -var MongoClient = require('mongodb').MongoClient - , assert = require('assert'); +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); // Connection URL -var url = 'mongodb://localhost:27017/myproject'; -// Use connect method to connect to the Server -MongoClient.connect(url, function(err, db) { +const url = 'mongodb://localhost:27017'; + +// Database Name +const dbName = 'myproject'; + +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { assert.equal(null, err); - console.log("Connected correctly to server"); + console.log("Connected successfully to server"); + + const db = client.db(dbName); insertDocuments(db, function() { updateDocument(db, function() { - deleteDocument(db, function() { - db.close(); + removeDocument(db, function() { + client.close(); }); }); }); }); ``` -Finally let's retrieve all the documents using a simple find. +### Index a Collection -Find All Documents ------------------- -We will finish up the Quickstart CRUD methods by performing a simple query that returns all the documents matching the query. +[Indexes](https://docs.mongodb.org/manual/indexes/) can improve your application's +performance. The following function creates an index on the **a** field in the +**documents** collection. ```js -var findDocuments = function(db, callback) { - // Get the documents collection - var collection = db.collection('documents'); - // Find some documents - collection.find({}).toArray(function(err, docs) { - assert.equal(err, null); - assert.equal(2, docs.length); - console.log("Found the following records"); - console.dir(docs); - callback(docs); - }); -} +const indexCollection = function(db, callback) { + db.collection('documents').createIndex( + { "a": 1 }, + null, + function(err, results) { + console.log(results); + callback(); + } + ); +}; ``` -This query will return all the documents in the **documents** collection. Since we deleted a document the total -documents returned is **2**. Finally let's add the findDocument method to the **MongoClient.connect** callback. +Add the ``indexCollection`` method to your app: ```js -var MongoClient = require('mongodb').MongoClient - , assert = require('assert'); +const MongoClient = require('mongodb').MongoClient; +const assert = require('assert'); // Connection URL -var url = 'mongodb://localhost:27017/myproject'; -// Use connect method to connect to the Server -MongoClient.connect(url, function(err, db) { +const url = 'mongodb://localhost:27017'; + +const dbName = 'myproject'; + +// Use connect method to connect to the server +MongoClient.connect(url, function(err, client) { assert.equal(null, err); - console.log("Connected correctly to server"); + console.log("Connected successfully to server"); + + const db = client.db(dbName); insertDocuments(db, function() { - updateDocument(db, function() { - deleteDocument(db, function() { - findDocuments(db, function() { - db.close(); - }); - }); + indexCollection(db, function() { + client.close(); }); }); }); ``` -This concludes the QuickStart of connecting and performing some Basic operations using the MongoDB Node.js driver. For more detailed information you can look at the tutorials covering more specific topics of interest. +For more detailed information, see the [tutorials](docs/reference/content/tutorials/main.md). ## Next Steps - * [MongoDB Documentation](http://mongodb.org/) - * [Read about Schemas](http://learnmongodbthehardway.com/) + * [MongoDB Documentation](http://mongodb.org) + * [Read about Schemas](http://learnmongodbthehardway.com) * [Star us on GitHub](https://github.com/mongodb/node-mongodb-native) diff --git a/node_modules/mongodb/conf.json b/node_modules/mongodb/conf.json index 99eb3a7..4aff802 100644 --- a/node_modules/mongodb/conf.json +++ b/node_modules/mongodb/conf.json @@ -2,31 +2,28 @@ "plugins": ["plugins/markdown", "docs/lib/jsdoc/examples_plugin.js"], "source": { "include": [ - "test/functional/operation_example_tests.js", - "test/functional/operation_promises_example_tests.js", - "test/functional/operation_generators_example_tests.js", - "test/functional/authentication_tests.js", - "test/functional/gridfs_stream_tests.js", "lib/admin.js", - "lib/collection.js", - "lib/cursor.js", "lib/aggregation_cursor.js", + "lib/change_stream.js", + "lib/collection.js", "lib/command_cursor.js", + "lib/cursor.js", "lib/db.js", "lib/mongo_client.js", - "lib/mongos.js", - "lib/read_preference.js", - "lib/replset.js", - "lib/server.js", "lib/bulk/common.js", "lib/bulk/ordered.js", "lib/bulk/unordered.js", "lib/gridfs/grid_store.js", - "node_modules/mongodb-core/lib/error.js", - "lib/gridfs-stream/index.js", "lib/gridfs-stream/download.js", + "lib/gridfs-stream/index.js", "lib/gridfs-stream/upload.js", + "lib/topologies/replset.js", + "lib/topologies/mongos.js", + "lib/topologies/server.js", + "node_modules/mongodb-core/lib/error.js", "node_modules/mongodb-core/lib/connection/logger.js", + "node_modules/mongodb-core/lib/sessions.js", + "node_modules/mongodb-core/lib/transactions.js", "node_modules/bson/lib/bson/binary.js", "node_modules/bson/lib/bson/code.js", "node_modules/bson/lib/bson/db_ref.js", @@ -39,7 +36,12 @@ "node_modules/bson/lib/bson/min_key.js", "node_modules/bson/lib/bson/decimal128.js", "node_modules/bson/lib/bson/int_32.js", - "node_modules/bson/lib/bson/regexp.js" + "node_modules/bson/lib/bson/regexp.js", + "test/functional/authentication_tests.js", + "test/functional/gridfs_stream_tests.js", + "test/functional/operation_example_tests.js", + "test/functional/operation_generators_example_tests.js", + "test/functional/operation_promises_example_tests.js" ] }, "templates": { @@ -49,10 +51,9 @@ "outputSourceFiles" : true }, "applicationName": "Node.js MongoDB Driver API", - "disqus": true, "googleAnalytics": "UA-29229787-1", "openGraph": { - "title": "", + "title": "MongoDB Driver API for Node.js", "type": "website", "image": "", "site_name": "", diff --git a/node_modules/mongodb/index.js b/node_modules/mongodb/index.js index 4e328fa..fe305d6 100644 --- a/node_modules/mongodb/index.js +++ b/node_modules/mongodb/index.js @@ -1,25 +1,30 @@ +'use strict'; + // Core module -var core = require('mongodb-core'), - Instrumentation = require('./lib/apm'); +const core = require('mongodb-core'); +const Instrumentation = require('./lib/apm'); // Set up the connect function -var connect = require('./lib/mongo_client').connect; +const connect = require('./lib/mongo_client').connect; // Expose error class connect.MongoError = core.MongoError; +connect.MongoNetworkError = core.MongoNetworkError; // Actual driver classes exported connect.Admin = require('./lib/admin'); connect.MongoClient = require('./lib/mongo_client'); connect.Db = require('./lib/db'); connect.Collection = require('./lib/collection'); -connect.Server = require('./lib/server'); -connect.ReplSet = require('./lib/replset'); -connect.Mongos = require('./lib/mongos'); -connect.ReadPreference = require('./lib/read_preference'); +connect.Server = require('./lib/topologies/server'); +connect.ReplSet = require('./lib/topologies/replset'); +connect.Mongos = require('./lib/topologies/mongos'); +connect.ReadPreference = require('mongodb-core').ReadPreference; connect.GridStore = require('./lib/gridfs/grid_store'); connect.Chunk = require('./lib/gridfs/chunk'); connect.Logger = core.Logger; +connect.AggregationCursor = require('./lib/aggregation_cursor'); +connect.CommandCursor = require('./lib/command_cursor'); connect.Cursor = require('./lib/cursor'); connect.GridFSBucket = require('./lib/gridfs-stream'); // Exported to be used in tests not to be used anywhere else @@ -48,9 +53,15 @@ connect.connect = connect; // Set up the instrumentation method connect.instrument = function(options, callback) { - if(typeof options == 'function') callback = options, options = {}; - return new Instrumentation(core, options, callback); -} + if (typeof options === 'function') { + callback = options; + options = {}; + } + + const instrumentation = new Instrumentation(); + instrumentation.instrument(connect.MongoClient, callback); + return instrumentation; +}; // Set our exports to be the connect function module.exports = connect; diff --git a/node_modules/mongodb/lib/admin.js b/node_modules/mongodb/lib/admin.js index 4675da4..8fb4cac 100644 --- a/node_modules/mongodb/lib/admin.js +++ b/node_modules/mongodb/lib/admin.js @@ -1,10 +1,14 @@ -"use strict"; +'use strict'; -var toError = require('./utils').toError, - Define = require('./metadata'), - shallowClone = require('./utils').shallowClone, - assign = require('./utils').assign, - authenticate = require('./authenticate'); +const executeOperation = require('./utils').executeOperation; +const applyWriteConcern = require('./utils').applyWriteConcern; + +const addUser = require('./operations/db_ops').addUser; +const executeDbAdminCommand = require('./operations/db_ops').executeDbAdminCommand; +const removeUser = require('./operations/db_ops').removeUser; +const replSetGetStatus = require('./operations/admin_ops').replSetGetStatus; +const serverStatus = require('./operations/admin_ops').serverStatus; +const validateCollection = require('./operations/admin_ops').validateCollection; /** * @fileOverview The **Admin** class is an internal class that allows convenient access to @@ -12,20 +16,23 @@ var toError = require('./utils').toError, * * **ADMIN Cannot directly be instantiated** * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; + * * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { + * MongoClient.connect(url, function(err, client) { * // Use the admin database for the operation - * var adminDb = db.admin(); + * const adminDb = client.db(dbName).admin(); * * // List all the available databases * adminDb.listDatabases(function(err, dbs) { * test.equal(null, err); * test.ok(dbs.databases.length > 0); - * db.close(); + * client.close(); * }); * }); */ @@ -35,19 +42,17 @@ var toError = require('./utils').toError, * @class * @return {Admin} a collection instance. */ -var Admin = function(db, topology, promiseLibrary) { - if(!(this instanceof Admin)) return new Admin(db, topology); +function Admin(db, topology, promiseLibrary) { + if (!(this instanceof Admin)) return new Admin(db, topology); // Internal state this.s = { - db: db - , topology: topology - , promiseLibrary: promiseLibrary - } + db: db, + topology: topology, + promiseLibrary: promiseLibrary + }; } -var define = Admin.define = new Define('Admin', Admin, false); - /** * The callback format for results * @callback Admin~resultCallback @@ -59,521 +64,230 @@ var define = Admin.define = new Define('Admin', Admin, false); * Execute a command * @method * @param {object} command The command hash - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query. * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Admin.prototype.command = function(command, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; options = args.length ? args.shift() : {}; - // Execute using callback - if(typeof callback == 'function') return this.s.db.executeDbAdminCommand(command, options, function(err, doc) { - return callback != null ? callback(err, doc) : null; - }); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.executeDbAdminCommand(command, options, function(err, doc) { - if(err) return reject(err); - resolve(doc); - }); - }); -} - -define.classMethod('command', {callback: true, promise:true}); + return executeOperation(this.s.db.s.topology, executeDbAdminCommand.bind(this.s.db), [ + this.s.db, + command, + options, + callback + ]); +}; /** * Retrieve the server information for the current * instance of the db client * + * @param {Object} [options] optional parameters for this operation + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Admin.prototype.buildInfo = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return this.serverInfo(callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.serverInfo(function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} +Admin.prototype.buildInfo = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('buildInfo', {callback: true, promise:true}); + const cmd = { buildinfo: 1 }; + return executeOperation(this.s.db.s.topology, executeDbAdminCommand.bind(this.s.db), [ + this.s.db, + cmd, + options, + callback + ]); +}; /** * Retrieve the server information for the current * instance of the db client * + * @param {Object} [options] optional parameters for this operation + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Admin.prototype.serverInfo = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return this.s.db.executeDbAdminCommand({buildinfo:1}, function(err, doc) { - if(err != null) return callback(err, null); - callback(null, doc); - }); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.executeDbAdminCommand({buildinfo:1}, function(err, doc) { - if(err) return reject(err); - resolve(doc); - }); - }); -} - -define.classMethod('serverInfo', {callback: true, promise:true}); - -/** - * Retrieve this db's server status. - * - * @param {Admin~resultCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed - */ -Admin.prototype.serverStatus = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return serverStatus(self, callback) +Admin.prototype.serverInfo = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - serverStatus(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + const cmd = { buildinfo: 1 }; + return executeOperation(this.s.db.s.topology, executeDbAdminCommand.bind(this.s.db), [ + this.s.db, + cmd, + options, + callback + ]); }; -var serverStatus = function(self, callback) { - self.s.db.executeDbAdminCommand({serverStatus: 1}, function(err, doc) { - if(err == null && doc.ok === 1) { - callback(null, doc); - } else { - if(err) return callback(err, false); - return callback(toError(doc), false); - } - }); -} - -define.classMethod('serverStatus', {callback: true, promise:true}); - /** - * Retrieve the current profiling Level for MongoDB + * Retrieve this db's server status. * + * @param {Object} [options] optional parameters for this operation + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Admin.prototype.profilingLevel = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return profilingLevel(self, callback) +Admin.prototype.serverStatus = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - profilingLevel(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.db.s.topology, serverStatus, [this, options, callback]); }; -var profilingLevel = function(self, callback) { - self.s.db.executeDbAdminCommand({profile:-1}, function(err, doc) { - if(err == null && doc.ok === 1) { - var was = doc.was; - if(was == 0) return callback(null, "off"); - if(was == 1) return callback(null, "slow_only"); - if(was == 2) return callback(null, "all"); - return callback(new Error("Error: illegal profiling level value " + was), null); - } else { - err != null ? callback(err, null) : callback(new Error("Error with profile command"), null); - } - }); -} - -define.classMethod('profilingLevel', {callback: true, promise:true}); - /** * Ping the MongoDB server and retrieve results * + * @param {Object} [options] optional parameters for this operation + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Admin.prototype.ping = function(options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - - // Execute using callback - if(typeof callback == 'function') return this.s.db.executeDbAdminCommand({ping: 1}, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.executeDbAdminCommand({ping: 1}, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('ping', {callback: true, promise:true}); - -/** - * Authenticate a user against the server. - * @method - * @param {string} username The username. - * @param {string} [password] The password. - * @param {Admin~resultCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed - * @deprecated This method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials. - */ -Admin.prototype.authenticate = function(username, password, options, callback) { - console.warn("Admin.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials."); - var finalArguments = [this.s.db]; - if(typeof username == 'string') finalArguments.push(username); - if(typeof password == 'string') finalArguments.push(password); - if(typeof options == 'function') { - finalArguments.push({ authdb: 'admin' }); - finalArguments.push(options); - } else { - finalArguments.push(assign({}, options, { authdb: 'admin' })); - } - - if(typeof callback == 'function') finalArguments.push(callback); - // Execute authenticate method - return authenticate.apply(this.s.db, finalArguments); -} - -define.classMethod('authenticate', {callback: true, promise:true}); - -/** - * Logout user from server, fire off on all connections and remove all auth info - * @method - * @param {Admin~resultCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed - */ -Admin.prototype.logout = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return this.s.db.logout({dbName: 'admin'}, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.logout({dbName: 'admin'}, function(err) { - if(err) return reject(err); - resolve(true); - }); - }); -} - -define.classMethod('logout', {callback: true, promise:true}); - -// Get write concern -var writeConcern = function(options, db) { - options = shallowClone(options); - - // If options already contain write concerns return it - if(options.w || options.wtimeout || options.j || options.fsync) { - return options; - } - - // Set db write concern if available - if(db.writeConcern) { - if(options.w) options.w = db.writeConcern.w; - if(options.wtimeout) options.wtimeout = db.writeConcern.wtimeout; - if(options.j) options.j = db.writeConcern.j; - if(options.fsync) options.fsync = db.writeConcern.fsync; - } + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Return modified options - return options; -} + const cmd = { ping: 1 }; + return executeOperation(this.s.db.s.topology, executeDbAdminCommand.bind(this.s.db), [ + this.s.db, + cmd, + options, + callback + ]); +}; /** * Add a user to the database. * @method * @param {string} username The username. * @param {string} password The password. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.fsync=false] Specify a file sync write concern. - * @param {object} [options.customData=null] Custom data associated with the user (only Mongodb 2.6 or higher) - * @param {object[]} [options.roles=null] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {object} [options.customData] Custom data associated with the user (only Mongodb 2.6 or higher) + * @param {object[]} [options.roles] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Admin.prototype.addUser = function(username, password, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + const args = Array.prototype.slice.call(arguments, 2); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + options = args.length ? args.shift() : {}; - options = options || {}; + options = Object.assign({}, options); // Get the options - options = writeConcern(options, self.s.db) + options = applyWriteConcern(options, { db: this.s.db }); // Set the db name to admin options.dbName = 'admin'; - // Execute using callback - if(typeof callback == 'function') - return self.s.db.addUser(username, password, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.addUser(username, password, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('addUser', {callback: true, promise:true}); + return executeOperation(this.s.db.s.topology, addUser, [ + this.s.db, + username, + password, + options, + callback + ]); +}; /** * Remove a user from a database * @method * @param {string} username The username. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Admin.prototype.removeUser = function(username, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + options = args.length ? args.shift() : {}; - options = options || {}; + options = Object.assign({}, options); // Get the options - options = writeConcern(options, self.s.db) + options = applyWriteConcern(options, { db: this.s.db }); // Set the db name options.dbName = 'admin'; - // Execute using callback - if(typeof callback == 'function') - return self.s.db.removeUser(username, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.removeUser(username, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('removeUser', {callback: true, promise:true}); - -/** - * Set the current profiling level of MongoDB - * - * @param {string} level The new profiling level (off, slow_only, all). - * @param {Admin~resultCallback} [callback] The command result callback. - * @return {Promise} returns Promise if no callback passed - */ -Admin.prototype.setProfilingLevel = function(level, callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return setProfilingLevel(self, level, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - setProfilingLevel(self, level, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -var setProfilingLevel = function(self, level, callback) { - var command = {}; - var profile = 0; - - if(level == "off") { - profile = 0; - } else if(level == "slow_only") { - profile = 1; - } else if(level == "all") { - profile = 2; - } else { - return callback(new Error("Error: illegal profiling level value " + level)); - } - - // Set up the profile number - command['profile'] = profile; - - self.s.db.executeDbAdminCommand(command, function(err, doc) { - if(err == null && doc.ok === 1) - return callback(null, level); - return err != null ? callback(err, null) : callback(new Error("Error with profile command"), null); - }); -} - -define.classMethod('setProfilingLevel', {callback: true, promise:true}); - -/** - * Retrieve the current profiling information for MongoDB - * - * @param {Admin~resultCallback} [callback] The command result callback. - * @return {Promise} returns Promise if no callback passed - * @deprecated Query the system.profile collection directly. - */ -Admin.prototype.profilingInfo = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return profilingInfo(self, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - profilingInfo(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.db.s.topology, removeUser, [ + this.s.db, + username, + options, + callback + ]); }; -var profilingInfo = function(self, callback) { - try { - self.s.topology.cursor("admin.system.profile", { find: 'system.profile', query: {}}, {}).toArray(callback); - } catch (err) { - return callback(err, null); - } -} - -define.classMethod('profilingLevel', {callback: true, promise:true}); - /** * Validate an existing collection * * @param {string} collectionName The name of the collection to validate. - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback. * @return {Promise} returns Promise if no callback passed */ Admin.prototype.validateCollection = function(collectionName, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - options = args.length ? args.shift() : {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Execute using callback - if(typeof callback == 'function') - return validateCollection(self, collectionName, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - validateCollection(self, collectionName, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.db.s.topology, validateCollection, [ + this, + collectionName, + options, + callback + ]); }; -var validateCollection = function(self, collectionName, options, callback) { - var command = {validate: collectionName}; - var keys = Object.keys(options); - - // Decorate command with extra options - for(var i = 0; i < keys.length; i++) { - if(options.hasOwnProperty(keys[i])) { - command[keys[i]] = options[keys[i]]; - } - } - - self.s.db.command(command, function(err, doc) { - if(err != null) return callback(err, null); - - if(doc.ok === 0) - return callback(new Error("Error with validate command"), null); - if(doc.result != null && doc.result.constructor != String) - return callback(new Error("Error with validation data"), null); - if(doc.result != null && doc.result.match(/exception|corrupt/) != null) - return callback(new Error("Error: invalid collection " + collectionName), null); - if(doc.valid != null && !doc.valid) - return callback(new Error("Error: invalid collection " + collectionName), null); - - return callback(null, doc); - }); -} - -define.classMethod('validateCollection', {callback: true, promise:true}); - /** * List the available databases * + * @param {object} [options] Optional settings. + * @param {boolean} [options.nameOnly=false] Whether the command should return only db names, or names and size info. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback. * @return {Promise} returns Promise if no callback passed */ -Admin.prototype.listDatabases = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return self.s.db.executeDbAdminCommand({listDatabases:1}, {}, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.executeDbAdminCommand({listDatabases:1}, {}, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} +Admin.prototype.listDatabases = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('listDatabases', {callback: true, promise:true}); + const cmd = { listDatabases: 1 }; + if (options.nameOnly) cmd.nameOnly = Number(cmd.nameOnly); + return executeOperation(this.s.db.s.topology, executeDbAdminCommand.bind(this.s.db), [ + this.s.db, + cmd, + options, + callback + ]); +}; /** * Get ReplicaSet status * + * @param {Object} [options] optional parameters for this operation + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Admin~resultCallback} [callback] The command result callback. * @return {Promise} returns Promise if no callback passed */ -Admin.prototype.replSetGetStatus = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return replSetGetStatus(self, callback); - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - replSetGetStatus(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -var replSetGetStatus = function(self, callback) { - self.s.db.executeDbAdminCommand({replSetGetStatus:1}, function(err, doc) { - if(err == null && doc.ok === 1) - return callback(null, doc); - if(err) return callback(err, false); - callback(toError(doc), false); - }); -} +Admin.prototype.replSetGetStatus = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('replSetGetStatus', {callback: true, promise:true}); + return executeOperation(this.s.db.s.topology, replSetGetStatus, [this, options, callback]); +}; module.exports = Admin; diff --git a/node_modules/mongodb/lib/aggregation_cursor.js b/node_modules/mongodb/lib/aggregation_cursor.js index a0d7f24..e1bff13 100644 --- a/node_modules/mongodb/lib/aggregation_cursor.js +++ b/node_modules/mongodb/lib/aggregation_cursor.js @@ -1,27 +1,28 @@ -"use strict"; +'use strict'; -var inherits = require('util').inherits - , MongoError = require('mongodb-core').MongoError - , Readable = require('stream').Readable || require('readable-stream').Readable - , Define = require('./metadata') - , CoreCursor = require('./cursor'); +const inherits = require('util').inherits; +const MongoError = require('mongodb-core').MongoError; +const Readable = require('stream').Readable; +const CoreCursor = require('./cursor'); /** * @fileOverview The **AggregationCursor** class is an internal class that embodies an aggregation cursor on MongoDB * allowing for iteration over the results returned from the underlying query. It supports - * one by one document iteration, conversion to an array or can be iterated as a Node 0.10.X + * one by one document iteration, conversion to an array or can be iterated as a Node 4.X * or higher stream * * **AGGREGATIONCURSOR Cannot directly be instantiated** * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { + * MongoClient.connect(url, function(err, client) { * // Create a collection we want to drop later - * var col = db.collection('createIndexExample1'); + * const col = client.db(dbName).collection('createIndexExample1'); * // Insert a bunch of documents * col.insert([{a:1, b:1} * , {a:2, b:2}, {a:3, b:3} @@ -31,7 +32,7 @@ var inherits = require('util').inherits * col.aggregation({}, {cursor: {}}).toArray(function(err, items) { * test.equal(null, err); * test.equal(4, items.length); - * db.close(); + * client.close(); * }); * }); * }); @@ -61,41 +62,37 @@ var AggregationCursor = function(bson, ns, cmd, options, topology, topologyOptio var maxTimeMS = null; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + var promiseLibrary = options.promiseLibrary || Promise; // Set up - Readable.call(this, {objectMode: true}); + Readable.call(this, { objectMode: true }); // Internal state this.s = { // MaxTimeMS - maxTimeMS: maxTimeMS + maxTimeMS: maxTimeMS, // State - , state: state + state: state, // Stream options - , streamOptions: streamOptions + streamOptions: streamOptions, // BSON - , bson: bson + bson: bson, // Namespace - , ns: ns + ns: ns, // Command - , cmd: cmd + cmd: cmd, // Options - , options: options + options: options, // Topology - , topology: topology + topology: topology, // Topology Options - , topologyOptions: topologyOptions + topologyOptions: topologyOptions, // Promise library - , promiseLibrary: promiseLibrary - } -} + promiseLibrary: promiseLibrary, + // Optional ClientSession + session: options.session + }; +}; /** * AggregationCursor stream data event, fired for each document in the cursor. @@ -129,12 +126,10 @@ var AggregationCursor = function(bson, ns, cmd, options, topology, topologyOptio inherits(AggregationCursor, Readable); // Extend the Cursor -for(var name in CoreCursor.prototype) { +for (var name in CoreCursor.prototype) { AggregationCursor.prototype[name] = CoreCursor.prototype[name]; } -var define = AggregationCursor.define = new Define('AggregationCursor', AggregationCursor, true); - /** * Set the batch size for the cursor. * @method @@ -143,14 +138,14 @@ var define = AggregationCursor.define = new Define('AggregationCursor', Aggregat * @return {AggregationCursor} */ AggregationCursor.prototype.batchSize = function(value) { - if(this.s.state == AggregationCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true }); - if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true }); - if(this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; + if (this.s.state === AggregationCursor.CLOSED || this.isDead()) + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + if (typeof value !== 'number') + throw MongoError.create({ message: 'batchSize requires an integer', drvier: true }); + if (this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; this.setCursorBatchSize(value); return this; -} - -define.classMethod('batchSize', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a geoNear stage to the aggregation pipeline @@ -159,11 +154,9 @@ define.classMethod('batchSize', {callback: false, promise:false, returns: [Aggre * @return {AggregationCursor} */ AggregationCursor.prototype.geoNear = function(document) { - this.s.cmd.pipeline.push({$geoNear: document}); + this.s.cmd.pipeline.push({ $geoNear: document }); return this; -} - -define.classMethod('geoNear', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a group stage to the aggregation pipeline @@ -172,11 +165,9 @@ define.classMethod('geoNear', {callback: false, promise:false, returns: [Aggrega * @return {AggregationCursor} */ AggregationCursor.prototype.group = function(document) { - this.s.cmd.pipeline.push({$group: document}); + this.s.cmd.pipeline.push({ $group: document }); return this; -} - -define.classMethod('group', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a limit stage to the aggregation pipeline @@ -185,11 +176,9 @@ define.classMethod('group', {callback: false, promise:false, returns: [Aggregati * @return {AggregationCursor} */ AggregationCursor.prototype.limit = function(value) { - this.s.cmd.pipeline.push({$limit: value}); + this.s.cmd.pipeline.push({ $limit: value }); return this; -} - -define.classMethod('limit', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a match stage to the aggregation pipeline @@ -198,11 +187,9 @@ define.classMethod('limit', {callback: false, promise:false, returns: [Aggregati * @return {AggregationCursor} */ AggregationCursor.prototype.match = function(document) { - this.s.cmd.pipeline.push({$match: document}); + this.s.cmd.pipeline.push({ $match: document }); return this; -} - -define.classMethod('match', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a maxTimeMS stage to the aggregation pipeline @@ -211,13 +198,11 @@ define.classMethod('match', {callback: false, promise:false, returns: [Aggregati * @return {AggregationCursor} */ AggregationCursor.prototype.maxTimeMS = function(value) { - if(this.s.topology.lastIsMaster().minWireVersion > 2) { + if (this.s.topology.lastIsMaster().minWireVersion > 2) { this.s.cmd.maxTimeMS = value; } return this; -} - -define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a out stage to the aggregation pipeline @@ -226,11 +211,9 @@ define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [Aggre * @return {AggregationCursor} */ AggregationCursor.prototype.out = function(destination) { - this.s.cmd.pipeline.push({$out: destination}); + this.s.cmd.pipeline.push({ $out: destination }); return this; -} - -define.classMethod('out', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a project stage to the aggregation pipeline @@ -239,11 +222,9 @@ define.classMethod('out', {callback: false, promise:false, returns: [Aggregation * @return {AggregationCursor} */ AggregationCursor.prototype.project = function(document) { - this.s.cmd.pipeline.push({$project: document}); + this.s.cmd.pipeline.push({ $project: document }); return this; -} - -define.classMethod('project', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a lookup stage to the aggregation pipeline @@ -252,11 +233,9 @@ define.classMethod('project', {callback: false, promise:false, returns: [Aggrega * @return {AggregationCursor} */ AggregationCursor.prototype.lookup = function(document) { - this.s.cmd.pipeline.push({$lookup: document}); + this.s.cmd.pipeline.push({ $lookup: document }); return this; -} - -define.classMethod('lookup', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a redact stage to the aggregation pipeline @@ -265,11 +244,9 @@ define.classMethod('lookup', {callback: false, promise:false, returns: [Aggregat * @return {AggregationCursor} */ AggregationCursor.prototype.redact = function(document) { - this.s.cmd.pipeline.push({$redact: document}); + this.s.cmd.pipeline.push({ $redact: document }); return this; -} - -define.classMethod('redact', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a skip stage to the aggregation pipeline @@ -278,11 +255,9 @@ define.classMethod('redact', {callback: false, promise:false, returns: [Aggregat * @return {AggregationCursor} */ AggregationCursor.prototype.skip = function(value) { - this.s.cmd.pipeline.push({$skip: value}); + this.s.cmd.pipeline.push({ $skip: value }); return this; -} - -define.classMethod('skip', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a sort stage to the aggregation pipeline @@ -291,11 +266,9 @@ define.classMethod('skip', {callback: false, promise:false, returns: [Aggregatio * @return {AggregationCursor} */ AggregationCursor.prototype.sort = function(document) { - this.s.cmd.pipeline.push({$sort: document}); + this.s.cmd.pipeline.push({ $sort: document }); return this; -} - -define.classMethod('sort', {callback: false, promise:false, returns: [AggregationCursor]}); +}; /** * Add a unwind stage to the aggregation pipeline @@ -304,26 +277,22 @@ define.classMethod('sort', {callback: false, promise:false, returns: [Aggregatio * @return {AggregationCursor} */ AggregationCursor.prototype.unwind = function(field) { - this.s.cmd.pipeline.push({$unwind: field}); + this.s.cmd.pipeline.push({ $unwind: field }); return this; -} +}; -define.classMethod('unwind', {callback: false, promise:false, returns: [AggregationCursor]}); +/** + * Return the cursor logger + * @method + * @return {Logger} return the cursor logger + * @ignore + */ +AggregationCursor.prototype.getLogger = function() { + return this.logger; +}; AggregationCursor.prototype.get = AggregationCursor.prototype.toArray; -// Inherited methods -define.classMethod('toArray', {callback: true, promise:true}); -define.classMethod('each', {callback: true, promise:false}); -define.classMethod('forEach', {callback: true, promise:false}); -define.classMethod('hasNext', {callback: true, promise:true}); -define.classMethod('next', {callback: true, promise:true}); -define.classMethod('close', {callback: true, promise:true}); -define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); -define.classMethod('rewind', {callback: false, promise:false}); -define.classMethod('bufferedCount', {callback: false, promise:false, returns: [Number]}); -define.classMethod('readBufferedDocuments', {callback: false, promise:false, returns: [Array]}); - /** * Get the next available document from the cursor, returns null if no more documents are available. * @function AggregationCursor.prototype.next @@ -350,7 +319,7 @@ define.classMethod('readBufferedDocuments', {callback: false, promise:false, ret /** * Returns an array of documents. The caller is responsible for making sure that there * is enough memory to store the results. Note that the array only contain partial - * results when this cursor had been previously accessed. In that case, + * results when this cursor had been previouly accessed. In that case, * cursor.rewind() can be used to reset the cursor. * @method AggregationCursor.prototype.toArray * @param {AggregationCursor~toArrayResultCallback} [callback] The result callback. @@ -367,7 +336,7 @@ define.classMethod('readBufferedDocuments', {callback: false, promise:false, ret /** * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, - * not all of the elements will be iterated if this cursor had been previously accessed. + * not all of the elements will be iterated if this cursor had been previouly accessed. * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements * at any given time if batch size is specified. Otherwise, the caller is responsible diff --git a/node_modules/mongodb/lib/apm.js b/node_modules/mongodb/lib/apm.js index 4948205..f78e4aa 100644 --- a/node_modules/mongodb/lib/apm.js +++ b/node_modules/mongodb/lib/apm.js @@ -1,596 +1,31 @@ -var EventEmitter = require('events').EventEmitter, - inherits = require('util').inherits; +'use strict'; +const EventEmitter = require('events').EventEmitter; -// Get prototypes -var AggregationCursor = require('./aggregation_cursor'), - CommandCursor = require('./command_cursor'), - OrderedBulkOperation = require('./bulk/ordered').OrderedBulkOperation, - UnorderedBulkOperation = require('./bulk/unordered').UnorderedBulkOperation, - GridStore = require('./gridfs/grid_store'), - Cursor = require('./cursor'), - Collection = require('./collection'), - Db = require('./db'); - -var basicOperationIdGenerator = { - operationId: 1, - - next: function() { - return this.operationId++; - } -} - -var basicTimestampGenerator = { - current: function() { - return new Date().getTime(); - }, - - duration: function(start, end) { - return end - start; +class Instrumentation extends EventEmitter { + constructor() { + super(); } -} - -var senstiveCommands = ['authenticate', 'saslStart', 'saslContinue', 'getnonce', - 'createUser', 'updateUser', 'copydbgetnonce', 'copydbsaslstart', 'copydb']; - -var Instrumentation = function(core, options, callback) { - options = options || {}; - - // Optional id generators - var operationIdGenerator = options.operationIdGenerator || basicOperationIdGenerator; - // Optional timestamp generator - var timestampGenerator = options.timestampGenerator || basicTimestampGenerator; - // Extend with event emitter functionality - EventEmitter.call(this); - - // Contains all the instrumentation overloads - this.overloads = []; - - // --------------------------------------------------------- - // - // Instrument prototype - // - // --------------------------------------------------------- - var instrumentPrototype = function(callback) { - var instrumentations = [] - - // Classes to support - var classes = [GridStore, OrderedBulkOperation, UnorderedBulkOperation, - CommandCursor, AggregationCursor, Cursor, Collection, Db]; - - // Add instrumentations to the available list - for(var i = 0; i < classes.length; i++) { - if(classes[i].define) { - instrumentations.push(classes[i].define.generate()); - } - } - - // Return the list of instrumentation points - callback(null, instrumentations); + instrument(MongoClient, callback) { + // store a reference to the original functions + this.$MongoClient = MongoClient; + const $prototypeConnect = (this.$prototypeConnect = MongoClient.prototype.connect); + + const instrumentation = this; + MongoClient.prototype.connect = function(callback) { + this.s.options.monitorCommands = true; + this.on('commandStarted', event => instrumentation.emit('started', event)); + this.on('commandSucceeded', event => instrumentation.emit('succeeded', event)); + this.on('commandFailed', event => instrumentation.emit('failed', event)); + return $prototypeConnect.call(this, callback); + }; + + if (typeof callback === 'function') callback(null, this); } - // Did the user want to instrument the prototype - if(typeof callback == 'function') { - instrumentPrototype(callback); + uninstrument() { + this.$MongoClient.prototype.connect = this.$prototypeConnect; } - - // --------------------------------------------------------- - // - // Server - // - // --------------------------------------------------------- - - // Reference - var self = this; - // Names of methods we need to wrap - var methods = ['command', 'insert', 'update', 'remove']; - // Prototype - var proto = core.Server.prototype; - // Core server method we are going to wrap - methods.forEach(function(x) { - var func = proto[x]; - - // Add to overloaded methods - self.overloads.push({proto: proto, name:x, func:func}); - - // The actual prototype - proto[x] = function() { - var requestId = core.Query.nextRequestId(); - // Get the arguments - var args = Array.prototype.slice.call(arguments, 0); - var ns = args[0]; - var commandObj = args[1]; - var options = args[2] || {}; - var keys = Object.keys(commandObj); - var commandName = keys[0]; - var db = ns.split('.')[0]; - - // Get the collection - var col = ns.split('.'); - col.shift(); - col = col.join('.'); - - // Do we have a legacy insert/update/remove command - if(x == 'insert') { //} && !this.lastIsMaster().maxWireVersion) { - commandName = 'insert'; - - // Re-write the command - commandObj = { - insert: col, documents: commandObj - } - - if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { - commandObj.writeConcern = options.writeConcern; - } - - commandObj.ordered = options.ordered != undefined ? options.ordered : true; - } else if(x == 'update') { // && !this.lastIsMaster().maxWireVersion) { - commandName = 'update'; - - // Re-write the command - commandObj = { - update: col, updates: commandObj - } - - if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { - commandObj.writeConcern = options.writeConcern; - } - - commandObj.ordered = options.ordered != undefined ? options.ordered : true; - } else if(x == 'remove') { //&& !this.lastIsMaster().maxWireVersion) { - commandName = 'delete'; - - // Re-write the command - commandObj = { - delete: col, deletes: commandObj - } - - if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { - commandObj.writeConcern = options.writeConcern; - } - - commandObj.ordered = options.ordered != undefined ? options.ordered : true; - } - - // Get the callback - var callback = args.pop(); - // Set current callback operation id from the current context or create - // a new one - var ourOpId = callback.operationId || operationIdGenerator.next(); - - // Get a connection reference for this server instance - var connection = this.s.pool.get() - - // Emit the start event for the command - var command = { - // Returns the command. - command: commandObj, - // Returns the database name. - databaseName: db, - // Returns the command name. - commandName: commandName, - // Returns the driver generated request id. - requestId: requestId, - // Returns the driver generated operation id. - // This is used to link events together such as bulk write operations. OPTIONAL. - operationId: ourOpId, - // Returns the connection id for the command. For languages that do not have this, - // this MUST return the driver equivalent which MUST include the server address and port. - // The name of this field is flexible to match the object that is returned from the driver. - connectionId: connection - }; - - // Filter out any sensitive commands - if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { - command.commandObj = {}; - command.commandObj[commandName] = true; - } - - // Emit the started event - self.emit('started', command) - - // Start time - var startTime = timestampGenerator.current(); - - // Push our handler callback - args.push(function(err, r) { - var endTime = timestampGenerator.current(); - var command = { - duration: timestampGenerator.duration(startTime, endTime), - commandName: commandName, - requestId: requestId, - operationId: ourOpId, - connectionId: connection - }; - - // If we have an error - if(err || (r && r.result && r.result.ok == 0)) { - command.failure = err || r.result.writeErrors || r.result; - - // Filter out any sensitive commands - if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { - command.failure = {}; - } - - self.emit('failed', command); - } else if(commandObj && commandObj.writeConcern - && commandObj.writeConcern.w == 0) { - // If we have write concern 0 - command.reply = {ok:1}; - self.emit('succeeded', command); - } else { - command.reply = r && r.result ? r.result : r; - - // Filter out any sensitive commands - if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { - command.reply = {}; - } - - self.emit('succeeded', command); - } - - // Return to caller - callback(err, r); - }); - - // Apply the call - func.apply(this, args); - } - }); - - // --------------------------------------------------------- - // - // Bulk Operations - // - // --------------------------------------------------------- - - // Inject ourselves into the Bulk methods - methods = ['execute']; - var prototypes = [ - require('./bulk/ordered').Bulk.prototype, - require('./bulk/unordered').Bulk.prototype - ] - - prototypes.forEach(function(proto) { - // Core server method we are going to wrap - methods.forEach(function(x) { - var func = proto[x]; - - // Add to overloaded methods - self.overloads.push({proto: proto, name:x, func:func}); - - // The actual prototype - proto[x] = function() { - // Get the arguments - var args = Array.prototype.slice.call(arguments, 0); - // Set an operation Id on the bulk object - this.operationId = operationIdGenerator.next(); - - // Get the callback - var callback = args.pop(); - // If we have a callback use this - if(typeof callback == 'function') { - args.push(function(err, r) { - // Return to caller - callback(err, r); - }); - - // Apply the call - func.apply(this, args); - } else { - return func.apply(this, args); - } - } - }); - }); - - // --------------------------------------------------------- - // - // Cursor - // - // --------------------------------------------------------- - - // Inject ourselves into the Cursor methods - methods = ['_find', '_getmore', '_killcursor']; - prototypes = [ - require('./cursor').prototype, - require('./command_cursor').prototype, - require('./aggregation_cursor').prototype - ] - - // Command name translation - var commandTranslation = { - '_find': 'find', '_getmore': 'getMore', '_killcursor': 'killCursors', '_explain': 'explain' - } - - prototypes.forEach(function(proto) { - - // Core server method we are going to wrap - methods.forEach(function(x) { - var func = proto[x]; - - // Add to overloaded methods - self.overloads.push({proto: proto, name:x, func:func}); - - // The actual prototype - proto[x] = function() { - var cursor = this; - var requestId = core.Query.nextRequestId(); - var ourOpId = operationIdGenerator.next(); - var parts = this.ns.split('.'); - var db = parts[0]; - - // Get the collection - parts.shift(); - var collection = parts.join('.'); - - // Set the command - var command = this.query; - var cmd = this.s.cmd; - - // If we have a find method, set the operationId on the cursor - if(x == '_find') { - cursor.operationId = ourOpId; - } - - // Do we have a find command rewrite it - if(x == '_getmore') { - command = { - getMore: this.cursorState.cursorId, - collection: collection, - batchSize: cmd.batchSize - } - - if(cmd.maxTimeMS) command.maxTimeMS = cmd.maxTimeMS; - } else if(x == '_killcursor') { - command = { - killCursors: collection, - cursors: [this.cursorState.cursorId] - } - } else if(cmd.find) { - command = { - find: collection, filter: cmd.query - } - - if(cmd.sort) command.sort = cmd.sort; - if(cmd.fields) command.projection = cmd.fields; - if(cmd.limit && cmd.limit < 0) { - command.limit = Math.abs(cmd.limit); - command.singleBatch = true; - } else if(cmd.limit) { - command.limit = Math.abs(cmd.limit); - } - - // Options - if(cmd.skip) command.skip = cmd.skip; - if(cmd.hint) command.hint = cmd.hint; - if(cmd.batchSize) command.batchSize = cmd.batchSize; - if(typeof cmd.returnKey == 'boolean') command.returnKey = cmd.returnKey; - if(cmd.comment) command.comment = cmd.comment; - if(cmd.min) command.min = cmd.min; - if(cmd.max) command.max = cmd.max; - if(cmd.maxScan) command.maxScan = cmd.maxScan; - if(cmd.maxTimeMS) command.maxTimeMS = cmd.maxTimeMS; - - // Flags - if(typeof cmd.awaitData == 'boolean') command.awaitData = cmd.awaitData; - if(typeof cmd.snapshot == 'boolean') command.snapshot = cmd.snapshot; - if(typeof cmd.tailable == 'boolean') command.tailable = cmd.tailable; - if(typeof cmd.oplogReplay == 'boolean') command.oplogReplay = cmd.oplogReplay; - if(typeof cmd.noCursorTimeout == 'boolean') command.noCursorTimeout = cmd.noCursorTimeout; - if(typeof cmd.partial == 'boolean') command.partial = cmd.partial; - if(typeof cmd.showDiskLoc == 'boolean') command.showRecordId = cmd.showDiskLoc; - - // Read Concern - if(cmd.readConcern) command.readConcern = cmd.readConcern; - - // Override method - if(cmd.explain) command.explain = cmd.explain; - if(cmd.exhaust) command.exhaust = cmd.exhaust; - - // If we have a explain flag - if(cmd.explain) { - // Create fake explain command - command = { - explain: command, - verbosity: 'allPlansExecution' - } - - // Set readConcern on the command if available - if(cmd.readConcern) command.readConcern = cmd.readConcern - - // Set up the _explain name for the command - x = '_explain'; - } - } else { - command = cmd; - } - - // Set up the connection - var connectionId = null; - - // Set local connection - if(this.connection) connectionId = this.connection; - if(!connectionId && this.server && this.server.getConnection) connectionId = this.server.getConnection(); - - // Get the command Name - var commandName = x == '_find' ? Object.keys(command)[0] : commandTranslation[x]; - - // Emit the start event for the command - command = { - // Returns the command. - command: command, - // Returns the database name. - databaseName: db, - // Returns the command name. - commandName: commandName, - // Returns the driver generated request id. - requestId: requestId, - // Returns the driver generated operation id. - // This is used to link events together such as bulk write operations. OPTIONAL. - operationId: this.operationId, - // Returns the connection id for the command. For languages that do not have this, - // this MUST return the driver equivalent which MUST include the server address and port. - // The name of this field is flexible to match the object that is returned from the driver. - connectionId: connectionId - }; - - // Get the arguments - var args = Array.prototype.slice.call(arguments, 0); - - // Get the callback - var callback = args.pop(); - - // We do not have a callback but a Promise - if(typeof callback == 'function' || command.commandName == 'killCursors') { - var startTime = timestampGenerator.current(); - // Emit the started event - self.emit('started', command) - - // Emit succeeded event with killcursor if we have a legacy protocol - if(command.commandName == 'killCursors' - && this.server.lastIsMaster() - && this.server.lastIsMaster().maxWireVersion < 4) { - // Emit the succeeded command - command = { - duration: timestampGenerator.duration(startTime, timestampGenerator.current()), - commandName: commandName, - requestId: requestId, - operationId: cursor.operationId, - connectionId: cursor.server.getConnection(), - reply: [{ok:1}] - }; - - // Apply callback to the list of args - args.push(callback); - // Apply the call - func.apply(this, args); - // Emit the command - return self.emit('succeeded', command) - } - - // Add our callback handler - args.push(function(err, r) { - if(err) { - // Command - var command = { - duration: timestampGenerator.duration(startTime, timestampGenerator.current()), - commandName: commandName, - requestId: requestId, - operationId: ourOpId, - connectionId: cursor.server.getConnection(), - failure: err }; - - // Emit the command - self.emit('failed', command) - } else { - // Do we have a getMore - if(commandName.toLowerCase() == 'getmore' && r == null) { - r = { - cursor: { - id: cursor.cursorState.cursorId, - ns: cursor.ns, - nextBatch: cursor.cursorState.documents - }, ok:1 - } - } else if((commandName.toLowerCase() == 'find' - || commandName.toLowerCase() == 'aggregate' - || commandName.toLowerCase() == 'listcollections') && r == null) { - r = { - cursor: { - id: cursor.cursorState.cursorId, - ns: cursor.ns, - firstBatch: cursor.cursorState.documents - }, ok:1 - } - } else if(commandName.toLowerCase() == 'killcursors' && r == null) { - r = { - cursorsUnknown:[cursor.cursorState.lastCursorId], - ok:1 - } - } - - // cursor id is zero, we can issue success command - command = { - duration: timestampGenerator.duration(startTime, timestampGenerator.current()), - commandName: commandName, - requestId: requestId, - operationId: cursor.operationId, - connectionId: cursor.server.getConnection(), - reply: r && r.result ? r.result : r - }; - - // Emit the command - self.emit('succeeded', command) - } - - // Return - if(!callback) return; - - // Return to caller - callback(err, r); - }); - - // Apply the call - func.apply(this, args); - } else { - // Assume promise, push back the missing value - args.push(callback); - // Get the promise - var promise = func.apply(this, args); - // Return a new promise - return new cursor.s.promiseLibrary(function(resolve, reject) { - var startTime = timestampGenerator.current(); - // Emit the started event - self.emit('started', command) - // Execute the function - promise.then(function() { - // cursor id is zero, we can issue success command - var command = { - duration: timestampGenerator.duration(startTime, timestampGenerator.current()), - commandName: commandName, - requestId: requestId, - operationId: cursor.operationId, - connectionId: cursor.server.getConnection(), - reply: cursor.cursorState.documents - }; - - // Emit the command - self.emit('succeeded', command) - }).catch(function(err) { - // Command - var command = { - duration: timestampGenerator.duration(startTime, timestampGenerator.current()), - commandName: commandName, - requestId: requestId, - operationId: ourOpId, - connectionId: cursor.server.getConnection(), - failure: err }; - - // Emit the command - self.emit('failed', command) - // reject the promise - reject(err); - }); - }); - } - } - }); - }); -} - -inherits(Instrumentation, EventEmitter); - -Instrumentation.prototype.uninstrument = function() { - for(var i = 0; i < this.overloads.length; i++) { - var obj = this.overloads[i]; - obj.proto[obj.name] = obj.func; - } - - // Remove all listeners - this.removeAllListeners('started'); - this.removeAllListeners('succeeded'); - this.removeAllListeners('failed'); } module.exports = Instrumentation; diff --git a/node_modules/mongodb/lib/authenticate.js b/node_modules/mongodb/lib/authenticate.js index d179478..35c92b4 100644 --- a/node_modules/mongodb/lib/authenticate.js +++ b/node_modules/mongodb/lib/authenticate.js @@ -1,109 +1,135 @@ -var shallowClone = require('./utils').shallowClone - , handleCallback = require('./utils').handleCallback - , MongoError = require('mongodb-core').MongoError - , f = require('util').format; +'use strict'; -var authenticate = function(self, username, password, options, callback) { +var shallowClone = require('./utils').shallowClone, + handleCallback = require('./utils').handleCallback, + MongoError = require('mongodb-core').MongoError, + f = require('util').format; + +var authenticate = function(client, username, password, options, callback) { // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + if (client.topology && client.topology.isDestroyed()) + return callback(new MongoError('topology was destroyed')); // the default db to authenticate against is 'self' - // if authenticate is called from a retry context, it may be another one, like admin - var authdb = options.dbName ? options.dbName : self.databaseName; - authdb = self.authSource ? self.authSource : authdb; + // if authententicate is called from a retry context, it may be another one, like admin + var authdb = options.dbName; authdb = options.authdb ? options.authdb : authdb; authdb = options.authSource ? options.authSource : authdb; // Callback var _callback = function(err, result) { - if(self.listeners('authenticated').length > 0) { - self.emit('authenticated', err, result); + if (client.listeners('authenticated').length > 0) { + client.emit('authenticated', err, result); } // Return to caller handleCallback(callback, err, result); - } + }; // authMechanism var authMechanism = options.authMechanism || ''; authMechanism = authMechanism.toUpperCase(); // If classic auth delegate to auth command - if(authMechanism == 'MONGODB-CR') { - self.s.topology.auth('mongocr', authdb, username, password, function(err) { - if(err) return handleCallback(callback, err, false); + if (authMechanism === 'MONGODB-CR') { + client.topology.auth('mongocr', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); - } else if(authMechanism == 'PLAIN') { - self.s.topology.auth('plain', authdb, username, password, function(err) { - if(err) return handleCallback(callback, err, false); + } else if (authMechanism === 'PLAIN') { + client.topology.auth('plain', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); - } else if(authMechanism == 'MONGODB-X509') { - self.s.topology.auth('x509', authdb, username, password, function(err) { - if(err) return handleCallback(callback, err, false); + } else if (authMechanism === 'MONGODB-X509') { + client.topology.auth('x509', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); - } else if(authMechanism == 'SCRAM-SHA-1') { - self.s.topology.auth('scram-sha-1', authdb, username, password, function(err) { - if(err) return handleCallback(callback, err, false); + } else if (authMechanism === 'SCRAM-SHA-1') { + client.topology.auth('scram-sha-1', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); - } else if(authMechanism == 'GSSAPI') { - if(process.platform == 'win32') { - self.s.topology.auth('sspi', authdb, username, password, options, function(err) { - if(err) return handleCallback(callback, err, false); + } else if (authMechanism === 'SCRAM-SHA-256') { + client.topology.auth('scram-sha-256', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else if (authMechanism === 'GSSAPI') { + if (process.platform === 'win32') { + client.topology.auth('sspi', authdb, username, password, options, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); } else { - self.s.topology.auth('gssapi', authdb, username, password, options, function(err) { - if(err) return handleCallback(callback, err, false); + client.topology.auth('gssapi', authdb, username, password, options, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); } - } else if(authMechanism == 'DEFAULT') { - self.s.topology.auth('default', authdb, username, password, function(err) { - if(err) return handleCallback(callback, err, false); + } else if (authMechanism === 'DEFAULT') { + client.topology.auth('default', authdb, username, password, function(err) { + if (err) return handleCallback(callback, err, false); _callback(null, true); }); } else { - handleCallback(callback, MongoError.create({message: f("authentication mechanism %s not supported", options.authMechanism), driver:true})); + handleCallback( + callback, + MongoError.create({ + message: f('authentication mechanism %s not supported', options.authMechanism), + driver: true + }) + ); } -} +}; module.exports = function(self, username, password, options, callback) { - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + // Shallow copy the options options = shallowClone(options); // Set default mechanism - if(!options.authMechanism) { + if (!options.authMechanism) { options.authMechanism = 'DEFAULT'; - } else if(options.authMechanism != 'GSSAPI' - && options.authMechanism != 'DEFAULT' - && options.authMechanism != 'MONGODB-CR' - && options.authMechanism != 'MONGODB-X509' - && options.authMechanism != 'SCRAM-SHA-1' - && options.authMechanism != 'PLAIN') { - return handleCallback(callback, MongoError.create({message: "only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, SCRAM-SHA-1 or MONGODB-CR is supported by authMechanism", driver:true})); + } else if ( + options.authMechanism !== 'GSSAPI' && + options.authMechanism !== 'DEFAULT' && + options.authMechanism !== 'MONGODB-CR' && + options.authMechanism !== 'MONGODB-X509' && + options.authMechanism !== 'SCRAM-SHA-1' && + options.authMechanism !== 'SCRAM-SHA-256' && + options.authMechanism !== 'PLAIN' + ) { + return handleCallback( + callback, + MongoError.create({ + message: + 'only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 is supported by authMechanism', + driver: true + }) + ); } // If we have a callback fallback - if(typeof callback == 'function') return authenticate(self, username, password, options, function(err, r) { - // Support failed auth method - if(err && err.message && err.message.indexOf('saslStart') != -1) err.code = 59; - // Reject error - if(err) return callback(err, r); - callback(null, r); - }); + if (typeof callback === 'function') + return authenticate(self, username, password, options, function(err, r) { + // Support failed auth method + if (err && err.message && err.message.indexOf('saslStart') !== -1) err.code = 59; + // Reject error + if (err) return callback(err, r); + callback(null, r); + }); // Return a promise return new self.s.promiseLibrary(function(resolve, reject) { authenticate(self, username, password, options, function(err, r) { // Support failed auth method - if(err && err.message && err.message.indexOf('saslStart') != -1) err.code = 59; + if (err && err.message && err.message.indexOf('saslStart') !== -1) err.code = 59; // Reject error - if(err) return reject(err); + if (err) return reject(err); resolve(r); }); }); diff --git a/node_modules/mongodb/lib/bulk/common.js b/node_modules/mongodb/lib/bulk/common.js index 6ebe3ef..587c6ad 100644 --- a/node_modules/mongodb/lib/bulk/common.js +++ b/node_modules/mongodb/lib/bulk/common.js @@ -1,105 +1,131 @@ -"use strict"; +'use strict'; -var Long = require('mongodb-core').BSON.Long, - Timestamp = require('mongodb-core').BSON.Timestamp; +const Long = require('mongodb-core').BSON.Long; +const MongoError = require('mongodb-core').MongoError; +const toError = require('../utils').toError; +const handleCallback = require('../utils').handleCallback; +const applyWriteConcern = require('../utils').applyWriteConcern; +const shallowClone = require('../utils').shallowClone; +const ObjectID = require('mongodb-core').BSON.ObjectID; +const BSON = require('mongodb-core').BSON; // Error codes -var UNKNOWN_ERROR = 8; -var INVALID_BSON_ERROR = 22; -var WRITE_CONCERN_ERROR = 64; -var MULTIPLE_ERROR = 65; +const UNKNOWN_ERROR = 8; +const INVALID_BSON_ERROR = 22; +const WRITE_CONCERN_ERROR = 64; +const MULTIPLE_ERROR = 65; // Insert types -var INSERT = 1; -var UPDATE = 2; -var REMOVE = 3 +const INSERT = 1; +const UPDATE = 2; +const REMOVE = 3; - -// Get write concern -var writeConcern = function(target, col, options) { - var writeConcern = {}; - - // Collection level write concern - if(col.writeConcern && col.writeConcern.w != null) writeConcern.w = col.writeConcern.w; - if(col.writeConcern && col.writeConcern.j != null) writeConcern.j = col.writeConcern.j; - if(col.writeConcern && col.writeConcern.fsync != null) writeConcern.fsync = col.writeConcern.fsync; - if(col.writeConcern && col.writeConcern.wtimeout != null) writeConcern.wtimeout = col.writeConcern.wtimeout; - - // Options level write concern - if(options && options.w != null) writeConcern.w = options.w; - if(options && options.wtimeout != null) writeConcern.wtimeout = options.wtimeout; - if(options && options.j != null) writeConcern.j = options.j; - if(options && options.fsync != null) writeConcern.fsync = options.fsync; - - // Return write concern - return writeConcern; -} - -/** - * Helper function to define properties - * @ignore - */ -var defineReadOnlyProperty = function(self, name, value) { - Object.defineProperty(self, name, { - enumerable: true - , get: function() { - return value; - } - }); -} +const bson = new BSON([ + BSON.Binary, + BSON.Code, + BSON.DBRef, + BSON.Decimal128, + BSON.Double, + BSON.Int32, + BSON.Long, + BSON.Map, + BSON.MaxKey, + BSON.MinKey, + BSON.ObjectId, + BSON.BSONRegExp, + BSON.Symbol, + BSON.Timestamp +]); /** * Keeps the state of a unordered batch so we can rewrite the results * correctly after command execution * @ignore */ -var Batch = function(batchType, originalZeroIndex) { - this.originalZeroIndex = originalZeroIndex; - this.currentIndex = 0; - this.originalIndexes = []; - this.batchType = batchType; - this.operations = []; - this.size = 0; - this.sizeBytes = 0; +class Batch { + constructor(batchType, originalZeroIndex) { + this.originalZeroIndex = originalZeroIndex; + this.currentIndex = 0; + this.originalIndexes = []; + this.batchType = batchType; + this.operations = []; + this.size = 0; + this.sizeBytes = 0; + } } /** * Wraps a legacy operation so we can correctly rewrite it's error * @ignore */ -var LegacyOp = function(batchType, operation, index) { - this.batchType = batchType; - this.index = index; - this.operation = operation; +class LegacyOp { + constructor(batchType, operation, index) { + this.batchType = batchType; + this.index = index; + this.operation = operation; + } } /** * Create a new BulkWriteResult instance (INTERNAL TYPE, do not instantiate directly) * * @class - * @property {boolean} ok Did bulk operation correctly execute - * @property {number} nInserted number of inserted documents - * @property {number} nUpdated number of documents updated logically - * @property {number} nUpserted Number of upserted documents - * @property {number} nModified Number of documents updated physically on disk - * @property {number} nRemoved Number of removed documents * @return {BulkWriteResult} a BulkWriteResult instance */ -var BulkWriteResult = function(bulkResult) { - defineReadOnlyProperty(this, "ok", bulkResult.ok); - defineReadOnlyProperty(this, "nInserted", bulkResult.nInserted); - defineReadOnlyProperty(this, "nUpserted", bulkResult.nUpserted); - defineReadOnlyProperty(this, "nMatched", bulkResult.nMatched); - defineReadOnlyProperty(this, "nModified", bulkResult.nModified); - defineReadOnlyProperty(this, "nRemoved", bulkResult.nRemoved); +class BulkWriteResult { + constructor(bulkResult) { + this.result = bulkResult; + } + + /** + * @return {boolean} ok Did bulk operation correctly execute + */ + get ok() { + return this.result.ok; + } + + /** + * @return {number} nInserted number of inserted documents + */ + get nInserted() { + return this.result.nInserted; + } + + /** + * @return {number} nUpserted Number of upserted documents + */ + get nUpserted() { + return this.result.nUpserted; + } + + /** + * @return {number} nMatched Number of matched documents + */ + get nMatched() { + return this.result.nMatched; + } + + /** + * @return {number} nModified Number of documents updated physically on disk + */ + get nModified() { + return this.result.nModified; + } + + /** + * @return {number} nRemoved Number of removed documents + */ + get nRemoved() { + return this.result.nRemoved; + } /** * Return an array of inserted ids * * @return {object[]} */ - this.getInsertedIds = function() { - return bulkResult.insertedIds; + getInsertedIds() { + return this.result.insertedIds; } /** @@ -107,8 +133,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {object[]} */ - this.getUpsertedIds = function() { - return bulkResult.upserted; + getUpsertedIds() { + return this.result.upserted; } /** @@ -117,8 +143,8 @@ var BulkWriteResult = function(bulkResult) { * @param {number} index the number of the upserted id to return, returns undefined if no result for passed in index * @return {object} */ - this.getUpsertedIdAt = function(index) { - return bulkResult.upserted[index]; + getUpsertedIdAt(index) { + return this.result.upserted[index]; } /** @@ -126,8 +152,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {object} */ - this.getRawResponse = function() { - return bulkResult; + getRawResponse() { + return this.result; } /** @@ -135,8 +161,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {boolean} */ - this.hasWriteErrors = function() { - return bulkResult.writeErrors.length > 0; + hasWriteErrors() { + return this.result.writeErrors.length > 0; } /** @@ -144,8 +170,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {number} */ - this.getWriteErrorCount = function() { - return bulkResult.writeErrors.length; + getWriteErrorCount() { + return this.result.writeErrors.length; } /** @@ -154,9 +180,9 @@ var BulkWriteResult = function(bulkResult) { * @param {number} index of the write error to return, returns null if there is no result for passed in index * @return {WriteError} */ - this.getWriteErrorAt = function(index) { - if(index < bulkResult.writeErrors.length) { - return bulkResult.writeErrors[index]; + getWriteErrorAt(index) { + if (index < this.result.writeErrors.length) { + return this.result.writeErrors[index]; } return null; } @@ -166,8 +192,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {object[]} */ - this.getWriteErrors = function() { - return bulkResult.writeErrors; + getWriteErrors() { + return this.result.writeErrors; } /** @@ -175,8 +201,8 @@ var BulkWriteResult = function(bulkResult) { * * @return {object} */ - this.getLastOp = function() { - return bulkResult.lastOp; + getLastOp() { + return this.result.lastOp; } /** @@ -184,38 +210,46 @@ var BulkWriteResult = function(bulkResult) { * * @return {WriteConcernError} */ - this.getWriteConcernError = function() { - if(bulkResult.writeConcernErrors.length == 0) { + getWriteConcernError() { + if (this.result.writeConcernErrors.length === 0) { return null; - } else if(bulkResult.writeConcernErrors.length == 1) { + } else if (this.result.writeConcernErrors.length === 1) { // Return the error - return bulkResult.writeConcernErrors[0]; + return this.result.writeConcernErrors[0]; } else { - // Combine the errors - var errmsg = ""; - for(var i = 0; i < bulkResult.writeConcernErrors.length; i++) { - var err = bulkResult.writeConcernErrors[i]; + let errmsg = ''; + for (let i = 0; i < this.result.writeConcernErrors.length; i++) { + const err = this.result.writeConcernErrors[i]; errmsg = errmsg + err.errmsg; // TODO: Something better - if(i == 0) errmsg = errmsg + " and "; + if (i === 0) errmsg = errmsg + ' and '; } - return new WriteConcernError({ errmsg : errmsg, code : WRITE_CONCERN_ERROR }); + return new WriteConcernError({ errmsg: errmsg, code: WRITE_CONCERN_ERROR }); } } - this.toJSON = function() { - return bulkResult; + /** + * @return {BulkWriteResult} a BulkWriteResult instance + */ + toJSON() { + return this.result; } - this.toString = function() { - return "BulkWriteResult(" + this.toJSON(bulkResult) + ")"; + /** + * @return {string} + */ + toString() { + return `BulkWriteResult(${this.toJSON(this.result)})`; } - this.isOk = function() { - return bulkResult.ok == 1; + /** + * @return {boolean} + */ + isOk() { + return this.result.ok === 1; } } @@ -223,23 +257,39 @@ var BulkWriteResult = function(bulkResult) { * Create a new WriteConcernError instance (INTERNAL TYPE, do not instantiate directly) * * @class - * @property {number} code Write concern error code. - * @property {string} errmsg Write concern error message. * @return {WriteConcernError} a WriteConcernError instance */ -var WriteConcernError = function(err) { - if(!(this instanceof WriteConcernError)) return new WriteConcernError(err); +class WriteConcernError { + constructor(err) { + this.err = err; + } + + /** + * @return {number} code Write concern error code. + */ + get code() { + return this.err.code; + } - // Define properties - defineReadOnlyProperty(this, "code", err.code); - defineReadOnlyProperty(this, "errmsg", err.errmsg); + /** + * @return {string} errmsg Write concern error message. + */ + get errmsg() { + return this.err.errmsg; + } - this.toJSON = function() { - return {code: err.code, errmsg: err.errmsg}; + /** + * @return {object} + */ + toJSON() { + return { code: this.err.code, errmsg: this.err.errmsg }; } - this.toString = function() { - return "WriteConcernError(" + err.errmsg + ")"; + /** + * @return {string} + */ + toString() { + return `WriteConcernError(${this.err.errmsg})`; } } @@ -247,31 +297,54 @@ var WriteConcernError = function(err) { * Create a new WriteError instance (INTERNAL TYPE, do not instantiate directly) * * @class - * @property {number} code Write concern error code. - * @property {number} index Write concern error original bulk operation index. - * @property {string} errmsg Write concern error message. * @return {WriteConcernError} a WriteConcernError instance */ -var WriteError = function(err) { - if(!(this instanceof WriteError)) return new WriteError(err); +class WriteError { + constructor(err) { + this.err = err; + } - // Define properties - defineReadOnlyProperty(this, "code", err.code); - defineReadOnlyProperty(this, "index", err.index); - defineReadOnlyProperty(this, "errmsg", err.errmsg); + /** + * @return {number} code Write concern error code. + */ + get code() { + return this.err.code; + } - // - // Define access methods - this.getOperation = function() { - return err.op; + /** + * @return {number} index Write concern error original bulk operation index. + */ + get index() { + return this.err.index; + } + + /** + * @return {string} errmsg Write concern error message. + */ + get errmsg() { + return this.err.errmsg; + } + + /** + * Define access methods + * @return {object} + */ + getOperation() { + return this.err.op; } - this.toJSON = function() { - return {code: err.code, index: err.index, errmsg: err.errmsg, op: err.op}; + /** + * @return {object} + */ + toJSON() { + return { code: this.err.code, index: this.err.index, errmsg: this.err.errmsg, op: this.err.op }; } - this.toString = function() { - return "WriteError(" + JSON.stringify(this.toJSON()) + ")"; + /** + * @return {string} + */ + toString() { + return `WriteError(${JSON.stringify(this.toJSON())})`; } } @@ -279,68 +352,70 @@ var WriteError = function(err) { * Merges results into shared data structure * @ignore */ -var mergeBatchResults = function(ordered, batch, bulkResult, err, result) { +function mergeBatchResults(ordered, batch, bulkResult, err, result) { // If we have an error set the result to be the err object - if(err) { + if (err) { result = err; - } else if(result && result.result) { + } else if (result && result.result) { result = result.result; - } else if(result == null) { + } else if (result == null) { return; } // Do we have a top level error stop processing and return - if(result.ok == 0 && bulkResult.ok == 1) { + if (result.ok === 0 && bulkResult.ok === 1) { bulkResult.ok = 0; - var writeError = { - index: 0 - , code: result.code || 0 - , errmsg: result.message - , op: batch.operations[0] + const writeError = { + index: 0, + code: result.code || 0, + errmsg: result.message, + op: batch.operations[0] }; bulkResult.writeErrors.push(new WriteError(writeError)); return; - } else if(result.ok == 0 && bulkResult.ok == 0) { + } else if (result.ok === 0 && bulkResult.ok === 0) { return; } // Deal with opTime if available - if(result.opTime || result.lastOp) { - var opTime = result.lastOp || result.opTime; - var lastOpTS = null; - var lastOpT = null; + if (result.opTime || result.lastOp) { + const opTime = result.lastOp || result.opTime; + let lastOpTS = null; + let lastOpT = null; // We have a time stamp - if(opTime && opTime._bsontype == 'Timestamp') { - if(bulkResult.lastOp == null) { + if (opTime && opTime._bsontype === 'Timestamp') { + if (bulkResult.lastOp == null) { bulkResult.lastOp = opTime; - } else if(opTime.greaterThan(bulkResult.lastOp)) { + } else if (opTime.greaterThan(bulkResult.lastOp)) { bulkResult.lastOp = opTime; } } else { // Existing TS - if(bulkResult.lastOp) { - lastOpTS = typeof bulkResult.lastOp.ts == 'number' - ? Long.fromNumber(bulkResult.lastOp.ts) : bulkResult.lastOp.ts; - lastOpT = typeof bulkResult.lastOp.t == 'number' - ? Long.fromNumber(bulkResult.lastOp.t) : bulkResult.lastOp.t; + if (bulkResult.lastOp) { + lastOpTS = + typeof bulkResult.lastOp.ts === 'number' + ? Long.fromNumber(bulkResult.lastOp.ts) + : bulkResult.lastOp.ts; + lastOpT = + typeof bulkResult.lastOp.t === 'number' + ? Long.fromNumber(bulkResult.lastOp.t) + : bulkResult.lastOp.t; } // Current OpTime TS - var opTimeTS = typeof opTime.ts == 'number' - ? Long.fromNumber(opTime.ts) : opTime.ts; - var opTimeT = typeof opTime.t == 'number' - ? Long.fromNumber(opTime.t) : opTime.t; + const opTimeTS = typeof opTime.ts === 'number' ? Long.fromNumber(opTime.ts) : opTime.ts; + const opTimeT = typeof opTime.t === 'number' ? Long.fromNumber(opTime.t) : opTime.t; // Compare the opTime's - if(bulkResult.lastOp == null) { + if (bulkResult.lastOp == null) { bulkResult.lastOp = opTime; - } else if(opTimeTS.greaterThan(lastOpTS)) { + } else if (opTimeTS.greaterThan(lastOpTS)) { bulkResult.lastOp = opTime; - } else if(opTimeTS.equals(lastOpTS)) { - if(opTimeT.greaterThan(lastOpT)) { + } else if (opTimeTS.equals(lastOpTS)) { + if (opTimeT.greaterThan(lastOpT)) { bulkResult.lastOp = opTime; } } @@ -348,93 +423,685 @@ var mergeBatchResults = function(ordered, batch, bulkResult, err, result) { } // If we have an insert Batch type - if(batch.batchType == INSERT && result.n) { + if (batch.batchType === INSERT && result.n) { bulkResult.nInserted = bulkResult.nInserted + result.n; } // If we have an insert Batch type - if(batch.batchType == REMOVE && result.n) { + if (batch.batchType === REMOVE && result.n) { bulkResult.nRemoved = bulkResult.nRemoved + result.n; } - var nUpserted = 0; + let nUpserted = 0; // We have an array of upserted values, we need to rewrite the indexes - if(Array.isArray(result.upserted)) { + if (Array.isArray(result.upserted)) { nUpserted = result.upserted.length; - for(var i = 0; i < result.upserted.length; i++) { + for (let i = 0; i < result.upserted.length; i++) { bulkResult.upserted.push({ - index: result.upserted[i].index + batch.originalZeroIndex - , _id: result.upserted[i]._id + index: result.upserted[i].index + batch.originalZeroIndex, + _id: result.upserted[i]._id }); } - } else if(result.upserted) { - + } else if (result.upserted) { nUpserted = 1; bulkResult.upserted.push({ - index: batch.originalZeroIndex - , _id: result.upserted + index: batch.originalZeroIndex, + _id: result.upserted }); } // If we have an update Batch type - if(batch.batchType == UPDATE && result.n) { - var nModified = result.nModified; + if (batch.batchType === UPDATE && result.n) { + const nModified = result.nModified; bulkResult.nUpserted = bulkResult.nUpserted + nUpserted; bulkResult.nMatched = bulkResult.nMatched + (result.n - nUpserted); - if(typeof nModified == 'number') { + if (typeof nModified === 'number') { bulkResult.nModified = bulkResult.nModified + nModified; } else { bulkResult.nModified = null; } } - if(Array.isArray(result.writeErrors)) { - for(i = 0; i < result.writeErrors.length; i++) { - - writeError = { - index: batch.originalZeroIndex + result.writeErrors[i].index - , code: result.writeErrors[i].code - , errmsg: result.writeErrors[i].errmsg - , op: batch.operations[result.writeErrors[i].index] + if (Array.isArray(result.writeErrors)) { + for (let i = 0; i < result.writeErrors.length; i++) { + const writeError = { + index: batch.originalZeroIndex + result.writeErrors[i].index, + code: result.writeErrors[i].code, + errmsg: result.writeErrors[i].errmsg, + op: batch.operations[result.writeErrors[i].index] }; bulkResult.writeErrors.push(new WriteError(writeError)); } } - if(result.writeConcernError) { + if (result.writeConcernError) { bulkResult.writeConcernErrors.push(new WriteConcernError(result.writeConcernError)); } } -// -// Clone the options -var cloneOptions = function(options) { - var clone = {}; - var keys = Object.keys(options); - for(var i = 0; i < keys.length; i++) { - clone[keys[i]] = options[keys[i]]; +/** + * handles write concern error + * + * @param {object} batch + * @param {object} bulkResult + * @param {boolean} ordered + * @param {WriteConcernError} err + * @param {function} callback + */ +function handleMongoWriteConcernError(batch, bulkResult, ordered, err, callback) { + mergeBatchResults(ordered, batch, bulkResult, null, err.result); + + const wrappedWriteConcernError = new WriteConcernError({ + errmsg: err.result.writeConcernError.errmsg, + code: err.result.writeConcernError.result + }); + return handleCallback( + callback, + new BulkWriteError(toError(wrappedWriteConcernError), new BulkWriteResult(bulkResult)), + null + ); +} + +/** + * Creates a new BulkWriteError + * + * @class + * @param {Error|string|object} message The error message + * @param {BulkWriteResult} result The result of the bulk write operation + * @return {BulkWriteError} A BulkWriteError instance + * @extends {MongoError} + */ +class BulkWriteError extends MongoError { + constructor(error, result) { + const message = error.err || error.errmsg || error.errMessage || error; + super(message); + + Object.assign(this, error); + + this.name = 'BulkWriteError'; + this.result = result; + } +} + +/** + * Handles the find operators for the bulk operations + * @class + */ +class FindOperators { + /** + * @param {OrderedBulkOperation|UnorderedBulkOperation} bulkOperation + */ + constructor(bulkOperation) { + this.s = bulkOperation.s; + } + + /** + * Add a single update document to the bulk operation + * + * @method + * @param {object} updateDocument update operations + * @throws {MongoError} + * @return {OrderedBulkOperation|UnordedBulkOperation} + */ + update(updateDocument) { + // Perform upsert + const upsert = typeof this.s.currentOp.upsert === 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + const document = { + q: this.s.currentOp.selector, + u: updateDocument, + multi: true, + upsert: upsert + }; + + // Clear out current Op + this.s.currentOp = null; + return this.s.options.addToOperationsList(this, UPDATE, document); + } + + /** + * Add a single update one document to the bulk operation + * + * @method + * @param {object} updateDocument update operations + * @throws {MongoError} + * @return {OrderedBulkOperation|UnordedBulkOperation} + */ + updateOne(updateDocument) { + // Perform upsert + const upsert = typeof this.s.currentOp.upsert === 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + const document = { + q: this.s.currentOp.selector, + u: updateDocument, + multi: false, + upsert: upsert + }; + + // Clear out current Op + this.s.currentOp = null; + return this.s.options.addToOperationsList(this, UPDATE, document); + } + + /** + * Add a replace one operation to the bulk operation + * + * @method + * @param {object} updateDocument the new document to replace the existing one with + * @throws {MongoError} + * @return {OrderedBulkOperation|UnorderedBulkOperation} + */ + replaceOne(updateDocument) { + this.updateOne(updateDocument); + } + + /** + * Upsert modifier for update bulk operation + * + * @method + * @throws {MongoError} + * @return {FindOperators} + */ + upsert() { + this.s.currentOp.upsert = true; + return this; } - return clone; + /** + * Add a delete one operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {OrderedBulkOperation|UnordedBulkOperation} + */ + deleteOne() { + // Establish the update command + const document = { + q: this.s.currentOp.selector, + limit: 1 + }; + + // Clear out current Op + this.s.currentOp = null; + return this.s.options.addToOperationsList(this, REMOVE, document); + } + + /** + * Add a delete operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {OrderedBulkOperation|UnordedBulkOperation} + */ + delete() { + // Establish the update command + const document = { + q: this.s.currentOp.selector, + limit: 0 + }; + + // Clear out current Op + this.s.currentOp = null; + return this.s.options.addToOperationsList(this, REMOVE, document); + } + + /** + * backwards compatability for deleteOne + */ + removeOne() { + return this.deleteOne(); + } + + /** + * backwards compatability for delete + */ + remove() { + return this.delete(); + } +} + +/** + * Parent class to OrderedBulkOperation and UnorderedBulkOperation + * @class + */ +class BulkOperationBase { + /** + * Create a new OrderedBulkOperation or UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @property {number} length Get the number of operations in the bulk. + * @return {OrderedBulkOperation|UnordedBulkOperation} + */ + constructor(topology, collection, options, isOrdered) { + // determine whether bulkOperation is ordered or unordered + this.isOrdered = isOrdered; + + options = options == null ? {} : options; + // TODO Bring from driver information in isMaster + // Get the namespace for the write operations + const namespace = collection.collectionName; + // Used to mark operation as executed + const executed = false; + + // Current item + const currentOp = null; + + // Handle to the bson serializer, used to calculate running sizes + const bson = topology.bson; + + // Set max byte size + const isMaster = topology.lastIsMaster(); + const maxBatchSizeBytes = + isMaster && isMaster.maxBsonObjectSize ? isMaster.maxBsonObjectSize : 1024 * 1024 * 16; + const maxWriteBatchSize = + isMaster && isMaster.maxWriteBatchSize ? isMaster.maxWriteBatchSize : 1000; + + // Get the write concern + let writeConcern = applyWriteConcern( + shallowClone(options), + { collection: collection }, + options + ); + writeConcern = writeConcern.writeConcern; + + // Get the promiseLibrary + const promiseLibrary = options.promiseLibrary || Promise; + + // Final results + const bulkResult = { + ok: 1, + writeErrors: [], + writeConcernErrors: [], + insertedIds: [], + nInserted: 0, + nUpserted: 0, + nMatched: 0, + nModified: 0, + nRemoved: 0, + upserted: [] + }; + + // Internal state + this.s = { + // Final result + bulkResult: bulkResult, + // Current batch state + currentBatch: null, + currentIndex: 0, + // ordered specific + currentBatchSize: 0, + currentBatchSizeBytes: 0, + // unordered specific + currentInsertBatch: null, + currentUpdateBatch: null, + currentRemoveBatch: null, + batches: [], + // Write concern + writeConcern: writeConcern, + // Max batch size options + maxBatchSizeBytes: maxBatchSizeBytes, + maxWriteBatchSize: maxWriteBatchSize, + // Namespace + namespace: namespace, + // BSON + bson: bson, + // Topology + topology: topology, + // Options + options: options, + // Current operation + currentOp: currentOp, + // Executed + executed: executed, + // Collection + collection: collection, + // Promise Library + promiseLibrary: promiseLibrary, + // Fundamental error + err: null, + // check keys + checkKeys: typeof options.checkKeys === 'boolean' ? options.checkKeys : true + }; + + // bypass Validation + if (options.bypassDocumentValidation === true) { + this.s.bypassDocumentValidation = true; + } + } + + /** + * Add a single insert document to the bulk operation + * + * @param {object} document the document to insert + * @throws {MongoError} + * @return {OrderedBulkOperation|UnorderedBulkOperation} + */ + insert(document) { + if (this.s.collection.s.db.options.forceServerObjectId !== true && document._id == null) + document._id = new ObjectID(); + return this.s.options.addToOperationsList(this, INSERT, document); + } + + /** + * Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne + * + * @method + * @param {object} selector The selector for the bulk operation. + * @throws {MongoError} + */ + find(selector) { + if (!selector) { + throw toError('Bulk find operation must specify a selector'); + } + + // Save a current selector + this.s.currentOp = { + selector: selector + }; + + return new FindOperators(this); + } + + /** + * Raw performs the bulk operation + * + * @method + * @param {object} op operation + * @return {OrderedBulkOperation|UnorderedBulkOperation} + */ + raw(op) { + const key = Object.keys(op)[0]; + + // Set up the force server object id + const forceServerObjectId = + typeof this.s.options.forceServerObjectId === 'boolean' + ? this.s.options.forceServerObjectId + : this.s.collection.s.db.options.forceServerObjectId; + + // Update operations + if ( + (op.updateOne && op.updateOne.q) || + (op.updateMany && op.updateMany.q) || + (op.replaceOne && op.replaceOne.q) + ) { + op[key].multi = op.updateOne || op.replaceOne ? false : true; + return this.s.options.addToOperationsList(this, UPDATE, op[key]); + } + + // Crud spec update format + if (op.updateOne || op.updateMany || op.replaceOne) { + const multi = op.updateOne || op.replaceOne ? false : true; + const operation = { + q: op[key].filter, + u: op[key].update || op[key].replacement, + multi: multi + }; + if (this.isOrdered) { + operation.upsert = op[key].upsert ? true : false; + if (op.collation) operation.collation = op.collation; + } else { + if (op[key].upsert) operation.upsert = true; + } + if (op[key].arrayFilters) operation.arrayFilters = op[key].arrayFilters; + return this.s.options.addToOperationsList(this, UPDATE, operation); + } + + // Remove operations + if ( + op.removeOne || + op.removeMany || + (op.deleteOne && op.deleteOne.q) || + (op.deleteMany && op.deleteMany.q) + ) { + op[key].limit = op.removeOne ? 1 : 0; + return this.s.options.addToOperationsList(this, REMOVE, op[key]); + } + + // Crud spec delete operations, less efficient + if (op.deleteOne || op.deleteMany) { + const limit = op.deleteOne ? 1 : 0; + const operation = { q: op[key].filter, limit: limit }; + if (this.isOrdered) { + if (op.collation) operation.collation = op.collation; + } + return this.s.options.addToOperationsList(this, REMOVE, operation); + } + + // Insert operations + if (op.insertOne && op.insertOne.document == null) { + if (forceServerObjectId !== true && op.insertOne._id == null) + op.insertOne._id = new ObjectID(); + return this.s.options.addToOperationsList(this, INSERT, op.insertOne); + } else if (op.insertOne && op.insertOne.document) { + if (forceServerObjectId !== true && op.insertOne.document._id == null) + op.insertOne.document._id = new ObjectID(); + return this.s.options.addToOperationsList(this, INSERT, op.insertOne.document); + } + + if (op.insertMany) { + for (let i = 0; i < op.insertMany.length; i++) { + if (forceServerObjectId !== true && op.insertMany[i]._id == null) + op.insertMany[i]._id = new ObjectID(); + this.s.options.addToOperationsList(this, INSERT, op.insertMany[i]); + } + + return; + } + + // No valid type of operation + throw toError( + 'bulkWrite only supports insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, deleteOne, deleteMany' + ); + } + + /** + * Execute next write command in a chain + * + * @method + * @param {class} bulk either OrderedBulkOperation or UnorderdBulkOperation + * @param {object} writeConcern + * @param {object} options + * @param {function} callback + */ + bulkExecute(_writeConcern, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + if (this.s.executed) { + const executedError = toError('batch cannot be re-executed'); + return typeof callback === 'function' + ? callback(executedError, null) + : this.s.promiseLibrary.reject(executedError); + } + + if (typeof _writeConcern === 'function') { + callback = _writeConcern; + } else if (_writeConcern && typeof _writeConcern === 'object') { + this.s.writeConcern = _writeConcern; + } + + // If we have current batch + if (this.isOrdered) { + if (this.s.currentBatch) this.s.batches.push(this.s.currentBatch); + } else { + if (this.s.currentInsertBatch) this.s.batches.push(this.s.currentInsertBatch); + if (this.s.currentUpdateBatch) this.s.batches.push(this.s.currentUpdateBatch); + if (this.s.currentRemoveBatch) this.s.batches.push(this.s.currentRemoveBatch); + } + // If we have no operations in the bulk raise an error + if (this.s.batches.length === 0) { + const emptyBatchError = toError('Invalid Operation, no operations specified'); + return typeof callback === 'function' + ? callback(emptyBatchError, null) + : this.s.promiseLibrary.reject(emptyBatchError); + } + return { options, callback }; + } + + /** + * Handles final options before executing command + * + * @param {object} config + * @param {object} config.options + * @param {number} config.batch + * @param {function} config.resultHandler + * @param {function} callback + */ + finalOptionsHandler(config, callback) { + const finalOptions = Object.assign({ ordered: this.isOrdered }, config.options); + if (this.s.writeConcern != null) { + finalOptions.writeConcern = this.s.writeConcern; + } + + if (finalOptions.bypassDocumentValidation !== true) { + delete finalOptions.bypassDocumentValidation; + } + + // Set an operationIf if provided + if (this.operationId) { + config.resultHandler.operationId = this.operationId; + } + + // Serialize functions + if (this.s.options.serializeFunctions) { + finalOptions.serializeFunctions = true; + } + + // Ignore undefined + if (this.s.options.ignoreUndefined) { + finalOptions.ignoreUndefined = true; + } + + // Is the bypassDocumentValidation options specific + if (this.s.bypassDocumentValidation === true) { + finalOptions.bypassDocumentValidation = true; + } + + // Is the checkKeys option disabled + if (this.s.checkKeys === false) { + finalOptions.checkKeys = false; + } + + if (finalOptions.retryWrites) { + if (config.batch.batchType === UPDATE) { + finalOptions.retryWrites = + finalOptions.retryWrites && !config.batch.operations.some(op => op.multi); + } + + if (config.batch.batchType === REMOVE) { + finalOptions.retryWrites = + finalOptions.retryWrites && !config.batch.operations.some(op => op.limit === 0); + } + } + + try { + if (config.batch.batchType === INSERT) { + this.s.topology.insert( + this.s.collection.namespace, + config.batch.operations, + finalOptions, + config.resultHandler + ); + } else if (config.batch.batchType === UPDATE) { + this.s.topology.update( + this.s.collection.namespace, + config.batch.operations, + finalOptions, + config.resultHandler + ); + } else if (config.batch.batchType === REMOVE) { + this.s.topology.remove( + this.s.collection.namespace, + config.batch.operations, + finalOptions, + config.resultHandler + ); + } + } catch (err) { + // Force top level error + err.ok = 0; + // Merge top level error and return + handleCallback( + callback, + null, + mergeBatchResults(false, config.batch, this.s.bulkResult, err, null) + ); + } + } + + /** + * Handles the write error before executing commands + * + * @param {function} callback + * @param {BulkWriteResult} writeResult + * @param {class} self either OrderedBulkOperation or UnorderdBulkOperation + */ + handleWriteError(callback, writeResult) { + if (this.s.bulkResult.writeErrors.length > 0) { + if (this.s.bulkResult.writeErrors.length === 1) { + handleCallback( + callback, + new BulkWriteError(toError(this.s.bulkResult.writeErrors[0]), writeResult), + null + ); + return true; + } + + handleCallback( + callback, + new BulkWriteError( + toError({ + message: 'write operation failed', + code: this.s.bulkResult.writeErrors[0].code, + writeErrors: this.s.bulkResult.writeErrors + }), + writeResult + ), + null + ); + return true; + } else if (writeResult.getWriteConcernError()) { + handleCallback( + callback, + new BulkWriteError(toError(writeResult.getWriteConcernError()), writeResult), + null + ); + return true; + } + } } +Object.defineProperty(BulkOperationBase.prototype, 'length', { + enumerable: true, + get: function() { + return this.s.currentIndex; + } +}); + // Exports symbols -exports.BulkWriteResult = BulkWriteResult; -exports.WriteError = WriteError; -exports.Batch = Batch; -exports.LegacyOp = LegacyOp; -exports.mergeBatchResults = mergeBatchResults; -exports.cloneOptions = cloneOptions; -exports.writeConcern = writeConcern; -exports.INVALID_BSON_ERROR = INVALID_BSON_ERROR; -exports.WRITE_CONCERN_ERROR = WRITE_CONCERN_ERROR; -exports.MULTIPLE_ERROR = MULTIPLE_ERROR; -exports.UNKNOWN_ERROR = UNKNOWN_ERROR; -exports.INSERT = INSERT; -exports.UPDATE = UPDATE; -exports.REMOVE = REMOVE; +module.exports = { + Batch, + BulkOperationBase, + BulkWriteError, + BulkWriteResult, + bson, + FindOperators, + handleMongoWriteConcernError, + LegacyOp, + mergeBatchResults, + INVALID_BSON_ERROR: INVALID_BSON_ERROR, + MULTIPLE_ERROR: MULTIPLE_ERROR, + UNKNOWN_ERROR: UNKNOWN_ERROR, + WRITE_CONCERN_ERROR: WRITE_CONCERN_ERROR, + INSERT: INSERT, + UPDATE: UPDATE, + REMOVE: REMOVE, + WriteError, + WriteConcernError +}; diff --git a/node_modules/mongodb/lib/bulk/ordered.js b/node_modules/mongodb/lib/bulk/ordered.js index e1ae3d7..95722b3 100644 --- a/node_modules/mongodb/lib/bulk/ordered.js +++ b/node_modules/mongodb/lib/bulk/ordered.js @@ -1,202 +1,81 @@ -"use strict"; - -var common = require('./common') - , utils = require('../utils') - , toError = require('../utils').toError - , handleCallback = require('../utils').handleCallback - , shallowClone = utils.shallowClone - , BulkWriteResult = common.BulkWriteResult - , ObjectID = require('mongodb-core').BSON.ObjectID - , Define = require('../metadata') - , BSON = require('mongodb-core').BSON - , Batch = common.Batch - , mergeBatchResults = common.mergeBatchResults; - -var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, - BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, - BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]); - -/** - * Create a FindOperatorsOrdered instance (INTERNAL TYPE, do not instantiate directly) - * @class - * @return {FindOperatorsOrdered} a FindOperatorsOrdered instance. - */ -var FindOperatorsOrdered = function(self) { - this.s = self.s; -} - -/** - * Add a single update document to the bulk operation - * - * @method - * @param {object} doc update operations - * @throws {MongoError} - * @return {OrderedBulkOperation} - */ -FindOperatorsOrdered.prototype.update = function(updateDocument) { - // Perform upsert - var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; - - // Establish the update command - var document = { - q: this.s.currentOp.selector - , u: updateDocument - , multi: true - , upsert: upsert - } - - // Clear out current Op - this.s.currentOp = null; - // Add the update document to the list - return addToOperationsList(this, common.UPDATE, document); -} - -/** - * Add a single update one document to the bulk operation - * - * @method - * @param {object} doc update operations - * @throws {MongoError} - * @return {OrderedBulkOperation} - */ -FindOperatorsOrdered.prototype.updateOne = function(updateDocument) { - // Perform upsert - var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; - - // Establish the update command - var document = { - q: this.s.currentOp.selector - , u: updateDocument - , multi: false - , upsert: upsert - } - - // Clear out current Op - this.s.currentOp = null; - // Add the update document to the list - return addToOperationsList(this, common.UPDATE, document); -} - -/** - * Add a replace one operation to the bulk operation - * - * @method - * @param {object} doc the new document to replace the existing one with - * @throws {MongoError} - * @return {OrderedBulkOperation} - */ -FindOperatorsOrdered.prototype.replaceOne = function(updateDocument) { - this.updateOne(updateDocument); -} - -/** - * Upsert modifier for update bulk operation - * - * @method - * @throws {MongoError} - * @return {FindOperatorsOrdered} - */ -FindOperatorsOrdered.prototype.upsert = function() { - this.s.currentOp.upsert = true; - return this; -} - -/** - * Add a remove one operation to the bulk operation - * - * @method - * @throws {MongoError} - * @return {OrderedBulkOperation} - */ -FindOperatorsOrdered.prototype.deleteOne = function() { - // Establish the update command - var document = { - q: this.s.currentOp.selector - , limit: 1 - } - - // Clear out current Op - this.s.currentOp = null; - // Add the remove document to the list - return addToOperationsList(this, common.REMOVE, document); -} - -// Backward compatibility -FindOperatorsOrdered.prototype.removeOne = FindOperatorsOrdered.prototype.deleteOne; +'use strict'; + +const common = require('./common'); +const BulkOperationBase = common.BulkOperationBase; +const utils = require('../utils'); +const toError = utils.toError; +const handleCallback = utils.handleCallback; +const BulkWriteResult = common.BulkWriteResult; +const Batch = common.Batch; +const mergeBatchResults = common.mergeBatchResults; +const executeOperation = utils.executeOperation; +const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError; +const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError; +const bson = common.bson; /** - * Add a remove operation to the bulk operation + * Add to internal list of Operations * - * @method - * @throws {MongoError} + * @param {OrderedBulkOperation} bulkOperation + * @param {number} docType number indicating the document type + * @param {object} document * @return {OrderedBulkOperation} */ -FindOperatorsOrdered.prototype.delete = function() { - // Establish the update command - var document = { - q: this.s.currentOp.selector - , limit: 0 - } - - // Clear out current Op - this.s.currentOp = null; - // Add the remove document to the list - return addToOperationsList(this, common.REMOVE, document); -} - -// Backward compatibility -FindOperatorsOrdered.prototype.remove = FindOperatorsOrdered.prototype.delete; - -// Add to internal list of documents -var addToOperationsList = function(_self, docType, document) { +function addToOperationsList(bulkOperation, docType, document) { // Get the bsonSize - var bsonSize = bson.calculateObjectSize(document, { - checkKeys: false, - }); + const bsonSize = bson.calculateObjectSize(document, { + checkKeys: false + }); // Throw error if the doc is bigger than the max BSON size - if(bsonSize >= _self.s.maxBatchSizeBytes) { - throw toError("document is larger than the maximum size " + _self.s.maxBatchSizeBytes); - } + if (bsonSize >= bulkOperation.s.maxBatchSizeBytes) + throw toError('document is larger than the maximum size ' + bulkOperation.s.maxBatchSizeBytes); // Create a new batch object if we don't have a current one - if(_self.s.currentBatch == null) _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + if (bulkOperation.s.currentBatch == null) + bulkOperation.s.currentBatch = new Batch(docType, bulkOperation.s.currentIndex); // Check if we need to create a new batch - if(((_self.s.currentBatchSize + 1) >= _self.s.maxWriteBatchSize) - || ((_self.s.currentBatchSizeBytes + _self.s.currentBatchSizeBytes) >= _self.s.maxBatchSizeBytes) - || (_self.s.currentBatch.batchType != docType)) { + if ( + bulkOperation.s.currentBatchSize + 1 >= bulkOperation.s.maxWriteBatchSize || + bulkOperation.s.currentBatchSizeBytes + bulkOperation.s.currentBatchSizeBytes >= + bulkOperation.s.maxBatchSizeBytes || + bulkOperation.s.currentBatch.batchType !== docType + ) { // Save the batch to the execution stack - _self.s.batches.push(_self.s.currentBatch); + bulkOperation.s.batches.push(bulkOperation.s.currentBatch); // Create a new batch - _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + bulkOperation.s.currentBatch = new Batch(docType, bulkOperation.s.currentIndex); // Reset the current size trackers - _self.s.currentBatchSize = 0; - _self.s.currentBatchSizeBytes = 0; + bulkOperation.s.currentBatchSize = 0; + bulkOperation.s.currentBatchSizeBytes = 0; } else { // Update current batch size - _self.s.currentBatchSize = _self.s.currentBatchSize + 1; - _self.s.currentBatchSizeBytes = _self.s.currentBatchSizeBytes + bsonSize; + bulkOperation.s.currentBatchSize = bulkOperation.s.currentBatchSize + 1; + bulkOperation.s.currentBatchSizeBytes = bulkOperation.s.currentBatchSizeBytes + bsonSize; } - if(docType == common.INSERT) { - _self.s.bulkResult.insertedIds.push({index: _self.s.currentIndex, _id: document._id}); + if (docType === common.INSERT) { + bulkOperation.s.bulkResult.insertedIds.push({ + index: bulkOperation.s.currentIndex, + _id: document._id + }); } // We have an array of documents - if(Array.isArray(document)) { - throw toError("operation passed in cannot be an Array"); + if (Array.isArray(document)) { + throw toError('operation passed in cannot be an Array'); } else { - _self.s.currentBatch.originalIndexes.push(_self.s.currentIndex); - _self.s.currentBatch.operations.push(document) - _self.s.currentBatchSizeBytes = _self.s.currentBatchSizeBytes + bsonSize; - _self.s.currentIndex = _self.s.currentIndex + 1; + bulkOperation.s.currentBatch.originalIndexes.push(bulkOperation.s.currentIndex); + bulkOperation.s.currentBatch.operations.push(document); + bulkOperation.s.currentBatchSizeBytes = bulkOperation.s.currentBatchSizeBytes + bsonSize; + bulkOperation.s.currentIndex = bulkOperation.s.currentIndex + 1; } - // Return self - return _self; + // Return bulkOperation + return bulkOperation; } /** @@ -205,333 +84,93 @@ var addToOperationsList = function(_self, docType, document) { * @property {number} length Get the number of operations in the bulk. * @return {OrderedBulkOperation} a OrderedBulkOperation instance. */ -function OrderedBulkOperation(topology, collection, options) { - options = options == null ? {} : options; - // TODO Bring from driver information in isMaster - var executed = false; - - // Current item - var currentOp = null; - - // Handle to the bson serializer, used to calculate running sizes - var bson = topology.bson; - - // Namespace for the operation - var namespace = collection.collectionName; - - // Set max byte size - var maxBatchSizeBytes = topology.isMasterDoc && topology.isMasterDoc.maxBsonObjectSize - ? topology.isMasterDoc.maxBsonObjectSize : (1024*1025*16); - var maxWriteBatchSize = topology.isMasterDoc && topology.isMasterDoc.maxWriteBatchSize - ? topology.isMasterDoc.maxWriteBatchSize : 1000; - - // Get the write concern - var writeConcern = common.writeConcern(shallowClone(options), collection, options); - - // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // Final results - var bulkResult = { - ok: 1 - , writeErrors: [] - , writeConcernErrors: [] - , insertedIds: [] - , nInserted: 0 - , nUpserted: 0 - , nMatched: 0 - , nModified: 0 - , nRemoved: 0 - , upserted: [] - }; - - // Internal state - this.s = { - // Final result - bulkResult: bulkResult - // Current batch state - , currentBatch: null - , currentIndex: 0 - , currentBatchSize: 0 - , currentBatchSizeBytes: 0 - , batches: [] - // Write concern - , writeConcern: writeConcern - // Max batch size options - , maxBatchSizeBytes: maxBatchSizeBytes - , maxWriteBatchSize: maxWriteBatchSize - // Namespace - , namespace: namespace - // BSON - , bson: bson - // Topology - , topology: topology - // Options - , options: options - // Current operation - , currentOp: currentOp - // Executed - , executed: executed - // Collection - , collection: collection - // Promise Library - , promiseLibrary: promiseLibrary - // Fundamental error - , err: null - // Bypass validation - , bypassDocumentValidation: typeof options.bypassDocumentValidation == 'boolean' ? options.bypassDocumentValidation : false - } -} -var define = OrderedBulkOperation.define = new Define('OrderedBulkOperation', OrderedBulkOperation, false); - -OrderedBulkOperation.prototype.raw = function(op) { - var key = Object.keys(op)[0]; - - // Set up the force server object id - var forceServerObjectId = typeof this.s.options.forceServerObjectId == 'boolean' - ? this.s.options.forceServerObjectId : this.s.collection.s.db.options.forceServerObjectId; - - // Update operations - if((op.updateOne && op.updateOne.q) - || (op.updateMany && op.updateMany.q) - || (op.replaceOne && op.replaceOne.q)) { - op[key].multi = op.updateOne || op.replaceOne ? false : true; - return addToOperationsList(this, common.UPDATE, op[key]); - } - - // Crud spec update format - if(op.updateOne || op.updateMany || op.replaceOne) { - var multi = op.updateOne || op.replaceOne ? false : true; - var operation = {q: op[key].filter, u: op[key].update || op[key].replacement, multi: multi} - operation.upsert = op[key].upsert ? true: false; - if(op.collation) operation.collation = op.collation; - return addToOperationsList(this, common.UPDATE, operation); - } - - // Remove operations - if(op.removeOne || op.removeMany || (op.deleteOne && op.deleteOne.q) || op.deleteMany && op.deleteMany.q) { - op[key].limit = op.removeOne ? 1 : 0; - return addToOperationsList(this, common.REMOVE, op[key]); - } - - // Crud spec delete operations, less efficient - if(op.deleteOne || op.deleteMany) { - var limit = op.deleteOne ? 1 : 0; - operation = {q: op[key].filter, limit: limit} - if(op.collation) operation.collation = op.collation; - return addToOperationsList(this, common.REMOVE, operation); - } - - // Insert operations - if(op.insertOne && op.insertOne.document == null) { - if(forceServerObjectId !== true && op.insertOne._id == null) op.insertOne._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, op.insertOne); - } else if(op.insertOne && op.insertOne.document) { - if(forceServerObjectId !== true && op.insertOne.document._id == null) op.insertOne.document._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, op.insertOne.document); - } - - if(op.insertMany) { - for(var i = 0; i < op.insertMany.length; i++) { - if(forceServerObjectId !== true && op.insertMany[i]._id == null) op.insertMany[i]._id = new ObjectID(); - addToOperationsList(this, common.INSERT, op.insertMany[i]); - } - - return; +class OrderedBulkOperation extends BulkOperationBase { + constructor(topology, collection, options) { + options = options || {}; + options = Object.assign(options, { addToOperationsList }); + + super(topology, collection, options, true); + } + + /** + * The callback format for results + * @callback OrderedBulkOperation~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {BulkWriteResult} result The bulk write result. + */ + + /** + * Execute the ordered bulk operation + * + * @method + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {OrderedBulkOperation~resultCallback} [callback] The result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + execute(_writeConcern, options, callback) { + const ret = this.bulkExecute(_writeConcern, options, callback); + options = ret.options; + callback = ret.callback; + + return executeOperation(this.s.topology, executeCommands, [this, options, callback]); } - - // No valid type of operation - throw toError("bulkWrite only supports insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, deleteOne, deleteMany"); } /** - * Add a single insert document to the bulk operation + * Execute next write command in a chain * - * @param {object} doc the document to insert - * @throws {MongoError} - * @return {OrderedBulkOperation} - */ -OrderedBulkOperation.prototype.insert = function(document) { - if(this.s.collection.s.db.options.forceServerObjectId !== true && document._id == null) document._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, document); -} - -/** - * Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne - * - * @method - * @param {object} selector The selector for the bulk operation. - * @throws {MongoError} - * @return {FindOperatorsOrdered} + * @param {OrderedBulkOperation} bulkOperation + * @param {object} options + * @param {function} callback */ -OrderedBulkOperation.prototype.find = function(selector) { - if (!selector) { - throw toError("Bulk find operation must specify a selector"); - } - - // Save a current selector - this.s.currentOp = { - selector: selector - } - - return new FindOperatorsOrdered(this); -} - -Object.defineProperty(OrderedBulkOperation.prototype, 'length', { - enumerable: true, - get: function() { - return this.s.currentIndex; - } -}); - -// -// Execute next write command in a chain -var executeCommands = function(self, callback) { - if(self.s.batches.length == 0) { - return handleCallback(callback, null, new BulkWriteResult(self.s.bulkResult)); +function executeCommands(bulkOperation, options, callback) { + if (bulkOperation.s.batches.length === 0) { + return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult)); } // Ordered execution of the command - var batch = self.s.batches.shift(); + const batch = bulkOperation.s.batches.shift(); - var resultHandler = function(err, result) { - // Error is a driver related error not a bulk op error, terminate - if(err && err.driver || err && err.message) { - return handleCallback(callback, err); - } - - // If we have and error - if(err) err.ok = 0; - // Merge the results together - var mergeResult = mergeBatchResults(true, batch, self.s.bulkResult, err, result); - if(mergeResult != null) { - return handleCallback(callback, null, new BulkWriteResult(self.s.bulkResult)); + function resultHandler(err, result) { + // Error is a driver related error not a bulk op error, terminate + if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) { + return handleCallback(callback, err); } - // If we are ordered and have errors and they are - // not all replication errors terminate the operation - if(self.s.bulkResult.writeErrors.length > 0) { - return handleCallback(callback, toError(self.s.bulkResult.writeErrors[0]), new BulkWriteResult(self.s.bulkResult)); + // If we have and error + if (err) err.ok = 0; + if (err instanceof MongoWriteConcernError) { + return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, true, err, callback); } - // Execute the next command in line - executeCommands(self, callback); - } - - var finalOptions = {ordered: true} - if(self.s.writeConcern != null) { - finalOptions.writeConcern = self.s.writeConcern; - } - - // Set an operationIf if provided - if(self.operationId) { - resultHandler.operationId = self.operationId; - } - - // Serialize functions - if(self.s.options.serializeFunctions) { - finalOptions.serializeFunctions = true - } - - // Serialize functions - if(self.s.options.ignoreUndefined) { - finalOptions.ignoreUndefined = true - } - - // Is the bypassDocumentValidation options specific - if(self.s.bypassDocumentValidation == true) { - finalOptions.bypassDocumentValidation = true; - } - - try { - if(batch.batchType == common.INSERT) { - self.s.topology.insert(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); - } else if(batch.batchType == common.UPDATE) { - self.s.topology.update(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); - } else if(batch.batchType == common.REMOVE) { - self.s.topology.remove(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + // Merge the results together + const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult); + const mergeResult = mergeBatchResults(true, batch, bulkOperation.s.bulkResult, err, result); + if (mergeResult != null) { + return handleCallback(callback, null, writeResult); } - } catch(err) { - // Force top level error - err.ok = 0; - // Merge top level error and return - handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, null)); - } -} -/** - * The callback format for results - * @callback OrderedBulkOperation~resultCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {BulkWriteResult} result The bulk write result. - */ - -/** - * Execute the ordered bulk operation - * - * @method - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. - * @param {boolean} [options.j=false] Specify a journal write concern. - * @param {boolean} [options.fsync=false] Specify a file sync write concern. - * @param {OrderedBulkOperation~resultCallback} [callback] The result callback - * @throws {MongoError} - * @return {Promise} returns Promise if no callback passed - */ -OrderedBulkOperation.prototype.execute = function(_writeConcern, callback) { - var self = this; - if (this.s.executed) { - var executedError = toError('batch cannot be re-executed'); - return (typeof callback === 'function') ? - callback(executedError, null) : this.s.promiseLibrary.reject(executedError); - } - - if (typeof _writeConcern === 'function') { - callback = _writeConcern; - } else if (_writeConcern && typeof _writeConcern === 'object') { - this.s.writeConcern = _writeConcern; - } - - // If we have current batch - if (this.s.currentBatch) this.s.batches.push(this.s.currentBatch) - - // If we have no operations in the bulk raise an error - if (this.s.batches.length == 0) { - var emptyBatchError = toError('Invalid Operation, no operations specified'); - return (typeof callback === 'function') ? - callback(emptyBatchError, null) : this.s.promiseLibrary.reject(emptyBatchError); - } + if (bulkOperation.handleWriteError(callback, writeResult)) return; - // Execute using callback - if (typeof callback === 'function') { - return executeCommands(this, callback); + // Execute the next command in line + executeCommands(bulkOperation, options, callback); } - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - executeCommands(self, function(err, r) { - if (err) return reject(err); - resolve(r); - }); - }); + bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback); } -define.classMethod('execute', {callback: true, promise:false}); - /** * Returns an unordered batch object * @ignore */ -var initializeOrderedBulkOp = function(topology, collection, options) { - return new OrderedBulkOperation(topology, collection, options); +function initializeOrderedBulkOp(topology, collection, options) { + return new OrderedBulkOperation(topology, collection, options); } initializeOrderedBulkOp.OrderedBulkOperation = OrderedBulkOperation; diff --git a/node_modules/mongodb/lib/bulk/unordered.js b/node_modules/mongodb/lib/bulk/unordered.js index f6a801e..0ff7473 100644 --- a/node_modules/mongodb/lib/bulk/unordered.js +++ b/node_modules/mongodb/lib/bulk/unordered.js @@ -1,207 +1,90 @@ -"use strict"; - -var common = require('./common') - , utils = require('../utils') - , toError = require('../utils').toError - , handleCallback = require('../utils').handleCallback - , shallowClone = utils.shallowClone - , BulkWriteResult = common.BulkWriteResult - , ObjectID = require('mongodb-core').BSON.ObjectID - , BSON = require('mongodb-core').BSON - , Define = require('../metadata') - , Batch = common.Batch - , mergeBatchResults = common.mergeBatchResults; - -var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, - BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, - BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]); - -/** - * Create a FindOperatorsUnordered instance (INTERNAL TYPE, do not instantiate directly) - * @class - * @property {number} length Get the number of operations in the bulk. - * @return {FindOperatorsUnordered} a FindOperatorsUnordered instance. - */ -var FindOperatorsUnordered = function(self) { - this.s = self.s; -} - -/** - * Add a single update document to the bulk operation - * - * @method - * @param {object} doc update operations - * @throws {MongoError} - * @return {UnorderedBulkOperation} - */ -FindOperatorsUnordered.prototype.update = function(updateDocument) { - // Perform upsert - var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; - - // Establish the update command - var document = { - q: this.s.currentOp.selector - , u: updateDocument - , multi: true - , upsert: upsert - } - - // Clear out current Op - this.s.currentOp = null; - // Add the update document to the list - return addToOperationsList(this, common.UPDATE, document); -} - -/** - * Add a single update one document to the bulk operation - * - * @method - * @param {object} doc update operations - * @throws {MongoError} - * @return {UnorderedBulkOperation} - */ -FindOperatorsUnordered.prototype.updateOne = function(updateDocument) { - // Perform upsert - var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; - - // Establish the update command - var document = { - q: this.s.currentOp.selector - , u: updateDocument - , multi: false - , upsert: upsert - } - - // Clear out current Op - this.s.currentOp = null; - // Add the update document to the list - return addToOperationsList(this, common.UPDATE, document); -} - -/** - * Add a replace one operation to the bulk operation - * - * @method - * @param {object} doc the new document to replace the existing one with - * @throws {MongoError} - * @return {UnorderedBulkOperation} - */ -FindOperatorsUnordered.prototype.replaceOne = function(updateDocument) { - this.updateOne(updateDocument); -} - -/** - * Upsert modifier for update bulk operation - * - * @method - * @throws {MongoError} - * @return {FindOperatorsUnordered} - */ -FindOperatorsUnordered.prototype.upsert = function() { - this.s.currentOp.upsert = true; - return this; -} - -/** - * Add a remove one operation to the bulk operation - * - * @method - * @throws {MongoError} - * @return {UnorderedBulkOperation} - */ -FindOperatorsUnordered.prototype.removeOne = function() { - // Establish the update command - var document = { - q: this.s.currentOp.selector - , limit: 1 - } - - // Clear out current Op - this.s.currentOp = null; - // Add the remove document to the list - return addToOperationsList(this, common.REMOVE, document); -} +'use strict'; + +const common = require('./common'); +const BulkOperationBase = common.BulkOperationBase; +const utils = require('../utils'); +const toError = utils.toError; +const handleCallback = utils.handleCallback; +const BulkWriteResult = common.BulkWriteResult; +const Batch = common.Batch; +const mergeBatchResults = common.mergeBatchResults; +const executeOperation = utils.executeOperation; +const MongoWriteConcernError = require('mongodb-core').MongoWriteConcernError; +const handleMongoWriteConcernError = require('./common').handleMongoWriteConcernError; +const bson = common.bson; /** - * Add a remove operation to the bulk operation + * Add to internal list of Operations * - * @method - * @throws {MongoError} + * @param {UnorderedBulkOperation} bulkOperation + * @param {number} docType number indicating the document type + * @param {object} document * @return {UnorderedBulkOperation} */ -FindOperatorsUnordered.prototype.remove = function() { - // Establish the update command - var document = { - q: this.s.currentOp.selector - , limit: 0 - } - - // Clear out current Op - this.s.currentOp = null; - // Add the remove document to the list - return addToOperationsList(this, common.REMOVE, document); -} - -// -// Add to the operations list -// -var addToOperationsList = function(_self, docType, document) { +function addToOperationsList(bulkOperation, docType, document) { // Get the bsonSize - var bsonSize = bson.calculateObjectSize(document, { - checkKeys: false, - }); + const bsonSize = bson.calculateObjectSize(document, { + checkKeys: false + }); // Throw error if the doc is bigger than the max BSON size - if(bsonSize >= _self.s.maxBatchSizeBytes) throw toError("document is larger than the maximum size " + _self.s.maxBatchSizeBytes); + if (bsonSize >= bulkOperation.s.maxBatchSizeBytes) + throw toError('document is larger than the maximum size ' + bulkOperation.s.maxBatchSizeBytes); // Holds the current batch - _self.s.currentBatch = null; + bulkOperation.s.currentBatch = null; // Get the right type of batch - if(docType == common.INSERT) { - _self.s.currentBatch = _self.s.currentInsertBatch; - } else if(docType == common.UPDATE) { - _self.s.currentBatch = _self.s.currentUpdateBatch; - } else if(docType == common.REMOVE) { - _self.s.currentBatch = _self.s.currentRemoveBatch; + if (docType === common.INSERT) { + bulkOperation.s.currentBatch = bulkOperation.s.currentInsertBatch; + } else if (docType === common.UPDATE) { + bulkOperation.s.currentBatch = bulkOperation.s.currentUpdateBatch; + } else if (docType === common.REMOVE) { + bulkOperation.s.currentBatch = bulkOperation.s.currentRemoveBatch; } // Create a new batch object if we don't have a current one - if(_self.s.currentBatch == null) _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + if (bulkOperation.s.currentBatch == null) + bulkOperation.s.currentBatch = new Batch(docType, bulkOperation.s.currentIndex); // Check if we need to create a new batch - if(((_self.s.currentBatch.size + 1) >= _self.s.maxWriteBatchSize) - || ((_self.s.currentBatch.sizeBytes + bsonSize) >= _self.s.maxBatchSizeBytes) - || (_self.s.currentBatch.batchType != docType)) { + if ( + bulkOperation.s.currentBatch.size + 1 >= bulkOperation.s.maxWriteBatchSize || + bulkOperation.s.currentBatch.sizeBytes + bsonSize >= bulkOperation.s.maxBatchSizeBytes || + bulkOperation.s.currentBatch.batchType !== docType + ) { // Save the batch to the execution stack - _self.s.batches.push(_self.s.currentBatch); + bulkOperation.s.batches.push(bulkOperation.s.currentBatch); // Create a new batch - _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + bulkOperation.s.currentBatch = new Batch(docType, bulkOperation.s.currentIndex); } // We have an array of documents - if(Array.isArray(document)) { - throw toError("operation passed in cannot be an Array"); + if (Array.isArray(document)) { + throw toError('operation passed in cannot be an Array'); } else { - _self.s.currentBatch.operations.push(document); - _self.s.currentBatch.originalIndexes.push(_self.s.currentIndex); - _self.s.currentIndex = _self.s.currentIndex + 1; + bulkOperation.s.currentBatch.operations.push(document); + bulkOperation.s.currentBatch.originalIndexes.push(bulkOperation.s.currentIndex); + bulkOperation.s.currentIndex = bulkOperation.s.currentIndex + 1; } // Save back the current Batch to the right type - if(docType == common.INSERT) { - _self.s.currentInsertBatch = _self.s.currentBatch; - _self.s.bulkResult.insertedIds.push({index: _self.s.bulkResult.insertedIds.length, _id: document._id}); - } else if(docType == common.UPDATE) { - _self.s.currentUpdateBatch = _self.s.currentBatch; - } else if(docType == common.REMOVE) { - _self.s.currentRemoveBatch = _self.s.currentBatch; + if (docType === common.INSERT) { + bulkOperation.s.currentInsertBatch = bulkOperation.s.currentBatch; + bulkOperation.s.bulkResult.insertedIds.push({ + index: bulkOperation.s.bulkResult.insertedIds.length, + _id: document._id + }); + } else if (docType === common.UPDATE) { + bulkOperation.s.currentUpdateBatch = bulkOperation.s.currentBatch; + } else if (docType === common.REMOVE) { + bulkOperation.s.currentRemoveBatch = bulkOperation.s.currentBatch; } // Update current batch size - _self.s.currentBatch.size = _self.s.currentBatch.size + 1; - _self.s.currentBatch.sizeBytes = _self.s.currentBatch.sizeBytes + bsonSize; + bulkOperation.s.currentBatch.size = bulkOperation.s.currentBatch.size + 1; + bulkOperation.s.currentBatch.sizeBytes = bulkOperation.s.currentBatch.sizeBytes + bsonSize; - // Return self - return _self; + // Return bulkOperation + return bulkOperation; } /** @@ -210,330 +93,108 @@ var addToOperationsList = function(_self, docType, document) { * @property {number} length Get the number of operations in the bulk. * @return {UnorderedBulkOperation} a UnorderedBulkOperation instance. */ -var UnorderedBulkOperation = function(topology, collection, options) { - options = options == null ? {} : options; - - // Get the namespace for the write operations - var namespace = collection.collectionName; - // Used to mark operation as executed - var executed = false; - - // Current item - // var currentBatch = null; - var currentOp = null; - - // Handle to the bson serializer, used to calculate running sizes - var bson = topology.bson; - - // Set max byte size - var maxBatchSizeBytes = topology.isMasterDoc && topology.isMasterDoc.maxBsonObjectSize - ? topology.isMasterDoc.maxBsonObjectSize : (1024*1025*16); - var maxWriteBatchSize = topology.isMasterDoc && topology.isMasterDoc.maxWriteBatchSize - ? topology.isMasterDoc.maxWriteBatchSize : 1000; - - // Get the write concern - var writeConcern = common.writeConcern(shallowClone(options), collection, options); - - // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; +class UnorderedBulkOperation extends BulkOperationBase { + constructor(topology, collection, options) { + options = options || {}; + options = Object.assign(options, { addToOperationsList }); + + super(topology, collection, options, false); + } + + /** + * The callback format for results + * @callback UnorderedBulkOperation~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {BulkWriteResult} result The bulk write result. + */ + + /** + * Execute the ordered bulk operation + * + * @method + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {UnorderedBulkOperation~resultCallback} [callback] The result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + execute(_writeConcern, options, callback) { + const ret = this.bulkExecute(_writeConcern, options, callback); + options = ret.options; + callback = ret.callback; + + return executeOperation(this.s.topology, executeBatches, [this, options, callback]); } - - // Final results - var bulkResult = { - ok: 1 - , writeErrors: [] - , writeConcernErrors: [] - , insertedIds: [] - , nInserted: 0 - , nUpserted: 0 - , nMatched: 0 - , nModified: 0 - , nRemoved: 0 - , upserted: [] - }; - - // Internal state - this.s = { - // Final result - bulkResult: bulkResult - // Current batch state - , currentInsertBatch: null - , currentUpdateBatch: null - , currentRemoveBatch: null - , currentBatch: null - , currentIndex: 0 - , batches: [] - // Write concern - , writeConcern: writeConcern - // Max batch size options - , maxBatchSizeBytes: maxBatchSizeBytes - , maxWriteBatchSize: maxWriteBatchSize - // Namespace - , namespace: namespace - // BSON - , bson: bson - // Topology - , topology: topology - // Options - , options: options - // Current operation - , currentOp: currentOp - // Executed - , executed: executed - // Collection - , collection: collection - // Promise Library - , promiseLibrary: promiseLibrary - // Bypass validation - , bypassDocumentValidation: typeof options.bypassDocumentValidation == 'boolean' ? options.bypassDocumentValidation : false - } -} - -var define = UnorderedBulkOperation.define = new Define('UnorderedBulkOperation', UnorderedBulkOperation, false); - -/** - * Add a single insert document to the bulk operation - * - * @param {object} doc the document to insert - * @throws {MongoError} - * @return {UnorderedBulkOperation} - */ -UnorderedBulkOperation.prototype.insert = function(document) { - if(this.s.collection.s.db.options.forceServerObjectId !== true && document._id == null) document._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, document); } /** - * Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne + * Execute the command * - * @method - * @param {object} selector The selector for the bulk operation. - * @throws {MongoError} - * @return {FindOperatorsUnordered} + * @param {UnorderedBulkOperation} bulkOperation + * @param {object} batch + * @param {object} options + * @param {function} callback */ -UnorderedBulkOperation.prototype.find = function(selector) { - if (!selector) { - throw toError("Bulk find operation must specify a selector"); - } - - // Save a current selector - this.s.currentOp = { - selector: selector - } - - return new FindOperatorsUnordered(this); -} - -Object.defineProperty(UnorderedBulkOperation.prototype, 'length', { - enumerable: true, - get: function() { - return this.s.currentIndex; - } -}); - -UnorderedBulkOperation.prototype.raw = function(op) { - var key = Object.keys(op)[0]; - - // Set up the force server object id - var forceServerObjectId = typeof this.s.options.forceServerObjectId == 'boolean' - ? this.s.options.forceServerObjectId : this.s.collection.s.db.options.forceServerObjectId; - - // Update operations - if((op.updateOne && op.updateOne.q) - || (op.updateMany && op.updateMany.q) - || (op.replaceOne && op.replaceOne.q)) { - op[key].multi = op.updateOne || op.replaceOne ? false : true; - return addToOperationsList(this, common.UPDATE, op[key]); - } - - // Crud spec update format - if(op.updateOne || op.updateMany || op.replaceOne) { - var multi = op.updateOne || op.replaceOne ? false : true; - var operation = {q: op[key].filter, u: op[key].update || op[key].replacement, multi: multi} - if(op[key].upsert) operation.upsert = true; - return addToOperationsList(this, common.UPDATE, operation); - } - - // Remove operations - if(op.removeOne || op.removeMany || (op.deleteOne && op.deleteOne.q) || op.deleteMany && op.deleteMany.q) { - op[key].limit = op.removeOne ? 1 : 0; - return addToOperationsList(this, common.REMOVE, op[key]); - } - - // Crud spec delete operations, less efficient - if(op.deleteOne || op.deleteMany) { - var limit = op.deleteOne ? 1 : 0; - operation = {q: op[key].filter, limit: limit} - return addToOperationsList(this, common.REMOVE, operation); - } - - // Insert operations - if(op.insertOne && op.insertOne.document == null) { - if(forceServerObjectId !== true && op.insertOne._id == null) op.insertOne._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, op.insertOne); - } else if(op.insertOne && op.insertOne.document) { - if(forceServerObjectId !== true && op.insertOne.document._id == null) op.insertOne.document._id = new ObjectID(); - return addToOperationsList(this, common.INSERT, op.insertOne.document); - } - - if(op.insertMany) { - for(var i = 0; i < op.insertMany.length; i++) { - if(forceServerObjectId !== true && op.insertMany[i]._id == null) op.insertMany[i]._id = new ObjectID(); - addToOperationsList(this, common.INSERT, op.insertMany[i]); +function executeBatch(bulkOperation, batch, options, callback) { + function resultHandler(err, result) { + // Error is a driver related error not a bulk op error, terminate + if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) { + return handleCallback(callback, err); } - return; - } - - // No valid type of operation - throw toError("bulkWrite only supports insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, deleteOne, deleteMany"); -} - -// -// Execute the command -var executeBatch = function(self, batch, callback) { - var finalOptions = {ordered: false} - if(self.s.writeConcern != null) { - finalOptions.writeConcern = self.s.writeConcern; - } - - var resultHandler = function(err, result) { - // Error is a driver related error not a bulk op error, terminate - if(err && err.driver || err && err.message) { - return handleCallback(callback, err); - } - // If we have and error - if(err) err.ok = 0; - handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, result)); - } - - // Set an operationIf if provided - if(self.operationId) { - resultHandler.operationId = self.operationId; - } - - // Serialize functions - if(self.s.options.serializeFunctions) { - finalOptions.serializeFunctions = true - } - - // Is the bypassDocumentValidation options specific - if(self.s.bypassDocumentValidation == true) { - finalOptions.bypassDocumentValidation = true; - } - - try { - if(batch.batchType == common.INSERT) { - self.s.topology.insert(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); - } else if(batch.batchType == common.UPDATE) { - self.s.topology.update(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); - } else if(batch.batchType == common.REMOVE) { - self.s.topology.remove(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + if (err) err.ok = 0; + if (err instanceof MongoWriteConcernError) { + return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, false, err, callback); } - } catch(err) { - // Force top level error - err.ok = 0; - // Merge top level error and return - handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, null)); + handleCallback( + callback, + null, + mergeBatchResults(false, batch, bulkOperation.s.bulkResult, err, result) + ); } -} - -// -// Execute all the commands -var executeBatches = function(self, callback) { - var numberOfCommandsToExecute = self.s.batches.length; - // Execute over all the batches - for(var i = 0; i < self.s.batches.length; i++) { - executeBatch(self, self.s.batches[i], function(err) { - // Driver layer error capture it - if(err) error = err; - // Count down the number of commands left to execute - numberOfCommandsToExecute = numberOfCommandsToExecute - 1; - // Execute - if(numberOfCommandsToExecute == 0) { - // Driver level error - if(error) return handleCallback(callback, error); - // Treat write errors - var error = self.s.bulkResult.writeErrors.length > 0 ? toError(self.s.bulkResult.writeErrors[0]) : null; - handleCallback(callback, error, new BulkWriteResult(self.s.bulkResult)); - } - }); - } + bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback); } /** - * The callback format for results - * @callback UnorderedBulkOperation~resultCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {BulkWriteResult} result The bulk write result. - */ - -/** - * Execute the ordered bulk operation + * Execute all the commands * - * @method - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. - * @param {boolean} [options.j=false] Specify a journal write concern. - * @param {boolean} [options.fsync=false] Specify a file sync write concern. - * @param {UnorderedBulkOperation~resultCallback} [callback] The result callback - * @throws {MongoError} - * @return {Promise} returns Promise if no callback passed + * @param {UnorderedBulkOperation} bulkOperation + * @param {object} options + * @param {function} callback */ -UnorderedBulkOperation.prototype.execute = function(_writeConcern, callback) { - var self = this; - if (this.s.executed) { - var executedError = toError('batch cannot be re-executed'); - return (typeof callback === 'function') ? - callback(executedError, null) : this.s.promiseLibrary.reject(executedError); - } - - if (typeof _writeConcern === 'function') { - callback = _writeConcern; - } else if (_writeConcern && typeof _writeConcern === 'object') { - this.s.writeConcern = _writeConcern; - } - - // If we have current batch - if (this.s.currentInsertBatch) this.s.batches.push(this.s.currentInsertBatch); - if (this.s.currentUpdateBatch) this.s.batches.push(this.s.currentUpdateBatch); - if (this.s.currentRemoveBatch) this.s.batches.push(this.s.currentRemoveBatch); +function executeBatches(bulkOperation, options, callback) { + let numberOfCommandsToExecute = bulkOperation.s.batches.length; + // Execute over all the batches + for (let i = 0; i < bulkOperation.s.batches.length; i++) { + executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) { + // Count down the number of commands left to execute + numberOfCommandsToExecute = numberOfCommandsToExecute - 1; - // If we have no operations in the bulk raise an error - if (this.s.batches.length == 0) { - var emptyBatchError = toError('Invalid Operation, no operations specified'); - return (typeof callback === 'function') ? - callback(emptyBatchError, null) : this.s.promiseLibrary.reject(emptyBatchError); - } + // Execute + if (numberOfCommandsToExecute === 0) { + // Driver level error + if (err) return handleCallback(callback, err); - // Execute using callback - if (typeof callback === 'function') return executeBatches(this, callback); + const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult); + if (bulkOperation.handleWriteError(callback, writeResult)) return; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - executeBatches(self, function(err, r) { - if (err) return reject(err); - resolve(r); + return handleCallback(callback, null, writeResult); + } }); - }); + } } -define.classMethod('execute', {callback: true, promise:false}); - /** * Returns an unordered batch object * @ignore */ -var initializeUnorderedBulkOp = function(topology, collection, options) { - return new UnorderedBulkOperation(topology, collection, options); +function initializeUnorderedBulkOp(topology, collection, options) { + return new UnorderedBulkOperation(topology, collection, options); } initializeUnorderedBulkOp.UnorderedBulkOperation = UnorderedBulkOperation; diff --git a/node_modules/mongodb/lib/change_stream.js b/node_modules/mongodb/lib/change_stream.js new file mode 100644 index 0000000..1d2bbe6 --- /dev/null +++ b/node_modules/mongodb/lib/change_stream.js @@ -0,0 +1,455 @@ +'use strict'; + +const EventEmitter = require('events'); +const isResumableError = require('./error').isResumableError; +const MongoError = require('mongodb-core').MongoError; + +var cursorOptionNames = ['maxAwaitTimeMS', 'collation', 'readPreference']; + +const CHANGE_DOMAIN_TYPES = { + COLLECTION: Symbol('Collection'), + DATABASE: Symbol('Database'), + CLUSTER: Symbol('Cluster') +}; + +/** + * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}. + * @class ChangeStream + * @since 3.0.0 + * @param {(MongoClient|Db|Collection)} changeDomain The domain against which to create the change stream + * @param {Array} pipeline An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents + * @param {object} [options] Optional settings + * @param {string} [options.fullDocument='default'] Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred. + * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a change stream query + * @param {object} [options.resumeAfter] Specifies the logical starting point for the new change stream. This should be the _id field from a previously returned change stream document. + * @param {number} [options.batchSize] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {ReadPreference} [options.readPreference] The read preference. Defaults to the read preference of the database or collection. See {@link https://docs.mongodb.com/manual/reference/read-preference|read preference documentation}. + * @fires ChangeStream#close + * @fires ChangeStream#change + * @fires ChangeStream#end + * @fires ChangeStream#error + * @return {ChangeStream} a ChangeStream instance. + */ + +class ChangeStream extends EventEmitter { + constructor(changeDomain, pipeline, options) { + super(); + const Collection = require('./collection'); + const Db = require('./db'); + const MongoClient = require('./mongo_client'); + + this.pipeline = pipeline || []; + this.options = options || {}; + this.cursorNamespace = undefined; + this.namespace = {}; + + if (changeDomain instanceof Collection) { + this.type = CHANGE_DOMAIN_TYPES.COLLECTION; + this.topology = changeDomain.s.db.serverConfig; + + this.namespace = { + collection: changeDomain.collectionName, + database: changeDomain.s.db.databaseName + }; + + this.cursorNamespace = `${this.namespace.database}.${this.namespace.collection}`; + } else if (changeDomain instanceof Db) { + this.type = CHANGE_DOMAIN_TYPES.DATABASE; + this.namespace = { collection: '', database: changeDomain.databaseName }; + this.cursorNamespace = this.namespace.database; + this.topology = changeDomain.serverConfig; + } else if (changeDomain instanceof MongoClient) { + this.type = CHANGE_DOMAIN_TYPES.CLUSTER; + this.namespace = { collection: '', database: 'admin' }; + this.cursorNamespace = this.namespace.database; + this.topology = changeDomain.topology; + } else { + throw new TypeError( + 'changeDomain provided to ChangeStream constructor is not an instance of Collection, Db, or MongoClient' + ); + } + + this.promiseLibrary = changeDomain.s.promiseLibrary; + if (!this.options.readPreference && changeDomain.s.readPreference) { + this.options.readPreference = changeDomain.s.readPreference; + } + + // We need to get the operationTime as early as possible + const isMaster = this.topology.lastIsMaster(); + if (!isMaster) { + throw new MongoError('Topology does not have an ismaster yet.'); + } + + this.operationTime = isMaster.operationTime; + + // Create contained Change Stream cursor + this.cursor = createChangeStreamCursor(this); + + // Listen for any `change` listeners being added to ChangeStream + this.on('newListener', eventName => { + if (eventName === 'change' && this.cursor && this.listenerCount('change') === 0) { + this.cursor.on('data', change => + processNewChange({ changeStream: this, change, eventEmitter: true }) + ); + } + }); + + // Listen for all `change` listeners being removed from ChangeStream + this.on('removeListener', eventName => { + if (eventName === 'change' && this.listenerCount('change') === 0 && this.cursor) { + this.cursor.removeAllListeners('data'); + } + }); + } + + /** + * Check if there is any document still available in the Change Stream + * @function ChangeStream.prototype.hasNext + * @param {ChangeStream~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + hasNext(callback) { + return this.cursor.hasNext(callback); + } + + /** + * Get the next available document from the Change Stream, returns null if no more documents are available. + * @function ChangeStream.prototype.next + * @param {ChangeStream~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + next(callback) { + var self = this; + if (this.isClosed()) { + if (callback) return callback(new Error('Change Stream is not open.'), null); + return self.promiseLibrary.reject(new Error('Change Stream is not open.')); + } + + return this.cursor + .next() + .then(change => processNewChange({ changeStream: self, change, callback })) + .catch(error => processNewChange({ changeStream: self, error, callback })); + } + + /** + * Is the cursor closed + * @method ChangeStream.prototype.isClosed + * @return {boolean} + */ + isClosed() { + if (this.cursor) { + return this.cursor.isClosed(); + } + return true; + } + + /** + * Close the Change Stream + * @method ChangeStream.prototype.close + * @param {ChangeStream~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ + close(callback) { + if (!this.cursor) { + if (callback) return callback(); + return this.promiseLibrary.resolve(); + } + + // Tidy up the existing cursor + var cursor = this.cursor; + delete this.cursor; + return cursor.close(callback); + } + + /** + * This method pulls all the data out of a readable stream, and writes it to the supplied destination, automatically managing the flow so that the destination is not overwhelmed by a fast readable stream. + * @method + * @param {Writable} destination The destination for writing data + * @param {object} [options] {@link https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options|Pipe options} + * @return {null} + */ + pipe(destination, options) { + if (!this.pipeDestinations) { + this.pipeDestinations = []; + } + this.pipeDestinations.push(destination); + return this.cursor.pipe(destination, options); + } + + /** + * This method will remove the hooks set up for a previous pipe() call. + * @param {Writable} [destination] The destination for writing data + * @return {null} + */ + unpipe(destination) { + if (this.pipeDestinations && this.pipeDestinations.indexOf(destination) > -1) { + this.pipeDestinations.splice(this.pipeDestinations.indexOf(destination), 1); + } + return this.cursor.unpipe(destination); + } + + /** + * Return a modified Readable stream including a possible transform method. + * @method + * @param {object} [options] Optional settings. + * @param {function} [options.transform] A transformation method applied to each document emitted by the stream. + * @return {Cursor} + */ + stream(options) { + this.streamOptions = options; + return this.cursor.stream(options); + } + + /** + * This method will cause a stream in flowing mode to stop emitting data events. Any data that becomes available will remain in the internal buffer. + * @return {null} + */ + pause() { + return this.cursor.pause(); + } + + /** + * This method will cause the readable stream to resume emitting data events. + * @return {null} + */ + resume() { + return this.cursor.resume(); + } +} + +// Create a new change stream cursor based on self's configuration +var createChangeStreamCursor = function(self) { + if (self.resumeToken) { + self.options.resumeAfter = self.resumeToken; + } + + var changeStreamCursor = buildChangeStreamAggregationCommand(self); + + /** + * Fired for each new matching change in the specified namespace. Attaching a `change` + * event listener to a Change Stream will switch the stream into flowing mode. Data will + * then be passed as soon as it is available. + * + * @event ChangeStream#change + * @type {object} + */ + if (self.listenerCount('change') > 0) { + changeStreamCursor.on('data', function(change) { + processNewChange({ changeStream: self, change, eventEmitter: true }); + }); + } + + /** + * Change stream close event + * + * @event ChangeStream#close + * @type {null} + */ + changeStreamCursor.on('close', function() { + self.emit('close'); + }); + + /** + * Change stream end event + * + * @event ChangeStream#end + * @type {null} + */ + changeStreamCursor.on('end', function() { + self.emit('end'); + }); + + /** + * Fired when the stream encounters an error. + * + * @event ChangeStream#error + * @type {Error} + */ + changeStreamCursor.on('error', function(error) { + processNewChange({ changeStream: self, error, eventEmitter: true }); + }); + + if (self.pipeDestinations) { + const cursorStream = changeStreamCursor.stream(self.streamOptions); + for (let pipeDestination in self.pipeDestinations) { + cursorStream.pipe(pipeDestination); + } + } + + return changeStreamCursor; +}; + +function getResumeToken(self) { + return self.resumeToken || self.options.resumeAfter; +} + +function getStartAtOperationTime(self) { + const isMaster = self.topology.lastIsMaster() || {}; + return ( + isMaster.maxWireVersion && isMaster.maxWireVersion >= 7 && self.options.startAtOperationTime + ); +} + +var buildChangeStreamAggregationCommand = function(self) { + const topology = self.topology; + const namespace = self.namespace; + const pipeline = self.pipeline; + const options = self.options; + const cursorNamespace = self.cursorNamespace; + + var changeStreamStageOptions = { + fullDocument: options.fullDocument || 'default' + }; + + const resumeToken = getResumeToken(self); + const startAtOperationTime = getStartAtOperationTime(self); + if (resumeToken) { + changeStreamStageOptions.resumeAfter = resumeToken; + } + + if (startAtOperationTime) { + changeStreamStageOptions.startAtOperationTime = startAtOperationTime; + } + + // Map cursor options + var cursorOptions = {}; + cursorOptionNames.forEach(function(optionName) { + if (options[optionName]) { + cursorOptions[optionName] = options[optionName]; + } + }); + + if (self.type === CHANGE_DOMAIN_TYPES.CLUSTER) { + changeStreamStageOptions.allChangesForCluster = true; + } + + var changeStreamPipeline = [{ $changeStream: changeStreamStageOptions }]; + + changeStreamPipeline = changeStreamPipeline.concat(pipeline); + + var command = { + aggregate: self.type === CHANGE_DOMAIN_TYPES.COLLECTION ? namespace.collection : 1, + pipeline: changeStreamPipeline, + readConcern: { level: 'majority' }, + cursor: { + batchSize: options.batchSize || 1 + } + }; + + // Create and return the cursor + return topology.cursor(cursorNamespace, command, cursorOptions); +}; + +// This method performs a basic server selection loop, satisfying the requirements of +// ChangeStream resumability until the new SDAM layer can be used. +const SELECTION_TIMEOUT = 30000; +function waitForTopologyConnected(topology, options, callback) { + setTimeout(() => { + if (options && options.start == null) options.start = process.hrtime(); + const start = options.start || process.hrtime(); + const timeout = options.timeout || SELECTION_TIMEOUT; + const readPreference = options.readPreference; + + if (topology.isConnected({ readPreference })) return callback(null, null); + const hrElapsed = process.hrtime(start); + const elapsed = (hrElapsed[0] * 1e9 + hrElapsed[1]) / 1e6; + if (elapsed > timeout) return callback(new MongoError('Timed out waiting for connection')); + waitForTopologyConnected(topology, options, callback); + }, 3000); // this is an arbitrary wait time to allow SDAM to transition +} + +// Handle new change events. This method brings together the routes from the callback, event emitter, and promise ways of using ChangeStream. +function processNewChange(args) { + const changeStream = args.changeStream; + const error = args.error; + const change = args.change; + const callback = args.callback; + const eventEmitter = args.eventEmitter || false; + const topology = changeStream.topology; + const options = changeStream.cursor.options; + + if (error) { + if (isResumableError(error) && !changeStream.attemptingResume) { + changeStream.attemptingResume = true; + + if (!(getResumeToken(changeStream) || getStartAtOperationTime(changeStream))) { + const startAtOperationTime = changeStream.cursor.cursorState.operationTime; + changeStream.options = Object.assign({ startAtOperationTime }, changeStream.options); + } + + // stop listening to all events from old cursor + ['data', 'close', 'end', 'error'].forEach(event => + changeStream.cursor.removeAllListeners(event) + ); + + // close internal cursor, ignore errors + changeStream.cursor.close(); + + // attempt recreating the cursor + if (eventEmitter) { + waitForTopologyConnected(topology, { readPreference: options.readPreference }, err => { + if (err) return changeStream.emit('error', err); + changeStream.cursor = createChangeStreamCursor(changeStream); + }); + + return; + } + + if (callback) { + waitForTopologyConnected(topology, { readPreference: options.readPreference }, err => { + if (err) return callback(err, null); + + changeStream.cursor = createChangeStreamCursor(changeStream); + changeStream.next(callback); + }); + + return; + } + + return new Promise((resolve, reject) => { + waitForTopologyConnected(topology, { readPreference: options.readPreference }, err => { + if (err) return reject(err); + resolve(); + }); + }) + .then(() => (changeStream.cursor = createChangeStreamCursor(changeStream))) + .then(() => changeStream.next()); + } + + if (eventEmitter) return changeStream.emit('error', error); + if (typeof callback === 'function') return callback(error, null); + return changeStream.promiseLibrary.reject(error); + } + + changeStream.attemptingResume = false; + + // Cache the resume token if it is present. If it is not present return an error. + if (!change || !change._id) { + var noResumeTokenError = new Error( + 'A change stream document has been received that lacks a resume token (_id).' + ); + + if (eventEmitter) return changeStream.emit('error', noResumeTokenError); + if (typeof callback === 'function') return callback(noResumeTokenError, null); + return changeStream.promiseLibrary.reject(noResumeTokenError); + } + + changeStream.resumeToken = change._id; + + // Return the change + if (eventEmitter) return changeStream.emit('change', change); + if (typeof callback === 'function') return callback(error, change); + return changeStream.promiseLibrary.resolve(change); +} + +/** + * The callback format for results + * @callback ChangeStream~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {(object|null)} result The result object if the command was executed successfully. + */ + +module.exports = ChangeStream; diff --git a/node_modules/mongodb/lib/collection.js b/node_modules/mongodb/lib/collection.js index dea16c1..e4a926e 100644 --- a/node_modules/mongodb/lib/collection.js +++ b/node_modules/mongodb/lib/collection.js @@ -1,27 +1,65 @@ -"use strict"; - -var checkCollectionName = require('./utils').checkCollectionName - , ObjectID = require('mongodb-core').BSON.ObjectID - , Long = require('mongodb-core').BSON.Long - , Code = require('mongodb-core').BSON.Code - , f = require('util').format - , AggregationCursor = require('./aggregation_cursor') - , MongoError = require('mongodb-core').MongoError - , shallowClone = require('./utils').shallowClone - , isObject = require('./utils').isObject - , toError = require('./utils').toError - , normalizeHintField = require('./utils').normalizeHintField - , handleCallback = require('./utils').handleCallback - , decorateCommand = require('./utils').decorateCommand - , formattedOrderClause = require('./utils').formattedOrderClause - , ReadPreference = require('./read_preference') - , CoreReadPreference = require('mongodb-core').ReadPreference - , CommandCursor = require('./command_cursor') - , Define = require('./metadata') - , Cursor = require('./cursor') - , unordered = require('./bulk/unordered') - , ordered = require('./bulk/ordered') - , assign = require('./utils').assign; +'use strict'; + +const deprecate = require('util').deprecate; +const deprecateOptions = require('./utils').deprecateOptions; +const checkCollectionName = require('./utils').checkCollectionName; +const ObjectID = require('mongodb-core').BSON.ObjectID; +const AggregationCursor = require('./aggregation_cursor'); +const MongoError = require('mongodb-core').MongoError; +const toError = require('./utils').toError; +const normalizeHintField = require('./utils').normalizeHintField; +const handleCallback = require('./utils').handleCallback; +const decorateWithCollation = require('./utils').decorateWithCollation; +const decorateWithReadConcern = require('./utils').decorateWithReadConcern; +const formattedOrderClause = require('./utils').formattedOrderClause; +const ReadPreference = require('mongodb-core').ReadPreference; +const CommandCursor = require('./command_cursor'); +const unordered = require('./bulk/unordered'); +const ordered = require('./bulk/ordered'); +const ChangeStream = require('./change_stream'); +const executeOperation = require('./utils').executeOperation; +const applyWriteConcern = require('./utils').applyWriteConcern; +const resolveReadPreference = require('./utils').resolveReadPreference; + +// Operations +const bulkWrite = require('./operations/collection_ops').bulkWrite; +const checkForAtomicOperators = require('./operations/collection_ops').checkForAtomicOperators; +const count = require('./operations/collection_ops').count; +const countDocuments = require('./operations/collection_ops').countDocuments; +const createIndex = require('./operations/collection_ops').createIndex; +const createIndexes = require('./operations/collection_ops').createIndexes; +const deleteMany = require('./operations/collection_ops').deleteMany; +const deleteOne = require('./operations/collection_ops').deleteOne; +const distinct = require('./operations/collection_ops').distinct; +const dropIndex = require('./operations/collection_ops').dropIndex; +const dropIndexes = require('./operations/collection_ops').dropIndexes; +const ensureIndex = require('./operations/collection_ops').ensureIndex; +const findAndModify = require('./operations/collection_ops').findAndModify; +const findAndRemove = require('./operations/collection_ops').findAndRemove; +const findOne = require('./operations/collection_ops').findOne; +const findOneAndDelete = require('./operations/collection_ops').findOneAndDelete; +const findOneAndReplace = require('./operations/collection_ops').findOneAndReplace; +const findOneAndUpdate = require('./operations/collection_ops').findOneAndUpdate; +const geoHaystackSearch = require('./operations/collection_ops').geoHaystackSearch; +const group = require('./operations/collection_ops').group; +const indexes = require('./operations/collection_ops').indexes; +const indexExists = require('./operations/collection_ops').indexExists; +const indexInformation = require('./operations/collection_ops').indexInformation; +const insertOne = require('./operations/collection_ops').insertOne; +const isCapped = require('./operations/collection_ops').isCapped; +const mapReduce = require('./operations/collection_ops').mapReduce; +const optionsOp = require('./operations/collection_ops').optionsOp; +const parallelCollectionScan = require('./operations/collection_ops').parallelCollectionScan; +const prepareDocs = require('./operations/collection_ops').prepareDocs; +const reIndex = require('./operations/collection_ops').reIndex; +const removeDocuments = require('./operations/collection_ops').removeDocuments; +const rename = require('./operations/collection_ops').rename; +const replaceOne = require('./operations/collection_ops').replaceOne; +const save = require('./operations/collection_ops').save; +const stats = require('./operations/collection_ops').stats; +const updateDocuments = require('./operations/collection_ops').updateDocuments; +const updateMany = require('./operations/collection_ops').updateMany; +const updateOne = require('./operations/collection_ops').updateOne; /** * @fileOverview The **Collection** class is an internal class that embodies a MongoDB collection @@ -29,24 +67,26 @@ var checkCollectionName = require('./utils').checkCollectionName * * **COLLECTION Cannot directly be instantiated** * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { + * MongoClient.connect(url, function(err, client) { * // Create a collection we want to drop later - * var col = db.collection('createIndexExample1'); + * const col = client.db(dbName).collection('createIndexExample1'); * // Show that duplicate records got dropped * col.find({}).toArray(function(err, items) { * test.equal(null, err); * test.equal(4, items.length); - * db.close(); + * client.close(); * }); * }); */ -var mergeKeys = ['readPreference', 'ignoreUndefined']; +const mergeKeys = ['ignoreUndefined']; /** * Create a new Collection instance (INTERNAL TYPE, do not instantiate directly) @@ -58,105 +98,129 @@ var mergeKeys = ['readPreference', 'ignoreUndefined']; * @property {object} hint Get current index hint for collection. * @return {Collection} a Collection instance. */ -var Collection = function(db, topology, dbName, name, pkFactory, options) { +function Collection(db, topology, dbName, name, pkFactory, options) { checkCollectionName(name); // Unpack variables - var internalHint = null; - var slaveOk = options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk; - var serializeFunctions = options == null || options.serializeFunctions == null ? db.s.options.serializeFunctions : options.serializeFunctions; - var raw = options == null || options.raw == null ? db.s.options.raw : options.raw; - var promoteLongs = options == null || options.promoteLongs == null ? db.s.options.promoteLongs : options.promoteLongs; - var promoteValues = options == null || options.promoteValues == null ? db.s.options.promoteValues : options.promoteValues; - var promoteBuffers = options == null || options.promoteBuffers == null ? db.s.options.promoteBuffers : options.promoteBuffers; - var readPreference = null; - var collectionHint = null; - var namespace = f("%s.%s", dbName, name); + const internalHint = null; + const slaveOk = options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk; + const serializeFunctions = + options == null || options.serializeFunctions == null + ? db.s.options.serializeFunctions + : options.serializeFunctions; + const raw = options == null || options.raw == null ? db.s.options.raw : options.raw; + const promoteLongs = + options == null || options.promoteLongs == null + ? db.s.options.promoteLongs + : options.promoteLongs; + const promoteValues = + options == null || options.promoteValues == null + ? db.s.options.promoteValues + : options.promoteValues; + const promoteBuffers = + options == null || options.promoteBuffers == null + ? db.s.options.promoteBuffers + : options.promoteBuffers; + let readPreference = null; + const collectionHint = null; + const namespace = `${dbName}.${name}`; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + const promiseLibrary = options.promiseLibrary || Promise; // Assign the right collection level readPreference - if(options && options.readPreference) { + if (options && options.readPreference) { readPreference = options.readPreference; - } else if(db.options.readPreference) { + } else if (db.options.readPreference) { readPreference = db.options.readPreference; } // Set custom primary key factory if provided - pkFactory = pkFactory == null - ? ObjectID - : pkFactory; + pkFactory = pkFactory == null ? ObjectID : pkFactory; // Internal state this.s = { // Set custom primary key factory if provided - pkFactory: pkFactory + pkFactory: pkFactory, // Db - , db: db + db: db, // Topology - , topology: topology + topology: topology, // dbName - , dbName: dbName + dbName: dbName, // Options - , options: options + options: options, // Namespace - , namespace: namespace + namespace: namespace, // Read preference - , readPreference: readPreference + readPreference: readPreference, // SlaveOK - , slaveOk: slaveOk + slaveOk: slaveOk, // Serialize functions - , serializeFunctions: serializeFunctions + serializeFunctions: serializeFunctions, // Raw - , raw: raw + raw: raw, // promoteLongs - , promoteLongs: promoteLongs + promoteLongs: promoteLongs, // promoteValues - , promoteValues: promoteValues + promoteValues: promoteValues, // promoteBuffers - , promoteBuffers: promoteBuffers + promoteBuffers: promoteBuffers, // internalHint - , internalHint: internalHint + internalHint: internalHint, // collectionHint - , collectionHint: collectionHint + collectionHint: collectionHint, // Name - , name: name + name: name, // Promise library - , promiseLibrary: promiseLibrary + promiseLibrary: promiseLibrary, // Read Concern - , readConcern: options.readConcern - } + readConcern: options.readConcern, + // Write Concern + writeConcern: options.writeConcern + }; } -var define = Collection.define = new Define('Collection', Collection, false); +Object.defineProperty(Collection.prototype, 'dbName', { + enumerable: true, + get: function() { + return this.s.dbName; + } +}); Object.defineProperty(Collection.prototype, 'collectionName', { - enumerable: true, get: function() { return this.s.name; } + enumerable: true, + get: function() { + return this.s.name; + } }); Object.defineProperty(Collection.prototype, 'namespace', { - enumerable: true, get: function() { return this.s.namespace; } + enumerable: true, + get: function() { + return this.s.namespace; + } }); Object.defineProperty(Collection.prototype, 'readConcern', { - enumerable: true, get: function() { return this.s.readConcern || {level: 'local'}; } + enumerable: true, + get: function() { + return this.s.readConcern || { level: 'local' }; + } }); Object.defineProperty(Collection.prototype, 'writeConcern', { - enumerable:true, + enumerable: true, get: function() { - var ops = {}; - if(this.s.options.w != null) ops.w = this.s.options.w; - if(this.s.options.j != null) ops.j = this.s.options.j; - if(this.s.options.fsync != null) ops.fsync = this.s.options.fsync; - if(this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; + let ops = {}; + if (this.s.writeConcern) { + return this.s.writeConcern; + } + + if (this.s.options.w != null) ops.w = this.s.options.w; + if (this.s.options.j != null) ops.j = this.s.options.j; + if (this.s.options.fsync != null) ops.fsync = this.s.options.fsync; + if (this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; return ops; } }); @@ -164,228 +228,209 @@ Object.defineProperty(Collection.prototype, 'writeConcern', { /** * @ignore */ -Object.defineProperty(Collection.prototype, "hint", { - enumerable: true - , get: function () { return this.s.collectionHint; } - , set: function (v) { this.s.collectionHint = normalizeHintField(v); } +Object.defineProperty(Collection.prototype, 'hint', { + enumerable: true, + get: function() { + return this.s.collectionHint; + }, + set: function(v) { + this.s.collectionHint = normalizeHintField(v); + } }); +const DEPRECATED_FIND_OPTIONS = ['maxScan', 'fields', 'snapshot']; + /** * Creates a cursor for a query that can be used to iterate over results from MongoDB * @method - * @param {object} query The cursor query object. + * @param {object} [query={}] The cursor query object. + * @param {object} [options] Optional settings. + * @param {number} [options.limit=0] Sets the limit of documents returned in the query. + * @param {(array|object)} [options.sort] Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc. + * @param {object} [options.projection] The fields to return in the query. Object of fields to include or exclude (not both), {'a':1} + * @param {object} [options.fields] **Deprecated** Use `options.projection` instead + * @param {number} [options.skip=0] Set to skip N documents ahead in your query (useful for pagination). + * @param {Object} [options.hint] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1} + * @param {boolean} [options.explain=false] Explain the query instead of returning the data. + * @param {boolean} [options.snapshot=false] DEPRECATED: Snapshot query. + * @param {boolean} [options.timeout=false] Specify if the cursor can timeout. + * @param {boolean} [options.tailable=false] Specify if the cursor is tailable. + * @param {number} [options.batchSize=0] Set the batchSize for the getMoreCommand when iterating over the query results. + * @param {boolean} [options.returnKey=false] Only return the index key. + * @param {number} [options.maxScan] DEPRECATED: Limit the number of items to scan. + * @param {number} [options.min] Set index bounds. + * @param {number} [options.max] Set index bounds. + * @param {boolean} [options.showDiskLoc=false] Show disk location of results. + * @param {string} [options.comment] You can put a $comment field on a query to make looking in the profiler logs simpler. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {ClientSession} [options.session] optional session to use for this operation * @throws {MongoError} * @return {Cursor} */ -Collection.prototype.find = function() { - var options - , args = Array.prototype.slice.call(arguments, 0) - , has_callback = typeof args[args.length - 1] === 'function' - , has_weird_callback = typeof args[0] === 'function' - , callback = has_callback ? args.pop() : (has_weird_callback ? args.shift() : null) - , len = args.length - , selector = len >= 1 ? args[0] : {} - , fields = len >= 2 ? args[1] : undefined; - - if(len === 1 && has_weird_callback) { - // backwards compat for callback?, options case - selector = {}; - options = args[0]; - } - - if(len === 2 && fields !== undefined && !Array.isArray(fields)) { - var fieldKeys = Object.keys(fields); - var is_option = false; +Collection.prototype.find = deprecateOptions( + { + name: 'collection.find', + deprecatedOptions: DEPRECATED_FIND_OPTIONS, + optionsIndex: 1 + }, + function(query, options, callback) { + if (typeof callback === 'object') { + // TODO(MAJOR): throw in the future + console.warn('Third parameter to `find()` must be a callback or undefined'); + } - for(var i = 0; i < fieldKeys.length; i++) { - if(testForFields[fieldKeys[i]] != null) { - is_option = true; - break; + let selector = query; + // figuring out arguments + if (typeof callback !== 'function') { + if (typeof options === 'function') { + callback = options; + options = undefined; + } else if (options == null) { + callback = typeof selector === 'function' ? selector : undefined; + selector = typeof selector === 'object' ? selector : undefined; } } - if(is_option) { - options = fields; - fields = undefined; - } else { - options = {}; - } - } else if(len === 2 && Array.isArray(fields) && !Array.isArray(fields[0])) { - var newFields = {}; - // Rewrite the array - for(i = 0; i < fields.length; i++) { - newFields[fields[i]] = 1; + // Ensure selector is not null + selector = selector == null ? {} : selector; + // Validate correctness off the selector + const object = selector; + if (Buffer.isBuffer(object)) { + const object_size = object[0] | (object[1] << 8) | (object[2] << 16) | (object[3] << 24); + if (object_size !== object.length) { + const error = new Error( + 'query selector raw message size does not match message header size [' + + object.length + + '] != [' + + object_size + + ']' + ); + error.name = 'MongoError'; + throw error; + } } - // Set the fields - fields = newFields; - } - - if(3 === len) { - options = args[2]; - } - // Ensure selector is not null - selector = selector == null ? {} : selector; - // Validate correctness off the selector - var object = selector; - if(Buffer.isBuffer(object)) { - var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24; - if(object_size != object.length) { - var error = new Error("query selector raw message size does not match message header size [" + object.length + "] != [" + object_size + "]"); - error.name = 'MongoError'; - throw error; + // Check special case where we are using an objectId + if (selector != null && selector._bsontype === 'ObjectID') { + selector = { _id: selector }; } - } - // Validate correctness of the field selector - object = fields; - if(Buffer.isBuffer(object)) { - object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24; - if(object_size != object.length) { - error = new Error("query fields raw message size does not match message header size [" + object.length + "] != [" + object_size + "]"); - error.name = 'MongoError'; - throw error; - } - } + if (!options) options = {}; - // Check special case where we are using an objectId - if(selector != null && selector._bsontype == 'ObjectID') { - selector = {_id:selector}; - } + let projection = options.projection || options.fields; - // If it's a serialized fields field we need to just let it through - // user be warned it better be good - if(options && options.fields && !(Buffer.isBuffer(options.fields))) { - fields = {}; + if (projection && !Buffer.isBuffer(projection) && Array.isArray(projection)) { + projection = projection.length + ? projection.reduce((result, field) => { + result[field] = 1; + return result; + }, {}) + : { _id: 1 }; + } - if(Array.isArray(options.fields)) { - if(!options.fields.length) { - fields['_id'] = 1; - } else { - var l = options.fields.length; + // Make a shallow copy of options + let newOptions = Object.assign({}, options); - for (i = 0; i < l; i++) { - fields[options.fields[i]] = 1; - } + // Make a shallow copy of the collection options + for (let key in this.s.options) { + if (mergeKeys.indexOf(key) !== -1) { + newOptions[key] = this.s.options[key]; } - } else { - fields = options.fields; } - } - if (!options) options = {}; - - var newOptions = {}; + // Unpack options + newOptions.skip = options.skip ? options.skip : 0; + newOptions.limit = options.limit ? options.limit : 0; + newOptions.raw = typeof options.raw === 'boolean' ? options.raw : this.s.raw; + newOptions.hint = + options.hint != null ? normalizeHintField(options.hint) : this.s.collectionHint; + newOptions.timeout = typeof options.timeout === 'undefined' ? undefined : options.timeout; + // // If we have overridden slaveOk otherwise use the default db setting + newOptions.slaveOk = options.slaveOk != null ? options.slaveOk : this.s.db.slaveOk; + + // Add read preference if needed + newOptions.readPreference = resolveReadPreference(newOptions, { + db: this.s.db, + collection: this + }); - // Make a shallow copy of the collection options - for(var key in this.s.options) { - if(mergeKeys.indexOf(key) != -1) { - newOptions[key] = this.s.options[key]; + // Set slave ok to true if read preference different from primary + if ( + newOptions.readPreference != null && + (newOptions.readPreference !== 'primary' || newOptions.readPreference.mode !== 'primary') + ) { + newOptions.slaveOk = true; } - } - - // Make a shallow copy of options - for (var key in options) { - newOptions[key] = options[key]; - } - - // Unpack options - newOptions.skip = len > 3 ? args[2] : options.skip ? options.skip : 0; - newOptions.limit = len > 3 ? args[3] : options.limit ? options.limit : 0; - newOptions.raw = options.raw != null && typeof options.raw === 'boolean' ? options.raw : this.s.raw; - newOptions.hint = options.hint != null ? normalizeHintField(options.hint) : this.s.collectionHint; - newOptions.timeout = len == 5 ? args[4] : typeof options.timeout === 'undefined' ? undefined : options.timeout; - // // If we have overridden slaveOk otherwise use the default db setting - newOptions.slaveOk = options.slaveOk != null ? options.slaveOk : this.s.db.slaveOk; - - // Add read preference if needed - newOptions = getReadPreference(this, newOptions, this.s.db, this); - - // Set slave ok to true if read preference different from primary - if(newOptions.readPreference != null - && (newOptions.readPreference != 'primary' || newOptions.readPreference.mode != 'primary')) { - newOptions.slaveOk = true; - } - - // Ensure the query is an object - if(selector != null && typeof selector != 'object') { - throw MongoError.create({message: "query selector must be an object", driver:true }); - } - // Build the find command - var findCommand = { - find: this.s.namespace - , limit: newOptions.limit - , skip: newOptions.skip - , query: selector - } + // Ensure the query is an object + if (selector != null && typeof selector !== 'object') { + throw MongoError.create({ message: 'query selector must be an object', driver: true }); + } - // Ensure we use the right await data option - if(typeof newOptions.awaitdata == 'boolean') { - newOptions.awaitData = newOptions.awaitdata - } + // Build the find command + const findCommand = { + find: this.s.namespace, + limit: newOptions.limit, + skip: newOptions.skip, + query: selector + }; - // Translate to new command option noCursorTimeout - if(typeof newOptions.timeout == 'boolean') newOptions.noCursorTimeout = newOptions.timeout; + // Ensure we use the right await data option + if (typeof newOptions.awaitdata === 'boolean') { + newOptions.awaitData = newOptions.awaitdata; + } - // Merge in options to command - for(var name in newOptions) { - if(newOptions[name] != null) findCommand[name] = newOptions[name]; - } + // Translate to new command option noCursorTimeout + if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = newOptions.timeout; - // Format the fields - var formatFields = function(fields) { - var object = {}; - if(Array.isArray(fields)) { - for(var i = 0; i < fields.length; i++) { - if(Array.isArray(fields[i])) { - object[fields[i][0]] = fields[i][1]; - } else { - object[fields[i][0]] = 1; - } + // Merge in options to command + for (let name in newOptions) { + if (newOptions[name] != null && name !== 'session') { + findCommand[name] = newOptions[name]; } - } else { - object = fields; } - return object; - } - - // Special treatment for the fields selector - if(fields) findCommand.fields = formatFields(fields); + if (projection) findCommand.fields = projection; - // Add db object to the new options - newOptions.db = this.s.db; + // Add db object to the new options + newOptions.db = this.s.db; - // Add the promise library - newOptions.promiseLibrary = this.s.promiseLibrary; + // Add the promise library + newOptions.promiseLibrary = this.s.promiseLibrary; - // Set raw if available at collection level - if(newOptions.raw == null && typeof this.s.raw == 'boolean') newOptions.raw = this.s.raw; - // Set promoteLongs if available at collection level - if(newOptions.promoteLongs == null && typeof this.s.promoteLongs == 'boolean') newOptions.promoteLongs = this.s.promoteLongs; - if(newOptions.promoteValues == null && typeof this.s.promoteValues == 'boolean') newOptions.promoteValues = this.s.promoteValues; - if(newOptions.promoteBuffers == null && typeof this.s.promoteBuffers == 'boolean') newOptions.promoteBuffers = this.s.promoteBuffers; + // Set raw if available at collection level + if (newOptions.raw == null && typeof this.s.raw === 'boolean') newOptions.raw = this.s.raw; + // Set promoteLongs if available at collection level + if (newOptions.promoteLongs == null && typeof this.s.promoteLongs === 'boolean') + newOptions.promoteLongs = this.s.promoteLongs; + if (newOptions.promoteValues == null && typeof this.s.promoteValues === 'boolean') + newOptions.promoteValues = this.s.promoteValues; + if (newOptions.promoteBuffers == null && typeof this.s.promoteBuffers === 'boolean') + newOptions.promoteBuffers = this.s.promoteBuffers; - // Sort options - if(findCommand.sort) { - findCommand.sort = formattedOrderClause(findCommand.sort); - } + // Sort options + if (findCommand.sort) { + findCommand.sort = formattedOrderClause(findCommand.sort); + } - // Set the readConcern - if(this.s.readConcern) { - findCommand.readConcern = this.s.readConcern; - } + // Set the readConcern + decorateWithReadConcern(findCommand, this, options); - // Decorate find command with collation options - decorateWithCollation(findCommand, this, options); + // Decorate find command with collation options + decorateWithCollation(findCommand, this, options); - // Create the cursor - if(typeof callback == 'function') return handleCallback(callback, null, this.s.topology.cursor(this.s.namespace, findCommand, newOptions)); - return this.s.topology.cursor(this.s.namespace, findCommand, newOptions); -} + const cursor = this.s.topology.cursor(this.s.namespace, findCommand, newOptions); -define.classMethod('find', {callback: false, promise:false, returns: [Cursor]}); + return typeof callback === 'function' ? handleCallback(callback, null, cursor) : cursor; + } +); /** * Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field, @@ -394,86 +439,45 @@ define.classMethod('find', {callback: false, promise:false, returns: [Cursor]}); * * @method * @param {object} doc Document to insert. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~insertOneWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.insertOne = function(doc, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - if(Array.isArray(doc) && typeof callback == 'function') { - return callback(MongoError.create({message: 'doc parameter must be an object', driver:true })); - } else if(Array.isArray(doc)) { - return new this.s.promiseLibrary(function(resolve, reject) { - reject(MongoError.create({message: 'doc parameter must be an object', driver:true })); - }); - } - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return insertOne(self, doc, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - insertOne(self, doc, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var insertOne = function(self, doc, options, callback) { - insertDocuments(self, [doc], options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - // Workaround for pre 2.6 servers - if(r == null) return callback(null, {result: {ok:1}}); - // Add values to top level to ensure crud spec compatibility - r.insertedCount = r.result.n; - r.insertedId = doc._id; - if(callback) callback(null, r); - }); -} - -var mapInsertManyResults = function(docs, r) { - var ids = r.getInsertedIds(); - var keys = Object.keys(ids); - var finalIds = new Array(keys.length); - - for(var i = 0; i < keys.length; i++) { - if(ids[keys[i]]._id) { - finalIds[ids[keys[i]].index] = ids[keys[i]]._id; - } - } + return executeOperation(this.s.topology, insertOne, [this, doc, options, callback]); +}; - var finalResult = { - result: {ok: 1, n: r.insertedCount}, +function mapInsertManyResults(docs, r) { + const finalResult = { + result: { ok: 1, n: r.insertedCount }, ops: docs, insertedCount: r.insertedCount, - insertedIds: finalIds + insertedIds: r.insertedIds }; - if(r.getLastOp()) { + if (r.getLastOp()) { finalResult.result.opTime = r.getLastOp(); } return finalResult; } -define.classMethod('insertOne', {callback: true, promise:true}); - /** * Inserts an array of documents into MongoDB. If documents passed in do not contain the **_id** field, * one will be added to each of the documents missing it by the driver, mutating the document. This behavior @@ -481,70 +485,50 @@ define.classMethod('insertOne', {callback: true, promise:true}); * * @method * @param {object[]} docs Documents to insert. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. * @param {boolean} [options.ordered=true] If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~insertWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.insertMany = function(docs, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = options ? shallowClone(options) : {ordered:true}; - if(!Array.isArray(docs) && typeof callback == 'function') { - return callback(MongoError.create({message: 'docs parameter must be an array of documents', driver:true })); - } else if(!Array.isArray(docs)) { - return new this.s.promiseLibrary(function(resolve, reject) { - reject(MongoError.create({message: 'docs parameter must be an array of documents', driver:true })); + if (typeof options === 'function') (callback = options), (options = {}); + options = options ? Object.assign({}, options) : { ordered: true }; + + if (!Array.isArray(docs) && typeof callback === 'function') { + return callback( + MongoError.create({ message: 'docs parameter must be an array of documents', driver: true }) + ); + } else if (!Array.isArray(docs)) { + return new this.s.promiseLibrary((resolve, reject) => { + reject( + MongoError.create({ message: 'docs parameter must be an array of documents', driver: true }) + ); }); } - // Get the write concern options - if(typeof options.checkKeys != 'boolean') { - options.checkKeys = true; - } - // If keep going set unordered - options['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; - - // Set up the force server object id - var forceServerObjectId = typeof options.forceServerObjectId == 'boolean' - ? options.forceServerObjectId : self.s.db.options.forceServerObjectId; + options['serializeFunctions'] = options['serializeFunctions'] || this.s.serializeFunctions; - // Do we want to force the server to assign the _id key - if(forceServerObjectId !== true) { - // Add _id if not specified - for(var i = 0; i < docs.length; i++) { - if(docs[i]._id == null) docs[i]._id = self.s.pkFactory.createPk(); - } - } + docs = prepareDocs(this, docs, options); // Generate the bulk write operations - var operations = [{ - insertMany: docs - }]; - - // Execute using callback - if(typeof callback == 'function') return bulkWrite(self, operations, options, function(err, r) { - if(err) return callback(err, r); - callback(null, mapInsertManyResults(docs, r)); - }); + const operations = [ + { + insertMany: docs + } + ]; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - bulkWrite(self, operations, options, function(err, r) { - if(err) return reject(err); - resolve(mapInsertManyResults(docs, r)); - }); + return executeOperation(this.s.topology, bulkWrite, [this, operations, options, callback], { + resultMutator: result => mapInsertManyResults(docs, result) }); -} - -define.classMethod('insertMany', {callback: true, promise:true}); +}; /** * @typedef {Object} Collection~BulkWriteOpResult @@ -561,7 +545,7 @@ define.classMethod('insertMany', {callback: true, promise:true}); /** * The callback format for inserts * @callback Collection~bulkWriteOpCallback - * @param {MongoError} error An error instance representing the error during the execution. + * @param {BulkWriteError} error An error instance representing the error during the execution. * @param {Collection~BulkWriteOpResult} result The result object if the command was executed successfully. */ @@ -588,172 +572,27 @@ define.classMethod('insertMany', {callback: true, promise:true}); * * @method * @param {object[]} operations Bulk operations to perform. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.ordered=true] Execute write operation in ordered or unordered fashion. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~bulkWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.bulkWrite = function(operations, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = options || {ordered:true}; - - if(!Array.isArray(operations)) { - throw MongoError.create({message: "operations must be an array of documents", driver:true }); - } - - // Execute using callback - if(typeof callback == 'function') return bulkWrite(self, operations, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - bulkWrite(self, operations, options, function(err, r) { - if(err && r == null) return reject(err); - resolve(r); - }); - }); -} - -var bulkWrite = function(self, operations, options, callback) { - // Add ignoreUndefined - if(self.s.options.ignoreUndefined) { - options = shallowClone(options); - options.ignoreUndefined = self.s.options.ignoreUndefined; - } - - // Create the bulk operation - var bulk = options.ordered == true || options.ordered == null ? self.initializeOrderedBulkOp(options) : self.initializeUnorderedBulkOp(options); - - // Do we have a collation - var collation = false; - - // for each op go through and add to the bulk - try { - for(var i = 0; i < operations.length; i++) { - // Get the operation type - var key = Object.keys(operations[i])[0]; - // Check if we have a collation - if(operations[i][key].collation) { - collation = true; - } - - // Pass to the raw bulk - bulk.raw(operations[i]); - } - } catch(err) { - return callback(err, null); - } - - // Final options for write concern - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - var writeCon = finalOptions.writeConcern ? finalOptions.writeConcern : {}; - var capabilities = self.s.topology.capabilities(); - - // Did the user pass in a collation, check if our write server supports it - if(collation && capabilities && !capabilities.commandsTakeCollation) { - return callback(new MongoError(f('server/primary/mongos does not support collation'))); - } - - // Execute the bulk - bulk.execute(writeCon, function(err, r) { - // We have connection level error - if(!r && err) return callback(err, null); - // We have single error - if(r && r.hasWriteErrors() && r.getWriteErrorCount() == 1) { - return callback(toError(r.getWriteErrorAt(0)), r); - } - - r.insertedCount = r.nInserted; - r.matchedCount = r.nMatched; - r.modifiedCount = r.nModified || 0; - r.deletedCount = r.nRemoved; - r.upsertedCount = r.getUpsertedIds().length; - r.upsertedIds = {}; - r.insertedIds = {}; - - // Update the n - r.n = r.insertedCount; - - // Inserted documents - var inserted = r.getInsertedIds(); - // Map inserted ids - for(var i = 0; i < inserted.length; i++) { - r.insertedIds[inserted[i].index] = inserted[i]._id; - } - - // Upserted documents - var upserted = r.getUpsertedIds(); - // Map upserted ids - for(i = 0; i < upserted.length; i++) { - r.upsertedIds[upserted[i].index] = upserted[i]._id; - } - - // Check if we have write errors - if(r.hasWriteErrors()) { - // Get all the errors - var errors = r.getWriteErrors(); - // Return the MongoError object - return callback(toError({ - message: 'write operation failed', code: errors[0].code, writeErrors: errors - }), r); - } - - // Check if we have a writeConcern error - if(r.getWriteConcernError()) { - // Return the MongoError object - return callback(toError(r.getWriteConcernError()), r); - } - - // Return the results - callback(null, r); - }); -} - -var insertDocuments = function(self, docs, options, callback) { - if(typeof options == 'function') callback = options, options = {}; - options = options || {}; - // Ensure we are operating on an array op docs - docs = Array.isArray(docs) ? docs : [docs]; - - // Get the write concern options - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - if(typeof finalOptions.checkKeys != 'boolean') finalOptions.checkKeys = true; - - // If keep going set unordered - if(finalOptions.keepGoing == true) finalOptions.ordered = false; - finalOptions['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; + if (typeof options === 'function') (callback = options), (options = {}); + options = options || { ordered: true }; - // Set up the force server object id - var forceServerObjectId = typeof options.forceServerObjectId == 'boolean' - ? options.forceServerObjectId : self.s.db.options.forceServerObjectId; - - // Add _id if not specified - if(forceServerObjectId !== true){ - for(var i = 0; i < docs.length; i++) { - if(docs[i]._id === void 0) docs[i]._id = self.s.pkFactory.createPk(); - } + if (!Array.isArray(operations)) { + throw MongoError.create({ message: 'operations must be an array of documents', driver: true }); } - // File inserts - self.s.topology.insert(self.s.namespace, docs, finalOptions, function(err, result) { - if(callback == null) return; - if(err) return handleCallback(callback, err); - if(result == null) return handleCallback(callback, null, null); - if(result.result.code) return handleCallback(callback, toError(result.result)); - if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); - // Add docs to the list - result.ops = docs; - // Return the results - handleCallback(callback, null, result); - }); -} - -define.classMethod('bulkWrite', {callback: true, promise:true}); + return executeOperation(this.s.topology, bulkWrite, [this, operations, options, callback]); +}; /** * @typedef {Object} Collection~WriteOpResult @@ -773,7 +612,7 @@ define.classMethod('bulkWrite', {callback: true, promise:true}); * @typedef {Object} Collection~insertWriteOpResult * @property {Number} insertedCount The total amount of documents inserted. * @property {object[]} ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany - * @property {ObjectId[]} insertedIds All the generated _id's for the inserted documents. + * @property {Object.} insertedIds Map of the index of the inserted document to the id of the inserted document. * @property {object} connection The connection object used for the operation. * @property {object} result The raw command result object returned from MongoDB (content might vary by server version). * @property {Number} result.ok Is 1 if the command executed correctly. @@ -812,30 +651,29 @@ define.classMethod('bulkWrite', {callback: true, promise:true}); * * @method * @param {(object|object[])} docs Documents to insert. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~insertWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed * @deprecated Use insertOne, insertMany or bulkWrite */ -Collection.prototype.insert = function(docs, options, callback) { - if(typeof options == 'function') callback = options, options = {}; - options = options || {ordered:false}; +Collection.prototype.insert = deprecate(function(docs, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || { ordered: false }; docs = !Array.isArray(docs) ? [docs] : docs; - if(options.keepGoing == true) { + if (options.keepGoing === true) { options.ordered = false; } return this.insertMany(docs, options, callback); -} - -define.classMethod('insert', {callback: true, promise:true}); +}, 'collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.'); /** * @typedef {Object} Collection~updateWriteOpResult @@ -863,245 +701,140 @@ define.classMethod('insert', {callback: true, promise:true}); * @method * @param {object} filter The Filter used to select the document to update * @param {object} update The update operations to be applied to the document - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.upsert=false] Update operation is an upsert. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Array} [options.arrayFilters] optional list of array filters referenced in filtered positional operators + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~updateWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.updateOne = function(filter, update, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = shallowClone(options) + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); - options.ignoreUndefined = this.s.options.ignoreUndefined; + const err = checkForAtomicOperators(update); + if (err) { + if (typeof callback === 'function') return callback(err); + return this.s.promiseLibrary.reject(err); } - // Execute using callback - if(typeof callback == 'function') return updateOne(self, filter, update, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - updateOne(self, filter, update, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} + options = Object.assign({}, options); -var updateOne = function(self, filter, update, options, callback) { - // Set single document update - options.multi = false; - // Execute update - updateDocuments(self, filter, update, options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - if(r == null) return callback(null, {result: {ok:1}}); - r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; - r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; - r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; - r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; - if(callback) callback(null, r); - }); -} + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } -define.classMethod('updateOne', {callback: true, promise:true}); + return executeOperation(this.s.topology, updateOne, [this, filter, update, options, callback]); +}; /** * Replace a document on MongoDB * @method * @param {object} filter The Filter used to select the document to update * @param {object} doc The Document that replaces the matching document - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.upsert=false] Update operation is an upsert. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~updateWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.replaceOne = function(filter, doc, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = shallowClone(options) + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options); - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return replaceOne(self, filter, doc, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - replaceOne(self, filter, doc, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var replaceOne = function(self, filter, doc, options, callback) { - // Set single document update - options.multi = false; - - // Execute update - updateDocuments(self, filter, doc, options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - if(r == null) return callback(null, {result: {ok:1}}); - - r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; - r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; - r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; - r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; - r.ops = [doc]; - if(callback) callback(null, r); - }); -} - -define.classMethod('replaceOne', {callback: true, promise:true}); + return executeOperation(this.s.topology, replaceOne, [this, filter, doc, options, callback]); +}; /** * Update multiple documents on MongoDB * @method - * @param {object} filter The Filter used to select the document to update + * @param {object} filter The Filter used to select the documents to update * @param {object} update The update operations to be applied to the document - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.upsert=false] Update operation is an upsert. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Array} [options.arrayFilters] optional list of array filters referenced in filtered positional operators + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~updateWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.updateMany = function(filter, update, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = shallowClone(options) + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); - options.ignoreUndefined = this.s.options.ignoreUndefined; + const err = checkForAtomicOperators(update); + if (err) { + if (typeof callback === 'function') return callback(err); + return this.s.promiseLibrary.reject(err); } - // Execute using callback - if(typeof callback == 'function') return updateMany(self, filter, update, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - updateMany(self, filter, update, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var updateMany = function(self, filter, update, options, callback) { - // Set single document update - options.multi = true; - // Execute update - updateDocuments(self, filter, update, options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - if(r == null) return callback(null, {result: {ok:1}}); - r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; - r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; - r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; - r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; - if(callback) callback(null, r); - }); -} - -define.classMethod('updateMany', {callback: true, promise:true}); - -var updateDocuments = function(self, selector, document, options, callback) { - if('function' === typeof options) callback = options, options = null; - if(options == null) options = {}; - if(!('function' === typeof callback)) callback = null; + options = Object.assign({}, options); - // If we are not providing a selector or document throw - if(selector == null || typeof selector != 'object') return callback(toError("selector must be a valid JavaScript object")); - if(document == null || typeof document != 'object') return callback(toError("document must be a valid JavaScript object")); - - // Get the write concern options - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - - // Do we return the actual result document - // Either use override on the function, or go back to default on either the collection - // level or db - finalOptions['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; - - // Execute the operation - var op = {q: selector, u: document}; - op.upsert = options.upsert !== void 0 ? !!options.upsert : false; - op.multi = options.multi !== void 0 ? !!options.multi : false; + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } - // Have we specified collation - decorateWithCollation(finalOptions, self, options); - - // Update options - self.s.topology.update(self.s.namespace, [op], finalOptions, function(err, result) { - if(callback == null) return; - if(err) return handleCallback(callback, err, null); - if(result == null) return handleCallback(callback, null, null); - if(result.result.code) return handleCallback(callback, toError(result.result)); - if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); - // Return the results - handleCallback(callback, null, result); - }); -} + return executeOperation(this.s.topology, updateMany, [this, filter, update, options, callback]); +}; /** * Updates documents. * @method * @param {object} selector The selector for the update operation. * @param {object} document The update document. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.upsert=false] Update operation is an upsert. * @param {boolean} [options.multi=false] Update one/all documents with operation. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Array} [options.arrayFilters] optional list of array filters referenced in filtered positional operators + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~writeOpCallback} [callback] The command result callback * @throws {MongoError} * @return {Promise} returns Promise if no callback passed * @deprecated use updateOne, updateMany or bulkWrite */ -Collection.prototype.update = function(selector, document, options, callback) { - var self = this; +Collection.prototype.update = deprecate(function(selector, document, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return updateDocuments(self, selector, document, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - updateDocuments(self, selector, document, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('update', {callback: true, promise:true}); + return executeOperation(this.s.topology, updateDocuments, [ + this, + selector, + document, + options, + callback + ]); +}, 'collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.'); /** * @typedef {Object} Collection~deleteWriteOpResult @@ -1123,233 +856,109 @@ define.classMethod('update', {callback: true, promise:true}); * Delete a document on MongoDB * @method * @param {object} filter The Filter used to select the document to remove - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~deleteWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.deleteOne = function(filter, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = shallowClone(options); + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options); - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return deleteOne(self, filter, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - deleteOne(self, filter, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var deleteOne = function(self, filter, options, callback) { - options.single = true; - removeDocuments(self, filter, options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - if(r == null) return callback(null, {result: {ok:1}}); - r.deletedCount = r.result.n; - if(callback) callback(null, r); - }); -} - -define.classMethod('deleteOne', {callback: true, promise:true}); + return executeOperation(this.s.topology, deleteOne, [this, filter, options, callback]); +}; Collection.prototype.removeOne = Collection.prototype.deleteOne; -define.classMethod('removeOne', {callback: true, promise:true}); - /** * Delete multiple documents on MongoDB * @method * @param {object} filter The Filter used to select the documents to remove - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~deleteWriteOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.deleteMany = function(filter, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; - options = shallowClone(options); + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options); - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return deleteMany(self, filter, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - deleteMany(self, filter, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var deleteMany = function(self, filter, options, callback) { - options.single = false; - - removeDocuments(self, filter, options, function(err, r) { - if(callback == null) return; - if(err && callback) return callback(err); - if(r == null) return callback(null, {result: {ok:1}}); - r.deletedCount = r.result.n; - if(callback) callback(null, r); - }); -} - -var removeDocuments = function(self, selector, options, callback) { - if(typeof options == 'function') { - callback = options, options = {}; - } else if (typeof selector === 'function') { - callback = selector; - options = {}; - selector = {}; - } - - // Create an empty options object if the provided one is null - options = options || {}; - - // Get the write concern options - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - - // If selector is null set empty - if(selector == null) selector = {}; - - // Build the op - var op = {q: selector, limit: 0}; - if(options.single) op.limit = 1; - - // Have we specified collation - decorateWithCollation(finalOptions, self, options); - - // Execute the remove - self.s.topology.remove(self.s.namespace, [op], finalOptions, function(err, result) { - if(callback == null) return; - if(err) return handleCallback(callback, err, null); - if(result == null) return handleCallback(callback, null, null); - if(result.result.code) return handleCallback(callback, toError(result.result)); - if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); - // Return the results - handleCallback(callback, null, result); - }); -} - -define.classMethod('deleteMany', {callback: true, promise:true}); + return executeOperation(this.s.topology, deleteMany, [this, filter, options, callback]); +}; Collection.prototype.removeMany = Collection.prototype.deleteMany; -define.classMethod('removeMany', {callback: true, promise:true}); - /** * Remove documents. * @method * @param {object} selector The selector for the update operation. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.single=false] Removes the first document found. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~writeOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed * @deprecated use deleteOne, deleteMany or bulkWrite */ -Collection.prototype.remove = function(selector, options, callback) { - var self = this; +Collection.prototype.remove = deprecate(function(selector, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return removeDocuments(self, selector, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - removeDocuments(self, selector, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('remove', {callback: true, promise:true}); + return executeOperation(this.s.topology, removeDocuments, [this, selector, options, callback]); +}, 'collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.'); /** * Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic * operators and update instead for more efficient operations. * @method * @param {object} doc Document to save - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~writeOpCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed * @deprecated use insertOne, insertMany, updateOne or updateMany */ -Collection.prototype.save = function(doc, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; +Collection.prototype.save = deprecate(function(doc, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Add ignoreUndefined - if(this.s.options.ignoreUndefined) { - options = shallowClone(options); + // Add ignoreUndfined + if (this.s.options.ignoreUndefined) { + options = Object.assign({}, options); options.ignoreUndefined = this.s.options.ignoreUndefined; } - // Execute using callback - if(typeof callback == 'function') return save(self, doc, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - save(self, doc, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var save = function(self, doc, options, callback) { - // Get the write concern options - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - // Establish if we need to perform an insert or update - if(doc._id != null) { - finalOptions.upsert = true; - return updateDocuments(self, {_id: doc._id}, doc, finalOptions, callback); - } - - // Insert the document - insertDocuments(self, [doc], options, function(err, r) { - if(callback == null) return; - if(doc == null) return handleCallback(callback, null, null); - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, r); - }); -} - -define.classMethod('save', {callback: true, promise:true}); + return executeOperation(this.s.topology, save, [this, doc, options, callback]); +}, 'collection.save is deprecated. Use insertOne, insertMany, updateOne, or updateMany instead.'); /** * The callback format for results @@ -1358,66 +967,67 @@ define.classMethod('save', {callback: true, promise:true}); * @param {object} result The result object if the command was executed successfully. */ +/** + * The callback format for an aggregation call + * @callback Collection~aggregationCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {AggregationCursor} cursor The cursor if the aggregation command was executed successfully. + */ + /** * Fetches the first document that matches the query * @method * @param {object} query Query for find Operation - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {number} [options.limit=0] Sets the limit of documents returned in the query. - * @param {(array|object)} [options.sort=null] Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc. - * @param {object} [options.fields=null] The fields to return in the query. Object of fields to include or exclude (not both), {'a':1} + * @param {(array|object)} [options.sort] Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc. + * @param {object} [options.projection] The fields to return in the query. Object of fields to include or exclude (not both), {'a':1} + * @param {object} [options.fields] **Deprecated** Use `options.projection` instead * @param {number} [options.skip=0] Set to skip N documents ahead in your query (useful for pagination). - * @param {Object} [options.hint=null] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1} + * @param {Object} [options.hint] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1} * @param {boolean} [options.explain=false] Explain the query instead of returning the data. - * @param {boolean} [options.snapshot=false] Snapshot query. + * @param {boolean} [options.snapshot=false] DEPRECATED: Snapshot query. * @param {boolean} [options.timeout=false] Specify if the cursor can timeout. * @param {boolean} [options.tailable=false] Specify if the cursor is tailable. * @param {number} [options.batchSize=0] Set the batchSize for the getMoreCommand when iterating over the query results. * @param {boolean} [options.returnKey=false] Only return the index key. - * @param {number} [options.maxScan=null] Limit the number of items to scan. - * @param {number} [options.min=null] Set index bounds. - * @param {number} [options.max=null] Set index bounds. + * @param {number} [options.maxScan] DEPRECATED: Limit the number of items to scan. + * @param {number} [options.min] Set index bounds. + * @param {number} [options.max] Set index bounds. * @param {boolean} [options.showDiskLoc=false] Show disk location of results. - * @param {string} [options.comment=null] You can put a $comment field on a query to make looking in the profiler logs simpler. + * @param {string} [options.comment] You can put a $comment field on a query to make looking in the profiler logs simpler. * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system - * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.findOne = function() { - var self = this; - var args = Array.prototype.slice.call(arguments, 0); - var callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - - // Execute using callback - if(typeof callback == 'function') return findOne(self, args, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - findOne(self, args, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} +Collection.prototype.findOne = deprecateOptions( + { + name: 'collection.find', + deprecatedOptions: DEPRECATED_FIND_OPTIONS, + optionsIndex: 1 + }, + function(query, options, callback) { + if (typeof callback === 'object') { + // TODO(MAJOR): throw in the future + console.warn('Third parameter to `findOne()` must be a callback or undefined'); + } -var findOne = function(self, args, callback) { - var cursor = self.find.apply(self, args).limit(-1).batchSize(1); - // Return the item - cursor.next(function(err, item) { - if(err != null) return handleCallback(callback, toError(err), null); - handleCallback(callback, null, item); - }); -} + if (typeof query === 'function') (callback = query), (query = {}), (options = {}); + if (typeof options === 'function') (callback = options), (options = {}); + query = query || {}; + options = options || {}; -define.classMethod('findOne', {callback: true, promise:true}); + return executeOperation(this.s.topology, findOne, [this, query, options, callback]); + } +); /** * The callback format for the collection method, must be used if strict is specified @@ -1431,195 +1041,100 @@ define.classMethod('findOne', {callback: true, promise:true}); * * @method * @param {string} newName New name of of the collection. - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.dropTarget=false] Drop the target name collection if it previously exists. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~collectionResultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.rename = function(newName, opt, callback) { - var self = this; - if(typeof opt == 'function') callback = opt, opt = {}; - opt = assign({}, opt, {readPreference: ReadPreference.PRIMARY}); - - // Execute using callback - if(typeof callback == 'function') return rename(self, newName, opt, callback); +Collection.prototype.rename = function(newName, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options, { readPreference: ReadPreference.PRIMARY }); - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - rename(self, newName, opt, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var rename = function(self, newName, opt, callback) { - // Check the collection name - checkCollectionName(newName); - // Build the command - var renameCollection = f("%s.%s", self.s.dbName, self.s.name); - var toCollection = f("%s.%s", self.s.dbName, newName); - var dropTarget = typeof opt.dropTarget == 'boolean' ? opt.dropTarget : false; - var cmd = {'renameCollection':renameCollection, 'to':toCollection, 'dropTarget':dropTarget}; - - // Decorate command with writeConcern if supported - decorateWithWriteConcern(cmd, self, opt); - - // Execute against admin - self.s.db.admin().command(cmd, opt, function(err, doc) { - if(err) return handleCallback(callback, err, null); - // We have an error - if(doc.errmsg) return handleCallback(callback, toError(doc), null); - try { - return handleCallback(callback, null, new Collection(self.s.db, self.s.topology, self.s.dbName, newName, self.s.pkFactory, self.s.options)); - } catch(err) { - return handleCallback(callback, toError(err), null); - } - }); -} - -define.classMethod('rename', {callback: true, promise:true}); + return executeOperation(this.s.topology, rename, [this, newName, options, callback]); +}; /** * Drop the collection from the database, removing it permanently. New accesses will create a new collection. * * @method - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.drop = function(options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Execute using callback - if(typeof callback == 'function') return self.s.db.dropCollection(self.s.name, options, callback); - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.db.dropCollection(self.s.name, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('drop', {callback: true, promise:true}); + return executeOperation(this.s.topology, this.s.db.dropCollection.bind(this.s.db), [ + this.s.name, + options, + callback + ]); +}; /** * Returns the options of the collection. * * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.options = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return options(self, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - options(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} +Collection.prototype.options = function(opts, callback) { + if (typeof opts === 'function') (callback = opts), (opts = {}); + opts = opts || {}; -var options = function(self, callback) { - self.s.db.listCollections({name: self.s.name}).toArray(function(err, collections) { - if(err) return handleCallback(callback, err); - if(collections.length == 0) { - return handleCallback(callback, MongoError.create({message: f("collection %s not found", self.s.namespace), driver:true })); - } - - handleCallback(callback, err, collections[0].options || null); - }); -} - -define.classMethod('options', {callback: true, promise:true}); + return executeOperation(this.s.topology, optionsOp, [this, opts, callback]); +}; /** * Returns if the collection is a capped collection * * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.isCapped = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return isCapped(self, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - isCapped(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var isCapped = function(self, callback) { - self.options(function(err, document) { - if(err) return handleCallback(callback, err); - handleCallback(callback, null, document && document.capped); - }); -} +Collection.prototype.isCapped = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('isCapped', {callback: true, promise:true}); + return executeOperation(this.s.topology, isCapped, [this, options, callback]); +}; /** * Creates an index on the db and collection collection. * @method * @param {(string|object)} fieldOrSpec Defines the index. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.unique=false] Creates an unique index. * @param {boolean} [options.sparse=false] Creates a sparse index. * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value - * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. - * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. - * @param {number} [options.v=null] Specify the format version of the indexes. - * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - * @param {string} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) - * @param {object} [options.partialFilterExpression=null] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {number} [options.min] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {string} [options.name] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.partialFilterExpression] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.createIndex = function(fieldOrSpec, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - options = args.length ? args.shift() || {} : {}; - options = typeof callback === 'function' ? options : callback; - options = options == null ? {} : options; - - // Execute using callback - if(typeof callback == 'function') return createIndex(self, fieldOrSpec, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - createIndex(self, fieldOrSpec, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var createIndex = function(self, fieldOrSpec, options, callback) { - self.s.db.createIndex(self.s.name, fieldOrSpec, options, callback); -} + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('createIndex', {callback: true, promise:true}); + return executeOperation(this.s.topology, createIndex, [this, fieldOrSpec, options, callback]); +}; /** * Creates multiple indexes in the collection, this method is only supported for @@ -1627,136 +1142,61 @@ define.classMethod('createIndex', {callback: true, promise:true}); * error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/. * @method * @param {array} indexSpecs An array of index specifications to be created + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.createIndexes = function(indexSpecs, callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return createIndexes(self, indexSpecs, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - createIndexes(self, indexSpecs, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var createIndexes = function(self, indexSpecs, callback) { - var capabilities = self.s.topology.capabilities(); - - // Ensure we generate the correct name if the parameter is not set - for(var i = 0; i < indexSpecs.length; i++) { - if(indexSpecs[i].name == null) { - var keys = []; - - // Did the user pass in a collation, check if our write server supports it - if(indexSpecs[i].collation && capabilities && !capabilities.commandsTakeCollation) { - return callback(new MongoError(f('server/primary/mongos does not support collation'))); - } - - for(var name in indexSpecs[i].key) { - keys.push(f('%s_%s', name, indexSpecs[i].key[name])); - } - - // Set the name - indexSpecs[i].name = keys.join('_'); - } - } +Collection.prototype.createIndexes = function(indexSpecs, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); - // Execute the index - self.s.db.command({ - createIndexes: self.s.name, indexes: indexSpecs - }, { readPreference: ReadPreference.PRIMARY }, callback); -} + options = options ? Object.assign({}, options) : {}; + if (typeof options.maxTimeMS !== 'number') delete options.maxTimeMS; -define.classMethod('createIndexes', {callback: true, promise:true}); + return executeOperation(this.s.topology, createIndexes, [this, indexSpecs, options, callback]); +}; /** * Drops an index from this collection. * @method * @param {string} indexName Name of the index to drop. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.dropIndex = function(indexName, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + options = args.length ? args.shift() || {} : {}; // Run only against primary options.readPreference = ReadPreference.PRIMARY; - // Execute using callback - if(typeof callback == 'function') return dropIndex(self, indexName, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - dropIndex(self, indexName, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var dropIndex = function(self, indexName, options, callback) { - // Delete index command - var cmd = {'dropIndexes':self.s.name, 'index':indexName}; - - // Decorate command with writeConcern if supported - decorateWithWriteConcern(cmd, self, options); - - // Execute command - self.s.db.command(cmd, options, function(err, result) { - if(typeof callback != 'function') return; - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, result); - }); -} - -define.classMethod('dropIndex', {callback: true, promise:true}); + return executeOperation(this.s.topology, dropIndex, [this, indexName, options, callback]); +}; /** * Drops all indexes from this collection. * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.dropIndexes = function(options, callback) { - var self = this; + if (typeof options === 'function') (callback = options), (options = {}); + options = options ? Object.assign({}, options) : {}; - // Do we have options - if(typeof options == 'function') callback = options, options = {}; - options = options || {}; - - // Execute using callback - if(typeof callback == 'function') return dropIndexes(self, options, callback); + if (typeof options.maxTimeMS !== 'number') delete options.maxTimeMS; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - dropIndexes(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var dropIndexes = function(self, options, callback) { - self.dropIndex('*', options, function(err) { - if(err) return handleCallback(callback, err, false); - handleCallback(callback, null, true); - }); -} - -define.classMethod('dropIndexes', {callback: true, promise:true}); + return executeOperation(this.s.topology, dropIndexes, [this, options, callback]); +}; /** * Drops all indexes from this collection. @@ -1765,220 +1205,141 @@ define.classMethod('dropIndexes', {callback: true, promise:true}); * @param {Collection~resultCallback} callback The command result callback * @return {Promise} returns Promise if no [callback] passed */ -Collection.prototype.dropAllIndexes = Collection.prototype.dropIndexes; - -define.classMethod('dropAllIndexes', {callback: true, promise:true}); +Collection.prototype.dropAllIndexes = deprecate( + Collection.prototype.dropIndexes, + 'collection.dropAllIndexes is deprecated. Use dropIndexes instead.' +); /** * Reindex all indexes on the collection * Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections. * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.reIndex = function(options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Execute using callback - if(typeof callback == 'function') return reIndex(self, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - reIndex(self, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var reIndex = function(self, options, callback) { - // Reindex - var cmd = {'reIndex':self.s.name}; - - // Execute the command - self.s.db.command(cmd, options, function(err, result) { - if(callback == null) return; - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, result.ok ? true : false); - }); -} - -define.classMethod('reIndex', {callback: true, promise:true}); + return executeOperation(this.s.topology, reIndex, [this, options, callback]); +}; /** * Get the list of all indexes information for the collection. * * @method - * @param {object} [options=null] Optional settings. - * @param {number} [options.batchSize=null] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {number} [options.batchSize] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @return {CommandCursor} */ Collection.prototype.listIndexes = function(options) { options = options || {}; // Clone the options - options = shallowClone(options); + options = Object.assign({}, options); // Determine the read preference in the options. - options = getReadPreference(this, options, this.s.db, this); + options.readPreference = resolveReadPreference(options, { db: this.s.db, collection: this }); // Set the CommandCursor constructor options.cursorFactory = CommandCursor; // Set the promiseLibrary options.promiseLibrary = this.s.promiseLibrary; - if(!this.s.topology.capabilities()) { + if (!this.s.topology.capabilities()) { throw new MongoError('cannot connect to server'); } + // Cursor options + let cursor = options.batchSize ? { batchSize: options.batchSize } : {}; + // We have a list collections command - if(this.s.topology.capabilities().hasListIndexesCommand) { - // Cursor options - var cursor = options.batchSize ? {batchSize: options.batchSize} : {} + if (this.s.topology.capabilities().hasListIndexesCommand) { // Build the command - var command = { listIndexes: this.s.name, cursor: cursor }; + const command = { listIndexes: this.s.name, cursor: cursor }; // Execute the cursor - cursor = this.s.topology.cursor(f('%s.$cmd', this.s.dbName), command, options); + cursor = this.s.topology.cursor(`${this.s.dbName}.$cmd`, command, options); // Do we have a readPreference, apply it - if(options.readPreference) cursor.setReadPreference(options.readPreference); + if (options.readPreference) cursor.setReadPreference(options.readPreference); // Return the cursor return cursor; } // Get the namespace - var ns = f('%s.system.indexes', this.s.dbName); + const ns = `${this.s.dbName}.system.indexes`; // Get the query - cursor = this.s.topology.cursor(ns, {find: ns, query: {ns: this.s.namespace}}, options); + cursor = this.s.topology.cursor(ns, { find: ns, query: { ns: this.s.namespace } }, options); // Do we have a readPreference, apply it - if(options.readPreference) cursor.setReadPreference(options.readPreference); + if (options.readPreference) cursor.setReadPreference(options.readPreference); // Set the passed in batch size if one was provided - if(options.batchSize) cursor = cursor.batchSize(options.batchSize); + if (options.batchSize) cursor = cursor.batchSize(options.batchSize); // Return the cursor return cursor; }; -define.classMethod('listIndexes', {callback: false, promise:false, returns: [CommandCursor]}); - /** * Ensures that an index exists, if it does not it creates it * @method * @deprecated use createIndexes instead * @param {(string|object)} fieldOrSpec Defines the index. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.unique=false] Creates an unique index. * @param {boolean} [options.sparse=false] Creates a sparse index. * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value - * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. - * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. - * @param {number} [options.v=null] Specify the format version of the indexes. - * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {number} [options.min] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.ensureIndex = function(fieldOrSpec, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; +Collection.prototype.ensureIndex = deprecate(function(fieldOrSpec, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Execute using callback - if(typeof callback == 'function') return ensureIndex(self, fieldOrSpec, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - ensureIndex(self, fieldOrSpec, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var ensureIndex = function(self, fieldOrSpec, options, callback) { - self.s.db.ensureIndex(self.s.name, fieldOrSpec, options, callback); -} - -define.classMethod('ensureIndex', {callback: true, promise:true}); + return executeOperation(this.s.topology, ensureIndex, [this, fieldOrSpec, options, callback]); +}, 'collection.ensureIndex is deprecated. Use createIndexes instead.'); /** * Checks if one or more indexes exist on the collection, fails on first non-existing index * @method * @param {(string|array)} indexes One or more index names to check. + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.indexExists = function(indexes, callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') return indexExists(self, indexes, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - indexExists(self, indexes, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var indexExists = function(self, indexes, callback) { - self.indexInformation(function(err, indexInformation) { - // If we have an error return - if(err != null) return handleCallback(callback, err, null); - // Let's check for the index names - if(!Array.isArray(indexes)) return handleCallback(callback, null, indexInformation[indexes] != null); - // Check in list of indexes - for(var i = 0; i < indexes.length; i++) { - if(indexInformation[indexes[i]] == null) { - return handleCallback(callback, null, false); - } - } - - // All keys found return true - return handleCallback(callback, null, true); - }); -} +Collection.prototype.indexExists = function(indexes, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('indexExists', {callback: true, promise:true}); + return executeOperation(this.s.topology, indexExists, [this, indexes, options, callback]); +}; /** * Retrieves this collections index info. * @method - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.full=false] Returns the full raw index information. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.indexInformation = function(options, callback) { - var self = this; - // Unpack calls - var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + const args = Array.prototype.slice.call(arguments, 0); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; options = args.length ? args.shift() || {} : {}; - // Execute using callback - if(typeof callback == 'function') return indexInformation(self, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - indexInformation(self, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var indexInformation = function(self, options, callback) { - self.s.db.indexInformation(self.s.name, options, callback); -} - -define.classMethod('indexInformation', {callback: true, promise:true}); + return executeOperation(this.s.topology, indexInformation, [this, options, callback]); +}; /** * The callback format for results @@ -1990,220 +1351,163 @@ define.classMethod('indexInformation', {callback: true, promise:true}); /** * Count number of matching documents in the db to a query. * @method - * @param {object} query The query for the count. - * @param {object} [options=null] Optional settings. - * @param {boolean} [options.limit=null] The limit of documents to count. - * @param {boolean} [options.skip=null] The number of documents to skip for the count. - * @param {string} [options.hint=null] An index name hint for the query. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {object} [query={}] The query for the count. + * @param {object} [options] Optional settings. + * @param {boolean} [options.limit] The limit of documents to count. + * @param {boolean} [options.skip] The number of documents to skip for the count. + * @param {string} [options.hint] An index name hint for the query. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~countCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed + * @deprecated use {@link Collection#countDocuments countDocuments} or {@link Collection#estimatedDocumentCount estimatedDocumentCount} instead */ -Collection.prototype.count = function(query, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - var queryOption = args.length ? args.shift() || {} : {}; - var optionsOption = args.length ? args.shift() || {} : {}; +Collection.prototype.count = deprecate(function(query, options, callback) { + const args = Array.prototype.slice.call(arguments, 0); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + query = args.length ? args.shift() || {} : {}; + options = args.length ? args.shift() || {} : {}; - // Execute using callback - if(typeof callback == 'function') return count(self, queryOption, optionsOption, callback); + return executeOperation(this.s.topology, count, [this, query, options, callback]); +}, 'collection.count is deprecated, and will be removed in a future version.' + + ' Use collection.countDocuments or collection.estimatedDocumentCount instead'); - // Check if query is empty - query = query || {}; +/** + * Gets an estimate of the count of documents in a collection using collection metadata. + * + * **Note**: When migrating from {@link Collection#count count} to {@link Collection#estimatedDocumentCount estimatedDocumentCount} + * the following query operators must be replaced: + * + * | Operator | Replacement | + * | -------- | ----------- | + * | `$where` | [`$expr`][1] | + * | `$near` | [`$geoWithin`][2] with [`$center`][3] | + * | `$nearSphere` | [`$geoWithin`][2] with [`$centerSphere`][4] | + * + * [1]: https://docs.mongodb.com/manual/reference/operator/query/expr/ + * [2]: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/ + * [3]: https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center + * [4]: https://docs.mongodb.com/manual/reference/operator/query/centerSphere/#op._S_centerSphere + * @method + * @param {object} [options] Optional settings. + * @param {number} [options.maxTimeMS] The maximum amount of time to allow the operation to run. + * @param {Collection~countCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed. + * @see https://docs.mongodb.com/manual/reference/operator/query/expr/ + * @see https://docs.mongodb.com/manual/reference/operator/query/geoWithin/ + * @see https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center + * @see https://docs.mongodb.com/manual/reference/operator/query/centerSphere/#op._S_centerSphere + */ +Collection.prototype.estimatedDocumentCount = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - count(self, query, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -var count = function(self, query, options, callback) { - var skip = options.skip; - var limit = options.limit; - var hint = options.hint; - var maxTimeMS = options.maxTimeMS; - - // Final query - var cmd = { - 'count': self.s.name, 'query': query - }; - - // Add limit, skip and maxTimeMS if defined - if(typeof skip == 'number') cmd.skip = skip; - if(typeof limit == 'number') cmd.limit = limit; - if(typeof maxTimeMS == 'number') cmd.maxTimeMS = maxTimeMS; - if(hint) cmd.hint = hint; - - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Do we have a readConcern specified - if(self.s.readConcern) { - cmd.readConcern = self.s.readConcern; - } + options = typeof options.maxTimeMS === 'number' ? options : {}; - // Have we specified collation - decorateWithCollation(cmd, self, options); + return executeOperation(this.s.topology, count, [this, null, options, callback]); +}; - // Execute command - self.s.db.command(cmd, options, function(err, result) { - if(err) return handleCallback(callback, err); - handleCallback(callback, null, result.n); - }); -} +/** + * Gets the number of documents matching the filter. + * + * **Note**: When migrating from {@link Collection#count count} to {@link Collection#countDocuments countDocuments} + * the following query operators must be replaced: + * + * | Operator | Replacement | + * | -------- | ----------- | + * | `$where` | [`$expr`][1] | + * | `$near` | [`$geoWithin`][2] with [`$center`][3] | + * | `$nearSphere` | [`$geoWithin`][2] with [`$centerSphere`][4] | + * + * [1]: https://docs.mongodb.com/manual/reference/operator/query/expr/ + * [2]: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/ + * [3]: https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center + * [4]: https://docs.mongodb.com/manual/reference/operator/query/centerSphere/#op._S_centerSphere + * + * @param {object} [query] the query for the count + * @param {object} [options] Optional settings. + * @param {object} [options.collation] Specifies a collation. + * @param {string|object} [options.hint] The index to use. + * @param {number} [options.limit] The maximum number of document to count. + * @param {number} [options.maxTimeMS] The maximum amount of time to allow the operation to run. + * @param {number} [options.skip] The number of documents to skip before counting. + * @param {Collection~countCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed. + * @see https://docs.mongodb.com/manual/reference/operator/query/expr/ + * @see https://docs.mongodb.com/manual/reference/operator/query/geoWithin/ + * @see https://docs.mongodb.com/manual/reference/operator/query/center/#op._S_center + * @see https://docs.mongodb.com/manual/reference/operator/query/centerSphere/#op._S_centerSphere + */ + +Collection.prototype.countDocuments = function(query, options, callback) { + const args = Array.prototype.slice.call(arguments, 0); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + query = args.length ? args.shift() || {} : {}; + options = args.length ? args.shift() || {} : {}; -define.classMethod('count', {callback: true, promise:true}); + return executeOperation(this.s.topology, countDocuments, [this, query, options, callback]); +}; /** * The distinct command returns returns a list of distinct values for the given key across a collection. * @method * @param {string} key Field of the document to find distinct values for. * @param {object} query The query for filtering the set of documents to which we apply the distinct filter. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.distinct = function(key, query, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - var queryOption = args.length ? args.shift() || {} : {}; - var optionsOption = args.length ? args.shift() || {} : {}; - - // Execute using callback - if(typeof callback == 'function') return distinct(self, key, queryOption, optionsOption, callback); - - // Ensure the query and options are set - query = query || {}; - options = options || {}; - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - distinct(self, key, query, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + const queryOption = args.length ? args.shift() || {} : {}; + const optionsOption = args.length ? args.shift() || {} : {}; + + return executeOperation(this.s.topology, distinct, [ + this, + key, + queryOption, + optionsOption, + callback + ]); }; -var distinct = function(self, key, query, options, callback) { - // maxTimeMS option - var maxTimeMS = options.maxTimeMS; - - // Distinct command - var cmd = { - 'distinct': self.s.name, 'key': key, 'query': query - }; - - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Add maxTimeMS if defined - if(typeof maxTimeMS == 'number') - cmd.maxTimeMS = maxTimeMS; - - // Do we have a readConcern specified - if(self.s.readConcern) { - cmd.readConcern = self.s.readConcern; - } - - // Have we specified collation - decorateWithCollation(cmd, self, options); - - // Execute the command - self.s.db.command(cmd, options, function(err, result) { - if(err) return handleCallback(callback, err); - handleCallback(callback, null, result.values); - }); -} - -define.classMethod('distinct', {callback: true, promise:true}); - /** * Retrieve all the indexes on the collection. * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Collection.prototype.indexes = function(callback) { - var self = this; - // Execute using callback - if(typeof callback == 'function') return indexes(self, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - indexes(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var indexes = function(self, callback) { - self.s.db.indexInformation(self.s.name, {full:true}, callback); -} +Collection.prototype.indexes = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('indexes', {callback: true, promise:true}); + return executeOperation(this.s.topology, indexes, [this, options, callback]); +}; /** * Get all the collection statistics. * * @method - * @param {object} [options=null] Optional settings. - * @param {number} [options.scale=null] Divide the returned sizes by scale value. + * @param {object} [options] Optional settings. + * @param {number} [options.scale] Divide the returned sizes by scale value. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.stats = function(options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - // Fetch all commands + const args = Array.prototype.slice.call(arguments, 0); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; options = args.length ? args.shift() || {} : {}; - // Execute using callback - if(typeof callback == 'function') return stats(self, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - stats(self, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var stats = function(self, options, callback) { - // Build command object - var commandObject = { - collStats:self.s.name - } - - // Check if we have the scale value - if(options['scale'] != null) commandObject['scale'] = options['scale']; - - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Execute the command - self.s.db.command(commandObject, options, callback); -} - -define.classMethod('stats', {callback: true, promise:true}); + return executeOperation(this.s.topology, stats, [this, options, callback]); +}; /** * @typedef {Object} Collection~findAndModifyWriteOpResult @@ -2224,51 +1528,24 @@ define.classMethod('stats', {callback: true, promise:true}); * * @method * @param {object} filter Document selection filter. - * @param {object} [options=null] Optional settings. - * @param {object} [options.projection=null] Limits the fields to return for all matching documents. - * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. - * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {object} [options] Optional settings. + * @param {object} [options.projection] Limits the fields to return for all matching documents. + * @param {object} [options.sort] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS] The maximum amount of time to allow the query to run. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.findOneAndDelete = function(filter, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Basic validation - if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); - - // Execute using callback - if(typeof callback == 'function') return findOneAndDelete(self, filter, options, callback); + if (filter == null || typeof filter !== 'object') + throw toError('filter parameter must be an object'); - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - options = options || {}; - - findOneAndDelete(self, filter, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var findOneAndDelete = function(self, filter, options, callback) { - // Final options - var finalOptions = shallowClone(options); - finalOptions['fields'] = options.projection; - finalOptions['remove'] = true; - // Execute find and Modify - self.findAndModify( - filter - , options.sort - , null - , finalOptions - , callback - ); -} - -define.classMethod('findOneAndDelete', {callback: true, promise:true}); + return executeOperation(this.s.topology, findOneAndDelete, [this, filter, options, callback]); +}; /** * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation. @@ -2276,57 +1553,34 @@ define.classMethod('findOneAndDelete', {callback: true, promise:true}); * @method * @param {object} filter Document selection filter. * @param {object} replacement Document replacing the matching document. - * @param {object} [options=null] Optional settings. - * @param {object} [options.projection=null] Limits the fields to return for all matching documents. - * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. - * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {object} [options] Optional settings. + * @param {object} [options.projection] Limits the fields to return for all matching documents. + * @param {object} [options.sort] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS] The maximum amount of time to allow the query to run. * @param {boolean} [options.upsert=false] Upsert the document if it does not exist. * @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.findOneAndReplace = function(filter, replacement, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Basic validation - if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); - if(replacement == null || typeof replacement != 'object') throw toError('replacement parameter must be an object'); - - // Execute using callback - if(typeof callback == 'function') return findOneAndReplace(self, filter, replacement, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - options = options || {}; - - findOneAndReplace(self, filter, replacement, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var findOneAndReplace = function(self, filter, replacement, options, callback) { - // Final options - var finalOptions = shallowClone(options); - finalOptions['fields'] = options.projection; - finalOptions['update'] = true; - finalOptions['new'] = typeof options.returnOriginal == 'boolean' ? !options.returnOriginal : false; - finalOptions['upsert'] = typeof options.upsert == 'boolean' ? options.upsert : false; - - // Execute findAndModify - self.findAndModify( - filter - , options.sort - , replacement - , finalOptions - , callback - ); -} - -define.classMethod('findOneAndReplace', {callback: true, promise:true}); + if (filter == null || typeof filter !== 'object') + throw toError('filter parameter must be an object'); + if (replacement == null || typeof replacement !== 'object') + throw toError('replacement parameter must be an object'); + + return executeOperation(this.s.topology, findOneAndReplace, [ + this, + filter, + replacement, + options, + callback + ]); +}; /** * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation. @@ -2334,57 +1588,41 @@ define.classMethod('findOneAndReplace', {callback: true, promise:true}); * @method * @param {object} filter Document selection filter. * @param {object} update Update operations to be performed on the document - * @param {object} [options=null] Optional settings. - * @param {object} [options.projection=null] Limits the fields to return for all matching documents. - * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. - * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {object} [options] Optional settings. + * @param {object} [options.projection] Limits the fields to return for all matching documents. + * @param {object} [options.sort] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS] The maximum amount of time to allow the query to run. * @param {boolean} [options.upsert=false] Upsert the document if it does not exist. * @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true. + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Array} [options.arrayFilters] optional list of array filters referenced in filtered positional operators * @param {Collection~findAndModifyCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.findOneAndUpdate = function(filter, update, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Basic validation - if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); - if(update == null || typeof update != 'object') throw toError('update parameter must be an object'); - - // Execute using callback - if(typeof callback == 'function') return findOneAndUpdate(self, filter, update, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - options = options || {}; - - findOneAndUpdate(self, filter, update, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var findOneAndUpdate = function(self, filter, update, options, callback) { - // Final options - var finalOptions = shallowClone(options); - finalOptions['fields'] = options.projection; - finalOptions['update'] = true; - finalOptions['new'] = options.returnOriginal !== void 0 ? !options.returnOriginal : false; - finalOptions['upsert'] = options.upsert !== void 0 ? !!options.upsert : false; - - // Execute findAndModify - self.findAndModify( - filter - , options.sort - , update - , finalOptions - , callback - ); -} - -define.classMethod('findOneAndUpdate', {callback: true, promise:true}); + if (filter == null || typeof filter !== 'object') + throw toError('filter parameter must be an object'); + if (update == null || typeof update !== 'object') + throw toError('update parameter must be an object'); + + const err = checkForAtomicOperators(update); + if (err) { + if (typeof callback === 'function') return callback(err); + return this.s.promiseLibrary.reject(err); + } + + return executeOperation(this.s.topology, findOneAndUpdate, [ + this, + filter, + update, + options, + callback + ]); +}; /** * Find and update a document. @@ -2392,327 +1630,240 @@ define.classMethod('findOneAndUpdate', {callback: true, promise:true}); * @param {object} query Query object to locate the object to modify. * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. * @param {object} doc The fields/vals to be updated. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.remove=false] Set to true to remove the object before returning. * @param {boolean} [options.upsert=false] Perform an upsert operation. * @param {boolean} [options.new=false] Set to true if you want to return the modified object rather than the original. Ignored for remove. - * @param {object} [options.fields=null] Object containing the field projection for the result returned from the operation. + * @param {object} [options.projection] Object containing the field projection for the result returned from the operation. + * @param {object} [options.fields] **Deprecated** Use `options.projection` instead + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Array} [options.arrayFilters] optional list of array filters referenced in filtered positional operators * @param {Collection~findAndModifyCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead */ -Collection.prototype.findAndModify = function(query, sort, doc, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); +Collection.prototype.findAndModify = deprecate(function(query, sort, doc, options, callback) { + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; sort = args.length ? args.shift() || [] : []; doc = args.length ? args.shift() : null; options = args.length ? args.shift() || {} : {}; // Clone options - options = shallowClone(options); + options = Object.assign({}, options); // Force read preference primary options.readPreference = ReadPreference.PRIMARY; - // Execute using callback - if(typeof callback == 'function') return findAndModify(self, query, sort, doc, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - options = options || {}; - - findAndModify(self, query, sort, doc, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var findAndModify = function(self, query, sort, doc, options, callback) { - // Create findAndModify command object - var queryObject = { - 'findandmodify': self.s.name - , 'query': query - }; - - sort = formattedOrderClause(sort); - if(sort) { - queryObject.sort = sort; - } - - queryObject.new = options.new ? true : false; - queryObject.remove = options.remove ? true : false; - queryObject.upsert = options.upsert ? true : false; - - if(options.fields) { - queryObject.fields = options.fields; - } - - if(doc && !options.remove) { - queryObject.update = doc; - } - - if(options.maxTimeMS) - queryObject.maxTimeMS = options.maxTimeMS; - - // Either use override on the function, or go back to default on either the collection - // level or db - if(options['serializeFunctions'] != null) { - options['serializeFunctions'] = options['serializeFunctions']; - } else { - options['serializeFunctions'] = self.s.serializeFunctions; - } - - // No check on the documents - options.checkKeys = false; - - // Get the write concern settings - var finalOptions = writeConcern(options, self.s.db, self, options); - - // Decorate the findAndModify command with the write Concern - if(finalOptions.writeConcern) { - queryObject.writeConcern = finalOptions.writeConcern; - } - - // Have we specified bypassDocumentValidation - if(typeof finalOptions.bypassDocumentValidation == 'boolean') { - queryObject.bypassDocumentValidation = finalOptions.bypassDocumentValidation; - } - - // Have we specified collation - decorateWithCollation(queryObject, self, options); - - // Execute the command - self.s.db.command(queryObject - , options, function(err, result) { - if(err) return handleCallback(callback, err, null); - return handleCallback(callback, null, result); - }); -} - -define.classMethod('findAndModify', {callback: true, promise:true}); + return executeOperation(this.s.topology, findAndModify, [ + this, + query, + sort, + doc, + options, + callback + ]); +}, 'collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.'); /** * Find and remove a document. * @method * @param {object} query Query object to locate the object to modify. * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed * @deprecated use findOneAndDelete instead */ -Collection.prototype.findAndRemove = function(query, sort, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); +Collection.prototype.findAndRemove = deprecate(function(query, sort, options, callback) { + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; sort = args.length ? args.shift() || [] : []; options = args.length ? args.shift() || {} : {}; - // Execute using callback - if(typeof callback == 'function') return findAndRemove(self, query, sort, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - findAndRemove(self, query, sort, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var findAndRemove = function(self, query, sort, options, callback) { - // Add the remove option - options['remove'] = true; - // Execute the callback - self.findAndModify(query, sort, null, options, callback); -} - -define.classMethod('findAndRemove', {callback: true, promise:true}); - -function decorateWithWriteConcern(command, self, options) { - // Do we support collation 3.4 and higher - var capabilities = self.s.topology.capabilities(); - // Do we support write concerns 3.4 and higher - if(capabilities && capabilities.commandsTakeWriteConcern) { - // Get the write concern settings - var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); - // Add the write concern to the command - if(finalOptions.writeConcern) { - command.writeConcern = finalOptions.writeConcern; - } - } -} - -function decorateWithCollation(command, self, options) { - // Do we support collation 3.4 and higher - var capabilities = self.s.topology.capabilities(); - // Do we support write concerns 3.4 and higher - if(capabilities && capabilities.commandsTakeCollation) { - if(options.collation && typeof options.collation == 'object') { - command.collation = options.collation; - } - } -} + return executeOperation(this.s.topology, findAndRemove, [this, query, sort, options, callback]); +}, 'collection.findAndRemove is deprecated. Use findOneAndDelete instead.'); /** * Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2 * @method - * @param {object} pipeline Array containing all the aggregation framework commands for the execution. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.cursor=null] Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor. - * @param {number} [options.cursor.batchSize=null] The batchSize for the cursor + * @param {object} [pipeline=[]] Array containing all the aggregation framework commands for the execution. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.cursor] Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor. + * @param {number} [options.cursor.batchSize] The batchSize for the cursor * @param {boolean} [options.explain=false] Explain returns the aggregation execution plan (requires mongodb 2.6 >). * @param {boolean} [options.allowDiskUse=false] allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >). - * @param {number} [options.maxTimeMS=null] maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + * @param {number} [options.maxTimeMS] maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). - * @param {Collection~resultCallback} callback The command result callback + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {string} [options.comment] Add a comment to an aggregation command + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Collection~aggregationCallback} callback The command result callback * @return {(null|AggregationCursor)} */ Collection.prototype.aggregate = function(pipeline, options, callback) { - var self = this; - - if(Array.isArray(pipeline)) { + if (Array.isArray(pipeline)) { // Set up callback if one is provided - if(typeof options == 'function') { + if (typeof options === 'function') { callback = options; options = {}; } // If we have no options or callback we are doing // a cursor based aggregation - if(options == null && callback == null) { + if (options == null && callback == null) { options = {}; } } else { // Aggregation pipeline passed as arguments on the method - var args = Array.prototype.slice.call(arguments, 0); + const args = Array.prototype.slice.call(arguments, 0); // Get the callback callback = args.pop(); // Get the possible options object - var opts = args[args.length - 1]; + const opts = args[args.length - 1]; // If it contains any of the admissible options pop it of the args - options = opts && (opts.readPreference - || opts.explain || opts.cursor || opts.out - || opts.maxTimeMS || opts.allowDiskUse) ? args.pop() : {}; - // Left over arguments is the pipeline + options = + opts && + (opts.readPreference || + opts.explain || + opts.cursor || + opts.out || + opts.maxTimeMS || + opts.hint || + opts.allowDiskUse) + ? args.pop() + : {}; + // Left over arguments is the pipeline pipeline = args; } // Ignore readConcern option - var ignoreReadConcern = false; + let ignoreReadConcern = false; // Build the command - var command = { aggregate : this.s.name, pipeline : pipeline}; + const command = { aggregate: this.s.name, pipeline: pipeline }; // If out was specified - if(typeof options.out == 'string') { - pipeline.push({$out: options.out}); + if (typeof options.out === 'string') { + pipeline.push({ $out: options.out }); // Ignore read concern ignoreReadConcern = true; - } else if(pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) { + } else if (pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) { ignoreReadConcern = true; } // Decorate command with writeConcern if out has been specified - if(pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) { - decorateWithWriteConcern(command, self, options); + if ( + pipeline.length > 0 && + pipeline[pipeline.length - 1]['$out'] && + this.s.topology.capabilities().commandsTakeWriteConcern + ) { + applyWriteConcern(command, { db: this.s.db, collection: this }, options); } // Have we specified collation - decorateWithCollation(command, self, options); + decorateWithCollation(command, this, options); // If we have bypassDocumentValidation set - if(typeof options.bypassDocumentValidation == 'boolean') { + if (options.bypassDocumentValidation === true) { command.bypassDocumentValidation = options.bypassDocumentValidation; } // Do we have a readConcern specified - if(!ignoreReadConcern && this.s.readConcern) { - command.readConcern = this.s.readConcern; + if (!ignoreReadConcern) { + decorateWithReadConcern(command, this, options); } // If we have allowDiskUse defined - if(options.allowDiskUse) command.allowDiskUse = options.allowDiskUse; - if(typeof options.maxTimeMS == 'number') command.maxTimeMS = options.maxTimeMS; + if (options.allowDiskUse) command.allowDiskUse = options.allowDiskUse; + if (typeof options.maxTimeMS === 'number') command.maxTimeMS = options.maxTimeMS; - options = shallowClone(options); + // If we are giving a hint + if (options.hint) command.hint = options.hint; + + options = Object.assign({}, options); // Ensure we have the right read preference inheritance - options = getReadPreference(this, options, this.s.db, this); + options.readPreference = resolveReadPreference(options, { db: this.s.db, collection: this }); // If explain has been specified add it - if (options.explain) command.explain = options.explain; + if (options.explain) { + if (command.readConcern || command.writeConcern) { + throw toError('"explain" cannot be used on an aggregate call with readConcern/writeConcern'); + } + command.explain = options.explain; + } + + if (typeof options.comment === 'string') command.comment = options.comment; // Validate that cursor options is valid - if(options.cursor != null && typeof options.cursor != 'object') { + if (options.cursor != null && typeof options.cursor !== 'object') { throw toError('cursor options must be an object'); } - if (this.s.topology.capabilities().hasAggregationCursor) { - options.cursor = options.cursor || { batchSize : 1000 }; - command.cursor = options.cursor; - } + options.cursor = options.cursor || {}; + if (options.batchSize) options.cursor.batchSize = options.batchSize; + command.cursor = options.cursor; // promiseLibrary options.promiseLibrary = this.s.promiseLibrary; // Set the AggregationCursor constructor options.cursorFactory = AggregationCursor; - if(typeof callback != 'function') { - if(!this.s.topology.capabilities()) { + if (typeof callback !== 'function') { + if (!this.s.topology.capabilities()) { throw new MongoError('cannot connect to server'); } // Allow disk usage command - if(typeof options.allowDiskUse == 'boolean') command.allowDiskUse = options.allowDiskUse; - if(typeof options.maxTimeMS == 'number') command.maxTimeMS = options.maxTimeMS; + if (typeof options.allowDiskUse === 'boolean') command.allowDiskUse = options.allowDiskUse; + if (typeof options.maxTimeMS === 'number') command.maxTimeMS = options.maxTimeMS; // Execute the cursor return this.s.topology.cursor(this.s.namespace, command, options); } - if (options.cursor) { - var cursor = this.s.topology.cursor(this.s.namespace, command, options); - return cursor.toArray(function(err, result) { - if (err) { - return handleCallback(callback, err); - } + return handleCallback(callback, null, this.s.topology.cursor(this.s.namespace, command, options)); +}; - handleCallback(callback, null, result); - }); - } +/** + * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this collection. + * @method + * @since 3.0.0 + * @param {Array} [pipeline] An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents. + * @param {object} [options] Optional settings + * @param {string} [options.fullDocument='default'] Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred. + * @param {object} [options.resumeAfter] Specifies the logical starting point for the new change stream. This should be the _id field from a previously returned change stream document. + * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a change stream query + * @param {number} [options.batchSize] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {ReadPreference} [options.readPreference] The read preference. Defaults to the read preference of the database or collection. See {@link https://docs.mongodb.com/manual/reference/read-preference|read preference documentation}. + * @param {Timestamp} [options.startAtClusterTime] receive change events that occur after the specified timestamp + * @param {ClientSession} [options.session] optional session to use for this operation + * @return {ChangeStream} a ChangeStream instance. + */ +Collection.prototype.watch = function(pipeline, options) { + pipeline = pipeline || []; + options = options || {}; - // For legacy server versions, we execute the command and format the result - this.s.db.command(command, options, function(err, result) { - if(err) { - handleCallback(callback, err); - } else if(result['err'] || result['errmsg']) { - handleCallback(callback, toError(result)); - } else if(typeof result == 'object' && result['serverPipeline']) { - handleCallback(callback, null, result['serverPipeline']); - } else if(typeof result == 'object' && result['stages']) { - handleCallback(callback, null, result['stages']); - } else { - handleCallback(callback, null, result.result); - } - }); -} + // Allow optionally not specifying a pipeline + if (!Array.isArray(pipeline)) { + options = pipeline; + pipeline = []; + } -define.classMethod('aggregate', {callback: true, promise:false}); + return new ChangeStream(this, pipeline, options); +}; /** * The callback format for results @@ -2725,161 +1876,35 @@ define.classMethod('aggregate', {callback: true, promise:false}); * Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are * no ordering guarantees for returned results. * @method - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.batchSize=null] Set the batchSize for the getMoreCommand when iterating over the query results. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.batchSize] Set the batchSize for the getMoreCommand when iterating over the query results. * @param {number} [options.numCursors=1] The maximum number of parallel command cursors to return (the number of returned cursors will be in the range 1:numCursors) * @param {boolean} [options.raw=false] Return all BSON documents as Raw Buffer documents. * @param {Collection~parallelCollectionScanCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.parallelCollectionScan = function(options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {numCursors: 1}; + if (typeof options === 'function') (callback = options), (options = { numCursors: 1 }); // Set number of cursors to 1 options.numCursors = options.numCursors || 1; options.batchSize = options.batchSize || 1000; - options = shallowClone(options); + options = Object.assign({}, options); // Ensure we have the right read preference inheritance - options = getReadPreference(this, options, this.s.db, this); + options.readPreference = resolveReadPreference(options, { db: this.s.db, collection: this }); // Add a promiseLibrary options.promiseLibrary = this.s.promiseLibrary; - // Execute using callback - if(typeof callback == 'function') return parallelCollectionScan(self, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - parallelCollectionScan(self, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var parallelCollectionScan = function(self, options, callback) { - // Create command object - var commandObject = { - parallelCollectionScan: self.s.name - , numCursors: options.numCursors - } - - // Do we have a readConcern specified - if(self.s.readConcern) { - commandObject.readConcern = self.s.readConcern; - } - - // Store the raw value - var raw = options.raw; - delete options['raw']; - - // Execute the command - self.s.db.command(commandObject, options, function(err, result) { - if(err) return handleCallback(callback, err, null); - if(result == null) return handleCallback(callback, new Error("no result returned for parallelCollectionScan"), null); - - var cursors = []; - // Add the raw back to the option - if(raw) options.raw = raw; - // Create command cursors for each item - for(var i = 0; i < result.cursors.length; i++) { - var rawId = result.cursors[i].cursor.id - // Convert cursorId to Long if needed - var cursorId = typeof rawId == 'number' ? Long.fromNumber(rawId) : rawId; - // Add a command cursor - cursors.push(self.s.topology.cursor(self.s.namespace, cursorId, options)); - } - - handleCallback(callback, null, cursors); - }); -} - -define.classMethod('parallelCollectionScan', {callback: true, promise:true}); - -/** - * Execute the geoNear command to search for items in the collection - * - * @method - * @param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order. - * @param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.num=null] Max number of results to return. - * @param {number} [options.minDistance=null] Include results starting at minDistance from a point (2.6 or higher) - * @param {number} [options.maxDistance=null] Include results up to maxDistance from the point. - * @param {number} [options.distanceMultiplier=null] Include a value to multiply the distances with allowing for range conversions. - * @param {object} [options.query=null] Filter the results by a query. - * @param {boolean} [options.spherical=false] Perform query using a spherical model. - * @param {boolean} [options.uniqueDocs=false] The closest location in a document to the center of the search region will always be returned MongoDB > 2.X. - * @param {boolean} [options.includeLocs=false] Include the location data fields in the top level of the results MongoDB > 2.X. - * @param {Collection~resultCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed - */ -Collection.prototype.geoNear = function(x, y, options, callback) { - var self = this; - var point = typeof(x) == 'object' && x - , args = Array.prototype.slice.call(arguments, point?1:2); - - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - // Fetch all commands - options = args.length ? args.shift() || {} : {}; - - // Execute using callback - if(typeof callback == 'function') return geoNear(self, x, y, point, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - geoNear(self, x, y, point, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var geoNear = function(self, x, y, point, options, callback) { - // Build command object - var commandObject = { - geoNear:self.s.name, - near: point || [x, y] + if (options.session) { + options.session = undefined; } - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Exclude readPreference and existing options to prevent user from - // shooting themselves in the foot - var exclude = { - readPreference: true, - geoNear: true, - near: true - }; - - // Filter out any excluded objects - commandObject = decorateCommand(commandObject, options, exclude); - - // Do we have a readConcern specified - if(self.s.readConcern) { - commandObject.readConcern = self.s.readConcern; - } - - // Have we specified collation - decorateWithCollation(commandObject, self, options); - - // Execute the command - self.s.db.command(commandObject, options, function (err, res) { - if(err) return handleCallback(callback, err); - if(res.err || res.errmsg) return handleCallback(callback, toError(res)); - // should we only be returning res.results here? Not sure if the user - // should see the other return information - handleCallback(callback, null, res); + return executeOperation(this.s.topology, parallelCollectionScan, [this, options, callback], { + skipSessions: true }); -} - -define.classMethod('geoNear', {callback: true, promise:true}); +}; /** * Execute a geo search using a geo haystack index on a collection. @@ -2887,97 +1912,22 @@ define.classMethod('geoNear', {callback: true, promise:true}); * @method * @param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order. * @param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {number} [options.maxDistance=null] Include results up to maxDistance from the point. - * @param {object} [options.search=null] Filter the results by a query. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxDistance] Include results up to maxDistance from the point. + * @param {object} [options.search] Filter the results by a query. * @param {number} [options.limit=false] Max number of results to return. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Collection.prototype.geoHaystackSearch = function(x, y, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - // Fetch all commands + const args = Array.prototype.slice.call(arguments, 2); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; options = args.length ? args.shift() || {} : {}; - // Execute using callback - if(typeof callback == 'function') return geoHaystackSearch(self, x, y, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - geoHaystackSearch(self, x, y, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var geoHaystackSearch = function(self, x, y, options, callback) { - // Build command object - var commandObject = { - geoSearch: self.s.name, - near: [x, y] - } - - // Remove read preference from hash if it exists - commandObject = decorateCommand(commandObject, options, {readPreference: true}); - - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Do we have a readConcern specified - if(self.s.readConcern) { - commandObject.readConcern = self.s.readConcern; - } - - // Execute the command - self.s.db.command(commandObject, options, function (err, res) { - if(err) return handleCallback(callback, err); - if(res.err || res.errmsg) handleCallback(callback, toError(res)); - // should we only be returning res.results here? Not sure if the user - // should see the other return information - handleCallback(callback, null, res); - }); -} - -define.classMethod('geoHaystackSearch', {callback: true, promise:true}); - -/** - * Group function helper - * @ignore - */ -// var groupFunction = function () { -// var c = db[ns].find(condition); -// var map = new Map(); -// var reduce_function = reduce; -// -// while (c.hasNext()) { -// var obj = c.next(); -// var key = {}; -// -// for (var i = 0, len = keys.length; i < len; ++i) { -// var k = keys[i]; -// key[k] = obj[k]; -// } -// -// var aggObj = map.get(key); -// -// if (aggObj == null) { -// var newObj = Object.extend({}, key); -// aggObj = Object.extend(newObj, initial); -// map.put(key, aggObj); -// } -// -// reduce_function(obj, aggObj); -// } -// -// return { "result": map.values() }; -// }.toString(); -var groupFunction = 'function () {\nvar c = db[ns].find(condition);\nvar map = new Map();\nvar reduce_function = reduce;\n\nwhile (c.hasNext()) {\nvar obj = c.next();\nvar key = {};\n\nfor (var i = 0, len = keys.length; i < len; ++i) {\nvar k = keys[i];\nkey[k] = obj[k];\n}\n\nvar aggObj = map.get(key);\n\nif (aggObj == null) {\nvar newObj = Object.extend({}, key);\naggObj = Object.extend(newObj, initial);\nmap.put(key, aggObj);\n}\n\nreduce_function(obj, aggObj);\n}\n\nreturn { "result": map.values() };\n}'; + return executeOperation(this.s.topology, geoHaystackSearch, [this, x, y, options, callback]); +}; /** * Run a group command across a collection @@ -2989,153 +1939,69 @@ var groupFunction = 'function () {\nvar c = db[ns].find(condition);\nvar map = n * @param {(function|Code)} reduce The reduce function aggregates (reduces) the objects iterated * @param {(function|Code)} finalize An optional function to be run on each item in the result set just before the item is returned. * @param {boolean} command Specify if you wish to run using the internal group command or using eval, default is true. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed - * @deprecated MongoDB 3.6 or higher will no longer support the group command. We recommend rewriting using the aggregation framework. - */ -Collection.prototype.group = function(keys, condition, initial, reduce, finalize, command, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 3); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - // Fetch all commands + * @deprecated MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework. + */ +Collection.prototype.group = deprecate(function( + keys, + condition, + initial, + reduce, + finalize, + command, + options, + callback +) { + const args = Array.prototype.slice.call(arguments, 3); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; reduce = args.length ? args.shift() : null; finalize = args.length ? args.shift() : null; command = args.length ? args.shift() : null; options = args.length ? args.shift() || {} : {}; // Make sure we are backward compatible - if(!(typeof finalize == 'function')) { + if (!(typeof finalize === 'function')) { command = finalize; finalize = null; } - if (!Array.isArray(keys) && keys instanceof Object && typeof(keys) !== 'function' && !(keys._bsontype == 'Code')) { + if ( + !Array.isArray(keys) && + keys instanceof Object && + typeof keys !== 'function' && + !(keys._bsontype === 'Code') + ) { keys = Object.keys(keys); } - if(typeof reduce === 'function') { + if (typeof reduce === 'function') { reduce = reduce.toString(); } - if(typeof finalize === 'function') { + if (typeof finalize === 'function') { finalize = finalize.toString(); } // Set up the command as default command = command == null ? true : command; - // Execute using callback - if(typeof callback == 'function') return group(self, keys, condition, initial, reduce, finalize, command, options, callback); - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - group(self, keys, condition, initial, reduce, finalize, command, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -var group = function(self, keys, condition, initial, reduce, finalize, command, options, callback) { - // Execute using the command - if(command) { - var reduceFunction = reduce && reduce._bsontype == 'Code' - ? reduce - : new Code(reduce); - - var selector = { - group: { - 'ns': self.s.name - , '$reduce': reduceFunction - , 'cond': condition - , 'initial': initial - , 'out': "inline" - } - }; - - // if finalize is defined - if(finalize != null) selector.group['finalize'] = finalize; - // Set up group selector - if ('function' === typeof keys || (keys && keys._bsontype == 'Code')) { - selector.group.$keyf = keys && keys._bsontype == 'Code' - ? keys - : new Code(keys); - } else { - var hash = {}; - keys.forEach(function (key) { - hash[key] = 1; - }); - selector.group.key = hash; - } - - options = shallowClone(options); - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // Do we have a readConcern specified - if(self.s.readConcern) { - selector.readConcern = self.s.readConcern; - } - - // Have we specified collation - decorateWithCollation(selector, self, options); - - // Execute command - self.s.db.command(selector, options, function(err, result) { - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, result.retval); - }); - } else { - // Create execution scope - var scope = reduce != null && reduce._bsontype == 'Code' - ? reduce.scope - : {}; - - scope.ns = self.s.name; - scope.keys = keys; - scope.condition = condition; - scope.initial = initial; - - // Pass in the function text to execute within mongodb. - var groupfn = groupFunction.replace(/ reduce;/, reduce.toString() + ';'); - - self.s.db.eval(new Code(groupfn, scope), function (err, results) { - if (err) return handleCallback(callback, err, null); - handleCallback(callback, null, results.result || results); - }); - } -} - -define.classMethod('group', {callback: true, promise:true}); - -/** - * Functions that are passed as scope args must - * be converted to Code instances. - * @ignore - */ -function processScope (scope) { - if(!isObject(scope) || scope._bsontype == 'ObjectID') { - return scope; - } - - var keys = Object.keys(scope); - var i = keys.length; - var key; - var new_scope = {}; - - while (i--) { - key = keys[i]; - if ('function' == typeof scope[key]) { - new_scope[key] = new Code(String(scope[key])); - } else { - new_scope[key] = processScope(scope[key]); - } - } - - return new_scope; -} + return executeOperation(this.s.topology, group, [ + this, + keys, + condition, + initial, + reduce, + finalize, + command, + options, + callback + ]); +}, +'MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework.'); /** * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection. @@ -3143,175 +2009,73 @@ function processScope (scope) { * @method * @param {(function|string)} map The mapping function. * @param {(function|string)} reduce The reduce function. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.out=null] Sets the output target for the map reduce job. *{inline:1} | {replace:'collectionName'} | {merge:'collectionName'} | {reduce:'collectionName'}* - * @param {object} [options.query=null] Query filter object. - * @param {object} [options.sort=null] Sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces. - * @param {number} [options.limit=null] Number of objects to return from collection. + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.out] Sets the output target for the map reduce job. *{inline:1} | {replace:'collectionName'} | {merge:'collectionName'} | {reduce:'collectionName'}* + * @param {object} [options.query] Query filter object. + * @param {object} [options.sort] Sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces. + * @param {number} [options.limit] Number of objects to return from collection. * @param {boolean} [options.keeptemp=false] Keep temporary data. - * @param {(function|string)} [options.finalize=null] Finalize function. - * @param {object} [options.scope=null] Can pass in variables that can be access from map/reduce/finalize. + * @param {(function|string)} [options.finalize] Finalize function. + * @param {object} [options.scope] Can pass in variables that can be access from map/reduce/finalize. * @param {boolean} [options.jsMode=false] It is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X. * @param {boolean} [options.verbose=false] Provide statistics on job execution time. * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Collection~resultCallback} [callback] The command result callback * @throws {MongoError} * @return {Promise} returns Promise if no callback passed */ Collection.prototype.mapReduce = function(map, reduce, options, callback) { - var self = this; - if('function' === typeof options) callback = options, options = {}; + if ('function' === typeof options) (callback = options), (options = {}); // Out must allways be defined (make sure we don't break weirdly on pre 1.8+ servers) - if(null == options.out) { - throw new Error("the out option parameter must be defined, see mongodb docs for possible values"); + if (null == options.out) { + throw new Error( + 'the out option parameter must be defined, see mongodb docs for possible values' + ); } - if('function' === typeof map) { + if ('function' === typeof map) { map = map.toString(); } - if('function' === typeof reduce) { + if ('function' === typeof reduce) { reduce = reduce.toString(); } - if('function' === typeof options.finalize) { + if ('function' === typeof options.finalize) { options.finalize = options.finalize.toString(); } - // Execute using callback - if(typeof callback == 'function') return mapReduce(self, map, reduce, options, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - mapReduce(self, map, reduce, options, function(err, r, r1) { - if(err) return reject(err); - if(!r1) return resolve(r); - resolve({results: r, stats: r1}); - }); - }); -} - -var mapReduce = function(self, map, reduce, options, callback) { - var mapCommandHash = { - mapreduce: self.s.name - , map: map - , reduce: reduce - }; - - // Exclusion list - var exclusionList = ['readPreference']; - - // Add any other options passed in - for(var n in options) { - if('scope' == n) { - mapCommandHash[n] = processScope(options[n]); - } else { - // Only include if not in exclusion list - if(exclusionList.indexOf(n) == -1) { - mapCommandHash[n] = options[n]; - } - } - } - - options = shallowClone(options); - - // Ensure we have the right read preference inheritance - options = getReadPreference(self, options, self.s.db, self); - - // If we have a read preference and inline is not set as output fail hard - if((options.readPreference != false && options.readPreference != 'primary') - && options['out'] && (options['out'].inline != 1 && options['out'] != 'inline')) { - // Force readPreference to primary - options.readPreference = 'primary'; - // Decorate command with writeConcern if supported - decorateWithWriteConcern(mapCommandHash, self, options); - } else if(self.s.readConcern) { - mapCommandHash.readConcern = self.s.readConcern; - } - - // Is bypassDocumentValidation specified - if(typeof options.bypassDocumentValidation == 'boolean') { - mapCommandHash.bypassDocumentValidation = options.bypassDocumentValidation; - } - - // Have we specified collation - decorateWithCollation(mapCommandHash, self, options); - - // Execute command - self.s.db.command(mapCommandHash, {readPreference:options.readPreference}, function (err, result) { - if(err) return handleCallback(callback, err); - // Check if we have an error - if(1 != result.ok || result.err || result.errmsg) { - return handleCallback(callback, toError(result)); - } - - // Create statistics value - var stats = {}; - if(result.timeMillis) stats['processtime'] = result.timeMillis; - if(result.counts) stats['counts'] = result.counts; - if(result.timing) stats['timing'] = result.timing; - - // invoked with inline? - if(result.results) { - // If we wish for no verbosity - if(options['verbose'] == null || !options['verbose']) { - return handleCallback(callback, null, result.results); - } - - return handleCallback(callback, null, result.results, stats); - } - - // The returned collection - var collection = null; - - // If we have an object it's a different db - if(result.result != null && typeof result.result == 'object') { - var doc = result.result; - collection = self.s.db.db(doc.db).collection(doc.collection); - } else { - // Create a collection object that wraps the result collection - collection = self.s.db.collection(result.result) - } - - // If we wish for no verbosity - if(options['verbose'] == null || !options['verbose']) { - return handleCallback(callback, err, collection); - } - - // Return stats as third set of values - handleCallback(callback, err, collection, stats); - }); -} - -define.classMethod('mapReduce', {callback: true, promise:true}); + return executeOperation(this.s.topology, mapReduce, [this, map, reduce, options, callback]); +}; /** - * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order. + * Initiate an Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order. * * @method - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @return {UnorderedBulkOperation} */ Collection.prototype.initializeUnorderedBulkOp = function(options) { options = options || {}; options.promiseLibrary = this.s.promiseLibrary; return unordered(this.s.topology, this, options); -} - -define.classMethod('initializeUnorderedBulkOp', {callback: false, promise:false, returns: [ordered.UnorderedBulkOperation]}); +}; /** - * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types. + * Initiate an In order bulk write operation. Operations will be serially executed in the order they are added, creating a new operation for each switch in types. * * @method - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {OrderedBulkOperation} callback The command result callback * @return {null} */ @@ -3319,59 +2083,16 @@ Collection.prototype.initializeOrderedBulkOp = function(options) { options = options || {}; options.promiseLibrary = this.s.promiseLibrary; return ordered(this.s.topology, this, options); -} - -define.classMethod('initializeOrderedBulkOp', {callback: false, promise:false, returns: [ordered.OrderedBulkOperation]}); - -// Get write concern -var writeConcern = function(target, db, col, options) { - if(options.w != null || options.j != null || options.fsync != null) { - var opts = {}; - if(options.w != null) opts.w = options.w; - if(options.wtimeout != null) opts.wtimeout = options.wtimeout; - if(options.j != null) opts.j = options.j; - if(options.fsync != null) opts.fsync = options.fsync; - target.writeConcern = opts; - } else if(col.writeConcern.w != null || col.writeConcern.j != null || col.writeConcern.fsync != null) { - target.writeConcern = col.writeConcern; - } else if(db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null) { - target.writeConcern = db.writeConcern; - } - - return target -} - -// Figure out the read preference -var getReadPreference = function(self, options, db) { - var r = null - if(options.readPreference) { - r = options.readPreference - } else if(self.s.readPreference) { - r = self.s.readPreference - } else if(db.s.readPreference) { - r = db.s.readPreference; - } - - if(r instanceof ReadPreference) { - options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); - } else if(typeof r == 'string') { - options.readPreference = new CoreReadPreference(r); - } else if(r && !(r instanceof ReadPreference) && typeof r == 'object') { - var mode = r.mode || r.preference; - if (mode && typeof mode == 'string') { - options.readPreference = new CoreReadPreference(mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); - } - } - - return options; -} +}; -var testForFields = { - limit: 1, sort: 1, fields:1, skip: 1, hint: 1, explain: 1, snapshot: 1, timeout: 1, tailable: 1, tailableRetryInterval: 1 - , numberOfRetries: 1, awaitdata: 1, awaitData: 1, exhaust: 1, batchSize: 1, returnKey: 1, maxScan: 1, min: 1, max: 1, showDiskLoc: 1 - , comment: 1, raw: 1, readPreference: 1, partial: 1, read: 1, dbName: 1, oplogReplay: 1, connection: 1, maxTimeMS: 1, transforms: 1 - , collation: 1 - , noCursorTimeout: 1 -} +/** + * Return the db logger + * @method + * @return {Logger} return the db logger + * @ignore + */ +Collection.prototype.getLogger = function() { + return this.s.db.s.logger; +}; module.exports = Collection; diff --git a/node_modules/mongodb/lib/command_cursor.js b/node_modules/mongodb/lib/command_cursor.js index a29d1fc..50afb6f 100644 --- a/node_modules/mongodb/lib/command_cursor.js +++ b/node_modules/mongodb/lib/command_cursor.js @@ -1,12 +1,10 @@ -"use strict"; +'use strict'; -var inherits = require('util').inherits - , ReadPreference = require('./read_preference') - , MongoError = require('mongodb-core').MongoError - , Readable = require('stream').Readable || require('readable-stream').Readable - , Define = require('./metadata') - , CoreCursor = require('./cursor') - , CoreReadPreference = require('mongodb-core').ReadPreference; +const inherits = require('util').inherits; +const ReadPreference = require('mongodb-core').ReadPreference; +const MongoError = require('mongodb-core').MongoError; +const Readable = require('stream').Readable; +const CoreCursor = require('./cursor'); /** * @fileOverview The **CommandCursor** class is an internal class that embodies a @@ -16,24 +14,25 @@ var inherits = require('util').inherits * * **CommandCursor Cannot directly be instantiated** * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { + * MongoClient.connect(url, function(err, client) { * // Create a collection we want to drop later - * var col = db.collection('listCollectionsExample1'); + * const col = client.db(dbName).collection('listCollectionsExample1'); * // Insert a bunch of documents * col.insert([{a:1, b:1} * , {a:2, b:2}, {a:3, b:3} * , {a:4, b:4}], {w:1}, function(err, result) { * test.equal(null, err); - * * // List the database collections available * db.listCollections().toArray(function(err, items) { * test.equal(null, err); - * db.close(); + * client.close(); * }); * }); * }); @@ -63,41 +62,37 @@ var CommandCursor = function(bson, ns, cmd, options, topology, topologyOptions) var maxTimeMS = null; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + var promiseLibrary = options.promiseLibrary || Promise; // Set up - Readable.call(this, {objectMode: true}); + Readable.call(this, { objectMode: true }); // Internal state this.s = { // MaxTimeMS - maxTimeMS: maxTimeMS + maxTimeMS: maxTimeMS, // State - , state: state + state: state, // Stream options - , streamOptions: streamOptions + streamOptions: streamOptions, // BSON - , bson: bson + bson: bson, // Namespace - , ns: ns + ns: ns, // Command - , cmd: cmd + cmd: cmd, // Options - , options: options + options: options, // Topology - , topology: topology + topology: topology, // Topology Options - , topologyOptions: topologyOptions + topologyOptions: topologyOptions, // Promise library - , promiseLibrary: promiseLibrary - } -} + promiseLibrary: promiseLibrary, + // Optional ClientSession + session: options.session + }; +}; /** * CommandCursor stream data event, fired for each document in the cursor. @@ -131,17 +126,36 @@ var CommandCursor = function(bson, ns, cmd, options, topology, topologyOptions) inherits(CommandCursor, Readable); // Set the methods to inherit from prototype -var methodsToInherit = ['_next', 'next', 'hasNext', 'each', 'forEach', 'toArray' - , 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill', 'setCursorBatchSize' - , '_find', '_getmore', '_killcursor', 'isDead', 'explain', 'isNotified', 'isKilled']; +var methodsToInherit = [ + '_next', + 'next', + 'hasNext', + 'each', + 'forEach', + 'toArray', + 'rewind', + 'bufferedCount', + 'readBufferedDocuments', + 'close', + 'isClosed', + 'kill', + 'setCursorBatchSize', + '_find', + '_getmore', + '_killcursor', + 'isDead', + 'explain', + 'isNotified', + 'isKilled', + '_endSession', + '_initImplicitSession' +]; // Only inherit the types we need -for(var i = 0; i < methodsToInherit.length; i++) { +for (var i = 0; i < methodsToInherit.length; i++) { CommandCursor.prototype[methodsToInherit[i]] = CoreCursor.prototype[methodsToInherit[i]]; } -var define = CommandCursor.define = new Define('CommandCursor', CommandCursor, true); - /** * Set the ReadPreference for the cursor. * @method @@ -149,22 +163,28 @@ var define = CommandCursor.define = new Define('CommandCursor', CommandCursor, t * @throws {MongoError} * @return {Cursor} */ -CommandCursor.prototype.setReadPreference = function(r) { - if(this.s.state == CommandCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(this.s.state != CommandCursor.INIT) throw MongoError.create({message: 'cannot change cursor readPreference after cursor has been accessed', driver:true}); - - if(r instanceof ReadPreference) { - this.s.options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); - } else if(typeof r == 'string') { - this.s.options.readPreference = new CoreReadPreference(r); - } else if(r instanceof CoreReadPreference) { - this.s.options.readPreference = r; +CommandCursor.prototype.setReadPreference = function(readPreference) { + if (this.s.state === CommandCursor.CLOSED || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); } - return this; -} + if (this.s.state !== CommandCursor.INIT) { + throw MongoError.create({ + message: 'cannot change cursor readPreference after cursor has been accessed', + driver: true + }); + } + + if (readPreference instanceof ReadPreference) { + this.s.options.readPreference = readPreference; + } else if (typeof readPreference === 'string') { + this.s.options.readPreference = new ReadPreference(readPreference); + } else { + throw new TypeError('Invalid read preference: ' + readPreference); + } -define.classMethod('setReadPreference', {callback: false, promise:false, returns: [CommandCursor]}); + return this; +}; /** * Set the batch size for the cursor. @@ -174,14 +194,14 @@ define.classMethod('setReadPreference', {callback: false, promise:false, returns * @return {CommandCursor} */ CommandCursor.prototype.batchSize = function(value) { - if(this.s.state == CommandCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true}); - if(this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; + if (this.s.state === CommandCursor.CLOSED || this.isDead()) + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + if (typeof value !== 'number') + throw MongoError.create({ message: 'batchSize requires an integer', driver: true }); + if (this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; this.setCursorBatchSize(value); return this; -} - -define.classMethod('batchSize', {callback: false, promise:false, returns: [CommandCursor]}); +}; /** * Add a maxTimeMS stage to the aggregation pipeline @@ -190,30 +210,24 @@ define.classMethod('batchSize', {callback: false, promise:false, returns: [Comma * @return {CommandCursor} */ CommandCursor.prototype.maxTimeMS = function(value) { - if(this.s.topology.lastIsMaster().minWireVersion > 2) { + if (this.s.topology.lastIsMaster().minWireVersion > 2) { this.s.cmd.maxTimeMS = value; } return this; -} +}; -define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [CommandCursor]}); +/** + * Return the cursor logger + * @method + * @return {Logger} return the cursor logger + * @ignore + */ +CommandCursor.prototype.getLogger = function() { + return this.logger; +}; CommandCursor.prototype.get = CommandCursor.prototype.toArray; -define.classMethod('get', {callback: true, promise:false}); - -// Inherited methods -define.classMethod('toArray', {callback: true, promise:true}); -define.classMethod('each', {callback: true, promise:false}); -define.classMethod('forEach', {callback: true, promise:false}); -define.classMethod('next', {callback: true, promise:true}); -define.classMethod('hasNext', {callback: true, promise:true}); -define.classMethod('close', {callback: true, promise:true}); -define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); -define.classMethod('rewind', {callback: false, promise:false}); -define.classMethod('bufferedCount', {callback: false, promise:false, returns: [Number]}); -define.classMethod('readBufferedDocuments', {callback: false, promise:false, returns: [Array]}); - /** * Get the next available document from the cursor, returns null if no more documents are available. * @function CommandCursor.prototype.next @@ -240,7 +254,7 @@ define.classMethod('readBufferedDocuments', {callback: false, promise:false, ret /** * Returns an array of documents. The caller is responsible for making sure that there * is enough memory to store the results. Note that the array only contain partial - * results when this cursor had been previously accessed. + * results when this cursor had been previouly accessed. * @method CommandCursor.prototype.toArray * @param {CommandCursor~toArrayResultCallback} [callback] The result callback. * @throws {MongoError} @@ -256,7 +270,7 @@ define.classMethod('readBufferedDocuments', {callback: false, promise:false, ret /** * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, - * not all of the elements will be iterated if this cursor had been previously accessed. + * not all of the elements will be iterated if this cursor had been previouly accessed. * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements * at any given time if batch size is specified. Otherwise, the caller is responsible diff --git a/node_modules/mongodb/lib/cursor.js b/node_modules/mongodb/lib/cursor.js index 9a9bd4d..6929321 100644 --- a/node_modules/mongodb/lib/cursor.js +++ b/node_modules/mongodb/lib/cursor.js @@ -1,44 +1,51 @@ -"use strict"; - -var inherits = require('util').inherits - , f = require('util').format - , formattedOrderClause = require('./utils').formattedOrderClause - , handleCallback = require('./utils').handleCallback - , ReadPreference = require('./read_preference') - , MongoError = require('mongodb-core').MongoError - , Readable = require('stream').Readable || require('readable-stream').Readable - , Define = require('./metadata') - , CoreCursor = require('mongodb-core').Cursor - , Map = require('mongodb-core').BSON.Map - , CoreReadPreference = require('mongodb-core').ReadPreference; +'use strict'; + +const Transform = require('stream').Transform; +const PassThrough = require('stream').PassThrough; +const inherits = require('util').inherits; +const deprecate = require('util').deprecate; +const handleCallback = require('./utils').handleCallback; +const ReadPreference = require('mongodb-core').ReadPreference; +const MongoError = require('mongodb-core').MongoError; +const Readable = require('stream').Readable; +const CoreCursor = require('mongodb-core').Cursor; +const Map = require('mongodb-core').BSON.Map; +const executeOperation = require('./utils').executeOperation; + +const count = require('./operations/cursor_ops').count; +const each = require('./operations/cursor_ops').each; +const hasNext = require('./operations/cursor_ops').hasNext; +const next = require('./operations/cursor_ops').next; +const toArray = require('./operations/cursor_ops').toArray; /** * @fileOverview The **Cursor** class is an internal class that embodies a cursor on MongoDB * allowing for iteration over the results returned from the underlying query. It supports - * one by one document iteration, conversion to an array or can be iterated as a Node 0.10.X + * one by one document iteration, conversion to an array or can be iterated as a Node 4.X * or higher stream * * **CURSORS Cannot directly be instantiated** * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { + * MongoClient.connect(url, function(err, client) { * // Create a collection we want to drop later - * var col = db.collection('createIndexExample1'); + * const col = client.db(dbName).collection('createIndexExample1'); * // Insert a bunch of documents * col.insert([{a:1, b:1} * , {a:2, b:2}, {a:3, b:3} * , {a:4, b:4}], {w:1}, function(err, result) { * test.equal(null, err); - * * // Show that duplicate records got dropped * col.find({}).toArray(function(err, items) { * test.equal(null, err); * test.equal(4, items.length); - * db.close(); + * client.close(); * }); * }); * }); @@ -51,9 +58,8 @@ var inherits = require('util').inherits */ // Flags allowed for cursor -var flags = ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'exhaust', 'partial']; -var fields = ['numberOfRetries', 'tailableRetryInterval']; -var push = Array.prototype.push; +const flags = ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'exhaust', 'partial']; +const fields = ['numberOfRetries', 'tailableRetryInterval']; /** * Creates a new Cursor instance (INTERNAL TYPE, do not instantiate directly) @@ -82,14 +88,12 @@ var push = Array.prototype.push; * collection.find({}).addCursorFlag('awaitData', true) // Set cursor as awaitData * collection.find({}).addCursorFlag('partial', true) // Set cursor as partial * collection.find({}).addQueryModifier('$orderby', {a:1}) // Set $orderby {a:1} - * collection.find({}).max(10) // Set the cursor maxScan - * collection.find({}).maxScan(10) // Set the cursor maxScan + * collection.find({}).max(10) // Set the cursor max * collection.find({}).maxTimeMS(1000) // Set the cursor maxTimeMS * collection.find({}).min(100) // Set the cursor min - * collection.find({}).returnKey(10) // Set the cursor returnKey + * collection.find({}).returnKey(true) // Set the cursor returnKey * collection.find({}).setReadPreference(ReadPreference.PRIMARY) // Set the cursor readPreference * collection.find({}).showRecordId(true) // Set the cursor showRecordId - * collection.find({}).snapshot(true) // Set the cursor snapshot * collection.find({}).sort([['a', 1]]) // Sets the sort order of the cursor query * collection.find({}).hint('a_1') // Set the cursor hint * @@ -97,69 +101,72 @@ var push = Array.prototype.push; * * collection.find({}).maxTimeMS(1000).maxScan(100).skip(1).toArray(..) */ -var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) { +function Cursor(bson, ns, cmd, options, topology, topologyOptions) { CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0)); - var self = this; - var state = Cursor.INIT; - var streamOptions = {}; + const state = Cursor.INIT; + const streamOptions = {}; // Tailable cursor options - var numberOfRetries = options.numberOfRetries || 5; - var tailableRetryInterval = options.tailableRetryInterval || 500; - var currentNumberOfRetries = numberOfRetries; + const numberOfRetries = options.numberOfRetries || 5; + const tailableRetryInterval = options.tailableRetryInterval || 500; + const currentNumberOfRetries = numberOfRetries; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + const promiseLibrary = options.promiseLibrary || Promise; // Set up - Readable.call(this, {objectMode: true}); + Readable.call(this, { objectMode: true }); // Internal cursor state this.s = { // Tailable cursor options - numberOfRetries: numberOfRetries - , tailableRetryInterval: tailableRetryInterval - , currentNumberOfRetries: currentNumberOfRetries + numberOfRetries: numberOfRetries, + tailableRetryInterval: tailableRetryInterval, + currentNumberOfRetries: currentNumberOfRetries, // State - , state: state + state: state, // Stream options - , streamOptions: streamOptions + streamOptions: streamOptions, // BSON - , bson: bson + bson: bson, // Namespace - , ns: ns + ns: ns, // Command - , cmd: cmd + cmd: cmd, // Options - , options: options + options: options, // Topology - , topology: topology + topology: topology, // Topology options - , topologyOptions: topologyOptions + topologyOptions: topologyOptions, // Promise library - , promiseLibrary: promiseLibrary + promiseLibrary: promiseLibrary, // Current doc - , currentDoc: null + currentDoc: null, + // explicitlyIgnoreSession + explicitlyIgnoreSession: options.explicitlyIgnoreSession + }; + + // Optional ClientSession + if (!options.explicitlyIgnoreSession && options.session) { + this.s.session = options.session; } // Translate correctly - if(self.s.options.noCursorTimeout == true) { - self.addCursorFlag('noCursorTimeout', true); + if (this.s.options.noCursorTimeout === true) { + this.addCursorFlag('noCursorTimeout', true); } // Set the sort value - this.sortValue = self.s.cmd.sort; + this.sortValue = this.s.cmd.sort; // Get the batchSize - var batchSize = cmd.cursor && cmd.cursor.batchSize - ? cmd.cursor && cmd.cursor.batchSize - : (options.cursor && options.cursor.batchSize ? options.cursor.batchSize : 1000); + const batchSize = + cmd.cursor && cmd.cursor.batchSize + ? cmd.cursor && cmd.cursor.batchSize + : options.cursor && options.cursor.batchSize + ? options.cursor.batchSize + : 1000; // Set the batchSize this.setCursorBatchSize(batchSize); @@ -197,13 +204,30 @@ var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) { inherits(Cursor, Readable); // Map core cursor _next method so we can apply mapping -CoreCursor.prototype._next = CoreCursor.prototype.next; +Cursor.prototype._next = function() { + if (this._initImplicitSession) { + this._initImplicitSession(); + } + return CoreCursor.prototype.next.apply(this, arguments); +}; -for(var name in CoreCursor.prototype) { +for (let name in CoreCursor.prototype) { Cursor.prototype[name] = CoreCursor.prototype[name]; } -var define = Cursor.define = new Define('Cursor', Cursor, true); +Cursor.prototype._initImplicitSession = function() { + if (!this.s.explicitlyIgnoreSession && !this.s.session && this.s.topology.hasSessionSupport()) { + this.s.session = this.s.topology.startSession({ owner: this }); + this.cursorState.session = this.s.session; + } +}; + +Cursor.prototype._endSession = function() { + const didCloseCursor = CoreCursor.prototype._endSession.apply(this, arguments); + if (didCloseCursor) { + this.s.session = undefined; + } +}; /** * Check if there is any document still available in the cursor @@ -213,39 +237,10 @@ var define = Cursor.define = new Define('Cursor', Cursor, true); * @return {Promise} returns Promise if no callback passed */ Cursor.prototype.hasNext = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') { - if(self.s.currentDoc){ - return callback(null, true); - } else { - return nextObject(self, function(err, doc) { - if (err) return callback(err, null); - if (!doc) return callback(null, false); - self.s.currentDoc = doc; - callback(null, true); - }); - } - } - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - if(self.s.currentDoc){ - resolve(true); - } else { - nextObject(self, function(err, doc) { - if(self.s.state == Cursor.CLOSED || self.isDead()) return resolve(false); - if(err) return reject(err); - if(!doc) return resolve(false); - self.s.currentDoc = doc; - resolve(true); - }); - } + return executeOperation(this.s.topology, hasNext, [this, callback], { + skipSessions: true }); -} - -define.classMethod('hasNext', {callback: true, promise:true}); +}; /** * Get the next available document from the cursor, returns null if no more documents are available. @@ -255,38 +250,10 @@ define.classMethod('hasNext', {callback: true, promise:true}); * @return {Promise} returns Promise if no callback passed */ Cursor.prototype.next = function(callback) { - var self = this; - - // Execute using callback - if(typeof callback == 'function') { - // Return the currentDoc if someone called hasNext first - if(self.s.currentDoc) { - var doc = self.s.currentDoc; - self.s.currentDoc = null; - return callback(null, doc); - } - - // Return the next object - return nextObject(self, callback) - } - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - // Return the currentDoc if someone called hasNext first - if(self.s.currentDoc) { - var doc = self.s.currentDoc; - self.s.currentDoc = null; - return resolve(doc); - } - - nextObject(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); + return executeOperation(this.s.topology, next, [this, callback], { + skipSessions: true }); -} - -define.classMethod('next', {callback: true, promise:true}); +}; /** * Set the cursor query @@ -295,26 +262,29 @@ define.classMethod('next', {callback: true, promise:true}); * @return {Cursor} */ Cursor.prototype.filter = function(filter) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.query = filter; return this; -} - -define.classMethod('filter', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the cursor maxScan * @method * @param {object} maxScan Constrains the query to only scan the specified number of documents when fulfilling the query + * @deprecated as of MongoDB 4.0 * @return {Cursor} */ -Cursor.prototype.maxScan = function(maxScan) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); +Cursor.prototype.maxScan = deprecate(function(maxScan) { + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.maxScan = maxScan; return this; -} - -define.classMethod('maxScan', {callback: false, promise:false, returns: [Cursor]}); +}, 'Cursor.maxScan is deprecated, and will be removed in a later version'); /** * Set the cursor hint @@ -323,12 +293,13 @@ define.classMethod('maxScan', {callback: false, promise:false, returns: [Cursor] * @return {Cursor} */ Cursor.prototype.hint = function(hint) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.hint = hint; return this; -} - -define.classMethod('hint', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the cursor min @@ -337,12 +308,11 @@ define.classMethod('hint', {callback: false, promise:false, returns: [Cursor]}); * @return {Cursor} */ Cursor.prototype.min = function(min) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) + throw MongoError.create({ message: 'Cursor is closed', driver: true }); this.s.cmd.min = min; return this; -} - -define.classMethod('min', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the cursor max @@ -351,26 +321,28 @@ define.classMethod('min', {callback: false, promise:false, returns: [Cursor]}); * @return {Cursor} */ Cursor.prototype.max = function(max) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.max = max; return this; -} - -define.classMethod('max', {callback: false, promise:false, returns: [Cursor]}); +}; /** - * Set the cursor returnKey + * Set the cursor returnKey. If set to true, modifies the cursor to only return the index field or fields for the results of the query, rather than documents. If set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields. * @method - * @param {object} returnKey Only return the index field or fields for the results of the query. If $returnKey is set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields. Use one of the following forms: + * @param {bool} returnKey the returnKey value. * @return {Cursor} */ Cursor.prototype.returnKey = function(value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.returnKey = value; return this; -} - -define.classMethod('returnKey', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the cursor showRecordId @@ -379,26 +351,29 @@ define.classMethod('returnKey', {callback: false, promise:false, returns: [Curso * @return {Cursor} */ Cursor.prototype.showRecordId = function(value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.showDiskLoc = value; return this; -} - -define.classMethod('showRecordId', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the cursor snapshot * @method * @param {object} snapshot The $snapshot operator prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document. + * @deprecated as of MongoDB 4.0 * @return {Cursor} */ -Cursor.prototype.snapshot = function(value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); +Cursor.prototype.snapshot = deprecate(function(value) { + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.snapshot = value; return this; -} - -define.classMethod('snapshot', {callback: false, promise:false, returns: [Cursor]}); +}, 'Cursor Snapshot is deprecated, and will be removed in a later version'); /** * Set a node.js specific cursor option @@ -409,15 +384,21 @@ define.classMethod('snapshot', {callback: false, promise:false, returns: [Cursor * @return {Cursor} */ Cursor.prototype.setCursorOption = function(field, value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(fields.indexOf(field) == -1) throw MongoError.create({message: f("option %s not a supported option %s", field, fields), driver:true }); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (fields.indexOf(field) === -1) { + throw MongoError.create({ + message: `option ${field} is not a supported option ${fields}`, + driver: true + }); + } + this.s[field] = value; - if(field == 'numberOfRetries') - this.s.currentNumberOfRetries = value; + if (field === 'numberOfRetries') this.s.currentNumberOfRetries = value; return this; -} - -define.classMethod('setCursorOption', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Add a cursor flag to the cursor @@ -428,36 +409,50 @@ define.classMethod('setCursorOption', {callback: false, promise:false, returns: * @return {Cursor} */ Cursor.prototype.addCursorFlag = function(flag, value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(flags.indexOf(flag) == -1) throw MongoError.create({message: f("flag %s not a supported flag %s", flag, flags), driver:true }); - if(typeof value != 'boolean') throw MongoError.create({message: f("flag %s must be a boolean value", flag), driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (flags.indexOf(flag) === -1) { + throw MongoError.create({ + message: `flag ${flag} is not a supported flag ${flags}`, + driver: true + }); + } + + if (typeof value !== 'boolean') { + throw MongoError.create({ message: `flag ${flag} must be a boolean value`, driver: true }); + } + this.s.cmd[flag] = value; return this; -} - -define.classMethod('addCursorFlag', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Add a query modifier to the cursor query * @method * @param {string} name The query modifier (must start with $, such as $orderby etc) - * @param {boolean} value The flag boolean value. + * @param {string|boolean|number} value The modifier value. * @throws {MongoError} * @return {Cursor} */ Cursor.prototype.addQueryModifier = function(name, value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(name[0] != '$') throw MongoError.create({message: f("%s is not a valid query modifier"), driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (name[0] !== '$') { + throw MongoError.create({ message: `${name} is not a valid query modifier`, driver: true }); + } + // Strip of the $ - var field = name.substr(1); + const field = name.substr(1); // Set on the command this.s.cmd[field] = value; // Deal with the special case for sort - if(field == 'orderby') this.s.cmd.sort = this.s.cmd[field]; + if (field === 'orderby') this.s.cmd.sort = this.s.cmd[field]; return this; -} - -define.classMethod('addQueryModifier', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Add a comment to the cursor query allowing for tracking the comment in the log. @@ -467,12 +462,13 @@ define.classMethod('addQueryModifier', {callback: false, promise:false, returns: * @return {Cursor} */ Cursor.prototype.comment = function(value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.comment = value; return this; -} - -define.classMethod('comment', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise) @@ -482,13 +478,17 @@ define.classMethod('comment', {callback: false, promise:false, returns: [Cursor] * @return {Cursor} */ Cursor.prototype.maxAwaitTimeMS = function(value) { - if(typeof value != 'number') throw MongoError.create({message: "maxAwaitTimeMS must be a number", driver:true}); - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (typeof value !== 'number') { + throw MongoError.create({ message: 'maxAwaitTimeMS must be a number', driver: true }); + } + + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.maxAwaitTimeMS = value; return this; -} - -define.classMethod('maxAwaitTimeMS', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher) @@ -498,18 +498,20 @@ define.classMethod('maxAwaitTimeMS', {callback: false, promise:false, returns: [ * @return {Cursor} */ Cursor.prototype.maxTimeMS = function(value) { - if(typeof value != 'number') throw MongoError.create({message: "maxTimeMS must be a number", driver:true}); - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (typeof value !== 'number') { + throw MongoError.create({ message: 'maxTimeMS must be a number', driver: true }); + } + + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.maxTimeMS = value; return this; -} - -define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [Cursor]}); +}; Cursor.prototype.maxTimeMs = Cursor.prototype.maxTimeMS; -define.classMethod('maxTimeMs', {callback: false, promise:false, returns: [Cursor]}); - /** * Sets a field projection for the query. * @method @@ -518,12 +520,13 @@ define.classMethod('maxTimeMs', {callback: false, promise:false, returns: [Curso * @return {Cursor} */ Cursor.prototype.project = function(value) { - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + this.s.cmd.fields = value; return this; -} - -define.classMethod('project', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Sets the sort order of the cursor query. @@ -534,39 +537,47 @@ define.classMethod('project', {callback: false, promise:false, returns: [Cursor] * @return {Cursor} */ Cursor.prototype.sort = function(keyOrList, direction) { - if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support sorting", driver:true}); - if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - var order = keyOrList; + if (this.s.options.tailable) { + throw MongoError.create({ message: "Tailable cursor doesn't support sorting", driver: true }); + } + + if (this.s.state === Cursor.CLOSED || this.s.state === Cursor.OPEN || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + let order = keyOrList; // We have an array of arrays, we need to preserve the order of the sort // so we will us a Map - if(Array.isArray(order) && Array.isArray(order[0])) { - order = new Map(order.map(function(x) { - var value = [x[0], null]; - if(x[1] == 'asc') { - value[1] = 1; - } else if(x[1] == 'desc') { - value[1] = -1; - } else if(x[1] == 1 || x[1] == -1) { - value[1] = x[1]; - } else { - throw new MongoError("Illegal sort clause, must be of the form [['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]"); - } + if (Array.isArray(order) && Array.isArray(order[0])) { + order = new Map( + order.map(x => { + const value = [x[0], null]; + if (x[1] === 'asc') { + value[1] = 1; + } else if (x[1] === 'desc') { + value[1] = -1; + } else if (x[1] === 1 || x[1] === -1) { + value[1] = x[1]; + } else { + throw new MongoError( + "Illegal sort clause, must be of the form [['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]" + ); + } - return value; - })); + return value; + }) + ); } - if(direction != null) { + if (direction != null) { order = [[keyOrList, direction]]; } this.s.cmd.sort = order; this.sortValue = order; return this; -} - -define.classMethod('sort', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the batch size for the cursor. @@ -576,15 +587,22 @@ define.classMethod('sort', {callback: false, promise:false, returns: [Cursor]}); * @return {Cursor} */ Cursor.prototype.batchSize = function(value) { - if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support batchSize", driver:true}); - if(this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true}); + if (this.s.options.tailable) { + throw MongoError.create({ message: "Tailable cursor doesn't support batchSize", driver: true }); + } + + if (this.s.state === Cursor.CLOSED || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (typeof value !== 'number') { + throw MongoError.create({ message: 'batchSize requires an integer', driver: true }); + } + this.s.cmd.batchSize = value; this.setCursorBatchSize(value); return this; -} - -define.classMethod('batchSize', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the collation options for the cursor. @@ -596,9 +614,7 @@ define.classMethod('batchSize', {callback: false, promise:false, returns: [Curso Cursor.prototype.collation = function(value) { this.s.cmd.collation = value; return this; -} - -define.classMethod('collation', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the limit for the cursor. @@ -608,16 +624,23 @@ define.classMethod('collation', {callback: false, promise:false, returns: [Curso * @return {Cursor} */ Cursor.prototype.limit = function(value) { - if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support limit", driver:true}); - if(this.s.state == Cursor.OPEN || this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(typeof value != 'number') throw MongoError.create({message: "limit requires an integer", driver:true}); + if (this.s.options.tailable) { + throw MongoError.create({ message: "Tailable cursor doesn't support limit", driver: true }); + } + + if (this.s.state === Cursor.OPEN || this.s.state === Cursor.CLOSED || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (typeof value !== 'number') { + throw MongoError.create({ message: 'limit requires an integer', driver: true }); + } + this.s.cmd.limit = value; // this.cursorLimit = value; this.setCursorLimit(value); return this; -} - -define.classMethod('limit', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Set the skip for the cursor. @@ -627,15 +650,22 @@ define.classMethod('limit', {callback: false, promise:false, returns: [Cursor]}) * @return {Cursor} */ Cursor.prototype.skip = function(value) { - if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support skip", driver:true}); - if(this.s.state == Cursor.OPEN || this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); - if(typeof value != 'number') throw MongoError.create({message: "skip requires an integer", driver:true}); + if (this.s.options.tailable) { + throw MongoError.create({ message: "Tailable cursor doesn't support skip", driver: true }); + } + + if (this.s.state === Cursor.OPEN || this.s.state === Cursor.CLOSED || this.isDead()) { + throw MongoError.create({ message: 'Cursor is closed', driver: true }); + } + + if (typeof value !== 'number') { + throw MongoError.create({ message: 'skip requires an integer', driver: true }); + } + this.s.cmd.skip = value; this.setCursorSkip(value); return this; -} - -define.classMethod('skip', {callback: false, promise:false, returns: [Cursor]}); +}; /** * The callback format for results @@ -656,54 +686,9 @@ define.classMethod('skip', {callback: false, promise:false, returns: [Cursor]}); * @return {null} */ -/** - * Get the next available document from the cursor, returns null if no more documents are available. - * @method - * @param {Cursor~resultCallback} [callback] The result callback. - * @throws {MongoError} - * @deprecated - * @return {Promise} returns Promise if no callback passed - */ -Cursor.prototype.nextObject = Cursor.prototype.next; - -var nextObject = function(self, callback) { - if(self.s.state == Cursor.CLOSED || self.isDead && self.isDead()) return handleCallback(callback, MongoError.create({message: "Cursor is closed", driver:true})); - if(self.s.state == Cursor.INIT && self.s.cmd.sort) { - try { - self.s.cmd.sort = formattedOrderClause(self.s.cmd.sort); - } catch(err) { - return handleCallback(callback, err); - } - } - - // Get the next object - self._next(function(err, doc) { - self.s.state = Cursor.OPEN; - if(err) return handleCallback(callback, err); - handleCallback(callback, null, doc); - }); -} - -define.classMethod('nextObject', {callback: true, promise:true}); - -// Trampoline emptying the number of retrieved items -// without incurring a nextTick operation -var loop = function(self, callback) { - // No more items we are done - if(self.bufferedCount() == 0) return; - // Get the next document - self._next(callback); - // Loop - return loop; -} - -Cursor.prototype.next = Cursor.prototype.nextObject; - -define.classMethod('next', {callback: true, promise:true}); - /** * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, - * not all of the elements will be iterated if this cursor had been previously accessed. + * not all of the elements will be iterated if this cursor had been previouly accessed. * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements * at any given time if batch size is specified. Otherwise, the caller is responsible @@ -714,46 +699,14 @@ define.classMethod('next', {callback: true, promise:true}); * @throws {MongoError} * @return {null} */ -Cursor.prototype.each = function(callback) { +Cursor.prototype.each = deprecate(function(callback) { // Rewind cursor state this.rewind(); // Set current cursor to INIT this.s.state = Cursor.INIT; // Run the query - _each(this, callback); -}; - -define.classMethod('each', {callback: true, promise:false}); - -// Run the each loop -var _each = function(self, callback) { - if(!callback) throw MongoError.create({message: 'callback is mandatory', driver:true}); - if(self.isNotified()) return; - if(self.s.state == Cursor.CLOSED || self.isDead()) { - return handleCallback(callback, MongoError.create({message: "Cursor is closed", driver:true})); - } - - if(self.s.state == Cursor.INIT) self.s.state = Cursor.OPEN; - - // Define function to avoid global scope escape - var fn = null; - // Trampoline all the entries - if(self.bufferedCount() > 0) { - while(fn = loop(self, callback)) fn(self, callback); - _each(self, callback); - } else { - self.next(function(err, item) { - if(err) return handleCallback(callback, err); - if(item == null) { - self.s.state = Cursor.CLOSED; - return handleCallback(callback, null, null); - } - - if(handleCallback(callback, null, item) == false) return; - _each(self, callback); - }) - } -} + each(this, callback); +}, 'Cursor.each is deprecated. Use Cursor.forEach instead.'); /** * The callback format for the forEach iterator method @@ -773,22 +726,49 @@ var _each = function(self, callback) { * @param {Cursor~iteratorCallback} iterator The iteration callback. * @param {Cursor~endCallback} callback The end callback. * @throws {MongoError} - * @return {null} + * @return {Promise} if no callback supplied */ Cursor.prototype.forEach = function(iterator, callback) { - this.each(function(err, doc){ - if(err) { callback(err); return false; } - if(doc != null) { iterator(doc); return true; } - if(doc == null && callback) { - var internalCallback = callback; - callback = null; - internalCallback(null); - return false; - } - }); -} + // Rewind cursor state + this.rewind(); -define.classMethod('forEach', {callback: true, promise:false}); + // Set current cursor to INIT + this.s.state = Cursor.INIT; + + if (typeof callback === 'function') { + each(this, (err, doc) => { + if (err) { + callback(err); + return false; + } + if (doc != null) { + iterator(doc); + return true; + } + if (doc == null && callback) { + const internalCallback = callback; + callback = null; + internalCallback(null); + return false; + } + }); + } else { + return new this.s.promiseLibrary((fulfill, reject) => { + each(this, (err, doc) => { + if (err) { + reject(err); + return false; + } else if (doc == null) { + fulfill(null); + return false; + } else { + iterator(doc); + return true; + } + }); + }); + } +}; /** * Set the ReadPreference for the cursor. @@ -797,20 +777,24 @@ define.classMethod('forEach', {callback: true, promise:false}); * @throws {MongoError} * @return {Cursor} */ -Cursor.prototype.setReadPreference = function(r) { - if(this.s.state != Cursor.INIT) throw MongoError.create({message: 'cannot change cursor readPreference after cursor has been accessed', driver:true}); - if(r instanceof ReadPreference) { - this.s.options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); - } else if(typeof r == 'string'){ - this.s.options.readPreference = new CoreReadPreference(r); - } else if(r instanceof CoreReadPreference) { - this.s.options.readPreference = r; +Cursor.prototype.setReadPreference = function(readPreference) { + if (this.s.state !== Cursor.INIT) { + throw MongoError.create({ + message: 'cannot change cursor readPreference after cursor has been accessed', + driver: true + }); } - return this; -} + if (readPreference instanceof ReadPreference) { + this.s.options.readPreference = readPreference; + } else if (typeof readPreference === 'string') { + this.s.options.readPreference = new ReadPreference(readPreference); + } else { + throw new TypeError('Invalid read preference: ' + readPreference); + } -define.classMethod('setReadPreference', {callback: false, promise:false, returns: [Cursor]}); + return this; +}; /** * The callback format for results @@ -821,8 +805,8 @@ define.classMethod('setReadPreference', {callback: false, promise:false, returns /** * Returns an array of documents. The caller is responsible for making sure that there - * is enough memory to store the results. Note that the array only contain partial - * results when this cursor had been previously accessed. In that case, + * is enough memory to store the results. Note that the array only contains partial + * results when this cursor had been previouly accessed. In that case, * cursor.rewind() can be used to reset the cursor. * @method * @param {Cursor~toArrayResultCallback} [callback] The result callback. @@ -830,61 +814,17 @@ define.classMethod('setReadPreference', {callback: false, promise:false, returns * @return {Promise} returns Promise if no callback passed */ Cursor.prototype.toArray = function(callback) { - var self = this; - if(self.s.options.tailable) throw MongoError.create({message: 'Tailable cursor cannot be converted to array', driver:true}); - - // Execute using callback - if(typeof callback == 'function') return toArray(self, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - toArray(self, function(err, r) { - if(err) return reject(err); - resolve(r); + if (this.s.options.tailable) { + throw MongoError.create({ + message: 'Tailable cursor cannot be converted to array', + driver: true }); - }); -} - -var toArray = function(self, callback) { - var items = []; - - // Reset cursor - self.rewind(); - self.s.state = Cursor.INIT; - - // Fetch all the documents - var fetchDocs = function() { - self._next(function(err, doc) { - if(err) return handleCallback(callback, err); - if(doc == null) { - self.s.state = Cursor.CLOSED; - return handleCallback(callback, null, items); - } - - // Add doc to items - items.push(doc) - - // Get all buffered objects - if(self.bufferedCount() > 0) { - var docs = self.readBufferedDocuments(self.bufferedCount()) - - // Transform the doc if transform method added - if(self.s.transforms && typeof self.s.transforms.doc == 'function') { - docs = docs.map(self.s.transforms.doc); - } - - push.apply(items, docs); - } - - // Attempt a fetch - fetchDocs(); - }) } - fetchDocs(); -} - -define.classMethod('toArray', {callback: true, promise:true}); + return executeOperation(this.s.topology, toArray, [this, callback], { + skipSessions: true + }); +}; /** * The callback format for results @@ -897,105 +837,80 @@ define.classMethod('toArray', {callback: true, promise:true}); * Get the count of documents for this cursor * @method * @param {boolean} [applySkipLimit=true] Should the count command apply limit and skip settings on the cursor or in the passed in options. - * @param {object} [options=null] Optional settings. - * @param {number} [options.skip=null] The number of documents to skip. - * @param {number} [options.limit=null] The maximum amounts to count before aborting. - * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. - * @param {string} [options.hint=null] An index name hint for the query. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {number} [options.skip] The number of documents to skip. + * @param {number} [options.limit] The maximum amounts to count before aborting. + * @param {number} [options.maxTimeMS] Number of miliseconds to wait before aborting the query. + * @param {string} [options.hint] An index name hint for the query. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @param {Cursor~countResultCallback} [callback] The result callback. * @return {Promise} returns Promise if no callback passed */ Cursor.prototype.count = function(applySkipLimit, opts, callback) { - var self = this; - if(self.s.cmd.query == null) throw MongoError.create({message: "count can only be used with find command", driver:true}); - if(typeof opts == 'function') callback = opts, opts = {}; + if (this.s.cmd.query == null) + throw MongoError.create({ message: 'count can only be used with find command', driver: true }); + if (typeof opts === 'function') (callback = opts), (opts = {}); opts = opts || {}; - // Execute using callback - if(typeof callback == 'function') return count(self, applySkipLimit, opts, callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - count(self, applySkipLimit, opts, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -var count = function(self, applySkipLimit, opts, callback) { - if(typeof applySkipLimit == 'function') { + if (typeof applySkipLimit === 'function') { callback = applySkipLimit; applySkipLimit = true; } - if(applySkipLimit) { - if(typeof self.cursorSkip() == 'number') opts.skip = self.cursorSkip(); - if(typeof self.cursorLimit() == 'number') opts.limit = self.cursorLimit(); + if (this.s.session) { + opts = Object.assign({}, opts, { session: this.s.session }); } - // Command - var delimiter = self.s.ns.indexOf('.'); - - var command = { - 'count': self.s.ns.substr(delimiter+1), 'query': self.s.cmd.query - } - - // Apply a readConcern if set - if(self.s.cmd.readConcern) { - command.readConcern = self.s.cmd.readConcern; - } - - // Apply a hint if set - if(self.s.cmd.hint) { - command.hint = self.s.cmd.hint; - } - - if(typeof opts.maxTimeMS == 'number') { - command.maxTimeMS = opts.maxTimeMS; - } else if(self.s.cmd && typeof self.s.cmd.maxTimeMS == 'number') { - command.maxTimeMS = self.s.cmd.maxTimeMS; - } - - // Merge in any options - if(opts.skip) command.skip = opts.skip; - if(opts.limit) command.limit = opts.limit; - if(self.s.options.hint) command.hint = self.s.options.hint; - - // Set cursor server to the same as the topology - self.server = self.topology; - - // Execute the command - self.topology.command(f("%s.$cmd", self.s.ns.substr(0, delimiter)) - , command, function(err, result) { - callback(err, result ? result.result.n : null) - }, self.options); -} - -define.classMethod('count', {callback: true, promise:true}); + return executeOperation(this.s.topology, count, [this, applySkipLimit, opts, callback], { + skipSessions: !!this.s.session + }); +}; /** * Close the cursor, sending a KillCursor command and emitting close. * @method + * @param {object} [options] Optional settings. + * @param {boolean} [options.skipKillCursors] Bypass calling killCursors when closing the cursor. * @param {Cursor~resultCallback} [callback] The result callback. * @return {Promise} returns Promise if no callback passed */ -Cursor.prototype.close = function(callback) { +Cursor.prototype.close = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, { skipKillCursors: false }, options); + this.s.state = Cursor.CLOSED; - // Kill the cursor - this.kill(); - // Emit the close event for the cursor - this.emit('close'); - // Callback if provided - if(typeof callback == 'function') return handleCallback(callback, null, this); - // Return a Promise - return new this.s.promiseLibrary(function(resolve) { - resolve(); - }); -} + if (!options.skipKillCursors) { + // Kill the cursor + this.kill(); + } -define.classMethod('close', {callback: true, promise:true}); + const completeClose = () => { + // Emit the close event for the cursor + this.emit('close'); + + // Callback if provided + if (typeof callback === 'function') { + return handleCallback(callback, null, this); + } + + // Return a Promise + return new this.s.promiseLibrary(resolve => { + resolve(); + }); + }; + + if (this.s.session) { + if (typeof callback === 'function') { + return this._endSession(() => completeClose()); + } + + return new this.s.promiseLibrary(resolve => { + this._endSession(() => completeClose().then(resolve)); + }); + } + + return completeClose(); +}; /** * Map all documents using the provided function @@ -1004,16 +919,16 @@ define.classMethod('close', {callback: true, promise:true}); * @return {Cursor} */ Cursor.prototype.map = function(transform) { - if(this.cursorState.transforms && this.cursorState.transforms.doc) { - var oldTransform = this.cursorState.transforms.doc; - this.cursorState.transforms.doc = function (doc) { return transform(oldTransform(doc)); }; + if (this.cursorState.transforms && this.cursorState.transforms.doc) { + const oldTransform = this.cursorState.transforms.doc; + this.cursorState.transforms.doc = doc => { + return transform(oldTransform(doc)); + }; } else { this.cursorState.transforms = { doc: transform }; } return this; -} - -define.classMethod('map', {callback: false, promise:false, returns: [Cursor]}); +}; /** * Is the cursor closed @@ -1022,31 +937,50 @@ define.classMethod('map', {callback: false, promise:false, returns: [Cursor]}); */ Cursor.prototype.isClosed = function() { return this.isDead(); -} - -define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); +}; Cursor.prototype.destroy = function(err) { - if(err) this.emit('error', err); + if (err) this.emit('error', err); this.pause(); this.close(); -} - -define.classMethod('destroy', {callback: false, promise:false}); +}; /** * Return a modified Readable stream including a possible transform method. * @method - * @param {object} [options=null] Optional settings. - * @param {function} [options.transform=null] A transformation method applied to each document emitted by the stream. + * @param {object} [options] Optional settings. + * @param {function} [options.transform] A transformation method applied to each document emitted by the stream. * @return {Cursor} + * TODO: replace this method with transformStream in next major release */ Cursor.prototype.stream = function(options) { this.s.streamOptions = options || {}; return this; -} +}; -define.classMethod('stream', {callback: false, promise:false, returns: [Cursor]}); +/** + * Return a modified Readable stream that applies a given transform function, if supplied. If none supplied, + * returns a stream of unmodified docs. + * @method + * @param {object} [options] Optional settings. + * @param {function} [options.transform] A transformation method applied to each document emitted by the stream. + * @return {stream} + */ +Cursor.prototype.transformStream = function(options) { + const streamOptions = options || {}; + if (typeof streamOptions.transform === 'function') { + const stream = new Transform({ + objectMode: true, + transform: function(chunk, encoding, callback) { + this.push(streamOptions.transform(chunk)); + callback(); + } + }); + + return this.pipe(stream); + } + return this.pipe(new PassThrough({ objectMode: true })); +}; /** * Execute the explain for the cursor @@ -1055,64 +989,74 @@ define.classMethod('stream', {callback: false, promise:false, returns: [Cursor]} * @return {Promise} returns Promise if no callback passed */ Cursor.prototype.explain = function(callback) { - var self = this; this.s.cmd.explain = true; // Do we have a readConcern - if(this.s.cmd.readConcern) { + if (this.s.cmd.readConcern) { delete this.s.cmd['readConcern']; } - // Execute using callback - if(typeof callback == 'function') return this._next(callback); - - // Return a Promise - return new this.s.promiseLibrary(function(resolve, reject) { - self._next(function(err, r) { - if(err) return reject(err); - resolve(r); - }); + return executeOperation(this.s.topology, this._next.bind(this), [callback], { + skipSessions: true }); -} - -define.classMethod('explain', {callback: true, promise:true}); +}; Cursor.prototype._read = function() { - var self = this; - if(self.s.state == Cursor.CLOSED || self.isDead()) { - return self.push(null); + if (this.s.state === Cursor.CLOSED || this.isDead()) { + return this.push(null); } // Get the next item - self.nextObject(function(err, result) { - if(err) { - if(self.listeners('error') && self.listeners('error').length > 0) { - self.emit('error', err); + this.next((err, result) => { + if (err) { + if (this.listeners('error') && this.listeners('error').length > 0) { + this.emit('error', err); } - if(!self.isDead()) self.close(); + if (!this.isDead()) this.close(); // Emit end event - self.emit('end'); - return self.emit('finish'); + this.emit('end'); + return this.emit('finish'); } // If we provided a transformation method - if(typeof self.s.streamOptions.transform == 'function' && result != null) { - return self.push(self.s.streamOptions.transform(result)); + if (typeof this.s.streamOptions.transform === 'function' && result != null) { + return this.push(this.s.streamOptions.transform(result)); } // If we provided a map function - if(self.cursorState.transforms && typeof self.cursorState.transforms.doc == 'function' && result != null) { - return self.push(self.cursorState.transforms.doc(result)); + if ( + this.cursorState.transforms && + typeof this.cursorState.transforms.doc === 'function' && + result != null + ) { + return this.push(this.cursorState.transforms.doc(result)); } // Return the result - self.push(result); + this.push(result); + + if (result === null && this.isDead()) { + this.once('end', () => { + this.close(); + this.emit('finish'); + }); + } }); -} +}; + +/** + * Return the cursor logger + * @method + * @return {Logger} return the cursor logger + * @ignore + */ +Cursor.prototype.getLogger = function() { + return this.logger; +}; Object.defineProperty(Cursor.prototype, 'readPreference', { - enumerable:true, + enumerable: true, get: function() { if (!this || !this.s) { return null; @@ -1130,8 +1074,8 @@ Object.defineProperty(Cursor.prototype, 'namespace', { } // TODO: refactor this logic into core - var ns = this.s.ns || ''; - var firstDot = ns.indexOf('.'); + const ns = this.s.ns || ''; + const firstDot = ns.indexOf('.'); if (firstDot < 0) { return { database: this.s.ns, diff --git a/node_modules/mongodb/lib/db.js b/node_modules/mongodb/lib/db.js index db878c5..4789896 100644 --- a/node_modules/mongodb/lib/db.js +++ b/node_modules/mongodb/lib/db.js @@ -1,69 +1,103 @@ -"use strict"; - -var EventEmitter = require('events').EventEmitter - , authenticate = require('./authenticate') - , inherits = require('util').inherits - , getSingleProperty = require('./utils').getSingleProperty - , shallowClone = require('./utils').shallowClone - , parseIndexOptions = require('./utils').parseIndexOptions - , debugOptions = require('./utils').debugOptions - , CommandCursor = require('./command_cursor') - , handleCallback = require('./utils').handleCallback - , filterOptions = require('./utils').filterOptions - , toError = require('./utils').toError - , ReadPreference = require('./read_preference') - , f = require('util').format - , Admin = require('./admin') - , Code = require('mongodb-core').BSON.Code - , CoreReadPreference = require('mongodb-core').ReadPreference - , MongoError = require('mongodb-core').MongoError - , ObjectID = require('mongodb-core').ObjectID - , Define = require('./metadata') - , Logger = require('mongodb-core').Logger - , Collection = require('./collection') - , crypto = require('crypto') - , mergeOptionsAndWriteConcern = require('./utils').mergeOptionsAndWriteConcern - , assign = require('./utils').assign; - -var debugFields = ['authSource', 'w', 'wtimeout', 'j', 'native_parser', 'forceServerObjectId' - , 'serializeFunctions', 'raw', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'bufferMaxEntries', 'numberOfRetries', 'retryMiliSeconds' - , 'readPreference', 'pkFactory', 'parentDb', 'promiseLibrary', 'noListener']; - -// Filter out any write concern options -var illegalCommandFields = ['w', 'wtimeout', 'j', 'fsync', 'autoIndexId' - , 'strict', 'serializeFunctions', 'pkFactory', 'raw', 'readPreference']; +'use strict'; + +const EventEmitter = require('events').EventEmitter; +const inherits = require('util').inherits; +const getSingleProperty = require('./utils').getSingleProperty; +const CommandCursor = require('./command_cursor'); +const handleCallback = require('./utils').handleCallback; +const filterOptions = require('./utils').filterOptions; +const toError = require('./utils').toError; +const ReadPreference = require('mongodb-core').ReadPreference; +const MongoError = require('mongodb-core').MongoError; +const ObjectID = require('mongodb-core').ObjectID; +const Logger = require('mongodb-core').Logger; +const Collection = require('./collection'); +const mergeOptionsAndWriteConcern = require('./utils').mergeOptionsAndWriteConcern; +const executeOperation = require('./utils').executeOperation; +const applyWriteConcern = require('./utils').applyWriteConcern; +const resolveReadPreference = require('./utils').resolveReadPreference; +const ChangeStream = require('./change_stream'); +const deprecate = require('util').deprecate; +const deprecateOptions = require('./utils').deprecateOptions; + +// Operations +const addUser = require('./operations/db_ops').addUser; +const collections = require('./operations/db_ops').collections; +const createCollection = require('./operations/db_ops').createCollection; +const createIndex = require('./operations/db_ops').createIndex; +const createListener = require('./operations/db_ops').createListener; +const dropCollection = require('./operations/db_ops').dropCollection; +const dropDatabase = require('./operations/db_ops').dropDatabase; +const ensureIndex = require('./operations/db_ops').ensureIndex; +const evaluate = require('./operations/db_ops').evaluate; +const executeCommand = require('./operations/db_ops').executeCommand; +const executeDbAdminCommand = require('./operations/db_ops').executeDbAdminCommand; +const indexInformation = require('./operations/db_ops').indexInformation; +const listCollectionsTransforms = require('./operations/db_ops').listCollectionsTransforms; +const profilingInfo = require('./operations/db_ops').profilingInfo; +const profilingLevel = require('./operations/db_ops').profilingLevel; +const removeUser = require('./operations/db_ops').removeUser; +const setProfilingLevel = require('./operations/db_ops').setProfilingLevel; +const validateDatabaseName = require('./operations/db_ops').validateDatabaseName; /** * @fileOverview The **Db** class is a class that represents a MongoDB Database. * * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * const MongoClient = require('mongodb').MongoClient; * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { - * // Get an additional db - * var testDb = db.db('test'); - * db.close(); + * MongoClient.connect(url, function(err, client) { + * // Select the database by name + * const testDb = client.db(dbName); + * client.close(); * }); */ // Allowed parameters -var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPreferenceTags', 'native_parser' - , 'forceServerObjectId', 'pkFactory', 'serializeFunctions', 'raw', 'bufferMaxEntries', 'authSource' - , 'ignoreUndefined', 'promoteLongs', 'promiseLibrary', 'readConcern', 'retryMiliSeconds', 'numberOfRetries' - , 'parentDb', 'noListener', 'loggerLevel', 'logger', 'promoteBuffers', 'promoteLongs', 'promoteValues']; +const legalOptionNames = [ + 'w', + 'wtimeout', + 'fsync', + 'j', + 'readPreference', + 'readPreferenceTags', + 'native_parser', + 'forceServerObjectId', + 'pkFactory', + 'serializeFunctions', + 'raw', + 'bufferMaxEntries', + 'authSource', + 'ignoreUndefined', + 'promoteLongs', + 'promiseLibrary', + 'readConcern', + 'retryMiliSeconds', + 'numberOfRetries', + 'parentDb', + 'noListener', + 'loggerLevel', + 'logger', + 'promoteBuffers', + 'promoteLongs', + 'promoteValues', + 'compression', + 'retryWrites' +]; /** * Creates a new Db instance * @class * @param {string} databaseName The name of the database this instance represents. * @param {(Server|ReplSet|Mongos)} topology The server topology for the database. - * @param {object} [options=null] Optional settings. - * @param {string} [options.authSource=null] If the database authentication is dependent on another databaseName. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {string} [options.authSource] If the database authentication is dependent on another databaseName. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. @@ -73,10 +107,10 @@ var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPr * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible - * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys. + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) * @property {(Server|ReplSet|Mongos)} serverConfig Get the current db topology. * @property {number} bufferMaxEntries Current bufferMaxEntries value for the database @@ -87,7 +121,6 @@ var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPr * @property {object} writeConcern The current write concern values. * @property {object} topology Access the topology object (single server, replicaset or mongos). * @fires Db#close - * @fires Db#authenticated * @fires Db#reconnect * @fires Db#error * @fires Db#timeout @@ -95,20 +128,13 @@ var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPr * @fires Db#fullsetup * @return {Db} a Db instance. */ -var Db = function(databaseName, topology, options) { +function Db(databaseName, topology, options) { options = options || {}; - if(!(this instanceof Db)) return new Db(databaseName, topology, options); + if (!(this instanceof Db)) return new Db(databaseName, topology, options); EventEmitter.call(this); - var self = this; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + const promiseLibrary = options.promiseLibrary || Promise; // Filter the options options = filterOptions(options, legalOptionNames); @@ -116,88 +142,90 @@ var Db = function(databaseName, topology, options) { // Ensure we put the promiseLib in the options options.promiseLibrary = promiseLibrary; - // var self = this; // Internal state of the db object + // Internal state of the db object this.s = { // Database name - databaseName: databaseName + databaseName: databaseName, // DbCache - , dbCache: {} + dbCache: {}, // Children db's - , children: [] + children: [], // Topology - , topology: topology + topology: topology, // Options - , options: options + options: options, // Logger instance - , logger: Logger('Db', options) + logger: Logger('Db', options), // Get the bson parser - , bson: topology ? topology.bson : null - // Authsource if any - , authSource: options.authSource + bson: topology ? topology.bson : null, // Unpack read preference - , readPreference: options.readPreference + readPreference: options.readPreference, // Set buffermaxEntries - , bufferMaxEntries: typeof options.bufferMaxEntries == 'number' ? options.bufferMaxEntries : -1 + bufferMaxEntries: typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : -1, // Parent db (if chained) - , parentDb: options.parentDb || null + parentDb: options.parentDb || null, // Set up the primary key factory or fallback to ObjectID - , pkFactory: options.pkFactory || ObjectID + pkFactory: options.pkFactory || ObjectID, // Get native parser - , nativeParser: options.nativeParser || options.native_parser + nativeParser: options.nativeParser || options.native_parser, // Promise library - , promiseLibrary: promiseLibrary + promiseLibrary: promiseLibrary, // No listener - , noListener: typeof options.noListener == 'boolean' ? options.noListener : false + noListener: typeof options.noListener === 'boolean' ? options.noListener : false, // ReadConcern - , readConcern: options.readConcern - } + readConcern: options.readConcern + }; // Ensure we have a valid db name - validateDatabaseName(self.s.databaseName); + validateDatabaseName(this.s.databaseName); // Add a read Only property - getSingleProperty(this, 'serverConfig', self.s.topology); - getSingleProperty(this, 'bufferMaxEntries', self.s.bufferMaxEntries); - getSingleProperty(this, 'databaseName', self.s.databaseName); + getSingleProperty(this, 'serverConfig', this.s.topology); + getSingleProperty(this, 'bufferMaxEntries', this.s.bufferMaxEntries); + getSingleProperty(this, 'databaseName', this.s.databaseName); // This is a child db, do not register any listeners - if(options.parentDb) return; - if(this.s.noListener) return; + if (options.parentDb) return; + if (this.s.noListener) return; // Add listeners - topology.on('error', createListener(self, 'error', self)); - topology.on('timeout', createListener(self, 'timeout', self)); - topology.on('close', createListener(self, 'close', self)); - topology.on('parseError', createListener(self, 'parseError', self)); - topology.once('open', createListener(self, 'open', self)); - topology.once('fullsetup', createListener(self, 'fullsetup', self)); - topology.once('all', createListener(self, 'all', self)); - topology.on('reconnect', createListener(self, 'reconnect', self)); - topology.on('reconnectFailed', createListener(self, 'reconnectFailed', self)); + topology.on('error', createListener(this, 'error', this)); + topology.on('timeout', createListener(this, 'timeout', this)); + topology.on('close', createListener(this, 'close', this)); + topology.on('parseError', createListener(this, 'parseError', this)); + topology.once('open', createListener(this, 'open', this)); + topology.once('fullsetup', createListener(this, 'fullsetup', this)); + topology.once('all', createListener(this, 'all', this)); + topology.on('reconnect', createListener(this, 'reconnect', this)); } inherits(Db, EventEmitter); -var define = Db.define = new Define('Db', Db, false); - // Topology Object.defineProperty(Db.prototype, 'topology', { - enumerable:true, - get: function() { return this.s.topology; } + enumerable: true, + get: function() { + return this.s.topology; + } }); // Options Object.defineProperty(Db.prototype, 'options', { - enumerable:true, - get: function() { return this.s.options; } + enumerable: true, + get: function() { + return this.s.options; + } }); // slaveOk specified Object.defineProperty(Db.prototype, 'slaveOk', { - enumerable:true, + enumerable: true, get: function() { - if(this.s.options.readPreference != null - && (this.s.options.readPreference != 'primary' || this.s.options.readPreference.mode != 'primary')) { + if ( + this.s.options.readPreference != null && + (this.s.options.readPreference !== 'primary' || + this.s.options.readPreference.mode !== 'primary') + ) { return true; } return false; @@ -206,195 +234,33 @@ Object.defineProperty(Db.prototype, 'slaveOk', { // get the write Concern Object.defineProperty(Db.prototype, 'writeConcern', { - enumerable:true, + enumerable: true, get: function() { - var ops = {}; - if(this.s.options.w != null) ops.w = this.s.options.w; - if(this.s.options.j != null) ops.j = this.s.options.j; - if(this.s.options.fsync != null) ops.fsync = this.s.options.fsync; - if(this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; + const ops = {}; + if (this.s.options.w != null) ops.w = this.s.options.w; + if (this.s.options.j != null) ops.j = this.s.options.j; + if (this.s.options.fsync != null) ops.fsync = this.s.options.fsync; + if (this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; return ops; } }); -/** - * The callback format for the Db.open method - * @callback Db~openCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {Db} db The Db instance if the open method was successful. - */ - -// Internal method -var open = function(self, callback) { - self.s.topology.connect(self, self.s.options, function(err) { - if(callback == null) return; - var internalCallback = callback; - callback == null; - - if(err) { - self.close(); - return internalCallback(err); - } - - internalCallback(null, self); - }); -} - -/** - * Open the database - * @method - * @param {Db~openCallback} [callback] Callback - * @return {Promise} returns Promise if no callback passed - */ -Db.prototype.open = function(callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return open(self, callback); - // Return promise - return new self.s.promiseLibrary(function(resolve, reject) { - open(self, function(err, db) { - if(err) return reject(err); - resolve(db); - }) - }); -} - -define.classMethod('open', {callback: true, promise:true}); - -/** - * Converts provided read preference to CoreReadPreference - * @param {(ReadPreference|string|object)} readPreference the user provided read preference - * @return {CoreReadPreference} - */ -var convertReadPreference = function(readPreference) { - if(readPreference && typeof readPreference == 'string') { - return new CoreReadPreference(readPreference); - } else if(readPreference instanceof ReadPreference) { - return new CoreReadPreference(readPreference.mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds}); - } else if(readPreference && typeof readPreference == 'object') { - var mode = readPreference.mode || readPreference.preference; - if (mode && typeof mode == 'string') { - readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds}); - } - } - return readPreference; -} - -/** - * The callback format for results - * @callback Db~resultCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {object} result The result object if the command was executed successfully. - */ - -var executeCommand = function(self, command, options, callback) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - // Get the db name we are executing against - var dbName = options.dbName || options.authdb || self.s.databaseName; - - // If we have a readPreference set - if(options.readPreference == null && self.s.readPreference) { - options.readPreference = self.s.readPreference; - } - - // Convert the readPreference if its not a write - if(options.readPreference) { - options.readPreference = convertReadPreference(options.readPreference); - } else { - options.readPreference = CoreReadPreference.primary; - } - - // Debug information - if(self.s.logger.isDebug()) self.s.logger.debug(f('executing command %s against %s with options [%s]' - , JSON.stringify(command), f('%s.$cmd', dbName), JSON.stringify(debugOptions(debugFields, options)))); - - // Execute command - self.s.topology.command(f('%s.$cmd', dbName), command, options, function(err, result) { - if(err) return handleCallback(callback, err); - if(options.full) return handleCallback(callback, null, result); - handleCallback(callback, null, result.result); - }); -} - /** * Execute a command * @method * @param {object} command The command hash - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.command = function(command, options, callback) { - var self = this; - // Change the callback - if(typeof options == 'function') callback = options, options = {}; - // Clone the options - options = shallowClone(options); - - // Do we have a callback - if(typeof callback == 'function') return executeCommand(self, command, options, callback); - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - executeCommand(self, command, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('command', {callback: true, promise:true}); - -/** - * The callback format for results - * @callback Db~noResultCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {null} result Is not set to a value - */ - -/** - * Close the db and its underlying connections - * @method - * @param {boolean} force Force close, emitting no events - * @param {Db~noResultCallback} [callback] The result callback - * @return {Promise} returns Promise if no callback passed - */ -Db.prototype.close = function(force, callback) { - if(typeof force == 'function') callback = force, force = false; - this.s.topology.close(force); - var self = this; - - // Fire close event if any listeners - if(this.listeners('close').length > 0) { - this.emit('close'); - - // If it's the top level db emit close on all children - if(this.parentDb == null) { - // Fire close on all children - for(var i = 0; i < this.s.children.length; i++) { - this.s.children[i].emit('close'); - } - } - - // Remove listeners after emit - self.removeAllListeners('close'); - } + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options); - // Close parent db if set - if(this.s.parentDb) this.s.parentDb.close(); - // Callback after next event loop tick - if(typeof callback == 'function') return process.nextTick(function() { - handleCallback(callback, null); - }) - - // Return dummy promise - return new this.s.promiseLibrary(function(resolve) { - resolve(); - }); -} - -define.classMethod('close', {callback: true, promise:true}); + return executeOperation(this.s.topology, executeCommand, [this, command, options, callback]); +}; /** * Return the Admin db instance @@ -402,11 +268,11 @@ define.classMethod('close', {callback: true, promise:true}); * @return {Admin} return the new Admin db instance */ Db.prototype.admin = function() { + const Admin = require('./admin'); + return new Admin(this, this.s.topology, this.s.promiseLibrary); }; -define.classMethod('admin', {callback: false, promise:false, returns: [Admin]}); - /** * The callback format for the collection method, must be used if strict is specified * @callback Db~collectionResultCallback @@ -414,34 +280,43 @@ define.classMethod('admin', {callback: false, promise:false, returns: [Admin]}); * @param {Collection} collection The collection instance. */ -var collectionKeys = ['pkFactory', 'readPreference' - , 'serializeFunctions', 'strict', 'readConcern', 'ignoreUndefined', 'promoteValues', 'promoteBuffers', 'promoteLongs']; +const collectionKeys = [ + 'pkFactory', + 'readPreference', + 'serializeFunctions', + 'strict', + 'readConcern', + 'ignoreUndefined', + 'promoteValues', + 'promoteBuffers', + 'promoteLongs' +]; /** - * Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can - * can use it without a callback in the following way: `var collection = db.collection('mycollection');` + * Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you + * can use it without a callback in the following way: `const collection = db.collection('mycollection');` * * @method * @param {string} name the collection name we wish to access. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. - * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.strict=false] Returns an error if the collection does not exist - * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {object} [options.readConcern] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) - * @param {Db~collectionResultCallback} callback The collection result callback + * @param {Db~collectionResultCallback} [callback] The collection result callback * @return {Collection} return the new Collection instance if not in strict mode */ Db.prototype.collection = function(name, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - options = shallowClone(options); + options = Object.assign({}, options); + // Set the promise library options.promiseLibrary = this.s.promiseLibrary; @@ -449,7 +324,7 @@ Db.prototype.collection = function(name, options, callback) { options.readConcern = options.readConcern || this.s.readConcern; // Do we have ignoreUndefined set - if(this.s.options.ignoreUndefined) { + if (this.s.options.ignoreUndefined) { options.ignoreUndefined = this.s.options.ignoreUndefined; } @@ -457,95 +332,57 @@ Db.prototype.collection = function(name, options, callback) { options = mergeOptionsAndWriteConcern(options, this.s.options, collectionKeys, true); // Execute - if(options == null || !options.strict) { + if (options == null || !options.strict) { try { - var collection = new Collection(this, this.s.topology, this.s.databaseName, name, this.s.pkFactory, options); - if(callback) callback(null, collection); + const collection = new Collection( + this, + this.s.topology, + this.s.databaseName, + name, + this.s.pkFactory, + options + ); + if (callback) callback(null, collection); return collection; - } catch(err) { - // if(err instanceof MongoError && callback) return callback(err); - if(callback) return callback(err); + } catch (err) { + if (err instanceof MongoError && callback) return callback(err); throw err; } } // Strict mode - if(typeof callback != 'function') { - throw toError(f("A callback is required in strict mode. While getting collection %s.", name)); + if (typeof callback !== 'function') { + throw toError(`A callback is required in strict mode. While getting collection ${name}`); } // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) { + if (this.serverConfig && this.serverConfig.isDestroyed()) { return callback(new MongoError('topology was destroyed')); } + const listCollectionOptions = Object.assign({}, options, { nameOnly: true }); + // Strict mode - this.listCollections({name:name}, options).toArray(function(err, collections) { - if(err != null) return handleCallback(callback, err, null); - if(collections.length == 0) return handleCallback(callback, toError(f("Collection %s does not exist. Currently in strict mode.", name)), null); + this.listCollections({ name: name }, listCollectionOptions).toArray((err, collections) => { + if (err != null) return handleCallback(callback, err, null); + if (collections.length === 0) + return handleCallback( + callback, + toError(`Collection ${name} does not exist. Currently in strict mode.`), + null + ); try { - return handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); - } catch(err) { + return handleCallback( + callback, + null, + new Collection(this, this.s.topology, this.s.databaseName, name, this.s.pkFactory, options) + ); + } catch (err) { return handleCallback(callback, err, null); } }); -} - -define.classMethod('collection', {callback: true, promise:false, returns: [Collection]}); - -function decorateWithWriteConcern(command, self, options) { - // Do we support write concerns 3.4 and higher - if(self.s.topology.capabilities().commandsTakeWriteConcern) { - // Get the write concern settings - var finalOptions = writeConcern(shallowClone(options), self, options); - // Add the write concern to the command - if(finalOptions.writeConcern) { - command.writeConcern = finalOptions.writeConcern; - } - } -} - -var createCollection = function(self, name, options, callback) { - // Get the write concern options - var finalOptions = writeConcern(shallowClone(options), self, options); - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - // Check if we have the name - self.listCollections({name: name}) - .setReadPreference(ReadPreference.PRIMARY) - .toArray(function(err, collections) { - if(err != null) return handleCallback(callback, err, null); - if(collections.length > 0 && finalOptions.strict) { - return handleCallback(callback, MongoError.create({message: f("Collection %s already exists. Currently in strict mode.", name), driver:true}), null); - } else if (collections.length > 0) { - try { return handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); } - catch(err) { return handleCallback(callback, err); } - } - - // Create collection command - var cmd = {'create':name}; - - // Decorate command with writeConcern if supported - decorateWithWriteConcern(cmd, self, options); - // Add all optional parameters - for(var n in options) { - if(options[n] != null - && typeof options[n] != 'function' && illegalCommandFields.indexOf(n) == -1) { - cmd[n] = options[n]; - } - } - - // Force a primary read Preference - finalOptions.readPreference = ReadPreference.PRIMARY; - - // Execute command - self.command(cmd, finalOptions, function(err) { - if(err) return handleCallback(callback, err); - handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); - }); - }); -} +}; /** * Create a new collection on a server with the specified options. Use this to create capped collections. @@ -553,110 +390,84 @@ var createCollection = function(self, name, options, callback) { * * @method * @param {string} name the collection name we wish to access. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. - * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. * @param {boolean} [options.strict=false] Returns an error if the collection does not exist * @param {boolean} [options.capped=false] Create a capped collection. - * @param {boolean} [options.autoIndexId=true] Create an index on the _id field of the document, True by default on MongoDB 2.2 or higher off for version < 2.2. - * @param {number} [options.size=null] The size of the capped collection in bytes. - * @param {number} [options.max=null] The maximum number of documents in the capped collection. - * @param {number} [options.flags=null] Optional. Available for the MMAPv1 storage engine only to set the usePowerOf2Sizes and the noPadding flag. - * @param {object} [options.storageEngine=null] Allows users to specify configuration to the storage engine on a per-collection basis when creating a collection on MongoDB 3.0 or higher. - * @param {object} [options.validator=null] Allows users to specify validation rules or expressions for the collection. For more information, see Document Validation on MongoDB 3.2 or higher. - * @param {string} [options.validationLevel=null] Determines how strictly MongoDB applies the validation rules to existing documents during an update on MongoDB 3.2 or higher. - * @param {string} [options.validationAction=null] Determines whether to error on invalid documents or just warn about the violations but allow invalid documents to be inserted on MongoDB 3.2 or higher. - * @param {object} [options.indexOptionDefaults=null] Allows users to specify a default configuration for indexes when creating a collection on MongoDB 3.2 or higher. - * @param {string} [options.viewOn=null] The name of the source collection or view from which to create the view. The name is not the full namespace of the collection or view; i.e. does not include the database name and implies the same database as the view to create on MongoDB 3.4 or higher. - * @param {array} [options.pipeline=null] An array that consists of the aggregation pipeline stage. create creates the view by applying the specified pipeline to the viewOn collection or view on MongoDB 3.4 or higher. - * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {boolean} [options.autoIndexId=true] DEPRECATED: Create an index on the _id field of the document, True by default on MongoDB 2.6 - 3.0 + * @param {number} [options.size] The size of the capped collection in bytes. + * @param {number} [options.max] The maximum number of documents in the capped collection. + * @param {number} [options.flags] Optional. Available for the MMAPv1 storage engine only to set the usePowerOf2Sizes and the noPadding flag. + * @param {object} [options.storageEngine] Allows users to specify configuration to the storage engine on a per-collection basis when creating a collection on MongoDB 3.0 or higher. + * @param {object} [options.validator] Allows users to specify validation rules or expressions for the collection. For more information, see Document Validation on MongoDB 3.2 or higher. + * @param {string} [options.validationLevel] Determines how strictly MongoDB applies the validation rules to existing documents during an update on MongoDB 3.2 or higher. + * @param {string} [options.validationAction] Determines whether to error on invalid documents or just warn about the violations but allow invalid documents to be inserted on MongoDB 3.2 or higher. + * @param {object} [options.indexOptionDefaults] Allows users to specify a default configuration for indexes when creating a collection on MongoDB 3.2 or higher. + * @param {string} [options.viewOn] The name of the source collection or view from which to create the view. The name is not the full namespace of the collection or view; i.e. does not include the database name and implies the same database as the view to create on MongoDB 3.4 or higher. + * @param {array} [options.pipeline] An array that consists of the aggregation pipeline stage. create creates the view by applying the specified pipeline to the viewOn collection or view on MongoDB 3.4 or higher. + * @param {object} [options.collation] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~collectionResultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ -Db.prototype.createCollection = function(name, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - name = args.length ? args.shift() : null; - options = args.length ? args.shift() || {} : {}; +Db.prototype.createCollection = deprecateOptions( + { + name: 'Db.createCollection', + deprecatedOptions: ['autoIndexId'], + optionsIndex: 1 + }, + function(name, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + options.promiseLibrary = options.promiseLibrary || this.s.promiseLibrary; - // Do we have a promisesLibrary - options.promiseLibrary = options.promiseLibrary || this.s.promiseLibrary; - - // Check if the callback is in fact a string - if(typeof callback == 'string') name = callback; - - // Execute the fallback callback - if(typeof callback == 'function') return createCollection(self, name, options, callback); - return new this.s.promiseLibrary(function(resolve, reject) { - createCollection(self, name, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -} - -define.classMethod('createCollection', {callback: true, promise:true}); + return executeOperation(this.s.topology, createCollection, [this, name, options, callback]); + } +); /** * Get all the db statistics. * * @method - * @param {object} [options=null] Optional settings. - * @param {number} [options.scale=null] Divide the returned sizes by scale value. + * @param {object} [options] Optional settings. + * @param {number} [options.scale] Divide the returned sizes by scale value. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The collection result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.stats = function(options, callback) { - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Build command object - var commandObject = { dbStats:true }; + const commandObject = { dbStats: true }; // Check if we have the scale value - if(options['scale'] != null) commandObject['scale'] = options['scale']; + if (options['scale'] != null) commandObject['scale'] = options['scale']; // If we have a readPreference set - if(options.readPreference == null && this.s.readPreference) { + if (options.readPreference == null && this.s.readPreference) { options.readPreference = this.s.readPreference; } // Execute the command return this.command(commandObject, options, callback); -} - -define.classMethod('stats', {callback: true, promise:true}); - -// Transformation methods for cursor results -var listCollectionsTranforms = function(databaseName) { - var matching = f('%s.', databaseName); - - return { - doc: function(doc) { - var index = doc.name.indexOf(matching); - // Remove database name if available - if(doc.name && index == 0) { - doc.name = doc.name.substr(index + matching.length); - } - - return doc; - } - } -} +}; /** * Get the list of all collection information for the specified db. * * @method * @param {object} [filter={}] Query to filter collections by - * @param {object} [options=null] Optional settings. - * @param {number} [options.batchSize=null] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {boolean} [options.nameOnly=false] Since 4.0: If true, will only return the collection name in the response, and will omit additional info + * @param {number} [options.batchSize] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @return {CommandCursor} */ Db.prototype.listCollections = function(filter, options) { @@ -664,29 +475,30 @@ Db.prototype.listCollections = function(filter, options) { options = options || {}; // Shallow clone the object - options = shallowClone(options); + options = Object.assign({}, options); // Set the promise library options.promiseLibrary = this.s.promiseLibrary; // Ensure valid readPreference - if(options.readPreference) { - options.readPreference = convertReadPreference(options.readPreference); - } else { - options.readPreference = this.s.readPreference || CoreReadPreference.primary; - } + options.readPreference = resolveReadPreference(options, { + db: this, + default: ReadPreference.primary + }); + + // Cursor options + let cursor = options.batchSize ? { batchSize: options.batchSize } : {}; // We have a list collections command - if(this.serverConfig.capabilities().hasListCollectionsCommand) { - // Cursor options - var cursor = options.batchSize ? {batchSize: options.batchSize} : {} + if (this.serverConfig.capabilities().hasListCollectionsCommand) { + const nameOnly = typeof options.nameOnly === 'boolean' ? options.nameOnly : false; // Build the command - var command = { listCollections : true, filter: filter, cursor: cursor }; + const command = { listCollections: true, filter, cursor, nameOnly }; // Set the AggregationCursor constructor options.cursorFactory = CommandCursor; // Create the cursor - cursor = this.s.topology.cursor(f('%s.$cmd', this.s.databaseName), command, options); + cursor = this.s.topology.cursor(`${this.s.databaseName}.$cmd`, command, options); // Do we have a readPreference, apply it - if(options.readPreference) { + if (options.readPreference) { cursor.setReadPreference(options.readPreference); } // Return the cursor @@ -694,107 +506,62 @@ Db.prototype.listCollections = function(filter, options) { } // We cannot use the listCollectionsCommand - if(!this.serverConfig.capabilities().hasListCollectionsCommand) { + if (!this.serverConfig.capabilities().hasListCollectionsCommand) { // If we have legacy mode and have not provided a full db name filter it - if(typeof filter.name == 'string' && !(new RegExp('^' + this.databaseName + '\\.').test(filter.name))) { - filter = shallowClone(filter); - filter.name = f('%s.%s', this.s.databaseName, filter.name); + if ( + typeof filter.name === 'string' && + !new RegExp('^' + this.databaseName + '\\.').test(filter.name) + ) { + filter = Object.assign({}, filter); + filter.name = `${this.s.databaseName}.${filter.name}`; } } // No filter, filter by current database - if(filter == null) { - filter.name = f('/%s/', this.s.databaseName); + if (filter == null) { + filter.name = `/${this.s.databaseName}/`; } // Rewrite the filter to use $and to filter out indexes - if(filter.name) { - filter = {$and: [{name: filter.name}, {name:/^((?!\$).)*$/}]}; + if (filter.name) { + filter = { $and: [{ name: filter.name }, { name: /^((?!\$).)*$/ }] }; } else { - filter = {name:/^((?!\$).)*$/}; + filter = { name: /^((?!\$).)*$/ }; } // Return options - var _options = {transforms: listCollectionsTranforms(this.s.databaseName)} + const _options = { transforms: listCollectionsTransforms(this.s.databaseName) }; // Get the cursor cursor = this.collection(Db.SYSTEM_NAMESPACE_COLLECTION).find(filter, _options); // Do we have a readPreference, apply it - if(options.readPreference) cursor.setReadPreference(options.readPreference); + if (options.readPreference) cursor.setReadPreference(options.readPreference); // Set the passed in batch size if one was provided - if(options.batchSize) cursor = cursor.batchSize(options.batchSize); + if (options.batchSize) cursor = cursor.batchSize(options.batchSize); // We have a fallback mode using legacy systems collections return cursor; }; -define.classMethod('listCollections', {callback: false, promise:false, returns: [CommandCursor]}); - -var evaluate = function(self, code, parameters, options, callback) { - var finalCode = code; - var finalParameters = []; - - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - - // If not a code object translate to one - if(!(finalCode && finalCode._bsontype == 'Code')) finalCode = new Code(finalCode); - // Ensure the parameters are correct - if(parameters != null && !Array.isArray(parameters) && typeof parameters !== 'function') { - finalParameters = [parameters]; - } else if(parameters != null && Array.isArray(parameters) && typeof parameters !== 'function') { - finalParameters = parameters; - } - - // Create execution selector - var cmd = {'$eval':finalCode, 'args':finalParameters}; - // Check if the nolock parameter is passed in - if(options['nolock']) { - cmd['nolock'] = options['nolock']; - } - - // Set primary read preference - options.readPreference = new CoreReadPreference(ReadPreference.PRIMARY); - - // Execute the command - self.command(cmd, options, function(err, result) { - if(err) return handleCallback(callback, err, null); - if(result && result.ok == 1) return handleCallback(callback, null, result.retval); - if(result) return handleCallback(callback, MongoError.create({message: f("eval failed: %s", result.errmsg), driver:true}), null); - handleCallback(callback, err, result); - }); -} - /** * Evaluate JavaScript on the server * * @method * @param {Code} code JavaScript to execute on server. * @param {(object|array)} parameters The parameters for the call. - * @param {object} [options=null] Optional settings. - * @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaluation of the javascript. + * @param {object} [options] Optional settings. + * @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaulation of the javascript. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The results callback * @deprecated Eval is deprecated on MongoDB 3.2 and forward * @return {Promise} returns Promise if no callback passed */ -Db.prototype.eval = function(code, parameters, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); +Db.prototype.eval = deprecate(function(code, parameters, options, callback) { + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; parameters = args.length ? args.shift() : parameters; options = args.length ? args.shift() || {} : {}; - // Check if the callback is in fact a string - if(typeof callback == 'function') return evaluate(self, code, parameters, options, callback); - // Execute the command - return new this.s.promiseLibrary(function(resolve, reject) { - evaluate(self, code, parameters, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -define.classMethod('eval', {callback: true, promise:true}); + return executeOperation(this.s.topology, evaluate, [this, code, parameters, options, callback]); +}, 'Db.eval is deprecated as of MongoDB version 3.2'); /** * Rename a collection. @@ -802,930 +569,351 @@ define.classMethod('eval', {callback: true, promise:true}); * @method * @param {string} fromCollection Name of current collection to rename. * @param {string} toCollection New name of of the collection. - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.dropTarget=false] Drop the target name collection if it previously exists. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~collectionResultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.renameCollection = function(fromCollection, toCollection, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Add return new collection options.new_collection = true; - // Check if the callback is in fact a string - if(typeof callback == 'function') { - return this.collection(fromCollection).rename(toCollection, options, callback); - } - - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.collection(fromCollection).rename(toCollection, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + const collection = this.collection(fromCollection); + return executeOperation(this.s.topology, collection.rename.bind(collection), [ + toCollection, + options, + callback + ]); }; -define.classMethod('renameCollection', {callback: true, promise:true}); - /** * Drop a collection from the database, removing it permanently. New accesses will create a new collection. * * @method * @param {string} name Name of collection to drop + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.dropCollection = function(name, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Command to execute - var cmd = {'drop':name} + const cmd = { drop: name }; // Decorate with write concern - decorateWithWriteConcern(cmd, self, options); + applyWriteConcern(cmd, { db: this }, options); // options - options = assign({}, this.s.options, {readPreference: ReadPreference.PRIMARY}); - - // Check if the callback is in fact a string - if(typeof callback == 'function') return this.command(cmd, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - if(err) return handleCallback(callback, err); - if(result.ok) return handleCallback(callback, null, true); - handleCallback(callback, null, false); - }); + const opts = Object.assign({}, this.s.options, { readPreference: ReadPreference.PRIMARY }); + if (options.session) opts.session = options.session; - // Clone the options - options = shallowClone(self.s.options); - // Set readPreference PRIMARY - options.readPreference = ReadPreference.PRIMARY; - - // Execute the command - return new this.s.promiseLibrary(function(resolve, reject) { - // Execute command - self.command(cmd, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); - if(err) return reject(err); - if(result.ok) return resolve(true); - resolve(false); - }); - }); + return executeOperation(this.s.topology, dropCollection, [this, cmd, opts, callback]); }; -define.classMethod('dropCollection', {callback: true, promise:true}); - /** * Drop a database, removing it permanently from the server. * * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.dropDatabase = function(options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; // Drop database command - var cmd = {'dropDatabase':1}; + const cmd = { dropDatabase: 1 }; // Decorate with write concern - decorateWithWriteConcern(cmd, self, options); + applyWriteConcern(cmd, { db: this }, options); // Ensure primary only - options = assign({}, this.s.options, {readPreference: ReadPreference.PRIMARY}); - - // Check if the callback is in fact a string - if(typeof callback == 'function') return this.command(cmd, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - if(callback == null) return; - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, result.ok ? true : false); - }); - - // Execute the command - return new this.s.promiseLibrary(function(resolve, reject) { - // Execute command - self.command(cmd, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); - if(err) return reject(err); - if(result.ok) return resolve(true); - resolve(false); - }); + const finalOptions = Object.assign({}, this.s.options, { + readPreference: ReadPreference.PRIMARY }); -} -define.classMethod('dropDatabase', {callback: true, promise:true}); + if (options.session) { + finalOptions.session = options.session; + } -/** - * The callback format for the collections method. - * @callback Db~collectionsResultCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {Collection[]} collections An array of all the collections objects for the db instance. - */ -var collections = function(self, callback) { - // Let's get the collection names - self.listCollections().toArray(function(err, documents) { - if(err != null) return handleCallback(callback, err, null); - // Filter collections removing any illegal ones - documents = documents.filter(function(doc) { - return doc.name.indexOf('$') == -1; - }); - - // Return the collection objects - handleCallback(callback, null, documents.map(function(d) { - return new Collection(self, self.s.topology, self.s.databaseName, d.name, self.s.pkFactory, self.s.options); - })); - }); -} + return executeOperation(this.s.topology, dropDatabase, [this, cmd, finalOptions, callback]); +}; /** * Fetch all collections for the current db. * * @method + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~collectionsResultCallback} [callback] The results callback * @return {Promise} returns Promise if no callback passed */ -Db.prototype.collections = function(callback) { - var self = this; - - // Return the callback - if(typeof callback == 'function') return collections(self, callback); - // Return the promise - return new self.s.promiseLibrary(function(resolve, reject) { - collections(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; +Db.prototype.collections = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('collections', {callback: true, promise:true}); + return executeOperation(this.s.topology, collections, [this, options, callback]); +}; /** * Runs a command on the database as admin. * @method * @param {object} command The command hash - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.executeDbAdminCommand = function(selector, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - - // Return the callback - if(typeof callback == 'function') { - // Convert read preference - if(options.readPreference) { - options.readPreference = convertReadPreference(options.readPreference) - } - - return self.s.topology.command('admin.$cmd', selector, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - if(err) return handleCallback(callback, err); - handleCallback(callback, null, result.result); - }); - } - - // Return promise - return new self.s.promiseLibrary(function(resolve, reject) { - self.s.topology.command('admin.$cmd', selector, options, function(err, result) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); - if(err) return reject(err); - resolve(result.result); - }); - }); + options.readPreference = resolveReadPreference(options); + + return executeOperation(this.s.topology, executeDbAdminCommand, [ + this, + selector, + options, + callback + ]); }; -define.classMethod('executeDbAdminCommand', {callback: true, promise:true}); - /** - * Creates an index on the db and collection collection. + * Creates an index on the db and collection. * @method * @param {string} name Name of the collection to create the index on. * @param {(string|object)} fieldOrSpec Defines the index. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.unique=false] Creates an unique index. * @param {boolean} [options.sparse=false] Creates a sparse index. * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value - * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. - * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. - * @param {number} [options.v=null] Specify the format version of the indexes. - * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) - * @param {object} [options.partialFilterExpression=null] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + * @param {number} [options.min] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.partialFilterExpression] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.createIndex = function(name, fieldOrSpec, options, callback) { - var self = this; - var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - options = args.length ? args.shift() || {} : {}; - options = typeof callback === 'function' ? options : callback; - options = options == null ? {} : options; - // Shallow clone the options - options = shallowClone(options); - - // If we have a callback fallback - if(typeof callback == 'function') return createIndex(self, name, fieldOrSpec, options, callback); - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - createIndex(self, name, fieldOrSpec, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + if (typeof options === 'function') (callback = options), (options = {}); + options = options ? Object.assign({}, options) : {}; + + return executeOperation(this.s.topology, createIndex, [ + this, + name, + fieldOrSpec, + options, + callback + ]); }; -var createIndex = function(self, name, fieldOrSpec, options, callback) { - // Get the write concern options - var finalOptions = writeConcern({}, self, options, { readPreference: ReadPreference.PRIMARY }); - // Ensure we have a callback - if(finalOptions.writeConcern && typeof callback != 'function') { - throw MongoError.create({message: "Cannot use a writeConcern without a provided callback", driver:true}); - } - - // Run only against primary - options.readPreference = ReadPreference.PRIMARY; - - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - - // Attempt to run using createIndexes command - createIndexUsingCreateIndexes(self, name, fieldOrSpec, options, function(err, result) { - if(err == null) return handleCallback(callback, err, result); - - // 67 = 'CannotCreateIndex' (malformed index options) - // 85 = 'IndexOptionsConflict' (index already exists with different options) - // 11000 = 'DuplicateKey' (couldn't build unique index because of dupes) - // 11600 = 'InterruptedAtShutdown' (interrupted at shutdown) - // These errors mean that the server recognized `createIndex` as a command - // and so we don't need to fallback to an insert. - if(err.code === 67 || err.code == 11000 || err.code === 85 || err.code == 11600) { - return handleCallback(callback, err, result); - } - - // Create command - var doc = createCreateIndexCommand(self, name, fieldOrSpec, options); - // Set no key checking - finalOptions.checkKeys = false; - // Insert document - self.s.topology.insert(f("%s.%s", self.s.databaseName, Db.SYSTEM_INDEX_COLLECTION), doc, finalOptions, function(err, result) { - if(callback == null) return; - if(err) return handleCallback(callback, err); - if(result == null) return handleCallback(callback, null, null); - if(result.result.writeErrors) return handleCallback(callback, MongoError.create(result.result.writeErrors[0]), null); - handleCallback(callback, null, doc.name); - }); - }); -} - -define.classMethod('createIndex', {callback: true, promise:true}); - /** * Ensures that an index exists, if it does not it creates it * @method * @deprecated since version 2.0 * @param {string} name The index name * @param {(string|object)} fieldOrSpec Defines the index. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.unique=false] Creates an unique index. * @param {boolean} [options.sparse=false] Creates a sparse index. * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value - * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. - * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. - * @param {number} [options.v=null] Specify the format version of the indexes. - * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) - * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {number} [options.min] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ -Db.prototype.ensureIndex = function(name, fieldOrSpec, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; +Db.prototype.ensureIndex = deprecate(function(name, fieldOrSpec, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // If we have a callback fallback - if(typeof callback == 'function') return ensureIndex(self, name, fieldOrSpec, options, callback); - - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - ensureIndex(self, name, fieldOrSpec, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); -}; - -var ensureIndex = function(self, name, fieldOrSpec, options, callback) { - // Get the write concern options - var finalOptions = writeConcern({}, self, options); - // Create command - var selector = createCreateIndexCommand(self, name, fieldOrSpec, options); - var index_name = selector.name; - - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - - // Merge primary readPreference - finalOptions.readPreference = ReadPreference.PRIMARY - - // Check if the index already exists - self.indexInformation(name, finalOptions, function(err, indexInformation) { - if(err != null && err.code != 26) return handleCallback(callback, err, null); - // If the index does not exist, create it - if(indexInformation == null || !indexInformation[index_name]) { - self.createIndex(name, fieldOrSpec, options, callback); - } else { - if(typeof callback === 'function') return handleCallback(callback, null, index_name); - } - }); -} - -define.classMethod('ensureIndex', {callback: true, promise:true}); + return executeOperation(this.s.topology, ensureIndex, [ + this, + name, + fieldOrSpec, + options, + callback + ]); +}, 'Db.ensureIndex is deprecated as of MongoDB version 3.0 / driver version 2.0'); Db.prototype.addChild = function(db) { - if(this.s.parentDb) return this.s.parentDb.addChild(db); + if (this.s.parentDb) return this.s.parentDb.addChild(db); this.s.children.push(db); -} - -/** - * Create a new Db instance sharing the current socket connections. Be aware that the new db instances are - * related in a parent-child relationship to the original instance so that events are correctly emitted on child - * db instances. Child db instances are cached so performing db('db1') twice will return the same instance. - * You can control these behaviors with the options noListener and returnNonCachedInstance. - * - * @method - * @param {string} name The name of the database we want to use. - * @param {object} [options=null] Optional settings. - * @param {boolean} [options.noListener=false] Do not make the db an event listener to the original connection. - * @param {boolean} [options.returnNonCachedInstance=false] Control if you want to return a cached instance or have a new one created - * @return {Db} - */ -Db.prototype.db = function(dbName, options) { - options = options || {}; - - // Copy the options and add out internal override of the not shared flag - var finalOptions = assign({}, this.options, options); - - // Do we have the db in the cache already - if(this.s.dbCache[dbName] && finalOptions.returnNonCachedInstance !== true) { - return this.s.dbCache[dbName]; - } - - // Add current db as parentDb - if(finalOptions.noListener == null || finalOptions.noListener == false) { - finalOptions.parentDb = this; - } - - // Add promiseLibrary - finalOptions.promiseLibrary = this.s.promiseLibrary; - - // Return the db object - var db = new Db(dbName, this.s.topology, finalOptions) - - // Add as child - if(finalOptions.noListener == null || finalOptions.noListener == false) { - this.addChild(db); - } - - // Add the db to the cache - this.s.dbCache[dbName] = db; - // Return the database - return db; }; -define.classMethod('db', {callback: false, promise:false, returns: [Db]}); - -var _executeAuthCreateUserCommand = function(self, username, password, options, callback) { - // Special case where there is no password ($external users) - if(typeof username == 'string' - && password != null && typeof password == 'object') { - options = password; - password = null; - } - - // Unpack all options - if(typeof options == 'function') { - callback = options; - options = {}; - } - - // Error out if we digestPassword set - if(options.digestPassword != null) { - throw toError("The digestPassword option is not supported via add_user. Please use db.command('createUser', ...) instead for this option."); - } - - // Get additional values - var customData = options.customData != null ? options.customData : {}; - var roles = Array.isArray(options.roles) ? options.roles : []; - var maxTimeMS = typeof options.maxTimeMS == 'number' ? options.maxTimeMS : null; - - // If not roles defined print deprecated message - if(roles.length == 0) { - console.log("Creating a user without roles is deprecated in MongoDB >= 2.6"); - } - - // Get the error options - var commandOptions = {writeCommand:true}; - if(options['dbName']) commandOptions.dbName = options['dbName']; - - // Add maxTimeMS to options if set - if(maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; - - // Check the db name and add roles if needed - if((self.databaseName.toLowerCase() == 'admin' || options.dbName == 'admin') && !Array.isArray(options.roles)) { - roles = ['root'] - } else if(!Array.isArray(options.roles)) { - roles = ['dbOwner'] - } - - // Build the command to execute - var command = { - createUser: username - , customData: customData - , roles: roles - , digestPassword:false - } - - // Apply write concern to command - command = writeConcern(command, self, options); - - // Use node md5 generator - var md5 = crypto.createHash('md5'); - // Generate keys used for authentication - md5.update(username + ":mongo:" + password); - var userPassword = md5.digest('hex'); - - // No password - if(typeof password == 'string') { - command.pwd = userPassword; - } - - // Force write using primary - commandOptions.readPreference = ReadPreference.primary; - - // Execute the command - self.command(command, commandOptions, function(err, result) { - if(err && err.ok == 0 && err.code == undefined) return handleCallback(callback, {code: -5000}, null); - if(err) return handleCallback(callback, err, null); - handleCallback(callback, !result.ok ? toError(result) : null - , result.ok ? [{user: username, pwd: ''}] : null); - }) -} - -var addUser = function(self, username, password, options, callback) { - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - // Attempt to execute auth command - _executeAuthCreateUserCommand(self, username, password, options, function(err, r) { - // We need to perform the backward compatible insert operation - if(err && err.code == -5000) { - var finalOptions = writeConcern(shallowClone(options), self, options); - // Use node md5 generator - var md5 = crypto.createHash('md5'); - // Generate keys used for authentication - md5.update(username + ":mongo:" + password); - var userPassword = md5.digest('hex'); - - // If we have another db set - var db = options.dbName ? self.db(options.dbName) : self; - - // Fetch a user collection - var collection = db.collection(Db.SYSTEM_USER_COLLECTION); - - // Check if we are inserting the first user - collection.count({}, function(err, count) { - // We got an error (f.ex not authorized) - if(err != null) return handleCallback(callback, err, null); - // Check if the user exists and update i - collection.find({user: username}, {dbName: options['dbName']}).toArray(function(err) { - // We got an error (f.ex not authorized) - if(err != null) return handleCallback(callback, err, null); - // Add command keys - finalOptions.upsert = true; - - // We have a user, let's update the password or upsert if not - collection.update({user: username},{$set: {user: username, pwd: userPassword}}, finalOptions, function(err) { - if(count == 0 && err) return handleCallback(callback, null, [{user:username, pwd:userPassword}]); - if(err) return handleCallback(callback, err, null) - handleCallback(callback, null, [{user:username, pwd:userPassword}]); - }); - }); - }); - - return; - } - - if(err) return handleCallback(callback, err); - handleCallback(callback, err, r); - }); -} - /** * Add a user to the database. * @method * @param {string} username The username. * @param {string} password The password. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. - * @param {object} [options.customData=null] Custom data associated with the user (only Mongodb 2.6 or higher) - * @param {object[]} [options.roles=null] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {object} [options.customData] Custom data associated with the user (only Mongodb 2.6 or higher) + * @param {object[]} [options.roles] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.addUser = function(username, password, options, callback) { - // Unpack the parameters - var self = this; - var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - options = args.length ? args.shift() || {} : {}; - - // If we have a callback fallback - if(typeof callback == 'function') return addUser(self, username, password, options, callback); + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - addUser(self, username, password, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.topology, addUser, [this, username, password, options, callback]); }; -define.classMethod('addUser', {callback: true, promise:true}); - -var _executeAuthRemoveUserCommand = function(self, username, options, callback) { - if(typeof options == 'function') callback = options, options = {}; - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - // Get the error options - var commandOptions = {writeCommand:true}; - if(options['dbName']) commandOptions.dbName = options['dbName']; - - // Get additional values - var maxTimeMS = typeof options.maxTimeMS == 'number' ? options.maxTimeMS : null; - - // Add maxTimeMS to options if set - if(maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; - - // Build the command to execute - var command = { - dropUser: username - } - - // Apply write concern to command - command = writeConcern(command, self, options); - - // Force write using primary - commandOptions.readPreference = ReadPreference.primary; - - // Execute the command - self.command(command, commandOptions, function(err, result) { - if(err && !err.ok && err.code == undefined) return handleCallback(callback, {code: -5000}); - if(err) return handleCallback(callback, err, null); - handleCallback(callback, null, result.ok ? true : false); - }) -} - -var removeUser = function(self, username, options, callback) { - // Attempt to execute command - _executeAuthRemoveUserCommand(self, username, options, function(err, result) { - if(err && err.code == -5000) { - var finalOptions = writeConcern(shallowClone(options), self, options); - // If we have another db set - var db = options.dbName ? self.db(options.dbName) : self; - - // Fetch a user collection - var collection = db.collection(Db.SYSTEM_USER_COLLECTION); - - // Locate the user - collection.findOne({user: username}, {}, function(err, user) { - if(user == null) return handleCallback(callback, err, false); - collection.remove({user: username}, finalOptions, function(err) { - handleCallback(callback, err, true); - }); - }); - - return; - } - - if(err) return handleCallback(callback, err); - handleCallback(callback, err, result); - }); -} - -define.classMethod('removeUser', {callback: true, promise:true}); - /** * Remove a user from a database * @method * @param {string} username The username. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.removeUser = function(username, options, callback) { - // Unpack the parameters - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - options = args.length ? args.shift() || {} : {}; - - // If we have a callback fallback - if(typeof callback == 'function') return removeUser(self, username, options, callback); + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - removeUser(self, username, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.topology, removeUser, [this, username, options, callback]); }; /** - * Authenticate a user against the server. - * @method - * @param {string} username The username. - * @param {string} [password] The password. - * @param {object} [options=null] Optional settings. - * @param {string} [options.authMechanism=MONGODB-CR] The authentication mechanism to use, GSSAPI, MONGODB-CR, MONGODB-X509, PLAIN - * @param {Db~resultCallback} [callback] The command result callback + * Set the current profiling level of MongoDB + * + * @param {string} level The new profiling level (off, slow_only, all). + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Db~resultCallback} [callback] The command result callback. * @return {Promise} returns Promise if no callback passed - * @deprecated This method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials. */ -Db.prototype.authenticate = function(username, password, options, callback) { - console.warn("Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials."); - return authenticate.apply(this, [this].concat(Array.prototype.slice.call(arguments))); -}; +Db.prototype.setProfilingLevel = function(level, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('authenticate', {callback: true, promise:true}); + return executeOperation(this.s.topology, setProfilingLevel, [this, level, options, callback]); +}; /** - * Logout user from server, fire off on all connections and remove all auth info - * @method - * @param {object} [options=null] Optional settings. - * @param {string} [options.dbName=null] Logout against different database than current. - * @param {Db~resultCallback} [callback] The command result callback + * Retrive the current profiling information for MongoDB + * + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Db~resultCallback} [callback] The command result callback. * @return {Promise} returns Promise if no callback passed + * @deprecated Query the system.profile collection directly. */ -Db.prototype.logout = function(options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; +Db.prototype.profilingInfo = deprecate(function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // Establish the correct database name - var dbName = this.s.authSource ? this.s.authSource : this.s.databaseName; - dbName = options.dbName ? options.dbName : dbName; + return executeOperation(this.s.topology, profilingInfo, [this, options, callback]); +}, 'Db.profilingInfo is deprecated. Query the system.profile collection directly.'); - // If we have a callback - if(typeof callback == 'function') { - return self.s.topology.logout(dbName, function(err) { - if(err) return callback(err); - callback(null, true); - }); - } - - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - self.s.topology.logout(dbName, function(err) { - if(err) return reject(err); - resolve(true); - }); - }); -} +/** + * Retrieve the current profiling Level for MongoDB + * + * @param {Object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.profilingLevel = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('logout', {callback: true, promise:true}); + return executeOperation(this.s.topology, profilingLevel, [this, options, callback]); +}; /** * Retrieves this collections index info. * @method * @param {string} name The name of the collection. - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {boolean} [options.full=false] Returns the full raw index information. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {ClientSession} [options.session] optional session to use for this operation * @param {Db~resultCallback} [callback] The command result callback * @return {Promise} returns Promise if no callback passed */ Db.prototype.indexInformation = function(name, options, callback) { - var self = this; - if(typeof options == 'function') callback = options, options = {}; + if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - // If we have a callback fallback - if(typeof callback == 'function') return indexInformation(self, name, options, callback); - - // Return a promise - return new this.s.promiseLibrary(function(resolve, reject) { - indexInformation(self, name, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }); - }); + return executeOperation(this.s.topology, indexInformation, [this, name, options, callback]); }; -var indexInformation = function(self, name, options, callback) { - // If we specified full information - var full = options['full'] == null ? false : options['full']; - - // Did the user destroy the topology - if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); - // Process all the results from the index command and collection - var processResults = function(indexes) { - // Contains all the information - var info = {}; - // Process all the indexes - for(var i = 0; i < indexes.length; i++) { - var index = indexes[i]; - // Let's unpack the object - info[index.name] = []; - for(var name in index.key) { - info[index.name].push([name, index.key[name]]); - } - } - - return info; - } - - // Get the list of indexes of the specified collection - self.collection(name).listIndexes(options).toArray(function(err, indexes) { - if(err) return callback(toError(err)); - if(!Array.isArray(indexes)) return handleCallback(callback, null, []); - if(full) return handleCallback(callback, null, indexes); - handleCallback(callback, null, processResults(indexes)); - }); -} - -define.classMethod('indexInformation', {callback: true, promise:true}); - -var createCreateIndexCommand = function(db, name, fieldOrSpec, options) { - var indexParameters = parseIndexOptions(fieldOrSpec); - var fieldHash = indexParameters.fieldHash; - - // Generate the index name - var indexName = typeof options.name == 'string' ? options.name : indexParameters.name; - var selector = { - 'ns': db.databaseName + "." + name, 'key': fieldHash, 'name': indexName - } - - // Ensure we have a correct finalUnique - var finalUnique = options == null || 'object' === typeof options ? false : options; - // Set up options - options = options == null || typeof options == 'boolean' ? {} : options; - - // Add all the options - var keysToOmit = Object.keys(selector); - for(var optionName in options) { - if(keysToOmit.indexOf(optionName) == -1) { - selector[optionName] = options[optionName]; - } - } - - if(selector['unique'] == null) selector['unique'] = finalUnique; - - // Remove any write concern operations - var removeKeys = ['w', 'wtimeout', 'j', 'fsync', 'readPreference']; - for(var i = 0; i < removeKeys.length; i++) { - delete selector[removeKeys[i]]; - } - - // Return the command creation selector - return selector; -} - -var createIndexUsingCreateIndexes = function(self, name, fieldOrSpec, options, callback) { - // Build the index - var indexParameters = parseIndexOptions(fieldOrSpec); - // Generate the index name - var indexName = typeof options.name == 'string' ? options.name : indexParameters.name; - // Set up the index - var indexes = [{ name: indexName, key: indexParameters.fieldHash }]; - // merge all the options - var keysToOmit = Object.keys(indexes[0]); - for(var optionName in options) { - if(keysToOmit.indexOf(optionName) == -1) { - indexes[0][optionName] = options[optionName]; - } - - // Remove any write concern operations - var removeKeys = ['w', 'wtimeout', 'j', 'fsync', 'readPreference']; - for(var i = 0; i < removeKeys.length; i++) { - delete indexes[0][removeKeys[i]]; - } - } - - // Get capabilities - var capabilities = self.s.topology.capabilities(); - - // Did the user pass in a collation, check if our write server supports it - if(indexes[0].collation && capabilities && !capabilities.commandsTakeCollation) { - // Create a new error - var error = new MongoError(f('server/primary/mongos does not support collation')); - error.code = 67; - // Return the error - return callback(error); - } - - // Create command, apply write concern to command - var cmd = writeConcern({createIndexes: name, indexes: indexes}, self, options); - - // Decorate command with writeConcern if supported - decorateWithWriteConcern(cmd, self, options); - - // ReadPreference primary - options.readPreference = ReadPreference.PRIMARY; - - // Build the command - self.command(cmd, options, function(err, result) { - if(err) return handleCallback(callback, err, null); - if(result.ok == 0) return handleCallback(callback, toError(result), null); - // Return the indexName for backward compatibility - handleCallback(callback, null, indexName); - }); -} - -// Validate the database name -var validateDatabaseName = function(databaseName) { - if(typeof databaseName !== 'string') throw MongoError.create({message: "database name must be a string", driver:true}); - if(databaseName.length === 0) throw MongoError.create({message: "database name cannot be the empty string", driver:true}); - if(databaseName == '$external') return; - - var invalidChars = [" ", ".", "$", "/", "\\"]; - for(var i = 0; i < invalidChars.length; i++) { - if(databaseName.indexOf(invalidChars[i]) != -1) throw MongoError.create({message: "database names cannot contain the character '" + invalidChars[i] + "'", driver:true}); - } -} - -// Get write concern -var writeConcern = function(target, db, options) { - if(options.w != null || options.j != null || options.fsync != null) { - var opts = {}; - if(options.w) opts.w = options.w; - if(options.wtimeout) opts.wtimeout = options.wtimeout; - if(options.j) opts.j = options.j; - if(options.fsync) opts.fsync = options.fsync; - target.writeConcern = opts; - } else if(db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null) { - target.writeConcern = db.writeConcern; - } - - return target -} +/** + * Unref all sockets + * @method + */ +Db.prototype.unref = function() { + this.s.topology.unref(); +}; -// Add listeners to topology -var createListener = function(self, e, object) { - var listener = function(err) { - if(object.listeners(e).length > 0) { - object.emit(e, err, self); +/** + * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this database. Will ignore all changes to system collections. + * @method + * @since 3.1.0 + * @param {Array} [pipeline] An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents. + * @param {object} [options] Optional settings + * @param {string} [options.fullDocument='default'] Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred. + * @param {object} [options.resumeAfter] Specifies the logical starting point for the new change stream. This should be the _id field from a previously returned change stream document. + * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a change stream query + * @param {number} [options.batchSize] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {ReadPreference} [options.readPreference] The read preference. Defaults to the read preference of the database. See {@link https://docs.mongodb.com/manual/reference/read-preference|read preference documentation}. + * @param {Timestamp} [options.startAtClusterTime] receive change events that occur after the specified timestamp + * @param {ClientSession} [options.session] optional session to use for this operation + * @return {ChangeStream} a ChangeStream instance. + */ +Db.prototype.watch = function(pipeline, options) { + pipeline = pipeline || []; + options = options || {}; - // Emit on all associated db's if available - for(var i = 0; i < self.s.children.length; i++) { - self.s.children[i].emit(e, err, self.s.children[i]); - } - } + // Allow optionally not specifying a pipeline + if (!Array.isArray(pipeline)) { + options = pipeline; + pipeline = []; } - return listener; -} + return new ChangeStream(this, pipeline, options); +}; /** - * Unref all sockets + * Return the db logger * @method + * @return {Logger} return the db logger + * @ignore */ -Db.prototype.unref = function() { - this.s.topology.unref(); -} +Db.prototype.getLogger = function() { + return this.s.logger; +}; /** * Db close event @@ -1736,15 +924,6 @@ Db.prototype.unref = function() { * @type {MongoError} */ -/** - * Db authenticated event - * - * Emitted after all server members in the topology (single server, replicaset or mongos) have successfully authenticated. - * - * @event Db#authenticated - * @type {object} - */ - /** * Db reconnect event * @@ -1795,11 +974,11 @@ Db.prototype.unref = function() { */ // Constants -Db.SYSTEM_NAMESPACE_COLLECTION = "system.namespaces"; -Db.SYSTEM_INDEX_COLLECTION = "system.indexes"; -Db.SYSTEM_PROFILE_COLLECTION = "system.profile"; -Db.SYSTEM_USER_COLLECTION = "system.users"; -Db.SYSTEM_COMMAND_COLLECTION = "$cmd"; -Db.SYSTEM_JS_COLLECTION = "system.js"; +Db.SYSTEM_NAMESPACE_COLLECTION = 'system.namespaces'; +Db.SYSTEM_INDEX_COLLECTION = 'system.indexes'; +Db.SYSTEM_PROFILE_COLLECTION = 'system.profile'; +Db.SYSTEM_USER_COLLECTION = 'system.users'; +Db.SYSTEM_COMMAND_COLLECTION = '$cmd'; +Db.SYSTEM_JS_COLLECTION = 'system.js'; module.exports = Db; diff --git a/node_modules/mongodb/lib/error.js b/node_modules/mongodb/lib/error.js new file mode 100644 index 0000000..03b555a --- /dev/null +++ b/node_modules/mongodb/lib/error.js @@ -0,0 +1,43 @@ +'use strict'; + +const MongoNetworkError = require('mongodb-core').MongoNetworkError; +const mongoErrorContextSymbol = require('mongodb-core').mongoErrorContextSymbol; + +const GET_MORE_NON_RESUMABLE_CODES = new Set([ + 136, // CappedPositionLost + 237, // CursorKilled + 11601 // Interrupted +]); + +// From spec@https://github.com/mongodb/specifications/blob/35e466ddf25059cb30e4113de71cdebd3754657f/source/change-streams.rst#resumable-error: +// +// An error is considered resumable if it meets any of the following criteria: +// - any error encountered which is not a server error (e.g. a timeout error or network error) +// - any server error response from a getMore command excluding those containing the following error codes +// - Interrupted: 11601 +// - CappedPositionLost: 136 +// - CursorKilled: 237 +// - a server error response with an error message containing the substring "not master" or "node is recovering" +// +// An error on an aggregate command is not a resumable error. Only errors on a getMore command may be considered resumable errors. + +function isGetMoreError(error) { + if (error[mongoErrorContextSymbol]) { + return error[mongoErrorContextSymbol].isGetMore; + } +} + +function isResumableError(error) { + if (!isGetMoreError(error)) { + return false; + } + + return !!( + error instanceof MongoNetworkError || + !GET_MORE_NON_RESUMABLE_CODES.has(error.code) || + error.message.match(/not master/) || + error.message.match(/node is recovering/) + ); +} + +module.exports = { GET_MORE_NON_RESUMABLE_CODES, isResumableError }; diff --git a/node_modules/mongodb/lib/gridfs-stream/download.js b/node_modules/mongodb/lib/gridfs-stream/download.js index b8e0a30..9012602 100644 --- a/node_modules/mongodb/lib/gridfs-stream/download.js +++ b/node_modules/mongodb/lib/gridfs-stream/download.js @@ -1,3 +1,5 @@ +'use strict'; + var stream = require('stream'), util = require('util'); @@ -13,11 +15,11 @@ module.exports = GridFSBucketReadStream; * @param {Collection} files Handle for files collection * @param {Object} readPreference The read preference to use * @param {Object} filter The query to use to find the file document - * @param {Object} [options=null] Optional settings. - * @param {Number} [options.sort=null] Optional sort for the file find query - * @param {Number} [options.skip=null] Optional skip for the file find query - * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from - * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @param {Object} [options] Optional settings. + * @param {Number} [options.sort] Optional sort for the file find query + * @param {Number} [options.skip] Optional skip for the file find query + * @param {Number} [options.start] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end] Optional 0-based offset in bytes to stop streaming before * @fires GridFSBucketReadStream#error * @fires GridFSBucketReadStream#file * @return {GridFSBucketReadStream} a GridFSBucketReadStream instance. @@ -161,8 +163,7 @@ GridFSBucketReadStream.prototype.abort = function(callback) { function throwIfInitialized(self) { if (self.s.init) { - throw new Error('You cannot change options after the stream has entered' + - 'flowing mode!'); + throw new Error('You cannot change options after the stream has entered' + 'flowing mode!'); } } @@ -194,18 +195,15 @@ function doRead(_this) { var bytesRemaining = _this.s.file.length - _this.s.bytesRead; var expectedN = _this.s.expected++; - var expectedLength = Math.min(_this.s.file.chunkSize, - bytesRemaining); + var expectedLength = Math.min(_this.s.file.chunkSize, bytesRemaining); if (doc.n > expectedN) { - var errmsg = 'ChunkIsMissing: Got unexpected n: ' + doc.n + - ', expected: ' + expectedN; + var errmsg = 'ChunkIsMissing: Got unexpected n: ' + doc.n + ', expected: ' + expectedN; return __handleError(_this, new Error(errmsg)); } if (doc.n < expectedN) { - errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n + - ', expected: ' + expectedN; + errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n + ', expected: ' + expectedN; return __handleError(_this, new Error(errmsg)); } @@ -217,8 +215,8 @@ function doRead(_this) { return __handleError(_this, new Error(errmsg)); } - errmsg = 'ChunkIsWrongSize: Got unexpected length: ' + - buf.length + ', expected: ' + expectedLength; + errmsg = + 'ChunkIsWrongSize: Got unexpected length: ' + buf.length + ', expected: ' + expectedLength; return __handleError(_this, new Error(errmsg)); } @@ -241,10 +239,8 @@ function doRead(_this) { } // If the remaining amount of data left is < chunkSize read the right amount of data - if (_this.s.options.end && ( - (_this.s.options.end - _this.s.bytesToSkip) < buf.length - )) { - sliceEnd = (_this.s.options.end - _this.s.bytesToSkip); + if (_this.s.options.end && _this.s.options.end - _this.s.bytesToSkip < buf.length) { + sliceEnd = _this.s.options.end - _this.s.bytesToSkip; } if (sliceStart != null || sliceEnd != null) { @@ -252,7 +248,7 @@ function doRead(_this) { } _this.push(buf); - }) + }); } /** @@ -276,8 +272,7 @@ function init(self) { return __handleError(self, error); } if (!doc) { - var identifier = self.s.filter._id ? - self.s.filter._id.toString() : self.s.filter.filename; + var identifier = self.s.filter._id ? self.s.filter._id.toString() : self.s.filter.filename; var errmsg = 'FileNotFound: file ' + identifier + ' was not found'; var err = new Error(errmsg); err.code = 'ENOENT'; @@ -306,10 +301,10 @@ function init(self) { // Currently (MongoDB 3.4.4) skip function does not support the index, // it needs to retrieve all the documents first and then skip them. (CS-25811) // As work around we use $gte on the "n" field. - if (self.s.options && self.s.options.start != null){ + if (self.s.options && self.s.options.start != null) { var skip = Math.floor(self.s.options.start / doc.chunkSize); - if (skip > 0){ - filter["n"] = {"$gte": skip}; + if (skip > 0) { + filter['n'] = { $gte: skip }; } } self.s.cursor = self.s.chunks.find(filter).sort({ n: 1 }); @@ -320,8 +315,7 @@ function init(self) { self.s.expectedEnd = Math.ceil(doc.length / doc.chunkSize); self.s.file = doc; - self.s.bytesToTrim = handleEndOption(self, doc, self.s.cursor, - self.s.options); + self.s.bytesToTrim = handleEndOption(self, doc, self.s.cursor, self.s.options); self.emit('file', doc); }); } @@ -342,7 +336,7 @@ function waitForFile(_this, callback) { _this.once('file', function() { callback(); - }) + }); } /** @@ -352,20 +346,30 @@ function waitForFile(_this, callback) { function handleStartOption(stream, doc, options) { if (options && options.start != null) { if (options.start > doc.length) { - throw new Error('Stream start (' + options.start + ') must not be ' + - 'more than the length of the file (' + doc.length +')'); + throw new Error( + 'Stream start (' + + options.start + + ') must not be ' + + 'more than the length of the file (' + + doc.length + + ')' + ); } if (options.start < 0) { - throw new Error('Stream start (' + options.start + ') must not be ' + - 'negative'); + throw new Error('Stream start (' + options.start + ') must not be ' + 'negative'); } if (options.end != null && options.end < options.start) { - throw new Error('Stream start (' + options.start + ') must not be ' + - 'greater than stream end (' + options.end + ')'); + throw new Error( + 'Stream start (' + + options.start + + ') must not be ' + + 'greater than stream end (' + + options.end + + ')' + ); } - stream.s.bytesRead = Math.floor(options.start / doc.chunkSize) * - doc.chunkSize; + stream.s.bytesRead = Math.floor(options.start / doc.chunkSize) * doc.chunkSize; stream.s.expected = Math.floor(options.start / doc.chunkSize); return options.start - stream.s.bytesRead; @@ -379,24 +383,26 @@ function handleStartOption(stream, doc, options) { function handleEndOption(stream, doc, cursor, options) { if (options && options.end != null) { if (options.end > doc.length) { - throw new Error('Stream end (' + options.end + ') must not be ' + - 'more than the length of the file (' + doc.length +')') + throw new Error( + 'Stream end (' + + options.end + + ') must not be ' + + 'more than the length of the file (' + + doc.length + + ')' + ); } if (options.start < 0) { - throw new Error('Stream end (' + options.end + ') must not be ' + - 'negative'); + throw new Error('Stream end (' + options.end + ') must not be ' + 'negative'); } - var start = options.start != null ? - Math.floor(options.start / doc.chunkSize) : - 0; + var start = options.start != null ? Math.floor(options.start / doc.chunkSize) : 0; cursor.limit(Math.ceil(options.end / doc.chunkSize) - start); stream.s.expectedEnd = Math.ceil(options.end / doc.chunkSize); - return (Math.ceil(options.end / doc.chunkSize) * doc.chunkSize) - - options.end; + return Math.ceil(options.end / doc.chunkSize) * doc.chunkSize - options.end; } } diff --git a/node_modules/mongodb/lib/gridfs-stream/index.js b/node_modules/mongodb/lib/gridfs-stream/index.js index e0e02c0..9d64a84 100644 --- a/node_modules/mongodb/lib/gridfs-stream/index.js +++ b/node_modules/mongodb/lib/gridfs-stream/index.js @@ -1,9 +1,12 @@ +'use strict'; + var Emitter = require('events').EventEmitter; var GridFSBucketReadStream = require('./download'); var GridFSBucketWriteStream = require('./upload'); var shallowClone = require('../utils').shallowClone; var toError = require('../utils').toError; var util = require('util'); +var executeOperation = require('../utils').executeOperation; var DEFAULT_GRIDFS_BUCKET_OPTIONS = { bucketName: 'fs', @@ -16,11 +19,11 @@ module.exports = GridFSBucket; * Constructor for a streaming GridFS interface * @class * @param {Db} db A db handle - * @param {object} [options=null] Optional settings. + * @param {object} [options] Optional settings. * @param {string} [options.bucketName="fs"] The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot. * @param {number} [options.chunkSizeBytes=255 * 1024] Number of bytes stored in each chunk. Defaults to 255KB - * @param {object} [options.writeConcern=null] Optional write concern to be passed to write operations, for instance `{ w: 1 }` - * @param {object} [options.readPreference=null] Optional read preference to be passed to read operations + * @param {object} [options.writeConcern] Optional write concern to be passed to write operations, for instance `{ w: 1 }` + * @param {object} [options.readPreference] Optional read preference to be passed to read operations * @fires GridFSBucketWriteStream#index * @return {GridFSBucket} */ @@ -48,8 +51,7 @@ function GridFSBucket(db, options) { _filesCollection: db.collection(options.bucketName + '.files'), checkedIndexes: false, calledOpenUploadStream: false, - promiseLibrary: db.s.promiseLibrary || - (typeof global.Promise == 'function' ? global.Promise : require('es6-promise').Promise) + promiseLibrary: db.s.promiseLibrary || Promise }; } @@ -72,11 +74,12 @@ util.inherits(GridFSBucket, Emitter); * file's id. * @method * @param {string} filename The value of the 'filename' key in the files doc - * @param {object} [options=null] Optional settings. - * @param {number} [options.chunkSizeBytes=null] Optional overwrite this bucket's chunkSizeBytes for this file - * @param {object} [options.metadata=null] Optional object to store in the file document's `metadata` field - * @param {string} [options.contentType=null] Optional string to store in the file document's `contentType` field - * @param {array} [options.aliases=null] Optional array of strings to store in the file document's `aliases` field + * @param {object} [options] Optional settings. + * @param {number} [options.chunkSizeBytes] Optional overwrite this bucket's chunkSizeBytes for this file + * @param {object} [options.metadata] Optional object to store in the file document's `metadata` field + * @param {string} [options.contentType] Optional string to store in the file document's `contentType` field + * @param {array} [options.aliases] Optional array of strings to store in the file document's `aliases` field + * @param {boolean} [options.disableMD5=false] If true, disables adding an md5 field to file data * @return {GridFSBucketWriteStream} */ @@ -99,11 +102,12 @@ GridFSBucket.prototype.openUploadStream = function(filename, options) { * @method * @param {string|number|object} id A custom id used to identify the file * @param {string} filename The value of the 'filename' key in the files doc - * @param {object} [options=null] Optional settings. - * @param {number} [options.chunkSizeBytes=null] Optional overwrite this bucket's chunkSizeBytes for this file - * @param {object} [options.metadata=null] Optional object to store in the file document's `metadata` field - * @param {string} [options.contentType=null] Optional string to store in the file document's `contentType` field - * @param {array} [options.aliases=null] Optional array of strings to store in the file document's `aliases` field + * @param {object} [options] Optional settings. + * @param {number} [options.chunkSizeBytes] Optional overwrite this bucket's chunkSizeBytes for this file + * @param {object} [options.metadata] Optional object to store in the file document's `metadata` field + * @param {string} [options.contentType] Optional string to store in the file document's `contentType` field + * @param {array} [options.aliases] Optional array of strings to store in the file document's `aliases` field + * @param {boolean} [options.disableMD5=false] If true, disables adding an md5 field to file data * @return {GridFSBucketWriteStream} */ @@ -128,9 +132,9 @@ GridFSBucket.prototype.openUploadStreamWithId = function(id, filename, options) * data from GridFS. * @method * @param {ObjectId} id The id of the file doc - * @param {Object} [options=null] Optional settings. - * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from - * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @param {Object} [options] Optional settings. + * @param {Number} [options.start] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end] Optional 0-based offset in bytes to stop streaming before * @return {GridFSBucketReadStream} */ @@ -141,8 +145,13 @@ GridFSBucket.prototype.openDownloadStream = function(id, options) { end: options && options.end }; - return new GridFSBucketReadStream(this.s._chunksCollection, - this.s._filesCollection, this.s.options.readPreference, filter, options); + return new GridFSBucketReadStream( + this.s._chunksCollection, + this.s._filesCollection, + this.s.options.readPreference, + filter, + options + ); }; /** @@ -153,19 +162,8 @@ GridFSBucket.prototype.openDownloadStream = function(id, options) { */ GridFSBucket.prototype.delete = function(id, callback) { - if (typeof callback === 'function') { - return _delete(this, id, callback); - } - - var _this = this; - return new this.s.promiseLibrary(function(resolve, reject) { - _delete(_this, id, function(error, res) { - if (error) { - reject(error); - } else { - resolve(res); - } - }); + return executeOperation(this.s.db.s.topology, _delete, [this, id, callback], { + skipSessions: true }); }; @@ -199,13 +197,13 @@ function _delete(_this, id, callback) { * Convenience wrapper around find on the files collection * @method * @param {Object} filter - * @param {Object} [options=null] Optional settings for cursor - * @param {number} [options.batchSize=null] Optional batch size for cursor - * @param {number} [options.limit=null] Optional limit for cursor - * @param {number} [options.maxTimeMS=null] Optional maxTimeMS for cursor - * @param {boolean} [options.noCursorTimeout=null] Optionally set cursor's `noCursorTimeout` flag - * @param {number} [options.skip=null] Optional skip for cursor - * @param {object} [options.sort=null] Optional sort for cursor + * @param {Object} [options] Optional settings for cursor + * @param {number} [options.batchSize] Optional batch size for cursor + * @param {number} [options.limit] Optional limit for cursor + * @param {number} [options.maxTimeMS] Optional maxTimeMS for cursor + * @param {boolean} [options.noCursorTimeout] Optionally set cursor's `noCursorTimeout` flag + * @param {number} [options.skip] Optional skip for cursor + * @param {object} [options.sort] Optional sort for cursor * @return {Cursor} */ @@ -245,10 +243,10 @@ GridFSBucket.prototype.find = function(filter, options) { * option to change this behavior. * @method * @param {String} filename The name of the file to stream - * @param {Object} [options=null] Optional settings + * @param {Object} [options] Optional settings * @param {number} [options.revision=-1] The revision number relative to the oldest file with the given filename. 0 gets you the oldest file, 1 gets you the 2nd oldest, -1 gets you the newest. - * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from - * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @param {Number} [options.start] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end] Optional 0-based offset in bytes to stop streaming before * @return {GridFSBucketReadStream} */ @@ -271,8 +269,13 @@ GridFSBucket.prototype.openDownloadStreamByName = function(filename, options) { start: options && options.start, end: options && options.end }; - return new GridFSBucketReadStream(this.s._chunksCollection, - this.s._filesCollection, this.s.options.readPreference, filter, options); + return new GridFSBucketReadStream( + this.s._chunksCollection, + this.s._filesCollection, + this.s.options.readPreference, + filter, + options + ); }; /** @@ -284,19 +287,8 @@ GridFSBucket.prototype.openDownloadStreamByName = function(filename, options) { */ GridFSBucket.prototype.rename = function(id, filename, callback) { - if (typeof callback === 'function') { - return _rename(this, id, filename, callback); - } - - var _this = this; - return new this.s.promiseLibrary(function(resolve, reject) { - _rename(_this, id, filename, function(error, res) { - if (error) { - reject(error); - } else { - resolve(res); - } - }); + return executeOperation(this.s.db.s.topology, _rename, [this, id, filename, callback], { + skipSessions: true }); }; @@ -325,22 +317,21 @@ function _rename(_this, id, filename, callback) { */ GridFSBucket.prototype.drop = function(callback) { - if (typeof callback === 'function') { - return _drop(this, callback); - } - - var _this = this; - return new this.s.promiseLibrary(function(resolve, reject) { - _drop(_this, function(error, res) { - if (error) { - reject(error); - } else { - resolve(res); - } - }); + return executeOperation(this.s.db.s.topology, _drop, [this, callback], { + skipSessions: true }); }; +/** + * Return the db logger + * @method + * @return {Logger} return the db logger + * @ignore + */ +GridFSBucket.prototype.getLogger = function() { + return this.s.db.s.logger; +}; + /** * @ignore */ diff --git a/node_modules/mongodb/lib/gridfs-stream/upload.js b/node_modules/mongodb/lib/gridfs-stream/upload.js index 180666e..da77dcd 100644 --- a/node_modules/mongodb/lib/gridfs-stream/upload.js +++ b/node_modules/mongodb/lib/gridfs-stream/upload.js @@ -1,7 +1,10 @@ +'use strict'; + var core = require('mongodb-core'); var crypto = require('crypto'); var stream = require('stream'); var util = require('util'); +var Buffer = require('safe-buffer').Buffer; var ERROR_NAMESPACE_NOT_FOUND = 26; @@ -15,12 +18,13 @@ module.exports = GridFSBucketWriteStream; * @class * @param {GridFSBucket} bucket Handle for this stream's corresponding bucket * @param {string} filename The value of the 'filename' key in the files doc - * @param {object} [options=null] Optional settings. - * @param {string|number|object} [options.id=null] Custom file id for the GridFS file. - * @param {number} [options.chunkSizeBytes=null] The chunk size to use, in bytes - * @param {number} [options.w=null] The write concern - * @param {number} [options.wtimeout=null] The write concern timeout - * @param {number} [options.j=null] The journal write concern + * @param {object} [options] Optional settings. + * @param {string|number|object} [options.id] Custom file id for the GridFS file. + * @param {number} [options.chunkSizeBytes] The chunk size to use, in bytes + * @param {number} [options.w] The write concern + * @param {number} [options.wtimeout] The write concern timeout + * @param {number} [options.j] The journal write concern + * @param {boolean} [options.disableMD5=false] If true, disables adding an md5 field to file data * @fires GridFSBucketWriteStream#error * @fires GridFSBucketWriteStream#finish * @return {GridFSBucketWriteStream} a GridFSBucketWriteStream instance. @@ -38,9 +42,9 @@ function GridFSBucketWriteStream(bucket, filename, options) { this.id = options.id ? options.id : core.BSON.ObjectId(); this.chunkSizeBytes = this.options.chunkSizeBytes; - this.bufToStore = new Buffer(this.chunkSizeBytes); + this.bufToStore = Buffer.alloc(this.chunkSizeBytes); this.length = 0; - this.md5 = crypto.createHash('md5'); + this.md5 = !options.disableMD5 && crypto.createHash('md5'); this.n = 0; this.pos = 0; this.state = { @@ -108,21 +112,21 @@ GridFSBucketWriteStream.prototype.write = function(chunk, encoding, callback) { GridFSBucketWriteStream.prototype.abort = function(callback) { if (this.state.streamEnd) { var error = new Error('Cannot abort a stream that has already completed'); - if (typeof callback == 'function') { + if (typeof callback === 'function') { return callback(error); } return this.state.promiseLibrary.reject(error); } if (this.state.aborted) { error = new Error('Cannot call abort() on a stream twice'); - if (typeof callback == 'function') { + if (typeof callback === 'function') { return callback(error); } return this.state.promiseLibrary.reject(error); } this.state.aborted = true; this.chunks.deleteMany({ files_id: this.id }, function(error) { - if(typeof callback == 'function') callback(error); + if (typeof callback === 'function') callback(error); }); }; @@ -139,10 +143,10 @@ GridFSBucketWriteStream.prototype.abort = function(callback) { GridFSBucketWriteStream.prototype.end = function(chunk, encoding, callback) { var _this = this; - if(typeof chunk == 'function') { - callback = chunk, chunk = null, encoding = null; - } else if(typeof encoding == 'function') { - callback = encoding, encoding = null; + if (typeof chunk === 'function') { + (callback = chunk), (chunk = null), (encoding = null); + } else if (typeof encoding === 'function') { + (callback = encoding), (encoding = null); } if (checkAborted(this, callback)) { @@ -222,8 +226,7 @@ function checkChunksIndex(_this, callback) { indexes.forEach(function(index) { if (index.key) { var keys = Object.keys(index.key); - if (keys.length === 2 && index.key.files_id === 1 && - index.key.n === 1) { + if (keys.length === 2 && index.key.files_id === 1 && index.key.n === 1) { hasChunksIndex = true; } } @@ -254,16 +257,21 @@ function checkChunksIndex(_this, callback) { */ function checkDone(_this, callback) { - if(_this.done) return true; - if (_this.state.streamEnd && - _this.state.outstandingRequests === 0 && - !_this.state.errored) { + if (_this.done) return true; + if (_this.state.streamEnd && _this.state.outstandingRequests === 0 && !_this.state.errored) { // Set done so we dont' trigger duplicate createFilesDoc _this.done = true; // Create a new files doc - var filesDoc = createFilesDoc(_this.id, _this.length, _this.chunkSizeBytes, - _this.md5.digest('hex'), _this.filename, _this.options.contentType, - _this.options.aliases, _this.options.metadata); + var filesDoc = createFilesDoc( + _this.id, + _this.length, + _this.chunkSizeBytes, + _this.md5 && _this.md5.digest('hex'), + _this.filename, + _this.options.contentType, + _this.options.aliases, + _this.options.metadata + ); if (checkAborted(_this, callback)) { return false; @@ -315,8 +323,7 @@ function checkIndexes(_this, callback) { var hasFileIndex = false; indexes.forEach(function(index) { var keys = Object.keys(index.key); - if (keys.length === 2 && index.key.filename === 1 && - index.key.uploadDate === 1) { + if (keys.length === 2 && index.key.filename === 1 && index.key.uploadDate === 1) { hasFileIndex = true; } }); @@ -346,17 +353,19 @@ function checkIndexes(_this, callback) { * @ignore */ -function createFilesDoc(_id, length, chunkSize, md5, filename, contentType, - aliases, metadata) { +function createFilesDoc(_id, length, chunkSize, md5, filename, contentType, aliases, metadata) { var ret = { _id: _id, length: length, chunkSize: chunkSize, uploadDate: new Date(), - md5: md5, filename: filename }; + if (md5) { + ret.md5 = md5; + } + if (contentType) { ret.contentType = contentType; } @@ -381,8 +390,7 @@ function doWrite(_this, chunk, encoding, callback) { return false; } - var inputBuf = (Buffer.isBuffer(chunk)) ? - chunk : new Buffer(chunk, encoding); + var inputBuf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding); _this.length += inputBuf.length; @@ -407,12 +415,13 @@ function doWrite(_this, chunk, encoding, callback) { var outstandingRequests = 0; while (inputBufRemaining > 0) { var inputBufPos = inputBuf.length - inputBufRemaining; - inputBuf.copy(_this.bufToStore, _this.pos, - inputBufPos, inputBufPos + numToCopy); + inputBuf.copy(_this.bufToStore, _this.pos, inputBufPos, inputBufPos + numToCopy); _this.pos += numToCopy; spaceRemaining -= numToCopy; if (spaceRemaining === 0) { - _this.md5.update(_this.bufToStore); + if (_this.md5) { + _this.md5.update(_this.bufToStore); + } var doc = createChunkDoc(_this.id, _this.n, _this.bufToStore); ++_this.state.outstandingRequests; ++outstandingRequests; @@ -427,7 +436,7 @@ function doWrite(_this, chunk, encoding, callback) { } --_this.state.outstandingRequests; --outstandingRequests; - + if (!outstandingRequests) { _this.emit('drain', doc); callback && callback(); @@ -493,9 +502,11 @@ function writeRemnant(_this, callback) { // Create a new buffer to make sure the buffer isn't bigger than it needs // to be. - var remnant = new Buffer(_this.pos); + var remnant = Buffer.alloc(_this.pos); _this.bufToStore.copy(remnant, 0, 0, _this.pos); - _this.md5.update(remnant); + if (_this.md5) { + _this.md5.update(remnant); + } var doc = createChunkDoc(_this.id, _this.n, remnant); // If the stream was aborted, do not write remnant @@ -518,7 +529,7 @@ function writeRemnant(_this, callback) { function checkAborted(_this, callback) { if (_this.state.aborted) { - if(typeof callback == 'function') { + if (typeof callback === 'function') { callback(new Error('this stream has been aborted')); } return true; diff --git a/node_modules/mongodb/lib/gridfs/chunk.js b/node_modules/mongodb/lib/gridfs/chunk.js index 9100197..c29bba0 100644 --- a/node_modules/mongodb/lib/gridfs/chunk.js +++ b/node_modules/mongodb/lib/gridfs/chunk.js @@ -1,8 +1,10 @@ -"use strict"; +'use strict'; var Binary = require('mongodb-core').BSON.Binary, ObjectID = require('mongodb-core').BSON.ObjectID; +var Buffer = require('safe-buffer').Buffer; + /** * Class for representing a single chunk in GridFS. * @@ -19,28 +21,28 @@ var Binary = require('mongodb-core').BSON.Binary, * @see Chunk#buildMongoObject */ var Chunk = function(file, mongoObject, writeConcern) { - if(!(this instanceof Chunk)) return new Chunk(file, mongoObject); + if (!(this instanceof Chunk)) return new Chunk(file, mongoObject); this.file = file; var mongoObjectFinal = mongoObject == null ? {} : mongoObject; - this.writeConcern = writeConcern || {w:1}; + this.writeConcern = writeConcern || { w: 1 }; this.objectId = mongoObjectFinal._id == null ? new ObjectID() : mongoObjectFinal._id; this.chunkNumber = mongoObjectFinal.n == null ? 0 : mongoObjectFinal.n; this.data = new Binary(); - if(typeof mongoObjectFinal.data == "string") { - var buffer = new Buffer(mongoObjectFinal.data.length); + if (typeof mongoObjectFinal.data === 'string') { + var buffer = Buffer.alloc(mongoObjectFinal.data.length); buffer.write(mongoObjectFinal.data, 0, mongoObjectFinal.data.length, 'binary'); this.data = new Binary(buffer); - } else if(Array.isArray(mongoObjectFinal.data)) { - buffer = new Buffer(mongoObjectFinal.data.length); + } else if (Array.isArray(mongoObjectFinal.data)) { + buffer = Buffer.alloc(mongoObjectFinal.data.length); var data = mongoObjectFinal.data.join(''); buffer.write(data, 0, data.length, 'binary'); this.data = new Binary(buffer); - } else if(mongoObjectFinal.data && mongoObjectFinal.data._bsontype === 'Binary') { + } else if (mongoObjectFinal.data && mongoObjectFinal.data._bsontype === 'Binary') { this.data = mongoObjectFinal.data; - } else if(!Buffer.isBuffer(mongoObjectFinal.data) && !(mongoObjectFinal.data == null)){ - throw Error("Illegal chunk format"); + } else if (!Buffer.isBuffer(mongoObjectFinal.data) && !(mongoObjectFinal.data == null)) { + throw Error('Illegal chunk format'); } // Update position @@ -58,7 +60,7 @@ var Chunk = function(file, mongoObject, writeConcern) { Chunk.prototype.write = function(data, callback) { this.data.write(data, this.internalPosition, data.length, 'binary'); this.internalPosition = this.data.length(); - if(callback != null) return callback(null, this); + if (callback != null) return callback(null, this); return this; }; @@ -72,9 +74,9 @@ Chunk.prototype.write = function(data, callback) { */ Chunk.prototype.read = function(length) { // Default to full read if no index defined - length = length == null || length == 0 ? this.length() : length; + length = length == null || length === 0 ? this.length() : length; - if(this.length() - this.internalPosition + 1 >= length) { + if (this.length() - this.internalPosition + 1 >= length) { var data = this.data.read(this.internalPosition, length); this.internalPosition = this.internalPosition + length; return data; @@ -84,12 +86,14 @@ Chunk.prototype.read = function(length) { }; Chunk.prototype.readSlice = function(length) { - if ((this.length() - this.internalPosition) >= length) { + if (this.length() - this.internalPosition >= length) { var data = null; - if (this.data.buffer != null) { //Pure BSON + if (this.data.buffer != null) { + //Pure BSON data = this.data.buffer.slice(this.internalPosition, this.internalPosition + length); - } else { //Native BSON - data = new Buffer(length); + } else { + //Native BSON + data = Buffer.alloc(length); length = this.data.readInto(data, this.internalPosition); } this.internalPosition = this.internalPosition + length; @@ -106,7 +110,7 @@ Chunk.prototype.readSlice = function(length) { * chunk. */ Chunk.prototype.eof = function() { - return this.internalPosition == this.length() ? true : false; + return this.internalPosition === this.length() ? true : false; }; /** @@ -139,27 +143,27 @@ Chunk.prototype.rewind = function() { */ Chunk.prototype.save = function(options, callback) { var self = this; - if(typeof options == 'function') { + if (typeof options === 'function') { callback = options; options = {}; } self.file.chunkCollection(function(err, collection) { - if(err) return callback(err); + if (err) return callback(err); // Merge the options var writeOptions = { upsert: true }; - for(var name in options) writeOptions[name] = options[name]; - for(name in self.writeConcern) writeOptions[name] = self.writeConcern[name]; + for (var name in options) writeOptions[name] = options[name]; + for (name in self.writeConcern) writeOptions[name] = self.writeConcern[name]; - if(self.data.length() > 0) { + if (self.data.length() > 0) { self.buildMongoObject(function(mongoObject) { - var options = {forceServerObjectId:true}; - for(var name in self.writeConcern) { + var options = { forceServerObjectId: true }; + for (var name in self.writeConcern) { options[name] = self.writeConcern[name]; } - collection.replaceOne({'_id':self.objectId}, mongoObject, writeOptions, function(err) { + collection.replaceOne({ _id: self.objectId }, mongoObject, writeOptions, function(err) { callback(err, self); }); }); @@ -190,11 +194,12 @@ Chunk.prototype.save = function(options, callback) { */ Chunk.prototype.buildMongoObject = function(callback) { var mongoObject = { - 'files_id': this.file.fileId, - 'n': this.chunkNumber, - 'data': this.data}; + files_id: this.file.fileId, + n: this.chunkNumber, + data: this.data + }; // If we are saving using a specific ObjectId - if(this.objectId != null) mongoObject._id = this.objectId; + if (this.objectId != null) mongoObject._id = this.objectId; callback(mongoObject); }; @@ -212,13 +217,14 @@ Chunk.prototype.length = function() { * @lends Chunk# * @field */ -Object.defineProperty(Chunk.prototype, "position", { enumerable: true - , get: function () { - return this.internalPosition; - } - , set: function(value) { - this.internalPosition = value; - } +Object.defineProperty(Chunk.prototype, 'position', { + enumerable: true, + get: function() { + return this.internalPosition; + }, + set: function(value) { + this.internalPosition = value; + } }); /** diff --git a/node_modules/mongodb/lib/gridfs/grid_store.js b/node_modules/mongodb/lib/gridfs/grid_store.js index ebf6613..4b5eb5e 100644 --- a/node_modules/mongodb/lib/gridfs/grid_store.js +++ b/node_modules/mongodb/lib/gridfs/grid_store.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; /** * @fileOverview GridFS is a tool for MongoDB to store files to the database. @@ -9,24 +9,25 @@ * found here. * * @example - * var MongoClient = require('mongodb').MongoClient, - * GridStore = require('mongodb').GridStore, - * ObjectID = require('mongodb').ObjectID, - * test = require('assert'); - * + * const MongoClient = require('mongodb').MongoClient; + * const GridStore = require('mongodb').GridStore; + * const ObjectID = require('mongodb').ObjectID; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { - * var gridStore = new GridStore(db, null, "w"); + * MongoClient.connect(url, function(err, client) { + * const db = client.db(dbName); + * const gridStore = new GridStore(db, null, "w"); * gridStore.open(function(err, gridStore) { * gridStore.write("hello world!", function(err, gridStore) { * gridStore.close(function(err, result) { - * * // Let's read the file using object Id * GridStore.read(db, result._id, function(err, data) { * test.equal('hello world!', data); - * db.close(); + * client.close(); * test.done(); * }); * }); @@ -34,23 +35,26 @@ * }); * }); */ -var Chunk = require('./chunk'), - ObjectID = require('mongodb-core').BSON.ObjectID, - ReadPreference = require('../read_preference'), - Buffer = require('buffer').Buffer, - Collection = require('../collection'), - fs = require('fs'), - f = require('util').format, - util = require('util'), - Define = require('../metadata'), - MongoError = require('mongodb-core').MongoError, - inherits = util.inherits, - Duplex = require('stream').Duplex || require('readable-stream').Duplex, - shallowClone = require('../utils').shallowClone; +const Chunk = require('./chunk'); +const ObjectID = require('mongodb-core').BSON.ObjectID; +const ReadPreference = require('mongodb-core').ReadPreference; +const Buffer = require('safe-buffer').Buffer; +const fs = require('fs'); +const f = require('util').format; +const util = require('util'); +const MongoError = require('mongodb-core').MongoError; +const inherits = util.inherits; +const Duplex = require('stream').Duplex; +const shallowClone = require('../utils').shallowClone; +const executeOperation = require('../utils').executeOperation; +const deprecate = require('util').deprecate; var REFERENCE_BY_FILENAME = 0, REFERENCE_BY_ID = 1; +const deprecationFn = deprecate(() => {}, +'GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead'); + /** * Namespace provided by the mongodb-core and node.js * @external Duplex @@ -61,24 +65,24 @@ var REFERENCE_BY_FILENAME = 0, * * Modes * - **"r"** - read only. This is the default mode. - * - **"w"** - write in truncate mode. Existing data will be overwritten. + * - **"w"** - write in truncate mode. Existing data will be overwriten. * * @class * @param {Db} db A database instance to interact with. * @param {object} [id] optional unique id for this file * @param {string} [filename] optional filename for this file, no unique constrain on the field * @param {string} mode set the mode for this file. - * @param {object} [options=null] Optional settings. - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {object} [options] Optional settings. + * @param {(number|string)} [options.w] The write concern. + * @param {number} [options.wtimeout] The write concern timeout. * @param {boolean} [options.j=false] Specify a journal write concern. * @param {boolean} [options.fsync=false] Specify a file sync write concern. - * @param {string} [options.root=null] Root collection to use. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. - * @param {string} [options.content_type=null] MIME type of the file. Defaults to **{GridStore.DEFAULT_CONTENT_TYPE}**. + * @param {string} [options.root] Root collection to use. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. + * @param {string} [options.content_type] MIME type of the file. Defaults to **{GridStore.DEFAULT_CONTENT_TYPE}**. * @param {number} [options.chunk_size=261120] Size for the chunk. Defaults to **{Chunk.DEFAULT_CHUNK_SIZE}**. - * @param {object} [options.metadata=null] Arbitrary data the user wants to store. - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.metadata] Arbitrary data the user wants to store. + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). * @property {number} chunkSize Get the gridstore chunk size. * @property {number} md5 The md5 checksum for this file. * @property {number} chunkNumber The current chunk number the gridstore has materialized into memory @@ -86,26 +90,27 @@ var REFERENCE_BY_FILENAME = 0, * @deprecated Use GridFSBucket API instead */ var GridStore = function GridStore(db, id, filename, mode, options) { - if(!(this instanceof GridStore)) return new GridStore(db, id, filename, mode, options); + deprecationFn(); + if (!(this instanceof GridStore)) return new GridStore(db, id, filename, mode, options); this.db = db; // Handle options - if(typeof options === 'undefined') options = {}; + if (typeof options === 'undefined') options = {}; // Handle mode - if(typeof mode === 'undefined') { + if (typeof mode === 'undefined') { mode = filename; filename = undefined; - } else if(typeof mode == 'object') { + } else if (typeof mode === 'object') { options = mode; mode = filename; filename = undefined; } - if(id && id._bsontype == 'ObjectID') { + if (id && id._bsontype === 'ObjectID') { this.referenceBy = REFERENCE_BY_ID; this.fileId = id; this.filename = filename; - } else if(typeof filename == 'undefined') { + } else if (typeof filename === 'undefined') { this.referenceBy = REFERENCE_BY_FILENAME; this.filename = id; if (mode.indexOf('w') != null) { @@ -118,59 +123,59 @@ var GridStore = function GridStore(db, id, filename, mode, options) { } // Set up the rest - this.mode = mode == null ? "r" : mode; + this.mode = mode == null ? 'r' : mode; this.options = options || {}; // Opened this.isOpen = false; // Set the root if overridden - this.root = this.options['root'] == null ? GridStore.DEFAULT_ROOT_COLLECTION : this.options['root']; + this.root = + this.options['root'] == null ? GridStore.DEFAULT_ROOT_COLLECTION : this.options['root']; this.position = 0; - this.readPreference = this.options.readPreference || db.options.readPreference || ReadPreference.PRIMARY; + this.readPreference = + this.options.readPreference || db.options.readPreference || ReadPreference.primary; this.writeConcern = _getWriteConcern(db, this.options); // Set default chunk size - this.internalChunkSize = this.options['chunkSize'] == null ? Chunk.DEFAULT_CHUNK_SIZE : this.options['chunkSize']; + this.internalChunkSize = + this.options['chunkSize'] == null ? Chunk.DEFAULT_CHUNK_SIZE : this.options['chunkSize']; // Get the promiseLibrary - var promiseLibrary = this.options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } + var promiseLibrary = this.options.promiseLibrary || Promise; // Set the promiseLibrary this.promiseLibrary = promiseLibrary; - Object.defineProperty(this, "chunkSize", { enumerable: true - , get: function () { - return this.internalChunkSize; - } - , set: function(value) { - if(!(this.mode[0] == "w" && this.position == 0 && this.uploadDate == null)) { - this.internalChunkSize = this.internalChunkSize; - } else { - this.internalChunkSize = value; - } - } + Object.defineProperty(this, 'chunkSize', { + enumerable: true, + get: function() { + return this.internalChunkSize; + }, + set: function(value) { + if (!(this.mode[0] === 'w' && this.position === 0 && this.uploadDate == null)) { + this.internalChunkSize = this.internalChunkSize; + } else { + this.internalChunkSize = value; + } + } }); - Object.defineProperty(this, "md5", { enumerable: true - , get: function () { - return this.internalMd5; - } + Object.defineProperty(this, 'md5', { + enumerable: true, + get: function() { + return this.internalMd5; + } }); - Object.defineProperty(this, "chunkNumber", { enumerable: true - , get: function () { - return this.currentChunk && this.currentChunk.chunkNumber ? this.currentChunk.chunkNumber : null; - } + Object.defineProperty(this, 'chunkNumber', { + enumerable: true, + get: function() { + return this.currentChunk && this.currentChunk.chunkNumber + ? this.currentChunk.chunkNumber + : null; + } }); -} - -var define = GridStore.define = new Define('Gridstore', GridStore, true); +}; /** * The callback format for the Gridstore.open method @@ -184,33 +189,31 @@ var define = GridStore.define = new Define('Gridstore', GridStore, true); * new one if file does not exist. * * @method + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~openCallback} [callback] this will be called after executing this method * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.open = function(callback) { - var self = this; - if( this.mode != "w" && this.mode != "w+" && this.mode != "r"){ - throw MongoError.create({message: "Illegal mode " + this.mode, driver:true}); +GridStore.prototype.open = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + if (this.mode !== 'w' && this.mode !== 'w+' && this.mode !== 'r') { + throw MongoError.create({ message: 'Illegal mode ' + this.mode, driver: true }); } - // We provided a callback leg - if(typeof callback == 'function') return open(self, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - open(self, function(err, store) { - if(err) return reject(err); - resolve(store); - }) + return executeOperation(this.db.s.topology, open, [this, options, callback], { + skipSessions: true }); }; -var open = function(self, callback) { +var open = function(self, options, callback) { // Get the write concern var writeConcern = _getWriteConcern(self.db, self.options); // If we are writing we need to ensure we have the right indexes for md5's - if((self.mode == "w" || self.mode == "w+")) { + if (self.mode === 'w' || self.mode === 'w+') { // Get files collection var collection = self.collection(); // Put index on filename @@ -224,7 +227,7 @@ var open = function(self, callback) { chunkCollection.ensureIndex([['files_id', 1], ['n', 1]], chunkIndexOptions, function() { // Open the connection _open(self, writeConcern, function(err, r) { - if(err) return callback(err); + if (err) return callback(err); self.isOpen = true; callback(err, r); }); @@ -233,15 +236,12 @@ var open = function(self, callback) { } else { // Open the gridstore _open(self, writeConcern, function(err, r) { - if(err) return callback(err); + if (err) return callback(err); self.isOpen = true; callback(err, r); }); } -} - -// Push the definition for open -define.classMethod('open', {callback: true, promise:true}); +}; /** * Verify if the file is at EOF. @@ -251,14 +251,14 @@ define.classMethod('open', {callback: true, promise:true}); * @deprecated Use GridFSBucket API instead */ GridStore.prototype.eof = function() { - return this.position == this.length ? true : false; -} - -define.classMethod('eof', {callback: false, promise:false, returns: [Boolean]}); + return this.position === this.length ? true : false; +}; /** * The callback result format. * @callback GridStore~resultCallback + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {MongoError} error An error instance representing the error during the execution. * @param {object} result The result from the callback. */ @@ -271,23 +271,19 @@ define.classMethod('eof', {callback: false, promise:false, returns: [Boolean]}); * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.getc = function(callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return eof(self, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - eof(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }) +GridStore.prototype.getc = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + return executeOperation(this.db.s.topology, getc, [this, options, callback], { + skipSessions: true }); -} +}; -var eof = function(self, callback) { - if(self.eof()) { +var getc = function(self, options, callback) { + if (self.eof()) { callback(null, null); - } else if(self.currentChunk.eof()) { + } else if (self.currentChunk.eof()) { nthChunk(self, self.currentChunk.chunkNumber + 1, function(err, chunk) { self.currentChunk = chunk; self.position = self.position + 1; @@ -297,9 +293,7 @@ var eof = function(self, callback) { self.position = self.position + 1; callback(null, self.currentChunk.getc()); } -} - -define.classMethod('getc', {callback: true, promise:true}); +}; /** * Writes a string to the file with a newline character appended at the end if @@ -307,25 +301,24 @@ define.classMethod('getc', {callback: true, promise:true}); * * @method * @param {string} string the string to write. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.puts = function(string, callback) { - var self = this; - var finalString = string.match(/\n$/) == null ? string + "\n" : string; - // We provided a callback leg - if(typeof callback == 'function') return this.write(finalString, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - self.write(finalString, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); -} +GridStore.prototype.puts = function(string, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('puts', {callback: true, promise:true}); + var finalString = string.match(/\n$/) == null ? string + '\n' : string; + return executeOperation( + this.db.s.topology, + this.write.bind(this), + [finalString, options, callback], + { skipSessions: true } + ); +}; /** * Return a modified Readable stream including a possible transform method. @@ -336,9 +329,7 @@ define.classMethod('puts', {callback: true, promise:true}); */ GridStore.prototype.stream = function() { return new GridStoreStream(this); -} - -define.classMethod('stream', {callback: false, promise:false, returns: [GridStoreStream]}); +}; /** * Writes some data. This method will work properly only if initialized with mode "w" or "w+". @@ -346,24 +337,23 @@ define.classMethod('stream', {callback: false, promise:false, returns: [GridStor * @method * @param {(string|Buffer)} data the data to write. * @param {boolean} [close] closes this file after writing if set to true. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.write = function write(data, close, callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return _writeNormal(this, data, close, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - _writeNormal(self, data, close, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); -} +GridStore.prototype.write = function write(data, close, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; -define.classMethod('write', {callback: true, promise:true}); + return executeOperation( + this.db.s.topology, + _writeNormal, + [this, data, close, options, callback], + { skipSessions: true } + ); +}; /** * Handles the destroy part of a stream @@ -374,53 +364,49 @@ define.classMethod('write', {callback: true, promise:true}); */ GridStore.prototype.destroy = function destroy() { // close and do not emit any more events. queued data is not sent. - if(!this.writable) return; + if (!this.writable) return; this.readable = false; - if(this.writable) { + if (this.writable) { this.writable = false; this._q.length = 0; this.emit('close'); } -} - -define.classMethod('destroy', {callback: false, promise:false}); +}; /** * Stores a file from the file system to the GridFS database. * * @method * @param {(string|Buffer|FileHandle)} file the file to store. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.writeFile = function (file, callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return writeFile(self, file, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - writeFile(self, file, function(err, r) { - if(err) return reject(err); - resolve(r); - }) +GridStore.prototype.writeFile = function(file, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + return executeOperation(this.db.s.topology, writeFile, [this, file, options, callback], { + skipSessions: true }); }; -var writeFile = function(self, file, callback) { +var writeFile = function(self, file, options, callback) { if (typeof file === 'string') { - fs.open(file, 'r', function (err, fd) { - if(err) return callback(err); + fs.open(file, 'r', function(err, fd) { + if (err) return callback(err); self.writeFile(fd, callback); }); return; } - self.open(function (err, self) { - if(err) return callback(err, self); + self.open(function(err, self) { + if (err) return callback(err, self); - fs.fstat(file, function (err, stats) { - if(err) return callback(err, self); + fs.fstat(file, function(err, stats) { + if (err) return callback(err, self); var offset = 0; var index = 0; @@ -428,31 +414,34 @@ var writeFile = function(self, file, callback) { // Write a chunk var writeChunk = function() { // Allocate the buffer - var _buffer = new Buffer(self.chunkSize); + var _buffer = Buffer.alloc(self.chunkSize); // Read the file fs.read(file, _buffer, 0, _buffer.length, offset, function(err, bytesRead, data) { - if(err) return callback(err, self); + if (err) return callback(err, self); offset = offset + bytesRead; // Create a new chunk for the data - var chunk = new Chunk(self, {n:index++}, self.writeConcern); + var chunk = new Chunk(self, { n: index++ }, self.writeConcern); chunk.write(data.slice(0, bytesRead), function(err, chunk) { - if(err) return callback(err, self); + if (err) return callback(err, self); chunk.save({}, function(err) { - if(err) return callback(err, self); + if (err) return callback(err, self); self.position = self.position + bytesRead; // Point to current chunk self.currentChunk = chunk; - if(offset >= stats.size) { - fs.close(file); - self.close(function(err) { - if(err) return callback(err, self); - return callback(null, self); + if (offset >= stats.size) { + fs.close(file, function(err) { + if (err) return callback(err); + + self.close(function(err) { + if (err) return callback(err, self); + return callback(null, self); + }); }); } else { return process.nextTick(writeChunk); @@ -460,15 +449,13 @@ var writeFile = function(self, file, callback) { }); }); }); - } + }; // Process the first write process.nextTick(writeChunk); }); }); -} - -define.classMethod('writeFile', {callback: true, promise:true}); +}; /** * Saves this file to the database. This will overwrite the old entry if it @@ -476,57 +463,55 @@ define.classMethod('writeFile', {callback: true, promise:true}); * "w" or "w+". * * @method + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.close = function(callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return close(self, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - close(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }) +GridStore.prototype.close = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + return executeOperation(this.db.s.topology, close, [this, options, callback], { + skipSessions: true }); }; -var close = function(self, callback) { - if(self.mode[0] == "w") { +var close = function(self, options, callback) { + if (self.mode[0] === 'w') { // Set up options - var options = self.writeConcern; + options = Object.assign({}, self.writeConcern, options); - if(self.currentChunk != null && self.currentChunk.position > 0) { + if (self.currentChunk != null && self.currentChunk.position > 0) { self.currentChunk.save({}, function(err) { - if(err && typeof callback == 'function') return callback(err); + if (err && typeof callback === 'function') return callback(err); self.collection(function(err, files) { - if(err && typeof callback == 'function') return callback(err); + if (err && typeof callback === 'function') return callback(err); // Build the mongo object - if(self.uploadDate != null) { + if (self.uploadDate != null) { buildMongoObject(self, function(err, mongoObject) { - if(err) { - if(typeof callback == 'function') return callback(err); else throw err; + if (err) { + if (typeof callback === 'function') return callback(err); + else throw err; } files.save(mongoObject, options, function(err) { - if(typeof callback == 'function') - callback(err, mongoObject); + if (typeof callback === 'function') callback(err, mongoObject); }); }); } else { self.uploadDate = new Date(); buildMongoObject(self, function(err, mongoObject) { - if(err) { - if(typeof callback == 'function') return callback(err); else throw err; + if (err) { + if (typeof callback === 'function') return callback(err); + else throw err; } files.save(mongoObject, options, function(err) { - if(typeof callback == 'function') - callback(err, mongoObject); + if (typeof callback === 'function') callback(err, mongoObject); }); }); } @@ -534,31 +519,28 @@ var close = function(self, callback) { }); } else { self.collection(function(err, files) { - if(err && typeof callback == 'function') return callback(err); + if (err && typeof callback === 'function') return callback(err); self.uploadDate = new Date(); buildMongoObject(self, function(err, mongoObject) { - if(err) { - if(typeof callback == 'function') return callback(err); else throw err; + if (err) { + if (typeof callback === 'function') return callback(err); + else throw err; } files.save(mongoObject, options, function(err) { - if(typeof callback == 'function') - callback(err, mongoObject); + if (typeof callback === 'function') callback(err, mongoObject); }); }); }); } - } else if(self.mode[0] == "r") { - if(typeof callback == 'function') - callback(null, null); + } else if (self.mode[0] === 'r') { + if (typeof callback === 'function') callback(null, null); } else { - if(typeof callback == 'function') - callback(MongoError.create({message: f("Illegal mode %s", self.mode), driver:true})); + if (typeof callback === 'function') + callback(MongoError.create({ message: f('Illegal mode %s', self.mode), driver: true })); } -} - -define.classMethod('close', {callback: true, promise:true}); +}; /** * The collection callback format. @@ -576,55 +558,48 @@ define.classMethod('close', {callback: true, promise:true}); * @deprecated Use GridFSBucket API instead */ GridStore.prototype.chunkCollection = function(callback) { - if(typeof callback == 'function') - return this.db.collection((this.root + ".chunks"), callback); - return this.db.collection((this.root + ".chunks")); + if (typeof callback === 'function') return this.db.collection(this.root + '.chunks', callback); + return this.db.collection(this.root + '.chunks'); }; -define.classMethod('chunkCollection', {callback: true, promise:false, returns: [Collection]}); - /** * Deletes all the chunks of this file in the database. * * @method + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.unlink = function(callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return unlink(self, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - unlink(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }) +GridStore.prototype.unlink = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + return executeOperation(this.db.s.topology, unlink, [this, options, callback], { + skipSessions: true }); }; -var unlink = function(self, callback) { +var unlink = function(self, options, callback) { deleteChunks(self, function(err) { - if(err!==null) { - err.message = "at deleteChunks: " + err.message; + if (err !== null) { + err.message = 'at deleteChunks: ' + err.message; return callback(err); } self.collection(function(err, collection) { - if(err!==null) { - err.message = "at collection: " + err.message; + if (err !== null) { + err.message = 'at collection: ' + err.message; return callback(err); } - collection.remove({'_id':self.fileId}, self.writeConcern, function(err) { + collection.remove({ _id: self.fileId }, self.writeConcern, function(err) { callback(err, self); }); }); }); -} - -define.classMethod('unlink', {callback: true, promise:true}); +}; /** * Retrieves the file collection associated with this object. @@ -635,13 +610,10 @@ define.classMethod('unlink', {callback: true, promise:true}); * @deprecated Use GridFSBucket API instead */ GridStore.prototype.collection = function(callback) { - if(typeof callback == 'function') - this.db.collection(this.root + ".files", callback); - return this.db.collection(this.root + ".files"); + if (typeof callback === 'function') this.db.collection(this.root + '.files', callback); + return this.db.collection(this.root + '.files'); }; -define.classMethod('collection', {callback: true, promise:false, returns: [Collection]}); - /** * The readlines callback format. * @callback GridStore~readlinesCallback @@ -654,80 +626,70 @@ define.classMethod('collection', {callback: true, promise:false, returns: [Colle * * @method * @param {string} [separator] The character to be recognized as the newline separator. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~readlinesCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.readlines = function(separator, callback) { - var self = this; +GridStore.prototype.readlines = function(separator, options, callback) { var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); - separator = args.length ? args.shift() : "\n"; - separator = separator || "\n"; - - // We provided a callback leg - if(typeof callback == 'function') return readlines(self, separator, callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + separator = args.length ? args.shift() : '\n'; + separator = separator || '\n'; + options = args.length ? args.shift() : {}; - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - readlines(self, separator, function(err, r) { - if(err) return reject(err); - resolve(r); - }) + return executeOperation(this.db.s.topology, readlines, [this, separator, options, callback], { + skipSessions: true }); }; -var readlines = function(self, separator, callback) { +var readlines = function(self, separator, options, callback) { self.read(function(err, data) { - if(err) return callback(err); + if (err) return callback(err); var items = data.toString().split(separator); items = items.length > 0 ? items.splice(0, items.length - 1) : []; - for(var i = 0; i < items.length; i++) { + for (var i = 0; i < items.length; i++) { items[i] = items[i] + separator; } callback(null, items); }); -} - -define.classMethod('readlines', {callback: true, promise:true}); +}; /** * Deletes all the chunks of this file in the database if mode was set to "w" or * "w+" and resets the read/write head to the initial position. * * @method + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.rewind = function(callback) { - var self = this; - // We provided a callback leg - if(typeof callback == 'function') return rewind(self, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - rewind(self, function(err, r) { - if(err) return reject(err); - resolve(r); - }) +GridStore.prototype.rewind = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + return executeOperation(this.db.s.topology, rewind, [this, options, callback], { + skipSessions: true }); }; -var rewind = function(self, callback) { - if(self.currentChunk.chunkNumber != 0) { - if(self.mode[0] == "w") { +var rewind = function(self, options, callback) { + if (self.currentChunk.chunkNumber !== 0) { + if (self.mode[0] === 'w') { deleteChunks(self, function(err) { - if(err) return callback(err); - self.currentChunk = new Chunk(self, {'n': 0}, self.writeConcern); + if (err) return callback(err); + self.currentChunk = new Chunk(self, { n: 0 }, self.writeConcern); self.position = 0; callback(null, self); }); } else { self.currentChunk(0, function(err, chunk) { - if(err) return callback(err); + if (err) return callback(err); self.currentChunk = chunk; self.currentChunk.rewind(); self.position = 0; @@ -739,9 +701,7 @@ var rewind = function(self, callback) { self.position = 0; callback(null, self); } -} - -define.classMethod('rewind', {callback: true, promise:true}); +}; /** * The read callback format. @@ -762,44 +722,40 @@ define.classMethod('rewind', {callback: true, promise:true}); * @method * @param {number} [length] the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified. * @param {(string|Buffer)} [buffer] a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~readCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.read = function(length, buffer, callback) { - var self = this; - +GridStore.prototype.read = function(length, buffer, options, callback) { var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; length = args.length ? args.shift() : null; buffer = args.length ? args.shift() : null; - // We provided a callback leg - if(typeof callback == 'function') return read(self, length, buffer, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - read(self, length, buffer, function(err, r) { - if(err) return reject(err); - resolve(r); - }) + options = args.length ? args.shift() : {}; + + return executeOperation(this.db.s.topology, read, [this, length, buffer, options, callback], { + skipSessions: true }); -} +}; -var read = function(self, length, buffer, callback) { +var read = function(self, length, buffer, options, callback) { // The data is a c-terminated string and thus the length - 1 var finalLength = length == null ? self.length - self.position : length; - var finalBuffer = buffer == null ? new Buffer(finalLength) : buffer; + var finalBuffer = buffer == null ? Buffer.alloc(finalLength) : buffer; // Add a index to buffer to keep track of writing position or apply current index finalBuffer._index = buffer != null && buffer._index != null ? buffer._index : 0; - if((self.currentChunk.length() - self.currentChunk.position + finalBuffer._index) >= finalLength) { + if (self.currentChunk.length() - self.currentChunk.position + finalBuffer._index >= finalLength) { var slice = self.currentChunk.readSlice(finalLength - finalBuffer._index); // Copy content to final buffer slice.copy(finalBuffer, finalBuffer._index); // Update internal position self.position = self.position + finalBuffer.length; // Check if we don't have a file at all - if(finalLength == 0 && finalBuffer.length == 0) return callback(MongoError.create({message: "File does not exist", driver:true}), null); + if (finalLength === 0 && finalBuffer.length === 0) + return callback(MongoError.create({ message: 'File does not exist', driver: true }), null); // Else return data return callback(null, finalBuffer); } @@ -813,22 +769,26 @@ var read = function(self, length, buffer, callback) { // Load next chunk and read more nthChunk(self, self.currentChunk.chunkNumber + 1, function(err, chunk) { - if(err) return callback(err); + if (err) return callback(err); - if(chunk.length() > 0) { + if (chunk.length() > 0) { self.currentChunk = chunk; self.read(length, finalBuffer, callback); } else { - if(finalBuffer._index > 0) { - callback(null, finalBuffer) + if (finalBuffer._index > 0) { + callback(null, finalBuffer); } else { - callback(MongoError.create({message: "no chunks found for file, possibly corrupt", driver:true}), null); + callback( + MongoError.create({ + message: 'no chunks found for file, possibly corrupt', + driver: true + }), + null + ); } } }); -} - -define.classMethod('read', {callback: true, promise:true}); +}; /** * The tell callback format. @@ -843,6 +803,8 @@ define.classMethod('read', {callback: true, promise:true}); * @method * @param {number} [length] the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified. * @param {(string|Buffer)} [buffer] a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~tellCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead @@ -850,15 +812,13 @@ define.classMethod('read', {callback: true, promise:true}); GridStore.prototype.tell = function(callback) { var self = this; // We provided a callback leg - if(typeof callback == 'function') return callback(null, this.position); + if (typeof callback === 'function') return callback(null, this.position); // Return promise return new self.promiseLibrary(function(resolve) { resolve(self.position); }); }; -define.classMethod('tell', {callback: true, promise:true}); - /** * The tell callback format. * @callback GridStore~gridStoreCallback @@ -879,33 +839,32 @@ define.classMethod('tell', {callback: true, promise:true}); * @method * @param {number} [position] the position to seek to * @param {number} [seekLocation] seek mode. Use one of the Seek Location modes. + * @param {object} [options] Optional settings + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~gridStoreCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ -GridStore.prototype.seek = function(position, seekLocation, callback) { - var self = this; - +GridStore.prototype.seek = function(position, seekLocation, options, callback) { var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; seekLocation = args.length ? args.shift() : null; + options = args.length ? args.shift() : {}; - // We provided a callback leg - if(typeof callback == 'function') return seek(self, position, seekLocation, callback); - // Return promise - return new self.promiseLibrary(function(resolve, reject) { - seek(self, position, seekLocation, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); -} + return executeOperation( + this.db.s.topology, + seek, + [this, position, seekLocation, options, callback], + { skipSessions: true } + ); +}; -var seek = function(self, position, seekLocation, callback) { +var seek = function(self, position, seekLocation, options, callback) { // Seek only supports read mode - if(self.mode != 'r') { - return callback(MongoError.create({message: "seek is only supported for mode r", driver:true})) + if (self.mode !== 'r') { + return callback( + MongoError.create({ message: 'seek is only supported for mode r', driver: true }) + ); } var seekLocationFinal = seekLocation == null ? GridStore.IO_SEEK_SET : seekLocation; @@ -913,33 +872,31 @@ var seek = function(self, position, seekLocation, callback) { var targetPosition = 0; // Calculate the position - if(seekLocationFinal == GridStore.IO_SEEK_CUR) { + if (seekLocationFinal === GridStore.IO_SEEK_CUR) { targetPosition = self.position + finalPosition; - } else if(seekLocationFinal == GridStore.IO_SEEK_END) { + } else if (seekLocationFinal === GridStore.IO_SEEK_END) { targetPosition = self.length + finalPosition; } else { targetPosition = finalPosition; } // Get the chunk - var newChunkNumber = Math.floor(targetPosition/self.chunkSize); + var newChunkNumber = Math.floor(targetPosition / self.chunkSize); var seekChunk = function() { nthChunk(self, newChunkNumber, function(err, chunk) { - if(err) return callback(err, null); - if(chunk == null) return callback(new Error('no chunk found')); + if (err) return callback(err, null); + if (chunk == null) return callback(new Error('no chunk found')); // Set the current chunk self.currentChunk = chunk; self.position = targetPosition; - self.currentChunk.position = (self.position % self.chunkSize); + self.currentChunk.position = self.position % self.chunkSize; callback(err, self); }); }; seekChunk(); -} - -define.classMethod('seek', {callback: true, promise:true}); +}; /** * @ignore @@ -947,20 +904,24 @@ define.classMethod('seek', {callback: true, promise:true}); var _open = function(self, options, callback) { var collection = self.collection(); // Create the query - var query = self.referenceBy == REFERENCE_BY_ID ? {_id:self.fileId} : {filename:self.filename}; + var query = + self.referenceBy === REFERENCE_BY_ID ? { _id: self.fileId } : { filename: self.filename }; query = null == self.fileId && self.filename == null ? null : query; options.readPreference = self.readPreference; // Fetch the chunks - if(query != null) { + if (query != null) { collection.findOne(query, options, function(err, doc) { - if(err) return error(err); + if (err) { + return error(err); + } // Check if the collection for the files exists otherwise prepare the new one - if(doc != null) { + if (doc != null) { self.fileId = doc._id; // Prefer a new filename over the existing one if this is a write - self.filename = ((self.mode == 'r') || (self.filename == undefined)) ? doc.filename : self.filename; + self.filename = + self.mode === 'r' || self.filename === undefined ? doc.filename : self.filename; self.contentType = doc.contentType; self.internalChunkSize = doc.chunkSize; self.uploadDate = doc.uploadDate; @@ -968,52 +929,70 @@ var _open = function(self, options, callback) { self.length = doc.length; self.metadata = doc.metadata; self.internalMd5 = doc.md5; - } else if (self.mode != 'r') { + } else if (self.mode !== 'r') { self.fileId = self.fileId == null ? new ObjectID() : self.fileId; self.contentType = GridStore.DEFAULT_CONTENT_TYPE; - self.internalChunkSize = self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; + self.internalChunkSize = + self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; self.length = 0; } else { self.length = 0; - var txtId = self.fileId._bsontype == "ObjectID" ? self.fileId.toHexString() : self.fileId; - return error(MongoError.create({message: f("file with id %s not opened for writing", (self.referenceBy == REFERENCE_BY_ID ? txtId : self.filename)), driver:true}), self); + var txtId = self.fileId._bsontype === 'ObjectID' ? self.fileId.toHexString() : self.fileId; + return error( + MongoError.create({ + message: f( + 'file with id %s not opened for writing', + self.referenceBy === REFERENCE_BY_ID ? txtId : self.filename + ), + driver: true + }), + self + ); } // Process the mode of the object - if(self.mode == "r") { + if (self.mode === 'r') { nthChunk(self, 0, options, function(err, chunk) { - if(err) return error(err); + if (err) return error(err); self.currentChunk = chunk; self.position = 0; callback(null, self); }); - } else if(self.mode == "w" && doc) { + } else if (self.mode === 'w' && doc) { // Delete any existing chunks deleteChunks(self, options, function(err) { - if(err) return error(err); - self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); - self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; - self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; - self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + if (err) return error(err); + self.currentChunk = new Chunk(self, { n: 0 }, self.writeConcern); + self.contentType = + self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = + self.options['chunk_size'] == null + ? self.internalChunkSize + : self.options['chunk_size']; + self.metadata = + self.options['metadata'] == null ? self.metadata : self.options['metadata']; self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; self.position = 0; callback(null, self); }); - } else if(self.mode == "w") { - self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); - self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; - self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; + } else if (self.mode === 'w') { + self.currentChunk = new Chunk(self, { n: 0 }, self.writeConcern); + self.contentType = + self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = + self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; self.position = 0; callback(null, self); - } else if(self.mode == "w+") { + } else if (self.mode === 'w+') { nthChunk(self, lastChunkNumber(self), options, function(err, chunk) { - if(err) return error(err); + if (err) return error(err); // Set the current chunk - self.currentChunk = chunk == null ? new Chunk(self, {'n':0}, self.writeConcern) : chunk; + self.currentChunk = chunk == null ? new Chunk(self, { n: 0 }, self.writeConcern) : chunk; self.currentChunk.position = self.currentChunk.data.length(); - self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.metadata = + self.options['metadata'] == null ? self.metadata : self.options['metadata']; self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; self.position = self.length; callback(null, self); @@ -1024,27 +1003,30 @@ var _open = function(self, options, callback) { // Write only mode self.fileId = null == self.fileId ? new ObjectID() : self.fileId; self.contentType = GridStore.DEFAULT_CONTENT_TYPE; - self.internalChunkSize = self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; + self.internalChunkSize = + self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; self.length = 0; // No file exists set up write mode - if(self.mode == "w") { + if (self.mode === 'w') { // Delete any existing chunks deleteChunks(self, options, function(err) { - if(err) return error(err); - self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); - self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; - self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; + if (err) return error(err); + self.currentChunk = new Chunk(self, { n: 0 }, self.writeConcern); + self.contentType = + self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = + self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; self.position = 0; callback(null, self); }); - } else if(self.mode == "w+") { + } else if (self.mode === 'w+') { nthChunk(self, lastChunkNumber(self), options, function(err, chunk) { - if(err) return error(err); + if (err) return error(err); // Set the current chunk - self.currentChunk = chunk == null ? new Chunk(self, {'n':0}, self.writeConcern) : chunk; + self.currentChunk = chunk == null ? new Chunk(self, { n: 0 }, self.writeConcern) : chunk; self.currentChunk.position = self.currentChunk.data.length(); self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; @@ -1055,9 +1037,9 @@ var _open = function(self, options, callback) { } // only pass error to callback once - function error (err) { - if(error.err) return; - callback(error.err = err); + function error(err) { + if (error.err) return; + callback((error.err = err)); } }; @@ -1065,13 +1047,25 @@ var _open = function(self, options, callback) { * @ignore */ var writeBuffer = function(self, buffer, close, callback) { - if(typeof close === "function") { callback = close; close = null; } - var finalClose = typeof close == 'boolean' ? close : false; - - if(self.mode != "w") { - callback(MongoError.create({message: f("file with id %s not opened for writing", (self.referenceBy == REFERENCE_BY_ID ? self.referenceBy : self.filename)), driver:true}), null); + if (typeof close === 'function') { + callback = close; + close = null; + } + var finalClose = typeof close === 'boolean' ? close : false; + + if (self.mode !== 'w') { + callback( + MongoError.create({ + message: f( + 'file with id %s not opened for writing', + self.referenceBy === REFERENCE_BY_ID ? self.referenceBy : self.filename + ), + driver: true + }), + null + ); } else { - if(self.currentChunk.position + buffer.length >= self.chunkSize) { + if (self.currentChunk.position + buffer.length >= self.chunkSize) { // Write out the current Chunk and then keep writing until we have less data left than a chunkSize left // to a new chunk (recursively) var previousChunkNumber = self.currentChunk.chunkNumber; @@ -1081,9 +1075,9 @@ var writeBuffer = function(self, buffer, close, callback) { // A list of chunks to write out var chunksToWrite = [self.currentChunk.write(firstChunkData)]; // If we have more data left than the chunk size let's keep writing new chunks - while(leftOverData.length >= self.chunkSize) { + while (leftOverData.length >= self.chunkSize) { // Create a new chunk and write to it - var newChunk = new Chunk(self, {'n': (previousChunkNumber + 1)}, self.writeConcern); + var newChunk = new Chunk(self, { n: previousChunkNumber + 1 }, self.writeConcern); firstChunkData = leftOverData.slice(0, self.chunkSize); leftOverData = leftOverData.slice(self.chunkSize); // Update chunk number @@ -1095,24 +1089,24 @@ var writeBuffer = function(self, buffer, close, callback) { } // Set current chunk with remaining data - self.currentChunk = new Chunk(self, {'n': (previousChunkNumber + 1)}, self.writeConcern); + self.currentChunk = new Chunk(self, { n: previousChunkNumber + 1 }, self.writeConcern); // If we have left over data write it - if(leftOverData.length > 0) self.currentChunk.write(leftOverData); + if (leftOverData.length > 0) self.currentChunk.write(leftOverData); // Update the position for the gridstore self.position = self.position + buffer.length; // Total number of chunks to write var numberOfChunksToWrite = chunksToWrite.length; - for(var i = 0; i < chunksToWrite.length; i++) { + for (var i = 0; i < chunksToWrite.length; i++) { chunksToWrite[i].save({}, function(err) { - if(err) return callback(err); + if (err) return callback(err); numberOfChunksToWrite = numberOfChunksToWrite - 1; - if(numberOfChunksToWrite <= 0) { + if (numberOfChunksToWrite <= 0) { // We care closing the file before returning - if(finalClose) { + if (finalClose) { return self.close(function(err) { callback(err, self); }); @@ -1129,7 +1123,7 @@ var writeBuffer = function(self, buffer, close, callback) { // We have less data than the chunk size just write it and callback self.currentChunk.write(buffer); // We care closing the file before returning - if(finalClose) { + if (finalClose) { return self.close(function(err) { callback(err, self); }); @@ -1161,19 +1155,19 @@ var writeBuffer = function(self, buffer, close, callback) { var buildMongoObject = function(self, callback) { // Calcuate the length var mongoObject = { - '_id': self.fileId, - 'filename': self.filename, - 'contentType': self.contentType, - 'length': self.position ? self.position : 0, - 'chunkSize': self.chunkSize, - 'uploadDate': self.uploadDate, - 'aliases': self.aliases, - 'metadata': self.metadata + _id: self.fileId, + filename: self.filename, + contentType: self.contentType, + length: self.position ? self.position : 0, + chunkSize: self.chunkSize, + uploadDate: self.uploadDate, + aliases: self.aliases, + metadata: self.metadata }; - var md5Command = {filemd5:self.fileId, root:self.root}; + var md5Command = { filemd5: self.fileId, root: self.root }; self.db.command(md5Command, function(err, results) { - if(err) return callback(err); + if (err) return callback(err); mongoObject.md5 = results.md5; callback(null, mongoObject); @@ -1185,7 +1179,7 @@ var buildMongoObject = function(self, callback) { * @ignore */ var nthChunk = function(self, chunkNumber, options, callback) { - if(typeof options == 'function') { + if (typeof options === 'function') { callback = options; options = {}; } @@ -1193,19 +1187,21 @@ var nthChunk = function(self, chunkNumber, options, callback) { options = options || self.writeConcern; options.readPreference = self.readPreference; // Get the nth chunk - self.chunkCollection().findOne({'files_id':self.fileId, 'n':chunkNumber}, options, function(err, chunk) { - if(err) return callback(err); + self + .chunkCollection() + .findOne({ files_id: self.fileId, n: chunkNumber }, options, function(err, chunk) { + if (err) return callback(err); - var finalChunk = chunk == null ? {} : chunk; - callback(null, new Chunk(self, finalChunk, self.writeConcern)); - }); + var finalChunk = chunk == null ? {} : chunk; + callback(null, new Chunk(self, finalChunk, self.writeConcern)); + }); }; /** * @ignore */ var lastChunkNumber = function(self) { - return Math.floor((self.length ? self.length - 1 : 0)/self.chunkSize); + return Math.floor((self.length ? self.length - 1 : 0) / self.chunkSize); }; /** @@ -1214,16 +1210,16 @@ var lastChunkNumber = function(self) { * @ignore */ var deleteChunks = function(self, options, callback) { - if(typeof options == 'function') { + if (typeof options === 'function') { callback = options; options = {}; } options = options || self.writeConcern; - if(self.fileId != null) { - self.chunkCollection().remove({'files_id':self.fileId}, options, function(err) { - if(err) return callback(err, false); + if (self.fileId != null) { + self.chunkCollection().remove({ files_id: self.fileId }, options, function(err) { + if (err) return callback(err, false); callback(null, true); }); } else { @@ -1232,38 +1228,38 @@ var deleteChunks = function(self, options, callback) { }; /** -* The collection to be used for holding the files and chunks collection. -* -* @classconstant DEFAULT_ROOT_COLLECTION -**/ + * The collection to be used for holding the files and chunks collection. + * + * @classconstant DEFAULT_ROOT_COLLECTION + */ GridStore.DEFAULT_ROOT_COLLECTION = 'fs'; /** -* Default file mime type -* -* @classconstant DEFAULT_CONTENT_TYPE -**/ + * Default file mime type + * + * @classconstant DEFAULT_CONTENT_TYPE + */ GridStore.DEFAULT_CONTENT_TYPE = 'binary/octet-stream'; /** -* Seek mode where the given length is absolute. -* -* @classconstant IO_SEEK_SET -**/ + * Seek mode where the given length is absolute. + * + * @classconstant IO_SEEK_SET + */ GridStore.IO_SEEK_SET = 0; /** -* Seek mode where the given length is an offset to the current read/write head. -* -* @classconstant IO_SEEK_CUR -**/ + * Seek mode where the given length is an offset to the current read/write head. + * + * @classconstant IO_SEEK_CUR + */ GridStore.IO_SEEK_CUR = 1; /** -* Seek mode where the given length is an offset to the end of the file. -* -* @classconstant IO_SEEK_END -**/ + * Seek mode where the given length is an offset to the end of the file. + * + * @classconstant IO_SEEK_END + */ GridStore.IO_SEEK_END = 2; /** @@ -1274,70 +1270,61 @@ GridStore.IO_SEEK_END = 2; * @param {Db} db the database to query. * @param {string} name The name of the file to look for. * @param {string} [rootCollection] The root collection that holds the files and chunks collection. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] result from exists. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ GridStore.exist = function(db, fileIdObject, rootCollection, options, callback) { var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; rootCollection = args.length ? args.shift() : null; options = args.length ? args.shift() : {}; options = options || {}; - // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // We provided a callback leg - if(typeof callback == 'function') return exists(db, fileIdObject, rootCollection, options, callback); - // Return promise - return new promiseLibrary(function(resolve, reject) { - exists(db, fileIdObject, rootCollection, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); + return executeOperation( + db.s.topology, + exists, + [db, fileIdObject, rootCollection, options, callback], + { skipSessions: true } + ); }; var exists = function(db, fileIdObject, rootCollection, options, callback) { // Establish read preference var readPreference = options.readPreference || ReadPreference.PRIMARY; // Fetch collection - var rootCollectionFinal = rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; - db.collection(rootCollectionFinal + ".files", function(err, collection) { - if(err) return callback(err); + var rootCollectionFinal = + rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; + db.collection(rootCollectionFinal + '.files', function(err, collection) { + if (err) return callback(err); // Build query - var query = (typeof fileIdObject == 'string' || Object.prototype.toString.call(fileIdObject) == '[object RegExp]' ) - ? {'filename':fileIdObject} - : {'_id':fileIdObject}; // Attempt to locate file + var query = + typeof fileIdObject === 'string' || + Object.prototype.toString.call(fileIdObject) === '[object RegExp]' + ? { filename: fileIdObject } + : { _id: fileIdObject }; // Attempt to locate file // We have a specific query - if(fileIdObject != null - && typeof fileIdObject == 'object' - && Object.prototype.toString.call(fileIdObject) != '[object RegExp]') { + if ( + fileIdObject != null && + typeof fileIdObject === 'object' && + Object.prototype.toString.call(fileIdObject) !== '[object RegExp]' + ) { query = fileIdObject; } // Check if the entry exists - collection.findOne(query, {readPreference:readPreference}, function(err, item) { - if(err) return callback(err); + collection.findOne(query, { readPreference: readPreference }, function(err, item) { + if (err) return callback(err); callback(null, item == null ? false : true); }); }); -} - -define.staticMethod('exist', {callback: true, promise:true}); +}; /** * Gets the list of files stored in the GridFS. @@ -1346,63 +1333,49 @@ define.staticMethod('exist', {callback: true, promise:true}); * @static * @param {Db} db the database to query. * @param {string} [rootCollection] The root collection that holds the files and chunks collection. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] result from exists. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ GridStore.list = function(db, rootCollection, options, callback) { var args = Array.prototype.slice.call(arguments, 1); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; rootCollection = args.length ? args.shift() : null; options = args.length ? args.shift() : {}; options = options || {}; - // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // We provided a callback leg - if(typeof callback == 'function') return list(db, rootCollection, options, callback); - // Return promise - return new promiseLibrary(function(resolve, reject) { - list(db, rootCollection, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }) + return executeOperation(db.s.topology, list, [db, rootCollection, options, callback], { + skipSessions: true }); }; var list = function(db, rootCollection, options, callback) { // Ensure we have correct values - if(rootCollection != null && typeof rootCollection == 'object') { + if (rootCollection != null && typeof rootCollection === 'object') { options = rootCollection; rootCollection = null; } // Establish read preference - var readPreference = options.readPreference || ReadPreference.PRIMARY; + var readPreference = options.readPreference || ReadPreference.primary; // Check if we are returning by id not filename var byId = options['id'] != null ? options['id'] : false; // Fetch item - var rootCollectionFinal = rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; + var rootCollectionFinal = + rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; var items = []; - db.collection((rootCollectionFinal + ".files"), function(err, collection) { - if(err) return callback(err); + db.collection(rootCollectionFinal + '.files', function(err, collection) { + if (err) return callback(err); - collection.find({}, {readPreference:readPreference}, function(err, cursor) { - if(err) return callback(err); + collection.find({}, { readPreference: readPreference }, function(err, cursor) { + if (err) return callback(err); cursor.each(function(err, item) { - if(item != null) { + if (item != null) { items.push(byId ? item._id : item.filename); } else { callback(err, items); @@ -1410,9 +1383,7 @@ var list = function(db, rootCollection, options, callback) { }); }); }); -} - -define.staticMethod('list', {callback: true, promise:true}); +}; /** * Reads the contents of a file. @@ -1430,62 +1401,51 @@ define.staticMethod('list', {callback: true, promise:true}); * @param {string} name The name of the file. * @param {number} [length] The size of data to read. * @param {number} [offset] The offset from the head of the file of which to start reading from. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~readCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ GridStore.read = function(db, name, length, offset, options, callback) { var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; length = args.length ? args.shift() : null; offset = args.length ? args.shift() : null; options = args.length ? args.shift() : null; options = options || {}; - // Get the promiseLibrary - var promiseLibrary = options ? options.promiseLibrary : null; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // We provided a callback leg - if(typeof callback == 'function') return readStatic(db, name, length, offset, options, callback); - // Return promise - return new promiseLibrary(function(resolve, reject) { - readStatic(db, name, length, offset, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); + return executeOperation( + db.s.topology, + readStatic, + [db, name, length, offset, options, callback], + { skipSessions: true } + ); }; var readStatic = function(db, name, length, offset, options, callback) { - new GridStore(db, name, "r", options).open(function(err, gridStore) { - if(err) return callback(err); + new GridStore(db, name, 'r', options).open(function(err, gridStore) { + if (err) return callback(err); // Make sure we are not reading out of bounds - if(offset && offset >= gridStore.length) return callback("offset larger than size of file", null); - if(length && length > gridStore.length) return callback("length is larger than the size of the file", null); - if(offset && length && (offset + length) > gridStore.length) return callback("offset and length is larger than the size of the file", null); - - if(offset != null) { + if (offset && offset >= gridStore.length) + return callback('offset larger than size of file', null); + if (length && length > gridStore.length) + return callback('length is larger than the size of the file', null); + if (offset && length && offset + length > gridStore.length) + return callback('offset and length is larger than the size of the file', null); + + if (offset != null) { gridStore.seek(offset, function(err, gridStore) { - if(err) return callback(err); + if (err) return callback(err); gridStore.read(length, callback); }); } else { gridStore.read(length, callback); } }); -} - -define.staticMethod('read', {callback: true, promise:true}); +}; /** * Read the entire file as a list of strings splitting by the provided separator. @@ -1495,50 +1455,36 @@ define.staticMethod('read', {callback: true, promise:true}); * @param {Db} db the database to query. * @param {(String|object)} name the name of the file. * @param {string} [separator] The character to be recognized as the newline separator. - * @param {object} [options=null] Optional settings. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~readlinesCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ GridStore.readlines = function(db, name, separator, options, callback) { var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; separator = args.length ? args.shift() : null; options = args.length ? args.shift() : null; options = options || {}; - // Get the promiseLibrary - var promiseLibrary = options ? options.promiseLibrary : null; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // We provided a callback leg - if(typeof callback == 'function') return readlinesStatic(db, name, separator, options, callback); - // Return promise - return new promiseLibrary(function(resolve, reject) { - readlinesStatic(db, name, separator, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }) - }); + return executeOperation( + db.s.topology, + readlinesStatic, + [db, name, separator, options, callback], + { skipSessions: true } + ); }; var readlinesStatic = function(db, name, separator, options, callback) { - var finalSeperator = separator == null ? "\n" : separator; - new GridStore(db, name, "r", options).open(function(err, gridStore) { - if(err) return callback(err); + var finalSeperator = separator == null ? '\n' : separator; + new GridStore(db, name, 'r', options).open(function(err, gridStore) { + if (err) return callback(err); gridStore.readlines(finalSeperator, callback); }); -} - -define.staticMethod('readlines', {callback: true, promise:true}); +}; /** * Deletes the chunks and metadata information of a file from GridFS. @@ -1547,38 +1493,21 @@ define.staticMethod('readlines', {callback: true, promise:true}); * @static * @param {Db} db The database to query. * @param {(string|array)} names The name/names of the files to delete. - * @param {object} [options=null] Optional settings. - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options] Optional settings. + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {ClientSession} [options.session] optional session to use for this operation * @param {GridStore~resultCallback} [callback] the command callback. * @return {Promise} returns Promise if no callback passed * @deprecated Use GridFSBucket API instead */ GridStore.unlink = function(db, names, options, callback) { - var self = this; var args = Array.prototype.slice.call(arguments, 2); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; options = args.length ? args.shift() : {}; options = options || {}; - // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // We provided a callback leg - if(typeof callback == 'function') return unlinkStatic(self, db, names, options, callback); - - // Return promise - return new promiseLibrary(function(resolve, reject) { - unlinkStatic(self, db, names, options, function(err, r) { - if(err) return reject(err); - resolve(r); - }) + return executeOperation(db.s.topology, unlinkStatic, [this, db, names, options, callback], { + skipSessions: true }); }; @@ -1587,89 +1516,109 @@ var unlinkStatic = function(self, db, names, options, callback) { var writeConcern = _getWriteConcern(db, options); // List of names - if(names.constructor == Array) { + if (names.constructor === Array) { var tc = 0; - for(var i = 0; i < names.length; i++) { + for (var i = 0; i < names.length; i++) { ++tc; GridStore.unlink(db, names[i], options, function() { - if(--tc == 0) { + if (--tc === 0) { callback(null, self); } }); } } else { - new GridStore(db, names, "w", options).open(function(err, gridStore) { - if(err) return callback(err); + new GridStore(db, names, 'w', options).open(function(err, gridStore) { + if (err) return callback(err); deleteChunks(gridStore, function(err) { - if(err) return callback(err); + if (err) return callback(err); gridStore.collection(function(err, collection) { - if(err) return callback(err); - collection.remove({'_id':gridStore.fileId}, writeConcern, function(err) { + if (err) return callback(err); + collection.remove({ _id: gridStore.fileId }, writeConcern, function(err) { callback(err, self); }); }); }); }); } -} - -define.staticMethod('unlink', {callback: true, promise:true}); +}; /** * @ignore */ -var _writeNormal = function(self, data, close, callback) { +var _writeNormal = function(self, data, close, options, callback) { // If we have a buffer write it using the writeBuffer method - if(Buffer.isBuffer(data)) { + if (Buffer.isBuffer(data)) { return writeBuffer(self, data, close, callback); } else { - return writeBuffer(self, new Buffer(data, 'binary'), close, callback); + return writeBuffer(self, Buffer.from(data, 'binary'), close, callback); } -} +}; /** * @ignore */ var _setWriteConcernHash = function(options) { var finalOptions = {}; - if(options.w != null) finalOptions.w = options.w; - if(options.journal == true) finalOptions.j = options.journal; - if(options.j == true) finalOptions.j = options.j; - if(options.fsync == true) finalOptions.fsync = options.fsync; - if(options.wtimeout != null) finalOptions.wtimeout = options.wtimeout; + if (options.w != null) finalOptions.w = options.w; + if (options.journal === true) finalOptions.j = options.journal; + if (options.j === true) finalOptions.j = options.j; + if (options.fsync === true) finalOptions.fsync = options.fsync; + if (options.wtimeout != null) finalOptions.wtimeout = options.wtimeout; return finalOptions; -} +}; /** * @ignore */ var _getWriteConcern = function(self, options) { // Final options - var finalOptions = {w:1}; + var finalOptions = { w: 1 }; options = options || {}; // Local options verification - if(options.w != null || typeof options.j == 'boolean' || typeof options.journal == 'boolean' || typeof options.fsync == 'boolean') { + if ( + options.w != null || + typeof options.j === 'boolean' || + typeof options.journal === 'boolean' || + typeof options.fsync === 'boolean' + ) { finalOptions = _setWriteConcernHash(options); - } else if(options.safe != null && typeof options.safe == 'object') { + } else if (options.safe != null && typeof options.safe === 'object') { finalOptions = _setWriteConcernHash(options.safe); - } else if(typeof options.safe == "boolean") { - finalOptions = {w: (options.safe ? 1 : 0)}; - } else if(self.options.w != null || typeof self.options.j == 'boolean' || typeof self.options.journal == 'boolean' || typeof self.options.fsync == 'boolean') { + } else if (typeof options.safe === 'boolean') { + finalOptions = { w: options.safe ? 1 : 0 }; + } else if ( + self.options.w != null || + typeof self.options.j === 'boolean' || + typeof self.options.journal === 'boolean' || + typeof self.options.fsync === 'boolean' + ) { finalOptions = _setWriteConcernHash(self.options); - } else if(self.safe && (self.safe.w != null || typeof self.safe.j == 'boolean' || typeof self.safe.journal == 'boolean' || typeof self.safe.fsync == 'boolean')) { + } else if ( + self.safe && + (self.safe.w != null || + typeof self.safe.j === 'boolean' || + typeof self.safe.journal === 'boolean' || + typeof self.safe.fsync === 'boolean') + ) { finalOptions = _setWriteConcernHash(self.safe); - } else if(typeof self.safe == "boolean") { - finalOptions = {w: (self.safe ? 1 : 0)}; + } else if (typeof self.safe === 'boolean') { + finalOptions = { w: self.safe ? 1 : 0 }; } // Ensure we don't have an invalid combination of write concerns - if(finalOptions.w < 1 - && (finalOptions.journal == true || finalOptions.j == true || finalOptions.fsync == true)) throw MongoError.create({message: "No acknowledgement using w < 1 cannot be combined with journal:true or fsync:true", driver:true}); + if ( + finalOptions.w < 1 && + (finalOptions.journal === true || finalOptions.j === true || finalOptions.fsync === true) + ) + throw MongoError.create({ + message: 'No acknowledgement using w < 1 cannot be combined with journal:true or fsync:true', + driver: true + }); // Return the options return finalOptions; -} +}; /** * Create a new GridStoreStream instance (INTERNAL TYPE, do not instantiate directly) @@ -1692,7 +1641,7 @@ var GridStoreStream = function(gs) { // If we have a seek this.totalBytesToRead = this.gs.length - this.gs.position; this.seekPosition = this.gs.position; -} +}; // // Inherit duplex @@ -1705,9 +1654,9 @@ GridStoreStream.prototype.pipe = function(destination) { var self = this; // Only open gridstore if not already open - if(!self.gs.isOpen) { + if (!self.gs.isOpen) { self.gs.open(function(err) { - if(err) return self.emit('error', err); + if (err) return self.emit('error', err); self.totalBytesToRead = self.gs.length - self.gs.position; self._pipe.apply(self, [destination]); }); @@ -1717,7 +1666,7 @@ GridStoreStream.prototype.pipe = function(destination) { } return destination; -} +}; // Called by stream GridStoreStream.prototype._read = function() { @@ -1726,51 +1675,56 @@ GridStoreStream.prototype._read = function() { var read = function() { // Read data self.gs.read(length, function(err, buffer) { - if(err && !self.endCalled) return self.emit('error', err); + if (err && !self.endCalled) return self.emit('error', err); // Stream is closed - if(self.endCalled || buffer == null) return self.push(null); + if (self.endCalled || buffer == null) return self.push(null); // Remove bytes read - if(buffer.length <= self.totalBytesToRead) { + if (buffer.length <= self.totalBytesToRead) { self.totalBytesToRead = self.totalBytesToRead - buffer.length; self.push(buffer); - } else if(buffer.length > self.totalBytesToRead) { + } else if (buffer.length > self.totalBytesToRead) { self.totalBytesToRead = self.totalBytesToRead - buffer._index; self.push(buffer.slice(0, buffer._index)); } // Finished reading - if(self.totalBytesToRead <= 0) { + if (self.totalBytesToRead <= 0) { self.endCalled = true; } }); - } + }; // Set read length - var length = self.gs.length < self.gs.chunkSize ? self.gs.length - self.seekPosition : self.gs.chunkSize; - if(!self.gs.isOpen) { + var length = + self.gs.length < self.gs.chunkSize ? self.gs.length - self.seekPosition : self.gs.chunkSize; + if (!self.gs.isOpen) { self.gs.open(function(err) { self.totalBytesToRead = self.gs.length - self.gs.position; - if(err) return self.emit('error', err); + if (err) return self.emit('error', err); read(); }); } else { read(); } -} +}; GridStoreStream.prototype.destroy = function() { this.pause(); this.endCalled = true; this.gs.close(); this.emit('end'); -} +}; GridStoreStream.prototype.write = function(chunk) { var self = this; - if(self.endCalled) return self.emit('error', MongoError.create({message: 'attempting to write to stream after end called', driver:true})) + if (self.endCalled) + return self.emit( + 'error', + MongoError.create({ message: 'attempting to write to stream after end called', driver: true }) + ); // Do we have to open the gridstore - if(!self.gs.isOpen) { + if (!self.gs.isOpen) { self.gs.open(function() { self.gs.isOpen = true; self.gs.write(chunk, function() { @@ -1786,31 +1740,30 @@ GridStoreStream.prototype.write = function(chunk) { }); return true; } -} +}; GridStoreStream.prototype.end = function(chunk, encoding, callback) { var self = this; var args = Array.prototype.slice.call(arguments, 0); - callback = args.pop(); - if(typeof callback != 'function') args.push(callback); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; chunk = args.length ? args.shift() : null; encoding = args.length ? args.shift() : null; self.endCalled = true; - if(chunk) { + if (chunk) { self.gs.write(chunk, function() { self.gs.close(function() { - if(typeof callback == 'function') callback(); - self.emit('end') + if (typeof callback === 'function') callback(); + self.emit('end'); }); }); } self.gs.close(function() { - if(typeof callback == 'function') callback(); - self.emit('end') + if (typeof callback === 'function') callback(); + self.emit('end'); }); -} +}; /** * The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null. diff --git a/node_modules/mongodb/lib/mongo_client.js b/node_modules/mongodb/lib/mongo_client.js index 76fd309..b1a3bed 100644 --- a/node_modules/mongodb/lib/mongo_client.js +++ b/node_modules/mongodb/lib/mongo_client.js @@ -1,531 +1,472 @@ -"use strict"; - -var parse = require('./url_parser') - , Server = require('./server') - , Mongos = require('./mongos') - , ReplSet = require('./replset') - , EventEmitter = require('events').EventEmitter - , inherits = require('util').inherits - , Define = require('./metadata') - , ReadPreference = require('./read_preference') - , Logger = require('mongodb-core').Logger - , MongoError = require('mongodb-core').MongoError - , Db = require('./db') - , f = require('util').format - , assign = require('./utils').assign - , shallowClone = require('./utils').shallowClone - , authenticate = require('./authenticate'); +'use strict'; + +const ChangeStream = require('./change_stream'); +const Db = require('./db'); +const EventEmitter = require('events').EventEmitter; +const executeOperation = require('./utils').executeOperation; +const handleCallback = require('./utils').handleCallback; +const inherits = require('util').inherits; +const MongoError = require('mongodb-core').MongoError; + +// Operations +const connectOp = require('./operations/mongo_client_ops').connectOp; +const logout = require('./operations/mongo_client_ops').logout; +const validOptions = require('./operations/mongo_client_ops').validOptions; /** * @fileOverview The **MongoClient** class is a class that allows for making Connections to MongoDB. * * @example - * var MongoClient = require('mongodb').MongoClient, - * test = require('assert'); + * // Connect using a MongoClient instance + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); + * // Connection url + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; + * // Connect using MongoClient + * const mongoClient = new MongoClient(url); + * mongoClient.connect(function(err, client) { + * const db = client.db(dbName); + * client.close(); + * }); + * + * @example + * // Connect using the MongoClient.connect static method + * const MongoClient = require('mongodb').MongoClient; + * const test = require('assert'); * // Connection url - * var url = 'mongodb://localhost:27017/test'; + * const url = 'mongodb://localhost:27017'; + * // Database Name + * const dbName = 'test'; * // Connect using MongoClient - * MongoClient.connect(url, function(err, db) { - * // Get an additional db - * db.close(); + * MongoClient.connect(url, function(err, client) { + * const db = client.db(dbName); + * client.close(); * }); */ -var validOptionNames = ['poolSize', 'ssl', 'sslValidate', 'sslCA', 'sslCert', 'ciphers', 'ecdhCurve', - 'sslKey', 'sslPass', 'sslCRL', 'autoReconnect', 'noDelay', 'keepAlive', 'connectTimeoutMS', 'family', - 'socketTimeoutMS', 'reconnectTries', 'reconnectInterval', 'ha', 'haInterval', - 'replicaSet', 'secondaryAcceptableLatencyMS', 'acceptableLatencyMS', - 'connectWithNoPrimary', 'authSource', 'w', 'wtimeout', 'j', 'forceServerObjectId', - 'serializeFunctions', 'ignoreUndefined', 'raw', 'bufferMaxEntries', - 'readPreference', 'pkFactory', 'promiseLibrary', 'readConcern', 'maxStalenessSeconds', - 'loggerLevel', 'logger', 'promoteValues', 'promoteBuffers', 'promoteLongs', - 'domainsEnabled', 'keepAliveInitialDelay', 'checkServerIdentity', 'validateOptions', 'appname', 'auth']; -var ignoreOptionNames = ['native_parser']; -var legacyOptionNames = ['server', 'replset', 'replSet', 'mongos', 'db']; - -function validOptions(options) { - var _validOptions = validOptionNames.concat(legacyOptionNames); - - for(var name in options) { - if(ignoreOptionNames.indexOf(name) != -1) { - continue; - } - - if(_validOptions.indexOf(name) == -1 && options.validateOptions) { - return new MongoError(f('option %s is not supported', name)); - } else if(_validOptions.indexOf(name) == -1) { - console.warn(f('the options [%s] is not supported', name)); - } - - if(legacyOptionNames.indexOf(name) != -1) { - console.warn(f('the server/replset/mongos options are deprecated, ' - + 'all their options are supported at the top level of the options object [%s]', validOptionNames)); - } - } -} /** * Creates a new MongoClient instance * @class - * @return {MongoClient} a MongoClient instance. - */ -function MongoClient() { - if(!(this instanceof MongoClient)) return new MongoClient(); - - // Set up event emitter - EventEmitter.call(this); - - /** - * The callback format for results - * @callback MongoClient~connectCallback - * @param {MongoError} error An error instance representing the error during the execution. - * @param {Db} db The connected database. - */ - - /** - * Connect to MongoDB using a url as documented at - * - * docs.mongodb.org/manual/reference/connection-string/ - * - * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver - * - * @method - * @param {string} url The connection URI string - * @param {object} [options] Optional settings. - * @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool. - * @param {boolean} [options.ssl=false] Enable SSL connection. - * @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer - * @param {Buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer - * @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer - * @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer - * @param {string} [options.sslPass=undefined] SSL Certificate pass phrase - * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. - * @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances - * @param {boolean} [options.noDelay=true] TCP Connection no delay - * @param {number} [options.family=4] Version of IP stack. Defaults to 4. - * @param {number} [options.keepAlive=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket. - * @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting - * @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting - * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times - * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries - * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies. - * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry - * @param {string} [options.replicaSet=undefined] The Replicaset set name - * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection - * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection. - * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available - * @param {string} [options.authSource=undefined] Define the database to authenticate against - * @param {string} [options.auth.user=undefined] The username for auth - * @param {string} [options.auth.password=undefined] The password for auth - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. - * @param {boolean} [options.j=false] Specify a journal write concern. - * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. - * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. - * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. - * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. - * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. - * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. - * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. - * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible - * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) - * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) - * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); - * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections. - * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) - * @param {object} [options.logger=undefined] Custom logger object - * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness. - * @param {MongoClient~connectCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed - */ - this.connect = MongoClient.connect; -} - -/** - * @ignore - */ -inherits(MongoClient, EventEmitter); - -var define = MongoClient.define = new Define('MongoClient', MongoClient, false); - -/** - * Connect to MongoDB using a url as documented at - * - * docs.mongodb.org/manual/reference/connection-string/ - * - * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver - * - * @method - * @static * @param {string} url The connection URI string - * @param {object} [options] Optional settings. - * @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool. + * @param {object} [options] Optional settings + * @param {number} [options.poolSize=5] The maximum size of the individual server pool * @param {boolean} [options.ssl=false] Enable SSL connection. - * @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer - * @param {Buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer - * @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer - * @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer + * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against Certificate Authority + * @param {buffer} [options.sslCA=undefined] SSL Certificate store binary buffer + * @param {buffer} [options.sslCert=undefined] SSL Certificate binary buffer + * @param {buffer} [options.sslKey=undefined] SSL Key file binary buffer * @param {string} [options.sslPass=undefined] SSL Certificate pass phrase - * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer * @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances * @param {boolean} [options.noDelay=true] TCP Connection no delay - * @param {number} [options.family=4] Version of IP stack. Defaults to 4. - * @param {boolean} [options.keepAlive=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket. + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket * @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting + * @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default). + * If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure * @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries - * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies. + * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry * @param {string} [options.replicaSet=undefined] The Replicaset set name * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection - * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection. + * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available * @param {string} [options.authSource=undefined] Define the database to authenticate against - * @param {string} [options.auth.user=undefined] The username for auth - * @param {string} [options.auth.password=undefined] The password for auth - * @param {(number|string)} [options.w=null] The write concern. - * @param {number} [options.wtimeout=null] The write concern timeout. - * @param {boolean} [options.j=false] Specify a journal write concern. - * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. - * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. - * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. - * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. - * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. - * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. - * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. - * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. - * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). - * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. - * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. - * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible - * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {(number|string)} [options.w] The write concern + * @param {number} [options.wtimeout] The write concern timeout + * @param {boolean} [options.j=false] Specify a journal write concern + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers + * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST) + * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern] Specify a read concern for the collection (only MongoDB 3.2 or higher supported) * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) - * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); - * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections. + * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed) * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) * @param {object} [options.logger=undefined] Custom logger object - * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers + * @param {boolean} [options.promoteLongs=true] Promotes long values to number if they fit inside the 53 bits resolution + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function + * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness + * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections + * @param {string} [options.auth.user=undefined] The username for auth + * @param {string} [options.auth.password=undefined] The password for auth + * @param {string} [options.authMechanism=undefined] Mechanism for authentication: MDEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 + * @param {object} [options.compression] Type of compression to use: snappy or zlib + * @param {boolean} [options.fsync=false] Specify a file sync write concern + * @param {array} [options.readPreferenceTags] Read preference tags + * @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor + * @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances + * @param {boolean} [options.monitorCommands=false] Enable command monitoring for this client + * @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections + * @param {boolean} [options.useNewUrlParser=false] Determines whether or not to use the new url parser * @param {MongoClient~connectCallback} [callback] The command result callback - * @return {Promise} returns Promise if no callback passed + * @return {MongoClient} a MongoClient instance */ -MongoClient.connect = function(url, options, callback) { - var args = Array.prototype.slice.call(arguments, 1); - callback = typeof args[args.length - 1] == 'function' ? args.pop() : null; - options = args.length ? args.shift() : null; - options = options || {}; - var self = this; +function MongoClient(url, options) { + if (!(this instanceof MongoClient)) return new MongoClient(url, options); + // Set up event emitter + EventEmitter.call(this); - // Validate options object - var err = validOptions(options); + // The internal state + this.s = { + url: url, + options: options || {}, + promiseLibrary: null, + dbCache: {}, + sessions: [] + }; // Get the promiseLibrary - var promiseLibrary = options.promiseLibrary; - - // No promise library selected fall back - if(!promiseLibrary) { - promiseLibrary = typeof global.Promise == 'function' ? - global.Promise : require('es6-promise').Promise; - } - - // Return a promise - if(typeof callback != 'function') { - return new promiseLibrary(function(resolve, reject) { - // Did we have a validation error - if(err) return reject(err); - // Attempt to connect - connect(self, url, options, function(err, db) { - if(err) return reject(err); - resolve(db); - }); - }); - } + const promiseLibrary = this.s.options.promiseLibrary || Promise; - // Did we have a validation error - if(err) return callback(err); - // Fallback to callback based connect - connect(self, url, options, callback); + // Add the promise to the internal state + this.s.promiseLibrary = promiseLibrary; } -define.staticMethod('connect', {callback: true, promise:true}); - -var mergeOptions = function(target, source, flatten) { - for(var name in source) { - if(source[name] && typeof source[name] == 'object' && flatten) { - target = mergeOptions(target, source[name], flatten); - } else { - target[name] = source[name]; - } - } - - return target; -} +/** + * @ignore + */ +inherits(MongoClient, EventEmitter); -var createUnifiedOptions = function(finalOptions, options) { - var childOptions = ['mongos', 'server', 'db' - , 'replset', 'db_options', 'server_options', 'rs_options', 'mongos_options']; - var noMerge = ['readconcern']; - - for(var name in options) { - if(noMerge.indexOf(name.toLowerCase()) != -1) { - finalOptions[name] = options[name]; - } else if(childOptions.indexOf(name.toLowerCase()) != -1) { - finalOptions = mergeOptions(finalOptions, options[name], false); - } else { - if(options[name] && typeof options[name] == 'object' && !Buffer.isBuffer(options[name]) && !Array.isArray(options[name])) { - finalOptions = mergeOptions(finalOptions, options[name], true); - } else { - finalOptions[name] = options[name]; - } - } - } +/** + * The callback format for results + * @callback MongoClient~connectCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {MongoClient} client The connected client. + */ - return finalOptions; -} +/** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @param {MongoClient~connectCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +MongoClient.prototype.connect = function(callback) { + // Validate options object + const err = validOptions(this.s.options); -function translateOptions(options) { - // If we have a readPreference passed in by the db options - if(typeof options.readPreference == 'string' || typeof options.read_preference == 'string') { - options.readPreference = new ReadPreference(options.readPreference || options.read_preference); + if (typeof callback === 'string') { + throw new TypeError('`connect` only accepts a callback'); } - // Do we have readPreference tags, add them - if(options.readPreference && (options.readPreferenceTags || options.read_preference_tags)) { - options.readPreference.tags = options.readPreferenceTags || options.read_preference_tags; - } + return executeOperation(this, connectOp, [this, err, callback], { + skipSessions: true + }); +}; - // Do we have maxStalenessSeconds - if(options.maxStalenessSeconds) { - options.readPreference.maxStalenessSeconds = options.maxStalenessSeconds; - } +/** + * Logout user from server, fire off on all connections and remove all auth info + * @method + * @param {object} [options] Optional settings. + * @param {string} [options.dbName] Logout against different database than current. + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +MongoClient.prototype.logout = function(options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; - // Set the socket and connection timeouts - if(options.socketTimeoutMS == null) options.socketTimeoutMS = 360000; - if(options.connectTimeoutMS == null) options.connectTimeoutMS = 30000; + // Establish the correct database name + const dbName = this.s.options.authSource ? this.s.options.authSource : this.s.options.dbName; - // Create server instances - return options.servers.map(function(serverObj) { - return serverObj.domain_socket ? - new Server(serverObj.domain_socket, 27017, options) - : new Server(serverObj.host, serverObj.port, options); + return executeOperation(this, logout, [this, dbName, callback], { + skipSessions: true }); -} +}; -// -// Collect all events in order from SDAM -// -function collectEvents(self, db) { - var collectedEvents = []; - - if(self instanceof MongoClient) { - var events = ["timeout", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted', - 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening', - 'topologyClosed', 'topologyDescriptionChanged', 'joined', 'left', 'ping', 'ha', 'all', 'fullsetup']; - events.forEach(function(event) { - db.serverConfig.on(event, function(object1, object2) { - collectedEvents.push({ - event: event, object1: object1, object2: object2 - }); - }); - }); - } - - return collectedEvents; -} +/** + * Close the db and its underlying connections + * @method + * @param {boolean} force Force close, emitting no events + * @param {Db~noResultCallback} [callback] The result callback + * @return {Promise} returns Promise if no callback passed + */ +MongoClient.prototype.close = function(force, callback) { + if (typeof force === 'function') (callback = force), (force = false); -// -// Replay any events due to single server connection switching to Mongos -// -function replayEvents(self, events) { - for(var i = 0; i < events.length; i++) { - self.emit(events[i].event, events[i].object1, events[i].object2); + // Close the topology connection + if (this.topology) { + this.topology.close(force); } -} + // Emit close event + this.emit('close', this); -function relayEvents(self, db) { - if(self instanceof MongoClient) { - var events = ["timeout", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted', - 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening', - 'topologyClosed', 'topologyDescriptionChanged', 'joined', 'left', 'ping', 'ha', 'all', 'fullsetup']; - events.forEach(function(event) { - db.serverConfig.on(event, function(object1, object2) { - self.emit(event, object1, object2); - }); - }); + // Fire close event on any cached db instances + for (const name in this.s.dbCache) { + this.s.dbCache[name].emit('close'); } -} - -function createReplicaset(self, options, callback) { - // Set default options - var servers = translateOptions(options); - // Create Db instance - var db = new Db(options.dbName, new ReplSet(servers, options), options); - // Propegate the events to the client - relayEvents(self, db); - // Open the connection - db.open(callback); -} -function createMongos(self, options, callback) { - // Set default options - var servers = translateOptions(options); - // Create Db instance - var db = new Db(options.dbName, new Mongos(servers, options), options) - // Propegate the events to the client - relayEvents(self, db); - // Open the connection - db.open(callback); -} + // Remove listeners after emit + this.removeAllListeners('close'); -function createServer(self, options, callback) { - // Set default options - var servers = translateOptions(options); - // Create db instance - var db = new Db(options.dbName, servers[0], options); - // Propegate the events to the client - var collectedEvents = collectEvents(self, db); - // Create Db instance - db.open(function(err, db) { - if(err) return callback(err); - // Check if we are really speaking to a mongos - var ismaster = db.serverConfig.lastIsMaster(); - - // Do we actually have a mongos - if(ismaster && ismaster.msg == 'isdbgrid') { - // Destroy the current connection - db.close(); - // Create mongos connection instead - return createMongos(self, options, callback); - } + // Callback after next event loop tick + if (typeof callback === 'function') + return process.nextTick(() => { + handleCallback(callback, null); + }); - // Fire all the events - replayEvents(self, collectedEvents); - // Propegate the events to the client - relayEvents(self, db); - // Otherwise callback - callback(err, db); + // Return dummy promise + return new this.s.promiseLibrary(resolve => { + resolve(); }); -} +}; -function connectHandler(options, callback) { - return function (err, db) { - if(err) { - return process.nextTick(function() { - try { - callback(err, null); - } catch (err) { - if(db) db.close(); - throw err - } - }); - } +/** + * Create a new Db instance sharing the current socket connections. Be aware that the new db instances are + * related in a parent-child relationship to the original instance so that events are correctly emitted on child + * db instances. Child db instances are cached so performing db('db1') twice will return the same instance. + * You can control these behaviors with the options noListener and returnNonCachedInstance. + * + * @method + * @param {string} [dbName] The name of the database we want to use. If not provided, use database name from connection string. + * @param {object} [options] Optional settings. + * @param {boolean} [options.noListener=false] Do not make the db an event listener to the original connection. + * @param {boolean} [options.returnNonCachedInstance=false] Control if you want to return a cached instance or have a new one created + * @return {Db} + */ +MongoClient.prototype.db = function(dbName, options) { + options = options || {}; - // No authentication just reconnect - if(!options.auth) { - return process.nextTick(function() { - try { - callback(err, db); - } catch (err) { - if(db) db.close(); - throw err - } - }) - } + // Default to db from connection string if not provided + if (!dbName) { + dbName = this.s.options.dbName; + } - // What db to authenticate against - var authentication_db = db; - if(options.authSource) { - authentication_db = db.db(options.authSource); - } + // Copy the options and add out internal override of the not shared flag + const finalOptions = Object.assign({}, this.s.options, options); - // Authenticate - authenticate(authentication_db, options.user, options.password, options, function(err, success) { - if(success){ - process.nextTick(function() { - try { - callback(null, db); - } catch (err) { - if(db) db.close(); - throw err - } - }); - } else { - if(db) db.close(); - process.nextTick(function() { - try { - callback(err ? err : new Error('Could not authenticate user ' + options.auth[0]), null); - } catch (err) { - if(db) db.close(); - throw err - } - }); - } - }); + // Do we have the db in the cache already + if (this.s.dbCache[dbName] && finalOptions.returnNonCachedInstance !== true) { + return this.s.dbCache[dbName]; } -} -/* - * Connect using MongoClient - */ -var connect = function(self, url, options, callback) { - options = options || {}; - options = shallowClone(options); + // Add promiseLibrary + finalOptions.promiseLibrary = this.s.promiseLibrary; - // If callback is null throw an exception - if(callback == null) { - throw new Error("no callback function provided"); + // If no topology throw an error message + if (!this.topology) { + throw new MongoError('MongoClient must be connected before calling MongoClient.prototype.db'); } - // Get a logger for MongoClient - var logger = Logger('MongoClient', options); + // Return the db object + const db = new Db(dbName, this.topology, finalOptions); - parse(url, options, function(err, object) { - if (err) return callback(err); + // Add the db to the cache + this.s.dbCache[dbName] = db; + // Return the database + return db; +}; - // Parse the string - var _finalOptions = createUnifiedOptions({}, object); - _finalOptions = mergeOptions(_finalOptions, object, false); - _finalOptions = createUnifiedOptions(_finalOptions, options); +/** + * Check if MongoClient is connected + * + * @method + * @param {object} [options] Optional settings. + * @param {boolean} [options.noListener=false] Do not make the db an event listener to the original connection. + * @param {boolean} [options.returnNonCachedInstance=false] Control if you want to return a cached instance or have a new one created + * @return {boolean} + */ +MongoClient.prototype.isConnected = function(options) { + options = options || {}; - // Check if we have connection and socket timeout set - if(_finalOptions.socketTimeoutMS == null) _finalOptions.socketTimeoutMS = 360000; - if(_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 30000; + if (!this.topology) return false; + return this.topology.isConnected(options); +}; - if (_finalOptions.db_options && _finalOptions.db_options.auth) { - delete _finalOptions.db_options.auth; - } +/** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @static + * @param {string} url The connection URI string + * @param {object} [options] Optional settings + * @param {number} [options.poolSize=5] The maximum size of the individual server pool + * @param {boolean} [options.ssl=false] Enable SSL connection. + * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against Certificate Authority + * @param {buffer} [options.sslCA=undefined] SSL Certificate store binary buffer + * @param {buffer} [options.sslCert=undefined] SSL Certificate binary buffer + * @param {buffer} [options.sslKey=undefined] SSL Key file binary buffer + * @param {string} [options.sslPass=undefined] SSL Certificate pass phrase + * @param {buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer + * @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {boolean} [options.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket + * @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting + * @param {number} [options.family] Version of IP stack. Can be 4, 6 or null (default). + * If null, will attempt to connect with IPv6, and will fall back to IPv4 on failure + * @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies + * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry + * @param {string} [options.replicaSet=undefined] The Replicaset set name + * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection + * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection + * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available + * @param {string} [options.authSource=undefined] Define the database to authenticate against + * @param {(number|string)} [options.w] The write concern + * @param {number} [options.wtimeout] The write concern timeout + * @param {boolean} [options.j=false] Specify a journal write concern + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers + * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited + * @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST) + * @param {object} [options.pkFactory] A primary key factory object for generation of custom _id keys + * @param {object} [options.promiseLibrary] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern] Specify a read concern for the collection (only MongoDB 3.2 or higher supported) + * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) + * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed) + * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) + * @param {object} [options.logger=undefined] Custom logger object + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers + * @param {boolean} [options.promoteLongs=true] Promotes long values to number if they fit inside the 53 bits resolution + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function + * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness + * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections + * @param {string} [options.auth.user=undefined] The username for auth + * @param {string} [options.auth.password=undefined] The password for auth + * @param {string} [options.authMechanism=undefined] Mechanism for authentication: MDEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 + * @param {object} [options.compression] Type of compression to use: snappy or zlib + * @param {boolean} [options.fsync=false] Specify a file sync write concern + * @param {array} [options.readPreferenceTags] Read preference tags + * @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor + * @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances + * @param {number} [options.minSize] If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections + * @param {MongoClient~connectCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +MongoClient.connect = function(url, options, callback) { + const args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] === 'function' ? args.pop() : undefined; + options = args.length ? args.shift() : null; + options = options || {}; - // Failure modes - if(object.servers.length == 0) { - throw new Error("connection string must contain at least one seed host"); - } + // Create client + const mongoClient = new MongoClient(url, options); + // Execute the connect method + return mongoClient.connect(callback); +}; - // Do we have a replicaset then skip discovery and go straight to connectivity - if(_finalOptions.replicaSet || _finalOptions.rs_name) { - return createReplicaset(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); - } else if(object.servers.length > 1) { - return createMongos(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); - } else { - return createServer(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); - } - }); +/** + * Starts a new session on the server + * + * @param {SessionOptions} [options] optional settings for a driver session + * @return {ClientSession} the newly established session + */ +MongoClient.prototype.startSession = function(options) { + options = Object.assign({ explicit: true }, options); + if (!this.topology) { + throw new MongoError('Must connect to a server before calling this method'); + } + + if (!this.topology.hasSessionSupport()) { + throw new MongoError('Current topology does not support sessions'); + } - function connectCallback(err, db) { - if(err && err.message == 'no mongos proxies found in seed list') { - if(logger.isWarn()) { - logger.warn(f('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name')); - } + return this.topology.startSession(options, this.s.options); +}; - // Return a more specific error message for MongoClient.connect - return callback(new MongoError('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name')); +/** + * Runs a given operation with an implicitly created session. The lifetime of the session + * will be handled without the need for user interaction. + * + * NOTE: presently the operation MUST return a Promise (either explicit or implicity as an async function) + * + * @param {Object} [options] Optional settings to be appled to implicitly created session + * @param {Function} operation An operation to execute with an implicitly created session. The signature of this MUST be `(session) => {}` + * @return {Promise} + */ +MongoClient.prototype.withSession = function(options, operation) { + if (typeof options === 'function') (operation = options), (options = undefined); + const session = this.startSession(options); + + let cleanupHandler = (err, result, opts) => { + // prevent multiple calls to cleanupHandler + cleanupHandler = () => { + throw new ReferenceError('cleanupHandler was called too many times'); + }; + + opts = Object.assign({ throw: true }, opts); + session.endSession(); + + if (err) { + if (opts.throw) throw err; + return Promise.reject(err); } + }; + + try { + const result = operation(session); + return Promise.resolve(result) + .then(result => cleanupHandler(null, result)) + .catch(err => cleanupHandler(err, null, { throw: true })); + } catch (err) { + return cleanupHandler(err, null, { throw: false }); + } +}; +/** + * Create a new Change Stream, watching for new changes (insertions, updates, replacements, deletions, and invalidations) in this cluster. Will ignore all changes to system collections, as well as the local, admin, + * and config databases. + * @method + * @since 3.1.0 + * @param {Array} [pipeline] An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents. + * @param {object} [options] Optional settings + * @param {string} [options.fullDocument='default'] Allowed values: ‘default’, ‘updateLookup’. When set to ‘updateLookup’, the change stream will include both a delta describing the changes to the document, as well as a copy of the entire document that was changed from some time after the change occurred. + * @param {object} [options.resumeAfter] Specifies the logical starting point for the new change stream. This should be the _id field from a previously returned change stream document. + * @param {number} [options.maxAwaitTimeMS] The maximum amount of time for the server to wait on new documents to satisfy a change stream query + * @param {number} [options.batchSize] The number of documents to return per batch. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {object} [options.collation] Specify collation settings for operation. See {@link https://docs.mongodb.com/manual/reference/command/aggregate|aggregation documentation}. + * @param {ReadPreference} [options.readPreference] The read preference. See {@link https://docs.mongodb.com/manual/reference/read-preference|read preference documentation}. + * @param {Timestamp} [options.startAtClusterTime] receive change events that occur after the specified timestamp + * @param {ClientSession} [options.session] optional session to use for this operation + * @return {ChangeStream} a ChangeStream instance. + */ +MongoClient.prototype.watch = function(pipeline, options) { + pipeline = pipeline || []; + options = options || {}; - // Return the error and db instance - callback(err, db); + // Allow optionally not specifying a pipeline + if (!Array.isArray(pipeline)) { + options = pipeline; + pipeline = []; } -} -module.exports = MongoClient + return new ChangeStream(this, pipeline, options); +}; + +/** + * Return the mongo client logger + * @method + * @return {Logger} return the mongo client logger + * @ignore + */ +MongoClient.prototype.getLogger = function() { + return this.s.options.logger; +}; + +module.exports = MongoClient; diff --git a/node_modules/mongodb/lib/operations/admin_ops.js b/node_modules/mongodb/lib/operations/admin_ops.js new file mode 100644 index 0000000..b08071c --- /dev/null +++ b/node_modules/mongodb/lib/operations/admin_ops.js @@ -0,0 +1,62 @@ +'use strict'; + +const executeCommand = require('./db_ops').executeCommand; +const executeDbAdminCommand = require('./db_ops').executeDbAdminCommand; + +/** + * Get ReplicaSet status + * + * @param {Admin} a collection instance. + * @param {Object} [options] Optional settings. See Admin.prototype.replSetGetStatus for a list of options. + * @param {Admin~resultCallback} [callback] The command result callback. + */ +function replSetGetStatus(admin, options, callback) { + executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback); +} + +/** + * Retrieve this db's server status. + * + * @param {Admin} a collection instance. + * @param {Object} [options] Optional settings. See Admin.prototype.serverStatus for a list of options. + * @param {Admin~resultCallback} [callback] The command result callback + */ +function serverStatus(admin, options, callback) { + executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback); +} + +/** + * Validate an existing collection + * + * @param {Admin} a collection instance. + * @param {string} collectionName The name of the collection to validate. + * @param {Object} [options] Optional settings. See Admin.prototype.validateCollection for a list of options. + * @param {Admin~resultCallback} [callback] The command result callback. + */ +function validateCollection(admin, collectionName, options, callback) { + const command = { validate: collectionName }; + const keys = Object.keys(options); + + // Decorate command with extra options + for (let i = 0; i < keys.length; i++) { + if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') { + command[keys[i]] = options[keys[i]]; + } + } + + executeCommand(admin.s.db, command, options, (err, doc) => { + if (err != null) return callback(err, null); + + if (doc.ok === 0) return callback(new Error('Error with validate command'), null); + if (doc.result != null && doc.result.constructor !== String) + return callback(new Error('Error with validation data'), null); + if (doc.result != null && doc.result.match(/exception|corrupt/) != null) + return callback(new Error('Error: invalid collection ' + collectionName), null); + if (doc.valid != null && !doc.valid) + return callback(new Error('Error: invalid collection ' + collectionName), null); + + return callback(null, doc); + }); +} + +module.exports = { replSetGetStatus, serverStatus, validateCollection }; diff --git a/node_modules/mongodb/lib/operations/collection_ops.js b/node_modules/mongodb/lib/operations/collection_ops.js new file mode 100644 index 0000000..ce0b6cf --- /dev/null +++ b/node_modules/mongodb/lib/operations/collection_ops.js @@ -0,0 +1,1455 @@ +'use strict'; + +const applyWriteConcern = require('../utils').applyWriteConcern; +const checkCollectionName = require('../utils').checkCollectionName; +const Code = require('mongodb-core').BSON.Code; +const createIndexDb = require('./db_ops').createIndex; +const decorateCommand = require('../utils').decorateCommand; +const decorateWithCollation = require('../utils').decorateWithCollation; +const decorateWithReadConcern = require('../utils').decorateWithReadConcern; +const ensureIndexDb = require('./db_ops').ensureIndex; +const evaluate = require('./db_ops').evaluate; +const executeCommand = require('./db_ops').executeCommand; +const executeDbAdminCommand = require('./db_ops').executeDbAdminCommand; +const formattedOrderClause = require('../utils').formattedOrderClause; +const resolveReadPreference = require('../utils').resolveReadPreference; +const handleCallback = require('../utils').handleCallback; +const indexInformationDb = require('./db_ops').indexInformation; +const isObject = require('../utils').isObject; +const Long = require('mongodb-core').BSON.Long; +const MongoError = require('mongodb-core').MongoError; +const ReadPreference = require('mongodb-core').ReadPreference; +const toError = require('../utils').toError; + +/** + * Group function helper + * @ignore + */ +// var groupFunction = function () { +// var c = db[ns].find(condition); +// var map = new Map(); +// var reduce_function = reduce; +// +// while (c.hasNext()) { +// var obj = c.next(); +// var key = {}; +// +// for (var i = 0, len = keys.length; i < len; ++i) { +// var k = keys[i]; +// key[k] = obj[k]; +// } +// +// var aggObj = map.get(key); +// +// if (aggObj == null) { +// var newObj = Object.extend({}, key); +// aggObj = Object.extend(newObj, initial); +// map.put(key, aggObj); +// } +// +// reduce_function(obj, aggObj); +// } +// +// return { "result": map.values() }; +// }.toString(); +const groupFunction = + 'function () {\nvar c = db[ns].find(condition);\nvar map = new Map();\nvar reduce_function = reduce;\n\nwhile (c.hasNext()) {\nvar obj = c.next();\nvar key = {};\n\nfor (var i = 0, len = keys.length; i < len; ++i) {\nvar k = keys[i];\nkey[k] = obj[k];\n}\n\nvar aggObj = map.get(key);\n\nif (aggObj == null) {\nvar newObj = Object.extend({}, key);\naggObj = Object.extend(newObj, initial);\nmap.put(key, aggObj);\n}\n\nreduce_function(obj, aggObj);\n}\n\nreturn { "result": map.values() };\n}'; + +/** + * Perform a bulkWrite operation. See Collection.prototype.bulkWrite for more information. + * + * @method + * @param {Collection} a Collection instance. + * @param {object[]} operations Bulk operations to perform. + * @param {object} [options] Optional settings. See Collection.prototype.bulkWrite for a list of options. + * @param {Collection~bulkWriteOpCallback} [callback] The command result callback + */ +function bulkWrite(coll, operations, options, callback) { + // Add ignoreUndfined + if (coll.s.options.ignoreUndefined) { + options = Object.assign({}, options); + options.ignoreUndefined = coll.s.options.ignoreUndefined; + } + + // Create the bulk operation + const bulk = + options.ordered === true || options.ordered == null + ? coll.initializeOrderedBulkOp(options) + : coll.initializeUnorderedBulkOp(options); + + // Do we have a collation + let collation = false; + + // for each op go through and add to the bulk + try { + for (let i = 0; i < operations.length; i++) { + // Get the operation type + const key = Object.keys(operations[i])[0]; + // Check if we have a collation + if (operations[i][key].collation) { + collation = true; + } + + // Pass to the raw bulk + bulk.raw(operations[i]); + } + } catch (err) { + return callback(err, null); + } + + // Final options for write concern + const finalOptions = applyWriteConcern( + Object.assign({}, options), + { db: coll.s.db, collection: coll }, + options + ); + + const writeCon = finalOptions.writeConcern ? finalOptions.writeConcern : {}; + const capabilities = coll.s.topology.capabilities(); + + // Did the user pass in a collation, check if our write server supports it + if (collation && capabilities && !capabilities.commandsTakeCollation) { + return callback(new MongoError('server/primary/mongos does not support collation')); + } + + // Execute the bulk + bulk.execute(writeCon, finalOptions, (err, r) => { + // We have connection level error + if (!r && err) { + return callback(err, null); + } + + r.insertedCount = r.nInserted; + r.matchedCount = r.nMatched; + r.modifiedCount = r.nModified || 0; + r.deletedCount = r.nRemoved; + r.upsertedCount = r.getUpsertedIds().length; + r.upsertedIds = {}; + r.insertedIds = {}; + + // Update the n + r.n = r.insertedCount; + + // Inserted documents + const inserted = r.getInsertedIds(); + // Map inserted ids + for (let i = 0; i < inserted.length; i++) { + r.insertedIds[inserted[i].index] = inserted[i]._id; + } + + // Upserted documents + const upserted = r.getUpsertedIds(); + // Map upserted ids + for (let i = 0; i < upserted.length; i++) { + r.upsertedIds[upserted[i].index] = upserted[i]._id; + } + + // Return the results + callback(null, r); + }); +} + +// Check the update operation to ensure it has atomic operators. +function checkForAtomicOperators(update) { + const keys = Object.keys(update); + + // same errors as the server would give for update doc lacking atomic operators + if (keys.length === 0) { + return toError('The update operation document must contain at least one atomic operator.'); + } + + if (keys[0][0] !== '$') { + return toError('the update operation document must contain atomic operators.'); + } +} + +/** + * Count the number of documents in the collection that match the query. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} query The query for the count. + * @param {object} [options] Optional settings. See Collection.prototype.count for a list of options. + * @param {Collection~countCallback} [callback] The command result callback + */ +function count(coll, query, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = Object.assign({}, options); + options.collectionName = coll.s.name; + + options.readPreference = resolveReadPreference(options, { + db: coll.s.db, + collection: coll + }); + + const cmd = buildCountCommand(coll, query, options); + + executeCommand(coll.s.db, cmd, options, (err, result) => { + if (err) return handleCallback(callback, err); + handleCallback(callback, null, result.n); + }); +} + +function countDocuments(coll, query, options, callback) { + const skip = options.skip; + const limit = options.limit; + options = Object.assign({}, options); + + const pipeline = [{ $match: query }]; + + // Add skip and limit if defined + if (typeof skip === 'number') { + pipeline.push({ $skip: skip }); + } + + if (typeof limit === 'number') { + pipeline.push({ $limit: limit }); + } + + pipeline.push({ $group: { _id: null, n: { $sum: 1 } } }); + + delete options.limit; + delete options.skip; + + coll.aggregate(pipeline, options).toArray((err, docs) => { + if (err) return handleCallback(callback, err); + handleCallback(callback, null, docs.length ? docs[0].n : 0); + }); +} + +/** + * Build the count command. + * + * @method + * @param {collectionOrCursor} an instance of a collection or cursor + * @param {object} query The query for the count. + * @param {object} [options] Optional settings. See Collection.prototype.count and Cursor.prototype.count for a list of options. + */ +function buildCountCommand(collectionOrCursor, query, options) { + const skip = options.skip; + const limit = options.limit; + let hint = options.hint; + const maxTimeMS = options.maxTimeMS; + query = query || {}; + + // Final query + const cmd = { + count: options.collectionName, + query: query + }; + + // check if collectionOrCursor is a cursor by using cursor.s.numberOfRetries + if (collectionOrCursor.s.numberOfRetries) { + if (collectionOrCursor.s.options.hint) { + hint = collectionOrCursor.s.options.hint; + } else if (collectionOrCursor.s.cmd.hint) { + hint = collectionOrCursor.s.cmd.hint; + } + decorateWithCollation(cmd, collectionOrCursor, collectionOrCursor.s.cmd); + } else { + decorateWithCollation(cmd, collectionOrCursor, options); + } + + // Add limit, skip and maxTimeMS if defined + if (typeof skip === 'number') cmd.skip = skip; + if (typeof limit === 'number') cmd.limit = limit; + if (typeof maxTimeMS === 'number') cmd.maxTimeMS = maxTimeMS; + if (hint) cmd.hint = hint; + + // Do we have a readConcern specified + decorateWithReadConcern(cmd, collectionOrCursor); + + return cmd; +} + +/** + * Create an index on the db and collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options] Optional settings. See Collection.prototype.createIndex for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function createIndex(coll, fieldOrSpec, options, callback) { + createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback); +} + +/** + * Create multiple indexes in the collection. This method is only supported for + * MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported + * error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/. + * + * @method + * @param {Collection} a Collection instance. + * @param {array} indexSpecs An array of index specifications to be created + * @param {Object} [options] Optional settings. See Collection.prototype.createIndexes for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function createIndexes(coll, indexSpecs, options, callback) { + const capabilities = coll.s.topology.capabilities(); + + // Ensure we generate the correct name if the parameter is not set + for (let i = 0; i < indexSpecs.length; i++) { + if (indexSpecs[i].name == null) { + const keys = []; + + // Did the user pass in a collation, check if our write server supports it + if (indexSpecs[i].collation && capabilities && !capabilities.commandsTakeCollation) { + return callback(new MongoError('server/primary/mongos does not support collation')); + } + + for (let name in indexSpecs[i].key) { + keys.push(`${name}_${indexSpecs[i].key[name]}`); + } + + // Set the name + indexSpecs[i].name = keys.join('_'); + } + } + + options = Object.assign({}, options, { readPreference: ReadPreference.PRIMARY }); + + // Execute the index + executeCommand( + coll.s.db, + { + createIndexes: coll.s.name, + indexes: indexSpecs + }, + options, + callback + ); +} + +function deleteCallback(err, r, callback) { + if (callback == null) return; + if (err && callback) return callback(err); + if (r == null) return callback(null, { result: { ok: 1 } }); + r.deletedCount = r.result.n; + if (callback) callback(null, r); +} + +/** + * Delete multiple documents from the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter The Filter used to select the documents to remove + * @param {object} [options] Optional settings. See Collection.prototype.deleteMany for a list of options. + * @param {Collection~deleteWriteOpCallback} [callback] The command result callback + */ +function deleteMany(coll, filter, options, callback) { + options.single = false; + + removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback)); +} + +/** + * Delete a single document from the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter The Filter used to select the document to remove + * @param {object} [options] Optional settings. See Collection.prototype.deleteOne for a list of options. + * @param {Collection~deleteWriteOpCallback} [callback] The command result callback + */ +function deleteOne(coll, filter, options, callback) { + options.single = true; + removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback)); +} + +/** + * Return a list of distinct values for the given key across a collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {string} key Field of the document to find distinct values for. + * @param {object} query The query for filtering the set of documents to which we apply the distinct filter. + * @param {object} [options] Optional settings. See Collection.prototype.distinct for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function distinct(coll, key, query, options, callback) { + // maxTimeMS option + const maxTimeMS = options.maxTimeMS; + + // Distinct command + const cmd = { + distinct: coll.s.name, + key: key, + query: query + }; + + options = Object.assign({}, options); + // Ensure we have the right read preference inheritance + options.readPreference = resolveReadPreference(options, { db: coll.s.db, collection: coll }); + + // Add maxTimeMS if defined + if (typeof maxTimeMS === 'number') cmd.maxTimeMS = maxTimeMS; + + // Do we have a readConcern specified + decorateWithReadConcern(cmd, coll, options); + + // Have we specified collation + decorateWithCollation(cmd, coll, options); + + // Execute the command + executeCommand(coll.s.db, cmd, options, (err, result) => { + if (err) return handleCallback(callback, err); + handleCallback(callback, null, result.values); + }); +} + +/** + * Drop an index from this collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {string} indexName Name of the index to drop. + * @param {object} [options] Optional settings. See Collection.prototype.dropIndex for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function dropIndex(coll, indexName, options, callback) { + // Delete index command + const cmd = { dropIndexes: coll.s.name, index: indexName }; + + // Decorate command with writeConcern if supported + applyWriteConcern(cmd, { db: coll.s.db, collection: coll }, options); + + // Execute command + executeCommand(coll.s.db, cmd, options, (err, result) => { + if (typeof callback !== 'function') return; + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result); + }); +} + +/** + * Drop all indexes from this collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {Object} [options] Optional settings. See Collection.prototype.dropIndexes for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function dropIndexes(coll, options, callback) { + dropIndex(coll, '*', options, err => { + if (err) return handleCallback(callback, err, false); + handleCallback(callback, null, true); + }); +} + +/** + * Ensure that an index exists. If the index does not exist, this function creates it. + * + * @method + * @param {Collection} a Collection instance. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options] Optional settings. See Collection.prototype.ensureIndex for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function ensureIndex(coll, fieldOrSpec, options, callback) { + ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback); +} + +/** + * Find and update a document. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} query Query object to locate the object to modify. + * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. + * @param {object} doc The fields/vals to be updated. + * @param {object} [options] Optional settings. See Collection.prototype.findAndModify for a list of options. + * @param {Collection~findAndModifyCallback} [callback] The command result callback + * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead + */ +function findAndModify(coll, query, sort, doc, options, callback) { + // Create findAndModify command object + const queryObject = { + findAndModify: coll.s.name, + query: query + }; + + sort = formattedOrderClause(sort); + if (sort) { + queryObject.sort = sort; + } + + queryObject.new = options.new ? true : false; + queryObject.remove = options.remove ? true : false; + queryObject.upsert = options.upsert ? true : false; + + const projection = options.projection || options.fields; + + if (projection) { + queryObject.fields = projection; + } + + if (options.arrayFilters) { + queryObject.arrayFilters = options.arrayFilters; + delete options.arrayFilters; + } + + if (doc && !options.remove) { + queryObject.update = doc; + } + + if (options.maxTimeMS) queryObject.maxTimeMS = options.maxTimeMS; + + // Either use override on the function, or go back to default on either the collection + // level or db + options.serializeFunctions = options.serializeFunctions || coll.s.serializeFunctions; + + // No check on the documents + options.checkKeys = false; + + // Get the write concern settings + const finalOptions = applyWriteConcern(options, { db: coll.s.db, collection: coll }, options); + + // Decorate the findAndModify command with the write Concern + if (finalOptions.writeConcern) { + queryObject.writeConcern = finalOptions.writeConcern; + } + + // Have we specified bypassDocumentValidation + if (finalOptions.bypassDocumentValidation === true) { + queryObject.bypassDocumentValidation = finalOptions.bypassDocumentValidation; + } + + finalOptions.readPreference = ReadPreference.primary; + + // Have we specified collation + decorateWithCollation(queryObject, coll, finalOptions); + + // Execute the command + executeCommand(coll.s.db, queryObject, finalOptions, (err, result) => { + if (err) return handleCallback(callback, err, null); + + return handleCallback(callback, null, result); + }); +} + +/** + * Find and remove a document. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} query Query object to locate the object to modify. + * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. + * @param {object} [options] Optional settings. See Collection.prototype.findAndRemove for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + * @deprecated use findOneAndDelete instead + */ +function findAndRemove(coll, query, sort, options, callback) { + // Add the remove option + options.remove = true; + // Execute the callback + findAndModify(coll, query, sort, null, options, callback); +} + +/** + * Fetch the first document that matches the query. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} query Query for find Operation + * @param {object} [options] Optional settings. See Collection.prototype.findOne for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function findOne(coll, query, options, callback) { + const cursor = coll + .find(query, options) + .limit(-1) + .batchSize(1); + + // Return the item + cursor.next((err, item) => { + if (err != null) return handleCallback(callback, toError(err), null); + handleCallback(callback, null, item); + }); +} + +/** + * Find a document and delete it in one atomic operation. This requires a write lock for the duration of the operation. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter Document selection filter. + * @param {object} [options] Optional settings. See Collection.prototype.findOneAndDelete for a list of options. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + */ +function findOneAndDelete(coll, filter, options, callback) { + // Final options + const finalOptions = Object.assign({}, options); + finalOptions.fields = options.projection; + finalOptions.remove = true; + // Execute find and Modify + findAndModify(coll, filter, options.sort, null, finalOptions, callback); +} + +/** + * Find a document and replace it in one atomic operation. This requires a write lock for the duration of the operation. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter Document selection filter. + * @param {object} replacement Document replacing the matching document. + * @param {object} [options] Optional settings. See Collection.prototype.findOneAndReplace for a list of options. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + */ +function findOneAndReplace(coll, filter, replacement, options, callback) { + // Final options + const finalOptions = Object.assign({}, options); + finalOptions.fields = options.projection; + finalOptions.update = true; + finalOptions.new = options.returnOriginal !== void 0 ? !options.returnOriginal : false; + finalOptions.upsert = options.upsert !== void 0 ? !!options.upsert : false; + + // Execute findAndModify + findAndModify(coll, filter, options.sort, replacement, finalOptions, callback); +} + +/** + * Find a document and update it in one atomic operation. This requires a write lock for the duration of the operation. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter Document selection filter. + * @param {object} update Update operations to be performed on the document + * @param {object} [options] Optional settings. See Collection.prototype.findOneAndUpdate for a list of options. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + */ +function findOneAndUpdate(coll, filter, update, options, callback) { + // Final options + const finalOptions = Object.assign({}, options); + finalOptions.fields = options.projection; + finalOptions.update = true; + finalOptions.new = typeof options.returnOriginal === 'boolean' ? !options.returnOriginal : false; + finalOptions.upsert = typeof options.upsert === 'boolean' ? options.upsert : false; + + // Execute findAndModify + findAndModify(coll, filter, options.sort, update, finalOptions, callback); +} + +/** + * Execute a geo search using a geo haystack index on a collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order. + * @param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order. + * @param {object} [options] Optional settings. See Collection.prototype.geoHaystackSearch for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function geoHaystackSearch(coll, x, y, options, callback) { + // Build command object + let commandObject = { + geoSearch: coll.s.name, + near: [x, y] + }; + + // Remove read preference from hash if it exists + commandObject = decorateCommand(commandObject, options, { readPreference: true, session: true }); + + options = Object.assign({}, options); + // Ensure we have the right read preference inheritance + options.readPreference = resolveReadPreference(options, { db: coll.s.db, collection: coll }); + + // Do we have a readConcern specified + decorateWithReadConcern(commandObject, coll, options); + + // Execute the command + executeCommand(coll.s.db, commandObject, options, (err, res) => { + if (err) return handleCallback(callback, err); + if (res.err || res.errmsg) handleCallback(callback, toError(res)); + // should we only be returning res.results here? Not sure if the user + // should see the other return information + handleCallback(callback, null, res); + }); +} + +/** + * Run a group command across a collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {(object|array|function|code)} keys An object, array or function expressing the keys to group by. + * @param {object} condition An optional condition that must be true for a row to be considered. + * @param {object} initial Initial value of the aggregation counter object. + * @param {(function|Code)} reduce The reduce function aggregates (reduces) the objects iterated + * @param {(function|Code)} finalize An optional function to be run on each item in the result set just before the item is returned. + * @param {boolean} command Specify if you wish to run using the internal group command or using eval, default is true. + * @param {object} [options] Optional settings. See Collection.prototype.group for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + * @deprecated MongoDB 3.6 or higher will no longer support the group command. We recommend rewriting using the aggregation framework. + */ +function group(coll, keys, condition, initial, reduce, finalize, command, options, callback) { + // Execute using the command + if (command) { + const reduceFunction = reduce && reduce._bsontype === 'Code' ? reduce : new Code(reduce); + + const selector = { + group: { + ns: coll.s.name, + $reduce: reduceFunction, + cond: condition, + initial: initial, + out: 'inline' + } + }; + + // if finalize is defined + if (finalize != null) selector.group['finalize'] = finalize; + // Set up group selector + if ('function' === typeof keys || (keys && keys._bsontype === 'Code')) { + selector.group.$keyf = keys && keys._bsontype === 'Code' ? keys : new Code(keys); + } else { + const hash = {}; + keys.forEach(key => { + hash[key] = 1; + }); + selector.group.key = hash; + } + + options = Object.assign({}, options); + // Ensure we have the right read preference inheritance + options.readPreference = resolveReadPreference(options, { db: coll.s.db, collection: coll }); + + // Do we have a readConcern specified + decorateWithReadConcern(selector, coll, options); + + // Have we specified collation + decorateWithCollation(selector, coll, options); + + // Execute command + executeCommand(coll.s.db, selector, options, (err, result) => { + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.retval); + }); + } else { + // Create execution scope + const scope = reduce != null && reduce._bsontype === 'Code' ? reduce.scope : {}; + + scope.ns = coll.s.name; + scope.keys = keys; + scope.condition = condition; + scope.initial = initial; + + // Pass in the function text to execute within mongodb. + const groupfn = groupFunction.replace(/ reduce;/, reduce.toString() + ';'); + + evaluate(coll.s.db, new Code(groupfn, scope), null, options, (err, results) => { + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, results.result || results); + }); + } +} + +/** + * Retrieve all the indexes on the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {Object} [options] Optional settings. See Collection.prototype.indexes for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function indexes(coll, options, callback) { + options = Object.assign({}, { full: true }, options); + indexInformationDb(coll.s.db, coll.s.name, options, callback); +} + +/** + * Check if one or more indexes exist on the collection. This fails on the first index that doesn't exist. + * + * @method + * @param {Collection} a Collection instance. + * @param {(string|array)} indexes One or more index names to check. + * @param {Object} [options] Optional settings. See Collection.prototype.indexExists for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function indexExists(coll, indexes, options, callback) { + indexInformation(coll, options, (err, indexInformation) => { + // If we have an error return + if (err != null) return handleCallback(callback, err, null); + // Let's check for the index names + if (!Array.isArray(indexes)) + return handleCallback(callback, null, indexInformation[indexes] != null); + // Check in list of indexes + for (let i = 0; i < indexes.length; i++) { + if (indexInformation[indexes[i]] == null) { + return handleCallback(callback, null, false); + } + } + + // All keys found return true + return handleCallback(callback, null, true); + }); +} + +/** + * Retrieve this collection's index info. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} [options] Optional settings. See Collection.prototype.indexInformation for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function indexInformation(coll, options, callback) { + indexInformationDb(coll.s.db, coll.s.name, options, callback); +} + +function insertDocuments(coll, docs, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + // Ensure we are operating on an array op docs + docs = Array.isArray(docs) ? docs : [docs]; + + // Get the write concern options + const finalOptions = applyWriteConcern( + Object.assign({}, options), + { db: coll.s.db, collection: coll }, + options + ); + + // If keep going set unordered + if (finalOptions.keepGoing === true) finalOptions.ordered = false; + finalOptions.serializeFunctions = options.serializeFunctions || coll.s.serializeFunctions; + + docs = prepareDocs(coll, docs, options); + + // File inserts + coll.s.topology.insert(coll.s.namespace, docs, finalOptions, (err, result) => { + if (callback == null) return; + if (err) return handleCallback(callback, err); + if (result == null) return handleCallback(callback, null, null); + if (result.result.code) return handleCallback(callback, toError(result.result)); + if (result.result.writeErrors) + return handleCallback(callback, toError(result.result.writeErrors[0])); + // Add docs to the list + result.ops = docs; + // Return the results + handleCallback(callback, null, result); + }); +} + +/** + * Insert a single document into the collection. See Collection.prototype.insertOne for more information. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} doc Document to insert. + * @param {object} [options] Optional settings. See Collection.prototype.insertOne for a list of options. + * @param {Collection~insertOneWriteOpCallback} [callback] The command result callback + */ +function insertOne(coll, doc, options, callback) { + if (Array.isArray(doc)) { + return callback( + MongoError.create({ message: 'doc parameter must be an object', driver: true }) + ); + } + + insertDocuments(coll, [doc], options, (err, r) => { + if (callback == null) return; + if (err && callback) return callback(err); + // Workaround for pre 2.6 servers + if (r == null) return callback(null, { result: { ok: 1 } }); + // Add values to top level to ensure crud spec compatibility + r.insertedCount = r.result.n; + r.insertedId = doc._id; + if (callback) callback(null, r); + }); +} + +/** + * Determine whether the collection is a capped collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {Object} [options] Optional settings. See Collection.prototype.isCapped for a list of options. + * @param {Collection~resultCallback} [callback] The results callback + */ +function isCapped(coll, options, callback) { + optionsOp(coll, options, (err, document) => { + if (err) return handleCallback(callback, err); + handleCallback(callback, null, !!(document && document.capped)); + }); +} + +/** + * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {(function|string)} map The mapping function. + * @param {(function|string)} reduce The reduce function. + * @param {object} [options] Optional settings. See Collection.prototype.mapReduce for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function mapReduce(coll, map, reduce, options, callback) { + const mapCommandHash = { + mapreduce: coll.s.name, + map: map, + reduce: reduce + }; + + // Exclusion list + const exclusionList = ['readPreference', 'session', 'bypassDocumentValidation']; + + // Add any other options passed in + for (let n in options) { + if ('scope' === n) { + mapCommandHash[n] = processScope(options[n]); + } else { + // Only include if not in exclusion list + if (exclusionList.indexOf(n) === -1) { + mapCommandHash[n] = options[n]; + } + } + } + + options = Object.assign({}, options); + + // Ensure we have the right read preference inheritance + options.readPreference = resolveReadPreference(options, { db: coll.s.db, collection: coll }); + + // If we have a read preference and inline is not set as output fail hard + if ( + options.readPreference !== false && + options.readPreference !== 'primary' && + options['out'] && + (options['out'].inline !== 1 && options['out'] !== 'inline') + ) { + // Force readPreference to primary + options.readPreference = 'primary'; + // Decorate command with writeConcern if supported + applyWriteConcern(mapCommandHash, { db: coll.s.db, collection: coll }, options); + } else { + decorateWithReadConcern(mapCommandHash, coll, options); + } + + // Is bypassDocumentValidation specified + if (options.bypassDocumentValidation === true) { + mapCommandHash.bypassDocumentValidation = options.bypassDocumentValidation; + } + + // Have we specified collation + decorateWithCollation(mapCommandHash, coll, options); + + // Execute command + executeCommand(coll.s.db, mapCommandHash, options, (err, result) => { + if (err) return handleCallback(callback, err); + // Check if we have an error + if (1 !== result.ok || result.err || result.errmsg) { + return handleCallback(callback, toError(result)); + } + + // Create statistics value + const stats = {}; + if (result.timeMillis) stats['processtime'] = result.timeMillis; + if (result.counts) stats['counts'] = result.counts; + if (result.timing) stats['timing'] = result.timing; + + // invoked with inline? + if (result.results) { + // If we wish for no verbosity + if (options['verbose'] == null || !options['verbose']) { + return handleCallback(callback, null, result.results); + } + + return handleCallback(callback, null, { results: result.results, stats: stats }); + } + + // The returned collection + let collection = null; + + // If we have an object it's a different db + if (result.result != null && typeof result.result === 'object') { + const doc = result.result; + // Return a collection from another db + const Db = require('../db'); + collection = new Db(doc.db, coll.s.db.s.topology, coll.s.db.s.options).collection( + doc.collection + ); + } else { + // Create a collection object that wraps the result collection + collection = coll.s.db.collection(result.result); + } + + // If we wish for no verbosity + if (options['verbose'] == null || !options['verbose']) { + return handleCallback(callback, err, collection); + } + + // Return stats as third set of values + handleCallback(callback, err, { collection: collection, stats: stats }); + }); +} + +/** + * Return the options of the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {Object} [options] Optional settings. See Collection.prototype.options for a list of options. + * @param {Collection~resultCallback} [callback] The results callback + */ +function optionsOp(coll, opts, callback) { + coll.s.db.listCollections({ name: coll.s.name }, opts).toArray((err, collections) => { + if (err) return handleCallback(callback, err); + if (collections.length === 0) { + return handleCallback( + callback, + MongoError.create({ message: `collection ${coll.s.namespace} not found`, driver: true }) + ); + } + + handleCallback(callback, err, collections[0].options || null); + }); +} + +/** + * Return N parallel cursors for a collection to allow parallel reading of the entire collection. There are + * no ordering guarantees for returned results. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} [options] Optional settings. See Collection.prototype.parallelCollectionScan for a list of options. + * @param {Collection~parallelCollectionScanCallback} [callback] The command result callback + */ +function parallelCollectionScan(coll, options, callback) { + // Create command object + const commandObject = { + parallelCollectionScan: coll.s.name, + numCursors: options.numCursors + }; + + // Do we have a readConcern specified + decorateWithReadConcern(commandObject, coll, options); + + // Store the raw value + const raw = options.raw; + delete options['raw']; + + // Execute the command + executeCommand(coll.s.db, commandObject, options, (err, result) => { + if (err) return handleCallback(callback, err, null); + if (result == null) + return handleCallback( + callback, + new Error('no result returned for parallelCollectionScan'), + null + ); + + options = Object.assign({ explicitlyIgnoreSession: true }, options); + + const cursors = []; + // Add the raw back to the option + if (raw) options.raw = raw; + // Create command cursors for each item + for (let i = 0; i < result.cursors.length; i++) { + const rawId = result.cursors[i].cursor.id; + // Convert cursorId to Long if needed + const cursorId = typeof rawId === 'number' ? Long.fromNumber(rawId) : rawId; + // Add a command cursor + cursors.push(coll.s.topology.cursor(coll.s.namespace, cursorId, options)); + } + + handleCallback(callback, null, cursors); + }); +} + +// modifies documents before being inserted or updated +function prepareDocs(coll, docs, options) { + const forceServerObjectId = + typeof options.forceServerObjectId === 'boolean' + ? options.forceServerObjectId + : coll.s.db.options.forceServerObjectId; + + // no need to modify the docs if server sets the ObjectId + if (forceServerObjectId === true) { + return docs; + } + + return docs.map(doc => { + if (forceServerObjectId !== true && doc._id == null) { + doc._id = coll.s.pkFactory.createPk(); + } + + return doc; + }); +} + +/** + * Functions that are passed as scope args must + * be converted to Code instances. + * @ignore + */ +function processScope(scope) { + if (!isObject(scope) || scope._bsontype === 'ObjectID') { + return scope; + } + + const keys = Object.keys(scope); + let key; + const new_scope = {}; + + for (let i = keys.length - 1; i >= 0; i--) { + key = keys[i]; + if ('function' === typeof scope[key]) { + new_scope[key] = new Code(String(scope[key])); + } else { + new_scope[key] = processScope(scope[key]); + } + } + + return new_scope; +} + +/** + * Reindex all indexes on the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {Object} [options] Optional settings. See Collection.prototype.reIndex for a list of options. + * @param {Collection~resultCallback} [callback] The command result callback + */ +function reIndex(coll, options, callback) { + // Reindex + const cmd = { reIndex: coll.s.name }; + + // Execute the command + executeCommand(coll.s.db, cmd, options, (err, result) => { + if (callback == null) return; + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }); +} + +function removeDocuments(coll, selector, options, callback) { + if (typeof options === 'function') { + (callback = options), (options = {}); + } else if (typeof selector === 'function') { + callback = selector; + options = {}; + selector = {}; + } + + // Create an empty options object if the provided one is null + options = options || {}; + + // Get the write concern options + const finalOptions = applyWriteConcern( + Object.assign({}, options), + { db: coll.s.db, collection: coll }, + options + ); + + // If selector is null set empty + if (selector == null) selector = {}; + + // Build the op + const op = { q: selector, limit: 0 }; + if (options.single) { + op.limit = 1; + } else if (finalOptions.retryWrites) { + finalOptions.retryWrites = false; + } + + // Have we specified collation + decorateWithCollation(finalOptions, coll, options); + + // Execute the remove + coll.s.topology.remove(coll.s.namespace, [op], finalOptions, (err, result) => { + if (callback == null) return; + if (err) return handleCallback(callback, err, null); + if (result == null) return handleCallback(callback, null, null); + if (result.result.code) return handleCallback(callback, toError(result.result)); + if (result.result.writeErrors) + return handleCallback(callback, toError(result.result.writeErrors[0])); + // Return the results + handleCallback(callback, null, result); + }); +} + +/** + * Rename the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {string} newName New name of of the collection. + * @param {object} [options] Optional settings. See Collection.prototype.rename for a list of options. + * @param {Collection~collectionResultCallback} [callback] The results callback + */ +function rename(coll, newName, options, callback) { + const Collection = require('../collection'); + // Check the collection name + checkCollectionName(newName); + // Build the command + const renameCollection = `${coll.s.dbName}.${coll.s.name}`; + const toCollection = `${coll.s.dbName}.${newName}`; + const dropTarget = typeof options.dropTarget === 'boolean' ? options.dropTarget : false; + const cmd = { renameCollection: renameCollection, to: toCollection, dropTarget: dropTarget }; + + // Decorate command with writeConcern if supported + applyWriteConcern(cmd, { db: coll.s.db, collection: coll }, options); + + // Execute against admin + executeDbAdminCommand(coll.s.db.admin().s.db, cmd, options, (err, doc) => { + if (err) return handleCallback(callback, err, null); + // We have an error + if (doc.errmsg) return handleCallback(callback, toError(doc), null); + try { + return handleCallback( + callback, + null, + new Collection( + coll.s.db, + coll.s.topology, + coll.s.dbName, + newName, + coll.s.pkFactory, + coll.s.options + ) + ); + } catch (err) { + return handleCallback(callback, toError(err), null); + } + }); +} + +/** + * Replace a document in the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter The Filter used to select the document to update + * @param {object} doc The Document that replaces the matching document + * @param {object} [options] Optional settings. See Collection.prototype.replaceOne for a list of options. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + */ +function replaceOne(coll, filter, doc, options, callback) { + // Set single document update + options.multi = false; + + // Execute update + updateDocuments(coll, filter, doc, options, (err, r) => { + if (callback == null) return; + if (err && callback) return callback(err); + if (r == null) return callback(null, { result: { ok: 1 } }); + + r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; + r.upsertedId = + Array.isArray(r.result.upserted) && r.result.upserted.length > 0 + ? r.result.upserted[0] // FIXME(major): should be `r.result.upserted[0]._id` + : null; + r.upsertedCount = + Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; + r.matchedCount = + Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; + r.ops = [doc]; + if (callback) callback(null, r); + }); +} + +/** + * Save a document. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} doc Document to save + * @param {object} [options] Optional settings. See Collection.prototype.save for a list of options. + * @param {Collection~writeOpCallback} [callback] The command result callback + * @deprecated use insertOne, insertMany, updateOne or updateMany + */ +function save(coll, doc, options, callback) { + // Get the write concern options + const finalOptions = applyWriteConcern( + Object.assign({}, options), + { db: coll.s.db, collection: coll }, + options + ); + // Establish if we need to perform an insert or update + if (doc._id != null) { + finalOptions.upsert = true; + return updateDocuments(coll, { _id: doc._id }, doc, finalOptions, callback); + } + + // Insert the document + insertDocuments(coll, [doc], finalOptions, (err, result) => { + if (callback == null) return; + if (doc == null) return handleCallback(callback, null, null); + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result); + }); +} + +/** + * Get all the collection statistics. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} [options] Optional settings. See Collection.prototype.stats for a list of options. + * @param {Collection~resultCallback} [callback] The collection result callback + */ +function stats(coll, options, callback) { + // Build command object + const commandObject = { + collStats: coll.s.name + }; + + // Check if we have the scale value + if (options['scale'] != null) commandObject['scale'] = options['scale']; + + options = Object.assign({}, options); + // Ensure we have the right read preference inheritance + options.readPreference = resolveReadPreference(options, { db: coll.s.db, collection: coll }); + + // Execute the command + executeCommand(coll.s.db, commandObject, options, callback); +} + +function updateCallback(err, r, callback) { + if (callback == null) return; + if (err) return callback(err); + if (r == null) return callback(null, { result: { ok: 1 } }); + r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; + r.upsertedId = + Array.isArray(r.result.upserted) && r.result.upserted.length > 0 + ? r.result.upserted[0] // FIXME(major): should be `r.result.upserted[0]._id` + : null; + r.upsertedCount = + Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; + r.matchedCount = + Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; + callback(null, r); +} + +function updateDocuments(coll, selector, document, options, callback) { + if ('function' === typeof options) (callback = options), (options = null); + if (options == null) options = {}; + if (!('function' === typeof callback)) callback = null; + + // If we are not providing a selector or document throw + if (selector == null || typeof selector !== 'object') + return callback(toError('selector must be a valid JavaScript object')); + if (document == null || typeof document !== 'object') + return callback(toError('document must be a valid JavaScript object')); + + // Get the write concern options + const finalOptions = applyWriteConcern( + Object.assign({}, options), + { db: coll.s.db, collection: coll }, + options + ); + + // Do we return the actual result document + // Either use override on the function, or go back to default on either the collection + // level or db + finalOptions.serializeFunctions = options.serializeFunctions || coll.s.serializeFunctions; + + // Execute the operation + const op = { q: selector, u: document }; + op.upsert = options.upsert !== void 0 ? !!options.upsert : false; + op.multi = options.multi !== void 0 ? !!options.multi : false; + + if (finalOptions.arrayFilters) { + op.arrayFilters = finalOptions.arrayFilters; + delete finalOptions.arrayFilters; + } + + if (finalOptions.retryWrites && op.multi) { + finalOptions.retryWrites = false; + } + + // Have we specified collation + decorateWithCollation(finalOptions, coll, options); + + // Update options + coll.s.topology.update(coll.s.namespace, [op], finalOptions, (err, result) => { + if (callback == null) return; + if (err) return handleCallback(callback, err, null); + if (result == null) return handleCallback(callback, null, null); + if (result.result.code) return handleCallback(callback, toError(result.result)); + if (result.result.writeErrors) + return handleCallback(callback, toError(result.result.writeErrors[0])); + // Return the results + handleCallback(callback, null, result); + }); +} + +/** + * Update multiple documents in the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter The Filter used to select the documents to update + * @param {object} update The update operations to be applied to the document + * @param {object} [options] Optional settings. See Collection.prototype.updateMany for a list of options. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + */ +function updateMany(coll, filter, update, options, callback) { + // Set single document update + options.multi = true; + // Execute update + updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback)); +} + +/** + * Update a single document in the collection. + * + * @method + * @param {Collection} a Collection instance. + * @param {object} filter The Filter used to select the document to update + * @param {object} update The update operations to be applied to the document + * @param {object} [options] Optional settings. See Collection.prototype.updateOne for a list of options. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + */ +function updateOne(coll, filter, update, options, callback) { + // Set single document update + options.multi = false; + // Execute update + updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback)); +} + +module.exports = { + bulkWrite, + checkForAtomicOperators, + count, + countDocuments, + buildCountCommand, + createIndex, + createIndexes, + deleteMany, + deleteOne, + distinct, + dropIndex, + dropIndexes, + ensureIndex, + findAndModify, + findAndRemove, + findOne, + findOneAndDelete, + findOneAndReplace, + findOneAndUpdate, + geoHaystackSearch, + group, + indexes, + indexExists, + indexInformation, + insertOne, + isCapped, + mapReduce, + optionsOp, + parallelCollectionScan, + prepareDocs, + reIndex, + removeDocuments, + rename, + replaceOne, + save, + stats, + updateDocuments, + updateMany, + updateOne +}; diff --git a/node_modules/mongodb/lib/operations/cursor_ops.js b/node_modules/mongodb/lib/operations/cursor_ops.js new file mode 100644 index 0000000..93ebc26 --- /dev/null +++ b/node_modules/mongodb/lib/operations/cursor_ops.js @@ -0,0 +1,237 @@ +'use strict'; + +const buildCountCommand = require('./collection_ops').buildCountCommand; +const formattedOrderClause = require('../utils').formattedOrderClause; +const handleCallback = require('../utils').handleCallback; +const MongoError = require('mongodb-core').MongoError; +const push = Array.prototype.push; + +/** + * Get the count of documents for this cursor. + * + * @method + * @param {Cursor} cursor The Cursor instance on which to count. + * @param {boolean} [applySkipLimit=true] Specifies whether the count command apply limit and skip settings should be applied on the cursor or in the provided options. + * @param {object} [options] Optional settings. See Cursor.prototype.count for a list of options. + * @param {Cursor~countResultCallback} [callback] The result callback. + */ +function count(cursor, applySkipLimit, opts, callback) { + if (applySkipLimit) { + if (typeof cursor.cursorSkip() === 'number') opts.skip = cursor.cursorSkip(); + if (typeof cursor.cursorLimit() === 'number') opts.limit = cursor.cursorLimit(); + } + + // Ensure we have the right read preference inheritance + if (opts.readPreference) { + cursor.setReadPreference(opts.readPreference); + } + + if ( + typeof opts.maxTimeMS !== 'number' && + cursor.s.cmd && + typeof cursor.s.cmd.maxTimeMS === 'number' + ) { + opts.maxTimeMS = cursor.s.cmd.maxTimeMS; + } + + let options = {}; + options.skip = opts.skip; + options.limit = opts.limit; + options.hint = opts.hint; + options.maxTimeMS = opts.maxTimeMS; + + // Command + const delimiter = cursor.s.ns.indexOf('.'); + options.collectionName = cursor.s.ns.substr(delimiter + 1); + + const command = buildCountCommand(cursor, cursor.s.cmd.query, options); + + // Set cursor server to the same as the topology + cursor.server = cursor.topology.s.coreTopology; + + // Execute the command + cursor.s.topology.command( + `${cursor.s.ns.substr(0, delimiter)}.$cmd`, + command, + cursor.s.options, + (err, result) => { + callback(err, result ? result.result.n : null); + } + ); +} + +/** + * Iterates over all the documents for this cursor. See Cursor.prototype.each for more information. + * + * @method + * @deprecated + * @param {Cursor} cursor The Cursor instance on which to run. + * @param {Cursor~resultCallback} callback The result callback. + */ +function each(cursor, callback) { + const Cursor = require('../cursor'); + + if (!callback) throw MongoError.create({ message: 'callback is mandatory', driver: true }); + if (cursor.isNotified()) return; + if (cursor.s.state === Cursor.CLOSED || cursor.isDead()) { + return handleCallback( + callback, + MongoError.create({ message: 'Cursor is closed', driver: true }) + ); + } + + if (cursor.s.state === Cursor.INIT) cursor.s.state = Cursor.OPEN; + + // Define function to avoid global scope escape + let fn = null; + // Trampoline all the entries + if (cursor.bufferedCount() > 0) { + while ((fn = loop(cursor, callback))) fn(cursor, callback); + each(cursor, callback); + } else { + cursor.next((err, item) => { + if (err) return handleCallback(callback, err); + if (item == null) { + return cursor.close({ skipKillCursors: true }, () => handleCallback(callback, null, null)); + } + + if (handleCallback(callback, null, item) === false) return; + each(cursor, callback); + }); + } +} + +/** + * Check if there is any document still available in the cursor. + * + * @method + * @param {Cursor} cursor The Cursor instance on which to run. + * @param {Cursor~resultCallback} [callback] The result callback. + */ +function hasNext(cursor, callback) { + const Cursor = require('../cursor'); + + if (cursor.s.currentDoc) { + return callback(null, true); + } + + if (cursor.isNotified()) { + return callback(null, false); + } + + nextObject(cursor, (err, doc) => { + if (err) return callback(err, null); + if (cursor.s.state === Cursor.CLOSED || cursor.isDead()) return callback(null, false); + if (!doc) return callback(null, false); + cursor.s.currentDoc = doc; + callback(null, true); + }); +} + +// Trampoline emptying the number of retrieved items +// without incurring a nextTick operation +function loop(cursor, callback) { + // No more items we are done + if (cursor.bufferedCount() === 0) return; + // Get the next document + cursor._next(callback); + // Loop + return loop; +} + +/** + * Get the next available document from the cursor. Returns null if no more documents are available. + * + * @method + * @param {Cursor} cursor The Cursor instance from which to get the next document. + * @param {Cursor~resultCallback} [callback] The result callback. + */ +function next(cursor, callback) { + // Return the currentDoc if someone called hasNext first + if (cursor.s.currentDoc) { + const doc = cursor.s.currentDoc; + cursor.s.currentDoc = null; + return callback(null, doc); + } + + // Return the next object + nextObject(cursor, callback); +} + +// Get the next available document from the cursor, returns null if no more documents are available. +function nextObject(cursor, callback) { + const Cursor = require('../cursor'); + + if (cursor.s.state === Cursor.CLOSED || (cursor.isDead && cursor.isDead())) + return handleCallback( + callback, + MongoError.create({ message: 'Cursor is closed', driver: true }) + ); + if (cursor.s.state === Cursor.INIT && cursor.s.cmd.sort) { + try { + cursor.s.cmd.sort = formattedOrderClause(cursor.s.cmd.sort); + } catch (err) { + return handleCallback(callback, err); + } + } + + // Get the next object + cursor._next((err, doc) => { + cursor.s.state = Cursor.OPEN; + if (err) return handleCallback(callback, err); + handleCallback(callback, null, doc); + }); +} + +/** + * Returns an array of documents. See Cursor.prototype.toArray for more information. + * + * @method + * @param {Cursor} cursor The Cursor instance from which to get the next document. + * @param {Cursor~toArrayResultCallback} [callback] The result callback. + */ +function toArray(cursor, callback) { + const Cursor = require('../cursor'); + + const items = []; + + // Reset cursor + cursor.rewind(); + cursor.s.state = Cursor.INIT; + + // Fetch all the documents + const fetchDocs = () => { + cursor._next((err, doc) => { + if (err) { + return cursor._endSession + ? cursor._endSession(() => handleCallback(callback, err)) + : handleCallback(callback, err); + } + if (doc == null) { + return cursor.close({ skipKillCursors: true }, () => handleCallback(callback, null, items)); + } + + // Add doc to items + items.push(doc); + + // Get all buffered objects + if (cursor.bufferedCount() > 0) { + let docs = cursor.readBufferedDocuments(cursor.bufferedCount()); + + // Transform the doc if transform method added + if (cursor.s.transforms && typeof cursor.s.transforms.doc === 'function') { + docs = docs.map(cursor.s.transforms.doc); + } + + push.apply(items, docs); + } + + // Attempt a fetch + fetchDocs(); + }); + }; + + fetchDocs(); +} + +module.exports = { count, each, hasNext, next, toArray }; diff --git a/node_modules/mongodb/lib/operations/db_ops.js b/node_modules/mongodb/lib/operations/db_ops.js new file mode 100644 index 0000000..af0210a --- /dev/null +++ b/node_modules/mongodb/lib/operations/db_ops.js @@ -0,0 +1,982 @@ +'use strict'; + +const applyWriteConcern = require('../utils').applyWriteConcern; +const Code = require('mongodb-core').BSON.Code; +const resolveReadPreference = require('../utils').resolveReadPreference; +const crypto = require('crypto'); +const Db = require('../db'); +const debugOptions = require('../utils').debugOptions; +const handleCallback = require('../utils').handleCallback; +const MongoError = require('mongodb-core').MongoError; +const parseIndexOptions = require('../utils').parseIndexOptions; +const ReadPreference = require('mongodb-core').ReadPreference; +const toError = require('../utils').toError; + +const count = require('./collection_ops').count; +const findOne = require('./collection_ops').findOne; +const remove = require('./collection_ops').remove; +const updateOne = require('./collection_ops').updateOne; + +const debugFields = [ + 'authSource', + 'w', + 'wtimeout', + 'j', + 'native_parser', + 'forceServerObjectId', + 'serializeFunctions', + 'raw', + 'promoteLongs', + 'promoteValues', + 'promoteBuffers', + 'bufferMaxEntries', + 'numberOfRetries', + 'retryMiliSeconds', + 'readPreference', + 'pkFactory', + 'parentDb', + 'promiseLibrary', + 'noListener' +]; + +// Filter out any write concern options +const illegalCommandFields = [ + 'w', + 'wtimeout', + 'j', + 'fsync', + 'autoIndexId', + 'strict', + 'serializeFunctions', + 'pkFactory', + 'raw', + 'readPreference', + 'session' +]; + +/** + * Add a user to the database. + * @method + * @param {Db} db The Db instance on which to add a user. + * @param {string} username The username. + * @param {string} password The password. + * @param {object} [options] Optional settings. See Db.prototype.addUser for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function addUser(db, username, password, options, callback) { + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + // Attempt to execute auth command + executeAuthCreateUserCommand(db, username, password, options, (err, r) => { + // We need to perform the backward compatible insert operation + if (err && err.code === -5000) { + const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options); + + // Use node md5 generator + const md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ':mongo:' + password); + const userPassword = md5.digest('hex'); + + // If we have another db set + const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db; + + // Fetch a user collection + const collection = db.collection(Db.SYSTEM_USER_COLLECTION); + + // Check if we are inserting the first user + count(collection, {}, finalOptions, (err, count) => { + // We got an error (f.ex not authorized) + if (err != null) return handleCallback(callback, err, null); + // Check if the user exists and update i + const findOptions = Object.assign({ projection: { dbName: 1 } }, finalOptions); + collection.find({ user: username }, findOptions).toArray(err => { + // We got an error (f.ex not authorized) + if (err != null) return handleCallback(callback, err, null); + // Add command keys + finalOptions.upsert = true; + + // We have a user, let's update the password or upsert if not + updateOne( + collection, + { user: username }, + { $set: { user: username, pwd: userPassword } }, + finalOptions, + err => { + if (count === 0 && err) + return handleCallback(callback, null, [{ user: username, pwd: userPassword }]); + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, [{ user: username, pwd: userPassword }]); + } + ); + }); + }); + + return; + } + + if (err) return handleCallback(callback, err); + handleCallback(callback, err, r); + }); +} + +/** + * Fetch all collections for the current db. + * + * @method + * @param {Db} db The Db instance on which to fetch collections. + * @param {object} [options] Optional settings. See Db.prototype.collections for a list of options. + * @param {Db~collectionsResultCallback} [callback] The results callback + */ +function collections(db, options, callback) { + const Collection = require('../collection'); + + options = Object.assign({}, options, { nameOnly: true }); + // Let's get the collection names + db.listCollections({}, options).toArray((err, documents) => { + if (err != null) return handleCallback(callback, err, null); + // Filter collections removing any illegal ones + documents = documents.filter(doc => { + return doc.name.indexOf('$') === -1; + }); + + // Return the collection objects + handleCallback( + callback, + null, + documents.map(d => { + return new Collection( + db, + db.s.topology, + db.s.databaseName, + d.name, + db.s.pkFactory, + db.s.options + ); + }) + ); + }); +} + +/** + * Create a new collection on a server with the specified options. Use this to create capped collections. + * More information about command options available at https://docs.mongodb.com/manual/reference/command/create/ + * + * @method + * @param {Db} db The Db instance on which to create the collection. + * @param {string} name The collection name to create. + * @param {object} [options] Optional settings. See Db.prototype.createCollection for a list of options. + * @param {Db~collectionResultCallback} [callback] The results callback + */ +function createCollection(db, name, options, callback) { + const Collection = require('../collection'); + + // Get the write concern options + const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options); + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) { + return callback(new MongoError('topology was destroyed')); + } + + const listCollectionOptions = Object.assign({}, finalOptions, { nameOnly: true }); + + // Check if we have the name + db + .listCollections({ name }, listCollectionOptions) + .setReadPreference(ReadPreference.PRIMARY) + .toArray((err, collections) => { + if (err != null) return handleCallback(callback, err, null); + if (collections.length > 0 && finalOptions.strict) { + return handleCallback( + callback, + MongoError.create({ + message: `Collection ${name} already exists. Currently in strict mode.`, + driver: true + }), + null + ); + } else if (collections.length > 0) { + try { + return handleCallback( + callback, + null, + new Collection(db, db.s.topology, db.s.databaseName, name, db.s.pkFactory, options) + ); + } catch (err) { + return handleCallback(callback, err); + } + } + + // Create collection command + const cmd = { create: name }; + + // Decorate command with writeConcern if supported + applyWriteConcern(cmd, { db }, options); + + // Add all optional parameters + for (let n in options) { + if ( + options[n] != null && + typeof options[n] !== 'function' && + illegalCommandFields.indexOf(n) === -1 + ) { + cmd[n] = options[n]; + } + } + + // Force a primary read Preference + finalOptions.readPreference = ReadPreference.PRIMARY; + // Execute command + executeCommand(db, cmd, finalOptions, err => { + if (err) return handleCallback(callback, err); + handleCallback( + callback, + null, + new Collection(db, db.s.topology, db.s.databaseName, name, db.s.pkFactory, options) + ); + }); + }); +} + +/** + * Creates an index on the db and collection. + * @method + * @param {Db} db The Db instance on which to create an index. + * @param {string} name Name of the collection to create the index on. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options] Optional settings. See Db.prototype.createIndex for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function createIndex(db, name, fieldOrSpec, options, callback) { + // Get the write concern options + let finalOptions = Object.assign({}, { readPreference: ReadPreference.PRIMARY }, options); + finalOptions = applyWriteConcern(finalOptions, { db }, options); + + // Ensure we have a callback + if (finalOptions.writeConcern && typeof callback !== 'function') { + throw MongoError.create({ + message: 'Cannot use a writeConcern without a provided callback', + driver: true + }); + } + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + + // Attempt to run using createIndexes command + createIndexUsingCreateIndexes(db, name, fieldOrSpec, finalOptions, (err, result) => { + if (err == null) return handleCallback(callback, err, result); + + /** + * The following errors mean that the server recognized `createIndex` as a command so we don't need to fallback to an insert: + * 67 = 'CannotCreateIndex' (malformed index options) + * 85 = 'IndexOptionsConflict' (index already exists with different options) + * 86 = 'IndexKeySpecsConflict' (index already exists with the same name) + * 11000 = 'DuplicateKey' (couldn't build unique index because of dupes) + * 11600 = 'InterruptedAtShutdown' (interrupted at shutdown) + * 197 = 'InvalidIndexSpecificationOption' (`_id` with `background: true`) + */ + if ( + err.code === 67 || + err.code === 11000 || + err.code === 85 || + err.code === 86 || + err.code === 11600 || + err.code === 197 + ) { + return handleCallback(callback, err, result); + } + + // Create command + const doc = createCreateIndexCommand(db, name, fieldOrSpec, options); + // Set no key checking + finalOptions.checkKeys = false; + // Insert document + db.s.topology.insert( + `${db.s.databaseName}.${Db.SYSTEM_INDEX_COLLECTION}`, + doc, + finalOptions, + (err, result) => { + if (callback == null) return; + if (err) return handleCallback(callback, err); + if (result == null) return handleCallback(callback, null, null); + if (result.result.writeErrors) + return handleCallback(callback, MongoError.create(result.result.writeErrors[0]), null); + handleCallback(callback, null, doc.name); + } + ); + }); +} + +// Add listeners to topology +function createListener(db, e, object) { + function listener(err) { + if (object.listeners(e).length > 0) { + object.emit(e, err, db); + + // Emit on all associated db's if available + for (let i = 0; i < db.s.children.length; i++) { + db.s.children[i].emit(e, err, db.s.children[i]); + } + } + } + return listener; +} + +/** + * Drop a collection from the database, removing it permanently. New accesses will create a new collection. + * + * @method + * @param {Db} db The Db instance on which to drop the collection. + * @param {string} name Name of collection to drop + * @param {Object} [options] Optional settings. See Db.prototype.dropCollection for a list of options. + * @param {Db~resultCallback} [callback] The results callback + */ +function dropCollection(db, name, options, callback) { + executeCommand(db, name, options, (err, result) => { + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) { + return callback(new MongoError('topology was destroyed')); + } + + if (err) return handleCallback(callback, err); + if (result.ok) return handleCallback(callback, null, true); + handleCallback(callback, null, false); + }); +} + +/** + * Drop a database, removing it permanently from the server. + * + * @method + * @param {Db} db The Db instance to drop. + * @param {Object} cmd The command document. + * @param {Object} [options] Optional settings. See Db.prototype.dropDatabase for a list of options. + * @param {Db~resultCallback} [callback] The results callback + */ +function dropDatabase(db, cmd, options, callback) { + executeCommand(db, cmd, options, (err, result) => { + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) { + return callback(new MongoError('topology was destroyed')); + } + + if (callback == null) return; + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }); +} + +/** + * Ensures that an index exists. If it does not, creates it. + * + * @method + * @param {Db} db The Db instance on which to ensure the index. + * @param {string} name The index name + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options] Optional settings. See Db.prototype.ensureIndex for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function ensureIndex(db, name, fieldOrSpec, options, callback) { + // Get the write concern options + const finalOptions = applyWriteConcern({}, { db }, options); + // Create command + const selector = createCreateIndexCommand(db, name, fieldOrSpec, options); + const index_name = selector.name; + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + + // Merge primary readPreference + finalOptions.readPreference = ReadPreference.PRIMARY; + + // Check if the index already exists + indexInformation(db, name, finalOptions, (err, indexInformation) => { + if (err != null && err.code !== 26) return handleCallback(callback, err, null); + // If the index does not exist, create it + if (indexInformation == null || !indexInformation[index_name]) { + createIndex(db, name, fieldOrSpec, options, callback); + } else { + if (typeof callback === 'function') return handleCallback(callback, null, index_name); + } + }); +} + +/** + * Evaluate JavaScript on the server + * + * @method + * @param {Db} db The Db instance. + * @param {Code} code JavaScript to execute on server. + * @param {(object|array)} parameters The parameters for the call. + * @param {object} [options] Optional settings. See Db.prototype.eval for a list of options. + * @param {Db~resultCallback} [callback] The results callback + * @deprecated Eval is deprecated on MongoDB 3.2 and forward + */ +function evaluate(db, code, parameters, options, callback) { + let finalCode = code; + let finalParameters = []; + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + + // If not a code object translate to one + if (!(finalCode && finalCode._bsontype === 'Code')) finalCode = new Code(finalCode); + // Ensure the parameters are correct + if (parameters != null && !Array.isArray(parameters) && typeof parameters !== 'function') { + finalParameters = [parameters]; + } else if (parameters != null && Array.isArray(parameters) && typeof parameters !== 'function') { + finalParameters = parameters; + } + + // Create execution selector + let cmd = { $eval: finalCode, args: finalParameters }; + // Check if the nolock parameter is passed in + if (options['nolock']) { + cmd['nolock'] = options['nolock']; + } + + // Set primary read preference + options.readPreference = new ReadPreference(ReadPreference.PRIMARY); + + // Execute the command + executeCommand(db, cmd, options, (err, result) => { + if (err) return handleCallback(callback, err, null); + if (result && result.ok === 1) return handleCallback(callback, null, result.retval); + if (result) + return handleCallback( + callback, + MongoError.create({ message: `eval failed: ${result.errmsg}`, driver: true }), + null + ); + handleCallback(callback, err, result); + }); +} + +/** + * Execute a command + * + * @method + * @param {Db} db The Db instance on which to execute the command. + * @param {object} command The command hash + * @param {object} [options] Optional settings. See Db.prototype.command for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function executeCommand(db, command, options, callback) { + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + // Get the db name we are executing against + const dbName = options.dbName || options.authdb || db.s.databaseName; + + // Convert the readPreference if its not a write + options.readPreference = resolveReadPreference(options, { db, default: ReadPreference.primary }); + + // Debug information + if (db.s.logger.isDebug()) + db.s.logger.debug( + `executing command ${JSON.stringify( + command + )} against ${dbName}.$cmd with options [${JSON.stringify( + debugOptions(debugFields, options) + )}]` + ); + + // Execute command + db.s.topology.command(`${dbName}.$cmd`, command, options, (err, result) => { + if (err) return handleCallback(callback, err); + if (options.full) return handleCallback(callback, null, result); + handleCallback(callback, null, result.result); + }); +} + +/** + * Runs a command on the database as admin. + * + * @method + * @param {Db} db The Db instance on which to execute the command. + * @param {object} command The command hash + * @param {object} [options] Optional settings. See Db.prototype.executeDbAdminCommand for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function executeDbAdminCommand(db, command, options, callback) { + db.s.topology.command('admin.$cmd', command, options, (err, result) => { + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) { + return callback(new MongoError('topology was destroyed')); + } + + if (err) return handleCallback(callback, err); + handleCallback(callback, null, result.result); + }); +} + +/** + * Retrieves this collections index info. + * + * @method + * @param {Db} db The Db instance on which to retrieve the index info. + * @param {string} name The name of the collection. + * @param {object} [options] Optional settings. See Db.prototype.indexInformation for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function indexInformation(db, name, options, callback) { + // If we specified full information + const full = options['full'] == null ? false : options['full']; + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + // Process all the results from the index command and collection + function processResults(indexes) { + // Contains all the information + let info = {}; + // Process all the indexes + for (let i = 0; i < indexes.length; i++) { + const index = indexes[i]; + // Let's unpack the object + info[index.name] = []; + for (let name in index.key) { + info[index.name].push([name, index.key[name]]); + } + } + + return info; + } + + // Get the list of indexes of the specified collection + db + .collection(name) + .listIndexes(options) + .toArray((err, indexes) => { + if (err) return callback(toError(err)); + if (!Array.isArray(indexes)) return handleCallback(callback, null, []); + if (full) return handleCallback(callback, null, indexes); + handleCallback(callback, null, processResults(indexes)); + }); +} + +// Transformation methods for cursor results +function listCollectionsTransforms(databaseName) { + const matching = `${databaseName}.`; + + return { + doc: doc => { + const index = doc.name.indexOf(matching); + // Remove database name if available + if (doc.name && index === 0) { + doc.name = doc.name.substr(index + matching.length); + } + + return doc; + } + }; +} + +/** + * Retrive the current profiling information for MongoDB + * + * @method + * @param {Db} db The Db instance on which to retrieve the profiling info. + * @param {Object} [options] Optional settings. See Db.protoype.profilingInfo for a list of options. + * @param {Db~resultCallback} [callback] The command result callback. + * @deprecated Query the system.profile collection directly. + */ +function profilingInfo(db, options, callback) { + try { + db + .collection('system.profile') + .find({}, options) + .toArray(callback); + } catch (err) { + return callback(err, null); + } +} + +/** + * Retrieve the current profiling level for MongoDB + * + * @method + * @param {Db} db The Db instance on which to retrieve the profiling level. + * @param {Object} [options] Optional settings. See Db.prototype.profilingLevel for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function profilingLevel(db, options, callback) { + executeCommand(db, { profile: -1 }, options, (err, doc) => { + if (err == null && doc.ok === 1) { + const was = doc.was; + if (was === 0) return callback(null, 'off'); + if (was === 1) return callback(null, 'slow_only'); + if (was === 2) return callback(null, 'all'); + return callback(new Error('Error: illegal profiling level value ' + was), null); + } else { + err != null ? callback(err, null) : callback(new Error('Error with profile command'), null); + } + }); +} + +/** + * Remove a user from a database + * + * @method + * @param {Db} db The Db instance on which to remove the user. + * @param {string} username The username. + * @param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function removeUser(db, username, options, callback) { + // Attempt to execute command + executeAuthRemoveUserCommand(db, username, options, (err, result) => { + if (err && err.code === -5000) { + const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options); + // If we have another db set + const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db; + + // Fetch a user collection + const collection = db.collection(Db.SYSTEM_USER_COLLECTION); + + // Locate the user + findOne(collection, { user: username }, finalOptions, (err, user) => { + if (user == null) return handleCallback(callback, err, false); + remove(collection, { user: username }, finalOptions, err => { + handleCallback(callback, err, true); + }); + }); + + return; + } + + if (err) return handleCallback(callback, err); + handleCallback(callback, err, result); + }); +} + +/** + * Set the current profiling level of MongoDB + * + * @method + * @param {Db} db The Db instance on which to execute the command. + * @param {string} level The new profiling level (off, slow_only, all). + * @param {Object} [options] Optional settings. See Db.prototype.setProfilingLevel for a list of options. + * @param {Db~resultCallback} [callback] The command result callback. + */ +function setProfilingLevel(db, level, options, callback) { + const command = {}; + let profile = 0; + + if (level === 'off') { + profile = 0; + } else if (level === 'slow_only') { + profile = 1; + } else if (level === 'all') { + profile = 2; + } else { + return callback(new Error('Error: illegal profiling level value ' + level)); + } + + // Set up the profile number + command['profile'] = profile; + + executeCommand(db, command, options, (err, doc) => { + if (err == null && doc.ok === 1) return callback(null, level); + return err != null + ? callback(err, null) + : callback(new Error('Error with profile command'), null); + }); +} + +// Validate the database name +function validateDatabaseName(databaseName) { + if (typeof databaseName !== 'string') + throw MongoError.create({ message: 'database name must be a string', driver: true }); + if (databaseName.length === 0) + throw MongoError.create({ message: 'database name cannot be the empty string', driver: true }); + if (databaseName === '$external') return; + + const invalidChars = [' ', '.', '$', '/', '\\']; + for (let i = 0; i < invalidChars.length; i++) { + if (databaseName.indexOf(invalidChars[i]) !== -1) + throw MongoError.create({ + message: "database names cannot contain the character '" + invalidChars[i] + "'", + driver: true + }); + } +} + +/** + * Create the command object for Db.prototype.createIndex. + * + * @param {Db} db The Db instance on which to create the command. + * @param {string} name Name of the collection to create the index on. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {Object} [options] Optional settings. See Db.prototype.createIndex for a list of options. + * @return {Object} The insert command object. + */ +function createCreateIndexCommand(db, name, fieldOrSpec, options) { + const indexParameters = parseIndexOptions(fieldOrSpec); + const fieldHash = indexParameters.fieldHash; + + // Generate the index name + const indexName = typeof options.name === 'string' ? options.name : indexParameters.name; + const selector = { + ns: db.databaseName + '.' + name, + key: fieldHash, + name: indexName + }; + + // Ensure we have a correct finalUnique + const finalUnique = options == null || 'object' === typeof options ? false : options; + // Set up options + options = options == null || typeof options === 'boolean' ? {} : options; + + // Add all the options + const keysToOmit = Object.keys(selector); + for (let optionName in options) { + if (keysToOmit.indexOf(optionName) === -1) { + selector[optionName] = options[optionName]; + } + } + + if (selector['unique'] == null) selector['unique'] = finalUnique; + + // Remove any write concern operations + const removeKeys = ['w', 'wtimeout', 'j', 'fsync', 'readPreference', 'session']; + for (let i = 0; i < removeKeys.length; i++) { + delete selector[removeKeys[i]]; + } + + // Return the command creation selector + return selector; +} + +/** + * Create index using the createIndexes command. + * + * @param {Db} db The Db instance on which to execute the command. + * @param {string} name Name of the collection to create the index on. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {Object} [options] Optional settings. See Db.prototype.createIndex for a list of options. + * @param {Db~resultCallback} [callback] The command result callback. + */ +function createIndexUsingCreateIndexes(db, name, fieldOrSpec, options, callback) { + // Build the index + const indexParameters = parseIndexOptions(fieldOrSpec); + // Generate the index name + const indexName = typeof options.name === 'string' ? options.name : indexParameters.name; + // Set up the index + const indexes = [{ name: indexName, key: indexParameters.fieldHash }]; + // merge all the options + const keysToOmit = Object.keys(indexes[0]).concat([ + 'writeConcern', + 'w', + 'wtimeout', + 'j', + 'fsync', + 'readPreference', + 'session' + ]); + + for (let optionName in options) { + if (keysToOmit.indexOf(optionName) === -1) { + indexes[0][optionName] = options[optionName]; + } + } + + // Get capabilities + const capabilities = db.s.topology.capabilities(); + + // Did the user pass in a collation, check if our write server supports it + if (indexes[0].collation && capabilities && !capabilities.commandsTakeCollation) { + // Create a new error + const error = new MongoError('server/primary/mongos does not support collation'); + error.code = 67; + // Return the error + return callback(error); + } + + // Create command, apply write concern to command + const cmd = applyWriteConcern({ createIndexes: name, indexes }, { db }, options); + + // ReadPreference primary + options.readPreference = ReadPreference.PRIMARY; + + // Build the command + executeCommand(db, cmd, options, (err, result) => { + if (err) return handleCallback(callback, err, null); + if (result.ok === 0) return handleCallback(callback, toError(result), null); + // Return the indexName for backward compatibility + handleCallback(callback, null, indexName); + }); +} + +/** + * Run the createUser command. + * + * @param {Db} db The Db instance on which to execute the command. + * @param {string} username The username of the user to add. + * @param {string} password The password of the user to add. + * @param {object} [options] Optional settings. See Db.prototype.addUser for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function executeAuthCreateUserCommand(db, username, password, options, callback) { + // Special case where there is no password ($external users) + if (typeof username === 'string' && password != null && typeof password === 'object') { + options = password; + password = null; + } + + // Unpack all options + if (typeof options === 'function') { + callback = options; + options = {}; + } + + // Error out if we digestPassword set + if (options.digestPassword != null) { + return callback( + toError( + "The digestPassword option is not supported via add_user. Please use db.command('createUser', ...) instead for this option." + ) + ); + } + + // Get additional values + const customData = options.customData != null ? options.customData : {}; + let roles = Array.isArray(options.roles) ? options.roles : []; + const maxTimeMS = typeof options.maxTimeMS === 'number' ? options.maxTimeMS : null; + + // If not roles defined print deprecated message + if (roles.length === 0) { + console.log('Creating a user without roles is deprecated in MongoDB >= 2.6'); + } + + // Get the error options + const commandOptions = { writeCommand: true }; + if (options['dbName']) commandOptions.dbName = options['dbName']; + + // Add maxTimeMS to options if set + if (maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; + + // Check the db name and add roles if needed + if ( + (db.databaseName.toLowerCase() === 'admin' || options.dbName === 'admin') && + !Array.isArray(options.roles) + ) { + roles = ['root']; + } else if (!Array.isArray(options.roles)) { + roles = ['dbOwner']; + } + + const digestPassword = db.s.topology.lastIsMaster().maxWireVersion >= 7; + + // Build the command to execute + let command = { + createUser: username, + customData: customData, + roles: roles, + digestPassword + }; + + // Apply write concern to command + command = applyWriteConcern(command, { db }, options); + + let userPassword = password; + + if (!digestPassword) { + // Use node md5 generator + const md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ':mongo:' + password); + userPassword = md5.digest('hex'); + } + + // No password + if (typeof password === 'string') { + command.pwd = userPassword; + } + + // Force write using primary + commandOptions.readPreference = ReadPreference.primary; + + // Execute the command + executeCommand(db, command, commandOptions, (err, result) => { + if (err && err.ok === 0 && err.code === undefined) + return handleCallback(callback, { code: -5000 }, null); + if (err) return handleCallback(callback, err, null); + handleCallback( + callback, + !result.ok ? toError(result) : null, + result.ok ? [{ user: username, pwd: '' }] : null + ); + }); +} + +/** + * Run the dropUser command. + * + * @param {Db} db The Db instance on which to execute the command. + * @param {string} username The username of the user to remove. + * @param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function executeAuthRemoveUserCommand(db, username, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + // Did the user destroy the topology + if (db.serverConfig && db.serverConfig.isDestroyed()) + return callback(new MongoError('topology was destroyed')); + // Get the error options + const commandOptions = { writeCommand: true }; + if (options['dbName']) commandOptions.dbName = options['dbName']; + + // Get additional values + const maxTimeMS = typeof options.maxTimeMS === 'number' ? options.maxTimeMS : null; + + // Add maxTimeMS to options if set + if (maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; + + // Build the command to execute + let command = { + dropUser: username + }; + + // Apply write concern to command + command = applyWriteConcern(command, { db }, options); + + // Force write using primary + commandOptions.readPreference = ReadPreference.primary; + + // Execute the command + executeCommand(db, command, commandOptions, (err, result) => { + if (err && !err.ok && err.code === undefined) return handleCallback(callback, { code: -5000 }); + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }); +} + +module.exports = { + addUser, + collections, + createCollection, + createListener, + createIndex, + dropCollection, + dropDatabase, + ensureIndex, + evaluate, + executeCommand, + executeDbAdminCommand, + listCollectionsTransforms, + indexInformation, + profilingInfo, + profilingLevel, + removeUser, + setProfilingLevel, + validateDatabaseName +}; diff --git a/node_modules/mongodb/lib/operations/mongo_client_ops.js b/node_modules/mongodb/lib/operations/mongo_client_ops.js new file mode 100644 index 0000000..e99d547 --- /dev/null +++ b/node_modules/mongodb/lib/operations/mongo_client_ops.js @@ -0,0 +1,636 @@ +'use strict'; + +const authenticate = require('../authenticate'); +const deprecate = require('util').deprecate; +const Logger = require('mongodb-core').Logger; +const MongoError = require('mongodb-core').MongoError; +const Mongos = require('../topologies/mongos'); +const parse = require('mongodb-core').parseConnectionString; +const ReadPreference = require('mongodb-core').ReadPreference; +const ReplSet = require('../topologies/replset'); +const Server = require('../topologies/server'); +const ServerSessionPool = require('mongodb-core').Sessions.ServerSessionPool; + +const monitoringEvents = [ + 'timeout', + 'close', + 'serverOpening', + 'serverDescriptionChanged', + 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', + 'serverHeartbeatFailed', + 'serverClosed', + 'topologyOpening', + 'topologyClosed', + 'topologyDescriptionChanged', + 'commandStarted', + 'commandSucceeded', + 'commandFailed', + 'joined', + 'left', + 'ping', + 'ha', + 'all', + 'fullsetup', + 'open' +]; +const ignoreOptionNames = ['native_parser']; +const legacyOptionNames = ['server', 'replset', 'replSet', 'mongos', 'db']; +const legacyParse = deprecate( + require('../url_parser'), + 'current URL string parser is deprecated, and will be removed in a future version. ' + + 'To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.' +); +const validOptionNames = [ + 'poolSize', + 'ssl', + 'sslValidate', + 'sslCA', + 'sslCert', + 'sslKey', + 'sslPass', + 'sslCRL', + 'autoReconnect', + 'noDelay', + 'keepAlive', + 'keepAliveInitialDelay', + 'connectTimeoutMS', + 'family', + 'socketTimeoutMS', + 'reconnectTries', + 'reconnectInterval', + 'ha', + 'haInterval', + 'replicaSet', + 'secondaryAcceptableLatencyMS', + 'acceptableLatencyMS', + 'connectWithNoPrimary', + 'authSource', + 'w', + 'wtimeout', + 'j', + 'forceServerObjectId', + 'serializeFunctions', + 'ignoreUndefined', + 'raw', + 'bufferMaxEntries', + 'readPreference', + 'pkFactory', + 'promiseLibrary', + 'readConcern', + 'maxStalenessSeconds', + 'loggerLevel', + 'logger', + 'promoteValues', + 'promoteBuffers', + 'promoteLongs', + 'domainsEnabled', + 'checkServerIdentity', + 'validateOptions', + 'appname', + 'auth', + 'user', + 'password', + 'authMechanism', + 'compression', + 'fsync', + 'readPreferenceTags', + 'numberOfRetries', + 'auto_reconnect', + 'minSize', + 'monitorCommands', + 'retryWrites', + 'useNewUrlParser' +]; + +function addListeners(mongoClient, topology) { + topology.on('authenticated', createListener(mongoClient, 'authenticated')); + topology.on('error', createListener(mongoClient, 'error')); + topology.on('timeout', createListener(mongoClient, 'timeout')); + topology.on('close', createListener(mongoClient, 'close')); + topology.on('parseError', createListener(mongoClient, 'parseError')); + topology.once('open', createListener(mongoClient, 'open')); + topology.once('fullsetup', createListener(mongoClient, 'fullsetup')); + topology.once('all', createListener(mongoClient, 'all')); + topology.on('reconnect', createListener(mongoClient, 'reconnect')); +} + +function assignTopology(client, topology) { + client.topology = topology; + topology.s.sessionPool = new ServerSessionPool(topology.s.coreTopology); +} + +// Clear out all events +function clearAllEvents(topology) { + monitoringEvents.forEach(event => topology.removeAllListeners(event)); +} + +// Collect all events in order from SDAM +function collectEvents(mongoClient, topology) { + const MongoClient = require('../mongo_client'); + const collectedEvents = []; + + if (mongoClient instanceof MongoClient) { + monitoringEvents.forEach(event => { + topology.on(event, (object1, object2) => { + if (event === 'open') { + collectedEvents.push({ event: event, object1: mongoClient }); + } else { + collectedEvents.push({ event: event, object1: object1, object2: object2 }); + } + }); + }); + } + + return collectedEvents; +} + +/** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @param {MongoClient} mongoClient The MongoClient instance with which to connect. + * @param {string} url The connection URI string + * @param {object} [options] Optional settings. See MongoClient.prototype.connect for a list of options. + * @param {MongoClient~connectCallback} [callback] The command result callback + */ +function connect(mongoClient, url, options, callback) { + options = Object.assign({}, options); + + // If callback is null throw an exception + if (callback == null) { + throw new Error('no callback function provided'); + } + + // Get a logger for MongoClient + const logger = Logger('MongoClient', options); + + // Did we pass in a Server/ReplSet/Mongos + if (url instanceof Server || url instanceof ReplSet || url instanceof Mongos) { + return connectWithUrl(mongoClient, url, options, connectCallback); + } + + const parseFn = options.useNewUrlParser ? parse : legacyParse; + const transform = options.useNewUrlParser ? transformUrlOptions : legacyTransformUrlOptions; + + parseFn(url, options, (err, _object) => { + // Do not attempt to connect if parsing error + if (err) return callback(err); + + // Flatten + const object = transform(_object); + + // Parse the string + const _finalOptions = createUnifiedOptions(object, options); + + // Check if we have connection and socket timeout set + if (_finalOptions.socketTimeoutMS == null) _finalOptions.socketTimeoutMS = 360000; + if (_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 30000; + + if (_finalOptions.db_options && _finalOptions.db_options.auth) { + delete _finalOptions.db_options.auth; + } + + // Store the merged options object + mongoClient.s.options = _finalOptions; + + // Failure modes + if (object.servers.length === 0) { + return callback(new Error('connection string must contain at least one seed host')); + } + + // Do we have a replicaset then skip discovery and go straight to connectivity + if (_finalOptions.replicaSet || _finalOptions.rs_name) { + return createTopology( + mongoClient, + 'replicaset', + _finalOptions, + connectHandler(mongoClient, _finalOptions, connectCallback) + ); + } else if (object.servers.length > 1) { + return createTopology( + mongoClient, + 'mongos', + _finalOptions, + connectHandler(mongoClient, _finalOptions, connectCallback) + ); + } else { + return createServer( + mongoClient, + _finalOptions, + connectHandler(mongoClient, _finalOptions, connectCallback) + ); + } + }); + function connectCallback(err, topology) { + const warningMessage = `seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name`; + if (err && err.message === 'no mongos proxies found in seed list') { + if (logger.isWarn()) { + logger.warn(warningMessage); + } + + // Return a more specific error message for MongoClient.connect + return callback(new MongoError(warningMessage)); + } + + // Return the error and db instance + callback(err, topology); + } +} + +function connectHandler(client, options, callback) { + return (err, topology) => { + if (err) { + return handleConnectCallback(err, topology, callback); + } + + // No authentication just reconnect + if (!options.auth) { + return handleConnectCallback(err, topology, callback); + } + + // Authenticate + authenticate(client, options.user, options.password, options, (err, success) => { + if (success) { + handleConnectCallback(null, topology, callback); + } else { + if (topology) topology.close(); + const authError = err ? err : new Error('Could not authenticate user ' + options.auth[0]); + handleConnectCallback(authError, topology, callback); + } + }); + }; +} + +/** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @param {MongoClient} mongoClient The MongoClient instance with which to connect. + * @param {MongoClient~connectCallback} [callback] The command result callback + */ +function connectOp(mongoClient, err, callback) { + // Did we have a validation error + if (err) return callback(err); + // Fallback to callback based connect + connect(mongoClient, mongoClient.s.url, mongoClient.s.options, err => { + if (err) return callback(err); + callback(null, mongoClient); + }); +} + +function connectWithUrl(mongoClient, url, options, connectCallback) { + // Set the topology + assignTopology(mongoClient, url); + + // Add listeners + addListeners(mongoClient, url); + + // Propagate the events to the client + relayEvents(mongoClient, url); + + let finalOptions = Object.assign({}, options); + + // If we have a readPreference passed in by the db options, convert it from a string + if (typeof options.readPreference === 'string' || typeof options.read_preference === 'string') { + finalOptions.readPreference = new ReadPreference( + options.readPreference || options.read_preference + ); + } + + // Connect + return url.connect( + finalOptions, + connectHandler(mongoClient, finalOptions, (err, topology) => { + if (err) return connectCallback(err, topology); + if (finalOptions.user || finalOptions.password || finalOptions.authMechanism) { + return authenticate( + mongoClient, + finalOptions.user, + finalOptions.password, + finalOptions, + err => { + if (err) return connectCallback(err, topology); + connectCallback(err, topology); + } + ); + } + + connectCallback(err, topology); + }) + ); +} + +function createListener(mongoClient, event) { + const eventSet = new Set(['all', 'fullsetup', 'open', 'reconnect']); + return (v1, v2) => { + if (eventSet.has(event)) { + return mongoClient.emit(event, mongoClient); + } + + mongoClient.emit(event, v1, v2); + }; +} + +function createServer(mongoClient, options, callback) { + // Pass in the promise library + options.promiseLibrary = mongoClient.s.promiseLibrary; + + // Set default options + const servers = translateOptions(options); + + const server = servers[0]; + + // Propagate the events to the client + const collectedEvents = collectEvents(mongoClient, server); + + // Connect to topology + server.connect(options, (err, topology) => { + if (err) { + server.close(true); + return callback(err); + } + // Clear out all the collected event listeners + clearAllEvents(server); + + // Relay all the events + relayEvents(mongoClient, server); + // Add listeners + addListeners(mongoClient, server); + // Check if we are really speaking to a mongos + const ismaster = topology.lastIsMaster(); + + // Set the topology + assignTopology(mongoClient, topology); + + // Do we actually have a mongos + if (ismaster && ismaster.msg === 'isdbgrid') { + // Destroy the current connection + topology.close(); + // Create mongos connection instead + return createTopology(mongoClient, 'mongos', options, callback); + } + + // Fire all the events + replayEvents(mongoClient, collectedEvents); + // Otherwise callback + callback(err, topology); + }); +} + +function createTopology(mongoClient, topologyType, options, callback) { + // Pass in the promise library + options.promiseLibrary = mongoClient.s.promiseLibrary; + + const translationOptions = {}; + if (topologyType === 'unified') translationOptions.createServers = false; + + // Set default options + const servers = translateOptions(options, translationOptions); + + // Create the topology + let topology; + if (topologyType === 'mongos') { + topology = new Mongos(servers, options); + } else if (topologyType === 'replicaset') { + topology = new ReplSet(servers, options); + } + + // Add listeners + addListeners(mongoClient, topology); + + // Propagate the events to the client + relayEvents(mongoClient, topology); + + // Open the connection + topology.connect(options, (err, newTopology) => { + if (err) { + topology.close(true); + return callback(err); + } + + assignTopology(mongoClient, newTopology); + callback(null, newTopology); + }); +} + +function createUnifiedOptions(finalOptions, options) { + const childOptions = [ + 'mongos', + 'server', + 'db', + 'replset', + 'db_options', + 'server_options', + 'rs_options', + 'mongos_options' + ]; + const noMerge = ['readconcern', 'compression']; + + for (const name in options) { + if (noMerge.indexOf(name.toLowerCase()) !== -1) { + finalOptions[name] = options[name]; + } else if (childOptions.indexOf(name.toLowerCase()) !== -1) { + finalOptions = mergeOptions(finalOptions, options[name], false); + } else { + if ( + options[name] && + typeof options[name] === 'object' && + !Buffer.isBuffer(options[name]) && + !Array.isArray(options[name]) + ) { + finalOptions = mergeOptions(finalOptions, options[name], true); + } else { + finalOptions[name] = options[name]; + } + } + } + + return finalOptions; +} + +function handleConnectCallback(err, topology, callback) { + return process.nextTick(() => { + try { + callback(err, topology); + } catch (err) { + if (topology) topology.close(); + throw err; + } + }); +} + +function legacyTransformUrlOptions(object) { + return mergeOptions(createUnifiedOptions({}, object), object, false); +} + +/** + * Logout user from server, fire off on all connections and remove all auth info. + * + * @method + * @param {MongoClient} mongoClient The MongoClient instance on which to logout. + * @param {object} [options] Optional settings. See MongoClient.prototype.logout for a list of options. + * @param {Db~resultCallback} [callback] The command result callback + */ +function logout(mongoClient, dbName, callback) { + mongoClient.topology.logout(dbName, err => { + if (err) return callback(err); + callback(null, true); + }); +} + +function mergeOptions(target, source, flatten) { + for (const name in source) { + if (source[name] && typeof source[name] === 'object' && flatten) { + target = mergeOptions(target, source[name], flatten); + } else { + target[name] = source[name]; + } + } + + return target; +} + +function relayEvents(mongoClient, topology) { + const serverOrCommandEvents = [ + 'serverOpening', + 'serverDescriptionChanged', + 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', + 'serverHeartbeatFailed', + 'serverClosed', + 'topologyOpening', + 'topologyClosed', + 'topologyDescriptionChanged', + 'commandStarted', + 'commandSucceeded', + 'commandFailed', + 'joined', + 'left', + 'ping', + 'ha' + ]; + + serverOrCommandEvents.forEach(event => { + topology.on(event, (object1, object2) => { + mongoClient.emit(event, object1, object2); + }); + }); +} + +// +// Replay any events due to single server connection switching to Mongos +// +function replayEvents(mongoClient, events) { + for (let i = 0; i < events.length; i++) { + mongoClient.emit(events[i].event, events[i].object1, events[i].object2); + } +} + +const LEGACY_OPTIONS_MAP = validOptionNames.reduce((obj, name) => { + obj[name.toLowerCase()] = name; + return obj; +}, {}); + +function transformUrlOptions(_object) { + let object = Object.assign({ servers: _object.hosts }, _object.options); + for (let name in object) { + const camelCaseName = LEGACY_OPTIONS_MAP[name]; + if (camelCaseName) { + object[camelCaseName] = object[name]; + } + } + if (_object.auth) { + const auth = _object.auth; + for (let i in auth) { + if (auth[i]) { + object[i] = auth[i]; + } + } + if (auth.username) { + object.auth = auth; + object.user = auth.username; + } + if (auth.db) { + object.dbName = auth.db; + } + } + if (object.maxpoolsize) { + object.poolSize = object.maxpoolsize; + } + if (object.readconcernlevel) { + object.readConcern = { level: object.readconcernlevel }; + } + if (object.wtimeoutms) { + object.wtimeout = object.wtimeoutms; + } + return object; +} + +function translateOptions(options, translationOptions) { + translationOptions = Object.assign({}, { createServers: true }, translationOptions); + + // If we have a readPreference passed in by the db options + if (typeof options.readPreference === 'string' || typeof options.read_preference === 'string') { + options.readPreference = new ReadPreference(options.readPreference || options.read_preference); + } + + // Do we have readPreference tags, add them + if (options.readPreference && (options.readPreferenceTags || options.read_preference_tags)) { + options.readPreference.tags = options.readPreferenceTags || options.read_preference_tags; + } + + // Do we have maxStalenessSeconds + if (options.maxStalenessSeconds) { + options.readPreference.maxStalenessSeconds = options.maxStalenessSeconds; + } + + // Set the socket and connection timeouts + if (options.socketTimeoutMS == null) options.socketTimeoutMS = 360000; + if (options.connectTimeoutMS == null) options.connectTimeoutMS = 30000; + + if (!translationOptions.createServers) { + return; + } + + // Create server instances + return options.servers.map(serverObj => { + return serverObj.domain_socket + ? new Server(serverObj.domain_socket, 27017, options) + : new Server(serverObj.host, serverObj.port, options); + }); +} + +// Validate options object +function validOptions(options) { + const _validOptions = validOptionNames.concat(legacyOptionNames); + + for (const name in options) { + if (ignoreOptionNames.indexOf(name) !== -1) { + continue; + } + + if (_validOptions.indexOf(name) === -1 && options.validateOptions) { + return new MongoError(`option ${name} is not supported`); + } else if (_validOptions.indexOf(name) === -1) { + console.warn(`the options [${name}] is not supported`); + } + + if (legacyOptionNames.indexOf(name) !== -1) { + console.warn( + `the server/replset/mongos/db options are deprecated, ` + + `all their options are supported at the top level of the options object [${validOptionNames}]` + ); + } + } +} + +module.exports = { connectOp, logout, validOptions }; diff --git a/node_modules/mongodb/lib/topologies/mongos.js b/node_modules/mongodb/lib/topologies/mongos.js new file mode 100644 index 0000000..dc14277 --- /dev/null +++ b/node_modules/mongodb/lib/topologies/mongos.js @@ -0,0 +1,452 @@ +'use strict'; + +const TopologyBase = require('./topology_base').TopologyBase; +const MongoError = require('mongodb-core').MongoError; +const CMongos = require('mongodb-core').Mongos; +const Cursor = require('../cursor'); +const Server = require('./server'); +const Store = require('./topology_base').Store; +const MAX_JS_INT = require('../utils').MAX_JS_INT; +const translateOptions = require('../utils').translateOptions; +const filterOptions = require('../utils').filterOptions; +const mergeOptions = require('../utils').mergeOptions; + +/** + * @fileOverview The **Mongos** class is a class that represents a Mongos Proxy topology and is + * used to construct connections. + * + * **Mongos Should not be used, use MongoClient.connect** + */ + +// Allowed parameters +var legalOptionNames = [ + 'ha', + 'haInterval', + 'acceptableLatencyMS', + 'poolSize', + 'ssl', + 'checkServerIdentity', + 'sslValidate', + 'sslCA', + 'sslCRL', + 'sslCert', + 'ciphers', + 'ecdhCurve', + 'sslKey', + 'sslPass', + 'socketOptions', + 'bufferMaxEntries', + 'store', + 'auto_reconnect', + 'autoReconnect', + 'emitError', + 'keepAlive', + 'keepAliveInitialDelay', + 'noDelay', + 'connectTimeoutMS', + 'socketTimeoutMS', + 'loggerLevel', + 'logger', + 'reconnectTries', + 'appname', + 'domainsEnabled', + 'servername', + 'promoteLongs', + 'promoteValues', + 'promoteBuffers', + 'promiseLibrary', + 'monitorCommands' +]; + +/** + * Creates a new Mongos instance + * @class + * @deprecated + * @param {Server[]} servers A seedlist of servers participating in the replicaset. + * @param {object} [options] Optional settings. + * @param {booelan} [options.ha=true] Turn on high availability monitoring. + * @param {number} [options.haInterval=5000] Time between each replicaset status check. + * @param {number} [options.poolSize=5] Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. + * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for MongoS proxy selection + * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support) + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {string} [options.ciphers] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {string} [options.ecdhCurve] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {(Buffer|string)} [options.sslCert] String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslKey] String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslPass] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {string} [options.servername] String containing the server name requested via TLS SNI. + * @param {object} [options.socketOptions] Socket options + * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option. + * @param {boolean} [options.socketOptions.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.socketOptions.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket + * @param {number} [options.socketOptions.connectTimeoutMS=0] TCP Connection timeout setting + * @param {number} [options.socketOptions.socketTimeoutMS=0] TCP Socket timeout setting + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology + * @fires Mongos#connect + * @fires Mongos#ha + * @fires Mongos#joined + * @fires Mongos#left + * @fires Mongos#fullsetup + * @fires Mongos#open + * @fires Mongos#close + * @fires Mongos#error + * @fires Mongos#timeout + * @fires Mongos#parseError + * @fires Mongos#commandStarted + * @fires Mongos#commandSucceeded + * @fires Mongos#commandFailed + * @property {string} parserType the parser type used (c++ or js). + * @return {Mongos} a Mongos instance. + */ +class Mongos extends TopologyBase { + constructor(servers, options) { + super(); + + options = options || {}; + var self = this; + + // Filter the options + options = filterOptions(options, legalOptionNames); + + // Ensure all the instances are Server + for (var i = 0; i < servers.length; i++) { + if (!(servers[i] instanceof Server)) { + throw MongoError.create({ + message: 'all seed list instances must be of the Server type', + driver: true + }); + } + } + + // Stored options + var storeOptions = { + force: false, + bufferMaxEntries: + typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : MAX_JS_INT + }; + + // Shared global store + var store = options.store || new Store(self, storeOptions); + + // Build seed list + var seedlist = servers.map(function(x) { + return { host: x.host, port: x.port }; + }); + + // Get the reconnect option + var reconnect = typeof options.auto_reconnect === 'boolean' ? options.auto_reconnect : true; + reconnect = typeof options.autoReconnect === 'boolean' ? options.autoReconnect : reconnect; + + // Clone options + var clonedOptions = mergeOptions( + {}, + { + disconnectHandler: store, + cursorFactory: Cursor, + reconnect: reconnect, + emitError: typeof options.emitError === 'boolean' ? options.emitError : true, + size: typeof options.poolSize === 'number' ? options.poolSize : 5, + monitorCommands: + typeof options.monitorCommands === 'boolean' ? options.monitorCommands : false + } + ); + + // Translate any SSL options and other connectivity options + clonedOptions = translateOptions(clonedOptions, options); + + // Socket options + var socketOptions = + options.socketOptions && Object.keys(options.socketOptions).length > 0 + ? options.socketOptions + : options; + + // Translate all the options to the mongodb-core ones + clonedOptions = translateOptions(clonedOptions, socketOptions); + + // Build default client information + clonedOptions.clientInfo = this.clientInfo; + // Do we have an application specific string + if (options.appname) { + clonedOptions.clientInfo.application = { name: options.appname }; + } + + // Internal state + this.s = { + // Create the Mongos + coreTopology: new CMongos(seedlist, clonedOptions), + // Server capabilities + sCapabilities: null, + // Debug turned on + debug: clonedOptions.debug, + // Store option defaults + storeOptions: storeOptions, + // Cloned options + clonedOptions: clonedOptions, + // Actual store of callbacks + store: store, + // Options + options: options, + // Server Session Pool + sessionPool: null, + // Active client sessions + sessions: [], + // Promise library + promiseLibrary: options.promiseLibrary || Promise + }; + } + + // Connect + connect(_options, callback) { + var self = this; + if ('function' === typeof _options) (callback = _options), (_options = {}); + if (_options == null) _options = {}; + if (!('function' === typeof callback)) callback = null; + _options = Object.assign({}, this.s.clonedOptions, _options); + self.s.options = _options; + + // Update bufferMaxEntries + self.s.storeOptions.bufferMaxEntries = + typeof _options.bufferMaxEntries === 'number' ? _options.bufferMaxEntries : -1; + + // Error handler + var connectErrorHandler = function() { + return function(err) { + // Remove all event handlers + var events = ['timeout', 'error', 'close']; + events.forEach(function(e) { + self.removeListener(e, connectErrorHandler); + }); + + self.s.coreTopology.removeListener('connect', connectErrorHandler); + // Force close the topology + self.close(true); + + // Try to callback + try { + callback(err); + } catch (err) { + process.nextTick(function() { + throw err; + }); + } + }; + }; + + // Actual handler + var errorHandler = function(event) { + return function(err) { + if (event !== 'error') { + self.emit(event, err); + } + }; + }; + + // Error handler + var reconnectHandler = function() { + self.emit('reconnect'); + self.s.store.execute(); + }; + + // relay the event + var relay = function(event) { + return function(t, server) { + self.emit(event, t, server); + }; + }; + + // Connect handler + var connectHandler = function() { + // Clear out all the current handlers left over + var events = ['timeout', 'error', 'close', 'fullsetup']; + events.forEach(function(e) { + self.s.coreTopology.removeAllListeners(e); + }); + + // Set up listeners + self.s.coreTopology.on('timeout', errorHandler('timeout')); + self.s.coreTopology.on('error', errorHandler('error')); + self.s.coreTopology.on('close', errorHandler('close')); + + // Set up serverConfig listeners + self.s.coreTopology.on('fullsetup', function() { + self.emit('fullsetup', self); + }); + + // Emit open event + self.emit('open', null, self); + + // Return correctly + try { + callback(null, self); + } catch (err) { + process.nextTick(function() { + throw err; + }); + } + }; + + // Clear out all the current handlers left over + var events = [ + 'timeout', + 'error', + 'close', + 'serverOpening', + 'serverDescriptionChanged', + 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', + 'serverHeartbeatFailed', + 'serverClosed', + 'topologyOpening', + 'topologyClosed', + 'topologyDescriptionChanged', + 'commandStarted', + 'commandSucceeded', + 'commandFailed' + ]; + events.forEach(function(e) { + self.s.coreTopology.removeAllListeners(e); + }); + + // Set up SDAM listeners + self.s.coreTopology.on('serverDescriptionChanged', relay('serverDescriptionChanged')); + self.s.coreTopology.on('serverHeartbeatStarted', relay('serverHeartbeatStarted')); + self.s.coreTopology.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded')); + self.s.coreTopology.on('serverHeartbeatFailed', relay('serverHeartbeatFailed')); + self.s.coreTopology.on('serverOpening', relay('serverOpening')); + self.s.coreTopology.on('serverClosed', relay('serverClosed')); + self.s.coreTopology.on('topologyOpening', relay('topologyOpening')); + self.s.coreTopology.on('topologyClosed', relay('topologyClosed')); + self.s.coreTopology.on('topologyDescriptionChanged', relay('topologyDescriptionChanged')); + self.s.coreTopology.on('commandStarted', relay('commandStarted')); + self.s.coreTopology.on('commandSucceeded', relay('commandSucceeded')); + self.s.coreTopology.on('commandFailed', relay('commandFailed')); + + // Set up listeners + self.s.coreTopology.once('timeout', connectErrorHandler('timeout')); + self.s.coreTopology.once('error', connectErrorHandler('error')); + self.s.coreTopology.once('close', connectErrorHandler('close')); + self.s.coreTopology.once('connect', connectHandler); + // Join and leave events + self.s.coreTopology.on('joined', relay('joined')); + self.s.coreTopology.on('left', relay('left')); + + // Reconnect server + self.s.coreTopology.on('reconnect', reconnectHandler); + + // Start connection + self.s.coreTopology.connect(_options); + } +} + +Object.defineProperty(Mongos.prototype, 'haInterval', { + enumerable: true, + get: function() { + return this.s.coreTopology.s.haInterval; + } +}); + +/** + * A mongos connect event, used to verify that the connection is up and running + * + * @event Mongos#connect + * @type {Mongos} + */ + +/** + * The mongos high availability event + * + * @event Mongos#ha + * @type {function} + * @param {string} type The stage in the high availability event (start|end) + * @param {boolean} data.norepeat This is a repeating high availability process or a single execution only + * @param {number} data.id The id for this high availability request + * @param {object} data.state An object containing the information about the current replicaset + */ + +/** + * A server member left the mongos set + * + * @event Mongos#left + * @type {function} + * @param {string} type The type of member that left (primary|secondary|arbiter) + * @param {Server} server The server object that left + */ + +/** + * A server member joined the mongos set + * + * @event Mongos#joined + * @type {function} + * @param {string} type The type of member that joined (primary|secondary|arbiter) + * @param {Server} server The server object that joined + */ + +/** + * Mongos fullsetup event, emitted when all proxies in the topology have been connected to. + * + * @event Mongos#fullsetup + * @type {Mongos} + */ + +/** + * Mongos open event, emitted when mongos can start processing commands. + * + * @event Mongos#open + * @type {Mongos} + */ + +/** + * Mongos close event + * + * @event Mongos#close + * @type {object} + */ + +/** + * Mongos error event, emitted if there is an error listener. + * + * @event Mongos#error + * @type {MongoError} + */ + +/** + * Mongos timeout event + * + * @event Mongos#timeout + * @type {object} + */ + +/** + * Mongos parseError event + * + * @event Mongos#parseError + * @type {object} + */ + +/** + * An event emitted indicating a command was started, if command monitoring is enabled + * + * @event Mongos#commandStarted + * @type {object} + */ + +/** + * An event emitted indicating a command succeeded, if command monitoring is enabled + * + * @event Mongos#commandSucceeded + * @type {object} + */ + +/** + * An event emitted indicating a command failed, if command monitoring is enabled + * + * @event Mongos#commandFailed + * @type {object} + */ + +module.exports = Mongos; diff --git a/node_modules/mongodb/lib/topologies/replset.js b/node_modules/mongodb/lib/topologies/replset.js new file mode 100644 index 0000000..0a73134 --- /dev/null +++ b/node_modules/mongodb/lib/topologies/replset.js @@ -0,0 +1,497 @@ +'use strict'; + +const Server = require('./server'); +const Cursor = require('../cursor'); +const MongoError = require('mongodb-core').MongoError; +const TopologyBase = require('./topology_base').TopologyBase; +const Store = require('./topology_base').Store; +const CReplSet = require('mongodb-core').ReplSet; +const MAX_JS_INT = require('../utils').MAX_JS_INT; +const translateOptions = require('../utils').translateOptions; +const filterOptions = require('../utils').filterOptions; +const mergeOptions = require('../utils').mergeOptions; + +/** + * @fileOverview The **ReplSet** class is a class that represents a Replicaset topology and is + * used to construct connections. + * + * **ReplSet Should not be used, use MongoClient.connect** + */ + +// Allowed parameters +var legalOptionNames = [ + 'ha', + 'haInterval', + 'replicaSet', + 'rs_name', + 'secondaryAcceptableLatencyMS', + 'connectWithNoPrimary', + 'poolSize', + 'ssl', + 'checkServerIdentity', + 'sslValidate', + 'sslCA', + 'sslCert', + 'ciphers', + 'ecdhCurve', + 'sslCRL', + 'sslKey', + 'sslPass', + 'socketOptions', + 'bufferMaxEntries', + 'store', + 'auto_reconnect', + 'autoReconnect', + 'emitError', + 'keepAlive', + 'keepAliveInitialDelay', + 'noDelay', + 'connectTimeoutMS', + 'socketTimeoutMS', + 'strategy', + 'debug', + 'family', + 'loggerLevel', + 'logger', + 'reconnectTries', + 'appname', + 'domainsEnabled', + 'servername', + 'promoteLongs', + 'promoteValues', + 'promoteBuffers', + 'maxStalenessSeconds', + 'promiseLibrary', + 'minSize', + 'monitorCommands' +]; + +/** + * Creates a new ReplSet instance + * @class + * @deprecated + * @param {Server[]} servers A seedlist of servers participating in the replicaset. + * @param {object} [options] Optional settings. + * @param {boolean} [options.ha=true] Turn on high availability monitoring. + * @param {number} [options.haInterval=10000] Time between each replicaset status check. + * @param {string} [options.replicaSet] The name of the replicaset to connect to. + * @param {number} [options.secondaryAcceptableLatencyMS=15] Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) + * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available + * @param {number} [options.poolSize=5] Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. + * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support) + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslCert] String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher. + * @param {string} [options.ciphers] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {string} [options.ecdhCurve] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {(Buffer|string)} [options.sslKey] String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslPass] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {string} [options.servername] String containing the server name requested via TLS SNI. + * @param {object} [options.socketOptions] Socket options + * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option. + * @param {boolean} [options.socketOptions.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.socketOptions.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket + * @param {number} [options.socketOptions.connectTimeoutMS=10000] TCP Connection timeout setting + * @param {number} [options.socketOptions.socketTimeoutMS=0] TCP Socket timeout setting + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + * @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology + * @fires ReplSet#connect + * @fires ReplSet#ha + * @fires ReplSet#joined + * @fires ReplSet#left + * @fires ReplSet#fullsetup + * @fires ReplSet#open + * @fires ReplSet#close + * @fires ReplSet#error + * @fires ReplSet#timeout + * @fires ReplSet#parseError + * @fires ReplSet#commandStarted + * @fires ReplSet#commandSucceeded + * @fires ReplSet#commandFailed + * @property {string} parserType the parser type used (c++ or js). + * @return {ReplSet} a ReplSet instance. + */ +class ReplSet extends TopologyBase { + constructor(servers, options) { + super(); + + options = options || {}; + var self = this; + + // Filter the options + options = filterOptions(options, legalOptionNames); + + // Ensure all the instances are Server + for (var i = 0; i < servers.length; i++) { + if (!(servers[i] instanceof Server)) { + throw MongoError.create({ + message: 'all seed list instances must be of the Server type', + driver: true + }); + } + } + + // Stored options + var storeOptions = { + force: false, + bufferMaxEntries: + typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : MAX_JS_INT + }; + + // Shared global store + var store = options.store || new Store(self, storeOptions); + + // Build seed list + var seedlist = servers.map(function(x) { + return { host: x.host, port: x.port }; + }); + + // Clone options + var clonedOptions = mergeOptions( + {}, + { + disconnectHandler: store, + cursorFactory: Cursor, + reconnect: false, + emitError: typeof options.emitError === 'boolean' ? options.emitError : true, + size: typeof options.poolSize === 'number' ? options.poolSize : 5, + monitorCommands: + typeof options.monitorCommands === 'boolean' ? options.monitorCommands : false + } + ); + + // Translate any SSL options and other connectivity options + clonedOptions = translateOptions(clonedOptions, options); + + // Socket options + var socketOptions = + options.socketOptions && Object.keys(options.socketOptions).length > 0 + ? options.socketOptions + : options; + + // Translate all the options to the mongodb-core ones + clonedOptions = translateOptions(clonedOptions, socketOptions); + + // Build default client information + clonedOptions.clientInfo = this.clientInfo; + // Do we have an application specific string + if (options.appname) { + clonedOptions.clientInfo.application = { name: options.appname }; + } + + // Create the ReplSet + var coreTopology = new CReplSet(seedlist, clonedOptions); + + // Listen to reconnect event + coreTopology.on('reconnect', function() { + self.emit('reconnect'); + store.execute(); + }); + + // Internal state + this.s = { + // Replicaset + coreTopology: coreTopology, + // Server capabilities + sCapabilities: null, + // Debug tag + tag: options.tag, + // Store options + storeOptions: storeOptions, + // Cloned options + clonedOptions: clonedOptions, + // Store + store: store, + // Options + options: options, + // Server Session Pool + sessionPool: null, + // Active client sessions + sessions: [], + // Promise library + promiseLibrary: options.promiseLibrary || Promise + }; + + // Debug + if (clonedOptions.debug) { + // Last ismaster + Object.defineProperty(this, 'replset', { + enumerable: true, + get: function() { + return coreTopology; + } + }); + } + } + + // Connect method + connect(_options, callback) { + var self = this; + if ('function' === typeof _options) (callback = _options), (_options = {}); + if (_options == null) _options = {}; + if (!('function' === typeof callback)) callback = null; + _options = Object.assign({}, this.s.clonedOptions, _options); + self.s.options = _options; + + // Update bufferMaxEntries + self.s.storeOptions.bufferMaxEntries = + typeof _options.bufferMaxEntries === 'number' ? _options.bufferMaxEntries : -1; + + // Actual handler + var errorHandler = function(event) { + return function(err) { + if (event !== 'error') { + self.emit(event, err); + } + }; + }; + + // Clear out all the current handlers left over + var events = [ + 'timeout', + 'error', + 'close', + 'serverOpening', + 'serverDescriptionChanged', + 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', + 'serverHeartbeatFailed', + 'serverClosed', + 'topologyOpening', + 'topologyClosed', + 'topologyDescriptionChanged', + 'commandStarted', + 'commandSucceeded', + 'commandFailed', + 'joined', + 'left', + 'ping', + 'ha' + ]; + events.forEach(function(e) { + self.s.coreTopology.removeAllListeners(e); + }); + + // relay the event + var relay = function(event) { + return function(t, server) { + self.emit(event, t, server); + }; + }; + + // Replset events relay + var replsetRelay = function(event) { + return function(t, server) { + self.emit(event, t, server.lastIsMaster(), server); + }; + }; + + // Relay ha + var relayHa = function(t, state) { + self.emit('ha', t, state); + + if (t === 'start') { + self.emit('ha_connect', t, state); + } else if (t === 'end') { + self.emit('ha_ismaster', t, state); + } + }; + + // Set up serverConfig listeners + self.s.coreTopology.on('joined', replsetRelay('joined')); + self.s.coreTopology.on('left', relay('left')); + self.s.coreTopology.on('ping', relay('ping')); + self.s.coreTopology.on('ha', relayHa); + + // Set up SDAM listeners + self.s.coreTopology.on('serverDescriptionChanged', relay('serverDescriptionChanged')); + self.s.coreTopology.on('serverHeartbeatStarted', relay('serverHeartbeatStarted')); + self.s.coreTopology.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded')); + self.s.coreTopology.on('serverHeartbeatFailed', relay('serverHeartbeatFailed')); + self.s.coreTopology.on('serverOpening', relay('serverOpening')); + self.s.coreTopology.on('serverClosed', relay('serverClosed')); + self.s.coreTopology.on('topologyOpening', relay('topologyOpening')); + self.s.coreTopology.on('topologyClosed', relay('topologyClosed')); + self.s.coreTopology.on('topologyDescriptionChanged', relay('topologyDescriptionChanged')); + self.s.coreTopology.on('commandStarted', relay('commandStarted')); + self.s.coreTopology.on('commandSucceeded', relay('commandSucceeded')); + self.s.coreTopology.on('commandFailed', relay('commandFailed')); + + self.s.coreTopology.on('fullsetup', function() { + self.emit('fullsetup', self, self); + }); + + self.s.coreTopology.on('all', function() { + self.emit('all', null, self); + }); + + // Connect handler + var connectHandler = function() { + // Set up listeners + self.s.coreTopology.once('timeout', errorHandler('timeout')); + self.s.coreTopology.once('error', errorHandler('error')); + self.s.coreTopology.once('close', errorHandler('close')); + + // Emit open event + self.emit('open', null, self); + + // Return correctly + try { + callback(null, self); + } catch (err) { + process.nextTick(function() { + throw err; + }); + } + }; + + // Error handler + var connectErrorHandler = function() { + return function(err) { + ['timeout', 'error', 'close'].forEach(function(e) { + self.s.coreTopology.removeListener(e, connectErrorHandler); + }); + + self.s.coreTopology.removeListener('connect', connectErrorHandler); + // Destroy the replset + self.s.coreTopology.destroy(); + + // Try to callback + try { + callback(err); + } catch (err) { + if (!self.s.coreTopology.isConnected()) + process.nextTick(function() { + throw err; + }); + } + }; + }; + + // Set up listeners + self.s.coreTopology.once('timeout', connectErrorHandler('timeout')); + self.s.coreTopology.once('error', connectErrorHandler('error')); + self.s.coreTopology.once('close', connectErrorHandler('close')); + self.s.coreTopology.once('connect', connectHandler); + + // Start connection + self.s.coreTopology.connect(_options); + } + + close(forceClosed) { + super.close(forceClosed); + + ['timeout', 'error', 'close', 'joined', 'left'].forEach(e => this.removeAllListeners(e)); + } +} + +Object.defineProperty(ReplSet.prototype, 'haInterval', { + enumerable: true, + get: function() { + return this.s.coreTopology.s.haInterval; + } +}); + +/** + * A replset connect event, used to verify that the connection is up and running + * + * @event ReplSet#connect + * @type {ReplSet} + */ + +/** + * The replset high availability event + * + * @event ReplSet#ha + * @type {function} + * @param {string} type The stage in the high availability event (start|end) + * @param {boolean} data.norepeat This is a repeating high availability process or a single execution only + * @param {number} data.id The id for this high availability request + * @param {object} data.state An object containing the information about the current replicaset + */ + +/** + * A server member left the replicaset + * + * @event ReplSet#left + * @type {function} + * @param {string} type The type of member that left (primary|secondary|arbiter) + * @param {Server} server The server object that left + */ + +/** + * A server member joined the replicaset + * + * @event ReplSet#joined + * @type {function} + * @param {string} type The type of member that joined (primary|secondary|arbiter) + * @param {Server} server The server object that joined + */ + +/** + * ReplSet open event, emitted when replicaset can start processing commands. + * + * @event ReplSet#open + * @type {Replset} + */ + +/** + * ReplSet fullsetup event, emitted when all servers in the topology have been connected to. + * + * @event ReplSet#fullsetup + * @type {Replset} + */ + +/** + * ReplSet close event + * + * @event ReplSet#close + * @type {object} + */ + +/** + * ReplSet error event, emitted if there is an error listener. + * + * @event ReplSet#error + * @type {MongoError} + */ + +/** + * ReplSet timeout event + * + * @event ReplSet#timeout + * @type {object} + */ + +/** + * ReplSet parseError event + * + * @event ReplSet#parseError + * @type {object} + */ + +/** + * An event emitted indicating a command was started, if command monitoring is enabled + * + * @event ReplSet#commandStarted + * @type {object} + */ + +/** + * An event emitted indicating a command succeeded, if command monitoring is enabled + * + * @event ReplSet#commandSucceeded + * @type {object} + */ + +/** + * An event emitted indicating a command failed, if command monitoring is enabled + * + * @event ReplSet#commandFailed + * @type {object} + */ + +module.exports = ReplSet; diff --git a/node_modules/mongodb/lib/topologies/server.js b/node_modules/mongodb/lib/topologies/server.js new file mode 100644 index 0000000..77d8b6e --- /dev/null +++ b/node_modules/mongodb/lib/topologies/server.js @@ -0,0 +1,455 @@ +'use strict'; + +const CServer = require('mongodb-core').Server; +const Cursor = require('../cursor'); +const TopologyBase = require('./topology_base').TopologyBase; +const Store = require('./topology_base').Store; +const MongoError = require('mongodb-core').MongoError; +const MAX_JS_INT = require('../utils').MAX_JS_INT; +const translateOptions = require('../utils').translateOptions; +const filterOptions = require('../utils').filterOptions; +const mergeOptions = require('../utils').mergeOptions; + +/** + * @fileOverview The **Server** class is a class that represents a single server topology and is + * used to construct connections. + * + * **Server Should not be used, use MongoClient.connect** + */ + +// Allowed parameters +var legalOptionNames = [ + 'ha', + 'haInterval', + 'acceptableLatencyMS', + 'poolSize', + 'ssl', + 'checkServerIdentity', + 'sslValidate', + 'sslCA', + 'sslCRL', + 'sslCert', + 'ciphers', + 'ecdhCurve', + 'sslKey', + 'sslPass', + 'socketOptions', + 'bufferMaxEntries', + 'store', + 'auto_reconnect', + 'autoReconnect', + 'emitError', + 'keepAlive', + 'keepAliveInitialDelay', + 'noDelay', + 'connectTimeoutMS', + 'socketTimeoutMS', + 'family', + 'loggerLevel', + 'logger', + 'reconnectTries', + 'reconnectInterval', + 'monitoring', + 'appname', + 'domainsEnabled', + 'servername', + 'promoteLongs', + 'promoteValues', + 'promoteBuffers', + 'compression', + 'promiseLibrary', + 'monitorCommands' +]; + +/** + * Creates a new Server instance + * @class + * @deprecated + * @param {string} host The host for the server, can be either an IP4, IP6 or domain socket style host. + * @param {number} [port] The server port if IP4. + * @param {object} [options] Optional settings. + * @param {number} [options.poolSize=5] Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. + * @param {boolean} [options.ssl=false] Use ssl connection (needs to have a mongod server with ssl support) + * @param {boolean} [options.sslValidate=true] Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {array} [options.sslCA] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {array} [options.sslCRL] Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslCert] String or buffer containing the certificate we wish to present (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {string} [options.ciphers] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {string} [options.ecdhCurve] Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. + * @param {(Buffer|string)} [options.sslKey] String or buffer containing the certificate private key we wish to present (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {(Buffer|string)} [options.sslPass] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher) + * @param {string} [options.servername] String containing the server name requested via TLS SNI. + * @param {object} [options.socketOptions] Socket options + * @param {boolean} [options.socketOptions.autoReconnect=true] Reconnect on error. + * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option. + * @param {boolean} [options.socketOptions.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.socketOptions.keepAliveInitialDelay=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket + * @param {number} [options.socketOptions.connectTimeoutMS=0] TCP Connection timeout setting + * @param {number} [options.socketOptions.socketTimeoutMS=0] TCP Socket timeout setting + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {number} [options.monitoring=true] Triggers the server instance to call ismaster + * @param {number} [options.haInterval=10000] The interval of calling ismaster when monitoring is enabled. + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology + * @fires Server#connect + * @fires Server#close + * @fires Server#error + * @fires Server#timeout + * @fires Server#parseError + * @fires Server#reconnect + * @fires Server#commandStarted + * @fires Server#commandSucceeded + * @fires Server#commandFailed + * @property {string} parserType the parser type used (c++ or js). + * @return {Server} a Server instance. + */ +class Server extends TopologyBase { + constructor(host, port, options) { + super(); + var self = this; + + // Filter the options + options = filterOptions(options, legalOptionNames); + + // Promise library + const promiseLibrary = options.promiseLibrary; + + // Stored options + var storeOptions = { + force: false, + bufferMaxEntries: + typeof options.bufferMaxEntries === 'number' ? options.bufferMaxEntries : MAX_JS_INT + }; + + // Shared global store + var store = options.store || new Store(self, storeOptions); + + // Detect if we have a socket connection + if (host.indexOf('/') !== -1) { + if (port != null && typeof port === 'object') { + options = port; + port = null; + } + } else if (port == null) { + throw MongoError.create({ message: 'port must be specified', driver: true }); + } + + // Get the reconnect option + var reconnect = typeof options.auto_reconnect === 'boolean' ? options.auto_reconnect : true; + reconnect = typeof options.autoReconnect === 'boolean' ? options.autoReconnect : reconnect; + + // Clone options + var clonedOptions = mergeOptions( + {}, + { + host: host, + port: port, + disconnectHandler: store, + cursorFactory: Cursor, + reconnect: reconnect, + emitError: typeof options.emitError === 'boolean' ? options.emitError : true, + size: typeof options.poolSize === 'number' ? options.poolSize : 5, + monitorCommands: + typeof options.monitorCommands === 'boolean' ? options.monitorCommands : false + } + ); + + // Translate any SSL options and other connectivity options + clonedOptions = translateOptions(clonedOptions, options); + + // Socket options + var socketOptions = + options.socketOptions && Object.keys(options.socketOptions).length > 0 + ? options.socketOptions + : options; + + // Translate all the options to the mongodb-core ones + clonedOptions = translateOptions(clonedOptions, socketOptions); + + // Build default client information + clonedOptions.clientInfo = this.clientInfo; + // Do we have an application specific string + if (options.appname) { + clonedOptions.clientInfo.application = { name: options.appname }; + } + + // Define the internal properties + this.s = { + // Create an instance of a server instance from mongodb-core + coreTopology: new CServer(clonedOptions), + // Server capabilities + sCapabilities: null, + // Cloned options + clonedOptions: clonedOptions, + // Reconnect + reconnect: clonedOptions.reconnect, + // Emit error + emitError: clonedOptions.emitError, + // Pool size + poolSize: clonedOptions.size, + // Store Options + storeOptions: storeOptions, + // Store + store: store, + // Host + host: host, + // Port + port: port, + // Options + options: options, + // Server Session Pool + sessionPool: null, + // Active client sessions + sessions: [], + // Promise library + promiseLibrary: promiseLibrary || Promise + }; + } + + // Connect + connect(_options, callback) { + var self = this; + if ('function' === typeof _options) (callback = _options), (_options = {}); + if (_options == null) _options = this.s.clonedOptions; + if (!('function' === typeof callback)) callback = null; + _options = Object.assign({}, this.s.clonedOptions, _options); + self.s.options = _options; + + // Update bufferMaxEntries + self.s.storeOptions.bufferMaxEntries = + typeof _options.bufferMaxEntries === 'number' ? _options.bufferMaxEntries : -1; + + // Error handler + var connectErrorHandler = function() { + return function(err) { + // Remove all event handlers + var events = ['timeout', 'error', 'close']; + events.forEach(function(e) { + self.s.coreTopology.removeListener(e, connectHandlers[e]); + }); + + self.s.coreTopology.removeListener('connect', connectErrorHandler); + + // Try to callback + try { + callback(err); + } catch (err) { + process.nextTick(function() { + throw err; + }); + } + }; + }; + + // Actual handler + var errorHandler = function(event) { + return function(err) { + if (event !== 'error') { + self.emit(event, err); + } + }; + }; + + // Error handler + var reconnectHandler = function() { + self.emit('reconnect', self); + self.s.store.execute(); + }; + + // Reconnect failed + var reconnectFailedHandler = function(err) { + self.emit('reconnectFailed', err); + self.s.store.flush(err); + }; + + // Destroy called on topology, perform cleanup + var destroyHandler = function() { + self.s.store.flush(); + }; + + // relay the event + var relay = function(event) { + return function(t, server) { + self.emit(event, t, server); + }; + }; + + // Connect handler + var connectHandler = function() { + // Clear out all the current handlers left over + ['timeout', 'error', 'close', 'destroy'].forEach(function(e) { + self.s.coreTopology.removeAllListeners(e); + }); + + // Set up listeners + self.s.coreTopology.on('timeout', errorHandler('timeout')); + self.s.coreTopology.once('error', errorHandler('error')); + self.s.coreTopology.on('close', errorHandler('close')); + // Only called on destroy + self.s.coreTopology.on('destroy', destroyHandler); + + // Emit open event + self.emit('open', null, self); + + // Return correctly + try { + callback(null, self); + } catch (err) { + process.nextTick(function() { + throw err; + }); + } + }; + + // Set up listeners + var connectHandlers = { + timeout: connectErrorHandler('timeout'), + error: connectErrorHandler('error'), + close: connectErrorHandler('close') + }; + + // Clear out all the current handlers left over + [ + 'timeout', + 'error', + 'close', + 'serverOpening', + 'serverDescriptionChanged', + 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', + 'serverHeartbeatFailed', + 'serverClosed', + 'topologyOpening', + 'topologyClosed', + 'topologyDescriptionChanged', + 'commandStarted', + 'commandSucceeded', + 'commandFailed' + ].forEach(function(e) { + self.s.coreTopology.removeAllListeners(e); + }); + + // Add the event handlers + self.s.coreTopology.once('timeout', connectHandlers.timeout); + self.s.coreTopology.once('error', connectHandlers.error); + self.s.coreTopology.once('close', connectHandlers.close); + self.s.coreTopology.once('connect', connectHandler); + // Reconnect server + self.s.coreTopology.on('reconnect', reconnectHandler); + self.s.coreTopology.on('reconnectFailed', reconnectFailedHandler); + + // Set up SDAM listeners + self.s.coreTopology.on('serverDescriptionChanged', relay('serverDescriptionChanged')); + self.s.coreTopology.on('serverHeartbeatStarted', relay('serverHeartbeatStarted')); + self.s.coreTopology.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded')); + self.s.coreTopology.on('serverHeartbeatFailed', relay('serverHeartbeatFailed')); + self.s.coreTopology.on('serverOpening', relay('serverOpening')); + self.s.coreTopology.on('serverClosed', relay('serverClosed')); + self.s.coreTopology.on('topologyOpening', relay('topologyOpening')); + self.s.coreTopology.on('topologyClosed', relay('topologyClosed')); + self.s.coreTopology.on('topologyDescriptionChanged', relay('topologyDescriptionChanged')); + self.s.coreTopology.on('commandStarted', relay('commandStarted')); + self.s.coreTopology.on('commandSucceeded', relay('commandSucceeded')); + self.s.coreTopology.on('commandFailed', relay('commandFailed')); + self.s.coreTopology.on('attemptReconnect', relay('attemptReconnect')); + self.s.coreTopology.on('monitoring', relay('monitoring')); + + // Start connection + self.s.coreTopology.connect(_options); + } +} + +Object.defineProperty(Server.prototype, 'poolSize', { + enumerable: true, + get: function() { + return this.s.coreTopology.connections().length; + } +}); + +Object.defineProperty(Server.prototype, 'autoReconnect', { + enumerable: true, + get: function() { + return this.s.reconnect; + } +}); + +Object.defineProperty(Server.prototype, 'host', { + enumerable: true, + get: function() { + return this.s.host; + } +}); + +Object.defineProperty(Server.prototype, 'port', { + enumerable: true, + get: function() { + return this.s.port; + } +}); + +/** + * Server connect event + * + * @event Server#connect + * @type {object} + */ + +/** + * Server close event + * + * @event Server#close + * @type {object} + */ + +/** + * Server reconnect event + * + * @event Server#reconnect + * @type {object} + */ + +/** + * Server error event + * + * @event Server#error + * @type {MongoError} + */ + +/** + * Server timeout event + * + * @event Server#timeout + * @type {object} + */ + +/** + * Server parseError event + * + * @event Server#parseError + * @type {object} + */ + +/** + * An event emitted indicating a command was started, if command monitoring is enabled + * + * @event Server#commandStarted + * @type {object} + */ + +/** + * An event emitted indicating a command succeeded, if command monitoring is enabled + * + * @event Server#commandSucceeded + * @type {object} + */ + +/** + * An event emitted indicating a command failed, if command monitoring is enabled + * + * @event Server#commandFailed + * @type {object} + */ + +module.exports = Server; diff --git a/node_modules/mongodb/lib/topologies/topology_base.js b/node_modules/mongodb/lib/topologies/topology_base.js new file mode 100644 index 0000000..54f848c --- /dev/null +++ b/node_modules/mongodb/lib/topologies/topology_base.js @@ -0,0 +1,446 @@ +'use strict'; + +const EventEmitter = require('events'), + MongoError = require('mongodb-core').MongoError, + f = require('util').format, + os = require('os'), + translateReadPreference = require('../utils').translateReadPreference, + ClientSession = require('mongodb-core').Sessions.ClientSession; + +// The store of ops +var Store = function(topology, storeOptions) { + var self = this; + var storedOps = []; + storeOptions = storeOptions || { force: false, bufferMaxEntries: -1 }; + + // Internal state + this.s = { + storedOps: storedOps, + storeOptions: storeOptions, + topology: topology + }; + + Object.defineProperty(this, 'length', { + enumerable: true, + get: function() { + return self.s.storedOps.length; + } + }); +}; + +Store.prototype.add = function(opType, ns, ops, options, callback) { + if (this.s.storeOptions.force) { + return callback(MongoError.create({ message: 'db closed by application', driver: true })); + } + + if (this.s.storeOptions.bufferMaxEntries === 0) { + return callback( + MongoError.create({ + message: f( + 'no connection available for operation and number of stored operation > %s', + this.s.storeOptions.bufferMaxEntries + ), + driver: true + }) + ); + } + + if ( + this.s.storeOptions.bufferMaxEntries > 0 && + this.s.storedOps.length > this.s.storeOptions.bufferMaxEntries + ) { + while (this.s.storedOps.length > 0) { + var op = this.s.storedOps.shift(); + op.c( + MongoError.create({ + message: f( + 'no connection available for operation and number of stored operation > %s', + this.s.storeOptions.bufferMaxEntries + ), + driver: true + }) + ); + } + + return; + } + + this.s.storedOps.push({ t: opType, n: ns, o: ops, op: options, c: callback }); +}; + +Store.prototype.addObjectAndMethod = function(opType, object, method, params, callback) { + if (this.s.storeOptions.force) { + return callback(MongoError.create({ message: 'db closed by application', driver: true })); + } + + if (this.s.storeOptions.bufferMaxEntries === 0) { + return callback( + MongoError.create({ + message: f( + 'no connection available for operation and number of stored operation > %s', + this.s.storeOptions.bufferMaxEntries + ), + driver: true + }) + ); + } + + if ( + this.s.storeOptions.bufferMaxEntries > 0 && + this.s.storedOps.length > this.s.storeOptions.bufferMaxEntries + ) { + while (this.s.storedOps.length > 0) { + var op = this.s.storedOps.shift(); + op.c( + MongoError.create({ + message: f( + 'no connection available for operation and number of stored operation > %s', + this.s.storeOptions.bufferMaxEntries + ), + driver: true + }) + ); + } + + return; + } + + this.s.storedOps.push({ t: opType, m: method, o: object, p: params, c: callback }); +}; + +Store.prototype.flush = function(err) { + while (this.s.storedOps.length > 0) { + this.s.storedOps + .shift() + .c( + err || + MongoError.create({ message: f('no connection available for operation'), driver: true }) + ); + } +}; + +var primaryOptions = ['primary', 'primaryPreferred', 'nearest', 'secondaryPreferred']; +var secondaryOptions = ['secondary', 'secondaryPreferred']; + +Store.prototype.execute = function(options) { + options = options || {}; + // Get current ops + var ops = this.s.storedOps; + // Reset the ops + this.s.storedOps = []; + + // Unpack options + var executePrimary = typeof options.executePrimary === 'boolean' ? options.executePrimary : true; + var executeSecondary = + typeof options.executeSecondary === 'boolean' ? options.executeSecondary : true; + + // Execute all the stored ops + while (ops.length > 0) { + var op = ops.shift(); + + if (op.t === 'cursor') { + if (executePrimary && executeSecondary) { + op.o[op.m].apply(op.o, op.p); + } else if ( + executePrimary && + op.o.options && + op.o.options.readPreference && + primaryOptions.indexOf(op.o.options.readPreference.mode) !== -1 + ) { + op.o[op.m].apply(op.o, op.p); + } else if ( + !executePrimary && + executeSecondary && + op.o.options && + op.o.options.readPreference && + secondaryOptions.indexOf(op.o.options.readPreference.mode) !== -1 + ) { + op.o[op.m].apply(op.o, op.p); + } + } else if (op.t === 'auth') { + this.s.topology[op.t].apply(this.s.topology, op.o); + } else { + if (executePrimary && executeSecondary) { + this.s.topology[op.t](op.n, op.o, op.op, op.c); + } else if ( + executePrimary && + op.op && + op.op.readPreference && + primaryOptions.indexOf(op.op.readPreference.mode) !== -1 + ) { + this.s.topology[op.t](op.n, op.o, op.op, op.c); + } else if ( + !executePrimary && + executeSecondary && + op.op && + op.op.readPreference && + secondaryOptions.indexOf(op.op.readPreference.mode) !== -1 + ) { + this.s.topology[op.t](op.n, op.o, op.op, op.c); + } + } + } +}; + +Store.prototype.all = function() { + return this.s.storedOps; +}; + +// Server capabilities +var ServerCapabilities = function(ismaster) { + var setup_get_property = function(object, name, value) { + Object.defineProperty(object, name, { + enumerable: true, + get: function() { + return value; + } + }); + }; + + // Capabilities + var aggregationCursor = false; + var writeCommands = false; + var textSearch = false; + var authCommands = false; + var listCollections = false; + var listIndexes = false; + var maxNumberOfDocsInBatch = ismaster.maxWriteBatchSize || 1000; + var commandsTakeWriteConcern = false; + var commandsTakeCollation = false; + + if (ismaster.minWireVersion >= 0) { + textSearch = true; + } + + if (ismaster.maxWireVersion >= 1) { + aggregationCursor = true; + authCommands = true; + } + + if (ismaster.maxWireVersion >= 2) { + writeCommands = true; + } + + if (ismaster.maxWireVersion >= 3) { + listCollections = true; + listIndexes = true; + } + + if (ismaster.maxWireVersion >= 5) { + commandsTakeWriteConcern = true; + commandsTakeCollation = true; + } + + // If no min or max wire version set to 0 + if (ismaster.minWireVersion == null) { + ismaster.minWireVersion = 0; + } + + if (ismaster.maxWireVersion == null) { + ismaster.maxWireVersion = 0; + } + + // Map up read only parameters + setup_get_property(this, 'hasAggregationCursor', aggregationCursor); + setup_get_property(this, 'hasWriteCommands', writeCommands); + setup_get_property(this, 'hasTextSearch', textSearch); + setup_get_property(this, 'hasAuthCommands', authCommands); + setup_get_property(this, 'hasListCollectionsCommand', listCollections); + setup_get_property(this, 'hasListIndexesCommand', listIndexes); + setup_get_property(this, 'minWireVersion', ismaster.minWireVersion); + setup_get_property(this, 'maxWireVersion', ismaster.maxWireVersion); + setup_get_property(this, 'maxNumberOfDocsInBatch', maxNumberOfDocsInBatch); + setup_get_property(this, 'commandsTakeWriteConcern', commandsTakeWriteConcern); + setup_get_property(this, 'commandsTakeCollation', commandsTakeCollation); +}; + +// Get package.json variable +const driverVersion = require('../../package.json').version, + nodejsversion = f('Node.js %s, %s', process.version, os.endianness()), + type = os.type(), + name = process.platform, + architecture = process.arch, + release = os.release(); + +class TopologyBase extends EventEmitter { + constructor() { + super(); + + // Build default client information + this.clientInfo = { + driver: { + name: 'nodejs', + version: driverVersion + }, + os: { + type: type, + name: name, + architecture: architecture, + version: release + }, + platform: nodejsversion + }; + + this.setMaxListeners(Infinity); + } + + // Sessions related methods + hasSessionSupport() { + return this.logicalSessionTimeoutMinutes != null; + } + + startSession(options, clientOptions) { + const session = new ClientSession(this, this.s.sessionPool, options, clientOptions); + session.once('ended', () => { + this.s.sessions = this.s.sessions.filter(s => !s.equals(session)); + }); + + this.s.sessions.push(session); + return session; + } + + endSessions(sessions, callback) { + return this.s.coreTopology.endSessions(sessions, callback); + } + + // Server capabilities + capabilities() { + if (this.s.sCapabilities) return this.s.sCapabilities; + if (this.s.coreTopology.lastIsMaster() == null) return null; + this.s.sCapabilities = new ServerCapabilities(this.s.coreTopology.lastIsMaster()); + return this.s.sCapabilities; + } + + // Command + command(ns, cmd, options, callback) { + this.s.coreTopology.command(ns, cmd, translateReadPreference(options), callback); + } + + // Insert + insert(ns, ops, options, callback) { + this.s.coreTopology.insert(ns, ops, options, callback); + } + + // Update + update(ns, ops, options, callback) { + this.s.coreTopology.update(ns, ops, options, callback); + } + + // Remove + remove(ns, ops, options, callback) { + this.s.coreTopology.remove(ns, ops, options, callback); + } + + // IsConnected + isConnected(options) { + options = options || {}; + options = translateReadPreference(options); + + return this.s.coreTopology.isConnected(options); + } + + // IsDestroyed + isDestroyed() { + return this.s.coreTopology.isDestroyed(); + } + + // Cursor + cursor(ns, cmd, options) { + options = options || {}; + options = translateReadPreference(options); + options.disconnectHandler = this.s.store; + options.topology = this; + + return this.s.coreTopology.cursor(ns, cmd, options); + } + + lastIsMaster() { + return this.s.coreTopology.lastIsMaster(); + } + + selectServer(selector, options, callback) { + return this.s.coreTopology.selectServer(selector, options, callback); + } + + /** + * Unref all sockets + * @method + */ + unref() { + return this.s.coreTopology.unref(); + } + + auth() { + var args = Array.prototype.slice.call(arguments, 0); + this.s.coreTopology.auth.apply(this.s.coreTopology, args); + } + + logout() { + var args = Array.prototype.slice.call(arguments, 0); + this.s.coreTopology.logout.apply(this.s.coreTopology, args); + } + + /** + * All raw connections + * @method + * @return {array} + */ + connections() { + return this.s.coreTopology.connections(); + } + + close(forceClosed) { + // If we have sessions, we want to individually move them to the session pool, + // and then send a single endSessions call. + if (this.s.sessions.length) { + this.s.sessions.forEach(session => session.endSession()); + } + + if (this.s.sessionPool) { + this.s.sessionPool.endAllPooledSessions(); + } + + this.s.coreTopology.destroy({ + force: typeof forceClosed === 'boolean' ? forceClosed : false + }); + + // We need to wash out all stored processes + if (forceClosed === true) { + this.s.storeOptions.force = forceClosed; + this.s.store.flush(); + } + } +} + +// Properties +Object.defineProperty(TopologyBase.prototype, 'bson', { + enumerable: true, + get: function() { + return this.s.coreTopology.s.bson; + } +}); + +Object.defineProperty(TopologyBase.prototype, 'parserType', { + enumerable: true, + get: function() { + return this.s.coreTopology.parserType; + } +}); + +Object.defineProperty(TopologyBase.prototype, 'logicalSessionTimeoutMinutes', { + enumerable: true, + get: function() { + return this.s.coreTopology.logicalSessionTimeoutMinutes; + } +}); + +Object.defineProperty(TopologyBase.prototype, 'type', { + enumerable: true, + get: function() { + return this.s.coreTopology.type; + } +}); + +exports.Store = Store; +exports.ServerCapabilities = ServerCapabilities; +exports.TopologyBase = TopologyBase; diff --git a/node_modules/mongodb/lib/url_parser.js b/node_modules/mongodb/lib/url_parser.js index 963cdbe..7cc0b2f 100644 --- a/node_modules/mongodb/lib/url_parser.js +++ b/node_modules/mongodb/lib/url_parser.js @@ -1,113 +1,130 @@ -"use strict"; +'use strict'; -var ReadPreference = require('./read_preference'), +const ReadPreference = require('mongodb-core').ReadPreference, parser = require('url'), f = require('util').format, - assign = require('./utils').assign, + Logger = require('mongodb-core').Logger, dns = require('dns'); module.exports = function(url, options, callback) { if (typeof options === 'function') (callback = options), (options = {}); options = options || {}; - var result = parser.parse(url, true); + let result; + try { + result = parser.parse(url, true); + } catch (e) { + return callback(new Error('URL malformed, cannot be parsed')); + } + if (result.protocol !== 'mongodb:' && result.protocol !== 'mongodb+srv:') { - return callback(new Error('invalid schema, expected mongodb or mongodb+srv')); + return callback(new Error('Invalid schema, expected `mongodb` or `mongodb+srv`')); } - if (result.protocol === 'mongodb+srv:') { + if (result.protocol === 'mongodb:') { + return parseHandler(url, options, callback); + } - if (result.hostname.split('.').length < 3) { - return callback(new Error('uri does not have hostname, domainname and tld')); - } + // Otherwise parse this as an SRV record + if (result.hostname.split('.').length < 3) { + return callback(new Error('URI does not have hostname, domain name and tld')); + } - result.domainLength = result.hostname.split('.').length; + result.domainLength = result.hostname.split('.').length; - if (result.pathname && result.pathname.match(',')) { - return callback(new Error('invalid uri, cannot contain multiple hostnames')); - } + if (result.pathname && result.pathname.match(',')) { + return callback(new Error('Invalid URI, cannot contain multiple hostnames')); + } - if (result.port) { - return callback(new Error('Ports not accepted with mongodb+srv')); - } + if (result.port) { + return callback(new Error('Ports not accepted with `mongodb+srv` URIs')); + } - var srvAddress = '_mongodb._tcp.' + result.host; - dns.resolveSrv(srvAddress, function(err, addresses) { - if (err) return callback(err); + let srvAddress = `_mongodb._tcp.${result.host}`; + dns.resolveSrv(srvAddress, function(err, addresses) { + if (err) return callback(err); - if (addresses.length === 0) { - return callback(new Error('No addresses found at host')); - } + if (addresses.length === 0) { + return callback(new Error('No addresses found at host')); + } - for (var i = 0; i < addresses.length; i++) { - if (!matchesParentDomain(addresses[i].name, result.hostname, result.domainLength)) { - return callback(new Error('srv record does not share hostname with parent uri')); - } + for (let i = 0; i < addresses.length; i++) { + if (!matchesParentDomain(addresses[i].name, result.hostname, result.domainLength)) { + return callback(new Error('Server record does not share hostname with parent URI')); } + } - var connectionStrings = addresses.map(function(address, i) { - if (i === 0) return 'mongodb://' + address.name + ':' + address.port; - else return address.name + ':' + address.port; - }); - - var connectionString = connectionStrings.join(',') + '/'; - var connectionStringOptions = []; + let base = result.auth ? `mongodb://${result.auth}@` : `mongodb://`; + let connectionStrings = addresses.map(function(address, i) { + if (i === 0) return `${base}${address.name}:${address.port}`; + else return `${address.name}:${address.port}`; + }); - // Default to SSL true - if (!options.ssl && !result.search) { - connectionStringOptions.push('ssl=true'); - } else if (!options.ssl && result.search && !result.search.match('ssl')) { - connectionStringOptions.push('ssl=true'); - } + let connectionString = connectionStrings.join(',') + '/'; + let connectionStringOptions = []; - // Keep original uri options - if (result.search) { - connectionStringOptions.push(result.search.replace('?', '')); + // Add the default database if needed + if (result.path) { + let defaultDb = result.path.slice(1); + if (defaultDb.indexOf('?') !== -1) { + defaultDb = defaultDb.slice(0, defaultDb.indexOf('?')); } - dns.resolveTxt(result.host, function(err, record) { - if (err && err.code !== 'ENODATA') return callback(err); - if (err && err.code === 'ENODATA') record = null; + connectionString += defaultDb; + } - if (record) { - if (record.length > 1) { - return callback(new Error('multiple text records not allowed')); - } + // Default to SSL true + if (!options.ssl && !result.search) { + connectionStringOptions.push('ssl=true'); + } else if (!options.ssl && result.search && !result.search.match('ssl')) { + connectionStringOptions.push('ssl=true'); + } - record = record[0]; - if (record.length > 1) record = record.join(''); - else record = record[0]; + // Keep original uri options + if (result.search) { + connectionStringOptions.push(result.search.replace('?', '')); + } - if (!record.includes('authSource') && !record.includes('replicaSet')) { - return callback(new Error('text record must only set `authSource` or `replicaSet`')); - } + dns.resolveTxt(result.host, function(err, record) { + if (err && err.code !== 'ENODATA') return callback(err); + if (err && err.code === 'ENODATA') record = null; - connectionStringOptions.push(record); + if (record) { + if (record.length > 1) { + return callback(new Error('Multiple text records not allowed')); } - // Add any options to the connection string - if (connectionStringOptions.length) { - connectionString += '?' + connectionStringOptions.join('&'); + record = record[0]; + if (record.length > 1) record = record.join(''); + else record = record[0]; + + if (!record.includes('authSource') && !record.includes('replicaSet')) { + return callback(new Error('Text record must only set `authSource` or `replicaSet`')); } - parseHandler(connectionString, options, callback); - }); + connectionStringOptions.push(record); + } + + // Add any options to the connection string + if (connectionStringOptions.length) { + connectionString += `?${connectionStringOptions.join('&')}`; + } + + parseHandler(connectionString, options, callback); }); - } else { - parseHandler(url, options, callback); - } + }); }; function matchesParentDomain(srvAddress, parentDomain) { - var regex = /^.*?\./; - var srv = '.' + srvAddress.replace(regex, ''); - var parent = '.' + parentDomain.replace(regex, ''); + let regex = /^.*?\./; + let srv = `.${srvAddress.replace(regex, '')}`; + let parent = `.${parentDomain.replace(regex, '')}`; if (srv.endsWith(parent)) return true; else return false; } function parseHandler(address, options, callback) { - var result, err; + let result, err; try { result = parseConnectionString(address, options); } catch (e) { @@ -119,157 +136,184 @@ function parseHandler(address, options, callback) { function parseConnectionString(url, options) { // Variables - var connection_part = ''; - var auth_part = ''; - var query_string_part = ''; - var dbName = 'admin'; + let connection_part = ''; + let auth_part = ''; + let query_string_part = ''; + let dbName = 'admin'; // Url parser result - var result = parser.parse(url, true); - - if((result.hostname == null || result.hostname == '') && url.indexOf('.sock') == -1) { - throw new Error('no hostname or hostnames provided in connection string'); + let result = parser.parse(url, true); + if ((result.hostname == null || result.hostname === '') && url.indexOf('.sock') === -1) { + throw new Error('No hostname or hostnames provided in connection string'); } - if(result.port == '0') { - throw new Error('invalid port (zero) with hostname'); + if (result.port === '0') { + throw new Error('Invalid port (zero) with hostname'); } - if(!isNaN(parseInt(result.port, 10)) && parseInt(result.port, 10) > 65535) { - throw new Error('invalid port (larger than 65535) with hostname'); + if (!isNaN(parseInt(result.port, 10)) && parseInt(result.port, 10) > 65535) { + throw new Error('Invalid port (larger than 65535) with hostname'); } - if(result.path - && result.path.length > 0 - && result.path[0] != '/' - && url.indexOf('.sock') == -1) { - throw new Error('missing delimiting slash between hosts and options'); + if ( + result.path && + result.path.length > 0 && + result.path[0] !== '/' && + url.indexOf('.sock') === -1 + ) { + throw new Error('Missing delimiting slash between hosts and options'); } - if(result.query) { - for(var name in result.query) { - if(name.indexOf('::') != -1) { - throw new Error('double colon in host identifier'); + if (result.query) { + for (let name in result.query) { + if (name.indexOf('::') !== -1) { + throw new Error('Double colon in host identifier'); } - if(result.query[name] == '') { - throw new Error('query parameter ' + name + ' is an incomplete value pair'); + if (result.query[name] === '') { + throw new Error('Query parameter ' + name + ' is an incomplete value pair'); } } } - if(result.auth) { - var parts = result.auth.split(':'); - if(url.indexOf(result.auth) != -1 && parts.length > 2) { + if (result.auth) { + let parts = result.auth.split(':'); + if (url.indexOf(result.auth) !== -1 && parts.length > 2) { throw new Error('Username with password containing an unescaped colon'); } - if(url.indexOf(result.auth) != -1 && result.auth.indexOf('@') != -1) { + if (url.indexOf(result.auth) !== -1 && result.auth.indexOf('@') !== -1) { throw new Error('Username containing an unescaped at-sign'); } } // Remove query - var clean = url.split('?').shift(); + let clean = url.split('?').shift(); // Extract the list of hosts - var strings = clean.split(','); - var hosts = []; + let strings = clean.split(','); + let hosts = []; - for(var i = 0; i < strings.length; i++) { - var hostString = strings[i]; + for (let i = 0; i < strings.length; i++) { + let hostString = strings[i]; - if(hostString.indexOf('mongodb') != -1) { - if(hostString.indexOf('@') != -1) { - hosts.push(hostString.split('@').pop()) + if (hostString.indexOf('mongodb') !== -1) { + if (hostString.indexOf('@') !== -1) { + hosts.push(hostString.split('@').pop()); } else { hosts.push(hostString.substr('mongodb://'.length)); } - } else if(hostString.indexOf('/') != -1) { + } else if (hostString.indexOf('/') !== -1) { hosts.push(hostString.split('/').shift()); - } else if(hostString.indexOf('/') == -1) { + } else if (hostString.indexOf('/') === -1) { hosts.push(hostString.trim()); } } - for(i = 0; i < hosts.length; i++) { - var r = parser.parse(f('mongodb://%s', hosts[i].trim())); - if(r.path && r.path.indexOf(':') != -1) { + for (let i = 0; i < hosts.length; i++) { + let r = parser.parse(f('mongodb://%s', hosts[i].trim())); + if (r.path && r.path.indexOf('.sock') !== -1) continue; + if (r.path && r.path.indexOf(':') !== -1) { // Not connecting to a socket so check for an extra slash in the hostname. // Using String#split as perf is better than match. - if (r.path.split('/').length > 1) { - throw new Error('slash in host identifier'); + if (r.path.split('/').length > 1 && r.path.indexOf('::') === -1) { + throw new Error('Slash in host identifier'); } else { - throw new Error('double colon in host identifier'); + throw new Error('Double colon in host identifier'); } } } // If we have a ? mark cut the query elements off - if(url.indexOf("?") != -1) { - query_string_part = url.substr(url.indexOf("?") + 1); - connection_part = url.substring("mongodb://".length, url.indexOf("?")) + if (url.indexOf('?') !== -1) { + query_string_part = url.substr(url.indexOf('?') + 1); + connection_part = url.substring('mongodb://'.length, url.indexOf('?')); } else { - connection_part = url.substring("mongodb://".length); + connection_part = url.substring('mongodb://'.length); } // Check if we have auth params - if(connection_part.indexOf("@") != -1) { - auth_part = connection_part.split("@")[0]; - connection_part = connection_part.split("@")[1]; + if (connection_part.indexOf('@') !== -1) { + auth_part = connection_part.split('@')[0]; + connection_part = connection_part.split('@')[1]; + } + + // Check there is not more than one unescaped slash + if (connection_part.split('/').length > 2) { + throw new Error( + "Unsupported host '" + + connection_part.split('?')[0] + + "', hosts must be URL encoded and contain at most one unencoded slash" + ); } // Check if the connection string has a db - if(connection_part.indexOf(".sock") != -1) { - if(connection_part.indexOf(".sock/") != -1) { - dbName = connection_part.split(".sock/")[1]; + if (connection_part.indexOf('.sock') !== -1) { + if (connection_part.indexOf('.sock/') !== -1) { + dbName = connection_part.split('.sock/')[1]; // Check if multiple database names provided, or just an illegal trailing backslash - if (dbName.indexOf("/") != -1) { - if (dbName.split("/").length == 2 && dbName.split("/")[1].length == 0) { + if (dbName.indexOf('/') !== -1) { + if (dbName.split('/').length === 2 && dbName.split('/')[1].length === 0) { throw new Error('Illegal trailing backslash after database name'); } throw new Error('More than 1 database name in URL'); } - connection_part = connection_part.split("/", connection_part.indexOf(".sock") + ".sock".length); + connection_part = connection_part.split( + '/', + connection_part.indexOf('.sock') + '.sock'.length + ); } - } else if(connection_part.indexOf("/") != -1) { + } else if (connection_part.indexOf('/') !== -1) { // Check if multiple database names provided, or just an illegal trailing backslash - if (connection_part.split("/").length > 2) { - if (connection_part.split("/")[2].length == 0) { + if (connection_part.split('/').length > 2) { + if (connection_part.split('/')[2].length === 0) { throw new Error('Illegal trailing backslash after database name'); } throw new Error('More than 1 database name in URL'); } - dbName = connection_part.split("/")[1]; - connection_part = connection_part.split("/")[0]; + dbName = connection_part.split('/')[1]; + connection_part = connection_part.split('/')[0]; } + // URI decode the host information + connection_part = decodeURIComponent(connection_part); + // Result object - var object = {}; + let object = {}; // Pick apart the authentication part of the string - var authPart = auth_part || ''; - var auth = authPart.split(':', 2); + let authPart = auth_part || ''; + let auth = authPart.split(':', 2); - // Decode the URI components - auth[0] = decodeURIComponent(auth[0]); - if(auth[1]){ - auth[1] = decodeURIComponent(auth[1]); + // Decode the authentication URI components and verify integrity + let user = decodeURIComponent(auth[0]); + if (auth[0] !== encodeURIComponent(user)) { + throw new Error('Username contains an illegal unescaped character'); + } + auth[0] = user; + + if (auth[1]) { + let pass = decodeURIComponent(auth[1]); + if (auth[1] !== encodeURIComponent(pass)) { + throw new Error('Password contains an illegal unescaped character'); + } + auth[1] = pass; } // Add auth to final object if we have 2 elements - if(auth.length == 2) object.auth = {user: auth[0], password: auth[1]}; + if (auth.length === 2) object.auth = { user: auth[0], password: auth[1] }; // if user provided auth options, use that - if(options && options.auth != null) object.auth = options.auth; + if (options && options.auth != null) object.auth = options.auth; // Variables used for temporary storage - var hostPart; - var urlOptions; - var servers; - var serverOptions = {socketOptions: {}}; - var dbOptions = {read_preference_tags: []}; - var replSetServersOptions = {socketOptions: {}}; - var mongosOptions = {socketOptions: {}}; + let hostPart; + let urlOptions; + let servers; + let compression; + let serverOptions = { socketOptions: {} }; + let dbOptions = { read_preference_tags: [] }; + let replSetServersOptions = { socketOptions: {} }; + let mongosOptions = { socketOptions: {} }; // Add server options to final object object.server_options = serverOptions; object.db_options = dbOptions; @@ -277,45 +321,50 @@ function parseConnectionString(url, options) { object.mongos_options = mongosOptions; // Let's check if we are using a domain socket - if(url.match(/\.sock/)) { + if (url.match(/\.sock/)) { // Split out the socket part - var domainSocket = url.substring( - url.indexOf("mongodb://") + "mongodb://".length - , url.lastIndexOf(".sock") + ".sock".length); + let domainSocket = url.substring( + url.indexOf('mongodb://') + 'mongodb://'.length, + url.lastIndexOf('.sock') + '.sock'.length + ); // Clean out any auth stuff if any - if(domainSocket.indexOf("@") != -1) domainSocket = domainSocket.split("@")[1]; - servers = [{domain_socket: domainSocket}]; + if (domainSocket.indexOf('@') !== -1) domainSocket = domainSocket.split('@')[1]; + domainSocket = decodeURIComponent(domainSocket); + servers = [{ domain_socket: domainSocket }]; } else { // Split up the db hostPart = connection_part; // Deduplicate servers - var deduplicatedServers = {}; + let deduplicatedServers = {}; // Parse all server results - servers = hostPart.split(',').map(function(h) { - var _host, _port, ipv6match; - //check if it matches [IPv6]:port, where the port number is optional - if ((ipv6match = /\[([^\]]+)\](?:\:(.+))?/.exec(h))) { - _host = ipv6match[1]; - _port = parseInt(ipv6match[2], 10) || 27017; - } else { - //otherwise assume it's IPv4, or plain hostname - var hostPort = h.split(':', 2); - _host = hostPort[0] || 'localhost'; - _port = hostPort[1] != null ? parseInt(hostPort[1], 10) : 27017; - // Check for localhost?safe=true style case - if(_host.indexOf("?") != -1) _host = _host.split(/\?/)[0]; - } + servers = hostPart + .split(',') + .map(function(h) { + let _host, _port, ipv6match; + //check if it matches [IPv6]:port, where the port number is optional + if ((ipv6match = /\[([^\]]+)\](?::(.+))?/.exec(h))) { + _host = ipv6match[1]; + _port = parseInt(ipv6match[2], 10) || 27017; + } else { + //otherwise assume it's IPv4, or plain hostname + let hostPort = h.split(':', 2); + _host = hostPort[0] || 'localhost'; + _port = hostPort[1] != null ? parseInt(hostPort[1], 10) : 27017; + // Check for localhost?safe=true style case + if (_host.indexOf('?') !== -1) _host = _host.split(/\?/)[0]; + } - // No entry returned for duplicate server - if(deduplicatedServers[_host + "_" + _port]) return null; - deduplicatedServers[_host + "_" + _port] = 1; + // No entry returned for duplicate servr + if (deduplicatedServers[_host + '_' + _port]) return null; + deduplicatedServers[_host + '_' + _port] = 1; - // Return the mapped object - return {host: _host, port: _port}; - }).filter(function(x) { - return x != null; - }); + // Return the mapped object + return { host: _host, port: _port }; + }) + .filter(function(x) { + return x != null; + }); } // Get the db name @@ -324,14 +373,17 @@ function parseConnectionString(url, options) { urlOptions = (query_string_part || '').split(/[&;]/); // Ugh, we have to figure out which options go to which constructor manually. urlOptions.forEach(function(opt) { - if(!opt) return; - var splitOpt = opt.split('='), name = splitOpt[0], value = splitOpt[1]; + if (!opt) return; + var splitOpt = opt.split('='), + name = splitOpt[0], + value = splitOpt[1]; + // Options implementations - switch(name) { + switch (name) { case 'slaveOk': case 'slave_ok': - serverOptions.slave_ok = (value == 'true'); - dbOptions.slaveOk = (value == 'true'); + serverOptions.slave_ok = value === 'true'; + dbOptions.slaveOk = value === 'true'; break; case 'maxPoolSize': case 'poolSize': @@ -343,33 +395,23 @@ function parseConnectionString(url, options) { break; case 'autoReconnect': case 'auto_reconnect': - serverOptions.auto_reconnect = (value == 'true'); + serverOptions.auto_reconnect = value === 'true'; break; - case 'minPoolSize': - throw new Error("minPoolSize not supported"); - case 'maxIdleTimeMS': - throw new Error("maxIdleTimeMS not supported"); - case 'waitQueueMultiple': - throw new Error("waitQueueMultiple not supported"); - case 'waitQueueTimeoutMS': - throw new Error("waitQueueTimeoutMS not supported"); - case 'uuidRepresentation': - throw new Error("uuidRepresentation not supported"); case 'ssl': - if(value == 'prefer') { + if (value === 'prefer') { serverOptions.ssl = value; replSetServersOptions.ssl = value; mongosOptions.ssl = value; break; } - serverOptions.ssl = (value == 'true'); - replSetServersOptions.ssl = (value == 'true'); - mongosOptions.ssl = (value == 'true'); + serverOptions.ssl = value === 'true'; + replSetServersOptions.ssl = value === 'true'; + mongosOptions.ssl = value === 'true'; break; case 'sslValidate': - serverOptions.sslValidate = (value == 'true'); - replSetServersOptions.sslValidate = (value == 'true'); - mongosOptions.sslValidate = (value == 'true'); + serverOptions.sslValidate = value === 'true'; + replSetServersOptions.sslValidate = value === 'true'; + mongosOptions.sslValidate = value === 'true'; break; case 'replicaSet': case 'rs_name': @@ -383,23 +425,23 @@ function parseConnectionString(url, options) { break; case 'readSecondary': case 'read_secondary': - replSetServersOptions.read_secondary = (value == 'true'); + replSetServersOptions.read_secondary = value === 'true'; break; case 'fsync': - dbOptions.fsync = (value == 'true'); + dbOptions.fsync = value === 'true'; break; case 'journal': - dbOptions.j = (value == 'true'); + dbOptions.j = value === 'true'; break; case 'safe': - dbOptions.safe = (value == 'true'); + dbOptions.safe = value === 'true'; break; case 'nativeParser': case 'native_parser': - dbOptions.native_parser = (value == 'true'); + dbOptions.native_parser = value === 'true'; break; case 'readConcernLevel': - dbOptions.readConcern = {level: value}; + dbOptions.readConcern = { level: value }; break; case 'connectTimeoutMS': serverOptions.socketOptions.connectTimeoutMS = parseInt(value, 10); @@ -413,7 +455,7 @@ function parseConnectionString(url, options) { break; case 'w': dbOptions.w = parseInt(value, 10); - if(isNaN(dbOptions.w)) dbOptions.w = value; + if (isNaN(dbOptions.w)) dbOptions.w = value; break; case 'authSource': dbOptions.authSource = value; @@ -422,101 +464,155 @@ function parseConnectionString(url, options) { dbOptions.gssapiServiceName = value; break; case 'authMechanism': - if(value == 'GSSAPI') { + if (value === 'GSSAPI') { // If no password provided decode only the principal - if(object.auth == null) { - var urlDecodeAuthPart = decodeURIComponent(authPart); - if(urlDecodeAuthPart.indexOf("@") == -1) throw new Error("GSSAPI requires a provided principal"); - object.auth = {user: urlDecodeAuthPart, password: null}; + if (object.auth == null) { + let urlDecodeAuthPart = decodeURIComponent(authPart); + if (urlDecodeAuthPart.indexOf('@') === -1) + throw new Error('GSSAPI requires a provided principal'); + object.auth = { user: urlDecodeAuthPart, password: null }; } else { object.auth.user = decodeURIComponent(object.auth.user); } - } else if(value == 'MONGODB-X509') { - object.auth = {user: decodeURIComponent(authPart)}; + } else if (value === 'MONGODB-X509') { + object.auth = { user: decodeURIComponent(authPart) }; } // Only support GSSAPI or MONGODB-CR for now - if(value != 'GSSAPI' - && value != 'MONGODB-X509' - && value != 'MONGODB-CR' - && value != 'DEFAULT' - && value != 'SCRAM-SHA-1' - && value != 'PLAIN') - throw new Error("only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, SCRAM-SHA-1 or MONGODB-CR is supported by authMechanism"); + if ( + value !== 'GSSAPI' && + value !== 'MONGODB-X509' && + value !== 'MONGODB-CR' && + value !== 'DEFAULT' && + value !== 'SCRAM-SHA-1' && + value !== 'SCRAM-SHA-256' && + value !== 'PLAIN' + ) + throw new Error( + 'Only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 is supported by authMechanism' + ); // Authentication mechanism dbOptions.authMechanism = value; break; case 'authMechanismProperties': - // Split up into key, value pairs - var values = value.split(','); - var o = {}; - // For each value split into key, value - values.forEach(function(x) { - var v = x.split(':'); - o[v[0]] = v[1]; - }); - - // Set all authMechanismProperties - dbOptions.authMechanismProperties = o; - // Set the service name value - if(typeof o.SERVICE_NAME == 'string') dbOptions.gssapiServiceName = o.SERVICE_NAME; - if(typeof o.SERVICE_REALM == 'string') dbOptions.gssapiServiceRealm = o.SERVICE_REALM; - if(typeof o.CANONICALIZE_HOST_NAME == 'string') dbOptions.gssapiCanonicalizeHostName = o.CANONICALIZE_HOST_NAME == 'true' ? true : false; + { + // Split up into key, value pairs + let values = value.split(','); + let o = {}; + // For each value split into key, value + values.forEach(function(x) { + let v = x.split(':'); + o[v[0]] = v[1]; + }); + + // Set all authMechanismProperties + dbOptions.authMechanismProperties = o; + // Set the service name value + if (typeof o.SERVICE_NAME === 'string') dbOptions.gssapiServiceName = o.SERVICE_NAME; + if (typeof o.SERVICE_REALM === 'string') dbOptions.gssapiServiceRealm = o.SERVICE_REALM; + if (typeof o.CANONICALIZE_HOST_NAME === 'string') + dbOptions.gssapiCanonicalizeHostName = + o.CANONICALIZE_HOST_NAME === 'true' ? true : false; + } break; case 'wtimeoutMS': dbOptions.wtimeout = parseInt(value, 10); break; case 'readPreference': - if(!ReadPreference.isValid(value)) throw new Error("readPreference must be either primary/primaryPreferred/secondary/secondaryPreferred/nearest"); + if (!ReadPreference.isValid(value)) + throw new Error( + 'readPreference must be either primary/primaryPreferred/secondary/secondaryPreferred/nearest' + ); dbOptions.readPreference = value; break; case 'maxStalenessSeconds': dbOptions.maxStalenessSeconds = parseInt(value, 10); break; case 'readPreferenceTags': - // Decode the value - value = decodeURIComponent(value); - // Contains the tag object - var tagObject = {}; - if(value == null || value == '') { + { + // Decode the value + value = decodeURIComponent(value); + // Contains the tag object + let tagObject = {}; + if (value == null || value === '') { + dbOptions.read_preference_tags.push(tagObject); + break; + } + + // Split up the tags + let tags = value.split(/,/); + for (let i = 0; i < tags.length; i++) { + let parts = tags[i].trim().split(/:/); + tagObject[parts[0]] = parts[1]; + } + + // Set the preferences tags dbOptions.read_preference_tags.push(tagObject); - break; } + break; + case 'compressors': + { + compression = serverOptions.compression || {}; + let compressors = value.split(','); + if ( + !compressors.every(function(compressor) { + return compressor === 'snappy' || compressor === 'zlib'; + }) + ) { + throw new Error('Compressors must be at least one of snappy or zlib'); + } - // Split up the tags - var tags = value.split(/\,/); - for(var i = 0; i < tags.length; i++) { - var parts = tags[i].trim().split(/\:/); - tagObject[parts[0]] = parts[1]; + compression.compressors = compressors; + serverOptions.compression = compression; } + break; + case 'zlibCompressionLevel': + { + compression = serverOptions.compression || {}; + let zlibCompressionLevel = parseInt(value, 10); + if (zlibCompressionLevel < -1 || zlibCompressionLevel > 9) { + throw new Error('zlibCompressionLevel must be an integer between -1 and 9'); + } - // Set the preferences tags - dbOptions.read_preference_tags.push(tagObject); + compression.zlibCompressionLevel = zlibCompressionLevel; + serverOptions.compression = compression; + } + break; + case 'retryWrites': + dbOptions.retryWrites = value === 'true'; + break; + case 'minSize': + dbOptions.minSize = parseInt(value, 10); break; default: + { + let logger = Logger('URL Parser'); + logger.warn(`${name} is not supported as a connection string option`); + } break; } }); // No tags: should be null (not []) - if(dbOptions.read_preference_tags.length === 0) { + if (dbOptions.read_preference_tags.length === 0) { dbOptions.read_preference_tags = null; } // Validate if there are an invalid write concern combinations - if((dbOptions.w == -1 || dbOptions.w == 0) && ( - dbOptions.journal == true - || dbOptions.fsync == true - || dbOptions.safe == true)) throw new Error("w set to -1 or 0 cannot be combined with safe/w/journal/fsync") + if ( + (dbOptions.w === -1 || dbOptions.w === 0) && + (dbOptions.journal === true || dbOptions.fsync === true || dbOptions.safe === true) + ) + throw new Error('w set to -1 or 0 cannot be combined with safe/w/journal/fsync'); // If no read preference set it to primary - if(!dbOptions.readPreference) { + if (!dbOptions.readPreference) { dbOptions.readPreference = 'primary'; } // make sure that user-provided options are applied with priority - dbOptions = assign(dbOptions, options); + dbOptions = Object.assign(dbOptions, options); // Add servers to result object.servers = servers; diff --git a/node_modules/mongodb/lib/utils.js b/node_modules/mongodb/lib/utils.js index c4efe49..ea79f4b 100644 --- a/node_modules/mongodb/lib/utils.js +++ b/node_modules/mongodb/lib/utils.js @@ -1,50 +1,51 @@ -"use strict"; +'use strict'; -var MongoError = require('mongodb-core').MongoError, - ReadPreference = require('./read_preference'), - CoreReadPreference = require('mongodb-core').ReadPreference; +const MongoError = require('mongodb-core').MongoError; +const ReadPreference = require('mongodb-core').ReadPreference; var shallowClone = function(obj) { var copy = {}; - for(var name in obj) copy[name] = obj[name]; + for (var name in obj) copy[name] = obj[name]; return copy; -} +}; // Figure out the read preference -var getReadPreference = function(options) { - var r = null - if(options.readPreference) { - r = options.readPreference +var translateReadPreference = function(options) { + var r = null; + if (options.readPreference) { + r = options.readPreference; } else { return options; } - if(r instanceof ReadPreference) { - options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); - } else if(typeof r == 'string') { - options.readPreference = new CoreReadPreference(r); - } else if(r && !(r instanceof ReadPreference) && typeof r == 'object') { - var mode = r.mode || r.preference; - if (mode && typeof mode == 'string') { - options.readPreference = new CoreReadPreference(mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + if (typeof r === 'string') { + options.readPreference = new ReadPreference(r); + } else if (r && !(r instanceof ReadPreference) && typeof r === 'object') { + const mode = r.mode || r.preference; + if (mode && typeof mode === 'string') { + options.readPreference = new ReadPreference(mode, r.tags, { + maxStalenessSeconds: r.maxStalenessSeconds + }); } + } else if (!(r instanceof ReadPreference)) { + throw new TypeError('Invalid read preference: ' + r); } return options; -} +}; // Set simple property var getSingleProperty = function(obj, name, value) { Object.defineProperty(obj, name, { - enumerable:true, + enumerable: true, get: function() { - return value + return value; } }); -} +}; -var formatSortValue = exports.formatSortValue = function(sortDirection) { - var value = ("" + sortDirection).toLowerCase(); +var formatSortValue = (exports.formatSortValue = function(sortDirection) { + var value = ('' + sortDirection).toLowerCase(); switch (value) { case 'ascending': @@ -56,76 +57,85 @@ var formatSortValue = exports.formatSortValue = function(sortDirection) { case '-1': return -1; default: - throw new Error("Illegal sort clause, must be of the form " - + "[['field1', '(ascending|descending)'], " - + "['field2', '(ascending|descending)']]"); + throw new Error( + 'Illegal sort clause, must be of the form ' + + "[['field1', '(ascending|descending)'], " + + "['field2', '(ascending|descending)']]" + ); } -}; +}); -var formattedOrderClause = exports.formattedOrderClause = function(sortValue) { +var formattedOrderClause = (exports.formattedOrderClause = function(sortValue) { var orderBy = {}; - if(sortValue == null) return null; + if (sortValue == null) return null; if (Array.isArray(sortValue)) { - if(sortValue.length === 0) { + if (sortValue.length === 0) { return null; } - for(var i = 0; i < sortValue.length; i++) { - if(sortValue[i].constructor == String) { + for (var i = 0; i < sortValue.length; i++) { + if (sortValue[i].constructor === String) { orderBy[sortValue[i]] = 1; } else { orderBy[sortValue[i][0]] = formatSortValue(sortValue[i][1]); } } - } else if(sortValue != null && typeof sortValue == 'object') { + } else if (sortValue != null && typeof sortValue === 'object') { orderBy = sortValue; - } else if (typeof sortValue == 'string') { + } else if (typeof sortValue === 'string') { orderBy[sortValue] = 1; } else { - throw new Error("Illegal sort clause, must be of the form " + - "[['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]"); + throw new Error( + 'Illegal sort clause, must be of the form ' + + "[['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]" + ); } return orderBy; -}; +}); -var checkCollectionName = function checkCollectionName (collectionName) { - if('string' !== typeof collectionName) { - throw new MongoError("collection name must be a String"); +var checkCollectionName = function checkCollectionName(collectionName) { + if ('string' !== typeof collectionName) { + throw new MongoError('collection name must be a String'); } - if(!collectionName || collectionName.indexOf('..') != -1) { - throw new MongoError("collection names cannot be empty"); + if (!collectionName || collectionName.indexOf('..') !== -1) { + throw new MongoError('collection names cannot be empty'); } - if(collectionName.indexOf('$') != -1 && - collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null) { + if ( + collectionName.indexOf('$') !== -1 && + collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null + ) { throw new MongoError("collection names must not contain '$'"); } - if(collectionName.match(/^\.|\.$/) != null) { + if (collectionName.match(/^\.|\.$/) != null) { throw new MongoError("collection names must not start or end with '.'"); } - // Validate that we are not passing 0x00 in the collection name - if(!!~collectionName.indexOf("\x00")) { - throw new MongoError("collection names cannot contain a null character"); + // Validate that we are not passing 0x00 in the colletion name + if (collectionName.indexOf('\x00') !== -1) { + throw new MongoError('collection names cannot contain a null character'); } }; var handleCallback = function(callback, err, value1, value2) { try { - if(callback == null) return; - if(callback) { - return value2 ? callback(err, value1, value2) : callback(err, value1); + if (callback == null) return; + + if (callback) { + return value2 ? callback(err, value1, value2) : callback(err, value1); } - } catch(err) { - process.nextTick(function() { throw err; }); + } catch (err) { + process.nextTick(function() { + throw err; + }); return false; } return true; -} +}; /** * Wrap a Mongo error document in an Error instance @@ -136,23 +146,21 @@ var toError = function(error) { if (error instanceof Error) return error; var msg = error.err || error.errmsg || error.errMessage || error; - var e = MongoError.create({message: msg, driver:true}); + var e = MongoError.create({ message: msg, driver: true }); // Get all object keys - var keys = typeof error == 'object' - ? Object.keys(error) - : []; + var keys = typeof error === 'object' ? Object.keys(error) : []; - for(var i = 0; i < keys.length; i++) { + for (var i = 0; i < keys.length; i++) { try { e[keys[i]] = error[keys[i]]; - } catch(err) { + } catch (err) { // continue } } return e; -} +}; /** * @ignore @@ -160,15 +168,15 @@ var toError = function(error) { var normalizeHintField = function normalizeHintField(hint) { var finalHint = null; - if(typeof hint == 'string') { + if (typeof hint === 'string') { finalHint = hint; - } else if(Array.isArray(hint)) { + } else if (Array.isArray(hint)) { finalHint = {}; hint.forEach(function(param) { finalHint[param] = 1; }); - } else if(hint != null && typeof hint == 'object') { + } else if (hint != null && typeof hint === 'object') { finalHint = {}; for (var name in hint) { finalHint[name] = hint[name]; @@ -190,21 +198,21 @@ var parseIndexOptions = function(fieldOrSpec) { var keys; // Get all the fields accordingly - if('string' == typeof fieldOrSpec) { + if ('string' === typeof fieldOrSpec) { // 'type' indexes.push(fieldOrSpec + '_' + 1); fieldHash[fieldOrSpec] = 1; - } else if(Array.isArray(fieldOrSpec)) { + } else if (Array.isArray(fieldOrSpec)) { fieldOrSpec.forEach(function(f) { - if('string' == typeof f) { + if ('string' === typeof f) { // [{location:'2d'}, 'type'] indexes.push(f + '_' + 1); fieldHash[f] = 1; - } else if(Array.isArray(f)) { + } else if (Array.isArray(f)) { // [['location', '2d'],['type', 1]] indexes.push(f[0] + '_' + (f[1] || 1)); fieldHash[f[0]] = f[1] || 1; - } else if(isObject(f)) { + } else if (isObject(f)) { // [{location:'2d'}, {type:1}] keys = Object.keys(f); keys.forEach(function(k) { @@ -215,7 +223,7 @@ var parseIndexOptions = function(fieldOrSpec) { // undefined (ignore) } }); - } else if(isObject(fieldOrSpec)) { + } else if (isObject(fieldOrSpec)) { // {location:'2d', type:1} keys = Object.keys(fieldOrSpec); keys.forEach(function(key) { @@ -225,13 +233,15 @@ var parseIndexOptions = function(fieldOrSpec) { } return { - name: indexes.join("_"), keys: keys, fieldHash: fieldHash - } -} + name: indexes.join('_'), + keys: keys, + fieldHash: fieldHash + }; +}; -var isObject = exports.isObject = function (arg) { - return '[object Object]' == Object.prototype.toString.call(arg) -} +var isObject = (exports.isObject = function(arg) { + return '[object Object]' === Object.prototype.toString.call(arg); +}); var debugOptions = function(debugFields, options) { var finaloptions = {}; @@ -240,41 +250,48 @@ var debugOptions = function(debugFields, options) { }); return finaloptions; -} +}; var decorateCommand = function(command, options, exclude) { - for(var name in options) { - if(exclude[name] == null) command[name] = options[name]; + for (var name in options) { + if (exclude[name] == null) command[name] = options[name]; } return command; -} +}; var mergeOptions = function(target, source) { - for(var name in source) { + for (var name in source) { target[name] = source[name]; } return target; -} +}; // Merge options with translation var translateOptions = function(target, source) { var translations = { // SSL translation options - 'sslCA': 'ca', 'sslCRL': 'crl', 'sslValidate': 'rejectUnauthorized', 'sslKey': 'key', - 'sslCert': 'cert', 'sslPass': 'passphrase', + sslCA: 'ca', + sslCRL: 'crl', + sslValidate: 'rejectUnauthorized', + sslKey: 'key', + sslCert: 'cert', + sslPass: 'passphrase', // SocketTimeout translation options - 'socketTimeoutMS': 'socketTimeout', 'connectTimeoutMS': 'connectionTimeout', + socketTimeoutMS: 'socketTimeout', + connectTimeoutMS: 'connectionTimeout', // Replicaset options - 'replicaSet': 'setName', 'rs_name': 'setName', 'secondaryAcceptableLatencyMS': 'acceptableLatency', - 'connectWithNoPrimary': 'secondaryOnlyConnectionAllowed', + replicaSet: 'setName', + rs_name: 'setName', + secondaryAcceptableLatencyMS: 'acceptableLatency', + connectWithNoPrimary: 'secondaryOnlyConnectionAllowed', // Mongos options - 'acceptableLatencyMS': 'localThresholdMS' - } + acceptableLatencyMS: 'localThresholdMS' + }; - for(var name in source) { - if(translations[name]) { + for (var name in source) { + if (translations[name]) { target[translations[name]] = source[name]; } else { target[name] = source[name]; @@ -282,43 +299,18 @@ var translateOptions = function(target, source) { } return target; -} +}; var filterOptions = function(options, names) { - var filterOptions = {}; + var filterOptions = {}; - for(var name in options) { - if(names.indexOf(name) != -1) filterOptions[name] = options[name]; + for (var name in options) { + if (names.indexOf(name) !== -1) filterOptions[name] = options[name]; } // Filtered options return filterOptions; -} - -// Object.assign method or polyfill -var assign = Object.assign ? Object.assign : function assign(target) { - if (target === undefined || target === null) { - throw new TypeError('Cannot convert first argument to object'); - } - - var to = Object(target); - for (var i = 1; i < arguments.length; i++) { - var nextSource = arguments[i]; - if (nextSource === undefined || nextSource === null) { - continue; - } - - var keysArray = Object.keys(Object(nextSource)); - for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { - var nextKey = keysArray[nextIndex]; - var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); - if (desc !== undefined && desc.enumerable) { - to[nextKey] = nextSource[nextKey]; - } - } - } - return to; -} +}; // Write concern keys var writeConcernKeys = ['w', 'j', 'wtimeout', 'fsync']; @@ -326,50 +318,393 @@ var writeConcernKeys = ['w', 'j', 'wtimeout', 'fsync']; // Merge the write concern options var mergeOptionsAndWriteConcern = function(targetOptions, sourceOptions, keys, mergeWriteConcern) { // Mix in any allowed options - for(var i = 0; i < keys.length; i++) { - if(!targetOptions[keys[i]] && sourceOptions[keys[i]] != undefined) { + for (var i = 0; i < keys.length; i++) { + if (!targetOptions[keys[i]] && sourceOptions[keys[i]] !== undefined) { targetOptions[keys[i]] = sourceOptions[keys[i]]; } } // No merging of write concern - if(!mergeWriteConcern) return targetOptions; + if (!mergeWriteConcern) return targetOptions; // Found no write Concern options var found = false; - for(var i = 0; i < writeConcernKeys.length; i++) { - if(targetOptions[writeConcernKeys[i]]) { + for (i = 0; i < writeConcernKeys.length; i++) { + if (targetOptions[writeConcernKeys[i]]) { found = true; break; } } - if(!found) { - for(var i = 0; i < writeConcernKeys.length; i++) { - if(sourceOptions[writeConcernKeys[i]]) { + if (!found) { + for (i = 0; i < writeConcernKeys.length; i++) { + if (sourceOptions[writeConcernKeys[i]]) { targetOptions[writeConcernKeys[i]] = sourceOptions[writeConcernKeys[i]]; } } } return targetOptions; +}; + +/** + * Executes the given operation with provided arguments. + * + * This method reduces large amounts of duplication in the entire codebase by providing + * a single point for determining whether callbacks or promises should be used. Additionally + * it allows for a single point of entry to provide features such as implicit sessions, which + * are required by the Driver Sessions specification in the event that a ClientSession is + * not provided + * + * @param {object} topology The topology to execute this operation on + * @param {function} operation The operation to execute + * @param {array} args Arguments to apply the provided operation + * @param {object} [options] Options that modify the behavior of the method + * @param {function]} [options.resultMutator] Allows for the result of the operation to be changed for custom return types + */ +const executeOperation = (topology, operation, args, options) => { + if (topology == null) { + throw new TypeError('This method requires a valid topology instance'); + } + + if (!Array.isArray(args)) { + throw new TypeError('This method requires an array of arguments to apply'); + } + + options = options || {}; + const Promise = topology.s.promiseLibrary; + let resultMutator = options.resultMutator; + let callback = args[args.length - 1]; + + // The driver sessions spec mandates that we implicitly create sessions for operations + // that are not explicitly provided with a session. + let session, opOptions, owner; + if (!options.skipSessions && topology.hasSessionSupport()) { + opOptions = args[args.length - 2]; + if (opOptions == null || opOptions.session == null) { + owner = Symbol(); + session = topology.startSession({ owner }); + const optionsIndex = args.length - 2; + args[optionsIndex] = Object.assign({}, args[optionsIndex], { session: session }); + } else if (opOptions.session && opOptions.session.hasEnded) { + throw new MongoError('Use of expired sessions is not permitted'); + } + } + + const makeExecuteCallback = (resolve, reject) => + function executeCallback(err, result) { + if (session && session.owner === owner && !options.returnsCursor) { + session.endSession(() => { + delete opOptions.session; + if (err) return reject(err); + if (resultMutator) return resolve(resultMutator(result)); + resolve(result); + }); + } else { + if (err) return reject(err); + if (resultMutator) return resolve(resultMutator(result)); + resolve(result); + } + }; + + // Execute using callback + if (typeof callback === 'function') { + callback = args.pop(); + const handler = makeExecuteCallback( + result => callback(null, result), + err => callback(err, null) + ); + args.push(handler); + + try { + return operation.apply(null, args); + } catch (e) { + handler(e); + throw e; + } + } + + // Return a Promise + if (args[args.length - 1] != null) { + throw new TypeError('final argument to `executeOperation` must be a callback'); + } + + return new Promise(function(resolve, reject) { + const handler = makeExecuteCallback(resolve, reject); + args[args.length - 1] = handler; + + try { + return operation.apply(null, args); + } catch (e) { + handler(e); + } + }); +}; + +/** + * Applies a write concern to a command based on well defined inheritance rules, optionally + * detecting support for the write concern in the first place. + * + * @param {Object} target the target command we will be applying the write concern to + * @param {Object} sources sources where we can inherit default write concerns from + * @param {Object} [options] optional settings passed into a command for write concern overrides + * @returns {Object} the (now) decorated target + */ +function applyWriteConcern(target, sources, options) { + options = options || {}; + const db = sources.db; + const coll = sources.collection; + + // NOTE: there is probably a much better place for this + if (db && db.s.options.retryWrites) { + target.retryWrites = true; + } + + if (options.session && options.session.inTransaction()) { + // writeConcern is not allowed within a multi-statement transaction + if (target.writeConcern) { + delete target.writeConcern; + } + + return target; + } + + if (options.w != null || options.j != null || options.fsync != null) { + const writeConcern = {}; + if (options.w != null) writeConcern.w = options.w; + if (options.wtimeout != null) writeConcern.wtimeout = options.wtimeout; + if (options.j != null) writeConcern.j = options.j; + if (options.fsync != null) writeConcern.fsync = options.fsync; + return Object.assign(target, { writeConcern }); + } + + if ( + coll && + (coll.writeConcern.w != null || coll.writeConcern.j != null || coll.writeConcern.fsync != null) + ) { + return Object.assign(target, { writeConcern: Object.assign({}, coll.writeConcern) }); + } + + if ( + db && + (db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null) + ) { + return Object.assign(target, { writeConcern: Object.assign({}, db.writeConcern) }); + } + + return target; +} + +/** + * Resolves a read preference based on well-defined inheritance rules. This method will not only + * determine the read preference (if there is one), but will also ensure the returned value is a + * properly constructed instance of `ReadPreference`. + * + * @param {Object} options The options passed into the method, potentially containing a read preference + * @param {Object} sources Sources from which we can inherit a read preference + * @returns {(ReadPreference|null)} The resolved read preference + */ +function resolveReadPreference(options, sources) { + options = options || {}; + sources = sources || {}; + + const db = sources.db; + const coll = sources.collection; + const defaultReadPreference = sources.default; + const session = options.session; + + let readPreference; + if (options.readPreference) { + readPreference = options.readPreference; + } else if (session && session.inTransaction() && session.transaction.options.readPreference) { + // The transaction’s read preference MUST override all other user configurable read preferences. + readPreference = session.transaction.options.readPreference; + } else { + if (coll && coll.s.readPreference) { + readPreference = coll.s.readPreference; + } else if (db && db.s.readPreference) { + readPreference = db.s.readPreference; + } else if (defaultReadPreference) { + readPreference = defaultReadPreference; + } + } + + // do we even have a read preference? + if (readPreference == null) { + return null; + } + + // now attempt to convert the read preference if necessary + if (typeof readPreference === 'string') { + readPreference = new ReadPreference(readPreference); + } else if ( + readPreference && + !(readPreference instanceof ReadPreference) && + typeof readPreference === 'object' + ) { + const mode = readPreference.mode || readPreference.preference; + if (mode && typeof mode === 'string') { + readPreference = new ReadPreference(mode, readPreference.tags, { + maxStalenessSeconds: readPreference.maxStalenessSeconds + }); + } + } else if (!(readPreference instanceof ReadPreference)) { + throw new TypeError('Invalid read preference: ' + readPreference); + } + + return readPreference; +} + +/** + * Checks if a given value is a Promise + * + * @param {*} maybePromise + * @return true if the provided value is a Promise + */ +function isPromiseLike(maybePromise) { + return maybePromise && typeof maybePromise.then === 'function'; +} + +/** + * Applies collation to a given command. + * + * @param {object} [command] the command on which to apply collation + * @param {(Cursor|Collection)} [target] target of command + * @param {object} [options] options containing collation settings + */ +function decorateWithCollation(command, target, options) { + const topology = target.s && target.s.topology; + + if (!topology) { + throw new TypeError('parameter "target" is missing a topology'); + } + + // Do we support collation 3.4 and higher + const capabilities = target.s.topology.capabilities(); + // Do we support write concerns 3.4 and higher + if (capabilities && capabilities.commandsTakeCollation) { + if (options.collation && typeof options.collation === 'object') { + command.collation = options.collation; + } + } } -exports.filterOptions = filterOptions; -exports.mergeOptions = mergeOptions; -exports.translateOptions = translateOptions; -exports.shallowClone = shallowClone; -exports.getSingleProperty = getSingleProperty; -exports.checkCollectionName = checkCollectionName; -exports.toError = toError; -exports.formattedOrderClause = formattedOrderClause; -exports.parseIndexOptions = parseIndexOptions; -exports.normalizeHintField = normalizeHintField; -exports.handleCallback = handleCallback; -exports.decorateCommand = decorateCommand; -exports.isObject = isObject; -exports.debugOptions = debugOptions; -exports.MAX_JS_INT = 0x20000000000000; -exports.assign = assign; -exports.mergeOptionsAndWriteConcern = mergeOptionsAndWriteConcern; -exports.getReadPreference = getReadPreference; +/** + * Applies a read concern to a given command. + * + * @param {object} command the command on which to apply the read concern + * @param {Collection} coll the parent collection of the operation calling this method + */ +function decorateWithReadConcern(command, coll) { + let readConcern = Object.assign({}, command.readConcern || {}); + if (coll.s.readConcern) { + Object.assign(readConcern, coll.s.readConcern); + } + + if (Object.keys(readConcern).length > 0) { + Object.assign(command, { readConcern: readConcern }); + } +} + +const emitProcessWarning = msg => process.emitWarning(msg, 'DeprecationWarning'); +const emitConsoleWarning = msg => console.error(msg); +const emitDeprecationWarning = process.emitWarning ? emitProcessWarning : emitConsoleWarning; + +/** + * Default message handler for generating deprecation warnings. + * + * @param {string} name function name + * @param {string} option option name + * @return {string} warning message + * @ignore + * @api private + */ +function defaultMsgHandler(name, option) { + return `${name} option [${option}] is deprecated and will be removed in a later version.`; +} + +/** + * Deprecates a given function's options. + * + * @param {object} config configuration for deprecation + * @param {string} config.name function name + * @param {Array} config.deprecatedOptions options to deprecate + * @param {number} config.optionsIndex index of options object in function arguments array + * @param {function} [config.msgHandler] optional custom message handler to generate warnings + * @param {function} fn the target function of deprecation + * @return {function} modified function that warns once per deprecated option, and executes original function + * @ignore + * @api private + */ +function deprecateOptions(config, fn) { + if (process.noDeprecation === true) { + return fn; + } + + const msgHandler = config.msgHandler ? config.msgHandler : defaultMsgHandler; + + const optionsWarned = new Set(); + function deprecated() { + const options = arguments[config.optionsIndex]; + + // ensure options is a valid, non-empty object, otherwise short-circuit + if (!isObject(options) || Object.keys(options).length === 0) { + return fn.apply(this, arguments); + } + + config.deprecatedOptions.forEach(deprecatedOption => { + if (options.hasOwnProperty(deprecatedOption) && !optionsWarned.has(deprecatedOption)) { + optionsWarned.add(deprecatedOption); + const msg = msgHandler(config.name, deprecatedOption); + emitDeprecationWarning(msg); + if (this && this.getLogger) { + const logger = this.getLogger(); + if (logger) { + logger.warn(msg); + } + } + } + }); + + return fn.apply(this, arguments); + } + + // These lines copied from https://github.com/nodejs/node/blob/25e5ae41688676a5fd29b2e2e7602168eee4ceb5/lib/internal/util.js#L73-L80 + // The wrapper will keep the same prototype as fn to maintain prototype chain + Object.setPrototypeOf(deprecated, fn); + if (fn.prototype) { + // Setting this (rather than using Object.setPrototype, as above) ensures + // that calling the unwrapped constructor gives an instanceof the wrapped + // constructor. + deprecated.prototype = fn.prototype; + } + + return deprecated; +} + +module.exports = { + filterOptions, + mergeOptions, + translateOptions, + shallowClone, + getSingleProperty, + checkCollectionName, + toError, + formattedOrderClause, + parseIndexOptions, + normalizeHintField, + handleCallback, + decorateCommand, + isObject, + debugOptions, + MAX_JS_INT: Number.MAX_SAFE_INTEGER + 1, + mergeOptionsAndWriteConcern, + translateReadPreference, + executeOperation, + applyWriteConcern, + resolveReadPreference, + isPromiseLike, + decorateWithCollation, + decorateWithReadConcern, + deprecateOptions +}; diff --git a/node_modules/mongodb/package.json b/node_modules/mongodb/package.json index 48bdd73..33bdd6d 100644 --- a/node_modules/mongodb/package.json +++ b/node_modules/mongodb/package.json @@ -1,27 +1,27 @@ { - "_from": "mongodb@2.2.34", - "_id": "mongodb@2.2.34", + "_from": "mongodb@latest", + "_id": "mongodb@3.1.4", "_inBundle": false, - "_integrity": "sha1-o09Zu+thdUrsQy3nLD/iFSakTBo=", + "_integrity": "sha512-BGUxo4a/p5KtZpOn6+z6iZXTHfDxKDvibHQap9uMJqQouwoszvTIO/QbVZkaSX3Spny0jtTEeHc0FwfpGbtEzA==", "_location": "/mongodb", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "tag", "registry": true, - "raw": "mongodb@2.2.34", + "raw": "mongodb@latest", "name": "mongodb", "escapedName": "mongodb", - "rawSpec": "2.2.34", + "rawSpec": "latest", "saveSpec": null, - "fetchSpec": "2.2.34" + "fetchSpec": "latest" }, "_requiredBy": [ - "/mongoose" + "/" ], - "_resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.34.tgz", - "_shasum": "a34f59bbeb61754aec432de72c3fe21526a44c1a", - "_spec": "mongodb@2.2.34", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.4.tgz", + "_shasum": "0ff07a7409a4edf05e71f9ff8df3633bd278ed53", + "_spec": "mongodb@latest", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Christian Kvalheim" }, @@ -30,38 +30,36 @@ }, "bundleDependencies": false, "dependencies": { - "es6-promise": "3.2.1", - "mongodb-core": "2.1.18", - "readable-stream": "2.2.7" + "mongodb-core": "3.1.3", + "safe-buffer": "^5.1.2" }, "deprecated": false, "description": "The official MongoDB driver for Node.js", "devDependencies": { - "JSONStream": "^1.0.7", - "betterbenchmarks": "^0.1.0", - "bluebird": "3.4.6", - "bson": "latest", - "cli-table": "^0.3.1", + "bluebird": "3.5.0", + "bson": "^1.0.4", + "chai": "^4.1.1", + "chai-subset": "^1.6.0", "co": "4.6.0", - "colors": "^1.1.2", "coveralls": "^2.11.6", - "eslint": "^3.8.1", - "event-stream": "^3.3.2", - "gleak": "0.5.0", - "integra": "0.1.8", - "jsdoc": "3.4.0", - "ldjson-stream": "^1.2.1", - "mongodb-extended-json": "1.7.1", - "mongodb-topology-manager": "1.0.x", - "mongodb-version-manager": "github:christkv/mongodb-version-manager#master", - "nyc": "^8.1.0", - "optimist": "0.6.1", - "rimraf": "2.5.4", - "semver": "5.3.0", - "worker-farm": "^1.3.1" + "eslint": "^4.5.0", + "eslint-plugin-prettier": "^2.2.0", + "istanbul": "^0.4.5", + "jsdoc": "3.5.5", + "lodash.camelcase": "^4.3.0", + "mocha-sinon": "^2.1.0", + "mongodb-extjson": "^2.1.1", + "mongodb-mock-server": "^1.0.0", + "mongodb-test-runner": "^1.1.18", + "prettier": "~1.12.0", + "semver": "^5.5.0", + "sinon": "^4.3.0", + "sinon-chai": "^3.2.0", + "standard-version": "^4.4.0", + "worker-farm": "^1.5.0" }, "engines": { - "node": ">=0.10.3" + "node": ">=4" }, "homepage": "https://github.com/mongodb/node-mongodb-native", "keywords": [ @@ -72,19 +70,18 @@ "license": "Apache-2.0", "main": "index.js", "name": "mongodb", - "nyc": { - "include": [ - "lib/**/*.js" - ] - }, "repository": { "type": "git", "url": "git+ssh://git@github.com/mongodb/node-mongodb-native.git" }, "scripts": { - "coverage": "nyc node test/runner.js -t functional && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls", - "lint": "eslint lib", - "test": "node test/runner.js -t functional" + "bench": "node test/driverBench/", + "coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/unit test/functional", + "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'", + "generate-evergreen": "node .evergreen/generate_evergreen_tasks.js", + "lint": "eslint lib test", + "release": "standard-version -i HISTORY.md", + "test": "npm run lint && mongodb-test-runner -t 60000 test/unit test/functional" }, - "version": "2.2.34" + "version": "3.1.4" } diff --git a/node_modules/mongodb/yarn.lock b/node_modules/mongodb/yarn.lock index 479c574..37db1a4 100644 --- a/node_modules/mongodb/yarn.lock +++ b/node_modules/mongodb/yarn.lock @@ -2,13 +2,27 @@ # yarn lockfile v1 -JSONStream@^1.0.7, JSONStream@^1.1.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" +"@sinonjs/formatio@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" + dependencies: + samsam "1.3.0" + +JSONStream@^1.0.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.4.tgz#615bb2adb0cd34c8f4c447b5f6512fa1d8f16a2e" dependencies: jsonparse "^1.2.0" through ">=2.2.7 <3" +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + +abbrev@1.0.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" + acorn-jsx@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" @@ -19,22 +33,15 @@ acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^5.2.1: - version "5.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" - -ajv-keywords@^1.0.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" +acorn@^5.5.0: + version "5.7.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.2.tgz#91fa871883485d06708800318404e72bfb26dcc5" -ajv@^4.7.0: - version "4.11.8" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" - dependencies: - co "^4.6.0" - json-stable-stringify "^1.0.1" +ajv-keywords@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" -ajv@^5.1.0: +ajv@^5.2.3, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" dependencies: @@ -79,9 +86,9 @@ ampersand-version@^1.0.0, ampersand-version@^1.0.2: find-root "^0.1.1" through2 "^0.6.3" -ansi-escapes@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" +ansi-escapes@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" ansi-regex@^2.0.0: version "2.1.1" @@ -95,47 +102,41 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi@^0.3.0, ansi@~0.3.0: +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + dependencies: + color-convert "^1.9.0" + +ansi@^0.3.0, ansi@~0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21" -append-transform@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" - dependencies: - default-require-extensions "^1.0.0" - -archy@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" -are-we-there-yet@~1.0.0: - version "1.0.6" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz#a2d28c93102aa6cc96245a26cb954de06ec53f0c" +are-we-there-yet@~1.1.2: + version "1.1.5" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" dependencies: delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" + readable-stream "^2.0.6" argparse@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" dependencies: sprintf-js "~1.0.2" -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - -arr-flatten@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" - array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" +array-ify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" + array-next@~0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/array-next/-/array-next-0.0.1.tgz#e5e4660a4c27fda8151ff7764275d00900062be1" @@ -150,17 +151,15 @@ array-uniq@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - arrify@^1.0.0, arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" asn1@~0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + dependencies: + safer-buffer "~2.1.0" assert-plus@1.0.0, assert-plus@^1.0.0: version "1.0.0" @@ -170,17 +169,19 @@ assert-plus@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" -async@^1.4.0, async@^1.4.2, async@^1.5.0, async@~1.5.0: +assertion-error@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + +async@1.x, async@^1.4.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" -async@~0.2.6: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - -async@~1.4.0: - version "1.4.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.4.2.tgz#6c9edcb11ced4f0dd2f2d40db0d49a109c088aab" +async@^2.1.2: + version "2.6.1" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" + dependencies: + lodash "^4.17.10" asynckit@^0.4.0: version "0.4.0" @@ -194,11 +195,11 @@ aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" -aws4@^1.2.1, aws4@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" +aws4@^1.2.1, aws4@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" -babel-code-frame@^6.16.0, babel-code-frame@^6.26.0: +babel-code-frame@^6.22.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -206,167 +207,43 @@ babel-code-frame@^6.16.0, babel-code-frame@^6.26.0: esutils "^2.0.2" js-tokens "^3.0.2" -babel-core@^6.2.1, babel-core@^6.25.0, babel-core@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" - dependencies: - babel-code-frame "^6.26.0" - babel-generator "^6.26.0" - babel-helpers "^6.24.1" - babel-messages "^6.23.0" - babel-register "^6.26.0" - babel-runtime "^6.26.0" - babel-template "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - convert-source-map "^1.5.0" - debug "^2.6.8" - json5 "^0.5.1" - lodash "^4.17.4" - minimatch "^3.0.4" - path-is-absolute "^1.0.1" - private "^0.1.7" - slash "^1.0.0" - source-map "^0.5.6" - -babel-generator@^6.18.0, babel-generator@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5" - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.17.4" - source-map "^0.5.6" - trim-right "^1.0.1" - -babel-helpers@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-messages@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - dependencies: - babel-runtime "^6.22.0" - -babel-polyfill@^6.2.0, babel-polyfill@^6.23.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" - dependencies: - babel-runtime "^6.26.0" - core-js "^2.5.0" - regenerator-runtime "^0.10.5" - -babel-register@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" - dependencies: - babel-core "^6.26.0" - babel-runtime "^6.26.0" - core-js "^2.5.0" - home-or-tmp "^2.0.0" - lodash "^4.17.4" - mkdirp "^0.5.1" - source-map-support "^0.4.15" - -babel-runtime@^6.22.0, babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" - dependencies: - babel-runtime "^6.26.0" - babel-traverse "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - lodash "^4.17.4" - -babel-traverse@^6.18.0, babel-traverse@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" - dependencies: - babel-code-frame "^6.26.0" - babel-messages "^6.23.0" - babel-runtime "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - debug "^2.6.8" - globals "^9.18.0" - invariant "^2.2.2" - lodash "^4.17.4" - -babel-types@^6.18.0, babel-types@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" +babylon@7.0.0-beta.19: + version "7.0.0-beta.19" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503" balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" +base64-js@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978" + bcrypt-pbkdf@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" dependencies: tweetnacl "^0.14.3" -betterbenchmarks@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/betterbenchmarks/-/betterbenchmarks-0.1.0.tgz#c07ac937e215d3d7a91a460eefb039b7c9002e43" - dependencies: - babel-core "^6.2.1" - babel-polyfill "^6.2.0" - cli-table "^0.3.1" - co "^4.6.0" - colors "^1.1.2" - fast-stats "0.0.3" - table "^3.7.4" - -"binary@>= 0.3.0 < 1": - version "0.3.0" - resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" - dependencies: - buffers "~0.1.1" - chainsaw "~0.1.0" +bindings@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7" -block-stream@*: - version "0.0.9" - resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" +bl@^1.0.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c" dependencies: - inherits "~2.0.0" + readable-stream "^2.3.5" + safe-buffer "^5.1.1" -bluebird@3.4.6: - version "3.4.6" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f" +bluebird@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" -bluebird@^3.5.0: +bluebird@^3.5.1, bluebird@~3.5.0: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" -bluebird@~2.9.34: - version "2.9.34" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.9.34.tgz#2f7b4ec80216328a9fddebdf69c8d4942feff7d8" - boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -377,61 +254,68 @@ boom@2.x.x: dependencies: hoek "2.x.x" -boom@4.x.x: - version "4.3.1" - resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" - dependencies: - hoek "4.x.x" - -boom@5.x.x: - version "5.2.0" - resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" - dependencies: - hoek "4.x.x" - brace-expansion@^1.1.7: - version "1.1.8" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" dependencies: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +bson@^1.0.4, bson@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.0.tgz#bee57d1fb6a87713471af4e32bcae36de814b5b0" + +bson@^2.0.7: + version "2.0.8" + resolved "https://registry.yarnpkg.com/bson/-/bson-2.0.8.tgz#e3bcc115e486bdcb222de7568c43b0b43292761e" + +bson@~1.0.4: + version "1.0.9" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.9.tgz#12319f8323b1254739b7c6bef8d3e89ae05a2f57" + +buffer-alloc-unsafe@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" + +buffer-alloc@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" + buffer-alloc-unsafe "^1.1.0" + buffer-fill "^1.0.0" -bson@^0.5.2: - version "0.5.7" - resolved "https://registry.yarnpkg.com/bson/-/bson-0.5.7.tgz#0d11fe0936c1fee029e11f7063f5d0ab2422ea3e" +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" -bson@latest, bson@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c" +buffer-fill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" buffer-shims@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" -buffers@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" +buffer@^3.0.1: + version "3.6.0" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-3.6.0.tgz#a72c936f77b96bf52f5f7e7b467180628551defb" + dependencies: + base64-js "0.0.8" + ieee754 "^1.1.4" + isarray "^1.0.0" builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" -caching-transform@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/caching-transform/-/caching-transform-1.0.1.tgz#6dbdb2f20f8d8fbce79f3e94e9d1742dcdf5c0a1" - dependencies: - md5-hex "^1.2.0" - mkdirp "^0.5.1" - write-file-atomic "^1.1.4" - caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -449,6 +333,14 @@ camelcase-keys@^2.0.0: camelcase "^2.0.0" map-obj "^1.0.0" +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" @@ -457,9 +349,9 @@ camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" -camelcase@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" caseless@~0.11.0: version "0.11.0" @@ -469,12 +361,21 @@ caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" -catharsis@~0.8.7: +catharsis@~0.8.9: version "0.8.9" resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" dependencies: underscore-contrib "~0.3.0" +caw@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/caw/-/caw-2.0.1.tgz#6c3ca071fc194720883c2dc5da9b074bfc7e9e95" + dependencies: + get-proxy "^2.0.0" + isurl "^1.0.0-alpha5" + tunnel-agent "^0.6.0" + url-to-options "^1.0.1" + center-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" @@ -482,13 +383,22 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chainsaw@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" +chai-subset@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/chai-subset/-/chai-subset-1.6.0.tgz#a5d0ca14e329a79596ed70058b6646bd6988cfe9" + +chai@^4.1.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" dependencies: - traverse ">=0.3.0 <0.4" + assertion-error "^1.0.1" + check-error "^1.0.1" + deep-eql "^3.0.0" + get-func-name "^2.0.0" + pathval "^1.0.0" + type-detect "^4.0.0" -chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: +chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -498,31 +408,56 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -cheerio@^0.19.0: - version "0.19.0" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.19.0.tgz#772e7015f2ee29965096d71ea4175b75ab354925" +chalk@^2.0.0, chalk@^2.1.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + +check-error@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + +cheerio@^0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" dependencies: - css-select "~1.0.0" + css-select "~1.2.0" dom-serializer "~0.1.0" entities "~1.1.1" - htmlparser2 "~3.8.1" - lodash "^3.2.0" + htmlparser2 "^3.9.1" + lodash.assignin "^4.0.9" + lodash.bind "^4.1.4" + lodash.defaults "^4.0.1" + lodash.filter "^4.4.0" + lodash.flatten "^4.2.0" + lodash.foreach "^4.3.0" + lodash.map "^4.4.0" + lodash.merge "^4.4.0" + lodash.pick "^4.2.1" + lodash.reduce "^4.4.0" + lodash.reject "^4.4.0" + lodash.some "^4.4.0" + +chownr@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" -cli-cursor@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" - dependencies: - restore-cursor "^1.0.1" - -cli-table@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: - colors "1.0.3" + restore-cursor "^2.0.0" cli-width@^2.0.0: version "2.2.0" @@ -552,47 +487,212 @@ code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" -colors@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" +color-convert@^1.9.0: + version "1.9.2" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.2.tgz#49881b8fba67df12a96bdf3f56c0aab9e7913147" + dependencies: + color-name "1.1.1" -colors@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" +color-name@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.1.tgz#4b1415304cf50028ea81643643bd82ea05803689" -combined-stream@^1.0.5, combined-stream@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" +combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5, combined-stream@~1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" dependencies: delayed-stream "~1.0.0" +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + commander@^2.9.0: - version "2.12.2" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" -commondir@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" +commander@~2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4" + dependencies: + graceful-readlink ">= 1.0.0" + +compare-func@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" + dependencies: + array-ify "^1.0.0" + dot-prop "^3.0.0" concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.5.2: - version "1.6.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" +concat-stream@^1.4.10, concat-stream@^1.6.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" dependencies: + buffer-from "^1.0.0" inherits "^2.0.3" readable-stream "^2.2.2" typedarray "^0.0.6" -convert-source-map@^1.3.0, convert-source-map@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" +config-chain@^1.1.11: + version "1.1.11" + resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2" + dependencies: + ini "^1.3.4" + proto-list "~1.2.1" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +content-disposition@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" + +conventional-changelog-angular@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.6.tgz#b27f2b315c16d0a1f23eb181309d0e6a4698ea0f" + dependencies: + compare-func "^1.3.1" + q "^1.5.1" + +conventional-changelog-atom@^0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.2.8.tgz#8037693455990e3256f297320a45fa47ee553a14" + dependencies: + q "^1.5.1" + +conventional-changelog-codemirror@^0.3.8: + version "0.3.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.8.tgz#a1982c8291f4ee4d6f2f62817c6b2ecd2c4b7b47" + dependencies: + q "^1.5.1" + +conventional-changelog-core@^2.0.11: + version "2.0.11" + resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-2.0.11.tgz#19b5fbd55a9697773ed6661f4e32030ed7e30287" + dependencies: + conventional-changelog-writer "^3.0.9" + conventional-commits-parser "^2.1.7" + dateformat "^3.0.0" + get-pkg-repo "^1.0.0" + git-raw-commits "^1.3.6" + git-remote-origin-url "^2.0.0" + git-semver-tags "^1.3.6" + lodash "^4.2.1" + normalize-package-data "^2.3.5" + q "^1.5.1" + read-pkg "^1.1.0" + read-pkg-up "^1.0.1" + through2 "^2.0.0" + +conventional-changelog-ember@^0.3.12: + version "0.3.12" + resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.3.12.tgz#b7d31851756d0fcb49b031dffeb6afa93b202400" + dependencies: + q "^1.5.1" + +conventional-changelog-eslint@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.9.tgz#b13cc7e4b472c819450ede031ff1a75c0e3d07d3" + dependencies: + q "^1.5.1" + +conventional-changelog-express@^0.3.6: + version "0.3.6" + resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.3.6.tgz#4a6295cb11785059fb09202180d0e59c358b9c2c" + dependencies: + q "^1.5.1" + +conventional-changelog-jquery@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" + dependencies: + q "^1.4.1" + +conventional-changelog-jscs@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" + dependencies: + q "^1.4.1" + +conventional-changelog-jshint@^0.3.8: + version "0.3.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.8.tgz#9051c1ac0767abaf62a31f74d2fe8790e8acc6c8" + dependencies: + compare-func "^1.3.1" + q "^1.5.1" + +conventional-changelog-preset-loader@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.8.tgz#40bb0f142cd27d16839ec6c74ee8db418099b373" + +conventional-changelog-writer@^3.0.9: + version "3.0.9" + resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-3.0.9.tgz#4aecdfef33ff2a53bb0cf3b8071ce21f0e994634" + dependencies: + compare-func "^1.3.1" + conventional-commits-filter "^1.1.6" + dateformat "^3.0.0" + handlebars "^4.0.2" + json-stringify-safe "^5.0.1" + lodash "^4.2.1" + meow "^4.0.0" + semver "^5.5.0" + split "^1.0.0" + through2 "^2.0.0" + +conventional-changelog@^1.1.0: + version "1.1.24" + resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.24.tgz#3d94c29c960f5261c002678315b756cdd3d7d1f0" + dependencies: + conventional-changelog-angular "^1.6.6" + conventional-changelog-atom "^0.2.8" + conventional-changelog-codemirror "^0.3.8" + conventional-changelog-core "^2.0.11" + conventional-changelog-ember "^0.3.12" + conventional-changelog-eslint "^1.0.9" + conventional-changelog-express "^0.3.6" + conventional-changelog-jquery "^0.1.0" + conventional-changelog-jscs "^0.1.0" + conventional-changelog-jshint "^0.3.8" + conventional-changelog-preset-loader "^1.1.8" + +conventional-commits-filter@^1.1.1, conventional-commits-filter@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.1.6.tgz#4389cd8e58fe89750c0b5fb58f1d7f0cc8ad3831" + dependencies: + is-subset "^0.1.1" + modify-values "^1.0.0" + +conventional-commits-parser@^2.1.1, conventional-commits-parser@^2.1.7: + version "2.1.7" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.7.tgz#eca45ed6140d72ba9722ee4132674d639e644e8e" + dependencies: + JSONStream "^1.0.4" + is-text-path "^1.0.0" + lodash "^4.2.1" + meow "^4.0.0" + split2 "^2.0.0" + through2 "^2.0.0" + trim-off-newlines "^1.0.0" -core-js@^2.4.0, core-js@^2.5.0: - version "2.5.3" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" +conventional-recommended-bump@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/conventional-recommended-bump/-/conventional-recommended-bump-1.2.1.tgz#1b7137efb5091f99fe009e2fe9ddb7cc490e9375" + dependencies: + concat-stream "^1.4.10" + conventional-commits-filter "^1.1.1" + conventional-commits-parser "^2.1.1" + git-raw-commits "^1.3.0" + git-semver-tags "^1.3.0" + meow "^3.3.0" + object-assign "^4.0.1" core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" @@ -608,11 +708,12 @@ coveralls@^2.11.6: minimist "1.2.0" request "2.79.0" -cross-spawn@^4: - version "4.0.2" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" +cross-spawn@^5.0.1, cross-spawn@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: lru-cache "^4.0.1" + shebang-command "^1.2.0" which "^1.2.9" cryptiles@2.x.x: @@ -621,24 +722,18 @@ cryptiles@2.x.x: dependencies: boom "2.x.x" -cryptiles@3.x.x: - version "3.1.2" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" - dependencies: - boom "5.x.x" - -css-select@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.0.0.tgz#b1121ca51848dd264e2244d058cee254deeb44b0" +css-select@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" dependencies: boolbase "~1.0.0" - css-what "1.0" - domutils "1.4" - nth-check "~1.0.0" + css-what "2.1" + domutils "1.5.1" + nth-check "~1.0.1" -css-what@1.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-1.0.0.tgz#d7cc2df45180666f99d2b14462639469e00f736c" +css-what@2.1: + version "2.1.0" + resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.0.tgz#9467d032c38cfaefb9f2d79501253062f87fa1bd" currently-unhandled@^0.4.1: version "0.4.1" @@ -646,11 +741,11 @@ currently-unhandled@^0.4.1: dependencies: array-find-index "^1.0.1" -d@1: - version "1.0.0" - resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" +dargs@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" dependencies: - es5-ext "^0.10.9" + number-is-nan "^1.0.0" dashdash@^1.12.0: version "1.14.1" @@ -658,38 +753,107 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.6.8: +dateformat@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" + +debug@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +debug@^2.2.0: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@^3.1.0: +debug@^3.0.1, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: ms "2.0.0" -debug@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" +decamelize-keys@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" dependencies: - ms "0.7.1" + decamelize "^1.1.0" + map-obj "^1.0.0" -decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: +decamelize@^1.0.0, decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decompress-response@^3.2.0, decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + dependencies: + mimic-response "^1.0.0" + +decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1" + dependencies: + file-type "^5.2.0" + is-stream "^1.1.0" + tar-stream "^1.5.2" + +decompress-tarbz2@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" + dependencies: + decompress-tar "^4.1.0" + file-type "^6.1.0" + is-stream "^1.1.0" + seek-bzip "^1.0.5" + unbzip2-stream "^1.0.9" + +decompress-targz@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" + dependencies: + decompress-tar "^4.1.1" + file-type "^5.2.0" + is-stream "^1.1.0" + +decompress-unzip@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69" + dependencies: + file-type "^3.8.0" + get-stream "^2.2.0" + pify "^2.3.0" + yauzl "^2.4.2" + +decompress@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/decompress/-/decompress-4.2.0.tgz#7aedd85427e5a92dacfe55674a7c505e96d01f9d" + dependencies: + decompress-tar "^4.0.0" + decompress-tarbz2 "^4.0.0" + decompress-targz "^4.0.0" + decompress-unzip "^4.0.1" + graceful-fs "^4.1.10" + make-dir "^1.0.0" + pify "^2.3.0" + strip-dirs "^2.0.0" + +deep-eql@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + dependencies: + type-detect "^4.0.0" + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" -default-require-extensions@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8" - dependencies: - strip-bom "^2.0.0" - del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" @@ -710,19 +874,25 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - dependencies: - repeating "^2.0.0" +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" -docopt@~0.6.2: +diff@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + +docopt@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11" -doctrine@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" dependencies: esutils "^2.0.2" @@ -733,7 +903,7 @@ dom-serializer@0, dom-serializer@~0.1.0: domelementtype "~1.1.1" entities "~1.1.1" -domelementtype@1: +domelementtype@1, domelementtype@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" @@ -741,285 +911,259 @@ domelementtype@~1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" -domhandler@2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" - dependencies: - domelementtype "1" - -domutils@1.4: - version "1.4.3" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.4.3.tgz#0865513796c6b306031850e175516baf80b72a6f" +domhandler@^2.3.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803" dependencies: domelementtype "1" -domutils@1.5: +domutils@1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" dependencies: dom-serializer "0" domelementtype "1" -downcache@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/downcache/-/downcache-0.0.8.tgz#332320dde5806ea55d2e6d2ea674990bda4e8b75" +domutils@^1.5.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" dependencies: - extend "2.0.x" - graceful-fs "2.0.3" - limiter "1.0.x" - mkdirp "~0.3.5" - npmlog "1.0.0" - request "^2.34.0" - -duplexer@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + dom-serializer "0" + domelementtype "1" -ecc-jsbn@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" +dot-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" dependencies: - jsbn "~0.1.0" + is-obj "^1.0.0" -entities@1.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" - -entities@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" +dotgitignore@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-1.0.3.tgz#a442cbde7dc20dff51cdb849e4c5a64568c07923" + dependencies: + find-up "^2.1.0" + minimatch "^3.0.4" -errno@^0.1.4: - version "0.1.6" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.6.tgz#c386ce8a6283f14fc09563b71560908c9bf53026" +downcache@^0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/downcache/-/downcache-0.0.9.tgz#790bb0424689136115ce93f2aa15946c6d806d0e" dependencies: - prr "~1.0.1" + extend "^3.0.0" + graceful-fs "^4.1.3" + limiter "^1.1.0" + mkdirp "^0.5.1" + npmlog "^2.0.3" + request "^2.69.0" + rimraf "^2.5.2" + +download@^6.2.5: + version "6.2.5" + resolved "https://registry.yarnpkg.com/download/-/download-6.2.5.tgz#acd6a542e4cd0bb42ca70cfc98c9e43b07039714" + dependencies: + caw "^2.0.0" + content-disposition "^0.5.2" + decompress "^4.0.0" + ext-name "^5.0.0" + file-type "5.2.0" + filenamify "^2.0.0" + get-stream "^3.0.0" + got "^7.0.0" + make-dir "^1.0.0" + p-event "^1.0.0" + pify "^3.0.0" + +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" -error-ex@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" dependencies: - is-arrayish "^0.2.1" + jsbn "~0.1.0" + safer-buffer "^2.1.0" -es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: - version "0.10.37" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.37.tgz#0ee741d148b80069ba27d020393756af257defc3" +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" dependencies: - es6-iterator "~2.0.1" - es6-symbol "~3.1.1" + once "^1.4.0" -es6-iterator@^2.0.1, es6-iterator@~2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" +entities@^1.1.1, entities@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" + +errno@~0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" dependencies: - d "1" - es5-ext "^0.10.35" - es6-symbol "^3.1.1" + prr "~1.0.1" -es6-map@^0.1.3: - version "0.1.5" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" +error-ex@^1.2.0, error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" dependencies: - d "1" - es5-ext "~0.10.14" - es6-iterator "~2.0.1" - es6-set "~0.1.5" - es6-symbol "~3.1.1" - event-emitter "~0.3.5" + is-arrayish "^0.2.1" es6-promise@3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.2.1.tgz#ec56233868032909207170c39448e24449dd1fc4" -es6-set@~0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" - dependencies: - d "1" - es5-ext "~0.10.14" - es6-iterator "~2.0.1" - es6-symbol "3.1.1" - event-emitter "~0.3.5" - -es6-symbol@3.1.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" - dependencies: - d "1" - es5-ext "~0.10.14" - -es6-weak-map@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" - dependencies: - d "1" - es5-ext "^0.10.14" - es6-iterator "^2.0.1" - es6-symbol "^3.1.1" - -escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.3: +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen@1.1.x: - version "1.1.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.1.0.tgz#c663923f6e20aad48d0c0fa49f31c6d4f49360cf" +escodegen@1.8.x: + version "1.8.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" dependencies: - esprima "~1.0.4" - estraverse "~1.5.0" - esutils "~1.0.0" + esprima "^2.7.1" + estraverse "^1.9.1" + esutils "^2.0.2" + optionator "^0.8.1" optionalDependencies: - source-map "~0.1.30" + source-map "~0.2.0" -escope@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" +eslint-plugin-prettier@^2.2.0: + version "2.6.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.2.tgz#71998c60aedfa2141f7bfcbf9d1c459bf98b4fad" + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + +eslint-scope@^3.7.1: + version "3.7.3" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.3.tgz#bb507200d3d17f60247636160b4826284b108535" dependencies: - es6-map "^0.1.3" - es6-weak-map "^2.0.1" esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^3.8.1: - version "3.19.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^4.5.0: + version "4.19.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" dependencies: - babel-code-frame "^6.16.0" - chalk "^1.1.3" - concat-stream "^1.5.2" - debug "^2.1.1" - doctrine "^2.0.0" - escope "^3.6.0" - espree "^3.4.0" + ajv "^5.3.0" + babel-code-frame "^6.22.0" + chalk "^2.1.0" + concat-stream "^1.6.0" + cross-spawn "^5.1.0" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^3.7.1" + eslint-visitor-keys "^1.0.0" + espree "^3.5.4" esquery "^1.0.0" - estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" - glob "^7.0.3" - globals "^9.14.0" - ignore "^3.2.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.0.1" + ignore "^3.3.3" imurmurhash "^0.1.4" - inquirer "^0.12.0" - is-my-json-valid "^2.10.0" + inquirer "^3.0.6" is-resolvable "^1.0.0" - js-yaml "^3.5.1" - json-stable-stringify "^1.0.0" + js-yaml "^3.9.1" + json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" - lodash "^4.0.0" - mkdirp "^0.5.0" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" - path-is-inside "^1.0.1" - pluralize "^1.2.1" - progress "^1.1.8" - require-uncached "^1.0.2" - shelljs "^0.7.5" - strip-bom "^3.0.0" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + regexpp "^1.0.1" + require-uncached "^1.0.3" + semver "^5.3.0" + strip-ansi "^4.0.0" strip-json-comments "~2.0.1" - table "^3.7.8" + table "4.0.2" text-table "~0.2.0" - user-home "^2.0.0" -espree@^3.4.0: - version "3.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" +espree@^3.5.4: + version "3.5.4" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" dependencies: - acorn "^5.2.1" + acorn "^5.5.0" acorn-jsx "^3.0.0" -espree@~2.2.3: - version "2.2.5" - resolved "https://registry.yarnpkg.com/espree/-/espree-2.2.5.tgz#df691b9310889402aeb29cc066708c56690b854b" - -esprima@1.0.x, esprima@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" - -esprima@^2.6.0: +esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" esprima@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" esquery@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + version "1.0.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" dependencies: estraverse "^4.0.0" esrecurse@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163" + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" dependencies: estraverse "^4.1.0" - object-assign "^4.0.1" -estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^1.9.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" + +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" -estraverse@~1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.5.1.tgz#867a3e8e58a9f84618afb6c2ddbcd916b7cbaf71" - esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" -esutils@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.0.0.tgz#8151d358e20c8acc7fb745e7472c0025fe496570" - -event-emitter@~0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" - dependencies: - d "1" - es5-ext "~0.10.14" - -event-stream@^3.3.1, event-stream@^3.3.2: - version "3.3.4" - resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" dependencies: - duplexer "~0.1.1" - from "~0" - map-stream "~0.1.0" - pause-stream "0.0.11" - split "0.3" - stream-combiner "~0.0.4" - through "~2.3.1" + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" -exit-hook@^1.0.0: +expand-template@^1.0.2: version "1.1.1" - resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-1.1.1.tgz#981f188c0c3a87d2e28f559bc541426ff94f21dd" -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" +ext-list@^2.0.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/ext-list/-/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37" dependencies: - is-posix-bracket "^0.1.0" + mime-db "^1.28.0" -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" +ext-name@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ext-name/-/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6" dependencies: - fill-range "^2.1.0" - -extend@2.0.x: - version "2.0.1" - resolved "https://registry.yarnpkg.com/extend/-/extend-2.0.1.tgz#1ee8010689e7395ff9448241c98652bc759a8260" + ext-list "^2.0.0" + sort-keys-length "^1.0.0" -extend@~3.0.0, extend@~3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" +extend@^3.0.0, extend@~3.0.0, extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" +external-editor@^2.0.4: + version "2.2.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" dependencies: - is-extglob "^1.0.0" + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" extsprintf@1.3.0: version "1.3.0" @@ -1030,8 +1174,12 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" fast-deep-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + version "1.1.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614" + +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" fast-json-stable-stringify@^2.0.0: version "2.0.0" @@ -1041,17 +1189,25 @@ fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" -fast-stats@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/fast-stats/-/fast-stats-0.0.3.tgz#650af963c3ff85c496a3610f20d40cd4c164594d" +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + dependencies: + pend "~1.2.0" -figures@^1.3.5, figures@^1.4.0: +figures@^1.5.0: version "1.7.0" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" dependencies: escape-string-regexp "^1.0.5" object-assign "^4.1.0" +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + dependencies: + escape-string-regexp "^1.0.5" + file-entry-cache@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" @@ -1059,39 +1215,47 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" -filename-regex@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" +file-type@5.2.0, file-type@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" +file-type@^3.8.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" -find-cache-dir@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" +file-type@^6.1.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" + +filename-reserved-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229" + +filenamify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-2.1.0.tgz#88faf495fb1b47abfd612300002a16228c677ee9" dependencies: - commondir "^1.0.1" - mkdirp "^0.5.1" - pkg-dir "^1.0.0" + filename-reserved-regex "^2.0.0" + strip-outer "^1.0.0" + trim-repeated "^1.0.0" find-root@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/find-root/-/find-root-0.1.2.tgz#98d2267cff1916ccaf2743b3a0eea81d79d7dcd1" -find-up@^1.0.0, find-up@^1.1.2: +find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" dependencies: path-exists "^2.0.0" pinkie-promise "^2.0.0" +find-up@^2.0.0, find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + dependencies: + locate-path "^2.0.0" + flat-cache@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" @@ -1101,23 +1265,6 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -for-in@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - -for-own@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" - dependencies: - for-in "^1.0.1" - -foreground-child@^1.5.3, foreground-child@^1.5.6: - version "1.5.6" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" - dependencies: - cross-spawn "^4" - signal-exit "^3.0.0" - forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -1130,64 +1277,70 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -form-data@~2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" +form-data@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" dependencies: asynckit "^0.4.0" - combined-stream "^1.0.5" + combined-stream "1.0.6" mime-types "^2.1.12" -from@~0: - version "0.1.7" - resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" +fs-access@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" + dependencies: + null-check "^1.0.0" + +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" -fs-extra@^0.22.1: - version "0.22.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.22.1.tgz#5fd6f8049dc976ca19eb2355d658173cabcce056" +fs-extra@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" dependencies: graceful-fs "^4.1.2" jsonfile "^2.1.0" - rimraf "^2.2.8" + klaw "^1.0.0" -fs-extra@~0.30.0: - version "0.30.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0" +fs-extra@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" dependencies: graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - path-is-absolute "^1.0.0" - rimraf "^2.2.8" + jsonfile "^4.0.0" + universalify "^0.1.0" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -"fstream@>= 0.1.30 < 1": - version "0.1.31" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988" - dependencies: - graceful-fs "~3.0.2" - inherits "~2.0.0" - mkdirp "0.5" - rimraf "2" - -fstream@^1.0.2: - version "1.0.11" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" -gauge@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.0.2.tgz#53e25965dfaf1c85be3a2a0633306a24a67dc2f9" +gauge@~1.2.5: + version "1.2.7" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.2.7.tgz#e9cec5483d3d4ee0ef44b60a7d99e4935e136d93" dependencies: ansi "^0.3.0" - has-unicode "^1.0.0" + has-unicode "^2.0.0" + lodash.pad "^4.1.0" + lodash.padend "^4.1.0" + lodash.padstart "^4.1.0" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" generate-function@^2.0.0: version "2.0.0" @@ -1200,47 +1353,116 @@ generate-object-property@^1.1.0: is-property "^1.0.0" get-caller-file@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" -get-mongodb-version@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/get-mongodb-version/-/get-mongodb-version-0.0.1.tgz#bc8aa433ba2fdd57fa33312dcf89f06f3a908caa" +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + +get-mongodb-version@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/get-mongodb-version/-/get-mongodb-version-1.0.0.tgz#a524d3bb53e1e857fce09b740d2401e475562aa3" dependencies: debug "^2.2.0" - lodash.startswith "^3.0.1" + lodash.startswith "^4.2.1" minimist "^1.1.1" mongodb "^2.0.39" which "^1.1.1" +get-pkg-repo@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" + dependencies: + hosted-git-info "^2.1.4" + meow "^3.3.0" + normalize-package-data "^2.3.0" + parse-github-repo-url "^1.3.0" + through2 "^2.0.0" + +get-proxy@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/get-proxy/-/get-proxy-2.1.0.tgz#349f2b4d91d44c4d4d4e9cba2ad90143fac5ef93" + dependencies: + npm-conf "^1.1.0" + get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stream@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" + dependencies: + object-assign "^4.0.1" + pinkie-promise "^2.0.0" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" dependencies: assert-plus "^1.0.0" -gleak@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/gleak/-/gleak-0.5.0.tgz#9cd7694be50d6dbeb842021ed8160814c51faddf" - -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" +git-raw-commits@^1.3.0, git-raw-commits@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.3.6.tgz#27c35a32a67777c1ecd412a239a6c19d71b95aff" dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" + dargs "^4.0.1" + lodash.template "^4.0.2" + meow "^4.0.0" + split2 "^2.0.0" + through2 "^2.0.0" -glob-parent@^2.0.0: +git-remote-origin-url@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" + dependencies: + gitconfiglocal "^1.0.0" + pify "^2.3.0" + +git-semver-tags@^1.3.0, git-semver-tags@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.3.6.tgz#357ea01f7280794fe0927f2806bee6414d2caba5" + dependencies: + meow "^4.0.0" + semver "^5.5.0" + +gitconfiglocal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" + dependencies: + ini "^1.3.2" + +github-from-package@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" + +glob@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^5.0.15: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: - is-glob "^2.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6: +glob@^7.0.3, glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -1251,9 +1473,9 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.14.0, globals@^9.18.0: - version "9.18.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" +globals@^11.0.1: + version "11.7.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" globby@^5.0.0: version "5.0.0" @@ -1266,29 +1488,38 @@ globby@^5.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" -graceful-fs@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-2.0.3.tgz#7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0" +got@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" + dependencies: + decompress-response "^3.2.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-plain-obj "^1.1.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + isurl "^1.0.0-alpha5" + lowercase-keys "^1.0.0" + p-cancelable "^0.3.0" + p-timeout "^1.1.1" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + url-parse-lax "^1.0.0" + url-to-options "^1.0.1" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -graceful-fs@~3.0.2: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - dependencies: - natives "^1.1.0" +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" -handlebars@2.0.0-alpha.1: - version "2.0.0-alpha.1" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-2.0.0-alpha.1.tgz#c4d149068c713de0afa7f45bbb88a2ca73715afd" - dependencies: - optimist "~0.3" - optionalDependencies: - uglify-js "~2.3" +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" -handlebars@^4.0.3: +handlebars@^4.0.1, handlebars@^4.0.2: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" dependencies: @@ -1311,11 +1542,11 @@ har-validator@~2.0.6: is-my-json-valid "^2.12.4" pinkie-promise "^2.0.0" -har-validator@~5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" +har-validator@~5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.0.tgz#44657f5688a22cfd4b72486e81b3a3fb11742c29" dependencies: - ajv "^5.1.0" + ajv "^5.3.0" har-schema "^2.0.0" has-ansi@^2.0.0: @@ -1328,9 +1559,23 @@ has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" -has-unicode@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-1.0.1.tgz#c46fceea053eb8ec789bffbba25fca52dfdcf38e" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + +has-symbol-support-x@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" + +has-to-string-tag-x@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + dependencies: + has-symbol-support-x "^1.4.1" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" hawk@~3.1.3: version "3.1.3" @@ -1341,43 +1586,28 @@ hawk@~3.1.3: hoek "2.x.x" sntp "1.x.x" -hawk@~6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" - dependencies: - boom "4.x.x" - cryptiles "3.x.x" - hoek "4.x.x" - sntp "2.x.x" +he@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" -hoek@4.x.x: - version "4.2.0" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" - -home-or-tmp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.1" - hosted-git-info@^2.1.4: - version "2.5.0" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" + version "2.7.1" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" -htmlparser2@~3.8.1: - version "3.8.3" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" +htmlparser2@^3.9.1: + version "3.9.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" dependencies: - domelementtype "1" - domhandler "2.3" - domutils "1.5" - entities "1.0" - readable-stream "1.1" + domelementtype "^1.3.0" + domhandler "^2.3.0" + domutils "^1.5.1" + entities "^1.1.1" + inherits "^2.0.1" + readable-stream "^2.0.2" http-signature@~1.1.0: version "1.1.1" @@ -1395,9 +1625,19 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -ignore@^3.2.0: - version "3.3.7" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" +iconv-lite@^0.4.17: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ieee754@^1.1.4: + version "1.1.12" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b" + +ignore@^3.3.3: + version "3.3.10" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" imurmurhash@^0.1.4: version "0.1.4" @@ -1409,6 +1649,10 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -1416,48 +1660,33 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" -inquirer@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" +ini@^1.3.2, ini@^1.3.4, ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" dependencies: - ansi-escapes "^1.1.0" - ansi-regex "^2.0.0" - chalk "^1.0.0" - cli-cursor "^1.0.1" + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" cli-width "^2.0.0" - figures "^1.3.5" + external-editor "^2.0.4" + figures "^2.0.0" lodash "^4.3.0" - readline2 "^1.0.1" - run-async "^0.1.0" - rx-lite "^3.1.2" - string-width "^1.0.1" - strip-ansi "^3.0.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" through "^2.3.6" -integra@0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/integra/-/integra-0.1.8.tgz#8d5b8019f87ea3704e6c97da2c912e14ec3bece7" - dependencies: - escodegen "1.1.x" - esprima "1.0.x" - handlebars "2.0.0-alpha.1" - mkdirp latest - rimraf "2.2.6" - -interpret@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" - -invariant@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" - dependencies: - loose-envify "^1.0.0" - invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -1476,24 +1705,6 @@ is-builtin-module@^1.0.0: dependencies: builtin-modules "^1.0.0" -is-dotfile@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - is-finite@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" @@ -1510,40 +1721,39 @@ is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" +is-my-ip-valid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" -is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: - version "2.17.1" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471" +is-my-json-valid@^2.12.4: + version "2.19.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.19.0.tgz#8fd6e40363cd06b963fa877d444bfb5eddc62175" dependencies: generate-function "^2.0.0" generate-object-property "^1.1.0" + is-my-ip-valid "^1.0.0" jsonpointer "^4.0.0" xtend "^4.0.0" -is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" +is-natural-number@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" -is-number@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - dependencies: - kind-of "^3.0.2" +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + +is-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" is-path-in-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52" dependencies: is-path-inside "^1.0.0" @@ -1553,21 +1763,39 @@ is-path-inside@^1.0.0: dependencies: path-is-inside "^1.0.1" -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" +is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" is-resolvable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" + +is-retry-allowed@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + +is-stream@^1.0.0, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-subset@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" + +is-text-path@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.1.tgz#acca1cd36dbe44b974b924321555a70ba03b1cf4" + resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" + dependencies: + text-extensions "^1.0.0" is-typedarray@~1.0.0: version "1.0.0" @@ -1581,7 +1809,7 @@ isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" -isarray@1.0.0, isarray@~1.0.0: +isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -1589,64 +1817,41 @@ isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - dependencies: - isarray "1.0.0" - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" - -istanbul-lib-hook@^1.0.0-alpha.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.1.0.tgz#8538d970372cb3716d53e55523dd54b557a8d89b" - dependencies: - append-transform "^0.4.0" - -istanbul-lib-instrument@^1.2.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e" - dependencies: - babel-generator "^6.18.0" - babel-template "^6.16.0" - babel-traverse "^6.18.0" - babel-types "^6.18.0" - babylon "^6.18.0" - istanbul-lib-coverage "^1.1.1" - semver "^5.3.0" - -istanbul-lib-report@^1.0.0-alpha.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.2.tgz#922be27c13b9511b979bd1587359f69798c1d425" - dependencies: - istanbul-lib-coverage "^1.1.1" - mkdirp "^0.5.1" - path-parse "^1.0.5" - supports-color "^3.1.2" +istanbul@^0.4.5: + version "0.4.5" + resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b" + dependencies: + abbrev "1.0.x" + async "1.x" + escodegen "1.8.x" + esprima "2.7.x" + glob "^5.0.15" + handlebars "^4.0.1" + js-yaml "3.x" + mkdirp "0.5.x" + nopt "3.x" + once "1.x" + resolve "1.1.x" + supports-color "^3.1.0" + which "^1.1.1" + wordwrap "^1.0.0" -istanbul-lib-source-maps@^1.0.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.2.tgz#750578602435f28a0c04ee6d7d9e0f2960e62c1c" +isurl@^1.0.0-alpha5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" dependencies: - debug "^3.1.0" - istanbul-lib-coverage "^1.1.1" - mkdirp "^0.5.1" - rimraf "^2.6.1" - source-map "^0.5.3" + has-to-string-tag-x "^1.2.0" + is-object "^1.0.1" -istanbul-reports@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.1.3.tgz#3b9e1e8defb6d18b1d425da8e8b32c5a163f2d10" - dependencies: - handlebars "^4.0.3" +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" -js-tokens@^3.0.0, js-tokens@^3.0.2: +js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -1657,41 +1862,43 @@ js-yaml@3.6.1: argparse "^1.0.7" esprima "^2.6.0" -js-yaml@^3.5.1: - version "3.10.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" +js-yaml@3.x, js-yaml@^3.9.1: + version "3.12.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: argparse "^1.0.7" esprima "^4.0.0" -js2xmlparser@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-1.0.0.tgz#5a170f2e8d6476ce45405e04823242513782fe30" +js2xmlparser@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733" + dependencies: + xmlcreate "^1.0.1" jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" -jsdoc@3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.4.0.tgz#341cdb06e44a113d9541efd212c95a488064e9ee" - dependencies: - async "~1.4.0" - bluebird "~2.9.34" - catharsis "~0.8.7" - escape-string-regexp "~1.0.3" - espree "~2.2.3" - js2xmlparser "~1.0.0" - marked "~0.3.4" - requizzle "~0.2.0" - strip-json-comments "~1.0.2" - taffydb "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e" +jsdoc@3.5.5: + version "3.5.5" + resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d" + dependencies: + babylon "7.0.0-beta.19" + bluebird "~3.5.0" + catharsis "~0.8.9" + escape-string-regexp "~1.0.5" + js2xmlparser "~3.0.0" + klaw "~2.0.0" + marked "~0.3.6" + mkdirp "~0.5.1" + requizzle "~0.2.1" + strip-json-comments "~2.0.1" + taffydb "2.6.2" underscore "~1.8.3" - wrench "~1.5.8" -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" json-schema-traverse@^0.3.0: version "0.3.1" @@ -1701,19 +1908,17 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: +json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - dependencies: - jsonify "~0.0.0" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" -json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" -json5@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" jsonfile@^2.1.0: version "2.4.0" @@ -1721,9 +1926,11 @@ jsonfile@^2.1.0: optionalDependencies: graceful-fs "^4.1.6" -jsonify@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + optionalDependencies: + graceful-fs "^4.1.6" jsonparse@^1.2.0: version "1.3.1" @@ -1742,11 +1949,17 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kerberos@^0.0.23: - version "0.0.23" - resolved "https://registry.yarnpkg.com/kerberos/-/kerberos-0.0.23.tgz#6aa46afdb9786c6919388cc5b408f012c71f0fd1" +just-extend@^1.1.27: + version "1.1.27" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" + +kerberos@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/kerberos/-/kerberos-1.0.0.tgz#b8e490349a30ccd5f2dc675f1fae7c681cf3c495" dependencies: - nan "~2.5.1" + bindings "^1.3.0" + nan "^2.10.0" + prebuild-install "^5.0.0" key-tree-store@^1.3.0: version "1.3.0" @@ -1758,18 +1971,18 @@ kind-of@^3.0.2: dependencies: is-buffer "^1.1.5" -kind-of@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - dependencies: - is-buffer "^1.1.5" - klaw@^1.0.0: version "1.3.1" resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" optionalDependencies: graceful-fs "^4.1.9" +klaw@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6" + dependencies: + graceful-fs "^4.1.9" + lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" @@ -1784,13 +1997,6 @@ lcov-parse@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -ldjson-stream@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ldjson-stream/-/ldjson-stream-1.2.1.tgz#91beceda5ac4ed2b17e649fb777e7abfa0189c2b" - dependencies: - split2 "^0.2.1" - through2 "^0.6.1" - levn@^0.3.0, levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" @@ -1798,9 +2004,9 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -limiter@1.0.x: - version "1.0.5" - resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.0.5.tgz#9630b2a0d3bad63203f96e3d96f32f83d442dfc8" +limiter@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.3.tgz#32e2eb55b2324076943e5d04c1185ffb387968ef" load-json-file@^1.0.0: version "1.1.0" @@ -1812,9 +2018,30 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -lodash._arrayeach@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e" +load-json-file@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + strip-bom "^3.0.0" + +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" lodash._baseassign@^3.0.0: version "3.2.0" @@ -1823,15 +2050,6 @@ lodash._baseassign@^3.0.0: lodash._basecopy "^3.0.0" lodash.keys "^3.0.0" -lodash._basecallback@^3.0.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/lodash._basecallback/-/lodash._basecallback-3.3.1.tgz#b7b2bb43dc2160424a21ccf26c57e443772a8e27" - dependencies: - lodash._baseisequal "^3.0.0" - lodash._bindcallback "^3.0.0" - lodash.isarray "^3.0.0" - lodash.pairs "^3.0.0" - lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" @@ -1840,30 +2058,6 @@ lodash._basecreate@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" -lodash._basefor@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2" - -lodash._baseisequal@^3.0.0: - version "3.0.7" - resolved "https://registry.yarnpkg.com/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz#d8025f76339d29342767dcc887ce5cb95a5b51f1" - dependencies: - lodash.isarray "^3.0.0" - lodash.istypedarray "^3.0.0" - lodash.keys "^3.0.0" - -lodash._bindcallback@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" - -lodash._createassigner@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" - dependencies: - lodash._bindcallback "^3.0.0" - lodash._isiterateecall "^3.0.0" - lodash.restparam "^3.0.0" - lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" @@ -1872,26 +2066,31 @@ lodash._isiterateecall@^3.0.0: version "3.0.9" resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" -lodash._root@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" +lodash._reinterpolate@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" -lodash.assign@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa" - dependencies: - lodash._baseassign "^3.0.0" - lodash._createassigner "^3.0.0" - lodash.keys "^3.0.0" +lodash.assignin@^4.0.9: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" -lodash.defaults@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-3.1.2.tgz#c7308b18dbf8bc9372d701a73493c61192bd2e2c" +lodash.bind@^4.1.4: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" dependencies: - lodash.assign "^3.0.0" - lodash.restparam "^3.0.0" + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" -lodash.defaults@^4.0.0: +lodash.defaults@^4.0.0, lodash.defaults@^4.0.1, lodash.defaults@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" @@ -1899,6 +2098,22 @@ lodash.difference@^4.1.1: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c" +lodash.filter@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" + +lodash.flatten@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" + +lodash.foreach@^4.3.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" + +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" @@ -1907,14 +2122,6 @@ lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" -lodash.isfunction@^3.0.0, lodash.isfunction@^3.0.6: - version "3.0.8" - resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.8.tgz#4db709fc81bc4a8fd7127a458a5346c5cdce2c6b" - -lodash.istypedarray@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62" - lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -1923,57 +2130,75 @@ lodash.keys@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" -lodash.pairs@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash.pairs/-/lodash.pairs-3.0.1.tgz#bbe08d5786eeeaa09a15c91ebf0dcb7d2be326a9" - dependencies: - lodash.keys "^3.0.0" +lodash.map@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" -lodash.restparam@^3.0.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" +lodash.merge@^4.4.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" -lodash.startswith@^3.0.1: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.startswith/-/lodash.startswith-3.2.0.tgz#fc2e1ed2c6df8c777117632e87fe4a9181d483fb" - dependencies: - lodash._root "^3.0.0" +lodash.pad@^4.1.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/lodash.pad/-/lodash.pad-4.5.1.tgz#4330949a833a7c8da22cc20f6a26c4d59debba70" -lodash.transform@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.transform/-/lodash.transform-3.0.4.tgz#8ebe53fbae15857ade36eca67fc559b78bb3ebe9" +lodash.padend@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padend/-/lodash.padend-4.6.1.tgz#53ccba047d06e158d311f45da625f4e49e6f166e" + +lodash.padstart@^4.1.0: + version "4.6.1" + resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b" + +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + +lodash.reduce@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + +lodash.reject@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" + +lodash.some@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" + +lodash.startswith@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.startswith/-/lodash.startswith-4.2.1.tgz#c598c4adce188a27e53145731cdc6c0e7177600c" + +lodash.template@^4.0.2: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" dependencies: - lodash._arrayeach "^3.0.0" - lodash._basecallback "^3.0.0" - lodash._basecreate "^3.0.0" - lodash._basefor "^3.0.0" - lodash.isarray "^3.0.0" - lodash.isfunction "^3.0.0" - lodash.istypedarray "^3.0.0" - lodash.keys "^3.0.0" + lodash._reinterpolate "~3.0.0" + lodash.templatesettings "^4.0.0" -lodash@^3.2.0: - version "3.10.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" +lodash.templatesettings@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" + dependencies: + lodash._reinterpolate "~3.0.0" -lodash@^4.0.0, lodash@^4.12.0, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1: - version "4.17.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +lodash@^4.12.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1: + version "4.17.10" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" log-driver@1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" +lolex@^2.2.0, lolex@^2.3.2: + version "2.7.1" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.7.1.tgz#e40a8c4d1f14b536aa03e42a537c7adbaf0c20be" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" -loose-envify@^1.0.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" - dependencies: - js-tokens "^3.0.0" - loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -1981,43 +2206,42 @@ loud-rejection@^1.0.0: currently-unhandled "^0.4.1" signal-exit "^3.0.0" +lowercase-keys@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" + lru-cache@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + version "4.1.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c" dependencies: pseudomap "^1.0.2" yallist "^2.1.2" +make-dir@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" + dependencies: + pify "^3.0.0" + map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" -map-stream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" - -marked@~0.3.4: - version "0.3.9" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.9.tgz#54ce6a57e720c3ac6098374ec625fcbcc97ff290" +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" -"match-stream@>= 0.0.2 < 1": - version "0.0.2" - resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf" - dependencies: - buffers "~0.1.1" - readable-stream "~1.0.0" +marked@~0.3.6: + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" -md5-hex@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-1.3.0.tgz#d2c4afe983c4370662179b8cad145219135046c4" +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" dependencies: - md5-o-matic "^0.1.1" - -md5-o-matic@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3" + mimic-fn "^1.0.0" -meow@^3.1.0: +meow@^3.3.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" dependencies: @@ -2032,45 +2256,66 @@ meow@^3.1.0: redent "^1.0.0" trim-newlines "^1.0.0" -micromatch@^2.3.11: - version "2.3.11" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" +meow@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/meow/-/meow-4.0.1.tgz#d48598f6f4b1472f35bf6317a95945ace347f975" + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist "^1.1.3" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + +metamocha@^1.2.5: + version "1.3.2" + resolved "https://registry.yarnpkg.com/metamocha/-/metamocha-1.3.2.tgz#13703deafd53c1ad77e1bfad37f2196cc3cecac0" + dependencies: + mocha "^3.5.3" -mime-db@~1.30.0: - version "1.30.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" +mime-db@^1.28.0: + version "1.36.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397" -mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.7: - version "2.1.17" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" +mime-db@~1.35.0: + version "1.35.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.35.0.tgz#0569d657466491283709663ad379a99b90d9ab47" + +mime-types@^2.1.12, mime-types@~2.1.19, mime-types@~2.1.7: + version "2.1.19" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.19.tgz#71e464537a7ef81c15f2db9d97e913fc0ff606f0" dependencies: - mime-db "~1.30.0" + mime-db "~1.35.0" + +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + +mimic-response@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" -minimatch@^3.0.4: +"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: +minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -2078,139 +2323,182 @@ minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" -mkdirp@0.5, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@latest: +mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: minimist "0.0.8" -mkdirp@~0.3.5: - version "0.3.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.5.tgz#de3e5f8961c88c787ee1368df849ac4413eca8d7" - -moment@^2.10.6: - version "2.20.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" +mocha-sinon@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mocha-sinon/-/mocha-sinon-2.1.0.tgz#61e92727e577bee44cac6f32162dcec33c1301e5" + +mocha@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.6.8" + diff "3.2.0" + escape-string-regexp "1.0.5" + glob "7.1.1" + growl "1.9.2" + he "1.1.1" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +modify-values@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" -mongodb-core@2.1.17: - version "2.1.17" - resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8" +mongodb-core@2.1.20: + version "2.1.20" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.20.tgz#fece8dd76b59ee7d7f2d313b65322c160492d8f1" dependencies: bson "~1.0.4" require_optional "~1.0.0" -mongodb-core@2.1.18, mongodb-core@^2.1.12: - version "2.1.18" - resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.18.tgz#4c46139bdf3a1f032ded91db49f38eec01659050" +mongodb-core@3.1.3, mongodb-core@^3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-3.1.3.tgz#b036bce5290b383fe507238965bef748dd8adb75" dependencies: - bson "~1.0.4" - require_optional "~1.0.0" + bson "^1.1.0" + require_optional "^1.0.1" + safe-buffer "^5.1.2" + optionalDependencies: + saslprep "^1.0.0" -mongodb-download-url@^0.1.10: - version "0.1.10" - resolved "https://registry.yarnpkg.com/mongodb-download-url/-/mongodb-download-url-0.1.10.tgz#a7047eec95001de9f4df39f7e4030dc87eb3f806" +mongodb-download-url@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/mongodb-download-url/-/mongodb-download-url-0.3.3.tgz#e3a8a548f13eb20f5a0cdf863cbc063421a3934c" dependencies: - async "^1.5.0" + async "^2.1.2" debug "^2.2.0" lodash.defaults "^4.0.0" minimist "^1.2.0" - mongodb-version-list "^0.0.3" + mongodb-version-list "^1.0.0" request "^2.65.0" semver "^5.0.3" -mongodb-extended-json@1.7.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/mongodb-extended-json/-/mongodb-extended-json-1.7.1.tgz#457ec1fe3582eb1c70c4c12a979d831c01344812" - dependencies: - JSONStream "^1.1.1" - async "^1.4.2" - bson "^0.5.2" - event-stream "^3.3.1" - lodash.isfunction "^3.0.6" - lodash.transform "^3.0.4" - moment "^2.10.6" - raf "^3.1.0" - -mongodb-topology-manager@1.0.x: - version "1.0.13" - resolved "https://registry.yarnpkg.com/mongodb-topology-manager/-/mongodb-topology-manager-1.0.13.tgz#053577386c587d2cfcc1cc45a0567b93b0f8710b" - dependencies: - babel-core "^6.25.0" - babel-polyfill "^6.23.0" - bluebird "^3.5.0" +mongodb-extjson@^2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/mongodb-extjson/-/mongodb-extjson-2.1.4.tgz#c7eae23bbeea9646b8f2c302764aa9540c20fe56" + dependencies: + bson "^2.0.7" + +mongodb-mock-server@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mongodb-mock-server/-/mongodb-mock-server-1.0.0.tgz#6dec212d22cc116cfd2257c8f9be3fa4dd34123d" + dependencies: + snappy "^6.0.1" + +mongodb-test-runner@^1.1.18: + version "1.3.4" + resolved "https://registry.yarnpkg.com/mongodb-test-runner/-/mongodb-test-runner-1.3.4.tgz#63dfdaa357499f07f5087570d0fdc6ef305126b4" + dependencies: + metamocha "^1.2.5" + mongodb-topology-manager "^2.0.0" + mongodb-version-manager "^1.0.7" + semver "^5.4.1" + yargs "^8.0.2" + +mongodb-topology-manager@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mongodb-topology-manager/-/mongodb-topology-manager-2.1.0.tgz#5dee0d517d1474f3003d96cc20c7a41ea9d263e9" + dependencies: + bluebird "^3.5.1" co "^4.6.0" - kerberos "^0.0.23" + kerberos "^1.0.0" mkdirp "^0.5.1" - mongodb-core "^2.1.12" - rimraf "^2.6.1" + mongodb-core "^3.1.2" + rimraf "^2.6.2" -mongodb-version-list@0.0.3, mongodb-version-list@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/mongodb-version-list/-/mongodb-version-list-0.0.3.tgz#bbb261861f041fcfc5bc72b5fe2681788bd52cef" +mongodb-version-list@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/mongodb-version-list/-/mongodb-version-list-1.0.0.tgz#f25031cfcdd6f145b1de8fce2a4ebec0288bb4a4" dependencies: - cheerio "^0.19.0" + cheerio "^0.22.0" debug "^2.2.0" - downcache "0.0.8" - fs-extra "^0.22.1" + downcache "^0.0.9" + fs-extra "^1.0.0" minimist "^1.1.1" semver "^5.0.1" -mongodb-version-manager@christkv/mongodb-version-manager#master: - version "1.0.7" - resolved "https://codeload.github.com/christkv/mongodb-version-manager/tar.gz/3ea7c20925d6a0b3a9243d341d3c69abf95e66b6" +mongodb-version-manager@^1.0.7: + version "1.1.3" + resolved "https://registry.yarnpkg.com/mongodb-version-manager/-/mongodb-version-manager-1.1.3.tgz#7cf543a9b33b663d09cf6f8ca91264b408418209" dependencies: ampersand-state "^5.0.1" - async "~1.5.0" - chalk "^1.1.1" - debug "~2.2.0" - docopt "~0.6.2" - figures "^1.4.0" - fs-extra "~0.30.0" - get-mongodb-version "0.0.1" - lodash.defaults "^3.1.2" + async "^2.1.2" + chalk "^2.1.0" + debug "^3.0.1" + docopt "^0.6.2" + download "^6.2.5" + figures "^2.0.0" + fs-extra "^4.0.2" + get-mongodb-version "^1.0.0" + lodash.defaults "^4.2.0" lodash.difference "^4.1.1" - mongodb-download-url "^0.1.10" - mongodb-version-list "0.0.3" - nugget "^2.0.0" - semver "~5.1.0" - tar "~2.2.1" - tildify "~1.2.0" - untildify "~2.1.0" - unzip "^0.1.11" + mongodb-download-url "^0.3.3" + mongodb-version-list "^1.0.0" + semver "^5.3.0" + tildify "^1.2.0" + untildify "^3.0.2" mongodb@^2.0.39: - version "2.2.33" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.33.tgz#b537c471d34a6651b48f36fdbf29750340e08b50" + version "2.2.36" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.36.tgz#1c573680b2849fb0f47acbba3dc5fa228de975f5" dependencies: es6-promise "3.2.1" - mongodb-core "2.1.17" + mongodb-core "2.1.20" readable-stream "2.2.7" -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" -mute-stream@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" - -nan@~2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -natives@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.1.tgz#011acce1f7cbd87f7ba6b3093d6cd9392be1c574" +nan@^2.10.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.0.tgz#574e360e4d954ab16966ec102c0c049fd961a099" natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: +nise@^1.2.0: + version "1.4.3" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.4.3.tgz#d1996e8d15256ceff1a0a1596e0c72bff370e37c" + dependencies: + "@sinonjs/formatio" "^2.0.0" + just-extend "^1.1.27" + lolex "^2.3.2" + path-to-regexp "^1.7.0" + text-encoding "^0.6.4" + +node-abi@^2.2.0: + version "2.4.3" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.4.3.tgz#43666b7b17e57863e572409edbb82115ac7af28b" + dependencies: + semver "^5.4.1" + +noop-logger@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" + +nopt@3.x: + version "3.0.6" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + +normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: version "2.4.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" dependencies: @@ -2219,115 +2507,82 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" +npm-conf@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/npm-conf/-/npm-conf-1.1.3.tgz#256cc47bd0e218c259c4e9550bf413bc2192aff9" dependencies: - remove-trailing-separator "^1.0.1" + config-chain "^1.1.11" + pify "^3.0.0" -npmlog@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-1.0.0.tgz#ed2f290b60316887c39e0da9f09f8d13847cef0f" +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" dependencies: - ansi "~0.3.0" - are-we-there-yet "~1.0.0" - gauge "~1.0.2" + path-key "^2.0.0" -nth-check@~1.0.0: +npmlog@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-2.0.4.tgz#98b52530f2514ca90d09ec5b22c8846722375692" + dependencies: + ansi "~0.3.1" + are-we-there-yet "~1.1.2" + gauge "~1.2.5" + +npmlog@^4.0.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +nth-check@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4" dependencies: boolbase "~1.0.0" -nugget@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nugget/-/nugget-2.0.1.tgz#201095a487e1ad36081b3432fa3cada4f8d071b0" - dependencies: - debug "^2.1.3" - minimist "^1.1.0" - pretty-bytes "^1.0.2" - progress-stream "^1.1.0" - request "^2.45.0" - single-line-log "^1.1.2" - throttleit "0.0.2" +null-check@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -nyc@^8.1.0: - version "8.4.0" - resolved "https://registry.yarnpkg.com/nyc/-/nyc-8.4.0.tgz#660371c807caef0427fb9b0948f74180624ea6e4" - dependencies: - archy "^1.0.0" - arrify "^1.0.1" - caching-transform "^1.0.0" - convert-source-map "^1.3.0" - default-require-extensions "^1.0.0" - find-cache-dir "^0.1.1" - find-up "^1.1.2" - foreground-child "^1.5.3" - glob "^7.0.6" - istanbul-lib-coverage "^1.0.0" - istanbul-lib-hook "^1.0.0-alpha.4" - istanbul-lib-instrument "^1.2.0" - istanbul-lib-report "^1.0.0-alpha.3" - istanbul-lib-source-maps "^1.0.2" - istanbul-reports "^1.0.0" - md5-hex "^1.2.0" - micromatch "^2.3.11" - mkdirp "^0.5.0" - resolve-from "^2.0.0" - rimraf "^2.5.4" - signal-exit "^3.0.1" - spawn-wrap "^1.2.4" - test-exclude "^2.1.3" - yargs "^6.0.0" - yargs-parser "^4.0.2" - -oauth-sign@~0.8.1, oauth-sign@~0.8.2: +oauth-sign@~0.8.1: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + object-assign@^4.0.1, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" -object-keys@~0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" - -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - -once@^1.3.0: +once@1.x, once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: wrappy "1" -onetime@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" -optimist@0.6.1, optimist@^0.6.1: +optimist@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" dependencies: minimist "~0.0.1" wordwrap "~0.0.2" -optimist@~0.3, optimist@~0.3.5: - version "0.3.7" - resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.7.tgz#c90941ad59e4273328923074d2cf2e7cbc6ec0d9" - dependencies: - wordwrap "~0.0.2" - -optionator@^0.8.2: +optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: @@ -2342,28 +2597,57 @@ os-homedir@^1.0.0, os-homedir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-locale@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" +os-locale@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" dependencies: + execa "^0.7.0" lcid "^1.0.0" + mem "^1.1.0" -os-tmpdir@^1.0.1: +os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" -"over@>= 0.0.5 < 1": - version "0.0.5" - resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + +p-event@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-event/-/p-event-1.3.0.tgz#8e6b4f4f65c72bc5b6fe28b75eda874f96a4a085" + dependencies: + p-timeout "^1.1.1" -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" + p-try "^1.0.0" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + dependencies: + p-limit "^1.1.0" + +p-timeout@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386" + dependencies: + p-finally "^1.0.0" + +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + +parse-github-repo-url@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" parse-json@^2.2.0: version "2.2.0" @@ -2371,46 +2655,81 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" dependencies: pinkie-promise "^2.0.0" -path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + +path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: +path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" -path-parse@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + +path-to-regexp@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" + dependencies: + isarray "0.0.1" path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" dependencies: - graceful-fs "^4.1.2" + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +path-type@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" + dependencies: pify "^2.0.0" - pinkie-promise "^2.0.0" -pause-stream@0.0.11: - version "0.0.11" - resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" dependencies: - through "~2.3" + pify "^3.0.0" + +pathval@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" + +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -pify@^2.0.0: +pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -2421,49 +2740,57 @@ pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" -pkg-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" - dependencies: - find-up "^1.0.0" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" -pluralize@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" +prebuild-install@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.0.0.tgz#bc1a24636beaf0af7945c0a84d4b9249bf191b6b" + dependencies: + detect-libc "^1.0.3" + expand-template "^1.0.2" + github-from-package "0.0.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + node-abi "^2.2.0" + noop-logger "^0.1.1" + npmlog "^4.0.1" + os-homedir "^1.0.1" + pump "^2.0.1" + rc "^1.2.7" + simple-get "^2.7.0" + tar-fs "^1.13.0" + tunnel-agent "^0.6.0" + which-pm-runs "^1.0.0" prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - -pretty-bytes@^1.0.2: +prepend-http@^1.0.1: version "1.0.4" - resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" - dependencies: - get-stdin "^4.0.1" - meow "^3.1.0" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" -private@^0.1.7: - version "0.1.8" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" +prettier@~1.12.0: + version "1.12.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325" process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" -progress-stream@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/progress-stream/-/progress-stream-1.2.0.tgz#2cd3cfea33ba3a89c9c121ec3347abe9ab125f77" - dependencies: - speedometer "~0.1.2" - through2 "~0.2.3" +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" +progress@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" + +proto-list@~1.2.1: + version "1.2.4" + resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" prr@~1.0.1: version "1.0.1" @@ -2473,39 +2800,52 @@ pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" -"pullstream@>= 0.4.1 < 1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314" +psl@^1.1.24: + version "1.1.29" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" + +pump@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" dependencies: - over ">= 0.0.5 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.2 < 2" - slice-stream ">= 1.0.0 < 2" + end-of-stream "^1.1.0" + once "^1.3.1" punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" +q@^1.4.1, q@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" + qs@~6.3.0: version "6.3.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" -qs@~6.5.1: - version "6.5.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" +qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" -raf@^3.1.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.0.tgz#a28876881b4bc2ca9117d4138163ddb80f781575" - dependencies: - performance-now "^2.1.0" +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" -randomatic@^1.1.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" read-pkg-up@^1.0.1: version "1.0.1" @@ -2514,7 +2854,21 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" -read-pkg@^1.0.0: +read-pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" + dependencies: + find-up "^2.0.0" + read-pkg "^2.0.0" + +read-pkg-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" + dependencies: + find-up "^2.0.0" + read-pkg "^3.0.0" + +read-pkg@^1.0.0, read-pkg@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" dependencies: @@ -2522,14 +2876,21 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -readable-stream@1.1: - version "1.1.13" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" +read-pkg@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" + load-json-file "^2.0.0" + normalize-package-data "^2.3.2" + path-type "^2.0.0" + +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" readable-stream@2.2.7: version "2.2.7" @@ -2543,7 +2904,7 @@ readable-stream@2.2.7: string_decoder "~1.0.0" util-deprecate "~1.0.1" -"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.0, readable-stream@~1.0.31: +"readable-stream@>=1.0.33-1 <1.1.0-0": version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" dependencies: @@ -2552,41 +2913,18 @@ readable-stream@2.2.7: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.2.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" dependencies: core-util-is "~1.0.0" inherits "~2.0.3" isarray "~1.0.0" - process-nextick-args "~1.0.6" + process-nextick-args "~2.0.0" safe-buffer "~5.1.1" - string_decoder "~1.0.3" + string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@~1.1.9: - version "1.1.14" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readline2@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - mute-stream "0.0.5" - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - dependencies: - resolve "^1.1.6" - redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -2594,27 +2932,16 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" -regenerator-runtime@^0.10.5: - version "0.10.5" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" - -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - -regex-cache@^0.4.2: - version "0.4.4" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" dependencies: - is-equal-shallow "^0.1.3" + indent-string "^3.0.0" + strip-indent "^2.0.0" -remove-trailing-separator@^1.0.1: +regexpp@^1.0.1: version "1.1.0" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - -repeat-element@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" repeat-string@^1.5.2: version "1.6.1" @@ -2651,32 +2978,30 @@ request@2.79.0: tunnel-agent "~0.4.1" uuid "^3.0.0" -request@^2.34.0, request@^2.45.0, request@^2.65.0: - version "2.83.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" +request@^2.65.0, request@^2.69.0: + version "2.88.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" dependencies: aws-sign2 "~0.7.0" - aws4 "^1.6.0" + aws4 "^1.8.0" caseless "~0.12.0" - combined-stream "~1.0.5" - extend "~3.0.1" + combined-stream "~1.0.6" + extend "~3.0.2" forever-agent "~0.6.1" - form-data "~2.3.1" - har-validator "~5.0.3" - hawk "~6.0.2" + form-data "~2.3.2" + har-validator "~5.1.0" http-signature "~1.2.0" is-typedarray "~1.0.0" isstream "~0.1.2" json-stringify-safe "~5.0.1" - mime-types "~2.1.17" - oauth-sign "~0.8.2" + mime-types "~2.1.19" + oauth-sign "~0.9.0" performance-now "^2.1.0" - qs "~6.5.1" - safe-buffer "^5.1.1" - stringstream "~0.0.5" - tough-cookie "~2.3.3" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.4.3" tunnel-agent "^0.6.0" - uuid "^3.1.0" + uuid "^3.3.2" require-directory@^2.1.1: version "2.1.1" @@ -2686,21 +3011,21 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" -require-uncached@^1.0.2: +require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: caller-path "^0.1.0" resolve-from "^1.0.0" -require_optional@~1.0.0: +require_optional@^1.0.1, require_optional@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" dependencies: resolve-from "^2.0.0" semver "^5.1.0" -requizzle@~0.2.0: +requizzle@~0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" dependencies: @@ -2714,18 +3039,16 @@ resolve-from@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" -resolve@^1.1.6: - version "1.5.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" - dependencies: - path-parse "^1.0.5" +resolve@1.1.x: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -restore-cursor@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" dependencies: - exit-hook "^1.0.0" - onetime "^1.0.0" + onetime "^2.0.0" + signal-exit "^3.0.2" right-align@^0.1.1: version "0.1.3" @@ -2733,91 +3056,112 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: +rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" -rimraf@2.2.6: - version "2.2.6" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.6.tgz#c59597569b14d956ad29cacc42bdddf5f0ea4f4c" - -rimraf@2.5.4: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" dependencies: - glob "^7.0.5" + is-promise "^2.1.0" -run-async@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" dependencies: - once "^1.3.0" + rx-lite "*" -rx-lite@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" -safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + +samsam@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" -"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" +saslprep@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.1.tgz#b644e0ba25b156b652f3cb90df7542f896049ba6" -semver@5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" +seek-bzip@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc" + dependencies: + commander "~2.8.1" -semver@~5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.1.1.tgz#a3292a373e6f3e0798da0b20641b9a9c5bc47e19" +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: + version "5.5.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" -set-blocking@^2.0.0: +set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" -"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2": - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - -shelljs@^0.7.5: - version "0.7.8" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" -signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: +signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" -single-line-log@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/single-line-log/-/single-line-log-1.1.2.tgz#c2f83f273a3e1a16edb0995661da0ed5ef033364" +simple-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.0.tgz#7344cbb8b6e26fb27d66b2fc86f9f6d5997521c6" + +simple-get@^2.7.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.1.tgz#0e22e91d4575d87620620bc91308d57a77f44b5d" dependencies: - string-width "^1.0.1" + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" -slash@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" +sinon-chai@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-3.2.0.tgz#ed995e13a8a3cfccec18f218d9b767edc47e0715" -slice-ansi@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" +sinon@^4.3.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.5.0.tgz#427ae312a337d3c516804ce2754e8c0d5028cb04" + dependencies: + "@sinonjs/formatio" "^2.0.0" + diff "^3.1.0" + lodash.get "^4.4.2" + lolex "^2.2.0" + nise "^1.2.0" + supports-color "^5.1.0" + type-detect "^4.0.5" -"slice-stream@>= 1.0.0 < 2": +slice-ansi@1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" dependencies: - readable-stream "~1.0.31" + is-fullwidth-code-point "^2.0.0" -slide@^1.1.5: - version "1.1.6" - resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" +snappy@^6.0.1: + version "6.0.4" + resolved "https://registry.yarnpkg.com/snappy/-/snappy-6.0.4.tgz#8914f84a273270868828f3e2f10f61631aceabe5" + dependencies: + bindings "^1.3.0" + nan "^2.10.0" sntp@1.x.x: version "1.0.9" @@ -2825,17 +3169,17 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -sntp@2.x.x: - version "2.1.0" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" +sort-keys-length@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sort-keys-length/-/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188" dependencies: - hoek "4.x.x" + sort-keys "^1.0.0" -source-map-support@^0.4.15: - version "0.4.18" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" +sort-keys@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" dependencies: - source-map "^0.5.6" + is-plain-obj "^1.0.0" source-map@^0.4.4: version "0.4.4" @@ -2843,54 +3187,47 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - -source-map@~0.1.30, source-map@~0.1.7: - version "0.1.43" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" +source-map@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" dependencies: amdefine ">=0.0.4" -spawn-wrap@^1.2.4: - version "1.4.2" - resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c" - dependencies: - foreground-child "^1.5.6" - mkdirp "^0.5.0" - os-homedir "^1.0.1" - rimraf "^2.6.2" - signal-exit "^3.0.2" - which "^1.3.0" +source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" -spdx-correct@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" +spdx-correct@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82" dependencies: - spdx-license-ids "^1.0.2" + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" -spdx-expression-parse@~1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" +spdx-exceptions@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9" -spdx-license-ids@^1.0.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" +spdx-expression-parse@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" -speedometer@~0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-0.1.4.tgz#9876dbd2a169d3115402d48e6ea6329c8816a50d" +spdx-license-ids@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87" -split2@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/split2/-/split2-0.2.1.tgz#02ddac9adc03ec0bb78c1282ec079ca6e85ae900" +split2@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-2.2.0.tgz#186b2575bcf83e85b7d18465756238ee4ee42493" dependencies: - through2 "~0.6.1" + through2 "^2.0.2" -split@0.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" +split@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" dependencies: through "2" @@ -2899,26 +3236,34 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" sshpk@^1.7.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + version "1.14.2" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.14.2.tgz#c6fc61648a3d9c4e764fd3fcdf4ea105e492ba98" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" dashdash "^1.12.0" getpass "^0.1.1" + safer-buffer "^2.0.2" optionalDependencies: bcrypt-pbkdf "^1.0.0" ecc-jsbn "~0.1.1" jsbn "~0.1.0" tweetnacl "~0.14.0" -stream-combiner@~0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" +standard-version@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/standard-version/-/standard-version-4.4.0.tgz#99de7a0709e6cafddf9c5984dd342c8cfe66e79f" dependencies: - duplexer "~0.1.1" + chalk "^1.1.3" + conventional-changelog "^1.1.0" + conventional-recommended-bump "^1.0.0" + dotgitignore "^1.0.3" + figures "^1.5.0" + fs-access "^1.0.0" + semver "^5.1.0" + yargs "^8.0.1" -string-width@^1.0.1, string-width@^1.0.2: +string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -2926,7 +3271,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0: +"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -2937,15 +3282,21 @@ string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" -string_decoder@~1.0.0, string_decoder@~1.0.3: +string_decoder@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" dependencies: safe-buffer "~5.1.0" -stringstream@~0.0.4, stringstream@~0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + +stringstream@~0.0.4: + version "0.0.6" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.6.tgz#7880225b0d4ad10e30927d167a1d6f2fd3b33a72" strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" @@ -2969,116 +3320,174 @@ strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" +strip-dirs@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5" + dependencies: + is-natural-number "^4.0.1" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + strip-indent@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" dependencies: get-stdin "^4.0.1" -strip-json-comments@~1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" +strip-outer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" + dependencies: + escape-string-regexp "^1.0.2" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.2: +supports-color@^3.1.0: version "3.2.3" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: has-flag "^1.0.0" -table@^3.7.4, table@^3.7.8: - version "3.8.3" - resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" +supports-color@^5.1.0, supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" dependencies: - ajv "^4.7.0" - ajv-keywords "^1.0.0" - chalk "^1.1.1" - lodash "^4.0.0" - slice-ansi "0.0.4" - string-width "^2.0.0" + has-flag "^3.0.0" + +table@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" + dependencies: + ajv "^5.2.3" + ajv-keywords "^2.1.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" -"taffydb@https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e": +taffydb@2.6.2: version "2.6.2" - resolved "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e#3c549d2f5712d7d1d109ad6bb1a4084f1b7add4e" + resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268" -tar@~2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" +tar-fs@^1.13.0: + version "1.16.3" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" dependencies: - block-stream "*" - fstream "^1.0.2" - inherits "2" + chownr "^1.0.1" + mkdirp "^0.5.1" + pump "^1.0.0" + tar-stream "^1.1.2" -test-exclude@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-2.1.3.tgz#a8d8968e1da83266f9864f2852c55e220f06434a" - dependencies: - arrify "^1.0.1" - micromatch "^2.3.11" - object-assign "^4.1.0" - read-pkg-up "^1.0.1" - require-main-filename "^1.0.1" +tar-stream@^1.1.2, tar-stream@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.1.tgz#f84ef1696269d6223ca48f6e1eeede3f7e81f395" + dependencies: + bl "^1.0.0" + buffer-alloc "^1.1.0" + end-of-stream "^1.0.0" + fs-constants "^1.0.0" + readable-stream "^2.3.0" + to-buffer "^1.1.0" + xtend "^4.0.0" + +text-encoding@^0.6.4: + version "0.6.4" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" + +text-extensions@^1.0.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" -throttleit@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf" - -through2@^0.6.1, through2@^0.6.3, through2@~0.6.1: +through2@^0.6.3: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" dependencies: readable-stream ">=1.0.33-1 <1.1.0-0" xtend ">=4.0.0 <4.1.0-0" -through2@~0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/through2/-/through2-0.2.3.tgz#eb3284da4ea311b6cc8ace3653748a52abf25a3f" +through2@^2.0.0, through2@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" dependencies: - readable-stream "~1.1.9" - xtend "~2.1.1" + readable-stream "^2.1.5" + xtend "~4.0.1" -through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3, through@~2.3.1: +through@2, "through@>=2.2.7 <3", through@^2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" -tildify@~1.2.0: +tildify@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" dependencies: os-homedir "^1.0.0" -to-fast-properties@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" +timed-out@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" -tough-cookie@~2.3.0, tough-cookie@~2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +to-buffer@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" + +tough-cookie@~2.3.0: + version "2.3.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" dependencies: punycode "^1.4.1" -"traverse@>=0.3.0 <0.4": - version "0.3.9" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" +tough-cookie@~2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" + dependencies: + psl "^1.1.24" + punycode "^1.4.1" trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" -trim-right@^1.0.1: +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + +trim-off-newlines@^1.0.0: version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" + +trim-repeated@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" + dependencies: + escape-string-regexp "^1.0.2" tunnel-agent@^0.6.0: version "0.6.0" @@ -3100,6 +3509,10 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" @@ -3113,18 +3526,17 @@ uglify-js@^2.6: optionalDependencies: uglify-to-browserify "~1.0.0" -uglify-js@~2.3: - version "2.3.6" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.3.6.tgz#fa0984770b428b7a9b2a8058f46355d14fef211a" - dependencies: - async "~0.2.6" - optimist "~0.3.5" - source-map "~0.1.7" - uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" +unbzip2-stream@^1.0.9: + version "1.2.5" + resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.2.5.tgz#73a033a567bbbde59654b193c44d48a7e4f43c47" + dependencies: + buffer "^3.0.1" + through "^2.3.6" + underscore-contrib@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" @@ -3139,43 +3551,38 @@ underscore@~1.8.3: version "1.8.3" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" -untildify@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/untildify/-/untildify-2.1.0.tgz#17eb2807987f76952e9c0485fc311d06a826a2e0" - dependencies: - os-homedir "^1.0.0" +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" -unzip@^0.1.11: - version "0.1.11" - resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0" - dependencies: - binary ">= 0.3.0 < 1" - fstream ">= 0.1.30 < 1" - match-stream ">= 0.0.2 < 1" - pullstream ">= 0.4.1 < 1" - readable-stream "~1.0.31" - setimmediate ">= 1.0.1 < 2" +untildify@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-3.0.3.tgz#1e7b42b140bcfd922b22e70ca1265bfe3634c7c9" -user-home@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" dependencies: - os-homedir "^1.0.0" + prepend-http "^1.0.1" + +url-to-options@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -uuid@^3.0.0, uuid@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" +uuid@^3.0.0, uuid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" validate-npm-package-license@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" dependencies: - spdx-correct "~1.0.0" - spdx-expression-parse "~1.0.0" + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" verror@1.10.0: version "1.10.0" @@ -3185,16 +3592,26 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -which-module@^1.0.0: +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + +which-pm-runs@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" + resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb" -which@^1.1.1, which@^1.2.9, which@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" +which@^1.1.1, which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" dependencies: isexe "^2.0.0" +wide-align@^1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + dependencies: + string-width "^1.0.2 || 2" + window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" @@ -3203,20 +3620,19 @@ wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +wordwrap@^1.0.0, wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" -wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - -worker-farm@^1.3.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.5.2.tgz#32b312e5dc3d5d45d79ef44acc2587491cd729ae" +worker-farm@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.6.0.tgz#aecc405976fab5a95526180846f0dba288f3a4a0" dependencies: - errno "^0.1.4" - xtend "^4.0.1" + errno "~0.1.7" wrap-ansi@^2.0.0: version "2.1.0" @@ -3229,34 +3645,20 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -wrench@~1.5.8: - version "1.5.9" - resolved "https://registry.yarnpkg.com/wrench/-/wrench-1.5.9.tgz#411691c63a9b2531b1700267279bdeca23b2142a" - -write-file-atomic@^1.1.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - slide "^1.1.5" - write@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" dependencies: mkdirp "^0.5.1" -"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1: +xmlcreate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f" + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" -xtend@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" - dependencies: - object-keys "~0.4.0" - y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" @@ -3265,29 +3667,29 @@ yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" -yargs-parser@^4.0.2, yargs-parser@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c" +yargs-parser@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9" dependencies: - camelcase "^3.0.0" + camelcase "^4.1.0" -yargs@^6.0.0: - version "6.6.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208" +yargs@^8.0.1, yargs@^8.0.2: + version "8.0.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360" dependencies: - camelcase "^3.0.0" + camelcase "^4.1.0" cliui "^3.2.0" decamelize "^1.1.1" get-caller-file "^1.0.1" - os-locale "^1.4.0" - read-pkg-up "^1.0.1" + os-locale "^2.0.0" + read-pkg-up "^2.0.0" require-directory "^2.1.1" require-main-filename "^1.0.1" set-blocking "^2.0.0" - string-width "^1.0.2" - which-module "^1.0.0" + string-width "^2.0.0" + which-module "^2.0.0" y18n "^3.2.1" - yargs-parser "^4.2.0" + yargs-parser "^7.0.0" yargs@~3.10.0: version "3.10.0" @@ -3297,3 +3699,10 @@ yargs@~3.10.0: cliui "^2.1.0" decamelize "^1.0.0" window-size "0.1.0" + +yauzl@^2.4.2: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" diff --git a/node_modules/mongoose/node_modules/mongodb-core/.coveralls.yml b/node_modules/mongoose/node_modules/mongodb-core/.coveralls.yml new file mode 100644 index 0000000..a0b4fb6 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/.coveralls.yml @@ -0,0 +1 @@ +repo_token: 47iIZ0B3llo2Wc4dxWRltvgdImqcrVDTi diff --git a/node_modules/mongodb/.eslintrc b/node_modules/mongoose/node_modules/mongodb-core/.eslintrc similarity index 100% rename from node_modules/mongodb/.eslintrc rename to node_modules/mongoose/node_modules/mongodb-core/.eslintrc diff --git a/node_modules/mongoose/node_modules/mongodb-core/HISTORY.md b/node_modules/mongoose/node_modules/mongodb-core/HISTORY.md new file mode 100644 index 0000000..cf45b6e --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/HISTORY.md @@ -0,0 +1,714 @@ + +## [2.1.18](https://github.com/christkv/mongodb-core/compare/v2.1.17...v2.1.18) (2018-01-02) + + +### Bug Fixes + +* **auth:** don't redeclare BSON variable in plain auth ([4fc77e3](https://github.com/christkv/mongodb-core/commit/4fc77e3)) +* **auth:** remove extra bson include ([4411d2c](https://github.com/christkv/mongodb-core/commit/4411d2c)) +* **connection:** accept incoming missed ssl options from mongo-native-driver ([fd543eb](https://github.com/christkv/mongodb-core/commit/fd543eb)) +* **connection:** added missed tls option ecdhCurve ([ca1d909](https://github.com/christkv/mongodb-core/commit/ca1d909)) +* **connection:** default `family` to undefined rather than 4 ([09916ae](https://github.com/christkv/mongodb-core/commit/09916ae)) +* **connection:** fixing leaky connection ([#234](https://github.com/christkv/mongodb-core/issues/234)) ([7633f10](https://github.com/christkv/mongodb-core/commit/7633f10)) +* **cursor:** check for autoReconnect option only for single server ([c841eb5](https://github.com/christkv/mongodb-core/commit/c841eb5)) +* **secondaries:** fixes connection with secondary readPreference ([5763f5c](https://github.com/christkv/mongodb-core/commit/5763f5c)) +* **timeout:** fixed compatibility with node <=0.12.x ([c7c72b2](https://github.com/christkv/mongodb-core/commit/c7c72b2)), closes [mongodb-js/mongodb-core#247](https://github.com/mongodb-js/mongodb-core/issues/247) [mongodb-js/mongodb-core#247](https://github.com/mongodb-js/mongodb-core/issues/247) [mongodb-js/mongodb-core#248](https://github.com/mongodb-js/mongodb-core/issues/248) [#248](https://github.com/christkv/mongodb-core/issues/248) + + +### Features + +* **replicaset:** More verbose replica set errors emission: ([#231](https://github.com/christkv/mongodb-core/issues/231)) ([de6d220](https://github.com/christkv/mongodb-core/commit/de6d220)) + + + +2.1.17 2017-10-11 +----------------- +* fix a typo that completely broke SCRAM-SHA1 authentication + +2.1.16 2017-10-11 +----------------- +* avoid waiting for reconnect if reconnect disabled in Server topology +* avoid waiting for reconnect if reconnect disabled in Cursor +* NODE-990 cache the ScramSHA1 salted passwords up to 200 entries +* NODE-1153 ensure that errors are propagated on force destroy +* NODE-1153 ensure inUse and connecting queues are cleared on reauth + +2.1.15 2017-08-08 +----------------- +* Emit SDAM events on close and reconnect + +2.1.14 2017-07-07 +----------------- +* NODE-1073 updates scram.js hi() algorithm to utilize crypto.pbkdf2Sync() +* NODE-1049 only include primary server if there are no secondary servers for + readPrefrence secondaryPreferred +* moved `assign` polyfill to shared utils, replace usage of `extend` in tests + +2.1.13 2017-06-19 +----------------- +* NODE-1039 ensure we force destroy server instances, forcing queue to be flushed. +* Use actual server type in standalone SDAM events. + +2.1.12 2017-06-02 +----------------- +* NODE-1019 Set keepAlive to 300 seconds or 1/2 of socketTimeout if socketTimeout < keepAlive. +* Minor fix to report the correct state on error. +* NODE-1020 'family' was added to options to provide high priority for ipv6 addresses (Issue #1518, https://github.com/firej). +* Fix require_optional loading of bson-ext. +* Ensure no errors are thrown by replset if topology is destroyed before it finished connecting. +* NODE-999 SDAM fixes for Mongos and single Server event emitting. +* NODE-1014 Set socketTimeout to default to 360 seconds. +* NODE-1019 Set keepAlive to 300 seconds or 1/2 of socketTimeout if socketTimeout < keepAlive. + +2.1.11 2017-05-22 +----------------- +* NODE-987 Clear out old intervalIds on when calling topologyMonitor. +* NODE-987 Moved filtering to pingServer method and added test case. +* Check for connection destroyed just before writing out and flush out operations correctly if it is (Issue #179, https://github.com/jmholzinger). +* NODE-989 Refactored Replicaset monitoring to correcly monitor newly added servers, Also extracted setTimeout and setInterval to use custom wrappers Timeout and Interva. + +2.1.10 2017-04-18 +----------------- +* NODE-981 delegate auth to replset/mongos if inTopology is set. +* NODE-978 Wrap connection.end in try/catch for node 0.10.x issue causing exceptions to be thrown, Also surfaced getConnection for mongos and replset. +* Remove dynamic require (Issue #175, https://github.com/tellnes). +* NODE-696 Handle interrupted error for createIndexes. +* Fixed isse when user is executing find command using Server.command and it get interpreted as a wire protcol message, #172. +* NODE-966 promoteValues not being promoted correctly to getMore. +* Merged in fix for flushing out monitoring operations. + +2.1.9 2017-03-17 +---------------- +* Return lastIsMaster correctly when connecting with secondaryOnlyConnectionAllowed is set to true and only a secondary is available in replica state. +* Clone options when passed to wireProtocol handler to avoid intermittent modifications causing errors. +* Ensure SSL error propegates better for Replset connections when there is a SSL validation error. +* NODE-957 Fixed issue where < batchSize not causing cursor to be closed on execution of first batch. +* NODE-958 Store reconnectConnection on pool object to allow destroy to close immediately. + +2.1.8 2017-02-13 +---------------- +* NODE-925 ensure we reschedule operations while pool is < poolSize while pool is growing and there are no connections with not currently performing work. +* NODE-927 fixes issue where authentication was performed against arbiter instances. +* NODE-915 Normalize all host names to avoid comparison issues. +* Fixed issue where pool.destroy would never finish due to a single operation not being executed and keeping it open. + +2.1.7 2017-01-24 +---------------- +* NODE-919 ReplicaSet connection does not close immediately (Issue #156). +* NODE-901 Fixed bug when normalizing host names. +* NODE-909 Fixed readPreference issue caused by direct connection to primary. +* NODE-910 Fixed issue when bufferMaxEntries == 0 and read preference set to nearest. + +2.1.6 2017-01-13 +---------------- +* NODE-908 Keep auth contexts in replset and mongos topology to ensure correct application of authentication credentials when primary is first server to be detected causing an immediate connect event to happen. + +2.1.5 2017-01-11 +---------------- +* updated bson and bson-ext dependencies to 1.0.4 to work past early node 4.x.x version having a broken Buffer.from implementation. + +2.1.4 2017-01-03 +---------------- +* updated bson and bson-ext dependencies to 1.0.3 due to util.inspect issue with ObjectId optimizations. + +2.1.3 2017-01-03 +---------------- +* Monitoring operations are re-scheduled in pool if it cannot find a connection that does not already have scheduled work on it, this is to avoid the monitoring socket timeout being applied to any existing operations on the socket due to pipelining +* Moved replicaset monitoring away from serial mode and to parallel mode. +* updated bson and bson-ext dependencies to 1.0.2. + +2.1.2 2016-12-10 +---------------- +* Delay topologyMonitoring on successful attemptReconnect as no need to run a full scan immediately. +* Emit reconnect event in primary joining when in connected status for a replicaset. + +2.1.1 2016-12-08 +---------------- +* Updated bson library to 1.0.1. +* Added optional support for bson-ext 1.0.1. + +2.1.0 2016-12-05 +---------------- +* Updated bson library to 1.0.0. +* Added optional support for bson-ext 1.0.0. +* Expose property parserType allowing for identification of currently configured parser. + +2.0.14 2016-11-29 +----------------- +* Updated bson library to 0.5.7. +* Dont leak connection.workItems elments when killCursor is called (Issue #150, https://github.com/mdlavin). +* Remove unnecessary errors formatting (Issue #149, https://github.com/akryvomaz). +* Only check isConnected against availableConnections (Issue #142). +* NODE-838 Provide better error message on failed to connect on first retry for Mongos topology. +* Set default servername to host is not passed through for sni. +* Made monitoring happen on exclusive connection and using connectionTimeout to handle the wait time before failure (Issue #148). +* NODE-859 Make minimum value of maxStalenessSeconds 90 seconds. +* NODE-852 Fix Kerberos module deprecations on linux and windows and release new kerberos version. +* NODE-850 Update Max Staleness implementation. +* NODE-849 username no longer required for MONGODB-X509 auth. +* NODE-848 BSON Regex flags must be alphabetically ordered. +* NODE-846 Create notice for all third party libraries. +* NODE-843 Executing bulk operations overwrites write concern parameter. +* NODE-842 Re-sync SDAM and SDAM Monitoring tests from Specs repo. +* NODE-840 Resync CRUD spec tests. +* Unescapable while(true) loop (Issue #152). + +2.0.13 2016-10-21 +----------------- +* Updated bson library to 0.5.6. + - Included cyclic dependency detection +* Fire callback when topology was destroyed (Issue #147, https://github.com/vkarpov15). +* Refactoring to support pipelining ala 1.4.x branch will retaining the benefits of the growing/shrinking pool (Issue #146). +* Fix typo in serverHeartbeatFailed event name (Issue #143, https://github.com/jakesjews). +* NODE-798 Driver hangs on count command in replica set with one member (Issue #141, https://github.com/isayme). + +2.0.12 2016-09-15 +----------------- +* fix debug logging message not printing server name. +* fixed application metadata being sent by wrong ismaster. +* NODE-812 Fixed mongos stall due to proxy monitoring ismaster failure causing reconnect. +* NODE-818 Replicaset timeouts in initial connect sequence can "no primary found". +* Updated bson library to 0.5.5. +* Added DBPointer up conversion to DBRef. + +2.0.11 2016-08-29 +----------------- +* NODE-803, Fixed issue in how the latency window is calculated for Mongos topology causing issues for single proxy connections. +* Avoid timeout in attemptReconnect causing multiple attemptReconnect attempts to happen (Issue #134, https://github.com/dead-horse). +* Ensure promoteBuffers is propagated in same fashion as promoteValues and promoteLongs + +2.0.10 2016-08-23 +----------------- +* Added promoteValues flag (default to true) to allow user to specify they only want wrapped BSON values back instead of promotion to native types. +* Do not close mongos proxy connection on failed ismaster check in ha process (Issue #130). + +2.0.9 2016-08-19 +---------------- +* Allow promoteLongs to be passed in through Response.parse method and overrides default set on the connection. +* NODE-798 Driver hangs on count command in replica set with one member. +* Allow promoteLongs to be passed in through Response.parse method and overrides default set on the connection. +* Allow passing in servername for TLS connections for SNI support. + +2.0.8 2016-08-16 +---------------- +* Allow execution of store operations indepent of having both a primary and secondary available (Issue #123). +* Fixed command execution issue for mongos to ensure buffering of commands when no mongos available. +* Added hashed connection names and fullResult. +* Updated bson library to 0.5.3. +* Wrap callback in nextTick to ensure exceptions are thrown correctly. + +2.0.7 2016-07-28 +---------------- +* Allow primary to be returned when secondaryPreferred is passed (Issue #117, https://github.com/dhendo). +* Added better warnings when passing in illegal seed list members to a Mongos topology. +* Minor attemptReconnect bug that would cause multiple attemptReconnect to run in parallel. +* Fix wrong opType passed to disconnectHandler.add (Issue #121, https://github.com/adrian-gierakowski) +* Implemented domain backward comp support enabled via domainsEnabled options on Server/ReplSet/Mongos and MongoClient.connect. +* Initial max staleness implementation for ReplSet and Mongos for 3.4 support. +* Added handling of collation for 3.4 support. + +2.0.6 2016-07-19 +---------------- +* Destroy connection on socket timeout due to newer node versions not closing the socket. + +2.0.5 2016-07-15 +---------------- +* Minor fixes to handle faster MongoClient connectivity from the driver, allowing single server instances to detect if they are a proxy. +* Added numberOfConsecutiveTimeouts to pool that will destroy the pool if the number of consecutive timeouts > reconnectTries. +* Print warning if seedlist servers host name does not match the one provided in it's ismaster.me field for Replicaset members. +* Fix issue where Replicaset connection would not succeeed if there the replicaset was a single primary server setup. + +2.0.4 2016-07-11 +----------------- +* Updated bson to version 0.5.1. +* handle situation where user is providing seedlist names that do not match host list. fix allows for a single full discovery connection sweep before erroring out. +* NODE-747 Polyfill for Object.assign for 0.12.x or 0.10.x. +* NODE-746 Improves replicaset errors for wrong setName. + +2.0.3 2016-07-08 +----------------- +* Implemented Server Selection Specification test suite. +* Added warning level to logger. +* Added warning message when sockeTimeout < haInterval for Replset/Mongos. + +2.0.2 2016-07-06 +----------------- +* Mongos emits close event on no proxies available or when reconnect attempt fails. +* Replset emits close event when no servers available or when attemptReconnect fails to reconnect. +* Don't throw in auth methods but return error in callback. + +2.0.1 2016-07-05 +----------------- +* Added missing logout method on mongos proxy topology. +* Fixed logger error serialization issue. +* Documentation fixes. + +2.0.0 2016-07-05 +----------------- +* Moved all authentication and handling of growing/shrinking of pool connections into actual pool. +* All authentication methods now handle both auth/reauthenticate and logout events. +* Introduced logout method to get rid of onAll option for logout command. +* Updated bson to 0.5.0 that includes Decimal128 support. + +1.3.21 2016-05-30 +----------------- +* Pool gets stuck if a connection marked for immediateRelease times out (Issue #99, https://github.com/nbrachet). +* Make authentication process retry up to authenticationRetries at authenticationRetryIntervalMS interval. +* Made ismaster replicaset calls operate with connectTimeout or monitorSocketTimeout to lower impact of big socketTimeouts on monitoring performance. +* Make sure connections mark as "immediateRelease" don't linger the inUserConnections list. Otherwise, after that connection times out, getAll() incorrectly returns more connections than are effectively present, causing the pool to not get restarted by reconnectServer. (Issue #99, https://github.com/nbrachet). +* Make cursor getMore or killCursor correctly trigger pool reconnect to single server if pool has not been destroyed. +* Make ismaster monitoring for single server connection default to avoid user confusion due to change in behavior. + +1.3.20 2016-05-25 +----------------- +* NODE-710 Allow setting driver loggerLevel and logger function from MongoClient options. +* Minor fix for SSL errors on connection attempts, minor fix to reconnect handler for the server. +* Don't write to socket before having registered the callback for commands, work around for windows issuing error events twice on node.js when socket gets destroyed by firewall. +* Fix minor issue where connectingServers would not be removed correctly causing single server connections to not auto-reconnect. + +1.3.19 2016-05-17 +----------------- +- Handle situation where a server connection in a replicaset sometimes fails to be destroyed properly due to being in the middle of authentication when the destroy method is called on the replicaset causing it to be orphaned and never collected. +- Set keepAlive to false by default to work around bug in node.js for Windows XP and Windows 2003. +- Ensure replicaset topology destroy is never called by SDAM. +- Ensure all paths are correctly returned on inspectServer in replset. + +1.3.18 2016-04-27 +----------------- +- Hardened cursor connection handling for getMore and killCursor to ensure mid operation connection kill does not throw null exception. +- Fixes for Node 6.0 support. + +1.3.17 2016-04-26 +----------------- +- Added improved handling of reconnect when topology is a single server. +- Added better handling of $query queries passed down for 3.2 or higher. +- Introduced getServerFrom method to topologies to let cursor grab a new pool for getMore and killCursors commands and not use connection pipelining. +- NODE-693 Move authentication to be after ismaster call to avoid authenticating against arbiters. + +1.3.16 2016-04-07 +----------------- +- Only call unref on destroy if it exists to ensure proper working destroy method on early node v0.10.x versions. + +1.3.15 2016-04-06 +----------------- +- NODE-687 Fixed issue where a server object failed to be destroyed if the replicaset state did not update successfully. This could leave active connections accumulating over time. +- Fixed some situations where all connections are flushed due to a single connection in the connection pool closing. + +1.3.14 2016-04-01 +----------------- +- Ensure server inquireServerState exits immediately on server.destroy call. +- Refactored readPreference handling in 2.4, 2.6 and 3.2 wire protocol handling. + +1.3.13 2016-03-30 +----------------- +- Handle missing cursor on getMore when going through a mongos proxy by pinning to socket connection and not server. + +1.3.12 2016-03-29 +----------------- +- Mongos pickProxies fall back to closest mongos if no proxies meet latency window specified. + +1.3.11 2016-03-29 +----------------- +- isConnected method for mongos uses same selection code as getServer. +- Exceptions in cursor getServer trapped and correctly delegated to high level handler. + +1.3.10 2016-03-22 +----------------- +- SDAM Monitoring emits diff for Replicasets to simplify detecting the state changes. +- SDAM Monitoring correctly emits Mongos as serverDescriptionEvent. + +1.3.9 2016-03-20 +---------------- +- Removed monitoring exclusive connection, should resolve timeouts and reconnects on idle replicasets where haInteval > socketTimeout. + +1.3.8 2016-03-18 +---------------- +- Implements the SDAM monitoring specification. +- Fix issue where cursor would error out and not be buffered when primary is not connected. + +1.3.7 2016-03-16 +---------------- +- Fixed issue with replicasetInquirer where it could stop performing monitoring if there was no servers available. + +1.3.6 2016-03-15 +---------------- +- Fixed raise condition where multiple replicasetInquirer operations could be started in parallel creating redundant connections. + +1.3.5 2016-03-14 +---------------- +- Handle rogue SSL exceptions (Issue #85, https://github.com/durran). + +1.3.4 2016-03-14 +---------------- +- Added unref options on server, replicaset and mongos (Issue #81, https://github.com/allevo) +- cursorNotFound flag always false (Issue #83, https://github.com/xgfd) +- refactor of events emission of fullsetup and all events (Issue #84, https://github.com/xizhibei) + +1.3.3 2016-03-08 +---------------- +- Added support for promoteLongs option for command function. +- Return connection if no callback available +- Emit connect event when server reconnects after initial connection failed (Issue #76, https://github.com/vkarpov15) +- Introduced optional monitoringSocketTimeout option to allow better control of SDAM monitoring timeouts. +- Made monitoringSocketTimeout default to 30000 if no connectionTimeout value specified or if set to 0. +- Fixed issue where tailable cursor would not retry even though cursor was still alive. +- Disabled exhaust flag support to avoid issues where users could easily write code that would cause memory to run out. +- Handle the case where the first command result document returns an empty list of documents but a live cursor. +- Allow passing down off CANONICALIZE_HOST_NAME and SERVICE_REALM options for kerberos. + +1.3.2 2016-02-09 +---------------- +- Harden MessageHandler in server.js to avoid issues where we cannot find a callback for an operation. +- Ensure RequestId can never be larger than Max Number integer size. + +1.3.1 2016-02-05 +---------------- +- Removed annoying missing Kerberos error (NODE-654). + +1.3.0 2016-02-03 +---------------- +- Added raw support for the command function on topologies. +- Fixed issue where raw results that fell on batchSize boundaries failed (Issue #72) +- Copy over all the properties to the callback returned from bindToDomain, (Issue #72) +- Added connection hash id to be able to reference connection host/name without leaking it outside of driver. +- NODE-638, Cannot authenticate database user with utf-8 password. +- Refactored pool to be worker queue based, minimizing the impact a slow query have on throughput as long as # slow queries < # connections in the pool. +- Pool now grows and shrinks correctly depending on demand not causing a full pool reconnect. +- Improvements in monitoring of a Replicaset where in certain situations the inquiry process could get exited. +- Switched to using Array.push instead of concat for use cases of a lot of documents. +- Fixed issue where re-authentication could loose the credentials if whole Replicaset disconnected at once. +- Added peer optional dependencies support using require_optional module. + +1.2.32 2016-01-12 +----------------- +- Bumped bson to V0.4.21 to allow using minor optimizations. + +1.2.31 2016-01-04 +----------------- +- Allow connection to secondary if primaryPreferred or secondaryPreferred (Issue #70, https://github.com/leichter) + +1.2.30 2015-12-23 +----------------- +- Pool allocates size + 1 connections when using replicasets, reserving additional pool connection for monitoring exclusively. +- Fixes bug when all replicaset members are down, that would cause it to fail to reconnect using the originally provided seedlist. + +1.2.29 2015-12-17 +----------------- +- Correctly emit close event when calling destroy on server topology. + +1.2.28 2015-12-13 +----------------- +- Backed out Prevent Maximum call stack exceeded by calling all callbacks on nextTick, (Issue #64, https://github.com/iamruinous) as it breaks node 0.10.x support. + +1.2.27 2015-12-13 +----------------- +- Added [options.checkServerIdentity=true] {boolean|function}. Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function, (Issue #29). +- Prevent Maximum call stack exceeded by calling all callbacks on nextTick, (Issue #64, https://github.com/iamruinous). +- State is not defined in mongos, (Issue #63, https://github.com/flyingfisher). +- Fixed corner case issue on exhaust cursors on pre 3.0.x MongoDB. + +1.2.26 2015-11-23 +----------------- +- Converted test suite to use mongodb-topology-manager. +- Upgraded bson library to V0.4.20. +- Minor fixes for 3.2 readPreferences. + +1.2.25 2015-11-23 +----------------- +- Correctly error out when passed a seedlist of non-valid server members. + +1.2.24 2015-11-20 +----------------- +- Fix Automattic/mongoose#3481; flush callbacks on error, (Issue #57, https://github.com/vkarpov15). +- $explain query for wire protocol 2.6 and 2.4 does not set number of returned documents to -1 but to 0. + +1.2.23 2015-11-16 +----------------- +- ismaster runs against admin.$cmd instead of system.$cmd. + +1.2.22 2015-11-16 +----------------- +- Fixes to handle getMore command errors for MongoDB 3.2 +- Allows the process to properly close upon a Db.close() call on the replica set by shutting down the haTimer and closing arbiter connections. + +1.2.21 2015-11-07 +----------------- +- Hardened the checking for replicaset equality checks. +- OpReplay flag correctly set on Wire protocol query. +- Mongos load balancing added, introduced localThresholdMS to control the feature. +- Kerberos now a peerDependency, making it not install it by default in Node 5.0 or higher. + +1.2.20 2015-10-28 +----------------- +- Fixed bug in arbiter connection capping code. +- NODE-599 correctly handle arrays of server tags in order of priority. +- Fix for 2.6 wire protocol handler related to readPreference handling. +- Added maxAwaitTimeMS support for 3.2 getMore to allow for custom timeouts on tailable cursors. +- Make CoreCursor check for $err before saying that 'next' succeeded (Issue #53, https://github.com/vkarpov15). + +1.2.19 2015-10-15 +----------------- +- Make batchSize always be > 0 for 3.2 wire protocol to make it work consistently with pre 3.2 servers. +- Locked to bson 0.4.19. + +1.2.18 2015-10-15 +----------------- +- Minor 3.2 fix for handling readPreferences on sharded commands. +- Minor fixes to correctly pass APM specification test suite. + +1.2.17 2015-10-08 +----------------- +- Connections to arbiters only maintain a single connection. + +1.2.15 2015-10-06 +----------------- +- Set slaveOk to true for getMore and killCursors commands. +- Don't swallow callback errors for 2.4 single server (Issue #49, https://github.com/vkarpov15). +- Apply toString('hex') to each buffer in an array when logging (Issue #48, https://github.com/nbrachet). + +1.2.14 2015-09-28 +----------------- +- NODE-547 only emit error if there are any listeners. +- Fixed APM issue with issuing readConcern. + +1.2.13 2015-09-18 +----------------- +- Added BSON serializer ignoreUndefined option for insert/update/remove/command/cursor. + +1.2.12 2015-09-08 +----------------- +- NODE-541 Added initial support for readConcern. + +1.2.11 2015-08-31 +----------------- +- NODE-535 If connectWithNoPrimary is true then primary-only connection is not allowed. +- NODE-534 Passive secondaries are not allowed for secondaryOnlyConnectionAllowed. +- Fixed filtering bug for logging (Issue 30, https://github.com/christkv/mongodb-core/issues/30). + +1.2.10 2015-08-14 +----------------- +- Added missing Mongos.prototype.parserType function. + +1.2.9 2015-08-05 +---------------- +- NODE-525 Reset connectionTimeout after it's overwritten by tls.connect. +- NODE-518 connectTimeoutMS is doubled in 2.0.39. + +1.2.8 2015-07-24 +----------------- +- Minor fix to handle 2.4.x errors better by correctly return driver layer issues. + +1.2.7 2015-07-16 +----------------- +- Refactoring to allow to tap into find/getmore/killcursor in cursors for APM monitoring in driver. + +1.2.6 2015-07-14 +----------------- +- NODE-505 Query fails to find records that have a 'result' property with an array value. + +1.2.5 2015-07-14 +----------------- +- NODE-492 correctly handle hanging replicaset monitoring connections when server is unavailable due to network partitions or firewalls dropping packets, configureable using the connectionTimeoutMS setting. + +1.2.4 2015-07-07 +----------------- +- NODE-493 staggering the socket connections to avoid overwhelming the mongod process. + +1.2.3 2015-06-26 +----------------- +- Minor bug fixes. + +1.2.2 2015-06-22 +----------------- +- Fix issue with SCRAM authentication causing authentication to return true on failed authentication (Issue 26, https://github.com/cglass17). + +1.2.1 2015-06-17 +----------------- +- Ensure serializeFunctions passed down correctly to wire protocol. + +1.2.0 2015-06-17 +----------------- +- Switching to using the 0.4.x pure JS serializer, removing dependency on C++ parser. +- Refactoring wire protocol messages to avoid expensive size calculations of documents in favor of writing out an array of buffers to the sockets. +- NODE-486 fixed issue related to limit and skip when calling toArray in 2.0 driver. +- NODE-483 throw error if capabilities of topology is queries before topology has performed connection setup. +- NODE-487 fixed issue where killcursor command was not being sent correctly on limit and skip queries. + +1.1.33 2015-05-31 +----------------- +- NODE-478 Work around authentication race condition in mongos authentication due to multi step authentication methods like SCRAM. + +1.1.32 2015-05-20 +----------------- +- After reconnect, it updates the allowable reconnect retries to the option settings (Issue #23, https://github.com/owenallenaz) + +1.1.31 2015-05-19 +----------------- +- Minor fixes for issues with re-authentication of mongos. + +1.1.30 2015-05-18 +----------------- +- Correctly emit 'all' event when primary + all secondaries have connected. + +1.1.29 2015-05-17 +----------------- +- NODE-464 Only use a single socket against arbiters and hidden servers. +- Ensure we filter out hidden servers from any server queries. + +1.1.28 2015-05-12 +----------------- +- Fixed buffer compare for electionId for < node 12.0.2 + +1.1.27 2015-05-12 +----------------- +- NODE-455 Update SDAM specification support to cover electionId and Mongos load balancing. + +1.1.26 2015-05-06 +----------------- +- NODE-456 Allow mongodb-core to pipeline commands (ex findAndModify+GLE) along the same connection and handle the returned results. +- Fixes to make mongodb-core work for node 0.8.x when using scram and setImmediate. + +1.1.25 2015-04-24 +----------------- +- Handle lack of callback in crud operations when returning error on application closed. + +1.1.24 2015-04-22 +----------------- +- Error out when topology has been destroyed either by connection retries being exhausted or destroy called on topology. + +1.1.23 2015-04-15 +----------------- +- Standardizing mongoErrors and its API (Issue #14) +- Creating a new connection is slow because of 100ms setTimeout() (Issue #17, https://github.com/vkarpov15) +- remove mkdirp and rimraf dependencies (Issue #12) +- Updated default value of param options.rejectUnauthorized to match documentation (Issue #16) +- ISSUE: NODE-417 Resolution. Improving behavior of thrown errors (Issue #14, https://github.com/owenallenaz) +- Fix cursor hanging when next() called on exhausted cursor (Issue #18, https://github.com/vkarpov15) + +1.1.22 2015-04-10 +----------------- +- Minor refactorings in cursor code to make extending the cursor simpler. +- NODE-417 Resolution. Improving behavior of thrown errors using Error.captureStackTrace. + +1.1.21 2015-03-26 +----------------- +- Updated bson module to 0.3.0 that extracted the c++ parser into bson-ext and made it an optional dependency. + +1.1.20 2015-03-24 +----------------- +- NODE-395 Socket Not Closing, db.close called before full set finished initalizing leading to server connections in progress not being closed properly. + +1.1.19 2015-03-21 +----------------- +- Made kerberos module ~0.0 to allow for quicker releases due to io.js of kerberos module. + +1.1.18 2015-03-17 +----------------- +- Added support for minHeartbeatFrequencyMS on server reconnect according to the SDAM specification. + +1.1.17 2015-03-16 +----------------- +- NODE-377, fixed issue where tags would correctly be checked on secondary and nearest to filter out eligible server candidates. + +1.1.16 2015-03-06 +----------------- +- rejectUnauthorized parameter is set to true for ssl certificates by default instead of false. + +1.1.15 2015-03-04 +----------------- +- Removed check for type in replset pickserver function. + +1.1.14 2015-02-26 +----------------- +- NODE-374 correctly adding passive secondaries to the list of eligable servers for reads + +1.1.13 2015-02-24 +----------------- +- NODE-365 mongoDB native node.js driver infinite reconnect attempts (fixed issue around handling of retry attempts) + +1.1.12 2015-02-16 +----------------- +- Fixed cursor transforms for buffered document reads from cursor. + +1.1.11 2015-02-02 +----------------- +- Remove the required setName for replicaset connections, if not set it will pick the first setName returned. + +1.1.10 2015-31-01 +----------------- +- Added tranforms.doc option to cursor to allow for pr. document transformations. + +1.1.9 2015-21-01 +---------------- +- Updated BSON dependency to 0.2.18 to fix issues with io.js and node. +- Updated Kerberos dependency to 0.0.8 to fix issues with io.js and node. +- Don't treat findOne() as a command cursor. +- Refactored out state changes into methods to simplify read the next method. + +1.1.8 2015-09-12 +---------------- +- Stripped out Object.defineProperty for performance reasons +- Applied more performance optimizations. +- properties cursorBatchSize, cursorSkip, cursorLimit are not methods setCursorBatchSize/cursorBatchSize, setCursorSkip/cursorSkip, setCursorLimit/cursorLimit + +1.1.7 2014-18-12 +---------------- +- Use ns variable for getMore commands for command cursors to work properly with cursor version of listCollections and listIndexes. + +1.1.6 2014-18-12 +---------------- +- Server manager fixed to support 2.2.X servers for travis test matrix. + +1.1.5 2014-17-12 +---------------- +- Fall back to errmsg when creating MongoError for command errors + +1.1.4 2014-17-12 +---------------- +- Added transform method support for cursor (initially just for initial query results) to support listCollections/listIndexes in 2.8. +- Fixed variable leak in scram. +- Fixed server manager to deal better with killing processes. +- Bumped bson to 0.2.16. + +1.1.3 2014-01-12 +---------------- +- Fixed error handling issue with nonce generation in mongocr. +- Fixed issues with restarting servers when using ssl. +- Using strict for all classes. +- Cleaned up any escaping global variables. + +1.1.2 2014-20-11 +---------------- +- Correctly encoding UTF8 collection names on wire protocol messages. +- Added emitClose parameter to topology destroy methods to allow users to specify that they wish the topology to emit the close event to any listeners. + +1.1.1 2014-14-11 +---------------- +- Refactored code to use prototype instead of privileged methods. +- Fixed issue with auth where a runtime condition could leave replicaset members without proper authentication. +- Several deopt optimizations for v8 to improve performance and reduce GC pauses. + +1.0.5 2014-29-10 +---------------- +- Fixed issue with wrong namespace being created for command cursors. + +1.0.4 2014-24-10 +---------------- +- switched from using shift for the cursor due to bad slowdown on big batchSizes as shift causes entire array to be copied on each call. + +1.0.3 2014-21-10 +---------------- +- fixed error issuing problem on cursor.next when iterating over a huge dataset with a very small batchSize. + +1.0.2 2014-07-10 +---------------- +- fullsetup is now defined as a primary and secondary being available allowing for all read preferences to be satisfied. +- fixed issue with replset_state logging. + +1.0.1 2014-07-10 +---------------- +- Dependency issue solved + +1.0.0 2014-07-10 +---------------- +- Initial release of mongodb-core diff --git a/node_modules/mongoose/node_modules/mongodb-core/LICENSE b/node_modules/mongoose/node_modules/mongodb-core/LICENSE new file mode 100644 index 0000000..ad410e1 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/node_modules/mongoose/node_modules/mongodb-core/Makefile b/node_modules/mongoose/node_modules/mongodb-core/Makefile new file mode 100644 index 0000000..36e1202 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/Makefile @@ -0,0 +1,11 @@ +NODE = node +NPM = npm +JSDOC = jsdoc +name = all + +generate_docs: + # cp -R ./HISTORY.md ./docs/content/meta/release-notes.md + hugo -s docs/reference -d ../../public + $(JSDOC) -c conf.json -t docs/jsdoc-template/ -d ./public/api + cp -R ./public/api/scripts ./public/. + cp -R ./public/api/styles ./public/. diff --git a/node_modules/mongoose/node_modules/mongodb-core/README.md b/node_modules/mongoose/node_modules/mongodb-core/README.md new file mode 100644 index 0000000..433dd88 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/README.md @@ -0,0 +1,228 @@ +[![Build Status](https://secure.travis-ci.org/christkv/mongodb-core.png)](http://travis-ci.org/christkv/mongodb-core) +[![Coverage Status](https://coveralls.io/repos/github/christkv/mongodb-core/badge.svg?branch=1.3)](https://coveralls.io/github/christkv/mongodb-core?branch=1.3) + +# Description + +The MongoDB Core driver is the low level part of the 2.0 or higher MongoDB driver and is meant for library developers not end users. It does not contain any abstractions or helpers outside of the basic management of MongoDB topology connections, CRUD operations and authentication. + +## MongoDB Node.JS Core Driver + +| what | where | +|---------------|------------------------------------------------| +| documentation | http://mongodb.github.io/node-mongodb-native/ | +| apidoc | http://mongodb.github.io/node-mongodb-native/ | +| source | https://github.com/christkv/mongodb-core | +| mongodb | http://www.mongodb.org/ | + +### Blogs of Engineers involved in the driver +- Christian Kvalheim [@christkv](https://twitter.com/christkv) + +### Bugs / Feature Requests + +Think you’ve found a bug? Want to see a new feature in node-mongodb-native? Please open a +case in our issue management tool, JIRA: + +- Create an account and login . +- Navigate to the NODE project . +- Click **Create Issue** - Please provide as much information as possible about the issue type and how to reproduce it. + +Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the +Core Server (i.e. SERVER) project are **public**. + +### Questions and Bug Reports + + * mailing list: https://groups.google.com/forum/#!forum/node-mongodb-native + * jira: http://jira.mongodb.org/ + +### Change Log + +http://jira.mongodb.org/browse/NODE + +# QuickStart + +The quick start guide will show you how to set up a simple application using Core driver and MongoDB. It scope is only how to set up the driver and perform the simple crud operations. For more inn depth coverage we encourage reading the tutorials. + +## Create the package.json file + +Let's create a directory where our application will live. In our case we will put this under our projects directory. + +``` +mkdir myproject +cd myproject +``` + +Create a **package.json** using your favorite text editor and fill it in. + +```json +{ + "name": "myproject", + "version": "1.0.0", + "description": "My first project", + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/christkv/myfirstproject.git" + }, + "dependencies": { + "mongodb-core": "~1.0" + }, + "author": "Christian Kvalheim", + "license": "Apache 2.0", + "bugs": { + "url": "https://github.com/christkv/myfirstproject/issues" + }, + "homepage": "https://github.com/christkv/myfirstproject" +} +``` + +Save the file and return to the shell or command prompt and use **NPM** to install all the dependencies. + +``` +npm install +``` + +You should see **NPM** download a lot of files. Once it's done you'll find all the downloaded packages under the **node_modules** directory. + +Booting up a MongoDB Server +--------------------------- +Let's boot up a MongoDB server instance. Download the right MongoDB version from [MongoDB](http://www.mongodb.org), open a new shell or command line and ensure the **mongod** command is in the shell or command line path. Now let's create a database directory (in our case under **/data**). + +``` +mongod --dbpath=/data --port 27017 +``` + +You should see the **mongod** process start up and print some status information. + +## Connecting to MongoDB + +Let's create a new **app.js** file that we will use to show the basic CRUD operations using the MongoDB driver. + +First let's add code to connect to the server. Notice that there is no concept of a database here and we use the topology directly to perform the connection. + +```js +var Server = require('mongodb-core').Server + , assert = require('assert'); + +// Set up server connection +var server = new Server({ + host: 'localhost' + , port: 27017 + , reconnect: true + , reconnectInterval: 50 +}); + +// Add event listeners +server.on('connect', function(_server) { + console.log('connected'); + test.done(); +}); + +server.on('close', function() { + console.log('closed'); +}); + +server.on('reconnect', function() { + console.log('reconnect'); +}); + +// Start connection +server.connect(); +``` + +To connect to a replicaset we would use the `ReplSet` class and for a set of Mongos proxies we use the `Mongos` class. Each topology class offer the same CRUD operations and you operate on the topology directly. Let's look at an example exercising all the different available CRUD operations. + +```js +var Server = require('mongodb-core').Server + , assert = require('assert'); + +// Set up server connection +var server = new Server({ + host: 'localhost' + , port: 27017 + , reconnect: true + , reconnectInterval: 50 +}); + +// Add event listeners +server.on('connect', function(_server) { + console.log('connected'); + + // Execute the ismaster command + _server.command('system.$cmd', {ismaster: true}, function(err, result) { + + // Perform a document insert + _server.insert('myproject.inserts1', [{a:1}, {a:2}], { + writeConcern: {w:1}, ordered:true + }, function(err, results) { + assert.equal(null, err); + assert.equal(2, results.result.n); + + // Perform a document update + _server.update('myproject.inserts1', [{ + q: {a: 1}, u: {'$set': {b:1}} + }], { + writeConcern: {w:1}, ordered:true + }, function(err, results) { + assert.equal(null, err); + assert.equal(1, results.result.n); + + // Remove a document + _server.remove('myproject.inserts1', [{ + q: {a: 1}, limit: 1 + }], { + writeConcern: {w:1}, ordered:true + }, function(err, results) { + assert.equal(null, err); + assert.equal(1, results.result.n); + + // Get a document + var cursor = _server.cursor('integration_tests.inserts_example4', { + find: 'integration_tests.example4' + , query: {a:1} + }); + + // Get the first document + cursor.next(function(err, doc) { + assert.equal(null, err); + assert.equal(2, doc.a); + + // Execute the ismaster command + _server.command("system.$cmd" + , {ismaster: true}, function(err, result) { + assert.equal(null, err) + _server.destroy(); + }); + }); + }); + }); + + test.done(); + }); +}); + +server.on('close', function() { + console.log('closed'); +}); + +server.on('reconnect', function() { + console.log('reconnect'); +}); + +// Start connection +server.connect(); +``` + +The core driver does not contain any helpers or abstractions only the core crud operations. These consist of the following commands. + +* `insert`, Insert takes an array of 1 or more documents to be inserted against the topology and allows you to specify a write concern and if you wish to execute the inserts in order or out of order. +* `update`, Update takes an array of 1 or more update commands to be executed against the server topology and also allows you to specify a write concern and if you wish to execute the updates in order or out of order. +* `remove`, Remove takes an array of 1 or more remove commands to be executed against the server topology and also allows you to specify a write concern and if you wish to execute the removes in order or out of order. +* `cursor`, Returns you a cursor for either the 'virtual' `find` command, a command that returns a cursor id or a plain cursor id. Read the cursor tutorial for more inn depth coverage. +* `command`, Executes a command against MongoDB and returns the result. +* `auth`, Authenticates the current topology using a supported authentication scheme. + +The Core Driver is a building block for library builders and is not meant for usage by end users as it lacks a lot of features the end user might need such as automatic buffering of operations when a primary is changing in a replicaset or the db and collections abstraction. + +## Next steps + +The next step is to get more in depth information about how the different aspects of the core driver works and how to leverage them to extend the functionality of the cursors. Please view the tutorials for more detailed information. diff --git a/node_modules/mongodb-core/TESTING.md b/node_modules/mongoose/node_modules/mongodb-core/TESTING.md similarity index 100% rename from node_modules/mongodb-core/TESTING.md rename to node_modules/mongoose/node_modules/mongodb-core/TESTING.md diff --git a/node_modules/mongoose/node_modules/mongodb-core/THIRD-PARTY-NOTICES b/node_modules/mongoose/node_modules/mongodb-core/THIRD-PARTY-NOTICES new file mode 100644 index 0000000..c13e5d9 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/THIRD-PARTY-NOTICES @@ -0,0 +1,41 @@ +Mongodb-core uses third-party libraries or other resources that may +be distributed under licenses different than the Mongodb-core software. + +In the event that we accidentally failed to list a required notice, +please bring it to our attention through any of the ways detailed here: + + mongodb-dev@googlegroups.com + +The attached notices are provided for information only. + +For any licenses that require disclosure of source, sources are available at +https://github.com/mongodb/node-mongodb-native. + +1) License Notice for nan.h +--------------------------- + +The MIT License (MIT) +===================== + +Copyright (c) 2016 NAN contributors +----------------------------------- + +NAN contributors listed at + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to +do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/node_modules/mongoose/node_modules/mongodb-core/conf.json b/node_modules/mongoose/node_modules/mongodb-core/conf.json new file mode 100644 index 0000000..12ce4c7 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/conf.json @@ -0,0 +1,59 @@ +{ + "plugins": ["plugins/markdown", "docs/lib/jsdoc/examples_plugin.js"], + "source": { + "include": [ + "test/tests/functional/operation_example_tests.js", + "lib/connection/command_result.js", + "lib/topologies/mongos.js", + "lib/topologies/read_preference.js", + "lib/topologies/replset.js", + "lib/topologies/server.js", + "lib/topologies/replset_state.js", + "lib/connection/logger.js", + "lib/connection/connection.js", + "lib/cursor.js", + "lib/error.js", + "node_modules/bson/lib/bson/binary.js", + "node_modules/bson/lib/bson/code.js", + "node_modules/bson/lib/bson/db_ref.js", + "node_modules/bson/lib/bson/double.js", + "node_modules/bson/lib/bson/long.js", + "node_modules/bson/lib/bson/objectid.js", + "node_modules/bson/lib/bson/symbol.js", + "node_modules/bson/lib/bson/timestamp.js", + "node_modules/bson/lib/bson/max_key.js", + "node_modules/bson/lib/bson/min_key.js" + ] + }, + "templates": { + "cleverLinks": true, + "monospaceLinks": true, + "default": { + "outputSourceFiles" : true + }, + "applicationName": "Node.js MongoDB Driver API", + "disqus": true, + "googleAnalytics": "UA-29229787-1", + "openGraph": { + "title": "", + "type": "website", + "image": "", + "site_name": "", + "url": "" + }, + "meta": { + "title": "", + "description": "", + "keyword": "" + }, + "linenums": true + }, + "markdown": { + "parser": "gfm", + "hardwrap": true, + "tags": ["examples"] + }, + "examples": { + "indent": 4 + } +} diff --git a/node_modules/mongoose/node_modules/mongodb-core/index.js b/node_modules/mongoose/node_modules/mongodb-core/index.js new file mode 100644 index 0000000..4a63acc --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/index.js @@ -0,0 +1,32 @@ +var BSON = require('bson'); +var require_optional = require('require_optional'); + +try { + // Attempt to grab the native BSON parser + var BSONNative = require_optional('bson-ext'); + // If we got the native parser, use it instead of the + // Javascript one + if(BSONNative) { + BSON = BSONNative + } +} catch(err) {} + +module.exports = { + MongoError: require('./lib/error') + , Connection: require('./lib/connection/connection') + , Server: require('./lib/topologies/server') + , ReplSet: require('./lib/topologies/replset') + , Mongos: require('./lib/topologies/mongos') + , Logger: require('./lib/connection/logger') + , Cursor: require('./lib/cursor') + , ReadPreference: require('./lib/topologies/read_preference') + , BSON: BSON + // Raw operations + , Query: require('./lib/connection/commands').Query + // Auth mechanisms + , MongoCR: require('./lib/auth/mongocr') + , X509: require('./lib/auth/x509') + , Plain: require('./lib/auth/plain') + , GSSAPI: require('./lib/auth/gssapi') + , ScramSHA1: require('./lib/auth/scram') +} diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/gssapi.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/gssapi.js new file mode 100644 index 0000000..7fe3026 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/gssapi.js @@ -0,0 +1,262 @@ +"use strict"; + +var f = require('util').format + , require_optional = require('require_optional') + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var AuthSession = function(db, username, password, options) { + this.db = db; + this.username = username; + this.password = password; + this.options = options; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +// Kerberos class +var Kerberos = null; +var MongoAuthProcess = null; + +// Try to grab the Kerberos class +try { + Kerberos = require_optional('kerberos').Kerberos; + // Authentication process for Mongo + MongoAuthProcess = require_optional('kerberos').processes.MongoAuthProcess; +} catch(err) { +} + +/** + * Creates a new GSSAPI authentication mechanism + * @class + * @return {GSSAPI} A cursor instance + */ +var GSSAPI = function(bson) { + this.bson = bson; + this.authStore = []; +} + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +GSSAPI.prototype.auth = function(server, connections, db, username, password, options, callback) { + var self = this; + // We don't have the Kerberos library + if(Kerberos == null) return callback(new Error("Kerberos library is not installed")); + var gssapiServiceName = options['gssapiServiceName'] || 'mongodb'; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // For each connection we need to authenticate + while(connections.length > 0) { + // Execute MongoCR + var execute = function(connection) { + // Start Auth process for a connection + GSSAPIInitialize(self, db, username, password, db, gssapiServiceName, server, connection, options, function(err, r) { + // Adjust count + count = count - 1; + + // If we have an error + if(err) { + errorObject = err; + } else if(r.result['$err']) { + errorObject = r.result; + } else if(r.result['errmsg']) { + errorObject = r.result; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + // We have authenticated all connections + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password, options)); + // Return correct authentication + callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using mongocr")); + callback(errorObject, false); + } + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + execute(_connection); + }); + } + + _execute(connections.shift()); + } +} + +// +// Initialize step +var GSSAPIInitialize = function(self, db, username, password, authdb, gssapiServiceName, server, connection, options, callback) { + // Create authenticator + var mongo_auth_process = new MongoAuthProcess(connection.host, connection.port, gssapiServiceName, options); + + // Perform initialization + mongo_auth_process.init(username, password, function(err) { + if(err) return callback(err, false); + + // Perform the first step + mongo_auth_process.transition('', function(err, payload) { + if(err) return callback(err, false); + + // Call the next db step + MongoDBGSSAPIFirstStep(self, mongo_auth_process, payload, db, username, password, authdb, server, connection, callback); + }); + }); +} + +// +// Perform first step against mongodb +var MongoDBGSSAPIFirstStep = function(self, mongo_auth_process, payload, db, username, password, authdb, server, connection, callback) { + // Build the sasl start command + var command = { + saslStart: 1 + , mechanism: 'GSSAPI' + , payload: payload + , autoAuthorize: 1 + }; + + // Write the commmand on the connection + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + // Execute mongodb transition + mongo_auth_process.transition(r.result.payload, function(err, payload) { + if(err) return callback(err, false); + + // MongoDB API Second Step + MongoDBGSSAPISecondStep(self, mongo_auth_process, payload, doc, db, username, password, authdb, server, connection, callback); + }); + }); +} + +// +// Perform first step against mongodb +var MongoDBGSSAPISecondStep = function(self, mongo_auth_process, payload, doc, db, username, password, authdb, server, connection, callback) { + // Build Authentication command to send to MongoDB + var command = { + saslContinue: 1 + , conversationId: doc.conversationId + , payload: payload + }; + + // Execute the command + // Write the commmand on the connection + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + // Call next transition for kerberos + mongo_auth_process.transition(doc.payload, function(err, payload) { + if(err) return callback(err, false); + + // Call the last and third step + MongoDBGSSAPIThirdStep(self, mongo_auth_process, payload, doc, db, username, password, authdb, server, connection, callback); + }); + }); +} + +var MongoDBGSSAPIThirdStep = function(self, mongo_auth_process, payload, doc, db, username, password, authdb, server, connection, callback) { + // Build final command + var command = { + saslContinue: 1 + , conversationId: doc.conversationId + , payload: payload + }; + + // Execute the command + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + mongo_auth_process.transition(null, function(err) { + if(err) return callback(err, null); + callback(null, r); + }); + }); +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +GSSAPI.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +GSSAPI.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, authStore[i].options, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + +/** + * This is a result from a authentication strategy + * + * @callback authResultCallback + * @param {error} error An error object. Set to null if no error present + * @param {boolean} result The result of the authentication process + */ + +module.exports = GSSAPI; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/mongocr.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/mongocr.js new file mode 100644 index 0000000..14e3c4d --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/mongocr.js @@ -0,0 +1,181 @@ +"use strict"; + +var f = require('util').format + , crypto = require('crypto') + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var AuthSession = function(db, username, password) { + this.db = db; + this.username = username; + this.password = password; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +/** + * Creates a new MongoCR authentication mechanism + * @class + * @return {MongoCR} A cursor instance + */ +var MongoCR = function(bson) { + this.bson = bson; + this.authStore = []; +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +MongoCR.prototype.auth = function(server, connections, db, username, password, callback) { + var self = this; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // For each connection we need to authenticate + while(connections.length > 0) { + // Execute MongoCR + var executeMongoCR = function(connection) { + // Write the commmand on the connection + server(connection, new Query(self.bson, f("%s.$cmd", db), { + getnonce:1 + }, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + var nonce = null; + var key = null; + + // Adjust the number of connections left + // Get nonce + if(err == null) { + nonce = r.result.nonce; + // Use node md5 generator + var md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ":mongo:" + password, 'utf8'); + var hash_password = md5.digest('hex'); + // Final key + md5 = crypto.createHash('md5'); + md5.update(nonce + username + hash_password, 'utf8'); + key = md5.digest('hex'); + } + + // Execute command + // Write the commmand on the connection + server(connection, new Query(self.bson, f("%s.$cmd", db), { + authenticate: 1, user: username, nonce: nonce, key:key + }, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + count = count - 1; + + // If we have an error + if(err) { + errorObject = err; + } else if(r.result['$err']) { + errorObject = r.result; + } else if(r.result['errmsg']) { + errorObject = r.result; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + // We have authenticated all connections + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password)); + // Return correct authentication + callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using mongocr")); + callback(errorObject, false); + } + }); + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + executeMongoCR(_connection); + }); + } + + _execute(connections.shift()); + } +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +MongoCR.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +MongoCR.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + +/** + * This is a result from a authentication strategy + * + * @callback authResultCallback + * @param {error} error An error object. Set to null if no error present + * @param {boolean} result The result of the authentication process + */ + +module.exports = MongoCR; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/plain.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/plain.js new file mode 100644 index 0000000..87f4820 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/plain.js @@ -0,0 +1,168 @@ +"use strict"; + +var f = require('util').format + , retrieveBSON = require('../connection/utils').retrieveBSON + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var BSON = retrieveBSON() + , Binary = BSON.Binary; + +var AuthSession = function(db, username, password) { + this.db = db; + this.username = username; + this.password = password; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +/** + * Creates a new Plain authentication mechanism + * @class + * @return {Plain} A cursor instance + */ +var Plain = function(bson) { + this.bson = bson; + this.authStore = []; +} + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +Plain.prototype.auth = function(server, connections, db, username, password, callback) { + var self = this; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // For each connection we need to authenticate + while(connections.length > 0) { + // Execute MongoCR + var execute = function(connection) { + // Create payload + var payload = new Binary(f("\x00%s\x00%s", username, password)); + + // Let's start the sasl process + var command = { + saslStart: 1 + , mechanism: 'PLAIN' + , payload: payload + , autoAuthorize: 1 + }; + + // Let's start the process + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + // Adjust count + count = count - 1; + + // If we have an error + if(err) { + errorObject = err; + } else if(r.result['$err']) { + errorObject = r.result; + } else if(r.result['errmsg']) { + errorObject = r.result; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + // We have authenticated all connections + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password)); + // Return correct authentication + callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using mongocr")); + callback(errorObject, false); + } + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + execute(_connection); + }); + } + + _execute(connections.shift()); + } +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +Plain.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +Plain.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + +/** + * This is a result from a authentication strategy + * + * @callback authResultCallback + * @param {error} error An error object. Set to null if no error present + * @param {boolean} result The result of the authentication process + */ + +module.exports = Plain; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js new file mode 100644 index 0000000..a02a159 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js @@ -0,0 +1,339 @@ +"use strict"; + +var f = require('util').format + , crypto = require('crypto') + , retrieveBSON = require('../connection/utils').retrieveBSON + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var BSON = retrieveBSON(), + Binary = BSON.Binary; + +var AuthSession = function(db, username, password) { + this.db = db; + this.username = username; + this.password = password; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +var id = 0; + +/** + * Creates a new ScramSHA1 authentication mechanism + * @class + * @return {ScramSHA1} A cursor instance + */ +var ScramSHA1 = function(bson) { + this.bson = bson; + this.authStore = []; + this.id = id++; +} + +var parsePayload = function(payload) { + var dict = {}; + var parts = payload.split(','); + + for(var i = 0; i < parts.length; i++) { + var valueParts = parts[i].split('='); + dict[valueParts[0]] = valueParts[1]; + } + + return dict; +} + +var passwordDigest = function(username, password) { + if(typeof username != 'string') throw new MongoError("username must be a string"); + if(typeof password != 'string') throw new MongoError("password must be a string"); + if(password.length == 0) throw new MongoError("password cannot be empty"); + // Use node md5 generator + var md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ":mongo:" + password, 'utf8'); + return md5.digest('hex'); +} + +// XOR two buffers +var xor = function(a, b) { + if (!Buffer.isBuffer(a)) a = new Buffer(a) + if (!Buffer.isBuffer(b)) b = new Buffer(b) + var res = [] + if (a.length > b.length) { + for (var i = 0; i < b.length; i++) { + res.push(a[i] ^ b[i]) + } + } else { + for (i = 0; i < a.length; i++) { + res.push(a[i] ^ b[i]) + } + } + return new Buffer(res); +} + +var _hiCache = {}; +var _hiCacheCount = 0; +var _hiCachePurge = function() { + _hiCache = {}; + _hiCacheCount = 0; +}; + +var hi = function(data, salt, iterations) { + // omit the work if already generated + var key = [data, salt.toString('base64'), iterations].join('_'); + if (_hiCache[key] !== undefined) { + return _hiCache[key]; + } + + // generate the salt + var saltedData = crypto.pbkdf2Sync(data, salt, iterations, 20, "sha1"); + + // cache a copy to speed up the next lookup, but prevent unbounded cache growth + if (_hiCacheCount >= 200) { + _hiCachePurge(); + } + + _hiCache[key] = saltedData; + _hiCacheCount += 1; + return saltedData; +}; + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +ScramSHA1.prototype.auth = function(server, connections, db, username, password, callback) { + var self = this; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // Execute MongoCR + var executeScram = function(connection) { + // Clean up the user + username = username.replace('=', "=3D").replace(',', '=2C'); + + // Create a random nonce + var nonce = crypto.randomBytes(24).toString('base64'); + // var nonce = 'MsQUY9iw0T9fx2MUEz6LZPwGuhVvWAhc' + var firstBare = f("n=%s,r=%s", username, nonce); + + // Build command structure + var cmd = { + saslStart: 1 + , mechanism: 'SCRAM-SHA-1' + , payload: new Binary(f("n,,%s", firstBare)) + , autoAuthorize: 1 + } + + // Handle the error + var handleError = function(err, r) { + if(err) { + numberOfValidConnections = numberOfValidConnections - 1; + errorObject = err; return false; + } else if(r.result['$err']) { + errorObject = r.result; return false; + } else if(r.result['errmsg']) { + errorObject = r.result; return false; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + return true + } + + // Finish up + var finish = function(_count, _numberOfValidConnections) { + if(_count == 0 && _numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password)); + // Return correct authentication + return callback(null, true); + } else if(_count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using scram")); + return callback(errorObject, false); + } + } + + var handleEnd = function(_err, _r) { + // Handle any error + handleError(_err, _r) + // Adjust the number of connections + count = count - 1; + // Execute the finish + finish(count, numberOfValidConnections); + } + + // Write the commmand on the connection + server(connection, new Query(self.bson, f("%s.$cmd", db), cmd, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + // Do we have an error, handle it + if(handleError(err, r) == false) { + count = count - 1; + + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password)); + // Return correct authentication + return callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using scram")); + return callback(errorObject, false); + } + + return; + } + + // Get the dictionary + var dict = parsePayload(r.result.payload.value()) + + // Unpack dictionary + var iterations = parseInt(dict.i, 10); + var salt = dict.s; + var rnonce = dict.r; + + // Set up start of proof + var withoutProof = f("c=biws,r=%s", rnonce); + var passwordDig = passwordDigest(username, password); + var saltedPassword = hi(passwordDig + , new Buffer(salt, 'base64') + , iterations); + + // Create the client key + var hmac = crypto.createHmac('sha1', saltedPassword); + hmac.update(new Buffer("Client Key")); + var clientKey = new Buffer(hmac.digest('base64'), 'base64'); + + // Create the stored key + var hash = crypto.createHash('sha1'); + hash.update(clientKey); + var storedKey = new Buffer(hash.digest('base64'), 'base64'); + + // Create the authentication message + var authMsg = [firstBare, r.result.payload.value().toString('base64'), withoutProof].join(','); + + // Create client signature + hmac = crypto.createHmac('sha1', storedKey); + hmac.update(new Buffer(authMsg)); + var clientSig = new Buffer(hmac.digest('base64'), 'base64'); + + // Create client proof + var clientProof = f("p=%s", new Buffer(xor(clientKey, clientSig)).toString('base64')); + + // Create client final + var clientFinal = [withoutProof, clientProof].join(','); + + // + // Create continue message + var cmd = { + saslContinue: 1 + , conversationId: r.result.conversationId + , payload: new Binary(new Buffer(clientFinal)) + } + + // + // Execute sasl continue + // Write the commmand on the connection + server(connection, new Query(self.bson, f("%s.$cmd", db), cmd, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(r && r.result.done == false) { + var cmd = { + saslContinue: 1 + , conversationId: r.result.conversationId + , payload: new Buffer(0) + } + + // Write the commmand on the connection + server(connection, new Query(self.bson, f("%s.$cmd", db), cmd, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + handleEnd(err, r); + }); + } else { + handleEnd(err, r); + } + }); + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + executeScram(_connection); + }); + } + + // For each connection we need to authenticate + while(connections.length > 0) { + _execute(connections.shift()); + } +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +ScramSHA1.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +ScramSHA1.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + // No connections + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + + +module.exports = ScramSHA1; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/sspi.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/sspi.js new file mode 100644 index 0000000..ef4874c --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/sspi.js @@ -0,0 +1,250 @@ +"use strict"; + +var f = require('util').format + , require_optional = require('require_optional') + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var AuthSession = function(db, username, password, options) { + this.db = db; + this.username = username; + this.password = password; + this.options = options; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +// Kerberos class +var Kerberos = null; +var MongoAuthProcess = null; + +// Try to grab the Kerberos class +try { + Kerberos = require_optional('kerberos').Kerberos + // Authentication process for Mongo + MongoAuthProcess = require_optional('kerberos').processes.MongoAuthProcess +} catch(err) {} + +/** + * Creates a new SSPI authentication mechanism + * @class + * @return {SSPI} A cursor instance + */ +var SSPI = function(bson) { + this.bson = bson; + this.authStore = []; +} + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +SSPI.prototype.auth = function(server, connections, db, username, password, options, callback) { + var self = this; + // We don't have the Kerberos library + if(Kerberos == null) return callback(new Error("Kerberos library is not installed")); + var gssapiServiceName = options['gssapiServiceName'] || 'mongodb'; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // For each connection we need to authenticate + while(connections.length > 0) { + // Execute MongoCR + var execute = function(connection) { + // Start Auth process for a connection + SSIPAuthenticate(self, username, password, gssapiServiceName, server, connection, options, function(err, r) { + // Adjust count + count = count - 1; + + // If we have an error + if(err) { + errorObject = err; + } else if(r && typeof r == 'object' && r.result['$err']) { + errorObject = r.result; + } else if(r && typeof r == 'object' && r.result['errmsg']) { + errorObject = r.result; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + // We have authenticated all connections + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password, options)); + // Return correct authentication + callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using mongocr")); + callback(errorObject, false); + } + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + execute(_connection); + }); + } + + _execute(connections.shift()); + } +} + +var SSIPAuthenticate = function(self, username, password, gssapiServiceName, server, connection, options, callback) { + // Build Authentication command to send to MongoDB + var command = { + saslStart: 1 + , mechanism: 'GSSAPI' + , payload: '' + , autoAuthorize: 1 + }; + + // Create authenticator + var mongo_auth_process = new MongoAuthProcess(connection.host, connection.port, gssapiServiceName, options); + + // Execute first sasl step + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + + mongo_auth_process.init(username, password, function(err) { + if(err) return callback(err); + + mongo_auth_process.transition(doc.payload, function(err, payload) { + if(err) return callback(err); + + // Perform the next step against mongod + var command = { + saslContinue: 1 + , conversationId: doc.conversationId + , payload: payload + }; + + // Execute the command + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + + mongo_auth_process.transition(doc.payload, function(err, payload) { + if(err) return callback(err); + + // Perform the next step against mongod + var command = { + saslContinue: 1 + , conversationId: doc.conversationId + , payload: payload + }; + + // Execute the command + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + + mongo_auth_process.transition(doc.payload, function(err, payload) { + // Perform the next step against mongod + var command = { + saslContinue: 1 + , conversationId: doc.conversationId + , payload: payload + }; + + // Execute the command + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + if(err) return callback(err, false); + var doc = r.result; + + if(doc.done) return callback(null, true); + callback(new Error("Authentication failed"), false); + }); + }); + }); + }); + }); + }); + }); + }); +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +SSPI.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +SSPI.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, authStore[i].options, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + +/** + * This is a result from a authentication strategy + * + * @callback authResultCallback + * @param {error} error An error object. Set to null if no error present + * @param {boolean} result The result of the authentication process + */ + +module.exports = SSPI; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/auth/x509.js b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/x509.js new file mode 100644 index 0000000..0b75d79 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/auth/x509.js @@ -0,0 +1,164 @@ +"use strict"; + +var f = require('util').format + , Query = require('../connection/commands').Query + , MongoError = require('../error'); + +var AuthSession = function(db, username, password) { + this.db = db; + this.username = username; + this.password = password; +} + +AuthSession.prototype.equal = function(session) { + return session.db == this.db + && session.username == this.username + && session.password == this.password; +} + +/** + * Creates a new X509 authentication mechanism + * @class + * @return {X509} A cursor instance + */ +var X509 = function(bson) { + this.bson = bson; + this.authStore = []; +} + +/** + * Authenticate + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {string} db Name of the database + * @param {string} username Username + * @param {string} password Password + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +X509.prototype.auth = function(server, connections, db, username, password, callback) { + var self = this; + // Total connections + var count = connections.length; + if(count == 0) return callback(null, null); + + // Valid connections + var numberOfValidConnections = 0; + var errorObject = null; + + // For each connection we need to authenticate + while(connections.length > 0) { + // Execute MongoCR + var execute = function(connection) { + // Let's start the sasl process + var command = { + authenticate: 1 + , mechanism: 'MONGODB-X509' + }; + + // Add username if specified + if(username) { + command.user = username; + } + + // Let's start the process + server(connection, new Query(self.bson, "$external.$cmd", command, { + numberToSkip: 0, numberToReturn: 1 + }), function(err, r) { + // Adjust count + count = count - 1; + + // If we have an error + if(err) { + errorObject = err; + } else if(r.result['$err']) { + errorObject = r.result; + } else if(r.result['errmsg']) { + errorObject = r.result; + } else { + numberOfValidConnections = numberOfValidConnections + 1; + } + + // We have authenticated all connections + if(count == 0 && numberOfValidConnections > 0) { + // Store the auth details + addAuthSession(self.authStore, new AuthSession(db, username, password)); + // Return correct authentication + callback(null, true); + } else if(count == 0) { + if(errorObject == null) errorObject = new MongoError(f("failed to authenticate using mongocr")); + callback(errorObject, false); + } + }); + } + + var _execute = function(_connection) { + process.nextTick(function() { + execute(_connection); + }); + } + + _execute(connections.shift()); + } +} + +// Add to store only if it does not exist +var addAuthSession = function(authStore, session) { + var found = false; + + for(var i = 0; i < authStore.length; i++) { + if(authStore[i].equal(session)) { + found = true; + break; + } + } + + if(!found) authStore.push(session); +} + +/** + * Remove authStore credentials + * @method + * @param {string} db Name of database we are removing authStore details about + * @return {object} + */ +X509.prototype.logout = function(dbName) { + this.authStore = this.authStore.filter(function(x) { + return x.db != dbName; + }); +} + +/** + * Re authenticate pool + * @method + * @param {{Server}|{ReplSet}|{Mongos}} server Topology the authentication method is being called on + * @param {[]Connections} connections Connections to authenticate using this authenticator + * @param {authResultCallback} callback The callback to return the result from the authentication + * @return {object} + */ +X509.prototype.reauthenticate = function(server, connections, callback) { + var authStore = this.authStore.slice(0); + var count = authStore.length; + if(count == 0) return callback(null, null); + // Iterate over all the auth details stored + for(var i = 0; i < authStore.length; i++) { + this.auth(server, connections, authStore[i].db, authStore[i].username, authStore[i].password, function(err) { + count = count - 1; + // Done re-authenticating + if(count == 0) { + callback(err, null); + } + }); + } +} + +/** + * This is a result from a authentication strategy + * + * @callback authResultCallback + * @param {error} error An error object. Set to null if no error present + * @param {boolean} result The result of the authentication process + */ + +module.exports = X509; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/command_result.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/command_result.js new file mode 100644 index 0000000..2b15dd7 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/command_result.js @@ -0,0 +1,34 @@ +"use strict"; + +/** + * Creates a new CommandResult instance + * @class + * @param {object} result CommandResult object + * @param {Connection} connection A connection instance associated with this result + * @return {CommandResult} A cursor instance + */ +var CommandResult = function(result, connection, message) { + this.result = result; + this.connection = connection; + this.message = message; +} + +/** + * Convert CommandResult to JSON + * @method + * @return {object} + */ +CommandResult.prototype.toJSON = function() { + return this.result; +} + +/** + * Convert CommandResult to String representation + * @method + * @return {string} + */ +CommandResult.prototype.toString = function() { + return JSON.stringify(this.toJSON()); +} + +module.exports = CommandResult; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/commands.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/commands.js new file mode 100644 index 0000000..b4c1684 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/commands.js @@ -0,0 +1,546 @@ +"use strict"; + +var retrieveBSON = require('../connection/utils').retrieveBSON; +var BSON = retrieveBSON(); +var Long = BSON.Long; + +// Incrementing request id +var _requestId = 0; + +// Wire command operation ids +var OP_QUERY = 2004; +var OP_GETMORE = 2005; +var OP_KILL_CURSORS = 2007; + +// Query flags +var OPTS_TAILABLE_CURSOR = 2; +var OPTS_SLAVE = 4; +var OPTS_OPLOG_REPLAY = 8; +var OPTS_NO_CURSOR_TIMEOUT = 16; +var OPTS_AWAIT_DATA = 32; +var OPTS_EXHAUST = 64; +var OPTS_PARTIAL = 128; + +// Response flags +var CURSOR_NOT_FOUND = 0; +var QUERY_FAILURE = 2; +var SHARD_CONFIG_STALE = 4; +var AWAIT_CAPABLE = 8; + +/************************************************************** + * QUERY + **************************************************************/ +var Query = function(bson, ns, query, options) { + var self = this; + // Basic options needed to be passed in + if(ns == null) throw new Error("ns must be specified for query"); + if(query == null) throw new Error("query must be specified for query"); + + // Validate that we are not passing 0x00 in the collection name + if(!!~ns.indexOf("\x00")) { + throw new Error("namespace cannot contain a null character"); + } + + // Basic options + this.bson = bson; + this.ns = ns; + this.query = query; + + // Ensure empty options + this.options = options || {}; + + // Additional options + this.numberToSkip = options.numberToSkip || 0; + this.numberToReturn = options.numberToReturn || 0; + this.returnFieldSelector = options.returnFieldSelector || null; + this.requestId = Query.getRequestId(); + + // Serialization option + this.serializeFunctions = typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false; + this.ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : false; + this.maxBsonSize = options.maxBsonSize || 1024 * 1024 * 16; + this.checkKeys = typeof options.checkKeys == 'boolean' ? options.checkKeys : true; + this.batchSize = self.numberToReturn; + + // Flags + this.tailable = false; + this.slaveOk = typeof options.slaveOk == 'boolean'? options.slaveOk : false; + this.oplogReplay = false; + this.noCursorTimeout = false; + this.awaitData = false; + this.exhaust = false; + this.partial = false; +} + +// +// Assign a new request Id +Query.prototype.incRequestId = function() { + this.requestId = _requestId++; +} + +// +// Assign a new request Id +Query.nextRequestId = function() { + return _requestId + 1; +} + +// +// Uses a single allocated buffer for the process, avoiding multiple memory allocations +Query.prototype.toBin = function() { + var self = this; + var buffers = []; + var projection = null; + + // Set up the flags + var flags = 0; + if(this.tailable) { + flags |= OPTS_TAILABLE_CURSOR; + } + + if(this.slaveOk) { + flags |= OPTS_SLAVE; + } + + if(this.oplogReplay) { + flags |= OPTS_OPLOG_REPLAY; + } + + if(this.noCursorTimeout) { + flags |= OPTS_NO_CURSOR_TIMEOUT; + } + + if(this.awaitData) { + flags |= OPTS_AWAIT_DATA; + } + + if(this.exhaust) { + flags |= OPTS_EXHAUST; + } + + if(this.partial) { + flags |= OPTS_PARTIAL; + } + + // If batchSize is different to self.numberToReturn + if(self.batchSize != self.numberToReturn) self.numberToReturn = self.batchSize; + + // Allocate write protocol header buffer + var header = new Buffer( + 4 * 4 // Header + + 4 // Flags + + Buffer.byteLength(self.ns) + 1 // namespace + + 4 // numberToSkip + + 4 // numberToReturn + ); + + // Add header to buffers + buffers.push(header); + + // Serialize the query + var query = self.bson.serialize(this.query, { + checkKeys: this.checkKeys, + serializeFunctions: this.serializeFunctions, + ignoreUndefined: this.ignoreUndefined, + }); + + // Add query document + buffers.push(query); + + if(self.returnFieldSelector && Object.keys(self.returnFieldSelector).length > 0) { + // Serialize the projection document + projection = self.bson.serialize(this.returnFieldSelector, { + checkKeys: this.checkKeys, + serializeFunctions: this.serializeFunctions, + ignoreUndefined: this.ignoreUndefined, + }); + // Add projection document + buffers.push(projection); + } + + // Total message size + var totalLength = header.length + query.length + (projection ? projection.length : 0); + + // Set up the index + var index = 4; + + // Write total document length + header[3] = (totalLength >> 24) & 0xff; + header[2] = (totalLength >> 16) & 0xff; + header[1] = (totalLength >> 8) & 0xff; + header[0] = (totalLength) & 0xff; + + // Write header information requestId + header[index + 3] = (this.requestId >> 24) & 0xff; + header[index + 2] = (this.requestId >> 16) & 0xff; + header[index + 1] = (this.requestId >> 8) & 0xff; + header[index] = (this.requestId) & 0xff; + index = index + 4; + + // Write header information responseTo + header[index + 3] = (0 >> 24) & 0xff; + header[index + 2] = (0 >> 16) & 0xff; + header[index + 1] = (0 >> 8) & 0xff; + header[index] = (0) & 0xff; + index = index + 4; + + // Write header information OP_QUERY + header[index + 3] = (OP_QUERY >> 24) & 0xff; + header[index + 2] = (OP_QUERY >> 16) & 0xff; + header[index + 1] = (OP_QUERY >> 8) & 0xff; + header[index] = (OP_QUERY) & 0xff; + index = index + 4; + + // Write header information flags + header[index + 3] = (flags >> 24) & 0xff; + header[index + 2] = (flags >> 16) & 0xff; + header[index + 1] = (flags >> 8) & 0xff; + header[index] = (flags) & 0xff; + index = index + 4; + + // Write collection name + index = index + header.write(this.ns, index, 'utf8') + 1; + header[index - 1] = 0; + + // Write header information flags numberToSkip + header[index + 3] = (this.numberToSkip >> 24) & 0xff; + header[index + 2] = (this.numberToSkip >> 16) & 0xff; + header[index + 1] = (this.numberToSkip >> 8) & 0xff; + header[index] = (this.numberToSkip) & 0xff; + index = index + 4; + + // Write header information flags numberToReturn + header[index + 3] = (this.numberToReturn >> 24) & 0xff; + header[index + 2] = (this.numberToReturn >> 16) & 0xff; + header[index + 1] = (this.numberToReturn >> 8) & 0xff; + header[index] = (this.numberToReturn) & 0xff; + index = index + 4; + + // Return the buffers + return buffers; +} + +Query.getRequestId = function() { + return ++_requestId; +} + +/************************************************************** + * GETMORE + **************************************************************/ +var GetMore = function(bson, ns, cursorId, opts) { + opts = opts || {}; + this.numberToReturn = opts.numberToReturn || 0; + this.requestId = _requestId++; + this.bson = bson; + this.ns = ns; + this.cursorId = cursorId; +} + +// +// Uses a single allocated buffer for the process, avoiding multiple memory allocations +GetMore.prototype.toBin = function() { + var length = 4 + Buffer.byteLength(this.ns) + 1 + 4 + 8 + (4 * 4); + // Create command buffer + var index = 0; + // Allocate buffer + var _buffer = new Buffer(length); + + // Write header information + // index = write32bit(index, _buffer, length); + _buffer[index + 3] = (length >> 24) & 0xff; + _buffer[index + 2] = (length >> 16) & 0xff; + _buffer[index + 1] = (length >> 8) & 0xff; + _buffer[index] = (length) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, requestId); + _buffer[index + 3] = (this.requestId >> 24) & 0xff; + _buffer[index + 2] = (this.requestId >> 16) & 0xff; + _buffer[index + 1] = (this.requestId >> 8) & 0xff; + _buffer[index] = (this.requestId) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, 0); + _buffer[index + 3] = (0 >> 24) & 0xff; + _buffer[index + 2] = (0 >> 16) & 0xff; + _buffer[index + 1] = (0 >> 8) & 0xff; + _buffer[index] = (0) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, OP_GETMORE); + _buffer[index + 3] = (OP_GETMORE >> 24) & 0xff; + _buffer[index + 2] = (OP_GETMORE >> 16) & 0xff; + _buffer[index + 1] = (OP_GETMORE >> 8) & 0xff; + _buffer[index] = (OP_GETMORE) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, 0); + _buffer[index + 3] = (0 >> 24) & 0xff; + _buffer[index + 2] = (0 >> 16) & 0xff; + _buffer[index + 1] = (0 >> 8) & 0xff; + _buffer[index] = (0) & 0xff; + index = index + 4; + + // Write collection name + index = index + _buffer.write(this.ns, index, 'utf8') + 1; + _buffer[index - 1] = 0; + + // Write batch size + // index = write32bit(index, _buffer, numberToReturn); + _buffer[index + 3] = (this.numberToReturn >> 24) & 0xff; + _buffer[index + 2] = (this.numberToReturn >> 16) & 0xff; + _buffer[index + 1] = (this.numberToReturn >> 8) & 0xff; + _buffer[index] = (this.numberToReturn) & 0xff; + index = index + 4; + + // Write cursor id + // index = write32bit(index, _buffer, cursorId.getLowBits()); + _buffer[index + 3] = (this.cursorId.getLowBits() >> 24) & 0xff; + _buffer[index + 2] = (this.cursorId.getLowBits() >> 16) & 0xff; + _buffer[index + 1] = (this.cursorId.getLowBits() >> 8) & 0xff; + _buffer[index] = (this.cursorId.getLowBits()) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, cursorId.getHighBits()); + _buffer[index + 3] = (this.cursorId.getHighBits() >> 24) & 0xff; + _buffer[index + 2] = (this.cursorId.getHighBits() >> 16) & 0xff; + _buffer[index + 1] = (this.cursorId.getHighBits() >> 8) & 0xff; + _buffer[index] = (this.cursorId.getHighBits()) & 0xff; + index = index + 4; + + // Return buffer + return _buffer; +} + +/************************************************************** + * KILLCURSOR + **************************************************************/ +var KillCursor = function(bson, cursorIds) { + this.requestId = _requestId++; + this.cursorIds = cursorIds; +} + +// +// Uses a single allocated buffer for the process, avoiding multiple memory allocations +KillCursor.prototype.toBin = function() { + var length = 4 + 4 + (4 * 4) + (this.cursorIds.length * 8); + + // Create command buffer + var index = 0; + var _buffer = new Buffer(length); + + // Write header information + // index = write32bit(index, _buffer, length); + _buffer[index + 3] = (length >> 24) & 0xff; + _buffer[index + 2] = (length >> 16) & 0xff; + _buffer[index + 1] = (length >> 8) & 0xff; + _buffer[index] = (length) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, requestId); + _buffer[index + 3] = (this.requestId >> 24) & 0xff; + _buffer[index + 2] = (this.requestId >> 16) & 0xff; + _buffer[index + 1] = (this.requestId >> 8) & 0xff; + _buffer[index] = (this.requestId) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, 0); + _buffer[index + 3] = (0 >> 24) & 0xff; + _buffer[index + 2] = (0 >> 16) & 0xff; + _buffer[index + 1] = (0 >> 8) & 0xff; + _buffer[index] = (0) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, OP_KILL_CURSORS); + _buffer[index + 3] = (OP_KILL_CURSORS >> 24) & 0xff; + _buffer[index + 2] = (OP_KILL_CURSORS >> 16) & 0xff; + _buffer[index + 1] = (OP_KILL_CURSORS >> 8) & 0xff; + _buffer[index] = (OP_KILL_CURSORS) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, 0); + _buffer[index + 3] = (0 >> 24) & 0xff; + _buffer[index + 2] = (0 >> 16) & 0xff; + _buffer[index + 1] = (0 >> 8) & 0xff; + _buffer[index] = (0) & 0xff; + index = index + 4; + + // Write batch size + // index = write32bit(index, _buffer, this.cursorIds.length); + _buffer[index + 3] = (this.cursorIds.length >> 24) & 0xff; + _buffer[index + 2] = (this.cursorIds.length >> 16) & 0xff; + _buffer[index + 1] = (this.cursorIds.length >> 8) & 0xff; + _buffer[index] = (this.cursorIds.length) & 0xff; + index = index + 4; + + // Write all the cursor ids into the array + for(var i = 0; i < this.cursorIds.length; i++) { + // Write cursor id + // index = write32bit(index, _buffer, cursorIds[i].getLowBits()); + _buffer[index + 3] = (this.cursorIds[i].getLowBits() >> 24) & 0xff; + _buffer[index + 2] = (this.cursorIds[i].getLowBits() >> 16) & 0xff; + _buffer[index + 1] = (this.cursorIds[i].getLowBits() >> 8) & 0xff; + _buffer[index] = (this.cursorIds[i].getLowBits()) & 0xff; + index = index + 4; + + // index = write32bit(index, _buffer, cursorIds[i].getHighBits()); + _buffer[index + 3] = (this.cursorIds[i].getHighBits() >> 24) & 0xff; + _buffer[index + 2] = (this.cursorIds[i].getHighBits() >> 16) & 0xff; + _buffer[index + 1] = (this.cursorIds[i].getHighBits() >> 8) & 0xff; + _buffer[index] = (this.cursorIds[i].getHighBits()) & 0xff; + index = index + 4; + } + + // Return buffer + return _buffer; +} + +var Response = function(bson, data, opts) { + opts = opts || {promoteLongs: true, promoteValues: true, promoteBuffers: false}; + this.parsed = false; + + // + // Parse Header + // + this.index = 0; + this.raw = data; + this.data = data; + this.bson = bson; + this.opts = opts; + + // Read the message length + this.length = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Fetch the request id for this reply + this.requestId = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Fetch the id of the request that triggered the response + this.responseTo = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Skip op-code field + this.index = this.index + 4; + + // Unpack flags + this.responseFlags = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Unpack the cursor + var lowBits = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + var highBits = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + // Create long object + this.cursorId = new Long(lowBits, highBits); + + // Unpack the starting from + this.startingFrom = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Unpack the number of objects returned + this.numberReturned = data[this.index] | data[this.index + 1] << 8 | data[this.index + 2] << 16 | data[this.index + 3] << 24; + this.index = this.index + 4; + + // Preallocate document array + this.documents = new Array(this.numberReturned); + + // Flag values + this.cursorNotFound = (this.responseFlags & CURSOR_NOT_FOUND) != 0; + this.queryFailure = (this.responseFlags & QUERY_FAILURE) != 0; + this.shardConfigStale = (this.responseFlags & SHARD_CONFIG_STALE) != 0; + this.awaitCapable = (this.responseFlags & AWAIT_CAPABLE) != 0; + this.promoteLongs = typeof opts.promoteLongs == 'boolean' ? opts.promoteLongs : true; + this.promoteValues = typeof opts.promoteValues == 'boolean' ? opts.promoteValues : true; + this.promoteBuffers = typeof opts.promoteBuffers == 'boolean' ? opts.promoteBuffers : false; +} + +Response.prototype.isParsed = function() { + return this.parsed; +} + +Response.prototype.parse = function(options) { + // Don't parse again if not needed + if(this.parsed) return; + options = options || {}; + + // Allow the return of raw documents instead of parsing + var raw = options.raw || false; + var documentsReturnedIn = options.documentsReturnedIn || null; + var promoteLongs = typeof options.promoteLongs == 'boolean' + ? options.promoteLongs + : this.opts.promoteLongs; + var promoteValues = typeof options.promoteValues == 'boolean' + ? options.promoteValues + : this.opts.promoteValues; + var promoteBuffers = typeof options.promoteBuffers == 'boolean' + ? options.promoteBuffers + : this.opts.promoteBuffers + var bsonSize, _options; + + // Set up the options + _options = { + promoteLongs: promoteLongs, + promoteValues: promoteValues, + promoteBuffers: promoteBuffers + }; + + // + // Single document and documentsReturnedIn set + // + if(this.numberReturned == 1 && documentsReturnedIn != null && raw) { + // Calculate the bson size + bsonSize = this.data[this.index] | this.data[this.index + 1] << 8 | this.data[this.index + 2] << 16 | this.data[this.index + 3] << 24; + // Slice out the buffer containing the command result document + var document = this.data.slice(this.index, this.index + bsonSize); + // Set up field we wish to keep as raw + var fieldsAsRaw = {} + fieldsAsRaw[documentsReturnedIn] = true; + _options.fieldsAsRaw = fieldsAsRaw; + + // Deserialize but keep the array of documents in non-parsed form + var doc = this.bson.deserialize(document, _options); + + // Get the documents + this.documents = doc.cursor[documentsReturnedIn]; + this.numberReturned = this.documents.length; + // Ensure we have a Long valie cursor id + this.cursorId = typeof doc.cursor.id == 'number' + ? Long.fromNumber(doc.cursor.id) + : doc.cursor.id; + + // Adjust the index + this.index = this.index + bsonSize; + + // Set as parsed + this.parsed = true + return; + } + + // + // Parse Body + // + for(var i = 0; i < this.numberReturned; i++) { + bsonSize = this.data[this.index] | this.data[this.index + 1] << 8 | this.data[this.index + 2] << 16 | this.data[this.index + 3] << 24; + + // If we have raw results specified slice the return document + if(raw) { + this.documents[i] = this.data.slice(this.index, this.index + bsonSize); + } else { + this.documents[i] = this.bson.deserialize(this.data.slice(this.index, this.index + bsonSize), _options); + } + + // Adjust the index + this.index = this.index + bsonSize; + } + + // Set parsed + this.parsed = true; +} + +module.exports = { + Query: Query + , GetMore: GetMore + , Response: Response + , KillCursor: KillCursor +} diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js new file mode 100644 index 0000000..d7dae1a --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js @@ -0,0 +1,619 @@ +"use strict"; + +var inherits = require('util').inherits + , EventEmitter = require('events').EventEmitter + , net = require('net') + , tls = require('tls') + , crypto = require('crypto') + , f = require('util').format + , debugOptions = require('./utils').debugOptions + , Response = require('./commands').Response + , MongoError = require('../error') + , Logger = require('./logger'); + +var _id = 0; +var debugFields = ['host', 'port', 'size', 'keepAlive', 'keepAliveInitialDelay', 'noDelay' + , 'connectionTimeout', 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'crl', 'cert' + , 'rejectUnauthorized', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'checkServerIdentity']; +var connectionAccounting = false; +var connections = {}; + +/** + * Creates a new Connection instance + * @class + * @param {string} options.host The server host + * @param {number} options.port The server port + * @param {number} [options.family=null] IP version for DNS lookup, passed down to Node's [`dns.lookup()` function](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback). If set to `6`, will only look for ipv6 addresses. + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=300000] Initial delay before TCP keep alive enabled + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.connectionTimeout=30000] TCP Connection timeout setting + * @param {number} [options.socketTimeout=360000] TCP Socket timeout setting + * @param {boolean} [options.singleBufferSerializtion=true] Serialize into single buffer, trade of peak memory for serialization speed + * @param {boolean} [options.ssl=false] Use SSL for connection + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {Buffer} [options.ca] SSL Certificate store binary buffer + * @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer + * @param {Buffer} [options.cert] SSL Certificate binary buffer + * @param {Buffer} [options.key] SSL Key file binary buffer + * @param {string} [options.passphrase] SSL Certificate pass phrase + * @param {boolean} [options.rejectUnauthorized=true] Reject unauthorized server certificates + * @param {boolean} [options.promoteLongs=true] Convert Long values from the db into Numbers if they fit into 53 bits + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @fires Connection#connect + * @fires Connection#close + * @fires Connection#error + * @fires Connection#timeout + * @fires Connection#parseError + * @return {Connection} A cursor instance + */ +var Connection = function(messageHandler, options) { + // Add event listener + EventEmitter.call(this); + // Set empty if no options passed + this.options = options || {}; + // Identification information + this.id = _id++; + // Logger instance + this.logger = Logger('Connection', options); + // No bson parser passed in + if(!options.bson) throw new Error("must pass in valid bson parser"); + // Get bson parser + this.bson = options.bson; + // Grouping tag used for debugging purposes + this.tag = options.tag; + // Message handler + this.messageHandler = messageHandler; + + // Max BSON message size + this.maxBsonMessageSize = options.maxBsonMessageSize || (1024 * 1024 * 16 * 4); + // Debug information + if(this.logger.isDebug()) this.logger.debug(f('creating connection %s with options [%s]', this.id, JSON.stringify(debugOptions(debugFields, options)))); + + // Default options + this.port = options.port || 27017; + this.host = options.host || 'localhost'; + this.family = typeof options.family == 'number' ? options.family : void 0; + this.keepAlive = typeof options.keepAlive == 'boolean' ? options.keepAlive : true; + this.keepAliveInitialDelay = typeof options.keepAliveInitialDelay == 'number' + ? options.keepAliveInitialDelay : 300000; + this.noDelay = typeof options.noDelay == 'boolean' ? options.noDelay : true; + this.connectionTimeout = typeof options.connectionTimeout == 'number' + ? options.connectionTimeout : 30000; + this.socketTimeout = typeof options.socketTimeout == 'number' + ? options.socketTimeout : 360000; + + // Is the keepAliveInitialDelay > socketTimeout set it to half of socketTimeout + if(this.keepAliveInitialDelay > this.socketTimeout) { + this.keepAliveInitialDelay = Math.round(this.socketTimeout/2); + } + + // If connection was destroyed + this.destroyed = false; + + // Check if we have a domain socket + this.domainSocket = this.host.indexOf('\/') != -1; + + // Serialize commands using function + this.singleBufferSerializtion = typeof options.singleBufferSerializtion == 'boolean' ? options.singleBufferSerializtion : true; + this.serializationFunction = this.singleBufferSerializtion ? 'toBinUnified' : 'toBin'; + + // SSL options + this.ca = options.ca || null; + this.crl = options.crl || null; + this.cert = options.cert || null; + this.key = options.key || null; + this.passphrase = options.passphrase || null; + this.ciphers = options.ciphers || null; + this.ecdhCurve = options.ecdhCurve || null; + this.ssl = typeof options.ssl == 'boolean' ? options.ssl : false; + this.rejectUnauthorized = typeof options.rejectUnauthorized == 'boolean' ? options.rejectUnauthorized : true; + this.checkServerIdentity = typeof options.checkServerIdentity == 'boolean' + || typeof options.checkServerIdentity == 'function' ? options.checkServerIdentity : true; + + // If ssl not enabled + if(!this.ssl) this.rejectUnauthorized = false; + + // Response options + this.responseOptions = { + promoteLongs: typeof options.promoteLongs == 'boolean' ? options.promoteLongs : true, + promoteValues: typeof options.promoteValues == 'boolean' ? options.promoteValues : true, + promoteBuffers: typeof options.promoteBuffers == 'boolean' ? options.promoteBuffers: false + } + + // Flushing + this.flushing = false; + this.queue = []; + + // Internal state + this.connection = null; + this.writeStream = null; + + // Create hash method + var hash = crypto.createHash('sha1'); + hash.update(f('%s:%s', this.host, this.port)); + + // Create a hash name + this.hashedName = hash.digest('hex'); + + // All operations in flight on the connection + this.workItems = []; +} + +inherits(Connection, EventEmitter); + +Connection.prototype.setSocketTimeout = function(value) { + if(this.connection) { + this.connection.setTimeout(value); + } +} + +Connection.prototype.resetSocketTimeout = function() { + if(this.connection) { + this.connection.setTimeout(this.socketTimeout); + } +} + +Connection.enableConnectionAccounting = function() { + connectionAccounting = true; + connections = {}; +} + +Connection.disableConnectionAccounting = function() { + connectionAccounting = false; +} + +Connection.connections = function() { + return connections; +} + +function deleteConnection(id) { + // console.log("=== deleted connection " + id + " :: " + (connections[id] ? connections[id].port : '')) + delete connections[id]; +} + +function addConnection(id, connection) { + // console.log("=== added connection " + id + " :: " + connection.port) + connections[id] = connection; +} + +// +// Connection handlers +var errorHandler = function(self) { + return function(err) { + if(connectionAccounting) deleteConnection(self.id); + // Debug information + if(self.logger.isDebug()) self.logger.debug(f('connection %s for [%s:%s] errored out with [%s]', self.id, self.host, self.port, JSON.stringify(err))); + // Emit the error + if(self.listeners('error').length > 0) self.emit("error", MongoError.create(err), self); + } +} + +var timeoutHandler = function(self) { + return function() { + if(connectionAccounting) deleteConnection(self.id); + // Debug information + if(self.logger.isDebug()) self.logger.debug(f('connection %s for [%s:%s] timed out', self.id, self.host, self.port)); + // Emit timeout error + self.emit("timeout" + , MongoError.create(f("connection %s to %s:%s timed out", self.id, self.host, self.port)) + , self); + } +} + +var closeHandler = function(self) { + return function(hadError) { + if(connectionAccounting) deleteConnection(self.id); + // Debug information + if(self.logger.isDebug()) self.logger.debug(f('connection %s with for [%s:%s] closed', self.id, self.host, self.port)); + + // Emit close event + if(!hadError) { + self.emit("close" + , MongoError.create(f("connection %s to %s:%s closed", self.id, self.host, self.port)) + , self); + } + } +} + +var dataHandler = function(self) { + return function(data) { + // Parse until we are done with the data + while(data.length > 0) { + // If we still have bytes to read on the current message + if(self.bytesRead > 0 && self.sizeOfMessage > 0) { + // Calculate the amount of remaining bytes + var remainingBytesToRead = self.sizeOfMessage - self.bytesRead; + // Check if the current chunk contains the rest of the message + if(remainingBytesToRead > data.length) { + // Copy the new data into the exiting buffer (should have been allocated when we know the message size) + data.copy(self.buffer, self.bytesRead); + // Adjust the number of bytes read so it point to the correct index in the buffer + self.bytesRead = self.bytesRead + data.length; + + // Reset state of buffer + data = new Buffer(0); + } else { + // Copy the missing part of the data into our current buffer + data.copy(self.buffer, self.bytesRead, 0, remainingBytesToRead); + // Slice the overflow into a new buffer that we will then re-parse + data = data.slice(remainingBytesToRead); + + // Emit current complete message + try { + var emitBuffer = self.buffer; + // Reset state of buffer + self.buffer = null; + self.sizeOfMessage = 0; + self.bytesRead = 0; + self.stubBuffer = null; + // Emit the buffer + self.messageHandler(new Response(self.bson, emitBuffer, self.responseOptions), self); + } catch(err) { + var errorObject = {err:"socketHandler", trace:err, bin:self.buffer, parseState:{ + sizeOfMessage:self.sizeOfMessage, + bytesRead:self.bytesRead, + stubBuffer:self.stubBuffer}}; + // We got a parse Error fire it off then keep going + self.emit("parseError", errorObject, self); + } + } + } else { + // Stub buffer is kept in case we don't get enough bytes to determine the + // size of the message (< 4 bytes) + if(self.stubBuffer != null && self.stubBuffer.length > 0) { + // If we have enough bytes to determine the message size let's do it + if(self.stubBuffer.length + data.length > 4) { + // Prepad the data + var newData = new Buffer(self.stubBuffer.length + data.length); + self.stubBuffer.copy(newData, 0); + data.copy(newData, self.stubBuffer.length); + // Reassign for parsing + data = newData; + + // Reset state of buffer + self.buffer = null; + self.sizeOfMessage = 0; + self.bytesRead = 0; + self.stubBuffer = null; + + } else { + + // Add the the bytes to the stub buffer + var newStubBuffer = new Buffer(self.stubBuffer.length + data.length); + // Copy existing stub buffer + self.stubBuffer.copy(newStubBuffer, 0); + // Copy missing part of the data + data.copy(newStubBuffer, self.stubBuffer.length); + // Exit parsing loop + data = new Buffer(0); + } + } else { + if(data.length > 4) { + // Retrieve the message size + // var sizeOfMessage = data.readUInt32LE(0); + var sizeOfMessage = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24; + // If we have a negative sizeOfMessage emit error and return + if(sizeOfMessage < 0 || sizeOfMessage > self.maxBsonMessageSize) { + errorObject = {err:"socketHandler", trace:'', bin:self.buffer, parseState:{ + sizeOfMessage: sizeOfMessage, + bytesRead: self.bytesRead, + stubBuffer: self.stubBuffer}}; + // We got a parse Error fire it off then keep going + self.emit("parseError", errorObject, self); + return; + } + + // Ensure that the size of message is larger than 0 and less than the max allowed + if(sizeOfMessage > 4 && sizeOfMessage < self.maxBsonMessageSize && sizeOfMessage > data.length) { + self.buffer = new Buffer(sizeOfMessage); + // Copy all the data into the buffer + data.copy(self.buffer, 0); + // Update bytes read + self.bytesRead = data.length; + // Update sizeOfMessage + self.sizeOfMessage = sizeOfMessage; + // Ensure stub buffer is null + self.stubBuffer = null; + // Exit parsing loop + data = new Buffer(0); + + } else if(sizeOfMessage > 4 && sizeOfMessage < self.maxBsonMessageSize && sizeOfMessage == data.length) { + try { + emitBuffer = data; + // Reset state of buffer + self.buffer = null; + self.sizeOfMessage = 0; + self.bytesRead = 0; + self.stubBuffer = null; + // Exit parsing loop + data = new Buffer(0); + // Emit the message + self.messageHandler(new Response(self.bson, emitBuffer, self.responseOptions), self); + } catch (err) { + self.emit("parseError", err, self); + } + } else if(sizeOfMessage <= 4 || sizeOfMessage > self.maxBsonMessageSize) { + errorObject = {err:"socketHandler", trace:null, bin:data, parseState:{ + sizeOfMessage:sizeOfMessage, + bytesRead:0, + buffer:null, + stubBuffer:null}}; + // We got a parse Error fire it off then keep going + self.emit("parseError", errorObject, self); + + // Clear out the state of the parser + self.buffer = null; + self.sizeOfMessage = 0; + self.bytesRead = 0; + self.stubBuffer = null; + // Exit parsing loop + data = new Buffer(0); + } else { + emitBuffer = data.slice(0, sizeOfMessage); + // Reset state of buffer + self.buffer = null; + self.sizeOfMessage = 0; + self.bytesRead = 0; + self.stubBuffer = null; + // Copy rest of message + data = data.slice(sizeOfMessage); + // Emit the message + self.messageHandler(new Response(self.bson, emitBuffer, self.responseOptions), self); + } + } else { + // Create a buffer that contains the space for the non-complete message + self.stubBuffer = new Buffer(data.length) + // Copy the data to the stub buffer + data.copy(self.stubBuffer, 0); + // Exit parsing loop + data = new Buffer(0); + } + } + } + } + } +} + +// List of socket level valid ssl options +var legalSslSocketOptions = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers' + , 'NPNProtocols', 'ALPNProtocols', 'servername', 'ecdhCurve' + , 'secureProtocol', 'secureContext', 'session' + , 'minDHSize']; + +function merge(options1, options2) { + // Merge in any allowed ssl options + for(var name in options2) { + if(options2[name] != null && legalSslSocketOptions.indexOf(name) != -1) { + options1[name] = options2[name]; + } + } +} + +/** + * Connect + * @method + */ +Connection.prototype.connect = function(_options) { + var self = this; + _options = _options || {}; + // Set the connections + if(connectionAccounting) addConnection(this.id, this); + // Check if we are overriding the promoteLongs + if(typeof _options.promoteLongs == 'boolean') { + self.responseOptions.promoteLongs = _options.promoteLongs; + self.responseOptions.promoteValues = _options.promoteValues; + self.responseOptions.promoteBuffers = _options.promoteBuffers; + } + + // Create new connection instance + var connection_options; + if (self.domainSocket) { + connection_options = {path: self.host}; + } else { + connection_options = {port: self.port, host: self.host}; + if (self.family !== void 0) { + connection_options.family = self.family; + } + } + self.connection = net.createConnection(connection_options); + + // Set the options for the connection + self.connection.setKeepAlive(self.keepAlive, self.keepAliveInitialDelay); + self.connection.setTimeout(self.connectionTimeout); + self.connection.setNoDelay(self.noDelay); + + // If we have ssl enabled + if(self.ssl) { + var sslOptions = { + socket: self.connection + , rejectUnauthorized: self.rejectUnauthorized + } + + // Merge in options + merge(sslOptions, this.options); + merge(sslOptions, _options); + + // Set options for ssl + if(self.ca) sslOptions.ca = self.ca; + if(self.crl) sslOptions.crl = self.crl; + if(self.cert) sslOptions.cert = self.cert; + if(self.key) sslOptions.key = self.key; + if(self.passphrase) sslOptions.passphrase = self.passphrase; + + // Override checkServerIdentity behavior + if(self.checkServerIdentity == false) { + // Skip the identiy check by retuning undefined as per node documents + // https://nodejs.org/api/tls.html#tls_tls_connect_options_callback + sslOptions.checkServerIdentity = function() { + return undefined; + } + } else if(typeof self.checkServerIdentity == 'function') { + sslOptions.checkServerIdentity = self.checkServerIdentity; + } + + // Set default sni servername to be the same as host + if(sslOptions.servername == null) { + sslOptions.servername = self.host; + } + + // Attempt SSL connection + self.connection = tls.connect(self.port, self.host, sslOptions, function() { + // Error on auth or skip + if(self.connection.authorizationError && self.rejectUnauthorized) { + return self.emit("error", self.connection.authorizationError, self, {ssl:true}); + } + + // Set socket timeout instead of connection timeout + self.connection.setTimeout(self.socketTimeout); + // We are done emit connect + self.emit('connect', self); + }); + self.connection.setTimeout(self.connectionTimeout); + } else { + self.connection.once('connect', function() { + // Set socket timeout instead of connection timeout + self.connection.setTimeout(self.socketTimeout); + // Emit connect event + self.emit('connect', self); + }); + } + + // Add handlers for events + self.connection.once('error', errorHandler(self)); + self.connection.once('timeout', timeoutHandler(self)); + self.connection.once('close', closeHandler(self)); + self.connection.on('data', dataHandler(self)); +} + +/** + * Unref this connection + * @method + * @return {boolean} + */ +Connection.prototype.unref = function() { + if (this.connection) this.connection.unref(); + else { + var self = this; + this.once('connect', function() { + self.connection.unref(); + }); + } +} + +/** + * Destroy connection + * @method + */ +Connection.prototype.destroy = function() { + // Set the connections + if(connectionAccounting) deleteConnection(this.id); + if(this.connection) { + // Catch posssible exception thrown by node 0.10.x + try { this.connection.end(); } catch (err) {} + // Destroy connection + this.connection.destroy(); + } + + this.destroyed = true; +} + +/** + * Write to connection + * @method + * @param {Command} command Command to write out need to implement toBin and toBinUnified + */ +Connection.prototype.write = function(buffer) { + var i; + // Debug Log + if(this.logger.isDebug()) { + if(!Array.isArray(buffer)) { + this.logger.debug(f('writing buffer [%s] to %s:%s', buffer.toString('hex'), this.host, this.port)); + } else { + for(i = 0; i < buffer.length; i++) + this.logger.debug(f('writing buffer [%s] to %s:%s', buffer[i].toString('hex'), this.host, this.port)); + } + } + + // Double check that the connection is not destroyed + if(this.connection.destroyed === false) { + // Write out the command + if(!Array.isArray(buffer)) { + this.connection.write(buffer, 'binary'); + return true; + } + + // Iterate over all buffers and write them in order to the socket + for(i = 0; i < buffer.length; i++) this.connection.write(buffer[i], 'binary'); + return true; + } + + // Connection is destroyed return write failed + return false; +} + +/** + * Return id of connection as a string + * @method + * @return {string} + */ +Connection.prototype.toString = function() { + return "" + this.id; +} + +/** + * Return json object of connection + * @method + * @return {object} + */ +Connection.prototype.toJSON = function() { + return {id: this.id, host: this.host, port: this.port}; +} + +/** + * Is the connection connected + * @method + * @return {boolean} + */ +Connection.prototype.isConnected = function() { + if(this.destroyed) return false; + return !this.connection.destroyed && this.connection.writable; +} + +/** + * A server connect event, used to verify that the connection is up and running + * + * @event Connection#connect + * @type {Connection} + */ + +/** + * The server connection closed, all pool connections closed + * + * @event Connection#close + * @type {Connection} + */ + +/** + * The server connection caused an error, all pool connections closed + * + * @event Connection#error + * @type {Connection} + */ + +/** + * The server connection timed out, all pool connections closed + * + * @event Connection#timeout + * @type {Connection} + */ + +/** + * The driver experienced an invalid message, all pool connections closed + * + * @event Connection#parseError + * @type {Connection} + */ + +module.exports = Connection; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/logger.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/logger.js new file mode 100644 index 0000000..b8b1818 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/logger.js @@ -0,0 +1,228 @@ +"use strict"; + +var f = require('util').format + , MongoError = require('../error'); + +// Filters for classes +var classFilters = {}; +var filteredClasses = {}; +var level = null; +// Save the process id +var pid = process.pid; +// current logger +var currentLogger = null; + +/** + * Creates a new Logger instance + * @class + * @param {string} className The Class name associated with the logging instance + * @param {object} [options=null] Optional settings. + * @param {Function} [options.logger=null] Custom logger function; + * @param {string} [options.loggerLevel=error] Override default global log level. + * @return {Logger} a Logger instance. + */ +var Logger = function(className, options) { + if(!(this instanceof Logger)) return new Logger(className, options); + options = options || {}; + + // Current reference + this.className = className; + + // Current logger + if(options.logger) { + currentLogger = options.logger; + } else if(currentLogger == null) { + currentLogger = console.log; + } + + // Set level of logging, default is error + if(options.loggerLevel) { + level = options.loggerLevel || 'error'; + } + + // Add all class names + if(filteredClasses[this.className] == null) classFilters[this.className] = true; +} + +/** + * Log a message at the debug level + * @method + * @param {string} message The message to log + * @param {object} object additional meta data to log + * @return {null} + */ +Logger.prototype.debug = function(message, object) { + if(this.isDebug() + && ((Object.keys(filteredClasses).length > 0 && filteredClasses[this.className]) + || (Object.keys(filteredClasses).length == 0 && classFilters[this.className]))) { + var dateTime = new Date().getTime(); + var msg = f("[%s-%s:%s] %s %s", 'DEBUG', this.className, pid, dateTime, message); + var state = { + type: 'debug', message: message, className: this.className, pid: pid, date: dateTime + }; + if(object) state.meta = object; + currentLogger(msg, state); + } +} + +/** + * Log a message at the warn level + * @method + * @param {string} message The message to log + * @param {object} object additional meta data to log + * @return {null} + */ +Logger.prototype.warn = function(message, object) { + if(this.isWarn() + && ((Object.keys(filteredClasses).length > 0 && filteredClasses[this.className]) + || (Object.keys(filteredClasses).length == 0 && classFilters[this.className]))) { + var dateTime = new Date().getTime(); + var msg = f("[%s-%s:%s] %s %s", 'WARN', this.className, pid, dateTime, message); + var state = { + type: 'warn', message: message, className: this.className, pid: pid, date: dateTime + }; + if(object) state.meta = object; + currentLogger(msg, state); + } +}, + +/** + * Log a message at the info level + * @method + * @param {string} message The message to log + * @param {object} object additional meta data to log + * @return {null} + */ +Logger.prototype.info = function(message, object) { + if(this.isInfo() + && ((Object.keys(filteredClasses).length > 0 && filteredClasses[this.className]) + || (Object.keys(filteredClasses).length == 0 && classFilters[this.className]))) { + var dateTime = new Date().getTime(); + var msg = f("[%s-%s:%s] %s %s", 'INFO', this.className, pid, dateTime, message); + var state = { + type: 'info', message: message, className: this.className, pid: pid, date: dateTime + }; + if(object) state.meta = object; + currentLogger(msg, state); + } +}, + +/** + * Log a message at the error level + * @method + * @param {string} message The message to log + * @param {object} object additional meta data to log + * @return {null} + */ +Logger.prototype.error = function(message, object) { + if(this.isError() + && ((Object.keys(filteredClasses).length > 0 && filteredClasses[this.className]) + || (Object.keys(filteredClasses).length == 0 && classFilters[this.className]))) { + var dateTime = new Date().getTime(); + var msg = f("[%s-%s:%s] %s %s", 'ERROR', this.className, pid, dateTime, message); + var state = { + type: 'error', message: message, className: this.className, pid: pid, date: dateTime + }; + if(object) state.meta = object; + currentLogger(msg, state); + } +}, + +/** + * Is the logger set at info level + * @method + * @return {boolean} + */ +Logger.prototype.isInfo = function() { + return level == 'info' || level == 'debug'; +}, + +/** + * Is the logger set at error level + * @method + * @return {boolean} + */ +Logger.prototype.isError = function() { + return level == 'error' || level == 'info' || level == 'debug'; +}, + +/** + * Is the logger set at error level + * @method + * @return {boolean} + */ +Logger.prototype.isWarn = function() { + return level == 'error' || level == 'warn' || level == 'info' || level == 'debug'; +}, + +/** + * Is the logger set at debug level + * @method + * @return {boolean} + */ +Logger.prototype.isDebug = function() { + return level == 'debug'; +} + +/** + * Resets the logger to default settings, error and no filtered classes + * @method + * @return {null} + */ +Logger.reset = function() { + level = 'error'; + filteredClasses = {}; +} + +/** + * Get the current logger function + * @method + * @return {function} + */ +Logger.currentLogger = function() { + return currentLogger; +} + +/** + * Set the current logger function + * @method + * @param {function} logger Logger function. + * @return {null} + */ +Logger.setCurrentLogger = function(logger) { + if(typeof logger != 'function') throw new MongoError("current logger must be a function"); + currentLogger = logger; +} + +/** + * Set what classes to log. + * @method + * @param {string} type The type of filter (currently only class) + * @param {string[]} values The filters to apply + * @return {null} + */ +Logger.filter = function(type, values) { + if(type == 'class' && Array.isArray(values)) { + filteredClasses = {}; + + values.forEach(function(x) { + filteredClasses[x] = true; + }); + } +} + +/** + * Set the current log level + * @method + * @param {string} level Set current log level (debug, info, error) + * @return {null} + */ +Logger.setLevel = function(_level) { + if(_level != 'info' && _level != 'error' && _level != 'debug' && _level != 'warn') { + throw new Error(f("%s is an illegal logging level", _level)); + } + + level = _level; +} + +module.exports = Logger; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js new file mode 100644 index 0000000..683edb8 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js @@ -0,0 +1,1387 @@ +"use strict"; + +var inherits = require('util').inherits, + EventEmitter = require('events').EventEmitter, + Connection = require('./connection'), + MongoError = require('../error'), + Logger = require('./logger'), + f = require('util').format, + Query = require('./commands').Query, + CommandResult = require('./command_result'), + assign = require('../utils').assign; + +var MongoCR = require('../auth/mongocr') + , X509 = require('../auth/x509') + , Plain = require('../auth/plain') + , GSSAPI = require('../auth/gssapi') + , SSPI = require('../auth/sspi') + , ScramSHA1 = require('../auth/scram'); + +var DISCONNECTED = 'disconnected'; +var CONNECTING = 'connecting'; +var CONNECTED = 'connected'; +var DESTROYING = 'destroying'; +var DESTROYED = 'destroyed'; + +var _id = 0; + +/** + * Creates a new Pool instance + * @class + * @param {string} options.host The server host + * @param {number} options.port The server port + * @param {number} [options.size=1] Max server connection pool size + * @param {boolean} [options.reconnect=true] Server will attempt to reconnect on loss of connection + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=300000] Initial delay before TCP keep alive enabled + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.connectionTimeout=30000] TCP Connection timeout setting + * @param {number} [options.socketTimeout=360000] TCP Socket timeout setting + * @param {number} [options.monitoringSocketTimeout=30000] TCP Socket timeout setting for replicaset monitoring socket + * @param {boolean} [options.ssl=false] Use SSL for connection + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {Buffer} [options.ca] SSL Certificate store binary buffer + * @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer + * @param {Buffer} [options.cert] SSL Certificate binary buffer + * @param {Buffer} [options.key] SSL Key file binary buffer + * @param {string} [options.passPhrase] SSL Certificate pass phrase + * @param {boolean} [options.rejectUnauthorized=false] Reject unauthorized server certificates + * @param {boolean} [options.promoteLongs=true] Convert Long values from the db into Numbers if they fit into 53 bits + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @fires Pool#connect + * @fires Pool#close + * @fires Pool#error + * @fires Pool#timeout + * @fires Pool#parseError + * @return {Pool} A cursor instance + */ +var Pool = function(options) { + // Add event listener + EventEmitter.call(this); + // Add the options + this.options = assign({ + // Host and port settings + host: 'localhost', + port: 27017, + // Pool default max size + size: 5, + // socket settings + connectionTimeout: 30000, + socketTimeout: 360000, + keepAlive: true, + keepAliveInitialDelay: 300000, + noDelay: true, + // SSL Settings + ssl: false, checkServerIdentity: true, + ca: null, crl: null, cert: null, key: null, passPhrase: null, + rejectUnauthorized: false, + promoteLongs: true, + promoteValues: true, + promoteBuffers: false, + // Reconnection options + reconnect: true, + reconnectInterval: 1000, + reconnectTries: 30, + // Enable domains + domainsEnabled: false + }, options); + + // console.log("=================================== pool options") + // console.dir(this.options) + + // Identification information + this.id = _id++; + // Current reconnect retries + this.retriesLeft = this.options.reconnectTries; + this.reconnectId = null; + // No bson parser passed in + if(!options.bson || (options.bson + && (typeof options.bson.serialize != 'function' + || typeof options.bson.deserialize != 'function'))) { + throw new Error("must pass in valid bson parser"); + } + + // Logger instance + this.logger = Logger('Pool', options); + // Pool state + this.state = DISCONNECTED; + // Connections + this.availableConnections = []; + this.inUseConnections = []; + this.connectingConnections = []; + // Currently executing + this.executing = false; + // Operation work queue + this.queue = []; + + // All the authProviders + this.authProviders = options.authProviders || { + 'mongocr': new MongoCR(options.bson), 'x509': new X509(options.bson) + , 'plain': new Plain(options.bson), 'gssapi': new GSSAPI(options.bson) + , 'sspi': new SSPI(options.bson), 'scram-sha-1': new ScramSHA1(options.bson) + } + + // Contains the reconnect connection + this.reconnectConnection = null; + + // Are we currently authenticating + this.authenticating = false; + this.loggingout = false; + this.nonAuthenticatedConnections = []; + this.authenticatingTimestamp = null; + // Number of consecutive timeouts caught + this.numberOfConsecutiveTimeouts = 0; + // Current pool Index + this.connectionIndex = 0; +} + +inherits(Pool, EventEmitter); + +Object.defineProperty(Pool.prototype, 'size', { + enumerable:true, + get: function() { return this.options.size; } +}); + +Object.defineProperty(Pool.prototype, 'connectionTimeout', { + enumerable:true, + get: function() { return this.options.connectionTimeout; } +}); + +Object.defineProperty(Pool.prototype, 'socketTimeout', { + enumerable:true, + get: function() { return this.options.socketTimeout; } +}); + +function stateTransition(self, newState) { + var legalTransitions = { + 'disconnected': [CONNECTING, DESTROYING, DISCONNECTED], + 'connecting': [CONNECTING, DESTROYING, CONNECTED, DISCONNECTED], + 'connected': [CONNECTED, DISCONNECTED, DESTROYING], + 'destroying': [DESTROYING, DESTROYED], + 'destroyed': [DESTROYED] + } + + // Get current state + var legalStates = legalTransitions[self.state]; + if(legalStates && legalStates.indexOf(newState) != -1) { + self.state = newState; + } else { + self.logger.error(f('Pool with id [%s] failed attempted illegal state transition from [%s] to [%s] only following state allowed [%s]' + , self.id, self.state, newState, legalStates)); + } +} + +function authenticate(pool, auth, connection, cb) { + if(auth[0] === undefined) return cb(null); + // We need to authenticate the server + var mechanism = auth[0]; + var db = auth[1]; + // Validate if the mechanism exists + if(!pool.authProviders[mechanism]) { + throw new MongoError(f('authMechanism %s not supported', mechanism)); + } + + // Get the provider + var provider = pool.authProviders[mechanism]; + + // Authenticate using the provided mechanism + provider.auth.apply(provider, [write(pool), [connection], db].concat(auth.slice(2)).concat([cb])); +} + +// The write function used by the authentication mechanism (bypasses external) +function write(self) { + return function(connection, command, callback) { + // Get the raw buffer + // Ensure we stop auth if pool was destroyed + if(self.state == DESTROYED || self.state == DESTROYING) { + return callback(new MongoError('pool destroyed')); + } + + // Set the connection workItem callback + connection.workItems.push({ + cb: callback, command: true, requestId: command.requestId + }); + + // Write the buffer out to the connection + connection.write(command.toBin()); + }; +} + + +function reauthenticate(pool, connection, cb) { + // Authenticate + function authenticateAgainstProvider(pool, connection, providers, cb) { + // Finished re-authenticating against providers + if(providers.length == 0) return cb(); + // Get the provider name + var provider = pool.authProviders[providers.pop()]; + + // Auth provider + provider.reauthenticate(write(pool), [connection], function(err) { + // We got an error return immediately + if(err) return cb(err); + // Continue authenticating the connection + authenticateAgainstProvider(pool, connection, providers, cb); + }); + } + + // Start re-authenticating process + authenticateAgainstProvider(pool, connection, Object.keys(pool.authProviders), cb); +} + +function connectionFailureHandler(self, event) { + return function(err) { + // console.log("========== connectionFailureHandler :: " + event) + // console.dir(err) + + if (this._connectionFailHandled) return; + this._connectionFailHandled = true; + // Destroy the connection + this.destroy(); + + // Remove the connection + removeConnection(self, this); + + // Flush all work Items on this connection + while(this.workItems.length > 0) { + var workItem = this.workItems.shift(); + // if(workItem.cb) workItem.cb(err); + if(workItem.cb) workItem.cb(err); + } + + // Did we catch a timeout, increment the numberOfConsecutiveTimeouts + if(event == 'timeout') { + self.numberOfConsecutiveTimeouts = self.numberOfConsecutiveTimeouts + 1; + + // Have we timed out more than reconnectTries in a row ? + // Force close the pool as we are trying to connect to tcp sink hole + if(self.numberOfConsecutiveTimeouts > self.options.reconnectTries) { + self.numberOfConsecutiveTimeouts = 0; + // Destroy all connections and pool + self.destroy(true); + // Emit close event + return self.emit('close', self); + } + } + + // No more socket available propegate the event + if(self.socketCount() == 0) { + if(self.state != DESTROYED && self.state != DESTROYING) { + stateTransition(self, DISCONNECTED); + } + + // Do not emit error events, they are always close events + // do not trigger the low level error handler in node + event = event == 'error' ? 'close' : event; + self.emit(event, err); + } + + // Start reconnection attempts + if(!self.reconnectId && self.options.reconnect) { + self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval); + } + }; +} + +function attemptReconnect(self) { + return function() { + // console.log("========================= attemptReconnect") + self.emit('attemptReconnect', self); + if(self.state == DESTROYED || self.state == DESTROYING) return; + + // We are connected do not try again + if(self.isConnected()) { + self.reconnectId = null; + return; + } + + // If we have failure schedule a retry + function _connectionFailureHandler(self, event) { + return function() { + // console.log("========== _connectionFailureHandler :: " + event) + if (this._connectionFailHandled) return; + this._connectionFailHandled = true; + // Destroy the connection + this.destroy(); + // Count down the number of reconnects + self.retriesLeft = self.retriesLeft - 1; + // How many retries are left + if(self.retriesLeft == 0) { + // Destroy the instance + self.destroy(); + // Emit close event + self.emit('reconnectFailed' + , new MongoError(f('failed to reconnect after %s attempts with interval %s ms', self.options.reconnectTries, self.options.reconnectInterval))); + } else { + self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval); + } + } + } + + // Got a connect handler + function _connectHandler(self) { + return function() { + // Assign + var connection = this; + + // Pool destroyed stop the connection + if(self.state == DESTROYED || self.state == DESTROYING) { + return connection.destroy(); + } + + // Clear out all handlers + handlers.forEach(function(event) { + connection.removeAllListeners(event); + }); + + // Reset reconnect id + self.reconnectId = null; + + // Apply pool connection handlers + connection.on('error', connectionFailureHandler(self, 'error')); + connection.on('close', connectionFailureHandler(self, 'close')); + connection.on('timeout', connectionFailureHandler(self, 'timeout')); + connection.on('parseError', connectionFailureHandler(self, 'parseError')); + + // Apply any auth to the connection + reauthenticate(self, this, function() { + // Reset retries + self.retriesLeft = self.options.reconnectTries; + // Push to available connections + self.availableConnections.push(connection); + // Set the reconnectConnection to null + self.reconnectConnection = null; + // Emit reconnect event + self.emit('reconnect', self); + // Trigger execute to start everything up again + _execute(self)(); + }); + } + } + + // Create a connection + self.reconnectConnection = new Connection(messageHandler(self), self.options); + // Add handlers + self.reconnectConnection.on('close', _connectionFailureHandler(self, 'close')); + self.reconnectConnection.on('error', _connectionFailureHandler(self, 'error')); + self.reconnectConnection.on('timeout', _connectionFailureHandler(self, 'timeout')); + self.reconnectConnection.on('parseError', _connectionFailureHandler(self, 'parseError')); + // On connection + self.reconnectConnection.on('connect', _connectHandler(self)); + // Attempt connection + self.reconnectConnection.connect(); + } +} + +function moveConnectionBetween(connection, from, to) { + var index = from.indexOf(connection); + // Move the connection from connecting to available + if(index != -1) { + from.splice(index, 1); + to.push(connection); + } +} + +function messageHandler(self) { + return function(message, connection) { + // workItem to execute + var workItem = null; + + // Locate the workItem + for(var i = 0; i < connection.workItems.length; i++) { + if(connection.workItems[i].requestId == message.responseTo) { + // Get the callback + workItem = connection.workItems[i]; + // Remove from list of workItems + connection.workItems.splice(i, 1); + } + } + + + // Reset timeout counter + self.numberOfConsecutiveTimeouts = 0; + + // Reset the connection timeout if we modified it for + // this operation + if(workItem.socketTimeout) { + connection.resetSocketTimeout(); + } + + // Log if debug enabled + if(self.logger.isDebug()) { + self.logger.debug(f('message [%s] received from %s:%s' + , message.raw.toString('hex'), self.options.host, self.options.port)); + } + + // Authenticate any straggler connections + function authenticateStragglers(self, connection, callback) { + // Get any non authenticated connections + var connections = self.nonAuthenticatedConnections.slice(0); + var nonAuthenticatedConnections = self.nonAuthenticatedConnections; + self.nonAuthenticatedConnections = []; + + // Establish if the connection need to be authenticated + // Add to authentication list if + // 1. we were in an authentication process when the operation was executed + // 2. our current authentication timestamp is from the workItem one, meaning an auth has happened + if(connection.workItems.length == 1 && (connection.workItems[0].authenticating == true + || (typeof connection.workItems[0].authenticatingTimestamp == 'number' + && connection.workItems[0].authenticatingTimestamp != self.authenticatingTimestamp))) { + // Add connection to the list + connections.push(connection); + } + + // No connections need to be re-authenticated + if(connections.length == 0) { + // Release the connection back to the pool + moveConnectionBetween(connection, self.inUseConnections, self.availableConnections); + // Finish + return callback(); + } + + // Apply re-authentication to all connections before releasing back to pool + var connectionCount = connections.length; + // Authenticate all connections + for(var i = 0; i < connectionCount; i++) { + reauthenticate(self, connections[i], function() { + connectionCount = connectionCount - 1; + + if(connectionCount == 0) { + // Put non authenticated connections in available connections + self.availableConnections = self.availableConnections.concat(nonAuthenticatedConnections); + // Release the connection back to the pool + moveConnectionBetween(connection, self.inUseConnections, self.availableConnections); + // Return + callback(); + } + }); + } + } + + function handleOperationCallback(self, cb, err, result) { + // No domain enabled + if(!self.options.domainsEnabled) { + return process.nextTick(function() { + return cb(err, result); + }); + } + + // Domain enabled just call the callback + cb(err, result); + } + + authenticateStragglers(self, connection, function() { + // Keep executing, ensure current message handler does not stop execution + if(!self.executing) { + process.nextTick(function() { + _execute(self)(); + }); + } + + // Time to dispatch the message if we have a callback + if(!workItem.immediateRelease) { + try { + // Parse the message according to the provided options + message.parse(workItem); + } catch(err) { + return handleOperationCallback(self, workItem.cb, MongoError.create(err)); + } + + // Establish if we have an error + if(workItem.command && message.documents[0] && (message.documents[0].ok == 0 || message.documents[0]['$err'] + || message.documents[0]['errmsg'] || message.documents[0]['code'])) { + return handleOperationCallback(self, workItem.cb, MongoError.create(message.documents[0])); + } + + // Add the connection details + message.hashedName = connection.hashedName; + + // Return the documents + handleOperationCallback(self, workItem.cb, null, new CommandResult(workItem.fullResult ? message : message.documents[0], connection, message)); + } + }); + } +} + +/** + * Return the total socket count in the pool. + * @method + * @return {Number} The number of socket available. + */ +Pool.prototype.socketCount = function() { + return this.availableConnections.length + + this.inUseConnections.length; + // + this.connectingConnections.length; +} + +/** + * Return all pool connections + * @method + * @return {Connection[]} The pool connections + */ +Pool.prototype.allConnections = function() { + return this.availableConnections + .concat(this.inUseConnections) + .concat(this.connectingConnections); +} + +/** + * Get a pool connection (round-robin) + * @method + * @return {Connection} + */ +Pool.prototype.get = function() { + return this.allConnections()[0]; +} + +/** + * Is the pool connected + * @method + * @return {boolean} + */ +Pool.prototype.isConnected = function() { + // We are in a destroyed state + if(this.state == DESTROYED || this.state == DESTROYING) { + return false; + } + + // Get connections + var connections = this.availableConnections + .concat(this.inUseConnections); + + // Check if we have any connected connections + for(var i = 0; i < connections.length; i++) { + if(connections[i].isConnected()) return true; + } + + // Might be authenticating, but we are still connected + if(connections.length == 0 && this.authenticating) { + return true + } + + // Not connected + return false; +} + +/** + * Was the pool destroyed + * @method + * @return {boolean} + */ +Pool.prototype.isDestroyed = function() { + return this.state == DESTROYED || this.state == DESTROYING; +} + +/** + * Is the pool in a disconnected state + * @method + * @return {boolean} + */ +Pool.prototype.isDisconnected = function() { + return this.state == DISCONNECTED; +} + +/** + * Connect pool + * @method + */ +Pool.prototype.connect = function() { + if(this.state != DISCONNECTED) { + throw new MongoError('connection in unlawful state ' + this.state); + } + + var self = this; + // Transition to connecting state + stateTransition(this, CONNECTING); + // Create an array of the arguments + var args = Array.prototype.slice.call(arguments, 0); + // Create a connection + var connection = new Connection(messageHandler(self), this.options); + // Add to list of connections + this.connectingConnections.push(connection); + // Add listeners to the connection + connection.once('connect', function(connection) { + if(self.state == DESTROYED || self.state == DESTROYING) return self.destroy(); + + // If we are in a topology, delegate the auth to it + // This is to avoid issues where we would auth against an + // arbiter + if(self.options.inTopology) { + // Set connected mode + stateTransition(self, CONNECTED); + + // Move the active connection + moveConnectionBetween(connection, self.connectingConnections, self.availableConnections); + + // Emit the connect event + return self.emit('connect', self); + } + + // Apply any store credentials + reauthenticate(self, connection, function(err) { + if(self.state == DESTROYED || self.state == DESTROYING) return self.destroy(); + + // We have an error emit it + if(err) { + // Destroy the pool + self.destroy(); + // Emit the error + return self.emit('error', err); + } + + // Authenticate + authenticate(self, args, connection, function(err) { + if(self.state == DESTROYED || self.state == DESTROYING) return self.destroy(); + + // We have an error emit it + if(err) { + // Destroy the pool + self.destroy(); + // Emit the error + return self.emit('error', err); + } + // Set connected mode + stateTransition(self, CONNECTED); + + // Move the active connection + moveConnectionBetween(connection, self.connectingConnections, self.availableConnections); + + // Emit the connect event + self.emit('connect', self); + }); + }); + }); + + // Add error handlers + connection.once('error', connectionFailureHandler(this, 'error')); + connection.once('close', connectionFailureHandler(this, 'close')); + connection.once('timeout', connectionFailureHandler(this, 'timeout')); + connection.once('parseError', connectionFailureHandler(this, 'parseError')); + + try { + connection.connect(); + } catch(err) { + // SSL or something threw on connect + process.nextTick(function() { + self.emit('error', err); + }); + } +} + +/** + * Authenticate using a specified mechanism + * @method + * @param {string} mechanism The Auth mechanism we are invoking + * @param {string} db The db we are invoking the mechanism against + * @param {...object} param Parameters for the specific mechanism + * @param {authResultCallback} callback A callback function + */ +Pool.prototype.auth = function(mechanism) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + var callback = args.pop(); + + // If we don't have the mechanism fail + if(self.authProviders[mechanism] == null && mechanism != 'default') { + throw new MongoError(f("auth provider %s does not exist", mechanism)); + } + + // Signal that we are authenticating a new set of credentials + this.authenticating = true; + this.authenticatingTimestamp = new Date().getTime(); + + // Authenticate all live connections + function authenticateLiveConnections(self, args, cb) { + // Get the current viable connections + var connections = self.allConnections(); + // Allow nothing else to use the connections while we authenticate them + self.availableConnections = []; + self.inUseConnections = []; + self.connectingConnections = []; + + var connectionsCount = connections.length; + var error = null; + // No connections available, return + if(connectionsCount == 0) { + self.authenticating = false; + return callback(null); + } + + // Authenticate the connections + for(var i = 0; i < connections.length; i++) { + authenticate(self, args, connections[i], function(err) { + connectionsCount = connectionsCount - 1; + + // Store the error + if(err) error = err; + + // Processed all connections + if(connectionsCount == 0) { + // Auth finished + self.authenticating = false; + // Add the connections back to available connections + self.availableConnections = self.availableConnections.concat(connections); + // We had an error, return it + if(error) { + // Log the error + if(self.logger.isError()) { + self.logger.error(f('[%s] failed to authenticate against server %s:%s' + , self.id, self.options.host, self.options.port)); + } + + return cb(error); + } + cb(null); + } + }); + } + } + + // Wait for a logout in process to happen + function waitForLogout(self, cb) { + if(!self.loggingout) return cb(); + setTimeout(function() { + waitForLogout(self, cb); + }, 1) + } + + // Wait for loggout to finish + waitForLogout(self, function() { + // Authenticate all live connections + authenticateLiveConnections(self, args, function(err) { + // Credentials correctly stored in auth provider if successful + // Any new connections will now reauthenticate correctly + self.authenticating = false; + // Return after authentication connections + callback(err); + }); + }); +} + +/** + * Logout all users against a database + * @method + * @param {string} dbName The database name + * @param {authResultCallback} callback A callback function + */ +Pool.prototype.logout = function(dbName, callback) { + var self = this; + if(typeof dbName != 'string') { + throw new MongoError('logout method requires a db name as first argument'); + } + + if(typeof callback != 'function') { + throw new MongoError('logout method requires a callback'); + } + + // Indicate logout in process + this.loggingout = true; + + // Get all relevant connections + var connections = self.availableConnections.concat(self.inUseConnections); + var count = connections.length; + // Store any error + var error = null; + + // Send logout command over all the connections + for(var i = 0; i < connections.length; i++) { + write(self)(connections[i], new Query(this.options.bson + , f('%s.$cmd', dbName) + , {logout:1}, {numberToSkip: 0, numberToReturn: 1}), function(err) { + count = count - 1; + if(err) error = err; + + if(count == 0) { + self.loggingout = false; + callback(error); + } + }); + } +} + +/** + * Unref the pool + * @method + */ +Pool.prototype.unref = function() { + // Get all the known connections + var connections = this.availableConnections + .concat(this.inUseConnections) + .concat(this.connectingConnections); + connections.forEach(function(c) { + c.unref(); + }); +} + +// Events +var events = ['error', 'close', 'timeout', 'parseError', 'connect']; + +// Destroy the connections +function destroy(self, connections) { + // Destroy all connections + connections.forEach(function(c) { + // Remove all listeners + for(var i = 0; i < events.length; i++) { + c.removeAllListeners(events[i]); + } + // Destroy connection + c.destroy(); + }); + + // Zero out all connections + self.inUseConnections = []; + self.availableConnections = []; + self.nonAuthenticatedConnections = []; + self.connectingConnections = []; + + // Set state to destroyed + stateTransition(self, DESTROYED); +} + +/** + * Destroy pool + * @method + */ +Pool.prototype.destroy = function(force) { + var self = this; + // Do not try again if the pool is already dead + if(this.state == DESTROYED || self.state == DESTROYING) return; + // Set state to destroyed + stateTransition(this, DESTROYING); + + // Are we force closing + if(force) { + // Get all the known connections + var connections = self.availableConnections + .concat(self.inUseConnections) + .concat(self.nonAuthenticatedConnections) + .concat(self.connectingConnections); + + // Flush any remaining work items with + // an error + while(self.queue.length > 0) { + var workItem = self.queue.shift(); + if(typeof workItem.cb == 'function') { + workItem.cb(new MongoError('Pool was force destroyed')); + } + } + + // Destroy the topology + return destroy(self, connections); + } + + // Clear out the reconnect if set + if (this.reconnectId) { + clearTimeout(this.reconnectId); + } + + // If we have a reconnect connection running, close + // immediately + if (this.reconnectConnection) { + this.reconnectConnection.destroy(); + } + + // Wait for the operations to drain before we close the pool + function checkStatus() { + flushMonitoringOperations(self.queue); + + if(self.queue.length == 0) { + // Get all the known connections + var connections = self.availableConnections + .concat(self.inUseConnections) + .concat(self.nonAuthenticatedConnections) + .concat(self.connectingConnections); + + // Check if we have any in flight operations + for(var i = 0; i < connections.length; i++) { + // There is an operation still in flight, reschedule a + // check waiting for it to drain + if(connections[i].workItems.length > 0) { + return setTimeout(checkStatus, 1); + } + } + + destroy(self, connections); + // } else if (self.queue.length > 0 && !this.reconnectId) { + + } else { + // Ensure we empty the queue + _execute(self)(); + // Set timeout + setTimeout(checkStatus, 1); + } + } + + // Initiate drain of operations + checkStatus(); +} + +/** + * Write a message to MongoDB + * @method + * @return {Connection} + */ +Pool.prototype.write = function(commands, options, cb) { + var self = this; + // Ensure we have a callback + if(typeof options == 'function') { + cb = options; + } + + // Always have options + options = options || {}; + + // Pool was destroyed error out + if(this.state == DESTROYED || this.state == DESTROYING) { + // Callback with an error + if(cb) { + try { + cb(new MongoError('pool destroyed')); + } catch(err) { + process.nextTick(function() { + throw err; + }); + } + } + + return; + } + + if(this.options.domainsEnabled + && process.domain && typeof cb === "function") { + // if we have a domain bind to it + var oldCb = cb; + cb = process.domain.bind(function() { + // v8 - argumentsToArray one-liner + var args = new Array(arguments.length); for(var i = 0; i < arguments.length; i++) { args[i] = arguments[i]; } + // bounce off event loop so domain switch takes place + process.nextTick(function() { + oldCb.apply(null, args); + }); + }); + } + + // Do we have an operation + var operation = { + cb: cb, raw: false, promoteLongs: true, promoteValues: true, promoteBuffers: false, fullResult: false + }; + + var buffer = null + + if(Array.isArray(commands)) { + buffer = []; + + for(var i = 0; i < commands.length; i++) { + buffer.push(commands[i].toBin()); + } + + // Get the requestId + operation.requestId = commands[commands.length - 1].requestId; + } else { + operation.requestId = commands.requestId; + buffer = commands.toBin(); + } + + // Set the buffers + operation.buffer = buffer; + + // Set the options for the parsing + operation.promoteLongs = typeof options.promoteLongs == 'boolean' ? options.promoteLongs : true; + operation.promoteValues = typeof options.promoteValues == 'boolean' ? options.promoteValues : true; + operation.promoteBuffers = typeof options.promoteBuffers == 'boolean' ? options.promoteBuffers : false; + operation.raw = typeof options.raw == 'boolean' ? options.raw : false; + operation.immediateRelease = typeof options.immediateRelease == 'boolean' ? options.immediateRelease : false; + operation.documentsReturnedIn = options.documentsReturnedIn; + operation.command = typeof options.command == 'boolean' ? options.command : false; + operation.fullResult = typeof options.fullResult == 'boolean' ? options.fullResult : false; + operation.noResponse = typeof options.noResponse == 'boolean' ? options.noResponse : false; + // operation.requestId = options.requestId; + + // Optional per operation socketTimeout + operation.socketTimeout = options.socketTimeout; + operation.monitoring = options.monitoring; + // Custom socket Timeout + if(options.socketTimeout) { + operation.socketTimeout = options.socketTimeout; + } + + // We need to have a callback function unless the message returns no response + if(!(typeof cb == 'function') && !options.noResponse) { + throw new MongoError('write method must provide a callback'); + } + + // If we have a monitoring operation schedule as the very first operation + // Otherwise add to back of queue + if(options.monitoring) { + this.queue.unshift(operation); + } else { + this.queue.push(operation); + } + + // Attempt to execute the operation + if(!self.executing) { + process.nextTick(function() { + _execute(self)(); + }); + } +} + +// Remove connection method +function remove(connection, connections) { + for(var i = 0; i < connections.length; i++) { + if(connections[i] === connection) { + connections.splice(i, 1); + return true; + } + } +} + +function removeConnection(self, connection) { + if(remove(connection, self.availableConnections)) return; + if(remove(connection, self.inUseConnections)) return; + if(remove(connection, self.connectingConnections)) return; + if(remove(connection, self.nonAuthenticatedConnections)) return; +} + +// All event handlers +var handlers = ["close", "message", "error", "timeout", "parseError", "connect"]; + +function _createConnection(self) { + if(self.state == DESTROYED || self.state == DESTROYING) { + return; + } + var connection = new Connection(messageHandler(self), self.options); + + // Push the connection + self.connectingConnections.push(connection); + + // Handle any errors + var tempErrorHandler = function(_connection) { + return function() { + // Destroy the connection + _connection.destroy(); + // Remove the connection from the connectingConnections list + removeConnection(self, _connection); + // Start reconnection attempts + if(!self.reconnectId && self.options.reconnect) { + self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval); + } + } + } + + // Handle successful connection + var tempConnectHandler = function(_connection) { + return function() { + // Destroyed state return + if(self.state == DESTROYED || self.state == DESTROYING) { + // Remove the connection from the list + removeConnection(self, _connection); + return _connection.destroy(); + } + + // Destroy all event emitters + handlers.forEach(function(e) { + _connection.removeAllListeners(e); + }); + + // Add the final handlers + _connection.once('close', connectionFailureHandler(self, 'close')); + _connection.once('error', connectionFailureHandler(self, 'error')); + _connection.once('timeout', connectionFailureHandler(self, 'timeout')); + _connection.once('parseError', connectionFailureHandler(self, 'parseError')); + + // Signal + reauthenticate(self, _connection, function(err) { + if(self.state == DESTROYED || self.state == DESTROYING) { + return _connection.destroy(); + } + // Remove the connection from the connectingConnections list + removeConnection(self, _connection); + + // Handle error + if(err) { + return _connection.destroy(); + } + + // If we are c at the moment + // Do not automatially put in available connections + // As we need to apply the credentials first + if(self.authenticating) { + self.nonAuthenticatedConnections.push(_connection); + } else { + // Push to available + self.availableConnections.push(_connection); + // Execute any work waiting + _execute(self)(); + } + }); + } + } + + // Add all handlers + connection.once('close', tempErrorHandler(connection)); + connection.once('error', tempErrorHandler(connection)); + connection.once('timeout', tempErrorHandler(connection)); + connection.once('parseError', tempErrorHandler(connection)); + connection.once('connect', tempConnectHandler(connection)); + + // Start connection + connection.connect(); +} + +function flushMonitoringOperations(queue) { + for(var i = 0; i < queue.length; i++) { + if(queue[i].monitoring) { + var workItem = queue[i]; + queue.splice(i, 1); + workItem.cb(new MongoError({ message: 'no connection available for monitoring', driver:true })); + } + } +} + +function _execute(self) { + return function() { + if(self.state == DESTROYED) return; + // Already executing, skip + if(self.executing) return; + // Set pool as executing + self.executing = true; + + // Wait for auth to clear before continuing + function waitForAuth(cb) { + if(!self.authenticating) return cb(); + // Wait for a milisecond and try again + setTimeout(function() { + waitForAuth(cb); + }, 1); + } + + // Block on any auth in process + waitForAuth(function() { + // New pool connections are in progress, wait them to finish + // before executing any more operation to ensure distribution of + // operations + if(self.connectingConnections.length > 0) { + return; + } + + // As long as we have available connections + while(true) { + // Total availble connections + var totalConnections = self.availableConnections.length + + self.connectingConnections.length + + self.inUseConnections.length; + + // No available connections available, flush any monitoring ops + if(self.availableConnections.length == 0) { + // Flush any monitoring operations + flushMonitoringOperations(self.queue); + break; + } + + // No queue break + if(self.queue.length == 0) { + break; + } + + // Get a connection + var connection = null; + + // Locate all connections that have no work + var connections = []; + // Get a list of all connections + for(var i = 0; i < self.availableConnections.length; i++) { + if(self.availableConnections[i].workItems.length == 0) { + connections.push(self.availableConnections[i]); + } + } + + // No connection found that has no work on it, just pick one for pipelining + if(connections.length == 0) { + connection = self.availableConnections[self.connectionIndex++ % self.availableConnections.length]; + } else { + connection = connections[self.connectionIndex++ % connections.length]; + } + + // Is the connection connected + if(connection.isConnected()) { + // Get the next work item + var workItem = self.queue.shift(); + + // If we are monitoring we need to use a connection that is not + // running another operation to avoid socket timeout changes + // affecting an existing operation + if (workItem.monitoring) { + var foundValidConnection = false; + + for (var i = 0; i < self.availableConnections.length; i++) { + // If the connection is connected + // And there are no pending workItems on it + // Then we can safely use it for monitoring. + if(self.availableConnections[i].isConnected() + && self.availableConnections[i].workItems.length == 0) { + foundValidConnection = true; + connection = self.availableConnections[i]; + break; + } + } + + // No safe connection found, attempt to grow the connections + // if possible and break from the loop + if(!foundValidConnection) { + // Put workItem back on the queue + self.queue.unshift(workItem); + + // Attempt to grow the pool if it's not yet maxsize + if(totalConnections < self.options.size + && self.queue.length > 0) { + // Create a new connection + _createConnection(self); + } + + // Re-execute the operation + setTimeout(function() { + _execute(self)(); + }, 10); + + break; + } + } + + // Don't execute operation until we have a full pool + if(totalConnections < self.options.size) { + // Connection has work items, then put it back on the queue + // and create a new connection + if(connection.workItems.length > 0) { + // Lets put the workItem back on the list + self.queue.unshift(workItem); + // Create a new connection + _createConnection(self); + // Break from the loop + break; + } + } + + // Get actual binary commands + var buffer = workItem.buffer; + + // Set current status of authentication process + workItem.authenticating = self.authenticating; + workItem.authenticatingTimestamp = self.authenticatingTimestamp; + + // If we are monitoring take the connection of the availableConnections + if (workItem.monitoring) { + moveConnectionBetween(connection, self.availableConnections, self.inUseConnections); + } + + // Track the executing commands on the mongo server + // as long as there is an expected response + if (! workItem.noResponse) { + connection.workItems.push(workItem); + } + + // We have a custom socketTimeout + if(!workItem.immediateRelease && typeof workItem.socketTimeout == 'number') { + connection.setSocketTimeout(workItem.socketTimeout); + } + + // Capture if write was successful + var writeSuccessful = true; + + // Put operation on the wire + if(Array.isArray(buffer)) { + for(var i = 0; i < buffer.length; i++) { + writeSuccessful = connection.write(buffer[i]) + } + } else { + writeSuccessful = connection.write(buffer); + } + + if(writeSuccessful && workItem.immediateRelease && self.authenticating) { + removeConnection(self, connection); + self.nonAuthenticatedConnections.push(connection); + } else if(writeSuccessful === false) { + // If write not successful put back on queue + self.queue.unshift(workItem); + // Remove the disconnected connection + removeConnection(self, connection); + // Flush any monitoring operations in the queue, failing fast + flushMonitoringOperations(self.queue); + } + } else { + // Remove the disconnected connection + removeConnection(self, connection); + // Flush any monitoring operations in the queue, failing fast + flushMonitoringOperations(self.queue); + } + } + }); + + self.executing = false; + } +} + +// Make execution loop available for testing +Pool._execute = _execute; + +/** + * A server connect event, used to verify that the connection is up and running + * + * @event Pool#connect + * @type {Pool} + */ + +/** + * A server reconnect event, used to verify that pool reconnected. + * + * @event Pool#reconnect + * @type {Pool} + */ + +/** + * The server connection closed, all pool connections closed + * + * @event Pool#close + * @type {Pool} + */ + +/** + * The server connection caused an error, all pool connections closed + * + * @event Pool#error + * @type {Pool} + */ + +/** + * The server connection timed out, all pool connections closed + * + * @event Pool#timeout + * @type {Pool} + */ + +/** + * The driver experienced an invalid message, all pool connections closed + * + * @event Pool#parseError + * @type {Pool} + */ + +/** + * The driver attempted to reconnect + * + * @event Pool#attemptReconnect + * @type {Pool} + */ + +/** + * The driver exhausted all reconnect attempts + * + * @event Pool#reconnectFailed + * @type {Pool} + */ + +module.exports = Pool; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/connection/utils.js b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/utils.js new file mode 100644 index 0000000..958f21c --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/connection/utils.js @@ -0,0 +1,86 @@ +"use strict"; + +var f = require('util').format, + require_optional = require('require_optional'); + +// Set property function +var setProperty = function(obj, prop, flag, values) { + Object.defineProperty(obj, prop.name, { + enumerable:true, + set: function(value) { + if(typeof value != 'boolean') throw new Error(f("%s required a boolean", prop.name)); + // Flip the bit to 1 + if(value == true) values.flags |= flag; + // Flip the bit to 0 if it's set, otherwise ignore + if(value == false && (values.flags & flag) == flag) values.flags ^= flag; + prop.value = value; + } + , get: function() { return prop.value; } + }); +} + +// Set property function +var getProperty = function(obj, propName, fieldName, values, func) { + Object.defineProperty(obj, propName, { + enumerable:true, + get: function() { + // Not parsed yet, parse it + if(values[fieldName] == null && obj.isParsed && !obj.isParsed()) { + obj.parse(); + } + + // Do we have a post processing function + if(typeof func == 'function') return func(values[fieldName]); + // Return raw value + return values[fieldName]; + } + }); +} + +// Set simple property +var getSingleProperty = function(obj, name, value) { + Object.defineProperty(obj, name, { + enumerable:true, + get: function() { + return value + } + }); +} + +// Shallow copy +var copy = function(fObj, tObj) { + tObj = tObj || {}; + for(var name in fObj) tObj[name] = fObj[name]; + return tObj; +} + +var debugOptions = function(debugFields, options) { + var finaloptions = {}; + debugFields.forEach(function(n) { + finaloptions[n] = options[n]; + }); + + return finaloptions; +} + +var retrieveBSON = function() { + var BSON = require('bson'); + BSON.native = false; + + try { + var optionalBSON = require_optional('bson-ext'); + if(optionalBSON) { + optionalBSON.native = true; + return optionalBSON; + } + } catch(err) {} + + return BSON; +} + +exports.setProperty = setProperty; +exports.getProperty = getProperty; +exports.getSingleProperty = getSingleProperty; +exports.copy = copy; +exports.debugOptions = debugOptions; +exports.retrieveBSON = retrieveBSON; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js b/node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js new file mode 100644 index 0000000..8f0e64a --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/cursor.js @@ -0,0 +1,704 @@ +"use strict"; + +var Logger = require('./connection/logger') + , retrieveBSON = require('./connection/utils').retrieveBSON + , MongoError = require('./error') + , f = require('util').format; + +var BSON = retrieveBSON(), + Long = BSON.Long; + +/** + * This is a cursor results callback + * + * @callback resultCallback + * @param {error} error An error object. Set to null if no error present + * @param {object} document + */ + +/** + * @fileOverview The **Cursor** class is an internal class that embodies a cursor on MongoDB + * allowing for iteration over the results returned from the underlying query. + * + * **CURSORS Cannot directly be instantiated** + * @example + * var Server = require('mongodb-core').Server + * , ReadPreference = require('mongodb-core').ReadPreference + * , assert = require('assert'); + * + * var server = new Server({host: 'localhost', port: 27017}); + * // Wait for the connection event + * server.on('connect', function(server) { + * assert.equal(null, err); + * + * // Execute the write + * var cursor = _server.cursor('integration_tests.inserts_example4', { + * find: 'integration_tests.example4' + * , query: {a:1} + * }, { + * readPreference: new ReadPreference('secondary'); + * }); + * + * // Get the first document + * cursor.next(function(err, doc) { + * assert.equal(null, err); + * server.destroy(); + * }); + * }); + * + * // Start connecting + * server.connect(); + */ + +/** + * Creates a new Cursor, not to be used directly + * @class + * @param {object} bson An instance of the BSON parser + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {{object}|Long} cmd The selector (can be a command or a cursorId) + * @param {object} [options=null] Optional settings. + * @param {object} [options.batchSize=1000] Batchsize for the operation + * @param {array} [options.documents=[]] Initial documents list for cursor + * @param {object} [options.transforms=null] Transform methods for the cursor results + * @param {function} [options.transforms.query] Transform the value returned from the initial query + * @param {function} [options.transforms.doc] Transform each document returned from Cursor.prototype.next + * @param {object} topology The server topology instance. + * @param {object} topologyOptions The server topology options. + * @return {Cursor} A cursor instance + * @property {number} cursorBatchSize The current cursorBatchSize for the cursor + * @property {number} cursorLimit The current cursorLimit for the cursor + * @property {number} cursorSkip The current cursorSkip for the cursor + */ +var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) { + options = options || {}; + + // Cursor pool + this.pool = null; + // Cursor server + this.server = null; + + // Do we have a not connected handler + this.disconnectHandler = options.disconnectHandler; + + // Set local values + this.bson = bson; + this.ns = ns; + this.cmd = cmd; + this.options = options; + this.topology = topology; + + // All internal state + this.cursorState = { + cursorId: null + , cmd: cmd + , documents: options.documents || [] + , cursorIndex: 0 + , dead: false + , killed: false + , init: false + , notified: false + , limit: options.limit || cmd.limit || 0 + , skip: options.skip || cmd.skip || 0 + , batchSize: options.batchSize || cmd.batchSize || 1000 + , currentLimit: 0 + // Result field name if not a cursor (contains the array of results) + , transforms: options.transforms + } + + // Add promoteLong to cursor state + if(typeof topologyOptions.promoteLongs == 'boolean') { + this.cursorState.promoteLongs = topologyOptions.promoteLongs; + } else if(typeof options.promoteLongs == 'boolean') { + this.cursorState.promoteLongs = options.promoteLongs; + } + + // Add promoteValues to cursor state + if(typeof topologyOptions.promoteValues == 'boolean') { + this.cursorState.promoteValues = topologyOptions.promoteValues; + } else if(typeof options.promoteValues == 'boolean') { + this.cursorState.promoteValues = options.promoteValues; + } + + // Add promoteBuffers to cursor state + if(typeof topologyOptions.promoteBuffers == 'boolean') { + this.cursorState.promoteBuffers = topologyOptions.promoteBuffers; + } else if(typeof options.promoteBuffers == 'boolean') { + this.cursorState.promoteBuffers = options.promoteBuffers; + } + + // Logger + this.logger = Logger('Cursor', topologyOptions); + + // + // Did we pass in a cursor id + if(typeof cmd == 'number') { + this.cursorState.cursorId = Long.fromNumber(cmd); + this.cursorState.lastCursorId = this.cursorState.cursorId; + } else if(cmd instanceof Long) { + this.cursorState.cursorId = cmd; + this.cursorState.lastCursorId = cmd; + } +} + +Cursor.prototype.setCursorBatchSize = function(value) { + this.cursorState.batchSize = value; +} + +Cursor.prototype.cursorBatchSize = function() { + return this.cursorState.batchSize; +} + +Cursor.prototype.setCursorLimit = function(value) { + this.cursorState.limit = value; +} + +Cursor.prototype.cursorLimit = function() { + return this.cursorState.limit; +} + +Cursor.prototype.setCursorSkip = function(value) { + this.cursorState.skip = value; +} + +Cursor.prototype.cursorSkip = function() { + return this.cursorState.skip; +} + +// +// Handle callback (including any exceptions thrown) +var handleCallback = function(callback, err, result) { + try { + callback(err, result); + } catch(err) { + process.nextTick(function() { + throw err; + }); + } +} + +// Internal methods +Cursor.prototype._find = function(callback) { + var self = this; + + if(self.logger.isDebug()) { + self.logger.debug(f('issue initial query [%s] with flags [%s]' + , JSON.stringify(self.cmd) + , JSON.stringify(self.query))); + } + + var queryCallback = function(err, r) { + if(err) return callback(err); + + // Get the raw message + var result = r.message; + + // Query failure bit set + if(result.queryFailure) { + return callback(MongoError.create(result.documents[0]), null); + } + + // Check if we have a command cursor + if(Array.isArray(result.documents) && result.documents.length == 1 + && (!self.cmd.find || (self.cmd.find && self.cmd.virtual == false)) + && (result.documents[0].cursor != 'string' + || result.documents[0]['$err'] + || result.documents[0]['errmsg'] + || Array.isArray(result.documents[0].result)) + ) { + + // We have a an error document return the error + if(result.documents[0]['$err'] + || result.documents[0]['errmsg']) { + return callback(MongoError.create(result.documents[0]), null); + } + + // We have a cursor document + if(result.documents[0].cursor != null + && typeof result.documents[0].cursor != 'string') { + var id = result.documents[0].cursor.id; + // If we have a namespace change set the new namespace for getmores + if(result.documents[0].cursor.ns) { + self.ns = result.documents[0].cursor.ns; + } + // Promote id to long if needed + self.cursorState.cursorId = typeof id == 'number' ? Long.fromNumber(id) : id; + self.cursorState.lastCursorId = self.cursorState.cursorId; + // If we have a firstBatch set it + if(Array.isArray(result.documents[0].cursor.firstBatch)) { + self.cursorState.documents = result.documents[0].cursor.firstBatch;//.reverse(); + } + + // Return after processing command cursor + return callback(null, null); + } + + if(Array.isArray(result.documents[0].result)) { + self.cursorState.documents = result.documents[0].result; + self.cursorState.cursorId = Long.ZERO; + return callback(null, null); + } + } + + // Otherwise fall back to regular find path + self.cursorState.cursorId = result.cursorId; + self.cursorState.documents = result.documents; + self.cursorState.lastCursorId = result.cursorId; + + // Transform the results with passed in transformation method if provided + if(self.cursorState.transforms && typeof self.cursorState.transforms.query == 'function') { + self.cursorState.documents = self.cursorState.transforms.query(result); + } + + // Return callback + callback(null, null); + } + + // Options passed to the pool + var queryOptions = {}; + + // If we have a raw query decorate the function + if(self.options.raw || self.cmd.raw) { + // queryCallback.raw = self.options.raw || self.cmd.raw; + queryOptions.raw = self.options.raw || self.cmd.raw; + } + + // Do we have documentsReturnedIn set on the query + if(typeof self.query.documentsReturnedIn == 'string') { + // queryCallback.documentsReturnedIn = self.query.documentsReturnedIn; + queryOptions.documentsReturnedIn = self.query.documentsReturnedIn; + } + + // Add promote Long value if defined + if(typeof self.cursorState.promoteLongs == 'boolean') { + queryOptions.promoteLongs = self.cursorState.promoteLongs; + } + + // Add promote values if defined + if(typeof self.cursorState.promoteValues == 'boolean') { + queryOptions.promoteValues = self.cursorState.promoteValues; + } + + // Add promote values if defined + if(typeof self.cursorState.promoteBuffers == 'boolean') { + queryOptions.promoteBuffers = self.cursorState.promoteBuffers; + } + // Write the initial command out + self.server.s.pool.write(self.query, queryOptions, queryCallback); +} + +Cursor.prototype._getmore = function(callback) { + if(this.logger.isDebug()) this.logger.debug(f('schedule getMore call for query [%s]', JSON.stringify(this.query))) + // Determine if it's a raw query + var raw = this.options.raw || this.cmd.raw; + + // Set the current batchSize + var batchSize = this.cursorState.batchSize; + if(this.cursorState.limit > 0 + && ((this.cursorState.currentLimit + batchSize) > this.cursorState.limit)) { + batchSize = this.cursorState.limit - this.cursorState.currentLimit; + } + + // Default pool + var pool = this.server.s.pool; + + // We have a wire protocol handler + this.server.wireProtocolHandler.getMore(this.bson, this.ns, this.cursorState, batchSize, raw, pool, this.options, callback); +} + +Cursor.prototype._killcursor = function(callback) { + // Set cursor to dead + this.cursorState.dead = true; + this.cursorState.killed = true; + // Remove documents + this.cursorState.documents = []; + + // If no cursor id just return + if(this.cursorState.cursorId == null || this.cursorState.cursorId.isZero() || this.cursorState.init == false) { + if(callback) callback(null, null); + return; + } + + // Default pool + var pool = this.server.s.pool; + // Execute command + this.server.wireProtocolHandler.killCursor(this.bson, this.ns, this.cursorState.cursorId, pool, callback); +} + +/** + * Clone the cursor + * @method + * @return {Cursor} + */ +Cursor.prototype.clone = function() { + return this.topology.cursor(this.ns, this.cmd, this.options); +} + +/** + * Checks if the cursor is dead + * @method + * @return {boolean} A boolean signifying if the cursor is dead or not + */ +Cursor.prototype.isDead = function() { + return this.cursorState.dead == true; +} + +/** + * Checks if the cursor was killed by the application + * @method + * @return {boolean} A boolean signifying if the cursor was killed by the application + */ +Cursor.prototype.isKilled = function() { + return this.cursorState.killed == true; +} + +/** + * Checks if the cursor notified it's caller about it's death + * @method + * @return {boolean} A boolean signifying if the cursor notified the callback + */ +Cursor.prototype.isNotified = function() { + return this.cursorState.notified == true; +} + +/** + * Returns current buffered documents length + * @method + * @return {number} The number of items in the buffered documents + */ +Cursor.prototype.bufferedCount = function() { + return this.cursorState.documents.length - this.cursorState.cursorIndex; +} + +/** + * Returns current buffered documents + * @method + * @return {Array} An array of buffered documents + */ +Cursor.prototype.readBufferedDocuments = function(number) { + var unreadDocumentsLength = this.cursorState.documents.length - this.cursorState.cursorIndex; + var length = number < unreadDocumentsLength ? number : unreadDocumentsLength; + var elements = this.cursorState.documents.slice(this.cursorState.cursorIndex, this.cursorState.cursorIndex + length); + + // Transform the doc with passed in transformation method if provided + if(this.cursorState.transforms && typeof this.cursorState.transforms.doc == 'function') { + // Transform all the elements + for(var i = 0; i < elements.length; i++) { + elements[i] = this.cursorState.transforms.doc(elements[i]); + } + } + + // Ensure we do not return any more documents than the limit imposed + // Just return the number of elements up to the limit + if(this.cursorState.limit > 0 && (this.cursorState.currentLimit + elements.length) > this.cursorState.limit) { + elements = elements.slice(0, (this.cursorState.limit - this.cursorState.currentLimit)); + this.kill(); + } + + // Adjust current limit + this.cursorState.currentLimit = this.cursorState.currentLimit + elements.length; + this.cursorState.cursorIndex = this.cursorState.cursorIndex + elements.length; + + // Return elements + return elements; +} + +/** + * Kill the cursor + * @method + * @param {resultCallback} callback A callback function + */ +Cursor.prototype.kill = function(callback) { + this._killcursor(callback); +} + +/** + * Resets the cursor + * @method + * @return {null} + */ +Cursor.prototype.rewind = function() { + if(this.cursorState.init) { + if(!this.cursorState.dead) { + this.kill(); + } + + this.cursorState.currentLimit = 0; + this.cursorState.init = false; + this.cursorState.dead = false; + this.cursorState.killed = false; + this.cursorState.notified = false; + this.cursorState.documents = []; + this.cursorState.cursorId = null; + this.cursorState.cursorIndex = 0; + } +} + +/** + * Validate if the pool is dead and return error + */ +var isConnectionDead = function(self, callback) { + if(self.pool + && self.pool.isDestroyed()) { + self.cursorState.notified = true; + self.cursorState.killed = true; + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + callback(MongoError.create(f('connection to host %s:%s was destroyed', self.pool.host, self.pool.port))) + return true; + } + + return false; +} + +/** + * Validate if the cursor is dead but was not explicitly killed by user + */ +var isCursorDeadButNotkilled = function(self, callback) { + // Cursor is dead but not marked killed, return null + if(self.cursorState.dead && !self.cursorState.killed) { + self.cursorState.notified = true; + self.cursorState.killed = true; + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + handleCallback(callback, null, null); + return true; + } + + return false; +} + +/** + * Validate if the cursor is dead and was killed by user + */ +var isCursorDeadAndKilled = function(self, callback) { + if(self.cursorState.dead && self.cursorState.killed) { + handleCallback(callback, MongoError.create('cursor is dead')); + return true; + } + + return false; +} + +/** + * Validate if the cursor was killed by the user + */ +var isCursorKilled = function(self, callback) { + if(self.cursorState.killed) { + self.cursorState.notified = true; + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + handleCallback(callback, null, null); + return true; + } + + return false; +} + +/** + * Mark cursor as being dead and notified + */ +var setCursorDeadAndNotified = function(self, callback) { + self.cursorState.dead = true; + self.cursorState.notified = true; + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + handleCallback(callback, null, null); +} + +/** + * Mark cursor as being notified + */ +var setCursorNotified = function(self, callback) { + self.cursorState.notified = true; + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + handleCallback(callback, null, null); +} + +var nextFunction = function(self, callback) { + // We have notified about it + if(self.cursorState.notified) { + return callback(new Error('cursor is exhausted')); + } + + // Cursor is killed return null + if(isCursorKilled(self, callback)) return; + + // Cursor is dead but not marked killed, return null + if(isCursorDeadButNotkilled(self, callback)) return; + + // We have a dead and killed cursor, attempting to call next should error + if(isCursorDeadAndKilled(self, callback)) return; + + // We have just started the cursor + if(!self.cursorState.init) { + // Topology is not connected, save the call in the provided store to be + // Executed at some point when the handler deems it's reconnected + if(!self.topology.isConnected(self.options)) { + // Only need this for single server, because repl sets and mongos + // will always continue trying to reconnect + if (self.topology._type === 'server' && !self.topology.s.options.reconnect) { + // Reconnect is disabled, so we'll never reconnect + return callback(new MongoError('no connection available')); + } + if (self.disconnectHandler != null) { + if (self.topology.isDestroyed()) { + // Topology was destroyed, so don't try to wait for it to reconnect + return callback(new MongoError('Topology was destroyed')); + } + + return self.disconnectHandler.addObjectAndMethod('cursor', self, 'next', [callback], callback); + } + } + + try { + self.server = self.topology.getServer(self.options); + } catch(err) { + // Handle the error and add object to next method call + if(self.disconnectHandler != null) { + return self.disconnectHandler.addObjectAndMethod('cursor', self, 'next', [callback], callback); + } + + // Otherwise return the error + return callback(err); + } + + // Set as init + self.cursorState.init = true; + + // Server does not support server + if(self.cmd + && self.cmd.collation + && self.server.ismaster.maxWireVersion < 5) { + return callback(new MongoError(f('server %s does not support collation', self.server.name))); + } + + try { + self.query = self.server.wireProtocolHandler.command(self.bson, self.ns, self.cmd, self.cursorState, self.topology, self.options); + } catch(err) { + return callback(err); + } + } + + // If we don't have a cursorId execute the first query + if(self.cursorState.cursorId == null) { + // Check if pool is dead and return if not possible to + // execute the query against the db + if(isConnectionDead(self, callback)) return; + + // Check if topology is destroyed + if(self.topology.isDestroyed()) return callback(new MongoError('connection destroyed, not possible to instantiate cursor')); + + // query, cmd, options, cursorState, callback + self._find(function(err) { + if(err) return handleCallback(callback, err, null); + + if(self.cursorState.documents.length == 0 + && self.cursorState.cursorId && self.cursorState.cursorId.isZero() + && !self.cmd.tailable && !self.cmd.awaitData) { + return setCursorNotified(self, callback); + } + + nextFunction(self, callback); + }); + } else if(self.cursorState.limit > 0 && self.cursorState.currentLimit >= self.cursorState.limit) { + // Ensure we kill the cursor on the server + self.kill(); + // Set cursor in dead and notified state + return setCursorDeadAndNotified(self, callback); + } else if(self.cursorState.cursorIndex == self.cursorState.documents.length + && !Long.ZERO.equals(self.cursorState.cursorId)) { + // Ensure an empty cursor state + self.cursorState.documents = []; + self.cursorState.cursorIndex = 0; + + // Check if topology is destroyed + if(self.topology.isDestroyed()) return callback(new MongoError('connection destroyed, not possible to instantiate cursor')); + + // Check if connection is dead and return if not possible to + // execute a getmore on this connection + if(isConnectionDead(self, callback)) return; + + // Execute the next get more + self._getmore(function(err, doc, connection) { + if(err) return handleCallback(callback, err); + + // Save the returned connection to ensure all getMore's fire over the same connection + self.connection = connection; + + // Tailable cursor getMore result, notify owner about it + // No attempt is made here to retry, this is left to the user of the + // core module to handle to keep core simple + if(self.cursorState.documents.length == 0 + && self.cmd.tailable && Long.ZERO.equals(self.cursorState.cursorId)) { + // No more documents in the tailed cursor + return handleCallback(callback, MongoError.create({ + message: 'No more documents in tailed cursor' + , tailable: self.cmd.tailable + , awaitData: self.cmd.awaitData + })); + } else if(self.cursorState.documents.length == 0 + && self.cmd.tailable && !Long.ZERO.equals(self.cursorState.cursorId)) { + return nextFunction(self, callback); + } + + if(self.cursorState.limit > 0 && self.cursorState.currentLimit >= self.cursorState.limit) { + return setCursorDeadAndNotified(self, callback); + } + + nextFunction(self, callback); + }); + } else if(self.cursorState.documents.length == self.cursorState.cursorIndex + && self.cmd.tailable && Long.ZERO.equals(self.cursorState.cursorId)) { + return handleCallback(callback, MongoError.create({ + message: 'No more documents in tailed cursor' + , tailable: self.cmd.tailable + , awaitData: self.cmd.awaitData + })); + } else if(self.cursorState.documents.length == self.cursorState.cursorIndex + && Long.ZERO.equals(self.cursorState.cursorId)) { + setCursorDeadAndNotified(self, callback); + } else { + if(self.cursorState.limit > 0 && self.cursorState.currentLimit >= self.cursorState.limit) { + // Ensure we kill the cursor on the server + self.kill(); + // Set cursor in dead and notified state + return setCursorDeadAndNotified(self, callback); + } + + // Increment the current cursor limit + self.cursorState.currentLimit += 1; + + // Get the document + var doc = self.cursorState.documents[self.cursorState.cursorIndex++]; + + // Doc overflow + if(!doc || doc.$err) { + // Ensure we kill the cursor on the server + self.kill(); + // Set cursor in dead and notified state + return setCursorDeadAndNotified(self, function() { + handleCallback(callback, new MongoError(doc ? doc.$err : undefined)); + }); + } + + // Transform the doc with passed in transformation method if provided + if(self.cursorState.transforms && typeof self.cursorState.transforms.doc == 'function') { + doc = self.cursorState.transforms.doc(doc); + } + + // Return the document + handleCallback(callback, null, doc); + } +} + +/** + * Retrieve the next document from the cursor + * @method + * @param {resultCallback} callback A callback function + */ +Cursor.prototype.next = function(callback) { + nextFunction(this, callback); +} + +module.exports = Cursor; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/error.js b/node_modules/mongoose/node_modules/mongodb-core/lib/error.js new file mode 100644 index 0000000..31ede94 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/error.js @@ -0,0 +1,44 @@ +"use strict"; + +/** + * Creates a new MongoError + * @class + * @augments Error + * @param {string} message The error message + * @return {MongoError} A MongoError instance + */ +function MongoError(message) { + this.name = 'MongoError'; + this.message = message; + Error.captureStackTrace(this, MongoError); +} + +/** + * Creates a new MongoError object + * @method + * @param {object} options The error options + * @return {MongoError} A MongoError instance + */ +MongoError.create = function(options) { + var err = null; + + if(options instanceof Error) { + err = new MongoError(options.message); + err.stack = options.stack; + } else if(typeof options == 'string') { + err = new MongoError(options); + } else { + err = new MongoError(options.message || options.errmsg || options.$err || "n/a"); + // Other options + for(var name in options) { + err[name] = options[name]; + } + } + + return err; +} + +// Extend JavaScript error +MongoError.prototype = new Error; + +module.exports = MongoError; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/tools/smoke_plugin.js b/node_modules/mongoose/node_modules/mongodb-core/lib/tools/smoke_plugin.js new file mode 100644 index 0000000..dcceda4 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/tools/smoke_plugin.js @@ -0,0 +1,59 @@ +var fs = require('fs'); + +/* Note: because this plugin uses process.on('uncaughtException'), only one + * of these can exist at any given time. This plugin and anything else that + * uses process.on('uncaughtException') will conflict. */ +exports.attachToRunner = function(runner, outputFile) { + var smokeOutput = { results : [] }; + var runningTests = {}; + + var integraPlugin = { + beforeTest: function(test, callback) { + test.startTime = Date.now(); + runningTests[test.name] = test; + callback(); + }, + afterTest: function(test, callback) { + smokeOutput.results.push({ + status: test.status, + start: test.startTime, + end: Date.now(), + test_file: test.name, + exit_code: 0, + url: "" + }); + delete runningTests[test.name]; + callback(); + }, + beforeExit: function(obj, callback) { + fs.writeFile(outputFile, JSON.stringify(smokeOutput), function() { + callback(); + }); + } + }; + + // In case of exception, make sure we write file + process.on('uncaughtException', function(err) { + // Mark all currently running tests as failed + for (var testName in runningTests) { + smokeOutput.results.push({ + status: "fail", + start: runningTests[testName].startTime, + end: Date.now(), + test_file: testName, + exit_code: 0, + url: "" + }); + } + + // write file + fs.writeFileSync(outputFile, JSON.stringify(smokeOutput)); + + // Standard NodeJS uncaught exception handler + console.error(err.stack); + process.exit(1); + }); + + runner.plugin(integraPlugin); + return integraPlugin; +}; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/mongos.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/mongos.js new file mode 100644 index 0000000..f6c5734 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/mongos.js @@ -0,0 +1,1307 @@ +"use strict" + +var inherits = require('util').inherits, + f = require('util').format, + EventEmitter = require('events').EventEmitter, + BasicCursor = require('../cursor'), + Logger = require('../connection/logger'), + retrieveBSON = require('../connection/utils').retrieveBSON, + MongoError = require('../error'), + Server = require('./server'), + assign = require('../utils').assign, + clone = require('./shared').clone, + sdam = require('./shared'), + diff = require('./shared').diff, + cloneOptions = require('./shared').cloneOptions, + createClientInfo = require('./shared').createClientInfo; + +var BSON = retrieveBSON(); + +/** + * @fileOverview The **Mongos** class is a class that represents a Mongos Proxy topology and is + * used to construct connections. + * + * @example + * var Mongos = require('mongodb-core').Mongos + * , ReadPreference = require('mongodb-core').ReadPreference + * , assert = require('assert'); + * + * var server = new Mongos([{host: 'localhost', port: 30000}]); + * // Wait for the connection event + * server.on('connect', function(server) { + * server.destroy(); + * }); + * + * // Start connecting + * server.connect(); + */ + +var MongoCR = require('../auth/mongocr') + , X509 = require('../auth/x509') + , Plain = require('../auth/plain') + , GSSAPI = require('../auth/gssapi') + , SSPI = require('../auth/sspi') + , ScramSHA1 = require('../auth/scram'); + +// +// States +var DISCONNECTED = 'disconnected'; +var CONNECTING = 'connecting'; +var CONNECTED = 'connected'; +var UNREFERENCED = 'unreferenced'; +var DESTROYED = 'destroyed'; + +function stateTransition(self, newState) { + var legalTransitions = { + 'disconnected': [CONNECTING, DESTROYED, DISCONNECTED], + 'connecting': [CONNECTING, DESTROYED, CONNECTED, DISCONNECTED], + 'connected': [CONNECTED, DISCONNECTED, DESTROYED, UNREFERENCED], + 'unreferenced': [UNREFERENCED, DESTROYED], + 'destroyed': [DESTROYED] + } + + // Get current state + var legalStates = legalTransitions[self.state]; + if(legalStates && legalStates.indexOf(newState) != -1) { + self.state = newState; + } else { + self.logger.error(f('Pool with id [%s] failed attempted illegal state transition from [%s] to [%s] only following state allowed [%s]' + , self.id, self.state, newState, legalStates)); + } +} + +// +// ReplSet instance id +var id = 1; +var handlers = ['connect', 'close', 'error', 'timeout', 'parseError']; + +/** + * Creates a new Mongos instance + * @class + * @param {array} seedlist A list of seeds for the replicaset + * @param {number} [options.haInterval=5000] The High availability period for replicaset inquiry + * @param {Cursor} [options.cursorFactory=Cursor] The cursor factory class used for all query cursors + * @param {number} [options.size=5] Server connection pool size + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=0] Initial delay before TCP keep alive enabled + * @param {number} [options.localThresholdMS=15] Cutoff latency point in MS for MongoS proxy selection + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.connectionTimeout=1000] TCP Connection timeout setting + * @param {number} [options.socketTimeout=0] TCP Socket timeout setting + * @param {boolean} [options.singleBufferSerializtion=true] Serialize into single buffer, trade of peak memory for serialization speed + * @param {boolean} [options.ssl=false] Use SSL for connection + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {Buffer} [options.ca] SSL Certificate store binary buffer + * @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer + * @param {Buffer} [options.cert] SSL Certificate binary buffer + * @param {Buffer} [options.key] SSL Key file binary buffer + * @param {string} [options.passphrase] SSL Certificate pass phrase + * @param {string} [options.servername=null] String containing the server name requested via TLS SNI. + * @param {boolean} [options.rejectUnauthorized=true] Reject unauthorized server certificates + * @param {boolean} [options.promoteLongs=true] Convert Long values from the db into Numbers if they fit into 53 bits + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @return {Mongos} A cursor instance + * @fires Mongos#connect + * @fires Mongos#reconnect + * @fires Mongos#joined + * @fires Mongos#left + * @fires Mongos#failed + * @fires Mongos#fullsetup + * @fires Mongos#all + * @fires Mongos#serverHeartbeatStarted + * @fires Mongos#serverHeartbeatSucceeded + * @fires Mongos#serverHeartbeatFailed + * @fires Mongos#topologyOpening + * @fires Mongos#topologyClosed + * @fires Mongos#topologyDescriptionChanged + * @property {string} type the topology type. + * @property {string} parserType the parser type used (c++ or js). + */ +var Mongos = function(seedlist, options) { + options = options || {}; + + // Get replSet Id + this.id = id++; + + // Internal state + this.s = { + options: assign({}, options), + // BSON instance + bson: options.bson || new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, + BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, + BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]), + // Factory overrides + Cursor: options.cursorFactory || BasicCursor, + // Logger instance + logger: Logger('Mongos', options), + // Seedlist + seedlist: seedlist, + // Ha interval + haInterval: options.haInterval ? options.haInterval : 10000, + // Disconnect handler + disconnectHandler: options.disconnectHandler, + // Server selection index + index: 0, + // Connect function options passed in + connectOptions: {}, + // Are we running in debug mode + debug: typeof options.debug == 'boolean' ? options.debug : false, + // localThresholdMS + localThresholdMS: options.localThresholdMS || 15, + // Client info + clientInfo: createClientInfo(options), + // Authentication context + authenticationContexts: [], + } + + // Set the client info + this.s.options.clientInfo = createClientInfo(options); + + // Log info warning if the socketTimeout < haInterval as it will cause + // a lot of recycled connections to happen. + if(this.s.logger.isWarn() + && this.s.options.socketTimeout != 0 + && this.s.options.socketTimeout < this.s.haInterval) { + this.s.logger.warn(f('warning socketTimeout %s is less than haInterval %s. This might cause unnecessary server reconnections due to socket timeouts' + , this.s.options.socketTimeout, this.s.haInterval)); + } + + // All the authProviders + this.authProviders = options.authProviders || { + 'mongocr': new MongoCR(this.s.bson), 'x509': new X509(this.s.bson) + , 'plain': new Plain(this.s.bson), 'gssapi': new GSSAPI(this.s.bson) + , 'sspi': new SSPI(this.s.bson), 'scram-sha-1': new ScramSHA1(this.s.bson) + } + + // Disconnected state + this.state = DISCONNECTED; + + // Current proxies we are connecting to + this.connectingProxies = []; + // Currently connected proxies + this.connectedProxies = []; + // Disconnected proxies + this.disconnectedProxies = []; + // Are we authenticating + this.authenticating = false; + // Index of proxy to run operations against + this.index = 0; + // High availability timeout id + this.haTimeoutId = null; + // Last ismaster + this.ismaster = null; + + // Description of the Replicaset + this.topologyDescription = { + "topologyType": "Unknown", "servers": [] + }; + + // Add event listener + EventEmitter.call(this); +} + +inherits(Mongos, EventEmitter); + +Object.defineProperty(Mongos.prototype, 'type', { + enumerable:true, get: function() { return 'mongos'; } +}); + +Object.defineProperty(Mongos.prototype, 'parserType', { + enumerable:true, get: function() { + return BSON.native ? "c++" : "js"; + } +}); + +/** + * Emit event if it exists + * @method + */ +function emitSDAMEvent(self, event, description) { + if(self.listeners(event).length > 0) { + self.emit(event, description); + } +} + +/** + * Initiate server connect + * @method + * @param {array} [options.auth=null] Array of auth options to apply on connect + */ +Mongos.prototype.connect = function(options) { + var self = this; + // Add any connect level options to the internal state + this.s.connectOptions = options || {}; + // Set connecting state + stateTransition(this, CONNECTING); + // Create server instances + var servers = this.s.seedlist.map(function(x) { + return new Server(assign({}, self.s.options, x, { + authProviders: self.authProviders, reconnect:false, monitoring:false, inTopology: true + }, { + clientInfo: clone(self.s.clientInfo) + })); + }); + + servers.forEach(function(server) { + server.on('serverDescriptionChanged', function(event) { self.emit('serverDescriptionChanged', event); }); + }); + + // Emit the topology opening event + emitSDAMEvent(this, 'topologyOpening', { topologyId: this.id }); + + // Start all server connections + connectProxies(self, servers); +} + +function handleEvent(self) { + return function() { + if(self.state == DESTROYED) return; + // Move to list of disconnectedProxies + moveServerFrom(self.connectedProxies, self.disconnectedProxies, this); + // Emit the initial topology + emitTopologyDescriptionChanged(self); + // Emit the left signal + self.emit('left', 'mongos', this); + // Emit the sdam event + self.emit('serverClosed', { + topologyId: self.id, + address: this.name + }); + } +} + +function handleInitialConnectEvent(self, event) { + return function() { + var _this = this; + + // Destroy the instance + if(self.state == DESTROYED) { + // Emit the initial topology + emitTopologyDescriptionChanged(self); + // Move from connectingProxies + moveServerFrom(self.connectingProxies, self.disconnectedProxies, this); + return this.destroy(); + } + + // Check the type of server + if(event == 'connect') { + // Do we have authentication contexts that need to be applied + applyAuthenticationContexts(self, _this, function() { + // Get last known ismaster + self.ismaster = _this.lastIsMaster(); + + // Is this not a proxy, remove t + if(self.ismaster.msg == 'isdbgrid') { + // Add to the connectd list + for(var i = 0; i < self.connectedProxies.length; i++) { + if(self.connectedProxies[i].name == _this.name) { + // Move from connectingProxies + moveServerFrom(self.connectingProxies, self.disconnectedProxies, _this); + // Emit the initial topology + emitTopologyDescriptionChanged(self); + _this.destroy(); + return self.emit('failed', _this); + } + } + + // Remove the handlers + for(i = 0; i < handlers.length; i++) { + _this.removeAllListeners(handlers[i]); + } + + // Add stable state handlers + _this.on('error', handleEvent(self, 'error')); + _this.on('close', handleEvent(self, 'close')); + _this.on('timeout', handleEvent(self, 'timeout')); + _this.on('parseError', handleEvent(self, 'parseError')); + + // Move from connecting proxies connected + moveServerFrom(self.connectingProxies, self.connectedProxies, _this); + // Emit the joined event + self.emit('joined', 'mongos', _this); + } else { + + // Print warning if we did not find a mongos proxy + if(self.s.logger.isWarn()) { + var message = 'expected mongos proxy, but found replicaset member mongod for server %s'; + // We have a standalone server + if(!self.ismaster.hosts) { + message = 'expected mongos proxy, but found standalone mongod for server %s'; + } + + self.s.logger.warn(f(message, _this.name)); + } + + // This is not a mongos proxy, remove it completely + removeProxyFrom(self.connectingProxies, _this); + // Emit the left event + self.emit('left', 'server', _this); + // Emit failed event + self.emit('failed', _this); + } + }); + } else { + moveServerFrom(self.connectingProxies, self.disconnectedProxies, this); + // Emit the left event + self.emit('left', 'mongos', this); + // Emit failed event + self.emit('failed', this); + } + + // Emit the initial topology + emitTopologyDescriptionChanged(self); + + // Trigger topologyMonitor + if(self.connectingProxies.length == 0) { + // Emit connected if we are connected + if(self.connectedProxies.length > 0) { + // Set the state to connected + stateTransition(self, CONNECTED); + // Emit the connect event + self.emit('connect', self); + self.emit('fullsetup', self); + self.emit('all', self); + } else if(self.disconnectedProxies.length == 0) { + // Print warning if we did not find a mongos proxy + if(self.s.logger.isWarn()) { + self.s.logger.warn(f('no mongos proxies found in seed list, did you mean to connect to a replicaset')); + } + + // Emit the error that no proxies were found + return self.emit('error', new MongoError('no mongos proxies found in seed list')); + } + + // Topology monitor + topologyMonitor(self, {firstConnect:true}); + } + }; +} + +function connectProxies(self, servers) { + // Update connectingProxies + self.connectingProxies = self.connectingProxies.concat(servers); + + // Index used to interleaf the server connects, avoiding + // runtime issues on io constrained vm's + var timeoutInterval = 0; + + function connect(server, timeoutInterval) { + setTimeout(function() { + // Emit opening server event + self.emit('serverOpening', { + topologyId: self.id, + address: server.name + }); + + // Emit the initial topology + emitTopologyDescriptionChanged(self); + + // Add event handlers + server.once('close', handleInitialConnectEvent(self, 'close')); + server.once('timeout', handleInitialConnectEvent(self, 'timeout')); + server.once('parseError', handleInitialConnectEvent(self, 'parseError')); + server.once('error', handleInitialConnectEvent(self, 'error')); + server.once('connect', handleInitialConnectEvent(self, 'connect')); + // Start connection + server.connect(self.s.connectOptions); + }, timeoutInterval); + } + // Start all the servers + while(servers.length > 0) { + connect(servers.shift(), timeoutInterval++); + } +} + +function pickProxy(self) { + // Get the currently connected Proxies + var connectedProxies = self.connectedProxies.slice(0); + + // Set lower bound + var lowerBoundLatency = Number.MAX_VALUE; + + // Determine the lower bound for the Proxies + for(var i = 0; i < connectedProxies.length; i++) { + if(connectedProxies[i].lastIsMasterMS < lowerBoundLatency) { + lowerBoundLatency = connectedProxies[i].lastIsMasterMS; + } + } + + // Filter out the possible servers + connectedProxies = connectedProxies.filter(function(server) { + if((server.lastIsMasterMS <= (lowerBoundLatency + self.s.localThresholdMS)) + && server.isConnected()) { + return true; + } + }); + + // We have no connectedProxies pick first of the connected ones + if(connectedProxies.length == 0) { + return self.connectedProxies[0]; + } + + // Get proxy + var proxy = connectedProxies[self.index % connectedProxies.length]; + // Update the index + self.index = (self.index + 1) % connectedProxies.length; + // Return the proxy + return proxy; +} + +function moveServerFrom(from, to, proxy) { + for(var i = 0; i < from.length; i++) { + if(from[i].name == proxy.name) { + from.splice(i, 1); + } + } + + for(i = 0; i < to.length; i++) { + if(to[i].name == proxy.name) { + to.splice(i, 1); + } + } + + to.push(proxy); +} + +function removeProxyFrom(from, proxy) { + for(var i = 0; i < from.length; i++) { + if(from[i].name == proxy.name) { + from.splice(i, 1); + } + } +} + +function reconnectProxies(self, proxies, callback) { + // Count lefts + var count = proxies.length; + + // Handle events + var _handleEvent = function(self, event) { + return function() { + var _self = this; + count = count - 1; + + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + moveServerFrom(self.connectingProxies, self.disconnectedProxies, _self); + // Return destroy + return this.destroy(); + } + + if(event == 'connect' && !self.authenticating) { + // Do we have authentication contexts that need to be applied + applyAuthenticationContexts(self, _self, function() { + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + moveServerFrom(self.connectingProxies, self.disconnectedProxies, _self); + return _self.destroy(); + } + + // Remove the handlers + for(var i = 0; i < handlers.length; i++) { + _self.removeAllListeners(handlers[i]); + } + + // Add stable state handlers + _self.on('error', handleEvent(self, 'error')); + _self.on('close', handleEvent(self, 'close')); + _self.on('timeout', handleEvent(self, 'timeout')); + _self.on('parseError', handleEvent(self, 'parseError')); + + // Move to the connected servers + moveServerFrom(self.disconnectedProxies, self.connectedProxies, _self); + // Emit topology Change + emitTopologyDescriptionChanged(self); + // Emit joined event + self.emit('joined', 'mongos', _self); + }); + } else if(event == 'connect' && self.authenticating) { + // Move from connectingProxies + moveServerFrom(self.connectingProxies, self.disconnectedProxies, _self); + this.destroy(); + } + + // Are we done finish up callback + if(count == 0) { + callback(); + } + } + } + + // No new servers + if(count == 0) { + return callback(); + } + + // Execute method + function execute(_server, i) { + setTimeout(function() { + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return; + } + + // Create a new server instance + var server = new Server(assign({}, self.s.options, { + host: _server.name.split(':')[0], + port: parseInt(_server.name.split(':')[1], 10) + }, { + authProviders: self.authProviders, reconnect:false, monitoring: false, inTopology: true + }, { + clientInfo: clone(self.s.clientInfo) + })); + + // Relay the server description change + server.on('serverDescriptionChanged', function(event) { self.emit('serverDescriptionChanged', event); }); + + // Emit opening server event + self.emit('serverOpening', { + topologyId: server.s.topologyId != -1 ? server.s.topologyId : self.id, + address: server.name + }); + + // Add temp handlers + server.once('connect', _handleEvent(self, 'connect')); + server.once('close', _handleEvent(self, 'close')); + server.once('timeout', _handleEvent(self, 'timeout')); + server.once('error', _handleEvent(self, 'error')); + server.once('parseError', _handleEvent(self, 'parseError')); + + // Connect to proxy + server.connect(self.s.connectOptions); + }, i); + } + + // Create new instances + for(var i = 0; i < proxies.length; i++) { + execute(proxies[i], i); + } +} + +function applyAuthenticationContexts(self, server, callback) { + if(self.s.authenticationContexts.length == 0) { + return callback(); + } + + // Copy contexts to ensure no modificiation in the middle of + // auth process. + var authContexts = self.s.authenticationContexts.slice(0); + + // Apply one of the contexts + function applyAuth(authContexts, server, callback) { + if(authContexts.length == 0) return callback(); + // Get the first auth context + var authContext = authContexts.shift(); + // Copy the params + var customAuthContext = authContext.slice(0); + // Push our callback handler + customAuthContext.push(function(err) { + applyAuth(authContexts, server, callback); + }); + + // Attempt authentication + server.auth.apply(server, customAuthContext) + } + + // Apply all auth contexts + applyAuth(authContexts, server, callback); +} + +function topologyMonitor(self, options) { + options = options || {}; + + // Set momitoring timeout + self.haTimeoutId = setTimeout(function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + // If we have a primary and a disconnect handler, execute + // buffered operations + if(self.isConnected() && self.s.disconnectHandler) { + self.s.disconnectHandler.execute(); + } + + // Get the connectingServers + var proxies = self.connectedProxies.slice(0); + // Get the count + var count = proxies.length; + + // If the count is zero schedule a new fast + function pingServer(_self, _server, cb) { + // Measure running time + var start = new Date().getTime(); + + // Emit the server heartbeat start + emitSDAMEvent(self, 'serverHeartbeatStarted', { connectionId: _server.name }); + + // Execute ismaster + _server.command('admin.$cmd', { + ismaster:true + }, { + monitoring: true, + socketTimeout: self.s.options.connectionTimeout || 2000, + }, function(err, r) { + if(self.state == DESTROYED || self.state == UNREFERENCED) { + // Move from connectingProxies + moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server); + _server.destroy(); + return cb(err, r); + } + + // Calculate latency + var latencyMS = new Date().getTime() - start; + + // We had an error, remove it from the state + if(err) { + // Emit the server heartbeat failure + emitSDAMEvent(self, 'serverHeartbeatFailed', { durationMS: latencyMS, failure: err, connectionId: _server.name }); + // Move from connected proxies to disconnected proxies + moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server); + } else { + // Update the server ismaster + _server.ismaster = r.result; + _server.lastIsMasterMS = latencyMS; + + // Server heart beat event + emitSDAMEvent(self, 'serverHeartbeatSucceeded', { durationMS: latencyMS, reply: r.result, connectionId: _server.name }); + } + + cb(err, r); + }); + } + + // No proxies initiate monitor again + if(proxies.length == 0) { + // Emit close event if any listeners registered + if(self.listeners("close").length > 0 && self.state == CONNECTING) { + self.emit('error', new MongoError('no mongos proxy available')); + } else { + self.emit('close', self); + } + + // Attempt to connect to any unknown servers + return reconnectProxies(self, self.disconnectedProxies, function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + + // Are we connected ? emit connect event + if(self.state == CONNECTING && options.firstConnect) { + self.emit('connect', self); + self.emit('fullsetup', self); + self.emit('all', self); + } else if(self.isConnected()) { + self.emit('reconnect', self); + } else if(!self.isConnected() && self.listeners("close").length > 0) { + self.emit('close', self); + } + + // Perform topology monitor + topologyMonitor(self); + }); + } + + // Ping all servers + for(var i = 0; i < proxies.length; i++) { + pingServer(self, proxies[i], function() { + count = count - 1; + + if(count == 0) { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + + // Attempt to connect to any unknown servers + reconnectProxies(self, self.disconnectedProxies, function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + // Perform topology monitor + topologyMonitor(self); + }); + } + }); + } + }, self.s.haInterval); +} + +/** + * Returns the last known ismaster document for this server + * @method + * @return {object} + */ +Mongos.prototype.lastIsMaster = function() { + return this.ismaster; +} + +/** + * Unref all connections belong to this server + * @method + */ +Mongos.prototype.unref = function() { + // Transition state + stateTransition(this, UNREFERENCED); + // Get all proxies + var proxies = this.connectedProxies.concat(this.connectingProxies); + proxies.forEach(function(x) { + x.unref(); + }); + + clearTimeout(this.haTimeoutId); +} + +/** + * Destroy the server connection + * @param {boolean} [options.force=false] Force destroy the pool + * @method + */ +Mongos.prototype.destroy = function(options) { + var self = this; + // Transition state + stateTransition(this, DESTROYED); + // Get all proxies + var proxies = this.connectedProxies.concat(this.connectingProxies); + // Clear out any monitoring process + if(this.haTimeoutId) clearTimeout(this.haTimeoutId); + // Clear out authentication contexts + this.s.authenticationContexts = []; + + // Destroy all connecting servers + proxies.forEach(function(x) { + // Emit the sdam event + self.emit('serverClosed', { + topologyId: self.id, + address: x.name + }); + + // Destroy the server + x.destroy(options); + // Move to list of disconnectedProxies + moveServerFrom(self.connectedProxies, self.disconnectedProxies, x); + }); + + // Emit the final topology change + emitTopologyDescriptionChanged(self); + // Emit toplogy closing event + emitSDAMEvent(this, 'topologyClosed', { topologyId: this.id }); +} + +/** + * Figure out if the server is connected + * @method + * @return {boolean} + */ +Mongos.prototype.isConnected = function() { + return this.connectedProxies.length > 0; +} + +/** + * Figure out if the server instance was destroyed by calling destroy + * @method + * @return {boolean} + */ +Mongos.prototype.isDestroyed = function() { + return this.state == DESTROYED; +} + +// +// Operations +// + +// Execute write operation +var executeWriteOperation = function(self, op, ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + // Ensure we have no options + options = options || {}; + // Pick a server + var server = pickProxy(self); + // No server found error out + if(!server) return callback(new MongoError('no mongos proxy available')); + // Execute the command + server[op](ns, ops, options, callback); +} + +/** + * Insert one or more documents + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of documents to insert + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Mongos.prototype.insert = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.isConnected() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('insert', ns, ops, options, callback); + } + + // No mongos proxy available + if(!this.isConnected()) { + return callback(new MongoError('no mongos proxy available')); + } + + // Execute write operation + executeWriteOperation(this, 'insert', ns, ops, options, callback); +} + +/** + * Perform one or more update operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of updates + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Mongos.prototype.update = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.isConnected() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('update', ns, ops, options, callback); + } + + // No mongos proxy available + if(!this.isConnected()) { + return callback(new MongoError('no mongos proxy available')); + } + + // Execute write operation + executeWriteOperation(this, 'update', ns, ops, options, callback); +} + +/** + * Perform one or more remove operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of removes + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Mongos.prototype.remove = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.isConnected() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('remove', ns, ops, options, callback); + } + + // No mongos proxy available + if(!this.isConnected()) { + return callback(new MongoError('no mongos proxy available')); + } + + // Execute write operation + executeWriteOperation(this, 'remove', ns, ops, options, callback); +} + +/** + * Execute a command + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {object} cmd The command hash + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Connection} [options.connection] Specify connection object to execute command against + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Mongos.prototype.command = function(ns, cmd, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + var self = this; + + // Pick a proxy + var server = pickProxy(self); + + // Topology is not connected, save the call in the provided store to be + // Executed at some point when the handler deems it's reconnected + if((server == null || !server.isConnected()) && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('command', ns, cmd, options, callback); + } + + // No server returned we had an error + if(server == null) { + return callback(new MongoError('no mongos proxy available')); + } + + // Cloned options + var clonedOptions = cloneOptions(options); + clonedOptions.topology = self; + + // Execute the command + server.command(ns, cmd, clonedOptions, callback); +} + +/** + * Perform one or more remove operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {{object}|{Long}} cmd Can be either a command returning a cursor or a cursorId + * @param {object} [options.batchSize=0] Batchsize for the operation + * @param {array} [options.documents=[]] Initial documents list for cursor + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Mongos.prototype.cursor = function(ns, cmd, cursorOptions) { + cursorOptions = cursorOptions || {}; + var FinalCursor = cursorOptions.cursorFactory || this.s.Cursor; + return new FinalCursor(this.s.bson, ns, cmd, cursorOptions, this, this.s.options); +} + +/** + * Authenticate using a specified mechanism + * @method + * @param {string} mechanism The Auth mechanism we are invoking + * @param {string} db The db we are invoking the mechanism against + * @param {...object} param Parameters for the specific mechanism + * @param {authResultCallback} callback A callback function + */ +Mongos.prototype.auth = function(mechanism, db) { + var allArgs = Array.prototype.slice.call(arguments, 0).slice(0); + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + var callback = args.pop(); + var currentContextIndex = 0; + + // If we don't have the mechanism fail + if(this.authProviders[mechanism] == null && mechanism != 'default') { + return callback(new MongoError(f("auth provider %s does not exist", mechanism))); + } + + // Are we already authenticating, throw + if(this.authenticating) { + return callback(new MongoError('authentication or logout allready in process')); + } + + // Topology is not connected, save the call in the provided store to be + // Executed at some point when the handler deems it's reconnected + if(!self.isConnected() && self.s.disconnectHandler != null) { + return self.s.disconnectHandler.add('auth', db, allArgs, {}, callback); + } + + // Set to authenticating + this.authenticating = true; + // All errors + var errors = []; + + // Get all the servers + var servers = this.connectedProxies.slice(0); + // No servers return + if(servers.length == 0) { + this.authenticating = false; + callback(null, true); + } + + // Authenticate + function auth(server) { + // Arguments without a callback + var argsWithoutCallback = [mechanism, db].concat(args.slice(0)); + // Create arguments + var finalArguments = argsWithoutCallback.concat([function(err) { + count = count - 1; + // Save all the errors + if(err) errors.push({name: server.name, err: err}); + // We are done + if(count == 0) { + // Auth is done + self.authenticating = false; + + // Return the auth error + if(errors.length) { + // Remove the entry from the stored authentication contexts + self.s.authenticationContexts.splice(currentContextIndex, 0); + // Return error + return callback(MongoError.create({ + message: 'authentication fail', errors: errors + }), false); + } + + // Successfully authenticated session + callback(null, self); + } + }]); + + // Execute the auth only against non arbiter servers + if(!server.lastIsMaster().arbiterOnly) { + server.auth.apply(server, finalArguments); + } + } + + // Save current context index + currentContextIndex = this.s.authenticationContexts.length; + // Store the auth context and return the last index + this.s.authenticationContexts.push([mechanism, db].concat(args.slice(0))); + + // Get total count + var count = servers.length; + // Authenticate against all servers + while(servers.length > 0) { + auth(servers.shift()); + } +} + +/** + * Logout from a database + * @method + * @param {string} db The db we are logging out from + * @param {authResultCallback} callback A callback function + */ +Mongos.prototype.logout = function(dbName, callback) { + var self = this; + // Are we authenticating or logging out, throw + if(this.authenticating) { + throw new MongoError('authentication or logout allready in process'); + } + + // Ensure no new members are processed while logging out + this.authenticating = true; + + // Remove from all auth providers (avoid any reaplication of the auth details) + var providers = Object.keys(this.authProviders); + for(var i = 0; i < providers.length; i++) { + this.authProviders[providers[i]].logout(dbName); + } + + // Now logout all the servers + var servers = this.connectedProxies.slice(0); + var count = servers.length; + if(count == 0) return callback(); + var errors = []; + + function logoutServer(_server, cb) { + _server.logout(dbName, function(err) { + if(err) errors.push({name: _server.name, err: err}); + cb(); + }); + } + + // Execute logout on all server instances + for(i = 0; i < servers.length; i++) { + logoutServer(servers[i], function() { + count = count - 1; + + if(count == 0) { + // Do not block new operations + self.authenticating = false; + // If we have one or more errors + if(errors.length) return callback(MongoError.create({ + message: f('logout failed against db %s', dbName), errors: errors + }), false); + + // No errors + callback(); + } + }) + } +} + +/** + * Get server + * @method + * @return {Server} + */ +Mongos.prototype.getServer = function() { + var server = pickProxy(this); + if(this.s.debug) this.emit('pickedServer', null, server); + return server; +} + +/** + * Get a direct connection + * @method + * @return {Connection} + */ +Mongos.prototype.getConnection = function() { + var server = this.getServer(); + if(server) return server.getConnection(); +} + +/** + * All raw connections + * @method + * @return {Connection[]} + */ +Mongos.prototype.connections = function() { + var connections = []; + + for(var i = 0; i < this.connectedProxies.length; i++) { + connections = connections.concat(this.connectedProxies[i].connections()); + } + + return connections; +} + +function emitTopologyDescriptionChanged(self) { + if(self.listeners('topologyDescriptionChanged').length > 0) { + var topology = 'Unknown'; + var setName = self.setName; + + if(self.connectedProxies.length > 0) { + topology = 'Sharded'; + } + + // Generate description + var description = { + topologyType: topology, + servers: [] + } + + // All proxies + var proxies = self.disconnectedProxies + .concat(self.connectingProxies); + + // Add all the disconnected proxies + description.servers = description.servers.concat(proxies.map(function(x) { + var description = x.getDescription(); + description.type = 'Unknown'; + return description; + })); + + // Add all the connected proxies + description.servers = description.servers.concat(self.connectedProxies.map(function(x) { + var description = x.getDescription(); + description.type = 'Mongos'; + return description; + })); + + // Get the diff + var diffResult = diff(self.topologyDescription, description); + + // Create the result + var result = { + topologyId: self.id, + previousDescription: self.topologyDescription, + newDescription: description, + diff: diffResult + }; + + // Emit the topologyDescription change + if(diffResult.servers.length > 0) { + self.emit('topologyDescriptionChanged', result); + } + + // Set the new description + self.topologyDescription = description; + } +} + +/** + * A mongos connect event, used to verify that the connection is up and running + * + * @event Mongos#connect + * @type {Mongos} + */ + +/** + * A mongos reconnect event, used to verify that the mongos topology has reconnected + * + * @event Mongos#reconnect + * @type {Mongos} + */ + +/** + * A mongos fullsetup event, used to signal that all topology members have been contacted. + * + * @event Mongos#fullsetup + * @type {Mongos} + */ + +/** + * A mongos all event, used to signal that all topology members have been contacted. + * + * @event Mongos#all + * @type {Mongos} + */ + +/** + * A server member left the mongos list + * + * @event Mongos#left + * @type {Mongos} + * @param {string} type The type of member that left (mongos) + * @param {Server} server The server object that left + */ + +/** + * A server member joined the mongos list + * + * @event Mongos#joined + * @type {Mongos} + * @param {string} type The type of member that left (mongos) + * @param {Server} server The server object that joined + */ + +/** + * A server opening SDAM monitoring event + * + * @event Mongos#serverOpening + * @type {object} + */ + +/** + * A server closed SDAM monitoring event + * + * @event Mongos#serverClosed + * @type {object} + */ + +/** + * A server description SDAM change monitoring event + * + * @event Mongos#serverDescriptionChanged + * @type {object} + */ + +/** + * A topology open SDAM event + * + * @event Mongos#topologyOpening + * @type {object} + */ + +/** + * A topology closed SDAM event + * + * @event Mongos#topologyClosed + * @type {object} + */ + +/** + * A topology structure SDAM change event + * + * @event Mongos#topologyDescriptionChanged + * @type {object} + */ + +/** + * A topology serverHeartbeatStarted SDAM event + * + * @event Mongos#serverHeartbeatStarted + * @type {object} + */ + +/** + * A topology serverHeartbeatFailed SDAM event + * + * @event Mongos#serverHeartbeatFailed + * @type {object} + */ + +/** + * A topology serverHeartbeatSucceeded SDAM change event + * + * @event Mongos#serverHeartbeatSucceeded + * @type {object} + */ + +module.exports = Mongos; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/read_preference.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/read_preference.js new file mode 100644 index 0000000..1f10dd9 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/read_preference.js @@ -0,0 +1,118 @@ +"use strict"; + +var needSlaveOk = ['primaryPreferred', 'secondary', 'secondaryPreferred', 'nearest']; + +/** + * @fileOverview The **ReadPreference** class is a class that represents a MongoDB ReadPreference and is + * used to construct connections. + * + * @example + * var ReplSet = require('mongodb-core').ReplSet + * , ReadPreference = require('mongodb-core').ReadPreference + * , assert = require('assert'); + * + * var server = new ReplSet([{host: 'localhost', port: 30000}], {setName: 'rs'}); + * // Wait for the connection event + * server.on('connect', function(server) { + * var cursor = server.cursor('db.test' + * , {find: 'db.test', query: {}} + * , {readPreference: new ReadPreference('secondary')}); + * cursor.next(function(err, doc) { + * server.destroy(); + * }); + * }); + * + * // Start connecting + * server.connect(); + */ + +/** + * Creates a new Pool instance + * @class + * @param {string} preference A string describing the preference (primary|primaryPreferred|secondary|secondaryPreferred|nearest) + * @param {array} tags The tags object + * @param {object} [options] Additional read preference options + * @param {number} [options.maxStalenessSeconds] Max Secondary Read Stalleness in Seconds, Minimum value is 90 seconds. + * @property {string} preference The preference string (primary|primaryPreferred|secondary|secondaryPreferred|nearest) + * @property {array} tags The tags object + * @property {object} options Additional read preference options + * @property {number} maxStalenessSeconds MaxStalenessSeconds value for the read preference + * @return {ReadPreference} + */ +var ReadPreference = function(preference, tags, options) { + this.preference = preference; + this.tags = tags; + this.options = options; + + // Add the maxStalenessSeconds value to the read Preference + if(this.options && this.options.maxStalenessSeconds != null) { + this.options = options; + this.maxStalenessSeconds = this.options.maxStalenessSeconds >= 0 + ? this.options.maxStalenessSeconds : null; + } else if(tags && typeof tags == 'object') { + this.options = tags, tags = null; + } +} + +/** + * This needs slaveOk bit set + * @method + * @return {boolean} + */ +ReadPreference.prototype.slaveOk = function() { + return needSlaveOk.indexOf(this.preference) != -1; +} + +/** + * Are the two read preference equal + * @method + * @return {boolean} + */ +ReadPreference.prototype.equals = function(readPreference) { + return readPreference.preference == this.preference; +} + +/** + * Return JSON representation + * @method + * @return {Object} + */ +ReadPreference.prototype.toJSON = function() { + var readPreference = {mode: this.preference}; + if(Array.isArray(this.tags)) readPreference.tags = this.tags; + if(this.maxStalenessSeconds) readPreference.maxStalenessSeconds = this.maxStalenessSeconds; + return readPreference; +} + +/** + * Primary read preference + * @method + * @return {ReadPreference} + */ +ReadPreference.primary = new ReadPreference('primary'); +/** + * Primary Preferred read preference + * @method + * @return {ReadPreference} + */ +ReadPreference.primaryPreferred = new ReadPreference('primaryPreferred'); +/** + * Secondary read preference + * @method + * @return {ReadPreference} + */ +ReadPreference.secondary = new ReadPreference('secondary'); +/** + * Secondary Preferred read preference + * @method + * @return {ReadPreference} + */ +ReadPreference.secondaryPreferred = new ReadPreference('secondaryPreferred'); +/** + * Nearest read preference + * @method + * @return {ReadPreference} + */ +ReadPreference.nearest = new ReadPreference('nearest'); + +module.exports = ReadPreference; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js new file mode 100644 index 0000000..e6c5ea1 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset.js @@ -0,0 +1,1473 @@ +"use strict" + +var inherits = require('util').inherits, + f = require('util').format, + EventEmitter = require('events').EventEmitter, + ReadPreference = require('./read_preference'), + BasicCursor = require('../cursor'), + retrieveBSON = require('../connection/utils').retrieveBSON, + Logger = require('../connection/logger'), + MongoError = require('../error'), + Server = require('./server'), + ReplSetState = require('./replset_state'), + assign = require('../utils').assign, + clone = require('./shared').clone, + Timeout = require('./shared').Timeout, + Interval = require('./shared').Interval, + createClientInfo = require('./shared').createClientInfo; + +var MongoCR = require('../auth/mongocr') + , X509 = require('../auth/x509') + , Plain = require('../auth/plain') + , GSSAPI = require('../auth/gssapi') + , SSPI = require('../auth/sspi') + , ScramSHA1 = require('../auth/scram'); + +var BSON = retrieveBSON(); + +// +// States +var DISCONNECTED = 'disconnected'; +var CONNECTING = 'connecting'; +var CONNECTED = 'connected'; +var UNREFERENCED = 'unreferenced'; +var DESTROYED = 'destroyed'; + +function stateTransition(self, newState) { + var legalTransitions = { + 'disconnected': [CONNECTING, DESTROYED, DISCONNECTED], + 'connecting': [CONNECTING, DESTROYED, CONNECTED, DISCONNECTED], + 'connected': [CONNECTED, DISCONNECTED, DESTROYED, UNREFERENCED], + 'unreferenced': [UNREFERENCED, DESTROYED], + 'destroyed': [DESTROYED] + } + + // Get current state + var legalStates = legalTransitions[self.state]; + if(legalStates && legalStates.indexOf(newState) != -1) { + self.state = newState; + } else { + self.s.logger.error(f('Pool with id [%s] failed attempted illegal state transition from [%s] to [%s] only following state allowed [%s]' + , self.id, self.state, newState, legalStates)); + } +} + +// +// ReplSet instance id +var id = 1; +var handlers = ['connect', 'close', 'error', 'timeout', 'parseError']; + +/** + * Creates a new Replset instance + * @class + * @param {array} seedlist A list of seeds for the replicaset + * @param {boolean} options.setName The Replicaset set name + * @param {boolean} [options.secondaryOnlyConnectionAllowed=false] Allow connection to a secondary only replicaset + * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry + * @param {boolean} [options.emitError=false] Server will emit errors events + * @param {Cursor} [options.cursorFactory=Cursor] The cursor factory class used for all query cursors + * @param {number} [options.size=5] Server connection pool size + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=0] Initial delay before TCP keep alive enabled + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.connectionTimeout=10000] TCP Connection timeout setting + * @param {number} [options.socketTimeout=0] TCP Socket timeout setting + * @param {boolean} [options.singleBufferSerializtion=true] Serialize into single buffer, trade of peak memory for serialization speed + * @param {boolean} [options.ssl=false] Use SSL for connection + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {Buffer} [options.ca] SSL Certificate store binary buffer + * @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer + * @param {Buffer} [options.cert] SSL Certificate binary buffer + * @param {Buffer} [options.key] SSL Key file binary buffer + * @param {string} [options.passphrase] SSL Certificate pass phrase + * @param {string} [options.servername=null] String containing the server name requested via TLS SNI. + * @param {boolean} [options.rejectUnauthorized=true] Reject unauthorized server certificates + * @param {boolean} [options.promoteLongs=true] Convert Long values from the db into Numbers if they fit into 53 bits + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {number} [options.pingInterval=5000] Ping interval to check the response time to the different servers + * @param {number} [options.localThresholdMS=15] Cutoff latency point in MS for Replicaset member selection + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @return {ReplSet} A cursor instance + * @fires ReplSet#connect + * @fires ReplSet#ha + * @fires ReplSet#joined + * @fires ReplSet#left + * @fires ReplSet#failed + * @fires ReplSet#fullsetup + * @fires ReplSet#all + * @fires ReplSet#error + * @fires ReplSet#serverHeartbeatStarted + * @fires ReplSet#serverHeartbeatSucceeded + * @fires ReplSet#serverHeartbeatFailed + * @fires ReplSet#topologyOpening + * @fires ReplSet#topologyClosed + * @fires ReplSet#topologyDescriptionChanged + * @property {string} type the topology type. + * @property {string} parserType the parser type used (c++ or js). + */ +var ReplSet = function(seedlist, options) { + var self = this; + options = options || {}; + + // Validate seedlist + if(!Array.isArray(seedlist)) throw new MongoError("seedlist must be an array"); + // Validate list + if(seedlist.length == 0) throw new MongoError("seedlist must contain at least one entry"); + // Validate entries + seedlist.forEach(function(e) { + if(typeof e.host != 'string' || typeof e.port != 'number') + throw new MongoError("seedlist entry must contain a host and port"); + }); + + // Add event listener + EventEmitter.call(this); + + // Get replSet Id + this.id = id++; + + // Get the localThresholdMS + var localThresholdMS = options.localThresholdMS || 15; + // Backward compatibility + if(options.acceptableLatency) localThresholdMS = options.acceptableLatency; + + // Create a logger + var logger = Logger('ReplSet', options); + + // Internal state + this.s = { + options: assign({}, options), + // BSON instance + bson: options.bson || new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, + BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, + BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]), + // Factory overrides + Cursor: options.cursorFactory || BasicCursor, + // Logger instance + logger: logger, + // Seedlist + seedlist: seedlist, + // Replicaset state + replicaSetState: new ReplSetState({ + id: this.id, setName: options.setName, + acceptableLatency: localThresholdMS, + heartbeatFrequencyMS: options.haInterval ? options.haInterval : 10000, + logger: logger + }), + // Current servers we are connecting to + connectingServers: [], + // Ha interval + haInterval: options.haInterval ? options.haInterval : 10000, + // Minimum heartbeat frequency used if we detect a server close + minHeartbeatFrequencyMS: 500, + // Disconnect handler + disconnectHandler: options.disconnectHandler, + // Server selection index + index: 0, + // Connect function options passed in + connectOptions: {}, + // Are we running in debug mode + debug: typeof options.debug == 'boolean' ? options.debug : false, + // Client info + clientInfo: createClientInfo(options), + // Authentication context + authenticationContexts: [], + } + + // Add handler for topology change + this.s.replicaSetState.on('topologyDescriptionChanged', function(r) { self.emit('topologyDescriptionChanged', r); }); + + // Log info warning if the socketTimeout < haInterval as it will cause + // a lot of recycled connections to happen. + if(this.s.logger.isWarn() + && this.s.options.socketTimeout != 0 + && this.s.options.socketTimeout < this.s.haInterval) { + this.s.logger.warn(f('warning socketTimeout %s is less than haInterval %s. This might cause unnecessary server reconnections due to socket timeouts' + , this.s.options.socketTimeout, this.s.haInterval)); + } + + // All the authProviders + this.authProviders = options.authProviders || { + 'mongocr': new MongoCR(this.s.bson), 'x509': new X509(this.s.bson) + , 'plain': new Plain(this.s.bson), 'gssapi': new GSSAPI(this.s.bson) + , 'sspi': new SSPI(this.s.bson), 'scram-sha-1': new ScramSHA1(this.s.bson) + } + + // Add forwarding of events from state handler + var types = ['joined', 'left']; + types.forEach(function(x) { + self.s.replicaSetState.on(x, function(t, s) { + self.emit(x, t, s); + }); + }); + + // Connect stat + this.initialConnectState = { + connect: false, fullsetup: false, all: false + } + + // Disconnected state + this.state = DISCONNECTED; + this.haTimeoutId = null; + // Are we authenticating + this.authenticating = false; + // Last ismaster + this.ismaster = null; + // Contains the intervalId + this.intervalIds = []; +} + +inherits(ReplSet, EventEmitter); + +Object.defineProperty(ReplSet.prototype, 'type', { + enumerable:true, get: function() { return 'replset'; } +}); + +Object.defineProperty(ReplSet.prototype, 'parserType', { + enumerable:true, get: function() { + return BSON.native ? "c++" : "js"; + } +}); + +function rexecuteOperations(self) { + // If we have a primary and a disconnect handler, execute + // buffered operations + if(self.s.replicaSetState.hasPrimaryAndSecondary() && self.s.disconnectHandler) { + self.s.disconnectHandler.execute(); + } else if(self.s.replicaSetState.hasPrimary() && self.s.disconnectHandler) { + self.s.disconnectHandler.execute({ executePrimary:true }); + } else if(self.s.replicaSetState.hasSecondary() && self.s.disconnectHandler) { + self.s.disconnectHandler.execute({ executeSecondary:true }); + } +} + +function connectNewServers(self, servers, callback) { + // Count lefts + var count = servers.length; + var error = null; + + // Handle events + var _handleEvent = function(self, event) { + return function(err) { + var _self = this; + count = count - 1; + + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return this.destroy({force:true}); + } + + if(event == 'connect' && !self.authenticating) { + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return _self.destroy({force:true}); + } + + // Do we have authentication contexts that need to be applied + applyAuthenticationContexts(self, _self, function() { + // Destroy the instance + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return _self.destroy({force:true}); + } + + // Update the state + var result = self.s.replicaSetState.update(_self); + // Update the state with the new server + if(result) { + // Primary lastIsMaster store it + if(_self.lastIsMaster() && _self.lastIsMaster().ismaster) { + self.ismaster = _self.lastIsMaster(); + } + + // Remove the handlers + for(var i = 0; i < handlers.length; i++) { + _self.removeAllListeners(handlers[i]); + } + + // Add stable state handlers + _self.on('error', handleEvent(self, 'error')); + _self.on('close', handleEvent(self, 'close')); + _self.on('timeout', handleEvent(self, 'timeout')); + _self.on('parseError', handleEvent(self, 'parseError')); + + // Enalbe the monitoring of the new server + monitorServer(_self.lastIsMaster().me, self, {}); + + // Rexecute any stalled operation + rexecuteOperations(self); + } else { + _self.destroy({force:true}); + } + }); + } else if(event == 'connect' && self.authenticating) { + this.destroy({force:true}); + } else if(event == 'error') { + error = err; + } + + // Rexecute any stalled operation + rexecuteOperations(self); + + // Are we done finish up callback + if(count == 0) { callback(error); } + } + } + + // No new servers + if(count == 0) return callback(); + + // Execute method + function execute(_server, i) { + setTimeout(function() { + // Destroyed + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return; + } + + // Create a new server instance + var server = new Server(assign({}, self.s.options, { + host: _server.split(':')[0], + port: parseInt(_server.split(':')[1], 10) + }, { + authProviders: self.authProviders, reconnect:false, monitoring: false, inTopology: true + }, { + clientInfo: clone(self.s.clientInfo) + })); + + // Add temp handlers + server.once('connect', _handleEvent(self, 'connect')); + server.once('close', _handleEvent(self, 'close')); + server.once('timeout', _handleEvent(self, 'timeout')); + server.once('error', _handleEvent(self, 'error')); + server.once('parseError', _handleEvent(self, 'parseError')); + + // SDAM Monitoring events + server.on('serverOpening', function(e) { self.emit('serverOpening', e); }); + server.on('serverDescriptionChanged', function(e) { self.emit('serverDescriptionChanged', e); }); + server.on('serverClosed', function(e) { self.emit('serverClosed', e); }); + server.connect(self.s.connectOptions); + }, i); + } + + // Create new instances + for(var i = 0; i < servers.length; i++) { + execute(servers[i], i); + } +} + +// Ping the server +var pingServer = function(self, server, cb) { + // Measure running time + var start = new Date().getTime(); + + // Emit the server heartbeat start + emitSDAMEvent(self, 'serverHeartbeatStarted', { connectionId: server.name }); + + // Execute ismaster + // Set the socketTimeout for a monitoring message to a low number + // Ensuring ismaster calls are timed out quickly + server.command('admin.$cmd', { + ismaster:true + }, { + monitoring: true, + socketTimeout: self.s.options.connectionTimeout || 2000, + }, function(err, r) { + if(self.state == DESTROYED || self.state == UNREFERENCED) { + server.destroy({force:true}); + return cb(err, r); + } + + // Calculate latency + var latencyMS = new Date().getTime() - start; + // Set the last updatedTime + var hrTime = process.hrtime(); + // Calculate the last update time + server.lastUpdateTime = hrTime[0] * 1000 + Math.round(hrTime[1]/1000); + + // We had an error, remove it from the state + if(err) { + // Emit the server heartbeat failure + emitSDAMEvent(self, 'serverHeartbeatFailed', { durationMS: latencyMS, failure: err, connectionId: server.name }); + + // Remove server from the state + self.s.replicaSetState.remove(server); + } else { + // Update the server ismaster + server.ismaster = r.result; + + // Check if we have a lastWriteDate convert it to MS + // and store on the server instance for later use + if(server.ismaster.lastWrite && server.ismaster.lastWrite.lastWriteDate) { + server.lastWriteDate = server.ismaster.lastWrite.lastWriteDate.getTime(); + } + + // Do we have a brand new server + if(server.lastIsMasterMS == -1) { + server.lastIsMasterMS = latencyMS; + } else if(server.lastIsMasterMS) { + // After the first measurement, average RTT MUST be computed using an + // exponentially-weighted moving average formula, with a weighting factor (alpha) of 0.2. + // If the prior average is denoted old_rtt, then the new average (new_rtt) is + // computed from a new RTT measurement (x) using the following formula: + // alpha = 0.2 + // new_rtt = alpha * x + (1 - alpha) * old_rtt + server.lastIsMasterMS = 0.2 * latencyMS + (1 - 0.2) * server.lastIsMasterMS; + } + + if(self.s.replicaSetState.update(server)) { + // Primary lastIsMaster store it + if(server.lastIsMaster() && server.lastIsMaster().ismaster) { + self.ismaster = server.lastIsMaster(); + } + } + + // Server heart beat event + emitSDAMEvent(self, 'serverHeartbeatSucceeded', { durationMS: latencyMS, reply: r.result, connectionId: server.name }); + } + + // Calculate the staleness for this server + self.s.replicaSetState.updateServerMaxStaleness(server, self.s.haInterval); + + // Callback + cb(err, r); + }); +} + +// Each server is monitored in parallel in their own timeout loop +var monitorServer = function(host, self, options) { + // If this is not the initial scan + // Is this server already being monitoried, then skip monitoring + if(!options.haInterval) { + for(var i = 0; i < self.intervalIds.length; i++) { + if(self.intervalIds[i].__host === host) { + return; + } + } + } + + // Get the haInterval + var _process = options.haInterval ? Timeout : Interval; + var _haInterval = options.haInterval ? options.haInterval : self.s.haInterval; + + // Create the interval + var intervalId = new _process(function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) { + // clearInterval(intervalId); + intervalId.stop(); + return; + } + + // Do we already have server connection available for this host + var _server = self.s.replicaSetState.get(host); + + // Check if we have a known server connection and reuse + if(_server) { + // Ping the server + return pingServer(self, _server, function(err) { + if(self.state == DESTROYED || self.state == UNREFERENCED) { + intervalId.stop(); + return; + } + + // Filter out all called intervaliIds + self.intervalIds = self.intervalIds.filter(function(intervalId) { + return intervalId.isRunning(); + } ); + + // Initial sweep + if(_process === Timeout) { + if(self.state == CONNECTING && ( + ( + self.s.replicaSetState.hasSecondary() + && self.s.options.secondaryOnlyConnectionAllowed + ) + || self.s.replicaSetState.hasPrimary() + )) { + self.state = CONNECTED; + + // Emit connected sign + process.nextTick(function() { + self.emit('connect', self); + }); + + // Start topology interval check + topologyMonitor(self, {}); + } + } else { + if(self.state == DISCONNECTED && ( + ( + self.s.replicaSetState.hasSecondary() + && self.s.options.secondaryOnlyConnectionAllowed + ) + || self.s.replicaSetState.hasPrimary() + )) { + self.state = CONNECTED; + + // Rexecute any stalled operation + rexecuteOperations(self); + + // Emit connected sign + process.nextTick(function() { + self.emit('reconnect', self); + }); + } + } + + if(self.initialConnectState.connect + && !self.initialConnectState.fullsetup + && self.s.replicaSetState.hasPrimaryAndSecondary()) { + // Set initial connect state + self.initialConnectState.fullsetup = true; + self.initialConnectState.all = true; + + process.nextTick(function() { + self.emit('fullsetup', self); + self.emit('all', self); + }); + } + }); + } + }, _haInterval); + + // Start the interval + intervalId.start(); + // Add the intervalId host name + intervalId.__host = host; + // Add the intervalId to our list of intervalIds + self.intervalIds.push(intervalId); +} + +function topologyMonitor(self, options) { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + options = options || {}; + + // Get the servers + var servers = Object.keys(self.s.replicaSetState.set); + + // Get the haInterval + var _process = options.haInterval ? Timeout : Interval; + var _haInterval = options.haInterval ? options.haInterval : self.s.haInterval; + + if(_process === Timeout) { + return connectNewServers(self, self.s.replicaSetState.unknownServers, function(err) { + // Don't emit errors if the connection was already + if(self.state === DESTROYED || self.state === UNREFERENCED) { + return; + } + + if(!self.s.replicaSetState.hasPrimary() && !self.s.options.secondaryOnlyConnectionAllowed) { + if(err) return self.emit('error', err); + self.emit('error', new MongoError('no primary found in replicaset or invalid replica set name')); + return self.destroy({force:true}); + } else if(!self.s.replicaSetState.hasSecondary() && self.s.options.secondaryOnlyConnectionAllowed) { + if(err) return self.emit('error', err); + self.emit('error', new MongoError('no secondary found in replicaset or invalid replica set name')); + return self.destroy({force:true}); + } + + for(var i = 0; i < servers.length; i++) { + monitorServer(servers[i], self, options); + } + }); + } else { + for(var i = 0; i < servers.length; i++) { + monitorServer(servers[i], self, options); + } + } + + // Run the reconnect process + function executeReconnect(self) { + return function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return; + } + + connectNewServers(self, self.s.replicaSetState.unknownServers, function() { + var monitoringFrequencey = self.s.replicaSetState.hasPrimary() + ? _haInterval : self.s.minHeartbeatFrequencyMS; + + // Create a timeout + self.intervalIds.push(new Timeout(executeReconnect(self), monitoringFrequencey).start()); + }); + } + } + + // Decide what kind of interval to use + var intervalTime = !self.s.replicaSetState.hasPrimary() + ? self.s.minHeartbeatFrequencyMS + : _haInterval + + self.intervalIds.push(new Timeout(executeReconnect(self), intervalTime).start()); +} + +function addServerToList(list, server) { + for(var i = 0; i < list.length; i++) { + if(list[i].name.toLowerCase() === server.name.toLowerCase()) return true; + } + + list.push(server); +} + +function handleEvent(self, event) { + return function() { + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + // Debug log + if(self.s.logger.isDebug()) { + self.s.logger.debug(f('handleEvent %s from server %s in replset with id %s', event, this.name, self.id)); + } + + // Remove from the replicaset state + self.s.replicaSetState.remove(this); + + // Are we in a destroyed state return + if(self.state == DESTROYED || self.state == UNREFERENCED) return; + + // If no primary and secondary available + if(!self.s.replicaSetState.hasPrimary() + && !self.s.replicaSetState.hasSecondary() + && self.s.options.secondaryOnlyConnectionAllowed) { + stateTransition(self, DISCONNECTED); + } else if(!self.s.replicaSetState.hasPrimary()) { + stateTransition(self, DISCONNECTED); + } + + addServerToList(self.s.connectingServers, this); + } +} + +function applyAuthenticationContexts(self, server, callback) { + if(self.s.authenticationContexts.length == 0) { + return callback(); + } + + // Do not apply any auth contexts if it's an arbiter + if(server.lastIsMaster() && server.lastIsMaster().arbiterOnly) { + return callback(); + } + + // Copy contexts to ensure no modificiation in the middle of + // auth process. + var authContexts = self.s.authenticationContexts.slice(0); + + // Apply one of the contexts + function applyAuth(authContexts, server, callback) { + if(authContexts.length == 0) return callback(); + // Get the first auth context + var authContext = authContexts.shift(); + // Copy the params + var customAuthContext = authContext.slice(0); + // Push our callback handler + customAuthContext.push(function(err) { + applyAuth(authContexts, server, callback); + }); + + // Attempt authentication + server.auth.apply(server, customAuthContext) + } + + // Apply all auth contexts + applyAuth(authContexts, server, callback); +} + +function shouldTriggerConnect(self) { + var secondaryReadPreferenceString = ReadPreference.secondary.preference || ReadPreference.secondary.mode; + var currentReadPreferenceString = self.s.connectOptions.readPreference && ( + self.s.connectOptions.readPreference.preference || + self.s.connectOptions.readPreference.mode + ); + + var isConnecting = self.state === CONNECTING; + var hasPrimary = self.s.replicaSetState.hasPrimary(); + var hasSecondary = self.s.replicaSetState.hasSecondary(); + var secondaryOnlyConnectionAllowed = self.s.options.secondaryOnlyConnectionAllowed; + var readPreferenceSecondary = secondaryReadPreferenceString === currentReadPreferenceString; + + return ( + (isConnecting && + ((readPreferenceSecondary && hasSecondary) || (!readPreferenceSecondary && hasPrimary))) || + (hasSecondary && secondaryOnlyConnectionAllowed) + ); +} + +function handleInitialConnectEvent(self, event) { + return function() { + var _this = this; + // Debug log + if(self.s.logger.isDebug()) { + self.s.logger.debug(f('handleInitialConnectEvent %s from server %s in replset with id %s', event, this.name, self.id)); + } + + // Destroy the instance + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return this.destroy({force:true}); + } + + // Check the type of server + if(event == 'connect') { + // Do we have authentication contexts that need to be applied + applyAuthenticationContexts(self, _this, function() { + // Destroy the instance + if(self.state == DESTROYED || self.state == UNREFERENCED) { + return _this.destroy({force:true}); + } + + // Update the state + var result = self.s.replicaSetState.update(_this); + if(result == true) { + // Primary lastIsMaster store it + if(_this.lastIsMaster() && _this.lastIsMaster().ismaster) { + self.ismaster = _this.lastIsMaster(); + } + + // Debug log + if(self.s.logger.isDebug()) { + self.s.logger.debug(f('handleInitialConnectEvent %s from server %s in replset with id %s has state [%s]', event, _this.name, self.id, JSON.stringify(self.s.replicaSetState.set))); + } + + // Remove the handlers + for(var i = 0; i < handlers.length; i++) { + _this.removeAllListeners(handlers[i]); + } + + // Add stable state handlers + _this.on('error', handleEvent(self, 'error')); + _this.on('close', handleEvent(self, 'close')); + _this.on('timeout', handleEvent(self, 'timeout')); + _this.on('parseError', handleEvent(self, 'parseError')); + + // Do we have a primary or primaryAndSecondary + if(shouldTriggerConnect(self)) { + // We are connected + self.state = CONNECTED; + + // Set initial connect state + self.initialConnectState.connect = true; + // Emit connect event + process.nextTick(function() { + self.emit('connect', self); + }); + + topologyMonitor(self, {}); + } + } else if(result instanceof MongoError) { + _this.destroy({force:true}); + self.destroy({force:true}); + return self.emit('error', result); + } else { + _this.destroy({force:true}); + } + }); + } else { + // Emit failure to connect + self.emit('failed', this); + + addServerToList(self.s.connectingServers, this); + // Remove from the state + self.s.replicaSetState.remove(this); + } + + if(self.initialConnectState.connect + && !self.initialConnectState.fullsetup + && self.s.replicaSetState.hasPrimaryAndSecondary()) { + // Set initial connect state + self.initialConnectState.fullsetup = true; + self.initialConnectState.all = true; + + process.nextTick(function() { + self.emit('fullsetup', self); + self.emit('all', self); + }); + } + + // Remove from the list from connectingServers + for(var i = 0; i < self.s.connectingServers.length; i++) { + if(self.s.connectingServers[i].equals(this)) { + self.s.connectingServers.splice(i, 1); + } + } + + // Trigger topologyMonitor + if(self.s.connectingServers.length == 0 && self.state == CONNECTING) { + topologyMonitor(self, {haInterval: 1}); + } + }; +} + +function connectServers(self, servers) { + // Update connectingServers + self.s.connectingServers = self.s.connectingServers.concat(servers); + + // Index used to interleaf the server connects, avoiding + // runtime issues on io constrained vm's + var timeoutInterval = 0; + + function connect(server, timeoutInterval) { + setTimeout(function() { + // Add the server to the state + if(self.s.replicaSetState.update(server)) { + // Primary lastIsMaster store it + if(server.lastIsMaster() && server.lastIsMaster().ismaster) { + self.ismaster = server.lastIsMaster(); + } + } + + // Add event handlers + server.once('close', handleInitialConnectEvent(self, 'close')); + server.once('timeout', handleInitialConnectEvent(self, 'timeout')); + server.once('parseError', handleInitialConnectEvent(self, 'parseError')); + server.once('error', handleInitialConnectEvent(self, 'error')); + server.once('connect', handleInitialConnectEvent(self, 'connect')); + // SDAM Monitoring events + server.on('serverOpening', function(e) { self.emit('serverOpening', e); }); + server.on('serverDescriptionChanged', function(e) { self.emit('serverDescriptionChanged', e); }); + server.on('serverClosed', function(e) { self.emit('serverClosed', e); }); + // Start connection + server.connect(self.s.connectOptions); + }, timeoutInterval); + } + + // Start all the servers + while(servers.length > 0) { + connect(servers.shift(), timeoutInterval++); + } +} + +/** + * Emit event if it exists + * @method + */ +function emitSDAMEvent(self, event, description) { + if(self.listeners(event).length > 0) { + self.emit(event, description); + } +} + +/** + * Initiate server connect + * @method + * @param {array} [options.auth=null] Array of auth options to apply on connect + */ +ReplSet.prototype.connect = function(options) { + var self = this; + // Add any connect level options to the internal state + this.s.connectOptions = options || {}; + // Set connecting state + stateTransition(this, CONNECTING); + // Create server instances + var servers = this.s.seedlist.map(function(x) { + return new Server(assign({}, self.s.options, x, { + authProviders: self.authProviders, reconnect:false, monitoring:false, inTopology: true + }, { + clientInfo: clone(self.s.clientInfo) + })); + }); + + // Error out as high availbility interval must be < than socketTimeout + if(this.s.options.socketTimeout > 0 && this.s.options.socketTimeout <= this.s.options.haInterval) { + return self.emit('error', new MongoError(f("haInterval [%s] MS must be set to less than socketTimeout [%s] MS" + , this.s.options.haInterval, this.s.options.socketTimeout))); + } + + // Emit the topology opening event + emitSDAMEvent(this, 'topologyOpening', { topologyId: this.id }); + // Start all server connections + connectServers(self, servers); +} + +/** + * Destroy the server connection + * @param {boolean} [options.force=false] Force destroy the pool + * @method + */ +ReplSet.prototype.destroy = function(options) { + options = options || {}; + // Transition state + stateTransition(this, DESTROYED); + // Clear out any monitoring process + if(this.haTimeoutId) clearTimeout(this.haTimeoutId); + // Destroy the replicaset + this.s.replicaSetState.destroy(options); + // Clear out authentication contexts + this.s.authenticationContexts = []; + + // Destroy all connecting servers + this.s.connectingServers.forEach(function(x) { + x.destroy(options); + }); + + // Clear out all monitoring + for(var i = 0; i < this.intervalIds.length; i++) { + this.intervalIds[i].stop(); + this.intervalIds[i].stop(); + } + + // Reset list of intervalIds + this.intervalIds = []; + + // Emit toplogy closing event + emitSDAMEvent(this, 'topologyClosed', { topologyId: this.id }); +} + +/** + * Unref all connections belong to this server + * @method + */ +ReplSet.prototype.unref = function() { + // Transition state + stateTransition(this, UNREFERENCED); + + this.s.replicaSetState.allServers().forEach(function(x) { + x.unref(); + }); + + clearTimeout(this.haTimeoutId); +} + +/** + * Returns the last known ismaster document for this server + * @method + * @return {object} + */ +ReplSet.prototype.lastIsMaster = function() { + // If secondaryOnlyConnectionAllowed and no primary but secondary + // return the secondaries ismaster result. + if (this.s.options.secondaryOnlyConnectionAllowed + && !this.s.replicaSetState.hasPrimary() + && this.s.replicaSetState.hasSecondary()) { + return this.s.replicaSetState.secondaries[0].lastIsMaster(); + } + + return this.s.replicaSetState.primary + ? this.s.replicaSetState.primary.lastIsMaster() : this.ismaster; +} + +/** + * All raw connections + * @method + * @return {Connection[]} + */ +ReplSet.prototype.connections = function() { + var servers = this.s.replicaSetState.allServers(); + var connections = []; + for(var i = 0; i < servers.length; i++) { + connections = connections.concat(servers[i].connections()); + } + + return connections; +} + +/** + * Figure out if the server is connected + * @method + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @return {boolean} + */ +ReplSet.prototype.isConnected = function(options) { + options = options || {}; + + // If we are authenticating signal not connected + // To avoid interleaving of operations + if(this.authenticating) return false; + + // If we specified a read preference check if we are connected to something + // than can satisfy this + if(options.readPreference + && options.readPreference.equals(ReadPreference.secondary)) { + return this.s.replicaSetState.hasSecondary(); + } + + if(options.readPreference + && options.readPreference.equals(ReadPreference.primary)) { + return this.s.replicaSetState.hasPrimary(); + } + + if(options.readPreference + && options.readPreference.equals(ReadPreference.primaryPreferred)) { + return this.s.replicaSetState.hasSecondary() || this.s.replicaSetState.hasPrimary(); + } + + if(options.readPreference + && options.readPreference.equals(ReadPreference.secondaryPreferred)) { + return this.s.replicaSetState.hasSecondary() || this.s.replicaSetState.hasPrimary(); + } + + if(this.s.options.secondaryOnlyConnectionAllowed + && this.s.replicaSetState.hasSecondary()) { + return true; + } + + return this.s.replicaSetState.hasPrimary(); +} + +/** + * Figure out if the replicaset instance was destroyed by calling destroy + * @method + * @return {boolean} + */ +ReplSet.prototype.isDestroyed = function() { + return this.state == DESTROYED; +} + +/** + * Get server + * @method + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @return {Server} + */ +ReplSet.prototype.getServer = function(options) { + // Ensure we have no options + options = options || {}; + // Pick the right server baspickServerd on readPreference + var server = this.s.replicaSetState.pickServer(options.readPreference); + if(this.s.debug) this.emit('pickedServer', options.readPreference, server); + return server; +} + +/** + * Get a direct connection + * @method + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @return {Connection} + */ +ReplSet.prototype.getConnection = function(options) { + var server = this.getServer(options); + if(server) return server.getConnection(); +} + +/** + * Get all connected servers + * @method + * @return {Server[]} + */ +ReplSet.prototype.getServers = function() { + return this.s.replicaSetState.allServers(); +} + +// +// Execute write operation +var executeWriteOperation = function(self, op, ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + // Ensure we have no options + options = options || {}; + + // No server returned we had an error + if(self.s.replicaSetState.primary == null) { + return callback(new MongoError("no primary server found")); + } + + // Execute the command + self.s.replicaSetState.primary[op](ns, ops, options, callback); +} + +/** + * Insert one or more documents + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of documents to insert + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +ReplSet.prototype.insert = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.s.replicaSetState.hasPrimary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('insert', ns, ops, options, callback); + } + + // Execute write operation + executeWriteOperation(this, 'insert', ns, ops, options, callback); +} + +/** + * Perform one or more update operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of updates + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +ReplSet.prototype.update = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.s.replicaSetState.hasPrimary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('update', ns, ops, options, callback); + } + + // Execute write operation + executeWriteOperation(this, 'update', ns, ops, options, callback); +} + +/** + * Perform one or more remove operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of removes + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +ReplSet.prototype.remove = function(ns, ops, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + + // Not connected but we have a disconnecthandler + if(!this.s.replicaSetState.hasPrimary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('remove', ns, ops, options, callback); + } + + // Execute write operation + executeWriteOperation(this, 'remove', ns, ops, options, callback); +} + +/** + * Execute a command + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {object} cmd The command hash + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Connection} [options.connection] Specify connection object to execute command against + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +ReplSet.prototype.command = function(ns, cmd, options, callback) { + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + if(this.state == DESTROYED) return callback(new MongoError(f('topology was destroyed'))); + var self = this; + + // Establish readPreference + var readPreference = options.readPreference ? options.readPreference : ReadPreference.primary; + + // If the readPreference is primary and we have no primary, store it + if(readPreference.preference == 'primary' && !this.s.replicaSetState.hasPrimary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('command', ns, cmd, options, callback); + } else if(readPreference.preference == 'secondary' && !this.s.replicaSetState.hasSecondary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('command', ns, cmd, options, callback); + } else if(readPreference.preference != 'primary' && !this.s.replicaSetState.hasSecondary() && !this.s.replicaSetState.hasPrimary() && this.s.disconnectHandler != null) { + return this.s.disconnectHandler.add('command', ns, cmd, options, callback); + } + + // Pick a server + var server = this.s.replicaSetState.pickServer(readPreference); + // We received an error, return it + if(!(server instanceof Server)) return callback(server); + // Emit debug event + if(self.s.debug) self.emit('pickedServer', ReadPreference.primary, server); + + // No server returned we had an error + if(server == null) { + return callback(new MongoError(f("no server found that matches the provided readPreference %s", readPreference))); + } + + // Execute the command + server.command(ns, cmd, options, callback); +} + +/** + * Authenticate using a specified mechanism + * @method + * @param {string} mechanism The Auth mechanism we are invoking + * @param {string} db The db we are invoking the mechanism against + * @param {...object} param Parameters for the specific mechanism + * @param {authResultCallback} callback A callback function + */ +ReplSet.prototype.auth = function(mechanism, db) { + var allArgs = Array.prototype.slice.call(arguments, 0).slice(0); + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + var callback = args.pop(); + var currentContextIndex = 0; + + // If we don't have the mechanism fail + if(this.authProviders[mechanism] == null && mechanism != 'default') { + return callback(new MongoError(f("auth provider %s does not exist", mechanism))); + } + + // Are we already authenticating, throw + if(this.authenticating) { + return callback(new MongoError('authentication or logout allready in process')); + } + + // Topology is not connected, save the call in the provided store to be + // Executed at some point when the handler deems it's reconnected + if(self.s.disconnectHandler != null) { + if(!self.s.replicaSetState.hasPrimary() && !self.s.options.secondaryOnlyConnectionAllowed) { + return self.s.disconnectHandler.add('auth', db, allArgs, {}, callback); + } else if(!self.s.replicaSetState.hasSecondary() && self.s.options.secondaryOnlyConnectionAllowed) { + return self.s.disconnectHandler.add('auth', db, allArgs, {}, callback); + } + } + + // Set to authenticating + this.authenticating = true; + // All errors + var errors = []; + + // Get all the servers + var servers = this.s.replicaSetState.allServers(); + // No servers return + if(servers.length == 0) { + this.authenticating = false; + callback(null, true); + } + + // Authenticate + function auth(server) { + // Arguments without a callback + var argsWithoutCallback = [mechanism, db].concat(args.slice(0)); + // Create arguments + var finalArguments = argsWithoutCallback.concat([function(err) { + count = count - 1; + // Save all the errors + if(err) errors.push({name: server.name, err: err}); + // We are done + if(count == 0) { + // Auth is done + self.authenticating = false; + + // Return the auth error + if(errors.length) { + // Remove the entry from the stored authentication contexts + self.s.authenticationContexts.splice(currentContextIndex, 0); + // Return error + return callback(MongoError.create({ + message: 'authentication fail', errors: errors + }), false); + } + + // Successfully authenticated session + callback(null, self); + } + }]); + + if(!server.lastIsMaster().arbiterOnly) { + // Execute the auth only against non arbiter servers + server.auth.apply(server, finalArguments); + } else { + // If we are authenticating against an arbiter just ignore it + finalArguments.pop()(null); + } + } + + // Get total count + var count = servers.length; + + // Save current context index + currentContextIndex = this.s.authenticationContexts.length; + + // Store the auth context and return the last index + this.s.authenticationContexts.push([mechanism, db].concat(args.slice(0))); + + // Authenticate against all servers + while(servers.length > 0) { + auth(servers.shift()); + } +} + +/** + * Logout from a database + * @method + * @param {string} db The db we are logging out from + * @param {authResultCallback} callback A callback function + */ +ReplSet.prototype.logout = function(dbName, callback) { + var self = this; + // Are we authenticating or logging out, throw + if(this.authenticating) { + throw new MongoError('authentication or logout allready in process'); + } + + // Ensure no new members are processed while logging out + this.authenticating = true; + + // Remove from all auth providers (avoid any reaplication of the auth details) + var providers = Object.keys(this.authProviders); + for(var i = 0; i < providers.length; i++) { + this.authProviders[providers[i]].logout(dbName); + } + + // Clear out any contexts associated with the db + self.s.authenticationContexts = self.s.authenticationContexts.filter(function(context) { + return context[1] !== dbName; + }); + + // Now logout all the servers + var servers = this.s.replicaSetState.allServers(); + var count = servers.length; + if(count == 0) return callback(); + var errors = []; + + function logoutServer(_server, cb) { + _server.logout(dbName, function(err) { + if(err) errors.push({name: _server.name, err: err}); + cb(); + }); + } + + // Execute logout on all server instances + for(i = 0; i < servers.length; i++) { + logoutServer(servers[i], function() { + count = count - 1; + + if(count == 0) { + // Do not block new operations + self.authenticating = false; + // If we have one or more errors + if(errors.length) return callback(MongoError.create({ + message: f('logout failed against db %s', dbName), errors: errors + }), false); + + // No errors + callback(); + } + }) + } +} + +/** + * Perform one or more remove operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {{object}|{Long}} cmd Can be either a command returning a cursor or a cursorId + * @param {object} [options.batchSize=0] Batchsize for the operation + * @param {array} [options.documents=[]] Initial documents list for cursor + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +ReplSet.prototype.cursor = function(ns, cmd, cursorOptions) { + cursorOptions = cursorOptions || {}; + var FinalCursor = cursorOptions.cursorFactory || this.s.Cursor; + return new FinalCursor(this.s.bson, ns, cmd, cursorOptions, this, this.s.options); +} + +/** + * A replset connect event, used to verify that the connection is up and running + * + * @event ReplSet#connect + * @type {ReplSet} + */ + +/** + * A replset reconnect event, used to verify that the topology reconnected + * + * @event ReplSet#reconnect + * @type {ReplSet} + */ + +/** + * A replset fullsetup event, used to signal that all topology members have been contacted. + * + * @event ReplSet#fullsetup + * @type {ReplSet} + */ + +/** + * A replset all event, used to signal that all topology members have been contacted. + * + * @event ReplSet#all + * @type {ReplSet} + */ + +/** + * A replset failed event, used to signal that initial replset connection failed. + * + * @event ReplSet#failed + * @type {ReplSet} + */ + +/** + * A server member left the replicaset + * + * @event ReplSet#left + * @type {function} + * @param {string} type The type of member that left (primary|secondary|arbiter) + * @param {Server} server The server object that left + */ + +/** + * A server member joined the replicaset + * + * @event ReplSet#joined + * @type {function} + * @param {string} type The type of member that joined (primary|secondary|arbiter) + * @param {Server} server The server object that joined + */ + +/** + * A server opening SDAM monitoring event + * + * @event ReplSet#serverOpening + * @type {object} + */ + +/** + * A server closed SDAM monitoring event + * + * @event ReplSet#serverClosed + * @type {object} + */ + +/** + * A server description SDAM change monitoring event + * + * @event ReplSet#serverDescriptionChanged + * @type {object} + */ + +/** + * A topology open SDAM event + * + * @event ReplSet#topologyOpening + * @type {object} + */ + +/** + * A topology closed SDAM event + * + * @event ReplSet#topologyClosed + * @type {object} + */ + +/** + * A topology structure SDAM change event + * + * @event ReplSet#topologyDescriptionChanged + * @type {object} + */ + +/** + * A topology serverHeartbeatStarted SDAM event + * + * @event ReplSet#serverHeartbeatStarted + * @type {object} + */ + +/** + * A topology serverHeartbeatFailed SDAM event + * + * @event ReplSet#serverHeartbeatFailed + * @type {object} + */ + +/** + * A topology serverHeartbeatSucceeded SDAM change event + * + * @event ReplSet#serverHeartbeatSucceeded + * @type {object} + */ + +module.exports = ReplSet; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset_state.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset_state.js new file mode 100644 index 0000000..65d450f --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/replset_state.js @@ -0,0 +1,1001 @@ +"use strict" + +var inherits = require('util').inherits, + f = require('util').format, + diff = require('./shared').diff, + EventEmitter = require('events').EventEmitter, + Logger = require('../connection/logger'), + ReadPreference = require('./read_preference'), + MongoError = require('../error'); + +var TopologyType = { + 'Single': 'Single', 'ReplicaSetNoPrimary': 'ReplicaSetNoPrimary', + 'ReplicaSetWithPrimary': 'ReplicaSetWithPrimary', 'Sharded': 'Sharded', + 'Unknown': 'Unknown' +}; + +var ServerType = { + 'Standalone': 'Standalone', 'Mongos': 'Mongos', 'PossiblePrimary': 'PossiblePrimary', + 'RSPrimary': 'RSPrimary', 'RSSecondary': 'RSSecondary', 'RSArbiter': 'RSArbiter', + 'RSOther': 'RSOther', 'RSGhost': 'RSGhost', 'Unknown': 'Unknown' +}; + +var ReplSetState = function(options) { + options = options || {}; + // Add event listener + EventEmitter.call(this); + // Topology state + this.topologyType = TopologyType.ReplicaSetNoPrimary; + this.setName = options.setName; + + // Server set + this.set = {}; + + // Unpacked options + this.id = options.id; + this.setName = options.setName; + + // Replicaset logger + this.logger = options.logger || Logger('ReplSet', options); + + // Server selection index + this.index = 0; + // Acceptable latency + this.acceptableLatency = options.acceptableLatency || 15; + + // heartbeatFrequencyMS + this.heartbeatFrequencyMS = options.heartbeatFrequencyMS || 10000; + + // Server side + this.primary = null; + this.secondaries = []; + this.arbiters = []; + this.passives = []; + this.ghosts = []; + // Current unknown hosts + this.unknownServers = []; + // In set status + this.set = {}; + // Status + this.maxElectionId = null; + this.maxSetVersion = 0; + // Description of the Replicaset + this.replicasetDescription = { + "topologyType": "Unknown", "servers": [] + }; +} + +inherits(ReplSetState, EventEmitter); + +ReplSetState.prototype.hasPrimaryAndSecondary = function() { + return this.primary != null && this.secondaries.length > 0; +} + +ReplSetState.prototype.hasPrimaryOrSecondary = function() { + return this.hasPrimary() || this.hasSecondary(); +} + +ReplSetState.prototype.hasPrimary = function() { + return this.primary != null; +} + +ReplSetState.prototype.hasSecondary = function() { + return this.secondaries.length > 0; +} + +ReplSetState.prototype.get = function(host) { + var servers = this.allServers(); + + for(var i = 0; i < servers.length; i++) { + if(servers[i].name.toLowerCase() === host.toLowerCase()) { + return servers[i]; + } + } + + return null; +} + +ReplSetState.prototype.allServers = function(options) { + options = options || {}; + var servers = this.primary ? [this.primary] : []; + servers = servers.concat(this.secondaries); + if(!options.ignoreArbiters) servers = servers.concat(this.arbiters); + servers = servers.concat(this.passives); + return servers; +} + +ReplSetState.prototype.destroy = function(options) { + // Destroy all sockets + if(this.primary) this.primary.destroy(options); + this.secondaries.forEach(function(x) { x.destroy(options); }); + this.arbiters.forEach(function(x) { x.destroy(options); }); + this.passives.forEach(function(x) { x.destroy(options); }); + this.ghosts.forEach(function(x) { x.destroy(options); }); + // Clear out the complete state + this.secondaries = []; + this.arbiters = []; + this.passives = []; + this.ghosts = []; + this.unknownServers = []; + this.set = {}; + this.primary = null; + // Emit the topology changed + emitTopologyDescriptionChanged(this); +} + +ReplSetState.prototype.remove = function(server, options) { + options = options || {}; + + // Get the server name and lowerCase it + var serverName = server.name.toLowerCase(); + + // Only remove if the current server is not connected + var servers = this.primary ? [this.primary] : []; + servers = servers.concat(this.secondaries); + servers = servers.concat(this.arbiters); + servers = servers.concat(this.passives); + + // Check if it's active and this is just a failed connection attempt + for(var i = 0; i < servers.length; i++) { + if(!options.force + && servers[i].equals(server) + && servers[i].isConnected + && servers[i].isConnected()) { + return; + } + } + + // If we have it in the set remove it + if(this.set[serverName]) { + this.set[serverName].type = ServerType.Unknown; + this.set[serverName].electionId = null; + this.set[serverName].setName = null; + this.set[serverName].setVersion = null; + } + + // Remove type + var removeType = null; + + // Remove from any lists + if(this.primary && this.primary.equals(server)) { + this.primary = null; + this.topologyType = TopologyType.ReplicaSetNoPrimary; + removeType = 'primary'; + } + + // Remove from any other server lists + removeType = removeFrom(server, this.secondaries) ? 'secondary' : removeType; + removeType = removeFrom(server, this.arbiters) ? 'arbiter' : removeType; + removeType = removeFrom(server, this.passives) ? 'secondary' : removeType; + removeFrom(server, this.ghosts); + removeFrom(server, this.unknownServers); + + // Push to unknownServers + this.unknownServers.push(serverName); + + // Do we have a removeType + if(removeType) { + this.emit('left', removeType, server); + } +} + +ReplSetState.prototype.update = function(server) { + var self = this; + // Get the current ismaster + var ismaster = server.lastIsMaster(); + + // Get the server name and lowerCase it + var serverName = server.name.toLowerCase(); + + // + // Add any hosts + // + if(ismaster) { + // Join all the possible new hosts + var hosts = Array.isArray(ismaster.hosts) ? ismaster.hosts : []; + hosts = hosts.concat(Array.isArray(ismaster.arbiters) ? ismaster.arbiters : []); + hosts = hosts.concat(Array.isArray(ismaster.passives) ? ismaster.passives : []); + hosts = hosts.map(function(s) { return s.toLowerCase() }); + + // Add all hosts as unknownServers + for(var i = 0; i < hosts.length; i++) { + // Add to the list of unknown server + if(this.unknownServers.indexOf(hosts[i]) == -1 + && (!this.set[hosts[i]] || this.set[hosts[i]].type == ServerType.Unknown)) { + this.unknownServers.push(hosts[i].toLowerCase()); + } + + if(!this.set[hosts[i]]) { + this.set[hosts[i]] = { + type: ServerType.Unknown, + electionId: null, + setName: null, + setVersion: null + } + } + } + } + + // + // Unknown server + // + if(!ismaster && !inList(ismaster, server, this.unknownServers)) { + self.set[serverName] = { + type: ServerType.Unknown, setVersion: null, electionId: null, setName: null + } + // Update set information about the server instance + self.set[serverName].type = ServerType.Unknown; + self.set[serverName].electionId = ismaster ? ismaster.electionId : ismaster; + self.set[serverName].setName = ismaster ? ismaster.setName : ismaster; + self.set[serverName].setVersion = ismaster ? ismaster.setVersion : ismaster; + + if(self.unknownServers.indexOf(server.name) == -1) { + self.unknownServers.push(serverName); + } + + // Set the topology + return false; + } + + // + // Is this a mongos + // + if(ismaster && ismaster.msg == 'isdbgrid') { + return false; + } + + // A RSOther instance + if((ismaster.setName && ismaster.hidden) + || (ismaster.setName && !ismaster.ismaster && !ismaster.secondary && !ismaster.arbiterOnly && !ismaster.passive)) { + self.set[serverName] = { + type: ServerType.RSOther, setVersion: null, + electionId: null, setName: ismaster.setName + } + // Set the topology + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + return false; + } + + // A RSGhost instance + if(ismaster.isreplicaset) { + self.set[serverName] = { + type: ServerType.RSGhost, setVersion: null, + electionId: null, setName: null + } + + // Set the topology + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + + // Set the topology + return false; + } + + // + // Standalone server, destroy and return + // + if(ismaster && ismaster.ismaster && !ismaster.setName) { + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.Unknown; + this.remove(server, {force:true}); + return false; + } + + // + // Server in maintanance mode + // + if(ismaster && !ismaster.ismaster && !ismaster.secondary && !ismaster.arbiterOnly) { + this.remove(server, {force:true}); + return false; + } + + // + // If the .me field does not match the passed in server + // + if(ismaster.me && ismaster.me.toLowerCase() != serverName) { + if(this.logger.isWarn()) { + this.logger.warn(f('the seedlist server was removed due to its address %s not matching its ismaster.me address %s', server.name, ismaster.me)); + } + + // Delete from the set + delete this.set[serverName]; + // Delete unknown servers + removeFrom(server, self.unknownServers); + + // Destroy the instance + server.destroy(); + + // Set the type of topology we have + if(this.primary && !this.primary.equals(server)) { + this.topologyType = TopologyType.ReplicaSetWithPrimary; + } else { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + } + + // + // We have a potential primary + // + if(!this.primary && ismaster.primary) { + this.set[ismaster.primary.toLowerCase()] = { + type: ServerType.PossiblePrimary, + setName: null, + electionId: null, + setVersion: null, + } + } + + return false; + } + + // + // Primary handling + // + if(!this.primary && ismaster.ismaster && ismaster.setName) { + var ismasterElectionId = server.lastIsMaster().electionId; + if(this.setName && this.setName != ismaster.setName) { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + return new MongoError(f('setName from ismaster does not match provided connection setName [%s] != [%s]', ismaster.setName, this.setName)); + } + + if(!this.maxElectionId && ismasterElectionId) { + this.maxElectionId = ismasterElectionId; + } else if(this.maxElectionId && ismasterElectionId) { + var result = compareObjectIds(this.maxElectionId, ismasterElectionId); + // Get the electionIds + var ismasterSetVersion = server.lastIsMaster().setVersion; + + if(result == 1) { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + return false; + } else if(result == 0 && ismasterSetVersion) { + if(ismasterSetVersion < this.maxSetVersion) { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + return false; + } + } + + this.maxSetVersion = ismasterSetVersion; + this.maxElectionId = ismasterElectionId; + } + + // Hande normalization of server names + var normalizedHosts = ismaster.hosts.map(function(x) { return x.toLowerCase() }); + var locationIndex = normalizedHosts.indexOf(serverName); + + // Validate that the server exists in the host list + if(locationIndex != -1) { + self.primary = server; + self.set[serverName] = { + type: ServerType.RSPrimary, + setVersion: ismaster.setVersion, + electionId: ismaster.electionId, + setName: ismaster.setName + } + + // Set the topology + this.topologyType = TopologyType.ReplicaSetWithPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + removeFrom(server, self.unknownServers); + removeFrom(server, self.secondaries); + removeFrom(server, self.passives); + self.emit('joined', 'primary', server); + } else { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + } + + emitTopologyDescriptionChanged(self); + return true; + } else if(ismaster.ismaster && ismaster.setName) { + // Get the electionIds + var currentElectionId = self.set[self.primary.name.toLowerCase()].electionId; + var currentSetVersion = self.set[self.primary.name.toLowerCase()].setVersion; + var currentSetName = self.set[self.primary.name.toLowerCase()].setName; + ismasterElectionId = server.lastIsMaster().electionId; + ismasterSetVersion = server.lastIsMaster().setVersion; + var ismasterSetName = server.lastIsMaster().setName; + + // Is it the same server instance + if(this.primary.equals(server) + && currentSetName == ismasterSetName) { + return false; + } + + // If we do not have the same rs name + if(currentSetName && currentSetName != ismasterSetName) { + if(!this.primary.equals(server)) { + this.topologyType = TopologyType.ReplicaSetWithPrimary; + } else { + this.topologyType = TopologyType.ReplicaSetNoPrimary; + } + + return false; + } + + // Check if we need to replace the server + if(currentElectionId && ismasterElectionId) { + result = compareObjectIds(currentElectionId, ismasterElectionId); + + if(result == 1) { + return false; + } else if(result == 0 && (currentSetVersion > ismasterSetVersion)) { + return false; + } + } else if(!currentElectionId && ismasterElectionId + && ismasterSetVersion) { + if(ismasterSetVersion < this.maxSetVersion) { + return false; + } + } + + if(!this.maxElectionId && ismasterElectionId) { + this.maxElectionId = ismasterElectionId; + } else if(this.maxElectionId && ismasterElectionId) { + result = compareObjectIds(this.maxElectionId, ismasterElectionId); + + if(result == 1) { + return false; + } else if(result == 0 && currentSetVersion && ismasterSetVersion) { + if(ismasterSetVersion < this.maxSetVersion) { + return false; + } + } else { + if(ismasterSetVersion < this.maxSetVersion) { + return false; + } + } + + this.maxElectionId = ismasterElectionId; + this.maxSetVersion = ismasterSetVersion; + } else { + this.maxSetVersion = ismasterSetVersion; + } + + // Modify the entry to unknown + self.set[self.primary.name.toLowerCase()] = { + type: ServerType.Unknown, setVersion: null, + electionId: null, setName: null + } + + // Signal primary left + self.emit('left', 'primary', this.primary); + // Destroy the instance + self.primary.destroy(); + // Set the new instance + self.primary = server; + // Set the set information + self.set[serverName] = { + type: ServerType.RSPrimary, setVersion: ismaster.setVersion, + electionId: ismaster.electionId, setName: ismaster.setName + } + + // Set the topology + this.topologyType = TopologyType.ReplicaSetWithPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + removeFrom(server, self.unknownServers); + removeFrom(server, self.secondaries); + removeFrom(server, self.passives); + self.emit('joined', 'primary', server); + emitTopologyDescriptionChanged(self); + return true; + } + + // A possible instance + if(!this.primary && ismaster.primary) { + self.set[ismaster.primary.toLowerCase()] = { + type: ServerType.PossiblePrimary, setVersion: null, + electionId: null, setName: null + } + } + + // + // Secondary handling + // + if(ismaster.secondary && ismaster.setName + && !inList(ismaster, server, this.secondaries) + && this.setName && this.setName == ismaster.setName) { + addToList(self, ServerType.RSSecondary, ismaster, server, this.secondaries); + // Set the topology + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + removeFrom(server, self.unknownServers); + + // Remove primary + if(this.primary + && this.primary.name.toLowerCase() == serverName) { + server.destroy(); + this.primary = null; + self.emit('left', 'primary', server); + } + + // Emit secondary joined replicaset + self.emit('joined', 'secondary', server); + emitTopologyDescriptionChanged(self); + return true; + } + + // + // Arbiter handling + // + if(ismaster.arbiterOnly && ismaster.setName + && !inList(ismaster, server, this.arbiters) + && this.setName && this.setName == ismaster.setName) { + addToList(self, ServerType.RSArbiter, ismaster, server, this.arbiters); + // Set the topology + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + removeFrom(server, self.unknownServers); + self.emit('joined', 'arbiter', server); + emitTopologyDescriptionChanged(self); + return true; + } + + // + // Passive handling + // + if(ismaster.passive && ismaster.setName + && !inList(ismaster, server, this.passives) + && this.setName && this.setName == ismaster.setName) { + addToList(self, ServerType.RSSecondary, ismaster, server, this.passives); + // Set the topology + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + if(ismaster.setName) this.setName = ismaster.setName; + removeFrom(server, self.unknownServers); + + // Remove primary + if(this.primary + && this.primary.name.toLowerCase() == serverName) { + server.destroy(); + this.primary = null; + self.emit('left', 'primary', server); + } + + self.emit('joined', 'secondary', server); + emitTopologyDescriptionChanged(self); + return true; + } + + // + // Remove the primary + // + if(this.set[serverName] && this.set[serverName].type == ServerType.RSPrimary) { + self.emit('left', 'primary', this.primary); + this.primary.destroy(); + this.primary = null; + this.topologyType = TopologyType.ReplicaSetNoPrimary; + return false; + } + + this.topologyType = this.primary ? TopologyType.ReplicaSetWithPrimary : TopologyType.ReplicaSetNoPrimary; + return false; +} + +/** + * Recalculate single server max staleness + * @method + */ +ReplSetState.prototype.updateServerMaxStaleness = function(server, haInterval) { + // Locate the max secondary lastwrite + var max = 0; + // Go over all secondaries + for(var i = 0; i < this.secondaries.length; i++) { + max = Math.max(max, this.secondaries[i].lastWriteDate); + } + + // Perform this servers staleness calculation + if(server.ismaster.maxWireVersion >= 5 + && server.ismaster.secondary + && this.hasPrimary()) { + server.staleness = (server.lastUpdateTime - server.lastWriteDate) + - (this.primary.lastUpdateTime - this.primary.lastWriteDate) + + haInterval; + } else if(server.ismaster.maxWireVersion >= 5 + && server.ismaster.secondary){ + server.staleness = max - server.lastWriteDate + haInterval; + } +} + +/** + * Recalculate all the staleness values for secodaries + * @method + */ +ReplSetState.prototype.updateSecondariesMaxStaleness = function(haInterval) { + for(var i = 0; i < this.secondaries.length; i++) { + this.updateServerMaxStaleness(this.secondaries[i], haInterval); + } +} + +/** + * Pick a server by the passed in ReadPreference + * @method + * @param {ReadPreference} readPreference The ReadPreference instance to use + */ +ReplSetState.prototype.pickServer = function(readPreference) { + // If no read Preference set to primary by default + readPreference = readPreference || ReadPreference.primary; + + // maxStalenessSeconds is not allowed with a primary read + if(readPreference.preference == 'primary' && readPreference.maxStalenessSeconds != null) { + return new MongoError('primary readPreference incompatible with maxStalenessSeconds'); + } + + // Check if we have any non compatible servers for maxStalenessSeconds + var allservers = this.primary ? [this.primary] : []; + allservers = allservers.concat(this.secondaries); + + // Does any of the servers not support the right wire protocol version + // for maxStalenessSeconds when maxStalenessSeconds specified on readPreference. Then error out + if(readPreference.maxStalenessSeconds != null) { + for(var i = 0; i < allservers.length; i++) { + if(allservers[i].ismaster.maxWireVersion < 5) { + return new MongoError('maxStalenessSeconds not supported by at least one of the replicaset members'); + } + } + } + + // Do we have the nearest readPreference + if(readPreference.preference == 'nearest' && readPreference.maxStalenessSeconds == null) { + return pickNearest(this, readPreference); + } else if(readPreference.preference == 'nearest' && readPreference.maxStalenessSeconds != null) { + return pickNearestMaxStalenessSeconds(this, readPreference); + } + + // Get all the secondaries + var secondaries = this.secondaries; + + // Check if we can satisfy and of the basic read Preferences + if(readPreference.equals(ReadPreference.secondary) + && secondaries.length == 0) { + return new MongoError("no secondary server available"); + } + + if(readPreference.equals(ReadPreference.secondaryPreferred) + && secondaries.length == 0 + && this.primary == null) { + return new MongoError("no secondary or primary server available"); + } + + if(readPreference.equals(ReadPreference.primary) + && this.primary == null) { + return new MongoError("no primary server available"); + } + + // Secondary preferred or just secondaries + if(readPreference.equals(ReadPreference.secondaryPreferred) + || readPreference.equals(ReadPreference.secondary)) { + + if(secondaries.length > 0 && readPreference.maxStalenessSeconds == null) { + // Pick nearest of any other servers available + var server = pickNearest(this, readPreference); + // No server in the window return primary + if(server) { + return server; + } + } else if(secondaries.length > 0 && readPreference.maxStalenessSeconds != null) { + // Pick nearest of any other servers available + server = pickNearestMaxStalenessSeconds(this, readPreference); + // No server in the window return primary + if(server) { + return server; + } + } + + if(readPreference.equals(ReadPreference.secondaryPreferred)){ + return this.primary; + } + + return null; + } + + // Primary preferred + if(readPreference.equals(ReadPreference.primaryPreferred)) { + server = null; + + // We prefer the primary if it's available + if(this.primary) { + return this.primary; + } + + // Pick a secondary + if(secondaries.length > 0 && readPreference.maxStalenessSeconds == null) { + server = pickNearest(this, readPreference); + } else if(secondaries.length > 0 && readPreference.maxStalenessSeconds != null) { + server = pickNearestMaxStalenessSeconds(this, readPreference); + } + + // Did we find a server + if(server) return server; + } + + // Return the primary + return this.primary; +} + +// +// Filter serves by tags +var filterByTags = function(readPreference, servers) { + if(readPreference.tags == null) return servers; + var filteredServers = []; + var tagsArray = Array.isArray(readPreference.tags) ? readPreference.tags : [readPreference.tags]; + + // Iterate over the tags + for(var j = 0; j < tagsArray.length; j++) { + var tags = tagsArray[j]; + + // Iterate over all the servers + for(var i = 0; i < servers.length; i++) { + var serverTag = servers[i].lastIsMaster().tags || {}; + + // Did we find the a matching server + var found = true; + // Check if the server is valid + for(var name in tags) { + if(serverTag[name] != tags[name]) { + found = false; + } + } + + // Add to candidate list + if(found) { + filteredServers.push(servers[i]); + } + } + } + + // Returned filtered servers + return filteredServers; +} + +function pickNearestMaxStalenessSeconds(self, readPreference) { + // Only get primary and secondaries as seeds + var servers = []; + var heartbeatFrequencyMS = self.heartbeatFrequencyMS; + + // Get the maxStalenessMS + var maxStalenessMS = readPreference.maxStalenessSeconds * 1000; + + // Check if the maxStalenessMS > 90 seconds + if(maxStalenessMS < 90 * 1000) { + return new MongoError('maxStalenessSeconds must be set to at least 90 seconds'); + } + + // Add primary to list if not a secondary read preference + if(self.primary + && readPreference.preference != 'secondary' + && readPreference.preference != 'secondaryPreferred') { + servers.push(self.primary); + } + + // Add all the secondaries + for(var i = 0; i < self.secondaries.length; i++) { + servers.push(self.secondaries[i]); + } + + // If we have a secondaryPreferred readPreference and no server add the primary + if(self.primary + && servers.length == 0 + && readPreference.preference != 'secondaryPreferred') { + servers.push(self.primary); + } + + // Filter by tags + servers = filterByTags(readPreference, servers); + + // + // Locate lowest time (picked servers are lowest time + acceptable Latency margin) + // var lowest = servers.length > 0 ? servers[0].lastIsMasterMS : 0; + + // Filter by latency + servers = servers.filter(function(s) { + return s.staleness <= maxStalenessMS; + }); + + // Sort by time + servers.sort(function(a, b) { + // return a.time > b.time; + return a.lastIsMasterMS > b.lastIsMasterMS + }); + + // No servers, default to primary + if(servers.length == 0) { + return null + } + + // Ensure index does not overflow the number of available servers + self.index = self.index % servers.length; + + // Get the server + var server = servers[self.index]; + // Add to the index + self.index = self.index + 1; + // Return the first server of the sorted and filtered list + return server; +} + +function pickNearest(self, readPreference) { + // Only get primary and secondaries as seeds + var servers = []; + + // Add primary to list if not a secondary read preference + if(self.primary + && readPreference.preference != 'secondary' + && readPreference.preference != 'secondaryPreferred') { + servers.push(self.primary); + } + + // Add all the secondaries + for(var i = 0; i < self.secondaries.length; i++) { + servers.push(self.secondaries[i]); + } + + // If we have a secondaryPreferred readPreference and no server add the primary + if(servers.length == 0 + && self.primary + && readPreference.preference != 'secondaryPreferred') { + servers.push(self.primary); + } + + // Filter by tags + servers = filterByTags(readPreference, servers); + + // Sort by time + servers.sort(function(a, b) { + // return a.time > b.time; + return a.lastIsMasterMS > b.lastIsMasterMS + }); + + // Locate lowest time (picked servers are lowest time + acceptable Latency margin) + var lowest = servers.length > 0 ? servers[0].lastIsMasterMS : 0; + + // Filter by latency + servers = servers.filter(function(s) { + return s.lastIsMasterMS <= lowest + self.acceptableLatency; + }); + + // No servers, default to primary + if(servers.length == 0) { + return null + } + + // Ensure index does not overflow the number of available servers + self.index = self.index % servers.length; + // Get the server + var server = servers[self.index]; + // Add to the index + self.index = self.index + 1; + // Return the first server of the sorted and filtered list + return server; +} + +function inList(ismaster, server, list) { + for(var i = 0; i < list.length; i++) { + if(list[i] && list[i].name + && list[i].name.toLowerCase() == server.name.toLowerCase()) return true; + } + + return false; +} + +function addToList(self, type, ismaster, server, list) { + var serverName = server.name.toLowerCase(); + // Update set information about the server instance + self.set[serverName].type = type; + self.set[serverName].electionId = ismaster ? ismaster.electionId : ismaster; + self.set[serverName].setName = ismaster ? ismaster.setName : ismaster; + self.set[serverName].setVersion = ismaster ? ismaster.setVersion : ismaster; + // Add to the list + list.push(server); +} + +function compareObjectIds(id1, id2) { + var a = new Buffer(id1.toHexString(), 'hex'); + var b = new Buffer(id2.toHexString(), 'hex'); + + if(a === b) { + return 0; + } + + if(typeof Buffer.compare === 'function') { + return Buffer.compare(a, b); + } + + var x = a.length; + var y = b.length; + var len = Math.min(x, y); + + for (var i = 0; i < len; i++) { + if (a[i] !== b[i]) { + break; + } + } + + if (i !== len) { + x = a[i]; + y = b[i]; + } + + return x < y ? -1 : y < x ? 1 : 0; +} + +function removeFrom(server, list) { + for(var i = 0; i < list.length; i++) { + if(list[i].equals && list[i].equals(server)) { + list.splice(i, 1); + return true; + } else if(typeof list[i] == 'string' + && list[i].toLowerCase() == server.name.toLowerCase()) { + list.splice(i, 1); + return true; + } + } + + return false; +} + +function emitTopologyDescriptionChanged(self) { + if(self.listeners('topologyDescriptionChanged').length > 0) { + var topology = 'Unknown'; + var setName = self.setName; + + if(self.hasPrimaryAndSecondary()) { + topology = 'ReplicaSetWithPrimary'; + } else if(!self.hasPrimary() && self.hasSecondary()) { + topology = 'ReplicaSetNoPrimary'; + } + + // Generate description + var description = { + topologyType: topology, + setName: setName, + servers: [] + } + + // Add the primary to the list + if(self.hasPrimary()) { + var desc = self.primary.getDescription(); + desc.type = 'RSPrimary'; + description.servers.push(desc); + } + + // Add all the secondaries + description.servers = description.servers.concat(self.secondaries.map(function(x) { + var description = x.getDescription(); + description.type = 'RSSecondary'; + return description; + })); + + // Add all the arbiters + description.servers = description.servers.concat(self.arbiters.map(function(x) { + var description = x.getDescription(); + description.type = 'RSArbiter'; + return description; + })); + + // Add all the passives + description.servers = description.servers.concat(self.passives.map(function(x) { + var description = x.getDescription(); + description.type = 'RSSecondary'; + return description; + })); + + // Get the diff + var diffResult = diff(self.replicasetDescription, description); + + // Create the result + var result = { + topologyId: self.id, + previousDescription: self.replicasetDescription, + newDescription: description, + diff: diffResult, + }; + + // Emit the topologyDescription change + // if(diffResult.servers.length > 0) { + self.emit('topologyDescriptionChanged', result); + // } + + // Set the new description + self.replicasetDescription = description; + } +} + +module.exports = ReplSetState; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js new file mode 100644 index 0000000..04cb2e6 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js @@ -0,0 +1,880 @@ +"use strict" + +var inherits = require('util').inherits, + f = require('util').format, + EventEmitter = require('events').EventEmitter, + ReadPreference = require('./read_preference'), + Logger = require('../connection/logger'), + debugOptions = require('../connection/utils').debugOptions, + retrieveBSON = require('../connection/utils').retrieveBSON, + Pool = require('../connection/pool'), + Query = require('../connection/commands').Query, + MongoError = require('../error'), + PreTwoSixWireProtocolSupport = require('../wireprotocol/2_4_support'), + TwoSixWireProtocolSupport = require('../wireprotocol/2_6_support'), + ThreeTwoWireProtocolSupport = require('../wireprotocol/3_2_support'), + BasicCursor = require('../cursor'), + sdam = require('./shared'), + assign = require('../utils').assign, + createClientInfo = require('./shared').createClientInfo; + +// Used for filtering out fields for loggin +var debugFields = ['reconnect', 'reconnectTries', 'reconnectInterval', 'emitError', 'cursorFactory', 'host' + , 'port', 'size', 'keepAlive', 'keepAliveInitialDelay', 'noDelay', 'connectionTimeout', 'checkServerIdentity' + , 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'crl', 'cert', 'key', 'rejectUnauthorized', 'promoteLongs', 'promoteValues' + , 'promoteBuffers', 'servername']; + +// Server instance id +var id = 0; +var serverAccounting = false; +var servers = {}; +var BSON = retrieveBSON(); + +/** + * Creates a new Server instance + * @class + * @param {boolean} [options.reconnect=true] Server will attempt to reconnect on loss of connection + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {number} [options.monitoring=true] Enable the server state monitoring (calling ismaster at monitoringInterval) + * @param {number} [options.monitoringInterval=5000] The interval of calling ismaster when monitoring is enabled. + * @param {Cursor} [options.cursorFactory=Cursor] The cursor factory class used for all query cursors + * @param {string} options.host The server host + * @param {number} options.port The server port + * @param {number} [options.size=5] Server connection pool size + * @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled + * @param {number} [options.keepAliveInitialDelay=300000] Initial delay before TCP keep alive enabled + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.connectionTimeout=30000] TCP Connection timeout setting + * @param {number} [options.socketTimeout=360000] TCP Socket timeout setting + * @param {boolean} [options.ssl=false] Use SSL for connection + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {Buffer} [options.ca] SSL Certificate store binary buffer + * @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer + * @param {Buffer} [options.cert] SSL Certificate binary buffer + * @param {Buffer} [options.key] SSL Key file binary buffer + * @param {string} [options.passphrase] SSL Certificate pass phrase + * @param {boolean} [options.rejectUnauthorized=true] Reject unauthorized server certificates + * @param {string} [options.servername=null] String containing the server name requested via TLS SNI. + * @param {boolean} [options.promoteLongs=true] Convert Long values from the db into Numbers if they fit into 53 bits + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {string} [options.appname=null] Application name, passed in on ismaster call and logged in mongod server logs. Maximum size 128 bytes. + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @return {Server} A cursor instance + * @fires Server#connect + * @fires Server#close + * @fires Server#error + * @fires Server#timeout + * @fires Server#parseError + * @fires Server#reconnect + * @fires Server#reconnectFailed + * @fires Server#serverHeartbeatStarted + * @fires Server#serverHeartbeatSucceeded + * @fires Server#serverHeartbeatFailed + * @fires Server#topologyOpening + * @fires Server#topologyClosed + * @fires Server#topologyDescriptionChanged + * @property {string} type the topology type. + * @property {string} parserType the parser type used (c++ or js). + */ +var Server = function(options) { + options = options || {}; + + // Add event listener + EventEmitter.call(this); + + // Server instance id + this.id = id++; + + // Internal state + this.s = { + // Options + options: options, + // Logger + logger: Logger('Server', options), + // Factory overrides + Cursor: options.cursorFactory || BasicCursor, + // BSON instance + bson: options.bson || new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, + BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, + BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]), + // Pool + pool: null, + // Disconnect handler + disconnectHandler: options.disconnectHandler, + // Monitor thread (keeps the connection alive) + monitoring: typeof options.monitoring == 'boolean' ? options.monitoring : true, + // Is the server in a topology + inTopology: typeof options.inTopology == 'boolean' ? options.inTopology : false, + // Monitoring timeout + monitoringInterval: typeof options.monitoringInterval == 'number' + ? options.monitoringInterval + : 5000, + // Topology id + topologyId: -1 + } + + // Curent ismaster + this.ismaster = null; + // Current ping time + this.lastIsMasterMS = -1; + // The monitoringProcessId + this.monitoringProcessId = null; + // Initial connection + this.initalConnect = true; + // Wire protocol handler, default to oldest known protocol handler + // this gets changed when the first ismaster is called. + this.wireProtocolHandler = new PreTwoSixWireProtocolSupport(); + // Default type + this._type = 'server'; + // Set the client info + this.clientInfo = createClientInfo(options); + + // Max Stalleness values + // last time we updated the ismaster state + this.lastUpdateTime = 0; + // Last write time + this.lastWriteDate = 0; + // Stalleness + this.staleness = 0; +} + +inherits(Server, EventEmitter); + +Object.defineProperty(Server.prototype, 'type', { + enumerable:true, get: function() { return this._type; } +}); + +Object.defineProperty(Server.prototype, 'parserType', { + enumerable:true, get: function() { + return BSON.native ? "c++" : "js"; + } +}); + +Server.enableServerAccounting = function() { + serverAccounting = true; + servers = {}; +} + +Server.disableServerAccounting = function() { + serverAccounting = false; +} + +Server.servers = function() { + return servers; +} + +Object.defineProperty(Server.prototype, 'name', { + enumerable:true, + get: function() { return this.s.options.host + ":" + this.s.options.port; } +}); + +function configureWireProtocolHandler(self, ismaster) { + // 3.2 wire protocol handler + if(ismaster.maxWireVersion >= 4) { + return new ThreeTwoWireProtocolSupport(new TwoSixWireProtocolSupport()); + } + + // 2.6 wire protocol handler + if(ismaster.maxWireVersion >= 2) { + return new TwoSixWireProtocolSupport(); + } + + // 2.4 or earlier wire protocol handler + return new PreTwoSixWireProtocolSupport(); +} + +function disconnectHandler(self, type, ns, cmd, options, callback) { + // Topology is not connected, save the call in the provided store to be + // Executed at some point when the handler deems it's reconnected + if(!self.s.pool.isConnected() && self.s.options.reconnect && self.s.disconnectHandler != null && !options.monitoring) { + self.s.disconnectHandler.add(type, ns, cmd, options, callback); + return true; + } + + // If we have no connection error + if(!self.s.pool.isConnected()) { + callback(MongoError.create(f("no connection available to server %s", self.name))); + return true; + } +} + +function monitoringProcess(self) { + return function() { + // Pool was destroyed do not continue process + if(self.s.pool.isDestroyed()) return; + // Emit monitoring Process event + self.emit('monitoring', self); + // Perform ismaster call + // Query options + var queryOptions = { numberToSkip: 0, numberToReturn: -1, checkKeys: false, slaveOk: true }; + // Create a query instance + var query = new Query(self.s.bson, 'admin.$cmd', {ismaster:true}, queryOptions); + // Get start time + var start = new Date().getTime(); + + // Execute the ismaster query + self.s.pool.write(query, { + socketTimeout: (typeof self.s.options.connectionTimeout !== 'number') ? 2000 : self.s.options.connectionTimeout, + monitoring: true, + }, function(err, result) { + // Set initial lastIsMasterMS + self.lastIsMasterMS = new Date().getTime() - start; + if(self.s.pool.isDestroyed()) return; + // Update the ismaster view if we have a result + if(result) { + self.ismaster = result.result; + } + // Re-schedule the monitoring process + self.monitoringProcessId = setTimeout(monitoringProcess(self), self.s.monitoringInterval); + }); + } +} + +var eventHandler = function(self, event) { + return function(err) { + // Log information of received information if in info mode + if(self.s.logger.isInfo()) { + var object = err instanceof MongoError ? JSON.stringify(err) : {} + self.s.logger.info(f('server %s fired event %s out with message %s' + , self.name, event, object)); + } + + // Handle connect event + if(event == 'connect') { + // Issue an ismaster command at connect + // Query options + var queryOptions = { numberToSkip: 0, numberToReturn: -1, checkKeys: false, slaveOk: true }; + // Create a query instance + var query = new Query(self.s.bson, 'admin.$cmd', {ismaster:true, client: self.clientInfo}, queryOptions); + // Get start time + var start = new Date().getTime(); + // Execute the ismaster query + self.s.pool.write(query, { + socketTimeout: self.s.options.connectionTimeout || 2000, + }, function(err, result) { + // Set initial lastIsMasterMS + self.lastIsMasterMS = new Date().getTime() - start; + if(err) { + self.destroy(); + if(self.listeners('error').length > 0) self.emit('error', err); + return; + } + + // Ensure no error emitted after initial connect when reconnecting + self.initalConnect = false; + // Save the ismaster + self.ismaster = result.result; + + // It's a proxy change the type so + // the wireprotocol will send $readPreference + if(self.ismaster.msg == 'isdbgrid') { + self._type = 'mongos'; + } + // Add the correct wire protocol handler + self.wireProtocolHandler = configureWireProtocolHandler(self, self.ismaster); + // Have we defined self monitoring + if(self.s.monitoring) { + self.monitoringProcessId = setTimeout(monitoringProcess(self), self.s.monitoringInterval); + } + + // Emit server description changed if something listening + sdam.emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: sdam.getTopologyType(self) + }); + + if(!self.s.inTopology) { + // Emit topology description changed if something listening + sdam.emitTopologyDescriptionChanged(self, { + topologyType: 'Single', servers: [{address: self.name, arbiters: [], hosts: [], passives: [], type: sdam.getTopologyType(self)}] + }); + } + + // Log the ismaster if available + if(self.s.logger.isInfo()) { + self.s.logger.info(f('server %s connected with ismaster [%s]', self.name, JSON.stringify(self.ismaster))); + } + + // Emit connect + self.emit('connect', self); + }); + } else if(event == 'error' || event == 'parseError' + || event == 'close' || event == 'timeout' || event == 'reconnect' + || event == 'attemptReconnect' || 'reconnectFailed') { + // Remove server instance from accounting + if(serverAccounting && ['close', 'timeout', 'error', 'parseError', 'reconnectFailed'].indexOf(event) != -1) { + // Emit toplogy opening event if not in topology + if(!self.s.inTopology) { + self.emit('topologyOpening', { topologyId: self.id }); + } + + delete servers[self.id]; + } + + if (event === 'close') { + // Closing emits a server description changed event going to unknown. + sdam.emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: 'Unknown' + }); + } + + // Reconnect failed return error + if(event == 'reconnectFailed') { + self.emit('reconnectFailed', err); + // Emit error if any listeners + if(self.listeners('error').length > 0) { + self.emit('error', err); + } + // Terminate + return; + } + + // On first connect fail + if(self.s.pool.state == 'disconnected' && self.initalConnect && ['close', 'timeout', 'error', 'parseError'].indexOf(event) != -1) { + self.initalConnect = false; + return self.emit('error', new MongoError(f('failed to connect to server [%s] on first connect [%s]', self.name, err))); + } + + // Reconnect event, emit the server + if(event == 'reconnect') { + // Reconnecting emits a server description changed event going from unknown to the + // current server type. + sdam.emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: sdam.getTopologyType(self) + }); + return self.emit(event, self); + } + + // Emit the event + self.emit(event, err); + } + } +} + +/** + * Initiate server connect + * @method + * @param {array} [options.auth=null] Array of auth options to apply on connect + */ +Server.prototype.connect = function(options) { + var self = this; + options = options || {}; + + // Set the connections + if(serverAccounting) servers[this.id] = this; + + // Do not allow connect to be called on anything that's not disconnected + if(self.s.pool && !self.s.pool.isDisconnected() && !self.s.pool.isDestroyed()) { + throw MongoError.create(f('server instance in invalid state %s', self.s.pool.state)); + } + + // Create a pool + self.s.pool = new Pool(assign(self.s.options, options, {bson: this.s.bson})); + + // Set up listeners + self.s.pool.on('close', eventHandler(self, 'close')); + self.s.pool.on('error', eventHandler(self, 'error')); + self.s.pool.on('timeout', eventHandler(self, 'timeout')); + self.s.pool.on('parseError', eventHandler(self, 'parseError')); + self.s.pool.on('connect', eventHandler(self, 'connect')); + self.s.pool.on('reconnect', eventHandler(self, 'reconnect')); + self.s.pool.on('reconnectFailed', eventHandler(self, 'reconnectFailed')); + + // Emit toplogy opening event if not in topology + if(!self.s.inTopology) { + this.emit('topologyOpening', { topologyId: self.id }); + } + + // Emit opening server event + self.emit('serverOpening', { + topologyId: self.s.topologyId != -1 ? self.s.topologyId : self.id, + address: self.name + }); + + // Connect with optional auth settings + if(options.auth) { + self.s.pool.connect.apply(self.s.pool, options.auth); + } else { + self.s.pool.connect(); + } +} + +/** + * Get the server description + * @method + * @return {object} +*/ +Server.prototype.getDescription = function() { + var ismaster = this.ismaster || {}; + var description = { + type: sdam.getTopologyType(this), + address: this.name, + }; + + // Add fields if available + if(ismaster.hosts) description.hosts = ismaster.hosts; + if(ismaster.arbiters) description.arbiters = ismaster.arbiters; + if(ismaster.passives) description.passives = ismaster.passives; + if(ismaster.setName) description.setName = ismaster.setName; + return description; +} + +/** + * Returns the last known ismaster document for this server + * @method + * @return {object} + */ +Server.prototype.lastIsMaster = function() { + return this.ismaster; +} + +/** + * Unref all connections belong to this server + * @method + */ +Server.prototype.unref = function() { + this.s.pool.unref(); +} + +/** + * Figure out if the server is connected + * @method + * @return {boolean} + */ +Server.prototype.isConnected = function() { + if(!this.s.pool) return false; + return this.s.pool.isConnected(); +} + +/** + * Figure out if the server instance was destroyed by calling destroy + * @method + * @return {boolean} + */ +Server.prototype.isDestroyed = function() { + if(!this.s.pool) return false; + return this.s.pool.isDestroyed(); +} + +function basicWriteValidations(self) { + if(!self.s.pool) return MongoError.create('server instance is not connected'); + if(self.s.pool.isDestroyed()) return MongoError.create('server instance pool was destroyed'); +} + +function basicReadValidations(self, options) { + basicWriteValidations(self, options); + + if(options.readPreference && !(options.readPreference instanceof ReadPreference)) { + throw new Error("readPreference must be an instance of ReadPreference"); + } +} + +/** + * Execute a command + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {object} cmd The command hash + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.checkKeys=false] Specify if the bson parser should validate keys. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {Boolean} [options.fullResult=false] Return the full envelope instead of just the result document. + * @param {opResultCallback} callback A callback function + */ +Server.prototype.command = function(ns, cmd, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + var result = basicReadValidations(self, options); + if(result) return callback(result); + + // Clone the options + options = assign({}, options, { wireProtocolCommand: false }); + + // Debug log + if(self.s.logger.isDebug()) self.s.logger.debug(f('executing command [%s] against %s', JSON.stringify({ + ns: ns, cmd: cmd, options: debugOptions(debugFields, options) + }), self.name)); + + // If we are not connected or have a disconnectHandler specified + if(disconnectHandler(self, 'command', ns, cmd, options, callback)) return; + + // Check if we have collation support + if(this.ismaster && this.ismaster.maxWireVersion < 5 && cmd.collation) { + return callback(new MongoError(f('server %s does not support collation', this.name))); + } + + // Query options + var queryOptions = { + numberToSkip: 0, + numberToReturn: -1, + checkKeys: typeof options.checkKeys == 'boolean' ? options.checkKeys: false, + serializeFunctions: typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false, + ignoreUndefined: typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : false + }; + + // Are we executing against a specific topology + var topology = options.topology || {}; + // Create the query object + var query = self.wireProtocolHandler.command(self.s.bson, ns, cmd, {}, topology, options); + // Set slave OK of the query + query.slaveOk = options.readPreference ? options.readPreference.slaveOk() : false; + + // Write options + var writeOptions = { + raw: typeof options.raw == 'boolean' ? options.raw : false, + promoteLongs: typeof options.promoteLongs == 'boolean' ? options.promoteLongs : true, + promoteValues: typeof options.promoteValues == 'boolean' ? options.promoteValues : true, + promoteBuffers: typeof options.promoteBuffers == 'boolean' ? options.promoteBuffers : false, + command: true, + monitoring: typeof options.monitoring == 'boolean' ? options.monitoring : false, + fullResult: typeof options.fullResult == 'boolean' ? options.fullResult : false, + requestId: query.requestId, + socketTimeout: typeof options.socketTimeout == 'number' ? options.socketTimeout : null, + }; + + // Write the operation to the pool + self.s.pool.write(query, writeOptions, callback); +} + +/** + * Insert one or more documents + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of documents to insert + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Server.prototype.insert = function(ns, ops, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + var result = basicWriteValidations(self, options); + if(result) return callback(result); + + // If we are not connected or have a disconnectHandler specified + if(disconnectHandler(self, 'insert', ns, ops, options, callback)) return; + + // Setup the docs as an array + ops = Array.isArray(ops) ? ops : [ops]; + + // Execute write + return self.wireProtocolHandler.insert(self.s.pool, self.ismaster, ns, self.s.bson, ops, options, callback); +} + +/** + * Perform one or more update operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of updates + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Server.prototype.update = function(ns, ops, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + var result = basicWriteValidations(self, options); + if(result) return callback(result); + + // If we are not connected or have a disconnectHandler specified + if(disconnectHandler(self, 'update', ns, ops, options, callback)) return; + + // Check if we have collation support + if(this.ismaster && this.ismaster.maxWireVersion < 5 && options.collation) { + return callback(new MongoError(f('server %s does not support collation', this.name))); + } + + // Setup the docs as an array + ops = Array.isArray(ops) ? ops : [ops]; + // Execute write + return self.wireProtocolHandler.update(self.s.pool, self.ismaster, ns, self.s.bson, ops, options, callback); +} + +/** + * Perform one or more remove operations + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {array} ops An array of removes + * @param {boolean} [options.ordered=true] Execute in order or out of order + * @param {object} [options.writeConcern={}] Write concern for the operation + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Server.prototype.remove = function(ns, ops, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}, options = options || {}; + var result = basicWriteValidations(self, options); + if(result) return callback(result); + + // If we are not connected or have a disconnectHandler specified + if(disconnectHandler(self, 'remove', ns, ops, options, callback)) return; + + // Check if we have collation support + if(this.ismaster && this.ismaster.maxWireVersion < 5 && options.collation) { + return callback(new MongoError(f('server %s does not support collation', this.name))); + } + + // Setup the docs as an array + ops = Array.isArray(ops) ? ops : [ops]; + // Execute write + return self.wireProtocolHandler.remove(self.s.pool, self.ismaster, ns, self.s.bson, ops, options, callback); +} + +/** + * Get a new cursor + * @method + * @param {string} ns The MongoDB fully qualified namespace (ex: db1.collection1) + * @param {{object}|{Long}} cmd Can be either a command returning a cursor or a cursorId + * @param {object} [options.batchSize=0] Batchsize for the operation + * @param {array} [options.documents=[]] Initial documents list for cursor + * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it + * @param {Boolean} [options.serializeFunctions=false] Specify if functions on an object should be serialized. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {opResultCallback} callback A callback function + */ +Server.prototype.cursor = function(ns, cmd, cursorOptions) { + var s = this.s; + cursorOptions = cursorOptions || {}; + // Set up final cursor type + var FinalCursor = cursorOptions.cursorFactory || s.Cursor; + // Return the cursor + return new FinalCursor(s.bson, ns, cmd, cursorOptions, this, s.options); +} + +/** + * Logout from a database + * @method + * @param {string} db The db we are logging out from + * @param {authResultCallback} callback A callback function + */ +Server.prototype.logout = function(dbName, callback) { + this.s.pool.logout(dbName, callback); +} + +/** + * Authenticate using a specified mechanism + * @method + * @param {string} mechanism The Auth mechanism we are invoking + * @param {string} db The db we are invoking the mechanism against + * @param {...object} param Parameters for the specific mechanism + * @param {authResultCallback} callback A callback function + */ +Server.prototype.auth = function(mechanism, db) { + var self = this; + + // If we have the default mechanism we pick mechanism based on the wire + // protocol max version. If it's >= 3 then scram-sha1 otherwise mongodb-cr + if(mechanism == 'default' && self.ismaster && self.ismaster.maxWireVersion >= 3) { + mechanism = 'scram-sha-1'; + } else if(mechanism == 'default') { + mechanism = 'mongocr'; + } + + // Slice all the arguments off + var args = Array.prototype.slice.call(arguments, 0); + // Set the mechanism + args[0] = mechanism; + // Get the callback + var callback = args[args.length - 1]; + + // If we are not connected or have a disconnectHandler specified + if(disconnectHandler(self, 'auth', db, args, {}, callback)) { + return; + } + + // Do not authenticate if we are an arbiter + if(this.lastIsMaster() && this.lastIsMaster().arbiterOnly) { + return callback(null, true); + } + + // Apply the arguments to the pool + self.s.pool.auth.apply(self.s.pool, args); +} + +/** + * Compare two server instances + * @method + * @param {Server} server Server to compare equality against + * @return {boolean} + */ +Server.prototype.equals = function(server) { + if(typeof server == 'string') return this.name.toLowerCase() == server.toLowerCase(); + if(server.name) return this.name.toLowerCase() == server.name.toLowerCase(); + return false; +} + +/** + * All raw connections + * @method + * @return {Connection[]} + */ +Server.prototype.connections = function() { + return this.s.pool.allConnections(); +} + +/** + * Get server + * @method + * @return {Server} + */ +Server.prototype.getServer = function() { + return this; +} + +/** + * Get connection + * @method + * @return {Connection} + */ +Server.prototype.getConnection = function() { + return this.s.pool.get(); +} + +var listeners = ['close', 'error', 'timeout', 'parseError', 'connect']; + +/** + * Destroy the server connection + * @method + * @param {boolean} [options.emitClose=false] Emit close event on destroy + * @param {boolean} [options.emitDestroy=false] Emit destroy event on destroy + * @param {boolean} [options.force=false] Force destroy the pool + */ +Server.prototype.destroy = function(options) { + options = options || {}; + var self = this; + + // Set the connections + if(serverAccounting) delete servers[this.id]; + + // Destroy the monitoring process if any + if(this.monitoringProcessId) { + clearTimeout(this.monitoringProcessId); + } + + // No pool, return + if(!self.s.pool) return; + + // Emit close event + if(options.emitClose) { + self.emit('close', self); + } + + // Emit destroy event + if(options.emitDestroy) { + self.emit('destroy', self); + } + + // Remove all listeners + listeners.forEach(function(event) { + self.s.pool.removeAllListeners(event); + }); + + // Emit opening server event + if(self.listeners('serverClosed').length > 0) self.emit('serverClosed', { + topologyId: self.s.topologyId != -1 ? self.s.topologyId : self.id, address: self.name + }); + + // Emit toplogy opening event if not in topology + if(self.listeners('topologyClosed').length > 0 && !self.s.inTopology) { + self.emit('topologyClosed', { topologyId: self.id }); + } + + if(self.s.logger.isDebug()) { + self.s.logger.debug(f('destroy called on server %s', self.name)); + } + + // Destroy the pool + this.s.pool.destroy(options.force); +} + +/** + * A server connect event, used to verify that the connection is up and running + * + * @event Server#connect + * @type {Server} + */ + +/** + * A server reconnect event, used to verify that the server topology has reconnected + * + * @event Server#reconnect + * @type {Server} + */ + +/** + * A server opening SDAM monitoring event + * + * @event Server#serverOpening + * @type {object} + */ + +/** + * A server closed SDAM monitoring event + * + * @event Server#serverClosed + * @type {object} + */ + +/** + * A server description SDAM change monitoring event + * + * @event Server#serverDescriptionChanged + * @type {object} + */ + +/** + * A topology open SDAM event + * + * @event Server#topologyOpening + * @type {object} + */ + +/** + * A topology closed SDAM event + * + * @event Server#topologyClosed + * @type {object} + */ + +/** + * A topology structure SDAM change event + * + * @event Server#topologyDescriptionChanged + * @type {object} + */ + +/** + * Server reconnect failed + * + * @event Server#reconnectFailed + * @type {Error} + */ + +/** + * Server connection pool closed + * + * @event Server#close + * @type {object} + */ + +/** + * Server connection pool caused an error + * + * @event Server#error + * @type {Error} + */ + +/** + * Server destroyed was called + * + * @event Server#destroy + * @type {Server} + */ + +module.exports = Server; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/shared.js b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/shared.js new file mode 100644 index 0000000..23f7fad --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/shared.js @@ -0,0 +1,334 @@ +"use strict" + +var os = require('os'), + f = require('util').format; + +/** + * Emit event if it exists + * @method + */ +function emitSDAMEvent(self, event, description) { + if(self.listeners(event).length > 0) { + self.emit(event, description); + } +} + +// Get package.json variable +var driverVersion = require('../../package.json').version; +var nodejsversion = f('Node.js %s, %s', process.version, os.endianness()); +var type = os.type(); +var name = process.platform; +var architecture = process.arch; +var release = os.release(); + +function createClientInfo(options) { + // Build default client information + var clientInfo = options.clientInfo ? clone(options.clientInfo) : { + driver: { + name: "nodejs-core", + version: driverVersion + }, + os: { + type: type, + name: name, + architecture: architecture, + version: release + } + } + + // Is platform specified + if(clientInfo.platform && clientInfo.platform.indexOf('mongodb-core') == -1) { + clientInfo.platform = f('%s, mongodb-core: %s', clientInfo.platform, driverVersion); + } else if(!clientInfo.platform){ + clientInfo.platform = nodejsversion; + } + + // Do we have an application specific string + if(options.appname) { + // Cut at 128 bytes + var buffer = new Buffer(options.appname); + // Return the truncated appname + var appname = buffer.length > 128 ? buffer.slice(0, 128).toString('utf8') : options.appname; + // Add to the clientInfo + clientInfo.application = { name: appname }; + } + + return clientInfo; +} + +function clone(object) { + return JSON.parse(JSON.stringify(object)); +} + +var getPreviousDescription = function(self) { + if(!self.s.serverDescription) { + self.s.serverDescription = { + address: self.name, + arbiters: [], hosts: [], passives: [], type: 'Unknown' + } + } + + return self.s.serverDescription; +} + +var emitServerDescriptionChanged = function(self, description) { + if(self.listeners('serverDescriptionChanged').length > 0) { + // Emit the server description changed events + self.emit('serverDescriptionChanged', { + topologyId: self.s.topologyId != -1 ? self.s.topologyId : self.id, address: self.name, + previousDescription: getPreviousDescription(self), + newDescription: description + }); + + self.s.serverDescription = description; + } +} + +var getPreviousTopologyDescription = function(self) { + if(!self.s.topologyDescription) { + self.s.topologyDescription = { + topologyType: 'Unknown', + servers: [{ + address: self.name, arbiters: [], hosts: [], passives: [], type: 'Unknown' + }] + } + } + + return self.s.topologyDescription; +} + +var emitTopologyDescriptionChanged = function(self, description) { + if(self.listeners('topologyDescriptionChanged').length > 0) { + // Emit the server description changed events + self.emit('topologyDescriptionChanged', { + topologyId: self.s.topologyId != -1 ? self.s.topologyId : self.id, address: self.name, + previousDescription: getPreviousTopologyDescription(self), + newDescription: description + }); + + self.s.serverDescription = description; + } +} + +var changedIsMaster = function(self, currentIsmaster, ismaster) { + var currentType = getTopologyType(self, currentIsmaster); + var newType = getTopologyType(self, ismaster); + if(newType != currentType) return true; + return false; +} + +var getTopologyType = function(self, ismaster) { + if(!ismaster) { + ismaster = self.ismaster; + } + + if(!ismaster) return 'Unknown'; + if(ismaster.ismaster && ismaster.msg == 'isdbgrid') return 'Mongos'; + if(ismaster.ismaster && !ismaster.hosts) return 'Standalone'; + if(ismaster.ismaster) return 'RSPrimary'; + if(ismaster.secondary) return 'RSSecondary'; + if(ismaster.arbiterOnly) return 'RSArbiter'; + return 'Unknown'; +} + +var inquireServerState = function(self) { + return function(callback) { + if(self.s.state == 'destroyed') return; + // Record response time + var start = new Date().getTime(); + + // emitSDAMEvent + emitSDAMEvent(self, 'serverHeartbeatStarted', { connectionId: self.name }); + + // Attempt to execute ismaster command + self.command('admin.$cmd', { ismaster:true }, { monitoring:true }, function(err, r) { + if(!err) { + // Legacy event sender + self.emit('ismaster', r, self); + + // Calculate latencyMS + var latencyMS = new Date().getTime() - start; + + // Server heart beat event + emitSDAMEvent(self, 'serverHeartbeatSucceeded', { durationMS: latencyMS, reply: r.result, connectionId: self.name }); + + // Did the server change + if(changedIsMaster(self, self.s.ismaster, r.result)) { + // Emit server description changed if something listening + emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: !self.s.inTopology ? 'Standalone' : getTopologyType(self) + }); + } + + // Updat ismaster view + self.s.ismaster = r.result; + + // Set server response time + self.s.isMasterLatencyMS = latencyMS; + } else { + emitSDAMEvent(self, 'serverHeartbeatFailed', { durationMS: latencyMS, failure: err, connectionId: self.name }); + } + + // Peforming an ismaster monitoring callback operation + if(typeof callback == 'function') { + return callback(err, r); + } + + // Perform another sweep + self.s.inquireServerStateTimeout = setTimeout(inquireServerState(self), self.s.haInterval); + }); + }; +} + +// +// Clone the options +var cloneOptions = function(options) { + var opts = {}; + for(var name in options) { + opts[name] = options[name]; + } + return opts; +} + +function Interval(fn, time) { + var timer = false; + + this.start = function () { + if (!this.isRunning()) { + timer = setInterval(fn, time); + } + + return this; + }; + + this.stop = function () { + clearInterval(timer); + timer = false; + return this; + }; + + this.isRunning = function () { + return timer !== false; + }; +} + +function Timeout(fn, time) { + var timer = false; + + this.start = function () { + if (!this.isRunning()) { + timer = setTimeout(function() { + fn(); + if (timer && timer._called === undefined) { + // The artificial _called is set here for compatibility with node.js 0.10.x/0.12.x versions + timer._called = true; + } + }, time); + } + return this; + }; + + this.stop = function () { + clearTimeout(timer); + timer = false; + return this; + }; + + this.isRunning = function () { + if(timer && timer._called) return false; + return timer !== false; + }; +} + +function diff(previous, current) { + // Difference document + var diff = { + servers: [] + } + + // Previous entry + if(!previous) { + previous = { servers: [] }; + } + + // Check if we have any previous servers missing in the current ones + for(var i = 0; i < previous.servers.length; i++) { + var found = false; + + for(var j = 0; j < current.servers.length; j++) { + if(current.servers[j].address.toLowerCase() + === previous.servers[i].address.toLowerCase()) { + found = true; + break; + } + } + + if(!found) { + // Add to the diff + diff.servers.push({ + address: previous.servers[i].address, + from: previous.servers[i].type, + to: 'Unknown', + }); + } + } + + // Check if there are any severs that don't exist + for(var j = 0; j < current.servers.length; j++) { + var found = false; + + // Go over all the previous servers + for(var i = 0; i < previous.servers.length; i++) { + if(previous.servers[i].address.toLowerCase() + === current.servers[j].address.toLowerCase()) { + found = true; + break; + } + } + + // Add the server to the diff + if(!found) { + diff.servers.push({ + address: current.servers[j].address, + from: 'Unknown', + to: current.servers[j].type, + }); + } + } + + // Got through all the servers + for(var i = 0; i < previous.servers.length; i++) { + var prevServer = previous.servers[i]; + + // Go through all current servers + for(var j = 0; j < current.servers.length; j++) { + var currServer = current.servers[j]; + + // Matching server + if(prevServer.address.toLowerCase() === currServer.address.toLowerCase()) { + // We had a change in state + if(prevServer.type != currServer.type) { + diff.servers.push({ + address: prevServer.address, + from: prevServer.type, + to: currServer.type + }); + } + } + } + } + + // Return difference + return diff; +} + +module.exports.inquireServerState = inquireServerState +module.exports.getTopologyType = getTopologyType; +module.exports.emitServerDescriptionChanged = emitServerDescriptionChanged; +module.exports.emitTopologyDescriptionChanged = emitTopologyDescriptionChanged; +module.exports.cloneOptions = cloneOptions; +module.exports.createClientInfo = createClientInfo; +module.exports.clone = clone; +module.exports.diff = diff; +module.exports.Interval = Interval; +module.exports.Timeout = Timeout; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/utils.js b/node_modules/mongoose/node_modules/mongodb-core/lib/utils.js new file mode 100644 index 0000000..afc2ced --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/utils.js @@ -0,0 +1,32 @@ +/** + * Copy the values of all enumerable own properties from one or more + * source objects to a target object. It will return the target object. + */ +var assign = Object.assign ? Object.assign : function assign(target) { + if (target === undefined || target === null) { + throw new TypeError('Cannot convert first argument to object'); + } + + var to = Object(target); + for (var i = 1; i < arguments.length; i++) { + var nextSource = arguments[i]; + if (nextSource === undefined || nextSource === null) { + continue; + } + + var keysArray = Object.keys(Object(nextSource)); + for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { + var nextKey = keysArray[nextIndex]; + var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); + if (desc !== undefined && desc.enumerable) { + to[nextKey] = nextSource[nextKey]; + } + } + } + + return to; +} + +module.exports = { + assign: assign +}; diff --git a/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js similarity index 100% rename from node_modules/mongodb-core/lib/wireprotocol/2_4_support.js rename to node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js new file mode 100644 index 0000000..90e510c --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js @@ -0,0 +1,334 @@ +"use strict"; + +var copy = require('../connection/utils').copy + , retrieveBSON = require('../connection/utils').retrieveBSON + , KillCursor = require('../connection/commands').KillCursor + , GetMore = require('../connection/commands').GetMore + , Query = require('../connection/commands').Query + , f = require('util').format + , MongoError = require('../error') + , getReadPreference = require('./shared').getReadPreference; + +var BSON = retrieveBSON(), + Long = BSON.Long; + +var WireProtocol = function() {} + +// +// Execute a write operation +var executeWrite = function(pool, bson, type, opsField, ns, ops, options, callback) { + if(ops.length == 0) throw new MongoError("insert must contain at least one document"); + if(typeof options == 'function') { + callback = options; + options = {}; + options = options || {}; + } + + // Split the ns up to get db and collection + var p = ns.split("."); + var d = p.shift(); + // Options + var ordered = typeof options.ordered == 'boolean' ? options.ordered : true; + var writeConcern = options.writeConcern; + + // return skeleton + var writeCommand = {}; + writeCommand[type] = p.join('.'); + writeCommand[opsField] = ops; + writeCommand.ordered = ordered; + + // Did we specify a write concern + if(writeConcern && Object.keys(writeConcern).length > 0) { + writeCommand.writeConcern = writeConcern; + } + + // Do we have bypassDocumentValidation set, then enable it on the write command + if(typeof options.bypassDocumentValidation == 'boolean') { + writeCommand.bypassDocumentValidation = options.bypassDocumentValidation; + } + + // Options object + var opts = { command: true }; + var queryOptions = { checkKeys : false, numberToSkip: 0, numberToReturn: 1 }; + if(type == 'insert') queryOptions.checkKeys = true; + if(typeof options.checkKeys == 'boolean') queryOptions.checkKeys = options.checkKeys; + // Ensure we support serialization of functions + if(options.serializeFunctions) queryOptions.serializeFunctions = options.serializeFunctions; + // Do not serialize the undefined fields + if(options.ignoreUndefined) queryOptions.ignoreUndefined = options.ignoreUndefined; + + try { + // Create write command + var cmd = new Query(bson, f("%s.$cmd", d), writeCommand, queryOptions); + // Execute command + pool.write(cmd, opts, callback); + } catch(err) { + callback(err); + } +} + +// +// Needs to support legacy mass insert as well as ordered/unordered legacy +// emulation +// +WireProtocol.prototype.insert = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'insert', 'documents', ns, ops, options, callback); +} + +WireProtocol.prototype.update = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'update', 'updates', ns, ops, options, callback); +} + +WireProtocol.prototype.remove = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'delete', 'deletes', ns, ops, options, callback); +} + +WireProtocol.prototype.killCursor = function(bson, ns, cursorId, pool, callback) { + // Create a kill cursor command + var killCursor = new KillCursor(bson, [cursorId]); + // Execute the kill cursor command + if(pool && pool.isConnected()) { + pool.write(killCursor, { + immediateRelease:true, noResponse: true + }); + } + + // Callback + if(typeof callback == 'function') callback(null, null); +} + +WireProtocol.prototype.getMore = function(bson, ns, cursorState, batchSize, raw, connection, options, callback) { + // Create getMore command + var getMore = new GetMore(bson, ns, cursorState.cursorId, {numberToReturn: batchSize}); + + // Query callback + var queryCallback = function(err, result) { + if(err) return callback(err); + // Get the raw message + var r = result.message; + + // If we have a timed out query or a cursor that was killed + if((r.responseFlags & (1 << 0)) != 0) { + return callback(new MongoError("cursor does not exist, was killed or timed out"), null); + } + + // Ensure we have a Long valie cursor id + var cursorId = typeof r.cursorId == 'number' + ? Long.fromNumber(r.cursorId) + : r.cursorId; + + // Set all the values + cursorState.documents = r.documents; + cursorState.cursorId = cursorId; + + // Return + callback(null, null, r.connection); + } + + // Contains any query options + var queryOptions = {}; + + // If we have a raw query decorate the function + if(raw) { + queryOptions.raw = raw; + } + + // Check if we need to promote longs + if(typeof cursorState.promoteLongs == 'boolean') { + queryOptions.promoteLongs = cursorState.promoteLongs; + } + + if(typeof cursorState.promoteValues == 'boolean') { + queryOptions.promoteValues = cursorState.promoteValues; + } + + if(typeof cursorState.promoteBuffers == 'boolean') { + queryOptions.promoteBuffers = cursorState.promoteBuffers; + } + + // Write out the getMore command + connection.write(getMore, queryOptions, queryCallback); +} + +WireProtocol.prototype.command = function(bson, ns, cmd, cursorState, topology, options) { + // Establish type of command + if(cmd.find) { + return setupClassicFind(bson, ns, cmd, cursorState, topology, options) + } else if(cursorState.cursorId != null) { + return; + } else if(cmd) { + return setupCommand(bson, ns, cmd, cursorState, topology, options); + } else { + throw new MongoError(f("command %s does not return a cursor", JSON.stringify(cmd))); + } +} + +// +// Execute a find command +var setupClassicFind = function(bson, ns, cmd, cursorState, topology, options) { + // Ensure we have at least some options + options = options || {}; + // Get the readPreference + var readPreference = getReadPreference(cmd, options); + // Set the optional batchSize + cursorState.batchSize = cmd.batchSize || cursorState.batchSize; + var numberToReturn = 0; + + // Unpack the limit and batchSize values + if(cursorState.limit == 0) { + numberToReturn = cursorState.batchSize; + } else if(cursorState.limit < 0 || cursorState.limit < cursorState.batchSize || (cursorState.limit > 0 && cursorState.batchSize == 0)) { + numberToReturn = cursorState.limit; + } else { + numberToReturn = cursorState.batchSize; + } + + var numberToSkip = cursorState.skip || 0; + // Build actual find command + var findCmd = {}; + // Using special modifier + var usesSpecialModifier = false; + + // We have a Mongos topology, check if we need to add a readPreference + if(topology.type == 'mongos' && readPreference) { + findCmd['$readPreference'] = readPreference.toJSON(); + usesSpecialModifier = true; + } + + // Add special modifiers to the query + if(cmd.sort) findCmd['orderby'] = cmd.sort, usesSpecialModifier = true; + if(cmd.hint) findCmd['$hint'] = cmd.hint, usesSpecialModifier = true; + if(cmd.snapshot) findCmd['$snapshot'] = cmd.snapshot, usesSpecialModifier = true; + if(cmd.returnKey) findCmd['$returnKey'] = cmd.returnKey, usesSpecialModifier = true; + if(cmd.maxScan) findCmd['$maxScan'] = cmd.maxScan, usesSpecialModifier = true; + if(cmd.min) findCmd['$min'] = cmd.min, usesSpecialModifier = true; + if(cmd.max) findCmd['$max'] = cmd.max, usesSpecialModifier = true; + if(cmd.showDiskLoc) findCmd['$showDiskLoc'] = cmd.showDiskLoc, usesSpecialModifier = true; + if(cmd.comment) findCmd['$comment'] = cmd.comment, usesSpecialModifier = true; + if(cmd.maxTimeMS) findCmd['$maxTimeMS'] = cmd.maxTimeMS, usesSpecialModifier = true; + + if(cmd.explain) { + // nToReturn must be 0 (match all) or negative (match N and close cursor) + // nToReturn > 0 will give explain results equivalent to limit(0) + numberToReturn = -Math.abs(cmd.limit || 0); + usesSpecialModifier = true; + findCmd['$explain'] = true; + } + + // If we have a special modifier + if(usesSpecialModifier) { + findCmd['$query'] = cmd.query; + } else { + findCmd = cmd.query; + } + + // Throw on majority readConcern passed in + if(cmd.readConcern && cmd.readConcern.level != 'local') { + throw new MongoError(f('server find command does not support a readConcern level of %s', cmd.readConcern.level)); + } + + // Remove readConcern, ensure no failing commands + if(cmd.readConcern) { + cmd = copy(cmd); + delete cmd['readConcern']; + } + + // Serialize functions + var serializeFunctions = typeof options.serializeFunctions == 'boolean' + ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' + ? options.ignoreUndefined : false; + + // Build Query object + var query = new Query(bson, ns, findCmd, { + numberToSkip: numberToSkip, numberToReturn: numberToReturn + , checkKeys: false, returnFieldSelector: cmd.fields + , serializeFunctions: serializeFunctions + , ignoreUndefined: ignoreUndefined + }); + + // Set query flags + query.slaveOk = readPreference.slaveOk(); + + // Set up the option bits for wire protocol + if(typeof cmd.tailable == 'boolean') { + query.tailable = cmd.tailable; + } + + if(typeof cmd.oplogReplay == 'boolean') { + query.oplogReplay = cmd.oplogReplay; + } + + if(typeof cmd.noCursorTimeout == 'boolean') { + query.noCursorTimeout = cmd.noCursorTimeout; + } + + if(typeof cmd.awaitData == 'boolean') { + query.awaitData = cmd.awaitData; + } + + if(typeof cmd.partial == 'boolean') { + query.partial = cmd.partial; + } + + // Return the query + return query; +} + +// +// Set up a command cursor +var setupCommand = function(bson, ns, cmd, cursorState, topology, options) { + // Set empty options object + options = options || {} + // Get the readPreference + var readPreference = getReadPreference(cmd, options); + + // Final query + var finalCmd = {}; + for(var name in cmd) { + finalCmd[name] = cmd[name]; + } + + // Build command namespace + var parts = ns.split(/\./); + + // Serialize functions + var serializeFunctions = typeof options.serializeFunctions == 'boolean' + ? options.serializeFunctions : false; + + var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' + ? options.ignoreUndefined : false; + + // Throw on majority readConcern passed in + if(cmd.readConcern && cmd.readConcern.level != 'local') { + throw new MongoError(f('server %s command does not support a readConcern level of %s', JSON.stringify(cmd), cmd.readConcern.level)); + } + + // Remove readConcern, ensure no failing commands + if(cmd.readConcern) delete cmd['readConcern']; + + // We have a Mongos topology, check if we need to add a readPreference + if(topology.type == 'mongos' + && readPreference + && readPreference.preference != 'primary') { + finalCmd = { + '$query': finalCmd, + '$readPreference': readPreference.toJSON() + }; + } + + // Build Query object + var query = new Query(bson, f('%s.$cmd', parts.shift()), finalCmd, { + numberToSkip: 0, numberToReturn: -1 + , checkKeys: false, serializeFunctions: serializeFunctions + , ignoreUndefined: ignoreUndefined + }); + + // Set query flags + query.slaveOk = readPreference.slaveOk(); + + // Return the query + return query; +} + +module.exports = WireProtocol; diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js new file mode 100644 index 0000000..c48857b --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js @@ -0,0 +1,549 @@ +"use strict"; + +var Query = require('../connection/commands').Query + , retrieveBSON = require('../connection/utils').retrieveBSON + , f = require('util').format + , MongoError = require('../error') + , getReadPreference = require('./shared').getReadPreference; + +var BSON = retrieveBSON(), + Long = BSON.Long; + +var WireProtocol = function(legacyWireProtocol) { + this.legacyWireProtocol = legacyWireProtocol; +} + +// +// Execute a write operation +var executeWrite = function(pool, bson, type, opsField, ns, ops, options, callback) { + if(ops.length == 0) throw new MongoError("insert must contain at least one document"); + if(typeof options == 'function') { + callback = options; + options = {}; + options = options || {}; + } + + // Split the ns up to get db and collection + var p = ns.split("."); + var d = p.shift(); + // Options + var ordered = typeof options.ordered == 'boolean' ? options.ordered : true; + var writeConcern = options.writeConcern; + + // return skeleton + var writeCommand = {}; + writeCommand[type] = p.join('.'); + writeCommand[opsField] = ops; + writeCommand.ordered = ordered; + + // Did we specify a write concern + if(writeConcern && Object.keys(writeConcern).length > 0) { + writeCommand.writeConcern = writeConcern; + } + + // If we have collation passed in + if(options.collation) { + for(var i = 0; i < writeCommand[opsField].length; i++) { + if(!writeCommand[opsField][i].collation) { + writeCommand[opsField][i].collation = options.collation; + } + } + } + + // Do we have bypassDocumentValidation set, then enable it on the write command + if(typeof options.bypassDocumentValidation == 'boolean') { + writeCommand.bypassDocumentValidation = options.bypassDocumentValidation; + } + + // Options object + var opts = { command: true }; + var queryOptions = { checkKeys : false, numberToSkip: 0, numberToReturn: 1 }; + if(type == 'insert') queryOptions.checkKeys = true; + if(typeof options.checkKeys == 'boolean') queryOptions.checkKeys = options.checkKeys; + + // Ensure we support serialization of functions + if(options.serializeFunctions) queryOptions.serializeFunctions = options.serializeFunctions; + // Do not serialize the undefined fields + if(options.ignoreUndefined) queryOptions.ignoreUndefined = options.ignoreUndefined; + + try { + // Create write command + var cmd = new Query(bson, f("%s.$cmd", d), writeCommand, queryOptions); + // Execute command + pool.write(cmd, opts, callback); + } catch(err) { + callback(err); + } +} + +// +// Needs to support legacy mass insert as well as ordered/unordered legacy +// emulation +// +WireProtocol.prototype.insert = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'insert', 'documents', ns, ops, options, callback); +} + +WireProtocol.prototype.update = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'update', 'updates', ns, ops, options, callback); +} + +WireProtocol.prototype.remove = function(pool, ismaster, ns, bson, ops, options, callback) { + executeWrite(pool, bson, 'delete', 'deletes', ns, ops, options, callback); +} + +WireProtocol.prototype.killCursor = function(bson, ns, cursorId, pool, callback) { + // Build command namespace + var parts = ns.split(/\./); + // Command namespace + var commandns = f('%s.$cmd', parts.shift()); + // Create getMore command + var killcursorCmd = { + killCursors: parts.join('.'), + cursors: [cursorId] + } + + // Build Query object + var query = new Query(bson, commandns, killcursorCmd, { + numberToSkip: 0, numberToReturn: -1 + , checkKeys: false, returnFieldSelector: null + }); + + // Set query flags + query.slaveOk = true; + + // Kill cursor callback + var killCursorCallback = function(err, result) { + if(err) { + if(typeof callback != 'function') return; + return callback(err); + } + + // Result + var r = result.message; + // If we have a timed out query or a cursor that was killed + if((r.responseFlags & (1 << 0)) != 0) { + if(typeof callback != 'function') return; + return callback(new MongoError("cursor killed or timed out"), null); + } + + if(!Array.isArray(r.documents) || r.documents.length == 0) { + if(typeof callback != 'function') return; + return callback(new MongoError(f('invalid killCursors result returned for cursor id %s', cursorId))); + } + + // Return the result + if(typeof callback == 'function') { + callback(null, r.documents[0]); + } + } + + // Execute the kill cursor command + if(pool && pool.isConnected()) { + pool.write(query, { + command: true + }, killCursorCallback); + } +} + +WireProtocol.prototype.getMore = function(bson, ns, cursorState, batchSize, raw, connection, options, callback) { + options = options || {}; + // Build command namespace + var parts = ns.split(/\./); + // Command namespace + var commandns = f('%s.$cmd', parts.shift()); + + // Create getMore command + var getMoreCmd = { + getMore: cursorState.cursorId, + collection: parts.join('.'), + batchSize: Math.abs(batchSize) + } + + if(cursorState.cmd.tailable + && typeof cursorState.cmd.maxAwaitTimeMS == 'number') { + getMoreCmd.maxTimeMS = cursorState.cmd.maxAwaitTimeMS; + } + + // Build Query object + var query = new Query(bson, commandns, getMoreCmd, { + numberToSkip: 0, numberToReturn: -1 + , checkKeys: false, returnFieldSelector: null + }); + + // Set query flags + query.slaveOk = true; + + // Query callback + var queryCallback = function(err, result) { + if(err) return callback(err); + // Get the raw message + var r = result.message; + + // If we have a timed out query or a cursor that was killed + if((r.responseFlags & (1 << 0)) != 0) { + return callback(new MongoError("cursor killed or timed out"), null); + } + + // Raw, return all the extracted documents + if(raw) { + cursorState.documents = r.documents; + cursorState.cursorId = r.cursorId; + return callback(null, r.documents); + } + + // We have an error detected + if(r.documents[0].ok == 0) { + return callback(MongoError.create(r.documents[0])); + } + + // Ensure we have a Long valid cursor id + var cursorId = typeof r.documents[0].cursor.id == 'number' + ? Long.fromNumber(r.documents[0].cursor.id) + : r.documents[0].cursor.id; + + // Set all the values + cursorState.documents = r.documents[0].cursor.nextBatch; + cursorState.cursorId = cursorId; + + // Return the result + callback(null, r.documents[0], r.connection); + } + + // Query options + var queryOptions = { command: true }; + + // If we have a raw query decorate the function + if(raw) { + queryOptions.raw = raw; + } + + // Add the result field needed + queryOptions.documentsReturnedIn = 'nextBatch'; + + // Check if we need to promote longs + if(typeof cursorState.promoteLongs == 'boolean') { + queryOptions.promoteLongs = cursorState.promoteLongs; + } + + if(typeof cursorState.promoteValues == 'boolean') { + queryOptions.promoteValues = cursorState.promoteValues; + } + + if(typeof cursorState.promoteBuffers == 'boolean') { + queryOptions.promoteBuffers = cursorState.promoteBuffers; + } + + // Write out the getMore command + connection.write(query, queryOptions, queryCallback); +} + +WireProtocol.prototype.command = function(bson, ns, cmd, cursorState, topology, options) { + options = options || {} + // Check if this is a wire protocol command or not + var wireProtocolCommand = typeof options.wireProtocolCommand == 'boolean' ? options.wireProtocolCommand : true; + + // Establish type of command + if(cmd.find && wireProtocolCommand) { + // Create the find command + var query = executeFindCommand(bson, ns, cmd, cursorState, topology, options) + // Mark the cmd as virtual + cmd.virtual = false; + // Signal the documents are in the firstBatch value + query.documentsReturnedIn = 'firstBatch'; + // Return the query + return query; + } else if(cursorState.cursorId != null) { + return; + } else if(cmd) { + return setupCommand(bson, ns, cmd, cursorState, topology, options); + } else { + throw new MongoError(f("command %s does not return a cursor", JSON.stringify(cmd))); + } +} + +// // Command +// { +// find: ns +// , query: +// , limit: +// , fields: +// , skip: +// , hint: +// , explain: +// , snapshot: +// , batchSize: +// , returnKey: +// , maxScan: +// , min: +// , max: +// , showDiskLoc: +// , comment: +// , maxTimeMS: +// , raw: +// , readPreference: +// , tailable: +// , oplogReplay: +// , noCursorTimeout: +// , awaitdata: +// , exhaust: +// , partial: +// } + +// FIND/GETMORE SPEC +// { +// “find”: , +// “filter”: { ... }, +// “sort”: { ... }, +// “projection”: { ... }, +// “hint”: { ... }, +// “skip”: , +// “limit”: , +// “batchSize”: , +// “singleBatch”: , +// “comment”: , +// “maxScan”: , +// “maxTimeMS”: , +// “max”: { ... }, +// “min”: { ... }, +// “returnKey”: , +// “showRecordId”: , +// “snapshot”: , +// “tailable”: , +// “oplogReplay”: , +// “noCursorTimeout”: , +// “awaitData”: , +// “partial”: , +// “$readPreference”: { ... } +// } + +// +// Execute a find command +var executeFindCommand = function(bson, ns, cmd, cursorState, topology, options) { + // Ensure we have at least some options + options = options || {}; + // Get the readPreference + var readPreference = getReadPreference(cmd, options); + // Set the optional batchSize + cursorState.batchSize = cmd.batchSize || cursorState.batchSize; + + // Build command namespace + var parts = ns.split(/\./); + // Command namespace + var commandns = f('%s.$cmd', parts.shift()); + + // Build actual find command + var findCmd = { + find: parts.join('.') + }; + + // I we provided a filter + if(cmd.query) { + // Check if the user is passing in the $query parameter + if(cmd.query['$query']) { + findCmd.filter = cmd.query['$query']; + } else { + findCmd.filter = cmd.query; + } + } + + // Sort value + var sortValue = cmd.sort; + + // Handle issue of sort being an Array + if(Array.isArray(sortValue)) { + var sortObject = {}; + + if(sortValue.length > 0 && !Array.isArray(sortValue[0])) { + var sortDirection = sortValue[1]; + // Translate the sort order text + if(sortDirection == 'asc') { + sortDirection = 1; + } else if(sortDirection == 'desc') { + sortDirection = -1; + } + + // Set the sort order + sortObject[sortValue[0]] = sortDirection; + } else { + for(var i = 0; i < sortValue.length; i++) { + sortDirection = sortValue[i][1]; + // Translate the sort order text + if(sortDirection == 'asc') { + sortDirection = 1; + } else if(sortDirection == 'desc') { + sortDirection = -1; + } + + // Set the sort order + sortObject[sortValue[i][0]] = sortDirection; + } + } + + sortValue = sortObject; + } + + // Add sort to command + if(cmd.sort) findCmd.sort = sortValue; + // Add a projection to the command + if(cmd.fields) findCmd.projection = cmd.fields; + // Add a hint to the command + if(cmd.hint) findCmd.hint = cmd.hint; + // Add a skip + if(cmd.skip) findCmd.skip = cmd.skip; + // Add a limit + if(cmd.limit) findCmd.limit = cmd.limit; + + // Check if we wish to have a singleBatch + if(cmd.limit < 0) { + findCmd.limit = Math.abs(cmd.limit); + findCmd.singleBatch = true; + } + + // Add a batchSize + if(typeof cmd.batchSize == 'number') { + if (cmd.batchSize < 0) { + if (cmd.limit != 0 && Math.abs(cmd.batchSize) < Math.abs(cmd.limit)) { + findCmd.limit = Math.abs(cmd.batchSize); + } + + findCmd.singleBatch = true; + } + + findCmd.batchSize = Math.abs(cmd.batchSize); + } + + // If we have comment set + if(cmd.comment) findCmd.comment = cmd.comment; + + // If we have maxScan + if(cmd.maxScan) findCmd.maxScan = cmd.maxScan; + + // If we have maxTimeMS set + if(cmd.maxTimeMS) findCmd.maxTimeMS = cmd.maxTimeMS; + + // If we have min + if(cmd.min) findCmd.min = cmd.min; + + // If we have max + if(cmd.max) findCmd.max = cmd.max; + + // If we have returnKey set + if(cmd.returnKey) findCmd.returnKey = cmd.returnKey; + + // If we have showDiskLoc set + if(cmd.showDiskLoc) findCmd.showRecordId = cmd.showDiskLoc; + + // If we have snapshot set + if(cmd.snapshot) findCmd.snapshot = cmd.snapshot; + + // If we have tailable set + if(cmd.tailable) findCmd.tailable = cmd.tailable; + + // If we have oplogReplay set + if(cmd.oplogReplay) findCmd.oplogReplay = cmd.oplogReplay; + + // If we have noCursorTimeout set + if(cmd.noCursorTimeout) findCmd.noCursorTimeout = cmd.noCursorTimeout; + + // If we have awaitData set + if(cmd.awaitData) findCmd.awaitData = cmd.awaitData; + if(cmd.awaitdata) findCmd.awaitData = cmd.awaitdata; + + // If we have partial set + if(cmd.partial) findCmd.partial = cmd.partial; + + // If we have collation passed in + if(cmd.collation) findCmd.collation = cmd.collation; + + // If we have explain, we need to rewrite the find command + // to wrap it in the explain command + if(cmd.explain) { + findCmd = { + explain: findCmd + } + } + + // Did we provide a readConcern + if(cmd.readConcern) findCmd.readConcern = cmd.readConcern; + + // Set up the serialize and ignoreUndefined fields + var serializeFunctions = typeof options.serializeFunctions == 'boolean' + ? options.serializeFunctions : false; + var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' + ? options.ignoreUndefined : false; + + // We have a Mongos topology, check if we need to add a readPreference + if(topology.type == 'mongos' + && readPreference + && readPreference.preference != 'primary') { + findCmd = { + '$query': findCmd, + '$readPreference': readPreference.toJSON() + }; + } + + // Build Query object + var query = new Query(bson, commandns, findCmd, { + numberToSkip: 0, numberToReturn: 1 + , checkKeys: false, returnFieldSelector: null + , serializeFunctions: serializeFunctions, ignoreUndefined: ignoreUndefined + }); + + // Set query flags + query.slaveOk = readPreference.slaveOk(); + + // Return the query + return query; +} + +// +// Set up a command cursor +var setupCommand = function(bson, ns, cmd, cursorState, topology, options) { + // Set empty options object + options = options || {} + // Get the readPreference + var readPreference = getReadPreference(cmd, options); + + // Final query + var finalCmd = {}; + for(var name in cmd) { + finalCmd[name] = cmd[name]; + } + + // Build command namespace + var parts = ns.split(/\./); + + // Serialize functions + var serializeFunctions = typeof options.serializeFunctions == 'boolean' + ? options.serializeFunctions : false; + + // Set up the serialize and ignoreUndefined fields + var ignoreUndefined = typeof options.ignoreUndefined == 'boolean' + ? options.ignoreUndefined : false; + + // We have a Mongos topology, check if we need to add a readPreference + if(topology.type == 'mongos' + && readPreference + && readPreference.preference != 'primary') { + finalCmd = { + '$query': finalCmd, + '$readPreference': readPreference.toJSON() + }; + } + + // Build Query object + var query = new Query(bson, f('%s.$cmd', parts.shift()), finalCmd, { + numberToSkip: 0, numberToReturn: -1 + , checkKeys: false, serializeFunctions: serializeFunctions + , ignoreUndefined: ignoreUndefined + }); + + // Set query flags + query.slaveOk = readPreference.slaveOk(); + + // Return the query + return query; +} + +module.exports = WireProtocol; diff --git a/node_modules/mongodb-core/lib/wireprotocol/commands.js b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/commands.js similarity index 100% rename from node_modules/mongodb-core/lib/wireprotocol/commands.js rename to node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/commands.js diff --git a/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/shared.js b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/shared.js new file mode 100644 index 0000000..25bd394 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/shared.js @@ -0,0 +1,27 @@ +"use strict" + +var ReadPreference = require('../topologies/read_preference'), + MongoError = require('../error'); + +var getReadPreference = function(cmd, options) { + // Default to command version of the readPreference + var readPreference = cmd.readPreference || new ReadPreference('primary'); + // If we have an option readPreference override the command one + if(options.readPreference) { + readPreference = options.readPreference; + } + + if(typeof readPreference == 'string') { + readPreference = new ReadPreference(readPreference); + } + + if(!(readPreference instanceof ReadPreference)) { + throw new MongoError('readPreference must be a ReadPreference instance'); + } + + return readPreference; +} + +module.exports = { + getReadPreference: getReadPreference +} diff --git a/node_modules/mongoose/node_modules/mongodb-core/package.json b/node_modules/mongoose/node_modules/mongodb-core/package.json new file mode 100644 index 0000000..b9aa0df --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb-core/package.json @@ -0,0 +1,76 @@ +{ + "_from": "mongodb-core@2.1.18", + "_id": "mongodb-core@2.1.18", + "_inBundle": false, + "_integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=", + "_location": "/mongoose/mongodb-core", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mongodb-core@2.1.18", + "name": "mongodb-core", + "escapedName": "mongodb-core", + "rawSpec": "2.1.18", + "saveSpec": null, + "fetchSpec": "2.1.18" + }, + "_requiredBy": [ + "/mongoose/mongodb" + ], + "_resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz", + "_shasum": "4c46139bdf3a1f032ded91db49f38eec01659050", + "_spec": "mongodb-core@2.1.18", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose/node_modules/mongodb", + "author": { + "name": "Christian Kvalheim" + }, + "bugs": { + "url": "https://github.com/christkv/mongodb-core/issues" + }, + "bundleDependencies": false, + "dependencies": { + "bson": "~1.0.4", + "require_optional": "~1.0.0" + }, + "deprecated": false, + "description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications", + "devDependencies": { + "co": "^4.5.4", + "coveralls": "^2.11.6", + "es6-promise": "^3.0.2", + "gleak": "0.5.0", + "integra": "0.1.8", + "jsdoc": "3.3.0-alpha8", + "mkdirp": "0.5.0", + "mongodb-topology-manager": "1.0.x", + "mongodb-version-manager": "github:christkv/mongodb-version-manager#master", + "nyc": "^5.5.0", + "optimist": "latest", + "request": "2.65.0", + "rimraf": "2.2.6", + "semver": "4.1.0" + }, + "homepage": "https://github.com/christkv/mongodb-core", + "keywords": [ + "mongodb", + "core" + ], + "license": "Apache-2.0", + "main": "index.js", + "name": "mongodb-core", + "peerOptionalDependencies": { + "kerberos": "~0.0", + "bson-ext": "1.0.5" + }, + "repository": { + "type": "git", + "url": "git://github.com/christkv/mongodb-core.git" + }, + "scripts": { + "coverage": "nyc node test/runner.js -t functional -l && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls", + "lint": "eslint lib", + "test": "node test/runner.js -t functional" + }, + "version": "2.1.18" +} diff --git a/node_modules/mongodb-core/test.js b/node_modules/mongoose/node_modules/mongodb-core/test.js similarity index 100% rename from node_modules/mongodb-core/test.js rename to node_modules/mongoose/node_modules/mongodb-core/test.js diff --git a/node_modules/mongodb-core/test1.js b/node_modules/mongoose/node_modules/mongodb-core/test1.js similarity index 100% rename from node_modules/mongodb-core/test1.js rename to node_modules/mongoose/node_modules/mongodb-core/test1.js diff --git a/node_modules/mongodb/.coveralls.yml b/node_modules/mongoose/node_modules/mongodb/.coveralls.yml similarity index 100% rename from node_modules/mongodb/.coveralls.yml rename to node_modules/mongoose/node_modules/mongodb/.coveralls.yml diff --git a/node_modules/mongoose/node_modules/mongodb/.eslintrc b/node_modules/mongoose/node_modules/mongodb/.eslintrc new file mode 100644 index 0000000..753e2a5 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/.eslintrc @@ -0,0 +1,15 @@ +{ + "extends": ["eslint:recommended"], + "env": { + "node": true, + "mocha": true + }, + "ecmaFeatures": { + "es6": true, + }, + "plugins": [ + ], + "rules": { + "no-console":0 + } +} diff --git a/node_modules/mongoose/node_modules/mongodb/HISTORY.md b/node_modules/mongoose/node_modules/mongodb/HISTORY.md new file mode 100644 index 0000000..3c5bd16 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/HISTORY.md @@ -0,0 +1,1767 @@ + +## [2.2.34](https://github.com/mongodb/node-mongodb-native/compare/v2.2.33...v2.2.34) (2018-01-03) + + +### Bug Fixes + +* **collection:** allow { upsert: 1 } for findOneAndUpdate() and update() ([#1580](https://github.com/mongodb/node-mongodb-native/issues/1580)) ([0f338c8](https://github.com/mongodb/node-mongodb-native/commit/0f338c8)), closes [Automattic/mongoose#5839](https://github.com/Automattic/mongoose/issues/5839) +* **GridFS:** fix TypeError: doc.data.length is not a function ([811de0c](https://github.com/mongodb/node-mongodb-native/commit/811de0c)) +* **import:** adds missing import to lib/authenticate.js ([10db9a2](https://github.com/mongodb/node-mongodb-native/commit/10db9a2)) +* **list-collections:** ensure default of primary ReadPreference ([0935306](https://github.com/mongodb/node-mongodb-native/commit/0935306)) + + +### Features + +* **ssl:** adds missing ssl options ssl options for `ciphers` and `ecdhCurve` ([bd4fb53](https://github.com/mongodb/node-mongodb-native/commit/bd4fb53)) +* **url parser:** add dns seedlist support ([2d357bc](https://github.com/mongodb/node-mongodb-native/commit/2d357bc)) +* **core**: update mongodb-core to 2.1.18 + + +2.2.33 2017-10-12 +----------------- +* update to mongodb-core 2.1.17 + +2.2.32 2017-10-11 +----------------- +* update to mongodb-core 2.1.16 +* ensure that the `cursor` key is always present in aggregation commands +* `Cursor.prototype.hasNext` now propagates errors when using callback +* allow passing `noCursorTimeout` as an option to `find()` +* bubble up `reconnectFailed` event from Server topology + +2.2.31 2017-08-08 +----------------- +* update mongodb-core to 2.1.15 +* allow auth option in MongoClient.connect +* remove duplicate option `promoteLongs` from MongoClient's `connect` +* bulk operations should not throw an error on empty batch + +2.2.30 2017-07-07 +----------------- +* Update mongodb-core to 2.1.14 +* MongoClient + * add `appname` to list of valid option names + * added test for passing appname as option +* NODE-1052 ensure user options are applied while parsing connection string uris + +2.2.29 2017-06-19 +----------------- +* Update mongodb-core to 2.1.13 + * NODE-1039 ensure we force destroy server instances, forcing queue to be flushed. + * Use actual server type in standalone SDAM events. +* Allow multiple map calls (Issue #1521, https://github.com/Robbilie). +* Clone insertMany options before mutating (Issue #1522, https://github.com/vkarpov15). +* NODE-1034 Fix GridStore issue caused by Node 8.0.0 breaking backward compatible fs.read API. +* NODE-1026, use operator instead of skip function in order to avoid useless fetch stage. + +2.2.28 2017-06-02 +----------------- +* Update mongodb-core to 2.1.12 + * NODE-1019 Set keepAlive to 300 seconds or 1/2 of socketTimeout if socketTimeout < keepAlive. + * Minor fix to report the correct state on error. + * NODE-1020 'family' was added to options to provide high priority for ipv6 addresses (Issue #1518, https://github.com/firej). + * Fix require_optional loading of bson-ext. + * Ensure no errors are thrown by replset if topology is destroyed before it finished connecting. + * NODE-999 SDAM fixes for Mongos and single Server event emitting. + * NODE-1014 Set socketTimeout to default to 360 seconds. + * NODE-1019 Set keepAlive to 300 seconds or 1/2 of socketTimeout if socketTimeout < keepAlive. +* Just handle Collection name errors distinctly from general callback errors avoiding double callbacks in Db.collection. +* NODE-999 SDAM fixes for Mongos and single Server event emitting. +* NODE-1000 Added guard condition for upload.js checkDone function in case of race condition caused by late arriving chunk write. + +2.2.27 2017-05-22 +----------------- +* Updated mongodb-core to 2.1.11 + * NODE-987 Clear out old intervalIds on when calling topologyMonitor. + * NODE-987 Moved filtering to pingServer method and added test case. + * Check for connection destroyed just before writing out and flush out operations correctly if it is (Issue #179, https://github.com/jmholzinger). + * NODE-989 Refactored Replicaset monitoring to correcly monitor newly added servers, Also extracted setTimeout and setInterval to use custom wrappers Timeout and Interval. +* NODE-985 Deprecated Db.authenticate and Admin.authenticate and moved auth methods into authenticate.js to ensure MongoClient.connect does not print deprecation warnings. +* NODE-988 Merged readConcern and hint correctly on collection(...).find(...).count() +* Fix passing the readConcern option to MongoClient.connect (Issue #1514, https://github.com/bausmeier). +* NODE-996 Propegate all events up to a MongoClient instance. +* Allow saving doc with null `_id` (Issue #1517, https://github.com/vkarpov15). +* NODE-993 Expose hasNext for command cursor and add docs for both CommandCursor and Aggregation Cursor. + +2.2.26 2017-04-18 +----------------- +* Updated mongodb-core to 2.1.10 + * NODE-981 delegate auth to replset/mongos if inTopology is set. + * NODE-978 Wrap connection.end in try/catch for node 0.10.x issue causing exceptions to be thrown, Also surfaced getConnection for mongos and replset. + * Remove dynamic require (Issue #175, https://github.com/tellnes). + * NODE-696 Handle interrupted error for createIndexes. + * Fixed isse when user is executing find command using Server.command and it get interpreted as a wire protcol message, #172. + * NODE-966 promoteValues not being promoted correctly to getMore. + * Merged in fix for flushing out monitoring operations. +* NODE-983 Add cursorId to aggregate and listCollections commands (Issue, #1510). +* Mark group and profilingInfo as deprecated methods +* NODE-956 DOCS Examples. +* Update readable-stream to version 2.2.7. +* NODE-978 Added test case to uncover connection.end issue for node 0.10.x. +* NODE-972 Fix(db): don't remove database name if collectionName == dbName (Issue, #1502) +* Fixed merging of writeConcerns on db.collection method. +* NODE-970 mix in readPreference for strict mode listCollections callback. +* NODE-966 added testcase for promoteValues being applied to getMore commands. +* NODE-962 Merge in ignoreUndefined from collection level for find/findOne. +* Remove multi option from updateMany tests/docs (Issue #1499, https://github.com/spratt). +* NODE-963 Correctly handle cursor.count when using APM. + +2.2.25 2017-03-17 +----------------- +* Don't rely on global toString() for checking if object (Issue #1494, https://github.com/vkarpov15). +* Remove obsolete option uri_decode_auth (Issue #1488, https://github.com/kamagatos). +* NODE-936 Correctly translate ReadPreference to CoreReadPreference for mongos queries. +* Exposed BSONRegExp type. +* NODE-950 push correct index for INSERT ops (https://github.com/mbroadst). +* NODE-951 Added support for sslCRL option and added a test case for it. +* NODE-953 Made batchSize issue general at cursor level. +* NODE-954 Remove write concern from reindex helper as it will not be supported in 3.6. +* Updated mongodb-core to 2.1.9. + * Return lastIsMaster correctly when connecting with secondaryOnlyConnectionAllowed is set to true and only a secondary is available in replica state. + * Clone options when passed to wireProtocol handler to avoid intermittent modifications causing errors. + * Ensure SSL error propegates better for Replset connections when there is a SSL validation error. + * NODE-957 Fixed issue where < batchSize not causing cursor to be closed on execution of first batch. + * NODE-958 Store reconnectConnection on pool object to allow destroy to close immediately. + +2.2.24 2017-02-14 +----------------- +* NODE-935, NODE-931 Make MongoClient strict options validation optional and instead print annoying console.warn entries. + +2.2.23 2017-02-13 +----------------- +* Updated mongodb-core to 2.1.8. + * NODE-925 ensure we reschedule operations while pool is < poolSize while pool is growing and there are no connections with not currently performing work. + * NODE-927 fixes issue where authentication was performed against arbiter instances. + * NODE-915 Normalize all host names to avoid comparison issues. + * Fixed issue where pool.destroy would never finish due to a single operation not being executed and keeping it open. +* NODE-931 Validates all the options for MongoClient.connect and fixes missing connection settings. +* NODE-929 Update SSL tutorial to correctly reflect the non-need for server/mongos/replset subobjects +* Fix sensitive command check (Issue #1473, https://github.com/Annoraaq) + +2.2.22 2017-01-24 +----------------- +* Updated mongodb-core to 2.1.7. + * NODE-919 ReplicaSet connection does not close immediately (Issue #156). + * NODE-901 Fixed bug when normalizing host names. + * NODE-909 Fixed readPreference issue caused by direct connection to primary. + * NODE-910 Fixed issue when bufferMaxEntries == 0 and read preference set to nearest. +* Add missing unref implementations for replset, mongos (Issue #1455, https://github.com/zbjornson) + +2.2.21 2017-01-13 +----------------- +* Updated mongodb-core to 2.1.6. + * NODE-908 Keep auth contexts in replset and mongos topology to ensure correct application of authentication credentials when primary is first server to be detected causing an immediate connect event to happen. + +2.2.20 2017-01-11 +----------------- +* Updated mongodb-core to 2.1.5 to include bson 1.0.4 and bson-ext 1.0.4 due to Buffer.from being broken in early node 4.x versions. + +2.2.19 2017-01-03 +----------------- +* Corrupted Npm release fix. + +2.2.18 2017-01-03 +----------------- +* Updated mongodb-core to 2.1.4 to fix bson ObjectId toString issue with utils.inspect messing with toString parameters in node 6. + +2.2.17 2017-01-02 +----------------- +* updated createCollection doc options and linked to create command. +* Updated mongodb-core to 2.1.3. + * Monitoring operations are re-scheduled in pool if it cannot find a connection that does not already have scheduled work on it, this is to avoid the monitoring socket timeout being applied to any existing operations on the socket due to pipelining + * Moved replicaset monitoring away from serial mode and to parallel mode. + * updated bson and bson-ext dependencies to 1.0.2. + +2.2.16 2016-12-13 +----------------- +* NODE-899 reversed upsertedId change to bring back old behavior. + +2.2.15 2016-12-10 +----------------- +* Updated mongodb-core to 2.1.2. + * Delay topologyMonitoring on successful attemptReconnect as no need to run a full scan immediately. + * Emit reconnect event in primary joining when in connected status for a replicaset (Fixes mongoose reconnect issue). + +2.2.14 2016-12-08 +----------------- +* Updated mongodb-core to 2.1.1. +* NODE-892 Passthrough options.readPreference to mongodb-core ReplSet instance. + +2.2.13 2016-12-05 +----------------- +* Updated mongodb-core to 2.1.0. +* NODE-889 Fixed issue where legacy killcursor wire protocol messages would not be sent when APM is enabled. +* Expose parserType as property on topology objects. + +2.2.12 2016-11-29 +----------------- +* Updated mongodb-core to 2.0.14. + * Updated bson library to 0.5.7. + * Dont leak connection.workItems elments when killCursor is called (Issue #150, https://github.com/mdlavin). + * Remove unnecessary errors formatting (Issue #149, https://github.com/akryvomaz). + * Only check isConnected against availableConnections (Issue #142). + * NODE-838 Provide better error message on failed to connect on first retry for Mongos topology. + * Set default servername to host is not passed through for sni. + * Made monitoring happen on exclusive connection and using connectionTimeout to handle the wait time before failure (Issue #148). + * NODE-859 Make minimum value of maxStalenessSeconds 90 seconds. + * NODE-852 Fix Kerberos module deprecations on linux and windows and release new kerberos version. + * NODE-850 Update Max Staleness implementation. + * NODE-849 username no longer required for MONGODB-X509 auth. + * NODE-848 BSON Regex flags must be alphabetically ordered. + * NODE-846 Create notice for all third party libraries. + * NODE-843 Executing bulk operations overwrites write concern parameter. + * NODE-842 Re-sync SDAM and SDAM Monitoring tests from Specs repo. + * NODE-840 Resync CRUD spec tests. + * Unescapable while(true) loop (Issue #152). +* NODE-864 close event not emits during network issues using single server topology. +* Introduced maxStalenessSeconds. +* NODE-840 Added CRUD specification test cases and fix minor issues with upserts reporting matchedCount > 0. +* Don't ignore Db-level authSource when using auth method. (https://github.com/donaldguy). + +2.2.11 2016-10-21 +----------------- +* Updated mongodb-core to 2.0.13. + - Fire callback when topology was destroyed (Issue #147, https://github.com/vkarpov15). + - Refactoring to support pipelining ala 1.4.x branch will retaining the benefits of the growing/shrinking pool (Issue #146). + - Fix typo in serverHeartbeatFailed event name (Issue #143, https://github.com/jakesjews). + - NODE-798 Driver hangs on count command in replica set with one member (Issue #141, https://github.com/isayme). +* Updated bson library to 0.5.6. + - Included cyclic dependency detection +* Fix typo in serverHeartbeatFailed event name (Issue #1418, https://github.com/jakesjews). +* NODE-824, readPreference "nearest" does not work when specified at collection level. +* NODE-822, GridFSBucketWriteStream end method does not handle optional parameters. +* NODE-823, GridFSBucketWriteStream end: callback is invoked with invalid parameters. +* NODE-829, Using Start/End offset option in GridFSBucketReadStream doesn't return the right sized buffer. + +2.2.10 2016-09-15 +----------------- +* Updated mongodb-core to 2.0.12. +* fix debug logging message not printing server name. +* fixed application metadata being sent by wrong ismaster. +* NODE-812 Fixed mongos stall due to proxy monitoring ismaster failure causing reconnect. +* NODE-818 Replicaset timeouts in initial connect sequence can "no primary found". +* Updated bson library to 0.5.5. +* Added DBPointer up conversion to DBRef. +* MongoDB 3.4-RC Pass **appname** through MongoClient.connect uri or options to allow metadata to be passed. +* MongoDB 3.4-RC Pass collation options on update, findOne, find, createIndex, aggregate. +* MongoDB 3.4-RC Allow write concerns to be passed to all supporting server commands. +* MongoDB 3.4-RC Allow passing of **servername** as SSL options to support SNI. + +2.2.9 2016-08-29 +---------------- +* Updated mongodb-core to 2.0.11. +* NODE-803, Fixed issue in how the latency window is calculated for Mongos topology causing issues for single proxy connections. +* Avoid timeout in attemptReconnect causing multiple attemptReconnect attempts to happen (Issue #134, https://github.com/dead-horse). +* Ensure promoteBuffers is propegated in same fashion as promoteValues and promoteLongs. +* Don't treat ObjectId as object for mapReduce scope (Issue #1397, https://github.com/vkarpov15). + +2.2.8 2016-08-23 +---------------- +* Updated mongodb-core to 2.0.10. +* Added promoteValues flag (default to true) to allow user to specify they only want wrapped BSON values back instead of promotion to native types. +* Do not close mongos proxy connection on failed ismaster check in ha process (Issue #130). + +2.2.7 2016-08-19 +---------------- +* If only a single mongos is provided in the seedlist, fix issue where it would be assigned as single standalone server instead of mongos topology (Issue #130). +* Updated mongodb-core to 2.0.9. +* Allow promoteLongs to be passed in through Response.parse method and overrides default set on the connection. +* NODE-798 Driver hangs on count command in replica set with one member. +* Allow promoteLongs to be passed in through Response.parse method and overrides default set on the connection. +* Allow passing in servername for TLS connections for SNI support. + +2.2.6 2016-08-16 +---------------- +* Updated mongodb-core to 2.0.8. +* Allow execution of store operations independent of having both a primary and secondary available (Issue #123). +* Fixed command execution issue for mongos to ensure buffering of commands when no mongos available. +* Allow passing in an array of tags to ReadPreference constructor (Issue #1382, https://github.com/vkarpov15) +* Added hashed connection names and fullResult. +* Updated bson library to 0.5.3. +* Enable maxTimeMS in count, distinct, findAndModify. + +2.2.5 2016-07-28 +---------------- +* Updated mongodb-core to 2.0.7. +* Allow primary to be returned when secondaryPreferred is passed (Issue #117, https://github.com/dhendo). +* Added better warnings when passing in illegal seed list members to a Mongos topology. +* Minor attemptReconnect bug that would cause multiple attemptReconnect to run in parallel. +* Fix wrong opType passed to disconnectHandler.add (Issue #121, https://github.com/adrian-gierakowski) +* Implemented domain backward comp support enabled via domainsEnabled options on Server/ReplSet/Mongos and MongoClient.connect. + +2.2.4 2016-07-19 +---------------- +* NPM corrupted upload fix. + +2.2.3 2016-07-19 +---------------- +* Updated mongodb-core to 2.0.6. +* Destroy connection on socket timeout due to newer node versions not closing the socket. + +2.2.2 2016-07-15 +---------------- +* Updated mongodb-core to 2.0.5. +* Minor fixes to handle faster MongoClient connectivity from the driver, allowing single server instances to detect if they are a proxy. +* Added numberOfConsecutiveTimeouts to pool that will destroy the pool if the number of consecutive timeouts > reconnectTries. +* Print warning if seedlist servers host name does not match the one provided in it's ismaster.me field for Replicaset members. +* Fix issue where Replicaset connection would not succeeed if there the replicaset was a single primary server setup. + +2.2.1 2016-07-11 +---------------- +* Updated mongodb-core to 2.0.4. +* handle situation where user is providing seedlist names that do not match host list. fix allows for a single full discovery connection sweep before erroring out. +* NODE-747 Polyfill for Object.assign for 0.12.x or 0.10.x. +* NODE-746 Improves replicaset errors for wrong setName. + +2.2.0 2016-07-05 +---------------- +* Updated mongodb-core to 2.0.3. +* Moved all authentication and handling of growing/shrinking of pool connections into actual pool. +* All authentication methods now handle both auth/reauthenticate and logout events. +* Introduced logout method to get rid of onAll option for logout command. +* Updated bson to 0.5.0 that includes Decimal128 support. +* Fixed logger error serialization issue. +* Documentation fixes. +* Implemented Server Selection Specification test suite. +* Added warning level to logger. +* Added warning message when sockeTimeout < haInterval for Replset/Mongos. +* Mongos emits close event on no proxies available or when reconnect attempt fails. +* Replset emits close event when no servers available or when attemptReconnect fails to reconnect. +* Don't throw in auth methods but return error in callback. + +2.1.21 2016-05-30 +----------------- +* Updated mongodb-core to 1.3.21. +* Pool gets stuck if a connection marked for immediateRelease times out (Issue #99, https://github.com/nbrachet). +* Make authentication process retry up to authenticationRetries at authenticationRetryIntervalMS interval. +* Made ismaster replicaset calls operate with connectTimeout or monitorSocketTimeout to lower impact of big socketTimeouts on monitoring performance. +* Make sure connections mark as "immediateRelease" don't linger the inUserConnections list. Otherwise, after that connection times out, getAll() incorrectly returns more connections than are effectively present, causing the pool to not get restarted by reconnectServer. (Issue #99, https://github.com/nbrachet). +* Make cursor getMore or killCursor correctly trigger pool reconnect to single server if pool has not been destroyed. +* Make ismaster monitoring for single server connection default to avoid user confusion due to change in behavior. + +2.1.20 2016-05-25 +----------------- +* Refactored MongoClient options handling to simplify the logic, unifying it. +* NODE-707 Implemented openUploadStreamWithId on GridFS to allow for custom fileIds so users are able to customize shard key and shard distribution. +* NODE-710 Allow setting driver loggerLevel and logger function from MongoClient options. +* Updated mongodb-core to 1.3.20. +* Minor fix for SSL errors on connection attempts, minor fix to reconnect handler for the server. +* Don't write to socket before having registered the callback for commands, work around for windows issuing error events twice on node.js when socket gets destroyed by firewall. +* Fix minor issue where connectingServers would not be removed correctly causing single server connections to not auto-reconnect. + +2.1.19 2016-05-17 +---------------- +* Handle situation where a server connection in a replicaset sometimes fails to be destroyed properly due to being in the middle of authentication when the destroy method is called on the replicaset causing it to be orphaned and never collected. +* Ensure replicaset topology destroy is never called by SDAM. +* Ensure all paths are correctly returned on inspectServer in replset. +* Updated mongodb-core to 1.3.19 to fix minor connectivity issue on quick open/close of MongoClient connections on auth enabled mongodb Replicasets. + +2.1.18 2016-04-27 +----------------- +* Updated mongodb-core to 1.3.18 to fix Node 6.0 issues. + +2.1.17 2016-04-26 +----------------- +* Updated mongodb-core to 1.3.16 to work around issue with early versions of node 0.10.x due to missing unref method on ClearText streams. +* INT-1308: Allow listIndexes to inherit readPreference from Collection or DB. +* Fix timeout issue using new flags #1361. +* Updated mongodb-core to 1.3.17. +* Better handling of unique createIndex error. +* Emit error only if db instance has an error listener. +* DEFAULT authMechanism; don't throw error if explicitly set by user. + +2.1.16 2016-04-06 +----------------- +* Updated mongodb-core to 1.3.16. + +2.1.15 2016-04-06 +----------------- +* Updated mongodb-core to 1.3.15. +* Set ssl, sslValidate etc to mongosOptions on url_parser (Issue #1352, https://github.com/rubenstolk). +- NODE-687 Fixed issue where a server object failed to be destroyed if the replicaset state did not update successfully. This could leave active connections accumulating over time. +- Fixed some situations where all connections are flushed due to a single connection in the connection pool closing. + +2.1.14 2016-03-29 +----------------- +* Updated mongodb-core to 1.3.13. +* Handle missing cursor on getMore when going through a mongos proxy by pinning to socket connection and not server. + +2.1.13 2016-03-29 +----------------- +* Updated mongodb-core to 1.3.12. + +2.1.12 2016-03-29 +----------------- +* Updated mongodb-core to 1.3.11. +* Mongos setting acceptableLatencyMS exposed to control the latency women for mongos selection. +* Mongos pickProxies fall back to closest mongos if no proxies meet latency window specified. +* isConnected method for mongos uses same selection code as getServer. +* Exceptions in cursor getServer trapped and correctly delegated to high level handler. + +2.1.11 2016-03-23 +----------------- +* Updated mongodb-core to 1.3.10. +* Introducing simplified connections settings. + +2.1.10 2016-03-21 +----------------- +* Updated mongodb-core to 1.3.9. +* Fixing issue that prevented mapReduce stats from being resolved (Issue #1351, https://github.com/davidgtonge) +* Forwards SDAM monitoring events from mongodb-core. + +2.1.9 2016-03-16 +---------------- +* Updated mongodb-core to 1.3.7 to fix intermittent race condition that causes some users to experience big amounts of socket connections. +* Makde bson parser in ordered/unordered bulk be directly from mongodb-core to avoid intermittent null error on mongoose. + +2.1.8 2016-03-14 +---------------- +* Updated mongodb-core to 1.3.5. +* NODE-660 TypeError: Cannot read property 'noRelease' of undefined. +* Harden MessageHandler in server.js to avoid issues where we cannot find a callback for an operation. +* Ensure RequestId can never be larger than Max Number integer size. +* NODE-661 typo in url_parser.js resulting in replSetServerOptions is not defined when connecting over ssl. +* Confusing error with invalid partial index filter (Issue #1341, https://github.com/vkarpov15). +* NODE-669 Should only error out promise for bulkWrite when error is a driver level error not a write error or write concern error. +* NODE-662 shallow copy options on methods that are not currently doing it to avoid passed in options mutiation. +* NODE-663 added lookup helper on aggregation cursor. +* NODE-585 Result object specified incorrectly for findAndModify?. +* NODE-666 harden validation for findAndModify CRUD methods. + +2.1.7 2016-02-09 +---------------- +* NODE-656 fixed corner case where cursor count command could be left without a connection available. +* NODE-658 Work around issue that bufferMaxEntries:-1 for js gets interpreted wrongly due to double nature of Javascript numbers. +* Fix: GridFS always returns the oldest version due to incorrect field name (Issue #1338, https://github.com/mdebruijne). +* NODE-655 GridFS stream support for cancelling upload streams and download streams (Issue #1339, https://github.com/vkarpov15). +* NODE-657 insertOne don`t return promise in some cases. +* Added destroy alias for abort function on GridFSBucketWriteStream. + +2.1.6 2016-02-05 +---------------- +* Updated mongodb-core to 1.3.1. + +2.1.5 2016-02-04 +---------------- +* Updated mongodb-core to 1.3.0. +* Added raw support for the command function on topologies. +* Fixed issue where raw results that fell on batchSize boundaries failed (Issue #72) +* Copy over all the properties to the callback returned from bindToDomain, (Issue #72) +* Added connection hash id to be able to reference connection host/name without leaking it outside of driver. +* NODE-638, Cannot authenticate database user with utf-8 password. +* Refactored pool to be worker queue based, minimizing the impact a slow query have on throughput as long as # slow queries < # connections in the pool. +* Pool now grows and shrinks correctly depending on demand not causing a full pool reconnect. +* Improvements in monitoring of a Replicaset where in certain situations the inquiry process could get exited. +* Switched to using Array.push instead of concat for use cases of a lot of documents. +* Fixed issue where re-authentication could loose the credentials if whole Replicaset disconnected at once. +* Added peer optional dependencies support using require_optional module. +* Bug is listCollections for collection names that start with db name (Issue #1333, https://github.com/flyingfisher) +* Emit error before closing stream (Issue #1335, https://github.com/eagleeye) + +2.1.4 2016-01-12 +---------------- +* Restricted node engine to >0.10.3 (https://jira.mongodb.org/browse/NODE-635). +* Multiple database names ignored without a warning (https://jira.mongodb.org/browse/NODE-636, Issue #1324, https://github.com/yousefhamza). +* Convert custom readPreference objects in collection.js (Issue #1326, https://github.com/Machyne). + +2.1.3 2016-01-04 +---------------- +* Updated mongodb-core to 1.2.31. +* Allow connection to secondary if primaryPreferred or secondaryPreferred (Issue #70, https://github.com/leichter) + +2.1.2 2015-12-23 +---------------- +* Updated mongodb-core to 1.2.30. +* Pool allocates size + 1 connections when using replicasets, reserving additional pool connection for monitoring exclusively. +* Fixes bug when all replicaset members are down, that would cause it to fail to reconnect using the originally provided seedlist. + +2.1.1 2015-12-13 +---------------- +* Surfaced checkServerIdentity options for MongoClient, Server, ReplSet and Mongos to allow for control of the checkServerIdentity method available in Node.s 0.12.x or higher. +* Added readPreference support to listCollections and listIndexes helpers. +* Updated mongodb-core to 1.2.28. + +2.1.0 2015-12-06 +---------------- +* Implements the connection string specification, https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst. +* Implements the new GridFS specification, https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst. +* Full MongoDB 3.2 support. +* NODE-601 Added maxAwaitTimeMS support for 3.2 getMore to allow for custom timeouts on tailable cursors. +* Updated mongodb-core to 1.2.26. +* Return destination in GridStore pipe function. +* NODE-606 better error handling on destroyed topology for db.js methods. +* Added isDestroyed method to server, replset and mongos topologies. +* Upgraded test suite to run using mongodb-topology-manager. + +2.0.53 2015-12-23 +----------------- +* Updated mongodb-core to 1.2.30. +* Pool allocates size + 1 connections when using replicasets, reserving additional pool connection for monitoring exclusively. +* Fixes bug when all replicaset members are down, that would cause it to fail to reconnect using the originally provided seedlist. + +2.0.52 2015-12-14 +----------------- +* removed remove from Gridstore.close. + +2.0.51 2015-12-13 +----------------- +* Surfaced checkServerIdentity options for MongoClient, Server, ReplSet and Mongos to allow for control of the checkServerIdentity method available in Node.s 0.12.x or higher. +* Added readPreference support to listCollections and listIndexes helpers. +* Updated mongodb-core to 1.2.28. + +2.0.50 2015-12-06 +----------------- +* Updated mongodb-core to 1.2.26. + +2.0.49 2015-11-20 +----------------- +* Updated mongodb-core to 1.2.24 with several fixes. + * Fix Automattic/mongoose#3481; flush callbacks on error, (Issue #57, https://github.com/vkarpov15). + * $explain query for wire protocol 2.6 and 2.4 does not set number of returned documents to -1 but to 0. + * ismaster runs against admin.$cmd instead of system.$cmd. + * Fixes to handle getMore command errors for MongoDB 3.2 + * Allows the process to properly close upon a Db.close() call on the replica set by shutting down the haTimer and closing arbiter connections. + +2.0.48 2015-11-07 +----------------- +* GridFS no longer performs any deletes when writing a brand new file that does not have any previous .fs.chunks or .fs.files documents. +* Updated mongodb-core to 1.2.21. +* Hardened the checking for replicaset equality checks. +* OpReplay flag correctly set on Wire protocol query. +* Mongos load balancing added, introduced localThresholdMS to control the feature. +* Kerberos now a peerDependency, making it not install it by default in Node 5.0 or higher. + +2.0.47 2015-10-28 +----------------- +* Updated mongodb-core to 1.2.20. +* Fixed bug in arbiter connection capping code. +* NODE-599 correctly handle arrays of server tags in order of priority. +* Fix for 2.6 wire protocol handler related to readPreference handling. +* Added maxAwaitTimeMS support for 3.2 getMore to allow for custom timeouts on tailable cursors. +* Make CoreCursor check for $err before saying that 'next' succeeded (Issue #53, https://github.com/vkarpov15). + +2.0.46 2015-10-15 +----------------- +* Updated mongodb-core to 1.2.19. +* NODE-578 Order of sort fields is lost for numeric field names. +* Expose BSON Map (ES6 Map or polyfill). +* Minor fixes for APM support to pass extended APM test suite. + +2.0.45 2015-09-30 +----------------- +* NODE-566 Fix issue with rewind on capped collections causing cursor state to be reset on connection loss. + +2.0.44 2015-09-28 +----------------- +* Bug fixes for APM upconverting of legacy INSERT/UPDATE/REMOVE wire protocol messages. +* NODE-562, fixed issue where a Replicaset MongoDB URI with a single seed and replSet name set would cause a single direct connection instead of topology discovery. +* Updated mongodb-core to 1.2.14. +* NODE-563 Introduced options.ignoreUndefined for db class and MongoClient db options, made serialize undefined to null default again but allowing for overrides on insert/update/delete operations. +* Use handleCallback if result is an error for count queries. (Issue #1298, https://github.com/agclever) +* Rewind cursor to correctly force reconnect on capped collections when first query comes back empty. +* NODE-571 added code 59 to legacy server errors when SCRAM-SHA-1 mechanism fails. +* NODE-572 Remove examples that use the second parameter to `find()`. + +2.0.43 2015-09-14 +----------------- +* Propagate timeout event correctly to db instances. +* Application Monitoring API (APM) implemented. +* NOT providing replSet name in MongoClient connection URI will force single server connection. Fixes issue where it was impossible to directly connect to a replicaset member server. +* Updated mongodb-core to 1.2.12. +* NODE-541 Initial Support "read committed" isolation level where "committed" means confimed by the voting majority of a replica set. +* GridStore doesn't share readPreference setting from connection string. (Issue #1295, https://github.com/zhangyaoxing) +* fixed forceServerObjectId calls (Issue #1292, https://github.com/d-mon-) +* Pass promise library through to DB function (Issue #1294, https://github.com/RovingCodeMonkey) + +2.0.42 2015-08-18 +----------------- +* Added test case to exercise all non-crud methods on mongos topologies, fixed numberOfConnectedServers on mongos topology instance. + +2.0.41 2015-08-14 +----------------- +* Added missing Mongos.prototype.parserType function. +* Updated mongodb-core to 1.2.10. + +2.0.40 2015-07-14 +----------------- +* Updated mongodb-core to 1.2.9 for 2.4 wire protocol error handler fix. +* NODE-525 Reset connectionTimeout after it's overwritten by tls.connect. +* NODE-518 connectTimeoutMS is doubled in 2.0.39. +* NODE-506 Ensures that errors from bulk unordered and ordered are instanceof Error (Issue #1282, https://github.com/owenallenaz). +* NODE-526 Unique index not throwing duplicate key error. +* NODE-528 Ignore undefined fields in Collection.find(). +* NODE-527 The API example for collection.createIndex shows Db.createIndex functionality. + +2.0.39 2015-07-14 +----------------- +* Updated mongodb-core to 1.2.6 for NODE-505. + +2.0.38 2015-07-14 +----------------- +* NODE-505 Query fails to find records that have a 'result' property with an array value. + +2.0.37 2015-07-14 +----------------- +* NODE-504 Collection * Default options when using promiseLibrary. +* NODE-500 Accidental repeat of hostname in seed list multiplies total connections persistently. +* Updated mongodb-core to 1.2.5 to fix NODE-492. + +2.0.36 2015-07-07 +----------------- +* Fully promisified allowing the use of ES6 generators and libraries like co. Also allows for BYOP (Bring your own promises). +* NODE-493 updated mongodb-core to 1.2.4 to ensure we cannot DDOS the mongod or mongos process on large connection pool sizes. + +2.0.35 2015-06-17 +----------------- +* Upgraded to mongodb-core 1.2.2 including removing warnings when C++ bson parser is not available and a fix for SCRAM authentication. + +2.0.34 2015-06-17 +----------------- +* Upgraded to mongodb-core 1.2.1 speeding up serialization and removing the need for the c++ bson extension. +* NODE-486 fixed issue related to limit and skip when calling toArray in 2.0 driver. +* NODE-483 throw error if capabilities of topology is queries before topology has performed connection setup. +* NODE-482 fixed issue where MongoClient.connect would incorrectly identify a replset seed list server as a non replicaset member. +* NODE-487 fixed issue where killcursor command was not being sent correctly on limit and skip queries. + +2.0.33 2015-05-20 +----------------- +* Bumped mongodb-core to 1.1.32. + +2.0.32 2015-05-19 +----------------- +* NODE-463 db.close immediately executes its callback. +* Don't only emit server close event once (Issue #1276, https://github.com/vkarpov15). +* NODE-464 Updated mongodb-core to 1.1.31 that uses a single socket connection to arbiters and hidden servers as well as emitting all event correctly. + +2.0.31 2015-05-08 +----------------- +* NODE-461 Tripping on error "no chunks found for file, possibly corrupt" when there is no error. + +2.0.30 2015-05-07 +----------------- +* NODE-460 fix; don't set authMechanism for user in db.authenticate() to avoid mongoose authentication issue. + +2.0.29 2015-05-07 +----------------- +* NODE-444 Possible memory leak, too many listeners added. +* NODE-459 Auth failure using Node 0.8.28, MongoDB 3.0.2 & mongodb-node-native 1.4.35. +* Bumped mongodb-core to 1.1.26. + +2.0.28 2015-04-24 +----------------- +* Bumped mongodb-core to 1.1.25 +* Added Cursor.prototype.setCursorOption to allow for setting node specific cursor options for tailable cursors. +* NODE-430 Cursor.count() opts argument masked by var opts = {} +* NODE-406 Implemented Cursor.prototype.map function tapping into MongoClient cursor transforms. +* NODE-438 replaceOne is not returning the result.ops property as described in the docs. +* NODE-433 _read, pipe and write all open gridstore automatically if not open. +* NODE-426 ensure drain event is emitted after write function returns, fixes intermittent issues in writing files to gridstore. +* NODE-440 GridStoreStream._read() doesn't check GridStore.read() error. +* Always use readPreference = primary for findAndModify command (ignore passed in read preferences) (Issue #1274, https://github.com/vkarpov15). +* Minor fix in GridStore.exists for dealing with regular expressions searches. + +2.0.27 2015-04-07 +----------------- +* NODE-410 Correctly handle issue with pause/resume in Node 0.10.x that causes exceptions when using the Node 0.12.0 style streams. + +2.0.26 2015-04-07 +----------------- +* Implements the Common Index specification Standard API at https://github.com/mongodb/specifications/blob/master/source/index-management.rst. +* NODE-408 Expose GridStore.currentChunk.chunkNumber. + +2.0.25 2015-03-26 +----------------- +* Upgraded mongodb-core to 1.1.21, making the C++ bson code an optional dependency to the bson module. + +2.0.24 2015-03-24 +----------------- +* NODE-395 Socket Not Closing, db.close called before full set finished initalizing leading to server connections in progress not being closed properly. +* Upgraded mongodb-core to 1.1.20. + +2.0.23 2015-03-21 +----------------- +* NODE-380 Correctly return MongoError from toError method. +* Fixed issue where addCursorFlag was not correctly setting the flag on the command for mongodb-core. +* NODE-388 Changed length from method to property on order.js/unordered.js bulk operations. +* Upgraded mongodb-core to 1.1.19. + +2.0.22 2015-03-16 +----------------- +* NODE-377, fixed issue where tags would correctly be checked on secondary and nearest to filter out eligible server candidates. +* Upgraded mongodb-core to 1.1.17. + +2.0.21 2015-03-06 +----------------- +* Upgraded mongodb-core to 1.1.16 making sslValidate default to true to force validation on connection unless overriden by the user. + +2.0.20 2015-03-04 +----------------- +* Updated mongodb-core 1.1.15 to relax pickserver method. + +2.0.19 2015-03-03 +----------------- +* NODE-376 Fixes issue * Unordered batch incorrectly tracks batch size when switching batch types (Issue #1261, https://github.com/meirgottlieb) +* NODE-379 Fixes bug in cursor.count() that causes the result to always be zero for dotted collection names (Issue #1262, https://github.com/vsivsi) +* Expose MongoError from mongodb-core (Issue #1260, https://github.com/tjconcept) + +2.0.18 2015-02-27 +----------------- +* Bumped mongodb-core 1.1.14 to ensure passives are correctly added as secondaries. + +2.0.17 2015-02-27 +----------------- +* NODE-336 Added length function to ordered and unordered bulk operations to be able know the amount of current operations in bulk. +* Bumped mongodb-core 1.1.13 to ensure passives are correctly added as secondaries. + +2.0.16 2015-02-16 +----------------- +* listCollection now returns filtered result correctly removing db name for 2.6 or earlier servers. +* Bumped mongodb-core 1.1.12 to correctly work for node 0.12.0 and io.js. +* Add ability to get collection name from cursor (Issue #1253, https://github.com/vkarpov15) + +2.0.15 2015-02-02 +----------------- +* Unified behavior of listCollections results so 3.0 and pre 3.0 return same type of results. +* Bumped mongodb-core to 1.1.11 to support per document tranforms in cursors as well as relaxing the setName requirement. +* NODE-360 Aggregation cursor and command correctly passing down the maxTimeMS property. +* Added ~1.0 mongodb-tools module for test running. +* Remove the required setName for replicaset connections, if not set it will pick the first setName returned. + +2.0.14 2015-01-21 +----------------- +* Fixed some MongoClient.connect options pass through issues and added test coverage. +* Bumped mongodb-core to 1.1.9 including fixes for io.js + +2.0.13 2015-01-09 +----------------- +* Bumped mongodb-core to 1.1.8. +* Optimized query path for performance, moving Object.defineProperty outside of constructors. + +2.0.12 2014-12-22 +----------------- +* Minor fixes to listCollections to ensure correct querying of a collection when using a string. + +2.0.11 2014-12-19 +----------------- +* listCollections filters out index namespaces on < 2.8 correctly +* Bumped mongo-client to 1.1.7 + +2.0.10 2014-12-18 +----------------- +* NODE-328 fixed db.open return when no callback available issue and added test. +* NODE-327 Refactored listCollections to return cursor to support 2.8. +* NODE-327 Added listIndexes method and refactored internal methods to use the new command helper. +* NODE-335 Cannot create index for nested objects fixed by relaxing key checking for createIndex helper. +* Enable setting of connectTimeoutMS (Issue #1235, https://github.com/vkarpov15) +* Bumped mongo-client to 1.1.6 + +2.0.9 2014-12-01 +---------------- +* Bumped mongodb-core to 1.1.3 fixing global leaked variables and introducing strict across all classes. +* All classes are now strict (Issue #1233) +* NODE-324 Refactored insert/update/remove and all other crud opts to rely on internal methods to avoid any recursion. +* Fixed recursion issues in debug logging due to JSON.stringify() +* Documentation fixes (Issue #1232, https://github.com/wsmoak) +* Fix writeConcern in Db.prototype.ensureIndex (Issue #1231, https://github.com/Qard) + +2.0.8 2014-11-28 +---------------- +* NODE-322 Finished up prototype refactoring of Db class. +* NODE-322 Exposed Cursor in index.js for New Relic. + +2.0.7 2014-11-20 +---------------- +* Bumped mongodb-core to 1.1.2 fixing a UTF8 encoding issue for collection names. +* NODE-318 collection.update error while setting a function with serializeFunctions option. +* Documentation fixes. + +2.0.6 2014-11-14 +---------------- +* Refactored code to be prototype based instead of privileged methods. +* Bumped mongodb-core to 1.1.1 to take advantage of the prototype based refactorings. +* Implemented missing aspects of the CRUD specification. +* Fixed documentation issues. +* Fixed global leak REFERENCE_BY_ID in gridfs grid_store (Issue #1225, https://github.com/j) +* Fix LearnBoost/mongoose#2313: don't let user accidentally clobber geoNear params (Issue #1223, https://github.com/vkarpov15) + +2.0.5 2014-10-29 +---------------- +* Minor fixes to documentation and generation of documentation. +* NODE-306 (No results in aggregation cursor when collection name contains a dot), Merged code for cursor and aggregation cursor. + +2.0.4 2014-10-23 +---------------- +* Allow for single replicaset seed list with no setName specified (Issue #1220, https://github.com/imaman) +* Made each rewind on each call allowing for re-using the cursor. +* Fixed issue where incorrect iterations would happen on each for extensive batchSizes. +* NODE-301 specifying maxTimeMS on find causes all fields to be omitted from result. + +2.0.3 2014-10-14 +---------------- +* NODE-297 Aggregate Broken for case of pipeline with no options. + +2.0.2 2014-10-08 +---------------- +* Bumped mongodb-core to 1.0.2. +* Fixed bson module dependency issue by relying on the mongodb-core one. +* Use findOne instead of find followed by nextObject (Issue #1216, https://github.com/sergeyksv) + +2.0.1 2014-10-07 +---------------- +* Dependency fix + +2.0.0 2014-10-07 +---------------- +* First release of 2.0 driver + +2.0.0-alpha2 2014-10-02 +----------------------- +* CRUD API (insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, bulkWrite, findOneAndDelete, findOneAndUpdate, findOneAndReplace) +* Cluster Management Spec compatible. + +2.0.0-alpha1 2014-09-08 +----------------------- +* Insert method allows only up 1000 pr batch for legacy as well as 2.6 mode +* Streaming behavior is 0.10.x or higher with backwards compatibility using readable-stream npm package +* Gridfs stream only available through .stream() method due to overlapping names on Gridstore object and streams in 0.10.x and higher of node +* remove third result on update and remove and return the whole result document instead (getting rid of the weird 3 result parameters) + * Might break some application +* Returns the actual mongodb-core result instead of just the number of records changed for insert/update/remove +* MongoClient only has the connect method (no ability instantiate with Server, ReplSet or similar) +* Removed Grid class +* GridStore only supports w+ for metadata updates, no appending to file as it's not thread safe and can cause corruption of the data + + seek will fail if attempt to use with w or w+ + + write will fail if attempted with w+ or r + + w+ only works for updating metadata on a file +* Cursor toArray and each resets and re-runs the cursor +* FindAndModify returns whole result document instead of just value +* Extend cursor to allow for setting all the options via methods instead of dealing with the current messed up find +* Removed db.dereference method +* Removed db.cursorInfo method +* Removed db.stats method +* Removed db.collectionNames not needed anymore as it's just a specialized case of listCollections +* Removed db.collectionInfo removed due to not being compatible with new storage engines in 2.8 as they need to use the listCollections command due to system collections not working for namespaces. +* Added db.listCollections to replace several methods above + +1.4.10 2014-09-04 +----------------- +* Fixed BSON and Kerberos compilation issues +* Bumped BSON to ~0.2 always installing latest BSON 0.2.x series +* Fixed Kerberos and bumped to 0.0.4 + +1.4.9 2014-08-26 +---------------- +* Check _bsonType for Binary (Issue #1202, https://github.com/mchapman) +* Remove duplicate Cursor constructor (Issue #1201, https://github.com/KenPowers) +* Added missing parameter in the documentation (Issue #1199, https://github.com/wpjunior) +* Documented third parameter on the update callback(Issue #1196, https://github.com/gabmontes) +* NODE-240 Operations on SSL connection hang on node 0.11.x +* NODE-235 writeResult is not being passed on when error occurs in insert +* NODE-229 Allow count to work with query hints +* NODE-233 collection.save() does not support fullResult +* NODE-244 Should parseError also emit a `disconnected` event? +* NODE-246 Cursors are inefficiently constructed and consequently cannot be promisified. +* NODE-248 Crash with X509 auth +* NODE-252 Uncaught Exception in Base.__executeAllServerSpecificErrorCallbacks +* Bumped BSON parser to 0.2.12 + + +1.4.8 2014-08-01 +---------------- +* NODE-205 correctly emit authenticate event +* NODE-210 ensure no undefined connection error when checking server state +* NODE-212 correctly inherit socketTimeoutMS from replicaset when HA process adds new servers or reconnects to existing ones +* NODE-220 don't throw error if ensureIndex errors out in Gridstore +* Updated bson to 0.2.11 to ensure correct toBSON behavior when returning non object in nested classes +* Fixed test running filters +* Wrap debug log in a call to format (Issue #1187, https://github.com/andyroyle) +* False option values should not trigger w:1 (Issue #1186, https://github.com/jsdevel) +* Fix aggregatestream.close(Issue #1194, https://github.com/jonathanong) +* Fixed parsing issue for w:0 in url parser when in connection string +* Modified collection.geoNear to support a geoJSON point or legacy coordinate pair (Issue #1198, https://github.com/mmacmillan) + +1.4.7 2014-06-18 +---------------- +* Make callbacks to be executed in right domain when server comes back up (Issue #1184, https://github.com/anton-kotenko) +* Fix issue where currentOp query against mongos would fail due to mongos passing through $readPreference field to mongod (CS-X) + +1.4.6 2014-06-12 +---------------- +* Added better support for MongoClient IP6 parsing (Issue #1181, https://github.com/micovery) +* Remove options check on index creation (Issue #1179, Issue #1183, https://github.com/jdesboeufs, https://github.com/rubenvereecken) +* Added missing type check before calling optional callback function (Issue #1180) + +1.4.5 2014-05-21 +---------------- +* Added fullResult flag to insert/update/remove which will pass raw result document back. Document contents will vary depending on the server version the driver is talking to. No attempt is made to coerce a joint response. +* Fix to avoid MongoClient.connect hanging during auth when secondaries building indexes pre 2.6. +* return the destination stream in GridStore.pipe (Issue #1176, https://github.com/iamdoron) + +1.4.4 2014-05-13 +---------------- +* Bumped BSON version to use the NaN 1.0 package, fixed strict comparison issue for ObjectID +* Removed leaking global variable (Issue #1174, https://github.com/dainis) +* MongoClient respects connectTimeoutMS for initial discovery process (NODE-185) +* Fix bug with return messages larger than 16MB but smaller than max BSON Message Size (NODE-184) + +1.4.3 2014-05-01 +---------------- +* Clone options for commands to avoid polluting original options passed from Mongoose (Issue #1171, https://github.com/vkarpov15) +* Made geoNear and geoHaystackSearch only clean out allowed options from command generation (Issue #1167) +* Fixed typo for allowDiskUse (Issue #1168, https://github.com/joaofranca) +* A 'mapReduce' function changed 'function' to instance '\' of 'Code' class (Issue #1165, https://github.com/exabugs) +* Made findAndModify set sort only when explicitly set (Issue #1163, https://github.com/sars) +* Rewriting a gridStore file by id should use a new filename if provided (Issue #1169, https://github.com/vsivsi) + +1.4.2 2014-04-15 +---------------- +* Fix for inheritance of readPreferences from MongoClient NODE-168/NODE-169 +* Merged in fix for ping strategy to avoid hitting non-pinged servers (Issue #1161, https://github.com/vaseker) +* Merged in fix for correct debug output for connection messages (Issue #1158, https://github.com/vaseker) +* Fixed global variable leak (Issue #1160, https://github.com/vaseker) + +1.4.1 2014-04-09 +---------------- +* Correctly emit joined event when primary change +* Add _id to documents correctly when using bulk operations + +1.4.0 2014-04-03 +---------------- +* All node exceptions will no longer be caught if on('error') is defined +* Added X509 auth support +* Fix for MongoClient connection timeout issue (NODE-97) +* Pass through error messages from parseError instead of just text (Issue #1125) +* Close db connection on error (Issue #1128, https://github.com/benighted) +* Fixed documentation generation +* Added aggregation cursor for 2.6 and emulated cursor for pre 2.6 (uses stream2) +* New Bulk API implementation using write commands for 2.6 and down converts for pre 2.6 +* Insert/Update/Remove using new write commands when available +* Added support for new roles based API's in 2.6 for addUser/removeUser +* Added bufferMaxEntries to start failing if the buffer hits the specified number of entries +* Upgraded BSON parser to version 0.2.7 to work with < 0.11.10 C++ API changes +* Support for OP_LOG_REPLAY flag (NODE-94) +* Fixes for SSL HA ping and discovery. +* Uses createIndexes if available for ensureIndex/createIndex +* Added parallelCollectionScan method to collection returning CommandCursor instances for cursors +* Made CommandCursor behave as Readable stream. +* Only Db honors readPreference settings, removed Server.js legacy readPreference settings due to user confusion. +* Reconnect event emitted by ReplSet/Mongos/Server after reconnect and before replaying of buffered operations. +* GridFS buildMongoObject returns error on illegal md5 (NODE-157, https://github.com/iantocristian) +* Default GridFS chunk size changed to (255 * 1024) bytes to optimize for collections defaulting to power of 2 sizes on 2.6. +* Refactored commands to all go through command function ensuring consistent command execution. +* Fixed issues where readPreferences where not correctly passed to mongos. +* Catch error == null and make err detection more prominent (NODE-130) +* Allow reads from arbiter for single server connection (NODE-117) +* Handle error coming back with no documents (NODE-130) +* Correctly use close parameter in Gridstore.write() (NODE-125) +* Throw an error on a bulk find with no selector (NODE-129, https://github.com/vkarpov15) +* Use a shallow copy of options in find() (NODE-124, https://github.com/vkarpov15) +* Fix statistical strategy (NODE-158, https://github.com/vkarpov15) +* GridFS off-by-one bug in lastChunkNumber() causes uncaught throw and data loss (Issue #1154, https://github.com/vsivsi) +* GridStore drops passed `aliases` option, always results in `null` value in GridFS files (Issue #1152, https://github.com/vsivsi) +* Remove superfluous connect object copying in index.js (Issue #1145, https://github.com/thomseddon) +* Do not return false when the connection buffer is still empty (Issue #1143, https://github.com/eknkc) +* Check ReadPreference object on ReplSet.canRead (Issue #1142, https://github.com/eknkc) +* Fix unpack error on _executeQueryCommand (Issue #1141, https://github.com/eknkc) +* Close db on failed connect so node can exit (Issue #1128, https://github.com/benighted) +* Fix global leak with _write_concern (Issue #1126, https://github.com/shanejonas) + +1.3.19 2013-08-21 +----------------- +* Correctly rethrowing errors after change from event emission to callbacks, compatibility with 0.10.X domains without breaking 0.8.X support. +* Small fix to return the entire findAndModify result as the third parameter (Issue #1068) +* No removal of "close" event handlers on server reconnect, emits "reconnect" event when reconnection happens. Reconnect Only applies for single server connections as of now as semantics for ReplSet and Mongos is not clear (Issue #1056) + +1.3.18 2013-08-10 +----------------- +* Fixed issue when throwing exceptions in MongoClient.connect/Db.open (Issue #1057) +* Fixed an issue where _events is not cleaned up correctly causing a slow steady memory leak. + +1.3.17 2013-08-07 +----------------- +* Ignore return commands that have no registered callback +* Made collection.count not use the db.command function +* Fix throw exception on ping command (Issue #1055) + +1.3.16 2013-08-02 +----------------- +* Fixes connection issue where lots of connections would happen if a server is in recovery mode during connection (Issue #1050, NODE-50, NODE-51) +* Bug in unlink mulit filename (Issue #1054) + +1.3.15 2013-08-01 +----------------- +* Memory leak issue due to node Issue #4390 where _events[id] is set to undefined instead of deleted leading to leaks in the Event Emitter over time + +1.3.14 2013-08-01 +----------------- +* Fixed issue with checkKeys where it would error on X.X + +1.3.13 2013-07-31 +----------------- +* Added override for checkKeys on insert/update (Warning will expose you to injection attacks) (Issue #1046) +* BSON size checking now done pre serialization (Issue #1037) +* Added isConnected returns false when no connection Pool exists (Issue #1043) +* Unified command handling to ensure same handling (Issue #1041, #1042) +* Correctly emit "open" and "fullsetup" across all Db's associated with Mongos, ReplSet or Server (Issue #1040) +* Correctly handles bug in authentication when attempting to connect to a recovering node in a replicaset. +* Correctly remove recovering servers from available servers in replicaset. Piggybacks on the ping command. +* Removed findAndModify chaining to be compliant with behavior in other official drivers and to fix a known mongos issue. +* Fixed issue with Kerberos authentication on Windows for re-authentication. +* Fixed Mongos failover behavior to correctly throw out old servers. +* Ensure stored queries/write ops are executed correctly after connection timeout +* Added promoteLongs option for to allow for overriding the promotion of Longs to Numbers and return the actual Long. + +1.3.12 2013-07-19 +----------------- +* Fixed issue where timeouts sometimes would behave wrongly (Issue #1032) +* Fixed bug with callback third parameter on some commands (Issue #1033) +* Fixed possible issue where killcursor command might leave hanging functions +* Fixed issue where Mongos was not correctly removing dead servers from the pool of eligable servers +* Throw error if dbName or collection name contains null character (at command level and at collection level) +* Updated bson parser to 0.2.1 with security fix and non-promotion of Long values to javascript Numbers (once a long always a long) + +1.3.11 2013-07-04 +----------------- +* Fixed errors on geoNear and geoSearch (Issue #1024, https://github.com/ebensing) +* Add driver version to export (Issue #1021, https://github.com/aheckmann) +* Add text to readpreference obedient commands (Issue #1019) +* Drivers should check the query failure bit even on getmore response (Issue #1018) +* Map reduce has incorrect expectations of 'inline' value for 'out' option (Issue #1016, https://github.com/rcotter) +* Support SASL PLAIN authentication (Issue #1009) +* Ability to use different Service Name on the driver for Kerberos Authentication (Issue #1008) +* Remove unnecessary octal literal to allow the code to run in strict mode (Issue #1005, https://github.com/jamesallardice) +* Proper handling of recovering nodes (when they go into recovery and when they return from recovery, Issue #1027) + +1.3.10 2013-06-17 +----------------- +* Guard against possible undefined in server::canCheckoutWriter (Issue #992, https://github.com/willyaranda) +* Fixed some duplicate test names (Issue #993, https://github.com/kawanet) +* Introduced write and read concerns for GridFS (Issue #996) +* Fixed commands not correctly respecting Collection level read preference (Issue #995, #999) +* Fixed issue with pool size on replicaset connections (Issue #1000) +* Execute all query commands on master switch (Issue #1002, https://github.com/fogaztuc) + +1.3.9 2013-06-05 +---------------- +* Fixed memory leak when findAndModify errors out on w>1 and chained callbacks not properly cleaned up. + +1.3.8 2013-05-31 +---------------- +* Fixed issue with socket death on windows where it emits error event instead of close event (Issue #987) +* Emit authenticate event on db after authenticate method has finished on db instance (Issue #984) +* Allows creation of MongoClient and do new MongoClient().connect(..). Emits open event when connection correct allowing for apps to react on event. + +1.3.7 2013-05-29 +---------------- +* After reconnect, tailable getMores go on inconsistent connections (Issue #981, #982, https://github.com/glasser) +* Updated Bson to 0.1.9 to fix ARM support (Issue #985) + +1.3.6 2013-05-21 +---------------- +* Fixed issue where single server reconnect attempt would throw due to missing options variable (Issue #979) +* Fixed issue where difference in ismaster server name and seed list caused connections issues, (Issue #976) + +1.3.5 2013-05-14 +---------------- +* Fixed issue where HA for replicaset would pick the same broken connection when attempting to ping the replicaset causing the replicaset to never recover. + +1.3.4 2013-05-14 +---------------- +* Fixed bug where options not correctly passed in for uri parser (Issue #973, https://github.com/supershabam) +* Fixed bug when passing a named index hint (Issue #974) + +1.3.3 2013-05-09 +---------------- +* Fixed auto-reconnect issue with single server instance. + +1.3.2 2013-05-08 +---------------- +* Fixes for an issue where replicaset would be pronounced dead when high priority primary caused double elections. + +1.3.1 2013-05-06 +---------------- +* Fix for replicaset consisting of primary/secondary/arbiter with priority applied failing to reconnect properly +* Applied auth before server instance is set as connected when single server connection +* Throw error if array of documents passed to save method + +1.3.0 2013-04-25 +---------------- +* Whole High availability handling for Replicaset, Server and Mongos connections refactored to ensure better handling of failover cases. +* Fixed issue where findAndModify would not correctly skip issuing of chained getLastError (Issue #941) +* Fixed throw error issue on errors with findAndModify during write out operation (Issue #939, https://github.com/autopulated) +* Gridstore.prototype.writeFile now returns gridstore object correctly (Issue #938) +* Kerberos support is now an optional module that allows for use of GSSAPI authentication using MongoDB Subscriber edition +* Fixed issue where cursor.toArray could blow the stack on node 0.10.X (#950) + +1.2.14 2013-03-14 +----------------- +* Refactored test suite to speed up running of replicaset tests +* Fix of async error handling when error happens in callback (Issue #909, https://github.com/medikoo) +* Corrected a slaveOk setting issue (Issue #906, #905) +* Fixed HA issue where ping's would not go to correct server on HA server connection failure. +* Uses setImmediate if on 0.10 otherwise nextTick for cursor stream +* Fixed race condition in Cursor stream (NODE-31) +* Fixed issues related to node 0.10 and process.nextTick now correctly using setImmediate where needed on node 0.10 +* Added support for maxMessageSizeBytes if available (DRIVERS-1) +* Added support for authSource (2.4) to MongoClient URL and db.authenticate method (DRIVER-69/NODE-34) +* Fixed issue in GridStore seek and GridStore read to correctly work on multiple seeks (Issue #895) + +1.2.13 2013-02-22 +----------------- +* Allow strategy 'none' for repliaset if no strategy wanted (will default to round robin selection of servers on a set readPreference) +* Fixed missing MongoErrors on some cursor methods (Issue #882) +* Correctly returning a null for the db instance on MongoClient.connect when auth fails (Issue #890) +* Added dropTarget option support for renameCollection/rename (Issue #891, help from https://github.com/jbottigliero) +* Fixed issue where connection using MongoClient.connect would fail if first server did not exist (Issue #885) + +1.2.12 2013-02-13 +----------------- +* Added limit/skip options to Collection.count (Issue #870) +* Added applySkipLimit option to Cursor.count (Issue #870) +* Enabled ping strategy as default for Replicaset if none specified (Issue #876) +* Should correctly pick nearest server for SECONDARY/SECONDARY_PREFERRED/NEAREST (Issue #878) + +1.2.11 2013-01-29 +----------------- +* Added fixes for handling type 2 binary due to PHP driver (Issue #864) +* Moved callBackStore to Base class to have single unified store (Issue #866) +* Ping strategy now reuses sockets unless they are closed by the server to avoid overhead + +1.2.10 2013-01-25 +----------------- +* Merged in SSL support for 2.4 supporting certificate validation and presenting certificates to the server. +* Only open a new HA socket when previous one dead (Issue #859, #857) +* Minor fixes + +1.2.9 2013-01-15 +---------------- +* Fixed bug in SSL support for MongoClient/Db.connect when discovering servers (Issue #849) +* Connection string with no db specified should default to admin db (Issue #848) +* Support port passed as string to Server class (Issue #844) +* Removed noOpen support for MongoClient/Db.connect as auto discovery of servers for Mongod/Mongos makes it not possible (Issue #842) +* Included toError wrapper code moved to utils.js file (Issue #839, #840) +* Rewrote cursor handling to avoid process.nextTick using trampoline instead to avoid stack overflow, speedup about 40% + +1.2.8 2013-01-07 +---------------- +* Accept function in a Map Reduce scope object not only a function string (Issue #826, https://github.com/aheckmann) +* Typo in db.authenticate caused a check (for provided connection) to return false, causing a connection AND onAll=true to be passed into __executeQueryCommand downstream (Issue #831, https://github.com/m4tty) +* Allow gridfs objects to use non ObjectID ids (Issue #825, https://github.com/nailgun) +* Removed the double wrap, by not passing an Error object to the wrap function (Issue #832, https://github.com/m4tty) +* Fix connection leak (gh-827) for HA replicaset health checks (Issue #833, https://github.com/aheckmann) +* Modified findOne to use nextObject instead of toArray avoiding a nextTick operation (Issue #836) +* Fixes for cursor stream to avoid multiple getmore issues when one in progress (Issue #818) +* Fixes .open replaying all backed up commands correctly if called after operations performed, (Issue #829 and #823) + +1.2.7 2012-12-23 +---------------- +* Rolled back batches as they hang in certain situations +* Fixes for NODE-25, keep reading from secondaries when primary goes down + +1.2.6 2012-12-21 +---------------- +* domain sockets shouldn't require a port arg (Issue #815, https://github.com/aheckmann) +* Cannot read property 'info' of null (Issue #809, https://github.com/thesmart) +* Cursor.each should work in batches (Issue #804, https://github.com/Swatinem) +* Cursor readPreference bug for non-supported read preferences (Issue #817) + +1.2.5 2012-12-12 +---------------- +* Fixed ssl regression, added more test coverage (Issue #800) +* Added better error reporting to the Db.connect if no valid serverConfig setup found (Issue #798) + +1.2.4 2012-12-11 +---------------- +* Fix to ensure authentication is correctly applied across all secondaries when using MongoClient. + +1.2.3 2012-12-10 +---------------- +* Fix for new replicaset members correctly authenticating when being added (Issue #791, https://github.com/m4tty) +* Fixed seek issue in gridstore when using stream (Issue #790) + +1.2.2 2012-12-03 +---------------- +* Fix for journal write concern not correctly being passed under some circumstances. +* Fixed correct behavior and re-auth for servers that get stepped down (Issue #779). + +1.2.1 2012-11-30 +---------------- +* Fix for double callback on insert with w:0 specified (Issue #783) +* Small cleanup of urlparser. + +1.2.0 2012-11-27 +---------------- +* Honor connectTimeoutMS option for replicasets (Issue #750, https://github.com/aheckmann) +* Fix ping strategy regression (Issue #738, https://github.com/aheckmann) +* Small cleanup of code (Issue #753, https://github.com/sokra/node-mongodb-native) +* Fixed index declaration using objects/arrays from other contexts (Issue #755, https://github.com/sokra/node-mongodb-native) +* Intermittent (and rare) null callback exception when using ReplicaSets (Issue #752) +* Force correct setting of read_secondary based on the read preference (Issue #741) +* If using read preferences with secondaries queries will not fail if primary is down (Issue #744) +* noOpen connection for Db.connect removed as not compatible with autodetection of Mongo type +* Mongos connection with auth not working (Issue #737) +* Use the connect method directly from the require. require('mongodb')("mongodb://localhost:27017/db") +* new MongoClient introduced as the point of connecting to MongoDB's instead of the Db + * open/close/db/connect methods implemented +* Implemented common URL connection format using MongoClient.connect allowing for simialar interface across all drivers. +* Fixed a bug with aggregation helper not properly accepting readPreference + +1.1.11 2012-10-10 +----------------- +* Removed strict mode and introduced normal handling of safe at DB level. + +1.1.10 2012-10-08 +----------------- +* fix Admin.serverStatus (Issue #723, https://github.com/Contra) +* logging on connection open/close(Issue #721, https://github.com/asiletto) +* more fixes for windows bson install (Issue #724) + +1.1.9 2012-10-05 +---------------- +* Updated bson to 0.1.5 to fix build problem on sunos/windows. + +1.1.8 2012-10-01 +---------------- +* Fixed db.eval to correctly handle system.js global javascript functions (Issue #709) +* Cleanup of non-closing connections (Issue #706) +* More cleanup of connections under replicaset (Issue #707, https://github.com/elbert3) +* Set keepalive on as default, override if not needed +* Cleanup of jsbon install to correctly build without install.js script (https://github.com/shtylman) +* Added domain socket support new Server("/tmp/mongodb.sock") style + +1.1.7 2012-09-10 +---------------- +* Protect against starting PingStrategy being called more than once (Issue #694, https://github.com/aheckmann) +* Make PingStrategy interval configurable (was 1 second, relaxed to 5) (Issue #693, https://github.com/aheckmann) +* Made PingStrategy api more consistant, callback to start/stop methods are optional (Issue #693, https://github.com/aheckmann) +* Proper stopping of strategy on replicaset stop +* Throw error when gridstore file is not found in read mode (Issue #702, https://github.com/jbrumwell) +* Cursor stream resume now using nextTick to avoid duplicated records (Issue #696) + +1.1.6 2012-09-01 +---------------- +* Fix for readPreference NEAREST for replicasets (Issue #693, https://github.com/aheckmann) +* Emit end correctly on stream cursor (Issue #692, https://github.com/Raynos) + +1.1.5 2012-08-29 +---------------- +* Fix for eval on replicaset Issue #684 +* Use helpful error msg when native parser not compiled (Issue #685, https://github.com/aheckmann) +* Arbiter connect hotfix (Issue #681, https://github.com/fengmk2) +* Upgraded bson parser to 0.1.2 using gyp, deprecated support for node 0.4.X +* Added name parameter to createIndex/ensureIndex to be able to override index names larger than 128 bytes +* Added exhaust option for find for feature completion (not recommended for normal use) +* Added tailableRetryInterval to find for tailable cursors to allow to control getMore retry time interval +* Fixes for read preferences when using MongoS to correctly handle no read preference set when iterating over a cursor (Issue #686) + +1.1.4 2012-08-12 +---------------- +* Added Mongos connection type with a fallback list for mongos proxies, supports ha (on by default) and will attempt to reconnect to failed proxies. +* Documents can now have a toBSON method that lets the user control the serialization behavior for documents being saved. +* Gridstore instance object now works as a readstream or writestream (thanks to code from Aaron heckmann (https://github.com/aheckmann/gridfs-stream)). +* Fix gridfs readstream (Issue #607, https://github.com/tedeh). +* Added disableDriverBSONSizeCheck property to Server.js for people who wish to push the inserts to the limit (Issue #609). +* Fixed bug where collection.group keyf given as Code is processed as a regular object (Issue #608, https://github.com/rrusso2007). +* Case mismatch between driver's ObjectID and mongo's ObjectId, allow both (Issue #618). +* Cleanup map reduce (Issue #614, https://github.com/aheckmann). +* Add proper error handling to gridfs (Issue #615, https://github.com/aheckmann). +* Ensure cursor is using same connection for all operations to avoid potential jump of servers when using replicasets. +* Date identification handled correctly in bson js parser when running in vm context. +* Documentation updates +* GridStore filename not set on read (Issue #621) +* Optimizations on the C++ bson parser to fix a potential memory leak and avoid non-needed calls +* Added support for awaitdata for tailable cursors (Issue #624) +* Implementing read preference setting at collection and cursor level + * collection.find().setReadPreference(Server.SECONDARY_PREFERRED) + * db.collection("some", {readPreference:Server.SECONDARY}) +* Replicaset now returns when the master is discovered on db.open and lets the rest of the connections happen asynchronous. + * ReplSet/ReplSetServers emits "fullsetup" when all servers have been connected to +* Prevent callback from executing more than once in getMore function (Issue #631, https://github.com/shankar0306) +* Corrupt bson messages now errors out to all callbacks and closes up connections correctly, Issue #634 +* Replica set member status update when primary changes bug (Issue #635, https://github.com/alinsilvian) +* Fixed auth to work better when multiple connections are involved. +* Default connection pool size increased to 5 connections. +* Fixes for the ReadStream class to work properly with 0.8 of Node.js +* Added explain function support to aggregation helper +* Added socketTimeoutMS and connectTimeoutMS to socket options for repl_set.js and server.js +* Fixed addUser to correctly handle changes in 2.2 for getLastError authentication required +* Added index to gridstore chunks on file_id (Issue #649, https://github.com/jacobbubu) +* Fixed Always emit db events (Issue #657) +* Close event not correctly resets DB openCalled variable to allow reconnect +* Added open event on connection established for replicaset, mongos and server +* Much faster BSON C++ parser thanks to Lucasfilm Singapore. +* Refactoring of replicaset connection logic to simplify the code. +* Add `options.connectArbiter` to decide connect arbiters or not (Issue #675) +* Minor optimization for findAndModify when not using j,w or fsync for safe + +1.0.2 2012-05-15 +---------------- +* Reconnect functionality for replicaset fix for mongodb 2.0.5 + +1.0.1 2012-05-12 +---------------- +* Passing back getLastError object as 3rd parameter on findAndModify command. +* Fixed a bunch of performance regressions in objectId and cursor. +* Fixed issue #600 allowing for single document delete to be passed in remove command. + +1.0.0 2012-04-25 +---------------- +* Fixes to handling of failover on server error +* Only emits error messages if there are error listeners to avoid uncaught events +* Server.isConnected using the server state variable not the connection pool state + +0.9.9.8 2012-04-12 +------------------ +* _id=0 is being turned into an ObjectID (Issue #551) +* fix for error in GridStore write method (Issue #559) +* Fix for reading a GridStore from arbitrary, non-chunk aligned offsets, added test (Issue #563, https://github.com/subroutine) +* Modified limitRequest to allow negative limits to pass through to Mongo, added test (Issue #561) +* Corrupt GridFS files when chunkSize < fileSize, fixed concurrency issue (Issue #555) +* Handle dead tailable cursors (Issue #568, https://github.com/aheckmann) +* Connection pools handles closing themselves down and clearing the state +* Check bson size of documents against maxBsonSize and throw client error instead of server error, (Issue #553) +* Returning update status document at the end of the callback for updates, (Issue #569) +* Refactor use of Arguments object to gain performance (Issue #574, https://github.com/AaronAsAChimp) + +0.9.9.7 2012-03-16 +------------------ +* Stats not returned from map reduce with inline results (Issue #542) +* Re-enable testing of whether or not the callback is called in the multi-chunk seek, fix small GridStore bug (Issue #543, https://github.com/pgebheim) +* Streaming large files from GridFS causes truncation (Issue #540) +* Make callback type checks agnostic to V8 context boundaries (Issue #545) +* Correctly throw error if an attempt is made to execute an insert/update/remove/createIndex/ensureIndex with safe enabled and no callback +* Db.open throws if the application attemps to call open again without calling close first + +0.9.9.6 2012-03-12 +------------------ +* BSON parser is externalized in it's own repository, currently using git master +* Fixes for Replicaset connectivity issue (Issue #537) +* Fixed issues with node 0.4.X vs 0.6.X (Issue #534) +* Removed SimpleEmitter and replaced with standard EventEmitter +* GridStore.seek fails to change chunks and call callback when in read mode (Issue #532) + +0.9.9.5 2012-03-07 +------------------ +* Merged in replSetGetStatus helper to admin class (Issue #515, https://github.com/mojodna) +* Merged in serverStatus helper to admin class (Issue #516, https://github.com/mojodna) +* Fixed memory leak in C++ bson parser (Issue #526) +* Fix empty MongoError "message" property (Issue #530, https://github.com/aheckmann) +* Cannot save files with the same file name to GridFS (Issue #531) + +0.9.9.4 2012-02-26 +------------------ +* bugfix for findAndModify: Error: corrupt bson message < 5 bytes long (Issue #519) + +0.9.9.3 2012-02-23 +------------------ +* document: save callback arguments are both undefined, (Issue #518) +* Native BSON parser install error with npm, (Issue #517) + +0.9.9.2 2012-02-17 +------------------ +* Improved detection of Buffers using Buffer.isBuffer instead of instanceof. +* Added wrap error around db.dropDatabase to catch all errors (Issue #512) +* Added aggregate helper to collection, only for MongoDB >= 2.1 + +0.9.9.1 2012-02-15 +------------------ +* Better handling of safe when using some commands such as createIndex, ensureIndex, addUser, removeUser, createCollection. +* Mapreduce now throws error if out parameter is not specified. + +0.9.9 2012-02-13 +---------------- +* Added createFromTime method on ObjectID to allow for queries against _id more easily using the timestamp. +* Db.close(true) now makes connection unusable as it's been force closed by app. +* Fixed mapReduce and group functions to correctly send slaveOk on queries. +* Fixes for find method to correctly work with find(query, fields, callback) (Issue #506). +* A fix for connection error handling when using the SSL on MongoDB. + +0.9.8-7 2012-02-06 +------------------ +* Simplified findOne to use the find command instead of the custom code (Issue #498). +* BSON JS parser not also checks for _bsonType variable in case BSON object is in weird scope (Issue #495). + +0.9.8-6 2012-02-04 +------------------ +* Removed the check for replicaset change code as it will never work with node.js. + +0.9.8-5 2012-02-02 +------------------ +* Added geoNear command to Collection. +* Added geoHaystackSearch command to Collection. +* Added indexes command to collection to retrieve the indexes on a Collection. +* Added stats command to collection to retrieve the statistics on a Collection. +* Added listDatabases command to admin object to allow retrieval of all available dbs. +* Changed createCreateIndexCommand to work better with options. +* Fixed dereference method on Db class to correctly dereference Db reference objects. +* Moved connect object onto Db class(Db.connect) as well as keeping backward compatibility. +* Removed writeBuffer method from gridstore, write handles switching automatically now. +* Changed readBuffer to read on Gridstore, Gridstore now only supports Binary Buffers no Strings anymore. +* Moved Long class to bson directory. + +0.9.8-4 2012-01-28 +------------------ +* Added reIndex command to collection and db level. +* Added support for $returnKey, $maxScan, $min, $max, $showDiskLoc, $comment to cursor and find/findOne methods. +* Added dropDups and v option to createIndex and ensureIndex. +* Added isCapped method to Collection. +* Added indexExists method to Collection. +* Added findAndRemove method to Collection. +* Fixed bug for replicaset connection when no active servers in the set. +* Fixed bug for replicaset connections when errors occur during connection. +* Merged in patch for BSON Number handling from Lee Salzman, did some small fixes and added test coverage. + +0.9.8-3 2012-01-21 +------------------ +* Workaround for issue with Object.defineProperty (Issue #484) +* ObjectID generation with date does not set rest of fields to zero (Issue #482) + +0.9.8-2 2012-01-20 +------------------ +* Fixed a missing this in the ReplSetServers constructor. + +0.9.8-1 2012-01-17 +------------------ +* FindAndModify bug fix for duplicate errors (Issue #481) + +0.9.8 2012-01-17 +---------------- +* Replicasets now correctly adjusts to live changes in the replicaset configuration on the servers, reconnecting correctly. + * Set the interval for checking for changes setting the replicaSetCheckInterval property when creating the ReplSetServers instance or on db.serverConfig.replicaSetCheckInterval. (default 1000 miliseconds) +* Fixes formattedOrderClause in collection.js to accept a plain hash as a parameter (Issue #469) https://github.com/tedeh +* Removed duplicate code for formattedOrderClause and moved to utils module +* Pass in poolSize for ReplSetServers to set default poolSize for new replicaset members +* Bug fix for BSON JS deserializer. Isolating the eval functions in separate functions to avoid V8 deoptimizations +* Correct handling of illegal BSON messages during deserialization +* Fixed Infinite loop when reading GridFs file with no chunks (Issue #471) +* Correctly update existing user password when using addUser (Issue #470) + +0.9.7.3-5 2012-01-04 +-------------------- +* Fix for RegExp serialization for 0.4.X where typeof /regexp/ == 'function' vs in 0.6.X typeof /regexp/ == 'object' +* Don't allow keepAlive and setNoDelay for 0.4.X as it throws errors + +0.9.7.3-4 2012-01-04 +-------------------- +* Chased down potential memory leak on findAndModify, Issue #467 (node.js removeAllListeners leaves the key in the _events object, node.js bug on eventlistener?, leads to extremely slow memory leak on listener object) +* Sanity checks for GridFS performance with benchmark added + +0.9.7.3-3 2012-01-04 +-------------------- +* Bug fixes for performance issues going form 0.9.6.X to 0.9.7.X on linux +* BSON bug fixes for performance + +0.9.7.3-2 2012-01-02 +-------------------- +* Fixed up documentation to reflect the preferred way of instantiating bson types +* GC bug fix for JS bson parser to avoid stop-and-go GC collection + +0.9.7.3-1 2012-01-02 +-------------------- +* Fix to make db.bson_serializer and db.bson_deserializer work as it did previously + +0.9.7.3 2011-12-30 +-------------------- +* Moved BSON_BINARY_SUBTYPE_DEFAULT from BSON object to Binary object and removed the BSON_BINARY_ prefixes +* Removed Native BSON types, C++ parser uses JS types (faster due to cost of crossing the JS-C++ barrier for each call) +* Added build fix for 0.4.X branch of Node.js where GetOwnPropertyNames is not defined in v8 +* Fix for wire protocol parser for corner situation where the message is larger than the maximum socket buffer in node.js (Issue #464, #461, #447) +* Connection pool status set to connected on poolReady, isConnected returns false on anything but connected status (Issue #455) + +0.9.7.2-5 2011-12-22 +-------------------- +* Brand spanking new Streaming Cursor support Issue #458 (https://github.com/christkv/node-mongodb-native/pull/458) thanks to Mr Aaron Heckmann + +0.9.7.2-4 2011-12-21 +-------------------- +* Refactoring of callback code to work around performance regression on linux +* Fixed group function to correctly use the command mode as default + +0.9.7.2-3 2011-12-18 +-------------------- +* Fixed error handling for findAndModify while still working for mongodb 1.8.6 (Issue #450). +* Allow for force send query to primary, pass option (read:'primary') on find command. + * ``find({a:1}, {read:'primary'}).toArray(function(err, items) {});`` + +0.9.7.2-2 2011-12-16 +-------------------- +* Fixes infinite streamRecords QueryFailure fix when using Mongos (Issue #442) + +0.9.7.2-1 2011-12-16 +-------------------- +* ~10% perf improvement for ObjectId#toHexString (Issue #448, https://github.com/aheckmann) +* Only using process.nextTick on errors emitted on callbacks not on all parsing, reduces number of ticks in the driver +* Changed parsing off bson messages to use process.nextTick to do bson parsing in batches if the message is over 10K as to yield more time to the event look increasing concurrency on big mongoreply messages with multiple documents + +0.9.7.2 2011-12-15 +------------------ +* Added SSL support for future version of mongodb (VERY VERY EXPERIMENTAL) + * pass in the ssl:true option to the server or replicaset server config to enable + * a bug either in mongodb or node.js does not allow for more than 1 connection pr db instance (poolSize:1). +* Added getTimestamp() method to objectID that returns a date object +* Added finalize function to collection.group + * function group (keys, condition, initial, reduce, finalize, command, callback) +* Reaper no longer using setTimeout to handle reaping. Triggering is done in the general flow leading to predictable behavior. + * reaperInterval, set interval for reaper (default 10000 miliseconds) + * reaperTimeout, set timeout for calls (default 30000 miliseconds) + * reaper, enable/disable reaper (default false) +* Work around for issues with findAndModify during high concurrency load, insure that the behavior is the same across the 1.8.X branch and 2.X branch of MongoDb +* Reworked multiple db's sharing same connection pool to behave correctly on error, timeout and close +* EnsureIndex command can be executed without a callback (Issue #438) +* Eval function no accepts options including nolock (Issue #432) + * eval(code, parameters, options, callback) (where options = {nolock:true}) + +0.9.7.1-4 2011-11-27 +-------------------- +* Replaced install.sh with install.js to install correctly on all supported os's + +0.9.7.1-3 2011-11-27 +-------------------- +* Fixes incorrect scope for ensureIndex error wrapping (Issue #419) https://github.com/ritch + +0.9.7.1-2 2011-11-27 +-------------------- +* Set statistical selection strategy as default for secondary choice. + +0.9.7.1-1 2011-11-27 +-------------------- +* Better handling of single server reconnect (fixes some bugs) +* Better test coverage of single server failure +* Correct handling of callbacks on replicaset servers when firewall dropping packets, correct reconnect + +0.9.7.1 2011-11-24 +------------------ +* Better handling of dead server for single server instances +* FindOne and find treats selector == null as {}, Issue #403 +* Possible to pass in a strategy for the replicaset to pick secondary reader node + * parameter strategy + * ping (default), pings the servers and picks the one with the lowest ping time + * statistical, measures each request and pick the one with the lowest mean and std deviation +* Set replicaset read preference replicaset.setReadPreference() + * Server.READ_PRIMARY (use primary server for reads) + * Server.READ_SECONDARY (from a secondary server (uses the strategy set)) + * tags, {object of tags} +* Added replay of commands issued to a closed connection when the connection is re-established +* Fix isConnected and close on unopened connections. Issue #409, fix by (https://github.com/sethml) +* Moved reaper to db.open instead of constructor (Issue #406) +* Allows passing through of socket connection settings to Server or ReplSetServer under the option socketOptions + * timeout = set seconds before connection times out (default 0) + * noDelay = Disables the Nagle algorithm (default true) + * keepAlive = Set if keepAlive is used (default 0, which means no keepAlive, set higher than 0 for keepAlive) + * encoding = ['ascii', 'utf8', or 'base64'] (default null) +* Fixes for handling of errors during shutdown off a socket connection +* Correctly applies socket options including timeout +* Cleanup of test management code to close connections correctly +* Handle parser errors better, closing down the connection and emitting an error +* Correctly emit errors from server.js only wrapping errors that are strings + +0.9.7 2011-11-10 +---------------- +* Added priority setting to replicaset manager +* Added correct handling of passive servers in replicaset +* Reworked socket code for simpler clearer handling +* Correct handling of connections in test helpers +* Added control of retries on failure + * control with parameters retryMiliSeconds and numberOfRetries when creating a db instance +* Added reaper that will timeout and cleanup queries that never return + * control with parameters reaperInterval and reaperTimeout when creating a db instance +* Refactored test helper classes for replicaset tests +* Allows raw (no bson parser mode for insert, update, remove, find and findOne) + * control raw mode passing in option raw:true on the commands + * will return buffers with the binary bson objects +* Fixed memory leak in cursor.toArray +* Fixed bug in command creation for mongodb server with wrong scope of call +* Added db(dbName) method to db.js to allow for reuse of connections against other databases +* Serialization of functions in an object is off by default, override with parameter + * serializeFunctions [true/false] on db level, collection level or individual insert/update/findAndModify +* Added Long.fromString to c++ class and fixed minor bug in the code (Test case for $gt operator on 64-bit integers, Issue #394) +* FindOne and find now share same code execution and will work in the same manner, Issue #399 +* Fix for tailable cursors, Issue #384 +* Fix for Cursor rewind broken, Issue #389 +* Allow Gridstore.exist to query using regexp, Issue #387, fix by (https://github.com/kaij) +* Updated documentation on https://github.com/christkv/node-mongodb-native +* Fixed toJSON methods across all objects for BSON, Binary return Base64 Encoded data + +0.9.6-22 2011-10-15 +------------------- +* Fixed bug in js bson parser that could cause wrong object size on serialization, Issue #370 +* Fixed bug in findAndModify that did not throw error on replicaset timeout, Issue #373 + +0.9.6-21 2011-10-05 +------------------- +* Reworked reconnect code to work correctly +* Handling errors in different parts of the code to ensure that it does not lock the connection +* Consistent error handling for Object.createFromHexString for JS and C++ + +0.9.6-20 2011-10-04 +------------------- +* Reworked bson.js parser to get rid off Array.shift() due to it allocating new memory for each call. Speedup varies between 5-15% depending on doc +* Reworked bson.cc to throw error when trying to serialize js bson types +* Added MinKey, MaxKey and Double support for JS and C++ parser +* Reworked socket handling code to emit errors on unparsable messages +* Added logger option for Db class, lets you pass in a function in the shape + { + log : function(message, object) {}, + error : function(errorMessage, errorObject) {}, + debug : function(debugMessage, object) {}, + } + + Usage is new Db(new Server(..), {logger: loggerInstance}) + +0.9.6-19 2011-09-29 +------------------- +* Fixing compatibility issues between C++ bson parser and js parser +* Added Symbol support to C++ parser +* Fixed socket handling bug for seldom misaligned message from mongodb +* Correctly handles serialization of functions using the C++ bson parser + +0.9.6-18 2011-09-22 +------------------- +* Fixed bug in waitForConnection that would lead to 100% cpu usage, Issue #352 + +0.9.6-17 2011-09-21 +------------------- +* Fixed broken exception test causing bamboo to hang +* Handling correctly command+lastError when both return results as in findAndModify, Issue #351 + +0.9.6-16 2011-09-14 +------------------- +* Fixing a bunch of issues with compatibility with MongoDB 2.0.X branch. Some fairly big changes in behavior from 1.8.X to 2.0.X on the server. +* Error Connection MongoDB V2.0.0 with Auth=true, Issue #348 + +0.9.6-15 2011-09-09 +------------------- +* Fixed issue where pools would not be correctly cleaned up after an error, Issue #345 +* Fixed authentication issue with secondary servers in Replicaset, Issue #334 +* Duplicate replica-set servers when omitting port, Issue #341 +* Fixing findAndModify to correctly work with Replicasets ensuring proper error handling, Issue #336 +* Merged in code from (https://github.com/aheckmann) that checks for global variable leaks + +0.9.6-14 2011-09-05 +------------------- +* Minor fixes for error handling in cursor streaming (https://github.com/sethml), Issue #332 +* Minor doc fixes +* Some more cursor sort tests added, Issue #333 +* Fixes to work with 0.5.X branch +* Fix Db not removing reconnect listener from serverConfig, (https://github.com/sbrekken), Issue #337 +* Removed node_events.h includes (https://github.com/jannehietamaki), Issue #339 +* Implement correct safe/strict mode for findAndModify. + +0.9.6-13 2011-08-24 +------------------- +* Db names correctly error checked for illegal characters + +0.9.6-12 2011-08-24 +------------------- +* Nasty bug in GridFS if you changed the default chunk size +* Fixed error handling bug in findOne + +0.9.6-11 2011-08-23 +------------------- +* Timeout option not correctly making it to the cursor, Issue #320, Fix from (https://github.com/year2013) +* Fixes for memory leaks when using buffers and C++ parser +* Fixes to make tests pass on 0.5.X +* Cleanup of bson.js to remove duplicated code paths +* Fix for errors occurring in ensureIndex, Issue #326 +* Removing require.paths to make tests work with the 0.5.X branch + +0.9.6-10 2011-08-11 +------------------- +* Specific type Double for capped collections (https://github.com/mbostock), Issue #312 +* Decorating Errors with all all object info from Mongo (https://github.com/laurie71), Issue #308 +* Implementing fixes for mongodb 1.9.1 and higher to make tests pass +* Admin validateCollection now takes an options argument for you to pass in full option +* Implemented keepGoing parameter for mongodb 1.9.1 or higher, Issue #310 +* Added test for read_secondary count issue, merged in fix from (https://github.com/year2013), Issue #317 + +0.9.6-9 +------- +* Bug fix for bson parsing the key '':'' correctly without crashing + +0.9.6-8 +------- +* Changed to using node.js crypto library MD5 digest +* Connect method support documented mongodb: syntax by (https://github.com/sethml) +* Support Symbol type for BSON, serializes to it's own type Symbol, Issue #302, #288 +* Code object without scope serializing to correct BSON type +* Lot's of fixes to avoid double callbacks (https://github.com/aheckmann) Issue #304 +* Long deserializes as Number for values in the range -2^53 to 2^53, Issue #305 (https://github.com/sethml) +* Fixed C++ parser to reflect JS parser handling of long deserialization +* Bson small optimizations + +0.9.6-7 2011-07-13 +------------------ +* JS Bson deserialization bug #287 + +0.9.6-6 2011-07-12 +------------------ +* FindAndModify not returning error message as other methods Issue #277 +* Added test coverage for $push, $pushAll and $inc atomic operations +* Correct Error handling for non 12/24 bit ids on Pure JS ObjectID class Issue #276 +* Fixed terrible deserialization bug in js bson code #285 +* Fix by andrewjstone to avoid throwing errors when this.primary not defined + +0.9.6-5 2011-07-06 +------------------ +* Rewritten BSON js parser now faster than the C parser on my core2duo laptop +* Added option full to indexInformation to get all index info Issue #265 +* Passing in ObjectID for new Gridstore works correctly Issue #272 + +0.9.6-4 2011-07-01 +------------------ +* Added test and bug fix for insert/update/remove without callback supplied + +0.9.6-3 2011-07-01 +------------------ +* Added simple grid class called Grid with put, get, delete methods +* Fixed writeBuffer/readBuffer methods on GridStore so they work correctly +* Automatic handling of buffers when using write method on GridStore +* GridStore now accepts a ObjectID instead of file name for write and read methods +* GridStore.list accepts id option to return of file ids instead of filenames +* GridStore close method returns document for the file allowing user to reference _id field + +0.9.6-2 2011-06-30 +------------------ +* Fixes for reconnect logic for server object (replays auth correctly) +* More testcases for auth +* Fixes in error handling for replicaset +* Fixed bug with safe parameter that would fail to execute safe when passing w or wtimeout +* Fixed slaveOk bug for findOne method +* Implemented auth support for replicaset and test cases +* Fixed error when not passing in rs_name + +0.9.6-1 2011-06-25 +------------------ +* Fixes for test to run properly using c++ bson parser +* Fixes for dbref in native parser (correctly handles ref without db component) +* Connection fixes for replicasets to avoid runtime conditions in cygwin (https://github.com/vincentcr) +* Fixes for timestamp in js bson parser (distinct timestamp type now) + +0.9.6 2011-06-21 +---------------- +* Worked around npm version handling bug +* Race condition fix for cygwin (https://github.com/vincentcr) + +0.9.5-1 2011-06-21 +------------------ +* Extracted Timestamp as separate class for bson js parser to avoid instanceof problems +* Fixed driver strict mode issue + +0.9.5 2011-06-20 +---------------- +* Replicaset support (failover and reading from secondary servers) +* Removed ServerPair and ServerCluster +* Added connection pool functionality +* Fixed serious bug in C++ bson parser where bytes > 127 would generate 2 byte sequences +* Allows for forcing the server to assign ObjectID's using the option {forceServerObjectId: true} + +0.6.8 +----- +* Removed multiple message concept from bson +* Changed db.open(db) to be db.open(err, db) + +0.1 2010-01-30 +-------------- +* Initial release support of driver using native node.js interface +* Supports gridfs specification +* Supports admin functionality diff --git a/node_modules/mongoose/node_modules/mongodb/LICENSE b/node_modules/mongoose/node_modules/mongodb/LICENSE new file mode 100644 index 0000000..ad410e1 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/node_modules/mongoose/node_modules/mongodb/Makefile b/node_modules/mongoose/node_modules/mongodb/Makefile new file mode 100644 index 0000000..36e1202 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/Makefile @@ -0,0 +1,11 @@ +NODE = node +NPM = npm +JSDOC = jsdoc +name = all + +generate_docs: + # cp -R ./HISTORY.md ./docs/content/meta/release-notes.md + hugo -s docs/reference -d ../../public + $(JSDOC) -c conf.json -t docs/jsdoc-template/ -d ./public/api + cp -R ./public/api/scripts ./public/. + cp -R ./public/api/styles ./public/. diff --git a/node_modules/mongoose/node_modules/mongodb/README.md b/node_modules/mongoose/node_modules/mongodb/README.md new file mode 100644 index 0000000..3b8fa37 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/README.md @@ -0,0 +1,415 @@ +[![NPM](https://nodei.co/npm/mongodb.png?downloads=true&downloadRank=true)](https://nodei.co/npm/mongodb/) [![NPM](https://nodei.co/npm-dl/mongodb.png?months=6&height=3)](https://nodei.co/npm/mongodb/) + +[![Build Status](https://secure.travis-ci.org/mongodb/node-mongodb-native.svg?branch=2.1)](http://travis-ci.org/mongodb/node-mongodb-native) +[![Coverage Status](https://coveralls.io/repos/github/mongodb/node-mongodb-native/badge.svg?branch=2.1)](https://coveralls.io/github/mongodb/node-mongodb-native?branch=2.1) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mongodb/node-mongodb-native?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +# Description + +The official [MongoDB](https://www.mongodb.com/) driver for Node.js. Provides a high-level API on top of [mongodb-core](https://www.npmjs.com/package/mongodb-core) that is meant for end users. + +## MongoDB Node.JS Driver + +| what | where | +|---------------|------------------------------------------------| +| documentation | http://mongodb.github.io/node-mongodb-native/ | +| api-doc | http://mongodb.github.io/node-mongodb-native/2.2/api/ | +| source | https://github.com/mongodb/node-mongodb-native | +| mongodb | http://www.mongodb.org/ | + +### Blogs of Engineers involved in the driver +- Christian Kvalheim [@christkv](https://twitter.com/christkv) + +### Bugs / Feature Requests + +Think you’ve found a bug? Want to see a new feature in node-mongodb-native? Please open a +case in our issue management tool, JIRA: + +- Create an account and login . +- Navigate to the NODE project . +- Click **Create Issue** - Please provide as much information as possible about the issue type and how to reproduce it. + +Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) and the +Core Server (i.e. SERVER) project are **public**. + +### Questions and Bug Reports + + * mailing list: https://groups.google.com/forum/#!forum/node-mongodb-native + * jira: http://jira.mongodb.org/ + +### Change Log + +http://jira.mongodb.org/browse/NODE + +# Installation + +The recommended way to get started using the Node.js 2.0 driver is by using the `NPM` (Node Package Manager) to install the dependency in your project. + +## MongoDB Driver + +Given that you have created your own project using `npm init` we install the mongodb driver and it's dependencies by executing the following `NPM` command. + +``` +npm install mongodb --save +``` + +This will download the MongoDB driver and add a dependency entry in your `package.json` file. + +## Troubleshooting + +The MongoDB driver depends on several other packages. These are. + +* mongodb-core +* bson +* kerberos +* node-gyp + +The `kerberos` package is a C++ extension that requires a build environment to be installed on your system. You must be able to build node.js itself to be able to compile and install the `kerberos` module. Furthermore the `kerberos` module requires the MIT Kerberos package to correctly compile on UNIX operating systems. Consult your UNIX operation system package manager what libraries to install. + +{{% note class="important" %}} +Windows already contains the SSPI API used for Kerberos authentication. However you will need to install a full compiler tool chain using visual studio C++ to correctly install the kerberos extension. +{{% /note %}} + +### Diagnosing on UNIX + +If you don’t have the build essentials it won’t build. In the case of linux you will need gcc and g++, node.js with all the headers and python. The easiest way to figure out what’s missing is by trying to build the kerberos project. You can do this by performing the following steps. + +``` +git clone https://github.com/christkv/kerberos.git +cd kerberos +npm install +``` + +If all the steps complete you have the right toolchain installed. If you get node-gyp not found you need to install it globally by doing. + +``` +npm install -g node-gyp +``` + +If correctly compiles and runs the tests you are golden. We can now try to install the mongod driver by performing the following command. + +``` +cd yourproject +npm install mongodb --save +``` + +If it still fails the next step is to examine the npm log. Rerun the command but in this case in verbose mode. + +``` +npm --loglevel verbose install mongodb +``` + +This will print out all the steps npm is performing while trying to install the module. + +### Diagnosing on Windows + +A known compiler tool chain known to work for compiling `kerberos` on windows is the following. + +* Visual Studio c++ 2010 (do not use higher versions) +* Windows 7 64bit SDK +* Python 2.7 or higher + +Open visual studio command prompt. Ensure node.exe is in your path and install node-gyp. + +``` +npm install -g node-gyp +``` + +Next you will have to build the project manually to test it. Use any tool you use with git and grab the repo. + +``` +git clone https://github.com/christkv/kerberos.git +cd kerberos +npm install +node-gyp rebuild +``` + +This should rebuild the driver successfully if you have everything set up correctly. + +### Other possible issues + +Your python installation might be hosed making gyp break. I always recommend that you test your deployment environment first by trying to build node itself on the server in question as this should unearth any issues with broken packages (and there are a lot of broken packages out there). + +Another thing is to ensure your user has write permission to wherever the node modules are being installed. + +QuickStart +========== +The quick start guide will show you how to setup a simple application using node.js and MongoDB. Its scope is only how to set up the driver and perform the simple crud operations. For more in depth coverage we encourage reading the tutorials. + +Create the package.json file +---------------------------- +Let's create a directory where our application will live. In our case we will put this under our projects directory. + +``` +mkdir myproject +cd myproject +``` + +Enter the following command and answer the questions to create the initial structure for your new project + +``` +npm init +``` + +Next we need to edit the generated package.json file to add the dependency for the MongoDB driver. The package.json file below is just an example and your will look different depending on how you answered the questions after entering `npm init` + +``` +{ + "name": "myproject", + "version": "1.0.0", + "description": "My first project", + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/christkv/myfirstproject.git" + }, + "dependencies": { + "mongodb": "~2.0" + }, + "author": "Christian Kvalheim", + "license": "Apache 2.0", + "bugs": { + "url": "https://github.com/christkv/myfirstproject/issues" + }, + "homepage": "https://github.com/christkv/myfirstproject" +} +``` + +Save the file and return to the shell or command prompt and use **NPM** to install all the dependencies. + +``` +npm install +``` + +You should see **NPM** download a lot of files. Once it's done you'll find all the downloaded packages under the **node_modules** directory. + +Booting up a MongoDB Server +--------------------------- +Let's boot up a MongoDB server instance. Download the right MongoDB version from [MongoDB](http://www.mongodb.org), open a new shell or command line and ensure the **mongod** command is in the shell or command line path. Now let's create a database directory (in our case under **/data**). + +``` +mongod --dbpath=/data --port 27017 +``` + +You should see the **mongod** process start up and print some status information. + +Connecting to MongoDB +--------------------- +Let's create a new **app.js** file that we will use to show the basic CRUD operations using the MongoDB driver. + +First let's add code to connect to the server and the database **myproject**. + +```js +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL +var url = 'mongodb://localhost:27017/myproject'; +// Use connect method to connect to the Server +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + db.close(); +}); +``` + +Given that you booted up the **mongod** process earlier the application should connect successfully and print **Connected correctly to server** to the console. + +Let's Add some code to show the different CRUD operations available. + +Inserting a Document +-------------------- +Let's create a function that will insert some documents for us. + +```js +var insertDocuments = function(db, callback) { + // Get the documents collection + var collection = db.collection('documents'); + // Insert some documents + collection.insertMany([ + {a : 1}, {a : 2}, {a : 3} + ], function(err, result) { + assert.equal(err, null); + assert.equal(3, result.result.n); + assert.equal(3, result.ops.length); + console.log("Inserted 3 documents into the document collection"); + callback(result); + }); +} +``` + +The insert command will return a results object that contains several fields that might be useful. + +* **result** Contains the result document from MongoDB +* **ops** Contains the documents inserted with added **_id** fields +* **connection** Contains the connection used to perform the insert + +Let's add call the **insertDocuments** command to the **MongoClient.connect** method callback. + +```js +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL +var url = 'mongodb://localhost:27017/myproject'; +// Use connect method to connect to the Server +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + insertDocuments(db, function() { + db.close(); + }); +}); +``` + +We can now run the update **app.js** file. + +``` +node app.js +``` + +You should see the following output after running the **app.js** file. + +``` +Connected correctly to server +Inserted 3 documents into the document collection +``` + +Updating a document +------------------- +Let's look at how to do a simple document update by adding a new field **b** to the document that has the field **a** set to **2**. + +```js +var updateDocument = function(db, callback) { + // Get the documents collection + var collection = db.collection('documents'); + // Update document where a is 2, set b equal to 1 + collection.updateOne({ a : 2 } + , { $set: { b : 1 } }, function(err, result) { + assert.equal(err, null); + assert.equal(1, result.result.n); + console.log("Updated the document with the field a equal to 2"); + callback(result); + }); +} +``` + +The method will update the first document where the field **a** is equal to **2** by adding a new field **b** to the document set to **1**. Let's update the callback function from **MongoClient.connect** to include the update method. + +```js +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL +var url = 'mongodb://localhost:27017/myproject'; +// Use connect method to connect to the Server +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + insertDocuments(db, function() { + updateDocument(db, function() { + db.close(); + }); + }); +}); +``` + +Delete a document +----------------- +Next lets delete the document where the field **a** equals to **3**. + +```js +var deleteDocument = function(db, callback) { + // Get the documents collection + var collection = db.collection('documents'); + // Delete document where a is 3 + collection.deleteOne({ a : 3 }, function(err, result) { + assert.equal(err, null); + assert.equal(1, result.result.n); + console.log("Removed the document with the field a equal to 3"); + callback(result); + }); +} +``` + +This will delete the first document where the field **a** equals to **3**. Let's add the method to the **MongoClient +.connect** callback function. + +```js +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL +var url = 'mongodb://localhost:27017/myproject'; +// Use connect method to connect to the Server +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + insertDocuments(db, function() { + updateDocument(db, function() { + deleteDocument(db, function() { + db.close(); + }); + }); + }); +}); +``` + +Finally let's retrieve all the documents using a simple find. + +Find All Documents +------------------ +We will finish up the Quickstart CRUD methods by performing a simple query that returns all the documents matching the query. + +```js +var findDocuments = function(db, callback) { + // Get the documents collection + var collection = db.collection('documents'); + // Find some documents + collection.find({}).toArray(function(err, docs) { + assert.equal(err, null); + assert.equal(2, docs.length); + console.log("Found the following records"); + console.dir(docs); + callback(docs); + }); +} +``` + +This query will return all the documents in the **documents** collection. Since we deleted a document the total +documents returned is **2**. Finally let's add the findDocument method to the **MongoClient.connect** callback. + +```js +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL +var url = 'mongodb://localhost:27017/myproject'; +// Use connect method to connect to the Server +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to server"); + + insertDocuments(db, function() { + updateDocument(db, function() { + deleteDocument(db, function() { + findDocuments(db, function() { + db.close(); + }); + }); + }); + }); +}); +``` + +This concludes the QuickStart of connecting and performing some Basic operations using the MongoDB Node.js driver. For more detailed information you can look at the tutorials covering more specific topics of interest. + +## Next Steps + + * [MongoDB Documentation](http://mongodb.org/) + * [Read about Schemas](http://learnmongodbthehardway.com/) + * [Star us on GitHub](https://github.com/mongodb/node-mongodb-native) diff --git a/node_modules/mongoose/node_modules/mongodb/THIRD-PARTY-NOTICES b/node_modules/mongoose/node_modules/mongodb/THIRD-PARTY-NOTICES new file mode 100644 index 0000000..c13e5d9 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/THIRD-PARTY-NOTICES @@ -0,0 +1,41 @@ +Mongodb-core uses third-party libraries or other resources that may +be distributed under licenses different than the Mongodb-core software. + +In the event that we accidentally failed to list a required notice, +please bring it to our attention through any of the ways detailed here: + + mongodb-dev@googlegroups.com + +The attached notices are provided for information only. + +For any licenses that require disclosure of source, sources are available at +https://github.com/mongodb/node-mongodb-native. + +1) License Notice for nan.h +--------------------------- + +The MIT License (MIT) +===================== + +Copyright (c) 2016 NAN contributors +----------------------------------- + +NAN contributors listed at + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to +do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/node_modules/mongoose/node_modules/mongodb/boot_auth.js b/node_modules/mongoose/node_modules/mongodb/boot_auth.js new file mode 100644 index 0000000..95956c7 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/boot_auth.js @@ -0,0 +1,52 @@ +var ReplSetManager = require('mongodb-topology-manager').ReplSet, + f = require('util').format; + +var rsOptions = { + server: { + keyFile: __dirname + '/test/functional/data/keyfile.txt', + auth: null, + replSet: 'rs' + }, + client: { + replSet: 'rs' + } +} + +// Set up the nodes +var nodes = [{ + options: { + bind_ip: 'localhost', port: 31000, + dbpath: f('%s/../db/31000', __dirname), + } +}, { + options: { + bind_ip: 'localhost', port: 31001, + dbpath: f('%s/../db/31001', __dirname), + } +}, { + options: { + bind_ip: 'localhost', port: 31002, + dbpath: f('%s/../db/31002', __dirname), + } +}] + +// Merge in any node start up options +for(var i = 0; i < nodes.length; i++) { + for(var name in rsOptions.server) { + nodes[i].options[name] = rsOptions.server[name]; + } +} + +// Create a manager +var replicasetManager = new ReplSetManager('mongod', nodes, rsOptions.client); +// Purge the set +replicasetManager.purge().then(function() { + // Start the server + replicasetManager.start().then(function() { + process.exit(0); + }).catch(function(e) { + console.log("====== ") + console.dir(e) + // // console.dir(e); + }); +}); diff --git a/node_modules/mongoose/node_modules/mongodb/conf.json b/node_modules/mongoose/node_modules/mongodb/conf.json new file mode 100644 index 0000000..99eb3a7 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/conf.json @@ -0,0 +1,76 @@ +{ + "plugins": ["plugins/markdown", "docs/lib/jsdoc/examples_plugin.js"], + "source": { + "include": [ + "test/functional/operation_example_tests.js", + "test/functional/operation_promises_example_tests.js", + "test/functional/operation_generators_example_tests.js", + "test/functional/authentication_tests.js", + "test/functional/gridfs_stream_tests.js", + "lib/admin.js", + "lib/collection.js", + "lib/cursor.js", + "lib/aggregation_cursor.js", + "lib/command_cursor.js", + "lib/db.js", + "lib/mongo_client.js", + "lib/mongos.js", + "lib/read_preference.js", + "lib/replset.js", + "lib/server.js", + "lib/bulk/common.js", + "lib/bulk/ordered.js", + "lib/bulk/unordered.js", + "lib/gridfs/grid_store.js", + "node_modules/mongodb-core/lib/error.js", + "lib/gridfs-stream/index.js", + "lib/gridfs-stream/download.js", + "lib/gridfs-stream/upload.js", + "node_modules/mongodb-core/lib/connection/logger.js", + "node_modules/bson/lib/bson/binary.js", + "node_modules/bson/lib/bson/code.js", + "node_modules/bson/lib/bson/db_ref.js", + "node_modules/bson/lib/bson/double.js", + "node_modules/bson/lib/bson/long.js", + "node_modules/bson/lib/bson/objectid.js", + "node_modules/bson/lib/bson/symbol.js", + "node_modules/bson/lib/bson/timestamp.js", + "node_modules/bson/lib/bson/max_key.js", + "node_modules/bson/lib/bson/min_key.js", + "node_modules/bson/lib/bson/decimal128.js", + "node_modules/bson/lib/bson/int_32.js", + "node_modules/bson/lib/bson/regexp.js" + ] + }, + "templates": { + "cleverLinks": true, + "monospaceLinks": true, + "default": { + "outputSourceFiles" : true + }, + "applicationName": "Node.js MongoDB Driver API", + "disqus": true, + "googleAnalytics": "UA-29229787-1", + "openGraph": { + "title": "", + "type": "website", + "image": "", + "site_name": "", + "url": "" + }, + "meta": { + "title": "", + "description": "", + "keyword": "" + }, + "linenums": true + }, + "markdown": { + "parser": "gfm", + "hardwrap": true, + "tags": ["examples"] + }, + "examples": { + "indent": 4 + } +} diff --git a/node_modules/mongoose/node_modules/mongodb/index.js b/node_modules/mongoose/node_modules/mongodb/index.js new file mode 100644 index 0000000..4e328fa --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/index.js @@ -0,0 +1,56 @@ +// Core module +var core = require('mongodb-core'), + Instrumentation = require('./lib/apm'); + +// Set up the connect function +var connect = require('./lib/mongo_client').connect; + +// Expose error class +connect.MongoError = core.MongoError; + +// Actual driver classes exported +connect.Admin = require('./lib/admin'); +connect.MongoClient = require('./lib/mongo_client'); +connect.Db = require('./lib/db'); +connect.Collection = require('./lib/collection'); +connect.Server = require('./lib/server'); +connect.ReplSet = require('./lib/replset'); +connect.Mongos = require('./lib/mongos'); +connect.ReadPreference = require('./lib/read_preference'); +connect.GridStore = require('./lib/gridfs/grid_store'); +connect.Chunk = require('./lib/gridfs/chunk'); +connect.Logger = core.Logger; +connect.Cursor = require('./lib/cursor'); +connect.GridFSBucket = require('./lib/gridfs-stream'); +// Exported to be used in tests not to be used anywhere else +connect.CoreServer = require('mongodb-core').Server; +connect.CoreConnection = require('mongodb-core').Connection; + +// BSON types exported +connect.Binary = core.BSON.Binary; +connect.Code = core.BSON.Code; +connect.Map = core.BSON.Map; +connect.DBRef = core.BSON.DBRef; +connect.Double = core.BSON.Double; +connect.Int32 = core.BSON.Int32; +connect.Long = core.BSON.Long; +connect.MinKey = core.BSON.MinKey; +connect.MaxKey = core.BSON.MaxKey; +connect.ObjectID = core.BSON.ObjectID; +connect.ObjectId = core.BSON.ObjectID; +connect.Symbol = core.BSON.Symbol; +connect.Timestamp = core.BSON.Timestamp; +connect.BSONRegExp = core.BSON.BSONRegExp; +connect.Decimal128 = core.BSON.Decimal128; + +// Add connect method +connect.connect = connect; + +// Set up the instrumentation method +connect.instrument = function(options, callback) { + if(typeof options == 'function') callback = options, options = {}; + return new Instrumentation(core, options, callback); +} + +// Set our exports to be the connect function +module.exports = connect; diff --git a/node_modules/mongoose/node_modules/mongodb/insert_bench.js b/node_modules/mongoose/node_modules/mongodb/insert_bench.js new file mode 100644 index 0000000..5c4d0b9 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/insert_bench.js @@ -0,0 +1,231 @@ +var MongoClient = require('./').MongoClient, + assert = require('assert'); + +// var memwatch = require('memwatch-next'); +// memwatch.on('leak', function(info) { +// console.log("======== leak") +// }); +// +// memwatch.on('stats', function(stats) { +// console.log("======== stats") +// console.dir(stats) +// }); + +// // Take first snapshot +// var hd = new memwatch.HeapDiff(); + +MongoClient.connect('mongodb://localhost:27017/bench', function(err, db) { + var docs = []; + var total = 1000; + var count = total; + var measurements = []; + + // Insert a bunch of documents + for(var i = 0; i < 100; i++) { + docs.push(JSON.parse(data)); + } + + var col = db.collection('inserts'); + + function execute(col, callback) { + var start = new Date().getTime(); + + col.find({}).limit(100).toArray(function(e, docs) { + measurements.push(new Date().getTime() - start); + assert.equal(null, e); + callback(); + }); + } + + console.log("== insert documents") + col.insert(docs, function(e, r) { + docs = []; + assert.equal(null, e); + + console.log("== start bench") + for(var i = 0; i < total; i++) { + execute(col, function(e) { + count = count - 1; + + if(count == 0) { + // Calculate total execution time for operations + var totalTime = measurements.reduce(function(prev, curr) { + return prev + curr; + }, 0); + + console.log("==========================================="); + console.log("total time: " + totalTime) + + // var diff = hd.end(); + // console.log("==========================================="); + // console.log(JSON.stringify(diff, null, 2)) + + db.close(); + process.exit(0) + } + }); + } + }); +}); + +var data = JSON.stringify({ + "data": [ + { + "_id": 1, + "x": 11 + }, + { + "_id": 2, + "x": 22 + }, + { + "_id": 3, + "x": 33 + } + ], + "collection_name": "test", + "database_name": "command-monitoring-tests", + "tests": [ + { + "description": "A successful mixed bulk write", + "operation": { + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "insertOne": { + "document": { + "_id": 4, + "x": 44 + } + } + }, + { + "updateOne": { + "filter": { + "_id": 3 + }, + "update": { + "set": { + "x": 333 + } + } + } + } + ] + } + }, + "expectations": [ + { + "command_started_event": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4, + "x": 44 + } + ], + "ordered": true + }, + "command_name": "insert", + "database_name": "command-monitoring-tests" + } + }, + { + "command_succeeded_event": { + "reply": { + "ok": 1.0, + "n": 1 + }, + "command_name": "insert" + } + }, + { + "command_started_event": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 3 + }, + "u": { + "set": { + "x": 333 + } + }, + "upsert": false, + "multi": false + } + ], + "ordered": true + }, + "command_name": "update", + "database_name": "command-monitoring-tests" + } + }, + { + "command_succeeded_event": { + "reply": { + "ok": 1.0, + "n": 1 + }, + "command_name": "update" + } + } + ] + }, + { + "description": "A successful unordered bulk write with an unacknowledged write concern", + "operation": { + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "insertOne": { + "document": { + "_id": 4, + "x": 44 + } + } + } + ], + "ordered": false, + "writeConcern": { + "w": 0 + } + } + }, + "expectations": [ + { + "command_started_event": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4, + "x": 44 + } + ], + "ordered": false, + "writeConcern": { + "w": 0 + } + }, + "command_name": "insert", + "database_name": "command-monitoring-tests" + } + }, + { + "command_succeeded_event": { + "reply": { + "ok": 1.0 + }, + "command_name": "insert" + } + } + ] + } + ] +}); diff --git a/node_modules/mongoose/node_modules/mongodb/lib/admin.js b/node_modules/mongoose/node_modules/mongodb/lib/admin.js new file mode 100644 index 0000000..4675da4 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/admin.js @@ -0,0 +1,579 @@ +"use strict"; + +var toError = require('./utils').toError, + Define = require('./metadata'), + shallowClone = require('./utils').shallowClone, + assign = require('./utils').assign, + authenticate = require('./authenticate'); + +/** + * @fileOverview The **Admin** class is an internal class that allows convenient access to + * the admin functionality and commands for MongoDB. + * + * **ADMIN Cannot directly be instantiated** + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Use the admin database for the operation + * var adminDb = db.admin(); + * + * // List all the available databases + * adminDb.listDatabases(function(err, dbs) { + * test.equal(null, err); + * test.ok(dbs.databases.length > 0); + * db.close(); + * }); + * }); + */ + +/** + * Create a new Admin instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @return {Admin} a collection instance. + */ +var Admin = function(db, topology, promiseLibrary) { + if(!(this instanceof Admin)) return new Admin(db, topology); + + // Internal state + this.s = { + db: db + , topology: topology + , promiseLibrary: promiseLibrary + } +} + +var define = Admin.define = new Define('Admin', Admin, false); + +/** + * The callback format for results + * @callback Admin~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object} result The result object if the command was executed successfully. + */ + +/** + * Execute a command + * @method + * @param {object} command The command hash + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.command = function(command, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() : {}; + + // Execute using callback + if(typeof callback == 'function') return this.s.db.executeDbAdminCommand(command, options, function(err, doc) { + return callback != null ? callback(err, doc) : null; + }); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.executeDbAdminCommand(command, options, function(err, doc) { + if(err) return reject(err); + resolve(doc); + }); + }); +} + +define.classMethod('command', {callback: true, promise:true}); + +/** + * Retrieve the server information for the current + * instance of the db client + * + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.buildInfo = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return this.serverInfo(callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.serverInfo(function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('buildInfo', {callback: true, promise:true}); + +/** + * Retrieve the server information for the current + * instance of the db client + * + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.serverInfo = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return this.s.db.executeDbAdminCommand({buildinfo:1}, function(err, doc) { + if(err != null) return callback(err, null); + callback(null, doc); + }); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.executeDbAdminCommand({buildinfo:1}, function(err, doc) { + if(err) return reject(err); + resolve(doc); + }); + }); +} + +define.classMethod('serverInfo', {callback: true, promise:true}); + +/** + * Retrieve this db's server status. + * + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.serverStatus = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return serverStatus(self, callback) + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + serverStatus(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var serverStatus = function(self, callback) { + self.s.db.executeDbAdminCommand({serverStatus: 1}, function(err, doc) { + if(err == null && doc.ok === 1) { + callback(null, doc); + } else { + if(err) return callback(err, false); + return callback(toError(doc), false); + } + }); +} + +define.classMethod('serverStatus', {callback: true, promise:true}); + +/** + * Retrieve the current profiling Level for MongoDB + * + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.profilingLevel = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return profilingLevel(self, callback) + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + profilingLevel(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var profilingLevel = function(self, callback) { + self.s.db.executeDbAdminCommand({profile:-1}, function(err, doc) { + if(err == null && doc.ok === 1) { + var was = doc.was; + if(was == 0) return callback(null, "off"); + if(was == 1) return callback(null, "slow_only"); + if(was == 2) return callback(null, "all"); + return callback(new Error("Error: illegal profiling level value " + was), null); + } else { + err != null ? callback(err, null) : callback(new Error("Error with profile command"), null); + } + }); +} + +define.classMethod('profilingLevel', {callback: true, promise:true}); + +/** + * Ping the MongoDB server and retrieve results + * + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.ping = function(options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + + // Execute using callback + if(typeof callback == 'function') return this.s.db.executeDbAdminCommand({ping: 1}, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.executeDbAdminCommand({ping: 1}, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('ping', {callback: true, promise:true}); + +/** + * Authenticate a user against the server. + * @method + * @param {string} username The username. + * @param {string} [password] The password. + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated This method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials. + */ +Admin.prototype.authenticate = function(username, password, options, callback) { + console.warn("Admin.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials."); + var finalArguments = [this.s.db]; + if(typeof username == 'string') finalArguments.push(username); + if(typeof password == 'string') finalArguments.push(password); + if(typeof options == 'function') { + finalArguments.push({ authdb: 'admin' }); + finalArguments.push(options); + } else { + finalArguments.push(assign({}, options, { authdb: 'admin' })); + } + + if(typeof callback == 'function') finalArguments.push(callback); + // Execute authenticate method + return authenticate.apply(this.s.db, finalArguments); +} + +define.classMethod('authenticate', {callback: true, promise:true}); + +/** + * Logout user from server, fire off on all connections and remove all auth info + * @method + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.logout = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return this.s.db.logout({dbName: 'admin'}, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.logout({dbName: 'admin'}, function(err) { + if(err) return reject(err); + resolve(true); + }); + }); +} + +define.classMethod('logout', {callback: true, promise:true}); + +// Get write concern +var writeConcern = function(options, db) { + options = shallowClone(options); + + // If options already contain write concerns return it + if(options.w || options.wtimeout || options.j || options.fsync) { + return options; + } + + // Set db write concern if available + if(db.writeConcern) { + if(options.w) options.w = db.writeConcern.w; + if(options.wtimeout) options.wtimeout = db.writeConcern.wtimeout; + if(options.j) options.j = db.writeConcern.j; + if(options.fsync) options.fsync = db.writeConcern.fsync; + } + + // Return modified options + return options; +} + +/** + * Add a user to the database. + * @method + * @param {string} username The username. + * @param {string} password The password. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {object} [options.customData=null] Custom data associated with the user (only Mongodb 2.6 or higher) + * @param {object[]} [options.roles=null] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.addUser = function(username, password, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() : {}; + options = options || {}; + // Get the options + options = writeConcern(options, self.s.db) + // Set the db name to admin + options.dbName = 'admin'; + + // Execute using callback + if(typeof callback == 'function') + return self.s.db.addUser(username, password, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.addUser(username, password, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('addUser', {callback: true, promise:true}); + +/** + * Remove a user from a database + * @method + * @param {string} username The username. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {Admin~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.removeUser = function(username, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() : {}; + options = options || {}; + // Get the options + options = writeConcern(options, self.s.db) + // Set the db name + options.dbName = 'admin'; + + // Execute using callback + if(typeof callback == 'function') + return self.s.db.removeUser(username, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.removeUser(username, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('removeUser', {callback: true, promise:true}); + +/** + * Set the current profiling level of MongoDB + * + * @param {string} level The new profiling level (off, slow_only, all). + * @param {Admin~resultCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.setProfilingLevel = function(level, callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return setProfilingLevel(self, level, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + setProfilingLevel(self, level, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var setProfilingLevel = function(self, level, callback) { + var command = {}; + var profile = 0; + + if(level == "off") { + profile = 0; + } else if(level == "slow_only") { + profile = 1; + } else if(level == "all") { + profile = 2; + } else { + return callback(new Error("Error: illegal profiling level value " + level)); + } + + // Set up the profile number + command['profile'] = profile; + + self.s.db.executeDbAdminCommand(command, function(err, doc) { + if(err == null && doc.ok === 1) + return callback(null, level); + return err != null ? callback(err, null) : callback(new Error("Error with profile command"), null); + }); +} + +define.classMethod('setProfilingLevel', {callback: true, promise:true}); + +/** + * Retrieve the current profiling information for MongoDB + * + * @param {Admin~resultCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Query the system.profile collection directly. + */ +Admin.prototype.profilingInfo = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return profilingInfo(self, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + profilingInfo(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var profilingInfo = function(self, callback) { + try { + self.s.topology.cursor("admin.system.profile", { find: 'system.profile', query: {}}, {}).toArray(callback); + } catch (err) { + return callback(err, null); + } +} + +define.classMethod('profilingLevel', {callback: true, promise:true}); + +/** + * Validate an existing collection + * + * @param {string} collectionName The name of the collection to validate. + * @param {object} [options=null] Optional settings. + * @param {Admin~resultCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.validateCollection = function(collectionName, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() : {}; + options = options || {}; + + // Execute using callback + if(typeof callback == 'function') + return validateCollection(self, collectionName, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + validateCollection(self, collectionName, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var validateCollection = function(self, collectionName, options, callback) { + var command = {validate: collectionName}; + var keys = Object.keys(options); + + // Decorate command with extra options + for(var i = 0; i < keys.length; i++) { + if(options.hasOwnProperty(keys[i])) { + command[keys[i]] = options[keys[i]]; + } + } + + self.s.db.command(command, function(err, doc) { + if(err != null) return callback(err, null); + + if(doc.ok === 0) + return callback(new Error("Error with validate command"), null); + if(doc.result != null && doc.result.constructor != String) + return callback(new Error("Error with validation data"), null); + if(doc.result != null && doc.result.match(/exception|corrupt/) != null) + return callback(new Error("Error: invalid collection " + collectionName), null); + if(doc.valid != null && !doc.valid) + return callback(new Error("Error: invalid collection " + collectionName), null); + + return callback(null, doc); + }); +} + +define.classMethod('validateCollection', {callback: true, promise:true}); + +/** + * List the available databases + * + * @param {Admin~resultCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.listDatabases = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return self.s.db.executeDbAdminCommand({listDatabases:1}, {}, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.executeDbAdminCommand({listDatabases:1}, {}, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('listDatabases', {callback: true, promise:true}); + +/** + * Get ReplicaSet status + * + * @param {Admin~resultCallback} [callback] The command result callback. + * @return {Promise} returns Promise if no callback passed + */ +Admin.prototype.replSetGetStatus = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return replSetGetStatus(self, callback); + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + replSetGetStatus(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var replSetGetStatus = function(self, callback) { + self.s.db.executeDbAdminCommand({replSetGetStatus:1}, function(err, doc) { + if(err == null && doc.ok === 1) + return callback(null, doc); + if(err) return callback(err, false); + callback(toError(doc), false); + }); +} + +define.classMethod('replSetGetStatus', {callback: true, promise:true}); + +module.exports = Admin; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js b/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js new file mode 100644 index 0000000..a0d7f24 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js @@ -0,0 +1,438 @@ +"use strict"; + +var inherits = require('util').inherits + , MongoError = require('mongodb-core').MongoError + , Readable = require('stream').Readable || require('readable-stream').Readable + , Define = require('./metadata') + , CoreCursor = require('./cursor'); + +/** + * @fileOverview The **AggregationCursor** class is an internal class that embodies an aggregation cursor on MongoDB + * allowing for iteration over the results returned from the underlying query. It supports + * one by one document iteration, conversion to an array or can be iterated as a Node 0.10.X + * or higher stream + * + * **AGGREGATIONCURSOR Cannot directly be instantiated** + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Create a collection we want to drop later + * var col = db.collection('createIndexExample1'); + * // Insert a bunch of documents + * col.insert([{a:1, b:1} + * , {a:2, b:2}, {a:3, b:3} + * , {a:4, b:4}], {w:1}, function(err, result) { + * test.equal(null, err); + * // Show that duplicate records got dropped + * col.aggregation({}, {cursor: {}}).toArray(function(err, items) { + * test.equal(null, err); + * test.equal(4, items.length); + * db.close(); + * }); + * }); + * }); + */ + +/** + * Namespace provided by the browser. + * @external Readable + */ + +/** + * Creates a new Aggregation Cursor instance (INTERNAL TYPE, do not instantiate directly) + * @class AggregationCursor + * @extends external:Readable + * @fires AggregationCursor#data + * @fires AggregationCursor#end + * @fires AggregationCursor#close + * @fires AggregationCursor#readable + * @return {AggregationCursor} an AggregationCursor instance. + */ +var AggregationCursor = function(bson, ns, cmd, options, topology, topologyOptions) { + CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0)); + var state = AggregationCursor.INIT; + var streamOptions = {}; + + // MaxTimeMS + var maxTimeMS = null; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Set up + Readable.call(this, {objectMode: true}); + + // Internal state + this.s = { + // MaxTimeMS + maxTimeMS: maxTimeMS + // State + , state: state + // Stream options + , streamOptions: streamOptions + // BSON + , bson: bson + // Namespace + , ns: ns + // Command + , cmd: cmd + // Options + , options: options + // Topology + , topology: topology + // Topology Options + , topologyOptions: topologyOptions + // Promise library + , promiseLibrary: promiseLibrary + } +} + +/** + * AggregationCursor stream data event, fired for each document in the cursor. + * + * @event AggregationCursor#data + * @type {object} + */ + +/** + * AggregationCursor stream end event + * + * @event AggregationCursor#end + * @type {null} + */ + +/** + * AggregationCursor stream close event + * + * @event AggregationCursor#close + * @type {null} + */ + +/** + * AggregationCursor stream readable event + * + * @event AggregationCursor#readable + * @type {null} + */ + +// Inherit from Readable +inherits(AggregationCursor, Readable); + +// Extend the Cursor +for(var name in CoreCursor.prototype) { + AggregationCursor.prototype[name] = CoreCursor.prototype[name]; +} + +var define = AggregationCursor.define = new Define('AggregationCursor', AggregationCursor, true); + +/** + * Set the batch size for the cursor. + * @method + * @param {number} value The batchSize for the cursor. + * @throws {MongoError} + * @return {AggregationCursor} + */ +AggregationCursor.prototype.batchSize = function(value) { + if(this.s.state == AggregationCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true }); + if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true }); + if(this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; + this.setCursorBatchSize(value); + return this; +} + +define.classMethod('batchSize', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a geoNear stage to the aggregation pipeline + * @method + * @param {object} document The geoNear stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.geoNear = function(document) { + this.s.cmd.pipeline.push({$geoNear: document}); + return this; +} + +define.classMethod('geoNear', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a group stage to the aggregation pipeline + * @method + * @param {object} document The group stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.group = function(document) { + this.s.cmd.pipeline.push({$group: document}); + return this; +} + +define.classMethod('group', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a limit stage to the aggregation pipeline + * @method + * @param {number} value The state limit value. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.limit = function(value) { + this.s.cmd.pipeline.push({$limit: value}); + return this; +} + +define.classMethod('limit', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a match stage to the aggregation pipeline + * @method + * @param {object} document The match stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.match = function(document) { + this.s.cmd.pipeline.push({$match: document}); + return this; +} + +define.classMethod('match', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a maxTimeMS stage to the aggregation pipeline + * @method + * @param {number} value The state maxTimeMS value. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.maxTimeMS = function(value) { + if(this.s.topology.lastIsMaster().minWireVersion > 2) { + this.s.cmd.maxTimeMS = value; + } + return this; +} + +define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a out stage to the aggregation pipeline + * @method + * @param {number} destination The destination name. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.out = function(destination) { + this.s.cmd.pipeline.push({$out: destination}); + return this; +} + +define.classMethod('out', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a project stage to the aggregation pipeline + * @method + * @param {object} document The project stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.project = function(document) { + this.s.cmd.pipeline.push({$project: document}); + return this; +} + +define.classMethod('project', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a lookup stage to the aggregation pipeline + * @method + * @param {object} document The lookup stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.lookup = function(document) { + this.s.cmd.pipeline.push({$lookup: document}); + return this; +} + +define.classMethod('lookup', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a redact stage to the aggregation pipeline + * @method + * @param {object} document The redact stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.redact = function(document) { + this.s.cmd.pipeline.push({$redact: document}); + return this; +} + +define.classMethod('redact', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a skip stage to the aggregation pipeline + * @method + * @param {number} value The state skip value. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.skip = function(value) { + this.s.cmd.pipeline.push({$skip: value}); + return this; +} + +define.classMethod('skip', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a sort stage to the aggregation pipeline + * @method + * @param {object} document The sort stage document. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.sort = function(document) { + this.s.cmd.pipeline.push({$sort: document}); + return this; +} + +define.classMethod('sort', {callback: false, promise:false, returns: [AggregationCursor]}); + +/** + * Add a unwind stage to the aggregation pipeline + * @method + * @param {number} field The unwind field name. + * @return {AggregationCursor} + */ +AggregationCursor.prototype.unwind = function(field) { + this.s.cmd.pipeline.push({$unwind: field}); + return this; +} + +define.classMethod('unwind', {callback: false, promise:false, returns: [AggregationCursor]}); + +AggregationCursor.prototype.get = AggregationCursor.prototype.toArray; + +// Inherited methods +define.classMethod('toArray', {callback: true, promise:true}); +define.classMethod('each', {callback: true, promise:false}); +define.classMethod('forEach', {callback: true, promise:false}); +define.classMethod('hasNext', {callback: true, promise:true}); +define.classMethod('next', {callback: true, promise:true}); +define.classMethod('close', {callback: true, promise:true}); +define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); +define.classMethod('rewind', {callback: false, promise:false}); +define.classMethod('bufferedCount', {callback: false, promise:false, returns: [Number]}); +define.classMethod('readBufferedDocuments', {callback: false, promise:false, returns: [Array]}); + +/** + * Get the next available document from the cursor, returns null if no more documents are available. + * @function AggregationCursor.prototype.next + * @param {AggregationCursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * Check if there is any document still available in the cursor + * @function AggregationCursor.prototype.hasNext + * @param {AggregationCursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * The callback format for results + * @callback AggregationCursor~toArrayResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object[]} documents All the documents the satisfy the cursor. + */ + +/** + * Returns an array of documents. The caller is responsible for making sure that there + * is enough memory to store the results. Note that the array only contain partial + * results when this cursor had been previously accessed. In that case, + * cursor.rewind() can be used to reset the cursor. + * @method AggregationCursor.prototype.toArray + * @param {AggregationCursor~toArrayResultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * The callback format for results + * @callback AggregationCursor~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {(object|null)} result The result object if the command was executed successfully. + */ + +/** + * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, + * not all of the elements will be iterated if this cursor had been previously accessed. + * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike + * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements + * at any given time if batch size is specified. Otherwise, the caller is responsible + * for making sure that the entire result can fit the memory. + * @method AggregationCursor.prototype.each + * @param {AggregationCursor~resultCallback} callback The result callback. + * @throws {MongoError} + * @return {null} + */ + +/** + * Close the cursor, sending a AggregationCursor command and emitting close. + * @method AggregationCursor.prototype.close + * @param {AggregationCursor~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ + +/** + * Is the cursor closed + * @method AggregationCursor.prototype.isClosed + * @return {boolean} + */ + +/** + * Execute the explain for the cursor + * @method AggregationCursor.prototype.explain + * @param {AggregationCursor~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ + +/** + * Clone the cursor + * @function AggregationCursor.prototype.clone + * @return {AggregationCursor} + */ + +/** + * Resets the cursor + * @function AggregationCursor.prototype.rewind + * @return {AggregationCursor} + */ + +/** + * The callback format for the forEach iterator method + * @callback AggregationCursor~iteratorCallback + * @param {Object} doc An emitted document for the iterator + */ + +/** + * The callback error format for the forEach iterator method + * @callback AggregationCursor~endCallback + * @param {MongoError} error An error instance representing the error during the execution. + */ + +/* + * Iterates over all the documents for this cursor using the iterator, callback pattern. + * @method AggregationCursor.prototype.forEach + * @param {AggregationCursor~iteratorCallback} iterator The iteration callback. + * @param {AggregationCursor~endCallback} callback The end callback. + * @throws {MongoError} + * @return {null} + */ + +AggregationCursor.INIT = 0; +AggregationCursor.OPEN = 1; +AggregationCursor.CLOSED = 2; + +module.exports = AggregationCursor; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/apm.js b/node_modules/mongoose/node_modules/mongodb/lib/apm.js new file mode 100644 index 0000000..4948205 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/apm.js @@ -0,0 +1,596 @@ +var EventEmitter = require('events').EventEmitter, + inherits = require('util').inherits; + +// Get prototypes +var AggregationCursor = require('./aggregation_cursor'), + CommandCursor = require('./command_cursor'), + OrderedBulkOperation = require('./bulk/ordered').OrderedBulkOperation, + UnorderedBulkOperation = require('./bulk/unordered').UnorderedBulkOperation, + GridStore = require('./gridfs/grid_store'), + Cursor = require('./cursor'), + Collection = require('./collection'), + Db = require('./db'); + +var basicOperationIdGenerator = { + operationId: 1, + + next: function() { + return this.operationId++; + } +} + +var basicTimestampGenerator = { + current: function() { + return new Date().getTime(); + }, + + duration: function(start, end) { + return end - start; + } +} + +var senstiveCommands = ['authenticate', 'saslStart', 'saslContinue', 'getnonce', + 'createUser', 'updateUser', 'copydbgetnonce', 'copydbsaslstart', 'copydb']; + +var Instrumentation = function(core, options, callback) { + options = options || {}; + + // Optional id generators + var operationIdGenerator = options.operationIdGenerator || basicOperationIdGenerator; + // Optional timestamp generator + var timestampGenerator = options.timestampGenerator || basicTimestampGenerator; + // Extend with event emitter functionality + EventEmitter.call(this); + + // Contains all the instrumentation overloads + this.overloads = []; + + // --------------------------------------------------------- + // + // Instrument prototype + // + // --------------------------------------------------------- + + var instrumentPrototype = function(callback) { + var instrumentations = [] + + // Classes to support + var classes = [GridStore, OrderedBulkOperation, UnorderedBulkOperation, + CommandCursor, AggregationCursor, Cursor, Collection, Db]; + + // Add instrumentations to the available list + for(var i = 0; i < classes.length; i++) { + if(classes[i].define) { + instrumentations.push(classes[i].define.generate()); + } + } + + // Return the list of instrumentation points + callback(null, instrumentations); + } + + // Did the user want to instrument the prototype + if(typeof callback == 'function') { + instrumentPrototype(callback); + } + + // --------------------------------------------------------- + // + // Server + // + // --------------------------------------------------------- + + // Reference + var self = this; + // Names of methods we need to wrap + var methods = ['command', 'insert', 'update', 'remove']; + // Prototype + var proto = core.Server.prototype; + // Core server method we are going to wrap + methods.forEach(function(x) { + var func = proto[x]; + + // Add to overloaded methods + self.overloads.push({proto: proto, name:x, func:func}); + + // The actual prototype + proto[x] = function() { + var requestId = core.Query.nextRequestId(); + // Get the arguments + var args = Array.prototype.slice.call(arguments, 0); + var ns = args[0]; + var commandObj = args[1]; + var options = args[2] || {}; + var keys = Object.keys(commandObj); + var commandName = keys[0]; + var db = ns.split('.')[0]; + + // Get the collection + var col = ns.split('.'); + col.shift(); + col = col.join('.'); + + // Do we have a legacy insert/update/remove command + if(x == 'insert') { //} && !this.lastIsMaster().maxWireVersion) { + commandName = 'insert'; + + // Re-write the command + commandObj = { + insert: col, documents: commandObj + } + + if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { + commandObj.writeConcern = options.writeConcern; + } + + commandObj.ordered = options.ordered != undefined ? options.ordered : true; + } else if(x == 'update') { // && !this.lastIsMaster().maxWireVersion) { + commandName = 'update'; + + // Re-write the command + commandObj = { + update: col, updates: commandObj + } + + if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { + commandObj.writeConcern = options.writeConcern; + } + + commandObj.ordered = options.ordered != undefined ? options.ordered : true; + } else if(x == 'remove') { //&& !this.lastIsMaster().maxWireVersion) { + commandName = 'delete'; + + // Re-write the command + commandObj = { + delete: col, deletes: commandObj + } + + if(options.writeConcern && Object.keys(options.writeConcern).length > 0) { + commandObj.writeConcern = options.writeConcern; + } + + commandObj.ordered = options.ordered != undefined ? options.ordered : true; + } + + // Get the callback + var callback = args.pop(); + // Set current callback operation id from the current context or create + // a new one + var ourOpId = callback.operationId || operationIdGenerator.next(); + + // Get a connection reference for this server instance + var connection = this.s.pool.get() + + // Emit the start event for the command + var command = { + // Returns the command. + command: commandObj, + // Returns the database name. + databaseName: db, + // Returns the command name. + commandName: commandName, + // Returns the driver generated request id. + requestId: requestId, + // Returns the driver generated operation id. + // This is used to link events together such as bulk write operations. OPTIONAL. + operationId: ourOpId, + // Returns the connection id for the command. For languages that do not have this, + // this MUST return the driver equivalent which MUST include the server address and port. + // The name of this field is flexible to match the object that is returned from the driver. + connectionId: connection + }; + + // Filter out any sensitive commands + if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { + command.commandObj = {}; + command.commandObj[commandName] = true; + } + + // Emit the started event + self.emit('started', command) + + // Start time + var startTime = timestampGenerator.current(); + + // Push our handler callback + args.push(function(err, r) { + var endTime = timestampGenerator.current(); + var command = { + duration: timestampGenerator.duration(startTime, endTime), + commandName: commandName, + requestId: requestId, + operationId: ourOpId, + connectionId: connection + }; + + // If we have an error + if(err || (r && r.result && r.result.ok == 0)) { + command.failure = err || r.result.writeErrors || r.result; + + // Filter out any sensitive commands + if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { + command.failure = {}; + } + + self.emit('failed', command); + } else if(commandObj && commandObj.writeConcern + && commandObj.writeConcern.w == 0) { + // If we have write concern 0 + command.reply = {ok:1}; + self.emit('succeeded', command); + } else { + command.reply = r && r.result ? r.result : r; + + // Filter out any sensitive commands + if(senstiveCommands.indexOf(commandName.toLowerCase()) != -1) { + command.reply = {}; + } + + self.emit('succeeded', command); + } + + // Return to caller + callback(err, r); + }); + + // Apply the call + func.apply(this, args); + } + }); + + // --------------------------------------------------------- + // + // Bulk Operations + // + // --------------------------------------------------------- + + // Inject ourselves into the Bulk methods + methods = ['execute']; + var prototypes = [ + require('./bulk/ordered').Bulk.prototype, + require('./bulk/unordered').Bulk.prototype + ] + + prototypes.forEach(function(proto) { + // Core server method we are going to wrap + methods.forEach(function(x) { + var func = proto[x]; + + // Add to overloaded methods + self.overloads.push({proto: proto, name:x, func:func}); + + // The actual prototype + proto[x] = function() { + // Get the arguments + var args = Array.prototype.slice.call(arguments, 0); + // Set an operation Id on the bulk object + this.operationId = operationIdGenerator.next(); + + // Get the callback + var callback = args.pop(); + // If we have a callback use this + if(typeof callback == 'function') { + args.push(function(err, r) { + // Return to caller + callback(err, r); + }); + + // Apply the call + func.apply(this, args); + } else { + return func.apply(this, args); + } + } + }); + }); + + // --------------------------------------------------------- + // + // Cursor + // + // --------------------------------------------------------- + + // Inject ourselves into the Cursor methods + methods = ['_find', '_getmore', '_killcursor']; + prototypes = [ + require('./cursor').prototype, + require('./command_cursor').prototype, + require('./aggregation_cursor').prototype + ] + + // Command name translation + var commandTranslation = { + '_find': 'find', '_getmore': 'getMore', '_killcursor': 'killCursors', '_explain': 'explain' + } + + prototypes.forEach(function(proto) { + + // Core server method we are going to wrap + methods.forEach(function(x) { + var func = proto[x]; + + // Add to overloaded methods + self.overloads.push({proto: proto, name:x, func:func}); + + // The actual prototype + proto[x] = function() { + var cursor = this; + var requestId = core.Query.nextRequestId(); + var ourOpId = operationIdGenerator.next(); + var parts = this.ns.split('.'); + var db = parts[0]; + + // Get the collection + parts.shift(); + var collection = parts.join('.'); + + // Set the command + var command = this.query; + var cmd = this.s.cmd; + + // If we have a find method, set the operationId on the cursor + if(x == '_find') { + cursor.operationId = ourOpId; + } + + // Do we have a find command rewrite it + if(x == '_getmore') { + command = { + getMore: this.cursorState.cursorId, + collection: collection, + batchSize: cmd.batchSize + } + + if(cmd.maxTimeMS) command.maxTimeMS = cmd.maxTimeMS; + } else if(x == '_killcursor') { + command = { + killCursors: collection, + cursors: [this.cursorState.cursorId] + } + } else if(cmd.find) { + command = { + find: collection, filter: cmd.query + } + + if(cmd.sort) command.sort = cmd.sort; + if(cmd.fields) command.projection = cmd.fields; + if(cmd.limit && cmd.limit < 0) { + command.limit = Math.abs(cmd.limit); + command.singleBatch = true; + } else if(cmd.limit) { + command.limit = Math.abs(cmd.limit); + } + + // Options + if(cmd.skip) command.skip = cmd.skip; + if(cmd.hint) command.hint = cmd.hint; + if(cmd.batchSize) command.batchSize = cmd.batchSize; + if(typeof cmd.returnKey == 'boolean') command.returnKey = cmd.returnKey; + if(cmd.comment) command.comment = cmd.comment; + if(cmd.min) command.min = cmd.min; + if(cmd.max) command.max = cmd.max; + if(cmd.maxScan) command.maxScan = cmd.maxScan; + if(cmd.maxTimeMS) command.maxTimeMS = cmd.maxTimeMS; + + // Flags + if(typeof cmd.awaitData == 'boolean') command.awaitData = cmd.awaitData; + if(typeof cmd.snapshot == 'boolean') command.snapshot = cmd.snapshot; + if(typeof cmd.tailable == 'boolean') command.tailable = cmd.tailable; + if(typeof cmd.oplogReplay == 'boolean') command.oplogReplay = cmd.oplogReplay; + if(typeof cmd.noCursorTimeout == 'boolean') command.noCursorTimeout = cmd.noCursorTimeout; + if(typeof cmd.partial == 'boolean') command.partial = cmd.partial; + if(typeof cmd.showDiskLoc == 'boolean') command.showRecordId = cmd.showDiskLoc; + + // Read Concern + if(cmd.readConcern) command.readConcern = cmd.readConcern; + + // Override method + if(cmd.explain) command.explain = cmd.explain; + if(cmd.exhaust) command.exhaust = cmd.exhaust; + + // If we have a explain flag + if(cmd.explain) { + // Create fake explain command + command = { + explain: command, + verbosity: 'allPlansExecution' + } + + // Set readConcern on the command if available + if(cmd.readConcern) command.readConcern = cmd.readConcern + + // Set up the _explain name for the command + x = '_explain'; + } + } else { + command = cmd; + } + + // Set up the connection + var connectionId = null; + + // Set local connection + if(this.connection) connectionId = this.connection; + if(!connectionId && this.server && this.server.getConnection) connectionId = this.server.getConnection(); + + // Get the command Name + var commandName = x == '_find' ? Object.keys(command)[0] : commandTranslation[x]; + + // Emit the start event for the command + command = { + // Returns the command. + command: command, + // Returns the database name. + databaseName: db, + // Returns the command name. + commandName: commandName, + // Returns the driver generated request id. + requestId: requestId, + // Returns the driver generated operation id. + // This is used to link events together such as bulk write operations. OPTIONAL. + operationId: this.operationId, + // Returns the connection id for the command. For languages that do not have this, + // this MUST return the driver equivalent which MUST include the server address and port. + // The name of this field is flexible to match the object that is returned from the driver. + connectionId: connectionId + }; + + // Get the arguments + var args = Array.prototype.slice.call(arguments, 0); + + // Get the callback + var callback = args.pop(); + + // We do not have a callback but a Promise + if(typeof callback == 'function' || command.commandName == 'killCursors') { + var startTime = timestampGenerator.current(); + // Emit the started event + self.emit('started', command) + + // Emit succeeded event with killcursor if we have a legacy protocol + if(command.commandName == 'killCursors' + && this.server.lastIsMaster() + && this.server.lastIsMaster().maxWireVersion < 4) { + // Emit the succeeded command + command = { + duration: timestampGenerator.duration(startTime, timestampGenerator.current()), + commandName: commandName, + requestId: requestId, + operationId: cursor.operationId, + connectionId: cursor.server.getConnection(), + reply: [{ok:1}] + }; + + // Apply callback to the list of args + args.push(callback); + // Apply the call + func.apply(this, args); + // Emit the command + return self.emit('succeeded', command) + } + + // Add our callback handler + args.push(function(err, r) { + if(err) { + // Command + var command = { + duration: timestampGenerator.duration(startTime, timestampGenerator.current()), + commandName: commandName, + requestId: requestId, + operationId: ourOpId, + connectionId: cursor.server.getConnection(), + failure: err }; + + // Emit the command + self.emit('failed', command) + } else { + // Do we have a getMore + if(commandName.toLowerCase() == 'getmore' && r == null) { + r = { + cursor: { + id: cursor.cursorState.cursorId, + ns: cursor.ns, + nextBatch: cursor.cursorState.documents + }, ok:1 + } + } else if((commandName.toLowerCase() == 'find' + || commandName.toLowerCase() == 'aggregate' + || commandName.toLowerCase() == 'listcollections') && r == null) { + r = { + cursor: { + id: cursor.cursorState.cursorId, + ns: cursor.ns, + firstBatch: cursor.cursorState.documents + }, ok:1 + } + } else if(commandName.toLowerCase() == 'killcursors' && r == null) { + r = { + cursorsUnknown:[cursor.cursorState.lastCursorId], + ok:1 + } + } + + // cursor id is zero, we can issue success command + command = { + duration: timestampGenerator.duration(startTime, timestampGenerator.current()), + commandName: commandName, + requestId: requestId, + operationId: cursor.operationId, + connectionId: cursor.server.getConnection(), + reply: r && r.result ? r.result : r + }; + + // Emit the command + self.emit('succeeded', command) + } + + // Return + if(!callback) return; + + // Return to caller + callback(err, r); + }); + + // Apply the call + func.apply(this, args); + } else { + // Assume promise, push back the missing value + args.push(callback); + // Get the promise + var promise = func.apply(this, args); + // Return a new promise + return new cursor.s.promiseLibrary(function(resolve, reject) { + var startTime = timestampGenerator.current(); + // Emit the started event + self.emit('started', command) + // Execute the function + promise.then(function() { + // cursor id is zero, we can issue success command + var command = { + duration: timestampGenerator.duration(startTime, timestampGenerator.current()), + commandName: commandName, + requestId: requestId, + operationId: cursor.operationId, + connectionId: cursor.server.getConnection(), + reply: cursor.cursorState.documents + }; + + // Emit the command + self.emit('succeeded', command) + }).catch(function(err) { + // Command + var command = { + duration: timestampGenerator.duration(startTime, timestampGenerator.current()), + commandName: commandName, + requestId: requestId, + operationId: ourOpId, + connectionId: cursor.server.getConnection(), + failure: err }; + + // Emit the command + self.emit('failed', command) + // reject the promise + reject(err); + }); + }); + } + } + }); + }); +} + +inherits(Instrumentation, EventEmitter); + +Instrumentation.prototype.uninstrument = function() { + for(var i = 0; i < this.overloads.length; i++) { + var obj = this.overloads[i]; + obj.proto[obj.name] = obj.func; + } + + // Remove all listeners + this.removeAllListeners('started'); + this.removeAllListeners('succeeded'); + this.removeAllListeners('failed'); +} + +module.exports = Instrumentation; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/authenticate.js b/node_modules/mongoose/node_modules/mongodb/lib/authenticate.js new file mode 100644 index 0000000..d179478 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/authenticate.js @@ -0,0 +1,110 @@ +var shallowClone = require('./utils').shallowClone + , handleCallback = require('./utils').handleCallback + , MongoError = require('mongodb-core').MongoError + , f = require('util').format; + +var authenticate = function(self, username, password, options, callback) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + + // the default db to authenticate against is 'self' + // if authenticate is called from a retry context, it may be another one, like admin + var authdb = options.dbName ? options.dbName : self.databaseName; + authdb = self.authSource ? self.authSource : authdb; + authdb = options.authdb ? options.authdb : authdb; + authdb = options.authSource ? options.authSource : authdb; + + // Callback + var _callback = function(err, result) { + if(self.listeners('authenticated').length > 0) { + self.emit('authenticated', err, result); + } + + // Return to caller + handleCallback(callback, err, result); + } + + // authMechanism + var authMechanism = options.authMechanism || ''; + authMechanism = authMechanism.toUpperCase(); + + // If classic auth delegate to auth command + if(authMechanism == 'MONGODB-CR') { + self.s.topology.auth('mongocr', authdb, username, password, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else if(authMechanism == 'PLAIN') { + self.s.topology.auth('plain', authdb, username, password, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else if(authMechanism == 'MONGODB-X509') { + self.s.topology.auth('x509', authdb, username, password, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else if(authMechanism == 'SCRAM-SHA-1') { + self.s.topology.auth('scram-sha-1', authdb, username, password, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else if(authMechanism == 'GSSAPI') { + if(process.platform == 'win32') { + self.s.topology.auth('sspi', authdb, username, password, options, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else { + self.s.topology.auth('gssapi', authdb, username, password, options, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } + } else if(authMechanism == 'DEFAULT') { + self.s.topology.auth('default', authdb, username, password, function(err) { + if(err) return handleCallback(callback, err, false); + _callback(null, true); + }); + } else { + handleCallback(callback, MongoError.create({message: f("authentication mechanism %s not supported", options.authMechanism), driver:true})); + } +} + +module.exports = function(self, username, password, options, callback) { + if(typeof options == 'function') callback = options, options = {}; + // Shallow copy the options + options = shallowClone(options); + + // Set default mechanism + if(!options.authMechanism) { + options.authMechanism = 'DEFAULT'; + } else if(options.authMechanism != 'GSSAPI' + && options.authMechanism != 'DEFAULT' + && options.authMechanism != 'MONGODB-CR' + && options.authMechanism != 'MONGODB-X509' + && options.authMechanism != 'SCRAM-SHA-1' + && options.authMechanism != 'PLAIN') { + return handleCallback(callback, MongoError.create({message: "only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, SCRAM-SHA-1 or MONGODB-CR is supported by authMechanism", driver:true})); + } + + // If we have a callback fallback + if(typeof callback == 'function') return authenticate(self, username, password, options, function(err, r) { + // Support failed auth method + if(err && err.message && err.message.indexOf('saslStart') != -1) err.code = 59; + // Reject error + if(err) return callback(err, r); + callback(null, r); + }); + + // Return a promise + return new self.s.promiseLibrary(function(resolve, reject) { + authenticate(self, username, password, options, function(err, r) { + // Support failed auth method + if(err && err.message && err.message.indexOf('saslStart') != -1) err.code = 59; + // Reject error + if(err) return reject(err); + resolve(r); + }); + }); +}; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js b/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js new file mode 100644 index 0000000..6ebe3ef --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js @@ -0,0 +1,440 @@ +"use strict"; + +var Long = require('mongodb-core').BSON.Long, + Timestamp = require('mongodb-core').BSON.Timestamp; + +// Error codes +var UNKNOWN_ERROR = 8; +var INVALID_BSON_ERROR = 22; +var WRITE_CONCERN_ERROR = 64; +var MULTIPLE_ERROR = 65; + +// Insert types +var INSERT = 1; +var UPDATE = 2; +var REMOVE = 3 + + +// Get write concern +var writeConcern = function(target, col, options) { + var writeConcern = {}; + + // Collection level write concern + if(col.writeConcern && col.writeConcern.w != null) writeConcern.w = col.writeConcern.w; + if(col.writeConcern && col.writeConcern.j != null) writeConcern.j = col.writeConcern.j; + if(col.writeConcern && col.writeConcern.fsync != null) writeConcern.fsync = col.writeConcern.fsync; + if(col.writeConcern && col.writeConcern.wtimeout != null) writeConcern.wtimeout = col.writeConcern.wtimeout; + + // Options level write concern + if(options && options.w != null) writeConcern.w = options.w; + if(options && options.wtimeout != null) writeConcern.wtimeout = options.wtimeout; + if(options && options.j != null) writeConcern.j = options.j; + if(options && options.fsync != null) writeConcern.fsync = options.fsync; + + // Return write concern + return writeConcern; +} + +/** + * Helper function to define properties + * @ignore + */ +var defineReadOnlyProperty = function(self, name, value) { + Object.defineProperty(self, name, { + enumerable: true + , get: function() { + return value; + } + }); +} + +/** + * Keeps the state of a unordered batch so we can rewrite the results + * correctly after command execution + * @ignore + */ +var Batch = function(batchType, originalZeroIndex) { + this.originalZeroIndex = originalZeroIndex; + this.currentIndex = 0; + this.originalIndexes = []; + this.batchType = batchType; + this.operations = []; + this.size = 0; + this.sizeBytes = 0; +} + +/** + * Wraps a legacy operation so we can correctly rewrite it's error + * @ignore + */ +var LegacyOp = function(batchType, operation, index) { + this.batchType = batchType; + this.index = index; + this.operation = operation; +} + +/** + * Create a new BulkWriteResult instance (INTERNAL TYPE, do not instantiate directly) + * + * @class + * @property {boolean} ok Did bulk operation correctly execute + * @property {number} nInserted number of inserted documents + * @property {number} nUpdated number of documents updated logically + * @property {number} nUpserted Number of upserted documents + * @property {number} nModified Number of documents updated physically on disk + * @property {number} nRemoved Number of removed documents + * @return {BulkWriteResult} a BulkWriteResult instance + */ +var BulkWriteResult = function(bulkResult) { + defineReadOnlyProperty(this, "ok", bulkResult.ok); + defineReadOnlyProperty(this, "nInserted", bulkResult.nInserted); + defineReadOnlyProperty(this, "nUpserted", bulkResult.nUpserted); + defineReadOnlyProperty(this, "nMatched", bulkResult.nMatched); + defineReadOnlyProperty(this, "nModified", bulkResult.nModified); + defineReadOnlyProperty(this, "nRemoved", bulkResult.nRemoved); + + /** + * Return an array of inserted ids + * + * @return {object[]} + */ + this.getInsertedIds = function() { + return bulkResult.insertedIds; + } + + /** + * Return an array of upserted ids + * + * @return {object[]} + */ + this.getUpsertedIds = function() { + return bulkResult.upserted; + } + + /** + * Return the upserted id at position x + * + * @param {number} index the number of the upserted id to return, returns undefined if no result for passed in index + * @return {object} + */ + this.getUpsertedIdAt = function(index) { + return bulkResult.upserted[index]; + } + + /** + * Return raw internal result + * + * @return {object} + */ + this.getRawResponse = function() { + return bulkResult; + } + + /** + * Returns true if the bulk operation contains a write error + * + * @return {boolean} + */ + this.hasWriteErrors = function() { + return bulkResult.writeErrors.length > 0; + } + + /** + * Returns the number of write errors off the bulk operation + * + * @return {number} + */ + this.getWriteErrorCount = function() { + return bulkResult.writeErrors.length; + } + + /** + * Returns a specific write error object + * + * @param {number} index of the write error to return, returns null if there is no result for passed in index + * @return {WriteError} + */ + this.getWriteErrorAt = function(index) { + if(index < bulkResult.writeErrors.length) { + return bulkResult.writeErrors[index]; + } + return null; + } + + /** + * Retrieve all write errors + * + * @return {object[]} + */ + this.getWriteErrors = function() { + return bulkResult.writeErrors; + } + + /** + * Retrieve lastOp if available + * + * @return {object} + */ + this.getLastOp = function() { + return bulkResult.lastOp; + } + + /** + * Retrieve the write concern error if any + * + * @return {WriteConcernError} + */ + this.getWriteConcernError = function() { + if(bulkResult.writeConcernErrors.length == 0) { + return null; + } else if(bulkResult.writeConcernErrors.length == 1) { + // Return the error + return bulkResult.writeConcernErrors[0]; + } else { + + // Combine the errors + var errmsg = ""; + for(var i = 0; i < bulkResult.writeConcernErrors.length; i++) { + var err = bulkResult.writeConcernErrors[i]; + errmsg = errmsg + err.errmsg; + + // TODO: Something better + if(i == 0) errmsg = errmsg + " and "; + } + + return new WriteConcernError({ errmsg : errmsg, code : WRITE_CONCERN_ERROR }); + } + } + + this.toJSON = function() { + return bulkResult; + } + + this.toString = function() { + return "BulkWriteResult(" + this.toJSON(bulkResult) + ")"; + } + + this.isOk = function() { + return bulkResult.ok == 1; + } +} + +/** + * Create a new WriteConcernError instance (INTERNAL TYPE, do not instantiate directly) + * + * @class + * @property {number} code Write concern error code. + * @property {string} errmsg Write concern error message. + * @return {WriteConcernError} a WriteConcernError instance + */ +var WriteConcernError = function(err) { + if(!(this instanceof WriteConcernError)) return new WriteConcernError(err); + + // Define properties + defineReadOnlyProperty(this, "code", err.code); + defineReadOnlyProperty(this, "errmsg", err.errmsg); + + this.toJSON = function() { + return {code: err.code, errmsg: err.errmsg}; + } + + this.toString = function() { + return "WriteConcernError(" + err.errmsg + ")"; + } +} + +/** + * Create a new WriteError instance (INTERNAL TYPE, do not instantiate directly) + * + * @class + * @property {number} code Write concern error code. + * @property {number} index Write concern error original bulk operation index. + * @property {string} errmsg Write concern error message. + * @return {WriteConcernError} a WriteConcernError instance + */ +var WriteError = function(err) { + if(!(this instanceof WriteError)) return new WriteError(err); + + // Define properties + defineReadOnlyProperty(this, "code", err.code); + defineReadOnlyProperty(this, "index", err.index); + defineReadOnlyProperty(this, "errmsg", err.errmsg); + + // + // Define access methods + this.getOperation = function() { + return err.op; + } + + this.toJSON = function() { + return {code: err.code, index: err.index, errmsg: err.errmsg, op: err.op}; + } + + this.toString = function() { + return "WriteError(" + JSON.stringify(this.toJSON()) + ")"; + } +} + +/** + * Merges results into shared data structure + * @ignore + */ +var mergeBatchResults = function(ordered, batch, bulkResult, err, result) { + // If we have an error set the result to be the err object + if(err) { + result = err; + } else if(result && result.result) { + result = result.result; + } else if(result == null) { + return; + } + + // Do we have a top level error stop processing and return + if(result.ok == 0 && bulkResult.ok == 1) { + bulkResult.ok = 0; + + var writeError = { + index: 0 + , code: result.code || 0 + , errmsg: result.message + , op: batch.operations[0] + }; + + bulkResult.writeErrors.push(new WriteError(writeError)); + return; + } else if(result.ok == 0 && bulkResult.ok == 0) { + return; + } + + // Deal with opTime if available + if(result.opTime || result.lastOp) { + var opTime = result.lastOp || result.opTime; + var lastOpTS = null; + var lastOpT = null; + + // We have a time stamp + if(opTime && opTime._bsontype == 'Timestamp') { + if(bulkResult.lastOp == null) { + bulkResult.lastOp = opTime; + } else if(opTime.greaterThan(bulkResult.lastOp)) { + bulkResult.lastOp = opTime; + } + } else { + // Existing TS + if(bulkResult.lastOp) { + lastOpTS = typeof bulkResult.lastOp.ts == 'number' + ? Long.fromNumber(bulkResult.lastOp.ts) : bulkResult.lastOp.ts; + lastOpT = typeof bulkResult.lastOp.t == 'number' + ? Long.fromNumber(bulkResult.lastOp.t) : bulkResult.lastOp.t; + } + + // Current OpTime TS + var opTimeTS = typeof opTime.ts == 'number' + ? Long.fromNumber(opTime.ts) : opTime.ts; + var opTimeT = typeof opTime.t == 'number' + ? Long.fromNumber(opTime.t) : opTime.t; + + // Compare the opTime's + if(bulkResult.lastOp == null) { + bulkResult.lastOp = opTime; + } else if(opTimeTS.greaterThan(lastOpTS)) { + bulkResult.lastOp = opTime; + } else if(opTimeTS.equals(lastOpTS)) { + if(opTimeT.greaterThan(lastOpT)) { + bulkResult.lastOp = opTime; + } + } + } + } + + // If we have an insert Batch type + if(batch.batchType == INSERT && result.n) { + bulkResult.nInserted = bulkResult.nInserted + result.n; + } + + // If we have an insert Batch type + if(batch.batchType == REMOVE && result.n) { + bulkResult.nRemoved = bulkResult.nRemoved + result.n; + } + + var nUpserted = 0; + + // We have an array of upserted values, we need to rewrite the indexes + if(Array.isArray(result.upserted)) { + nUpserted = result.upserted.length; + + for(var i = 0; i < result.upserted.length; i++) { + bulkResult.upserted.push({ + index: result.upserted[i].index + batch.originalZeroIndex + , _id: result.upserted[i]._id + }); + } + } else if(result.upserted) { + + nUpserted = 1; + + bulkResult.upserted.push({ + index: batch.originalZeroIndex + , _id: result.upserted + }); + } + + // If we have an update Batch type + if(batch.batchType == UPDATE && result.n) { + var nModified = result.nModified; + bulkResult.nUpserted = bulkResult.nUpserted + nUpserted; + bulkResult.nMatched = bulkResult.nMatched + (result.n - nUpserted); + + if(typeof nModified == 'number') { + bulkResult.nModified = bulkResult.nModified + nModified; + } else { + bulkResult.nModified = null; + } + } + + if(Array.isArray(result.writeErrors)) { + for(i = 0; i < result.writeErrors.length; i++) { + + writeError = { + index: batch.originalZeroIndex + result.writeErrors[i].index + , code: result.writeErrors[i].code + , errmsg: result.writeErrors[i].errmsg + , op: batch.operations[result.writeErrors[i].index] + }; + + bulkResult.writeErrors.push(new WriteError(writeError)); + } + } + + if(result.writeConcernError) { + bulkResult.writeConcernErrors.push(new WriteConcernError(result.writeConcernError)); + } +} + +// +// Clone the options +var cloneOptions = function(options) { + var clone = {}; + var keys = Object.keys(options); + for(var i = 0; i < keys.length; i++) { + clone[keys[i]] = options[keys[i]]; + } + + return clone; +} + +// Exports symbols +exports.BulkWriteResult = BulkWriteResult; +exports.WriteError = WriteError; +exports.Batch = Batch; +exports.LegacyOp = LegacyOp; +exports.mergeBatchResults = mergeBatchResults; +exports.cloneOptions = cloneOptions; +exports.writeConcern = writeConcern; +exports.INVALID_BSON_ERROR = INVALID_BSON_ERROR; +exports.WRITE_CONCERN_ERROR = WRITE_CONCERN_ERROR; +exports.MULTIPLE_ERROR = MULTIPLE_ERROR; +exports.UNKNOWN_ERROR = UNKNOWN_ERROR; +exports.INSERT = INSERT; +exports.UPDATE = UPDATE; +exports.REMOVE = REMOVE; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js b/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js new file mode 100644 index 0000000..e1ae3d7 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js @@ -0,0 +1,539 @@ +"use strict"; + +var common = require('./common') + , utils = require('../utils') + , toError = require('../utils').toError + , handleCallback = require('../utils').handleCallback + , shallowClone = utils.shallowClone + , BulkWriteResult = common.BulkWriteResult + , ObjectID = require('mongodb-core').BSON.ObjectID + , Define = require('../metadata') + , BSON = require('mongodb-core').BSON + , Batch = common.Batch + , mergeBatchResults = common.mergeBatchResults; + +var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, + BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, + BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]); + +/** + * Create a FindOperatorsOrdered instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @return {FindOperatorsOrdered} a FindOperatorsOrdered instance. + */ +var FindOperatorsOrdered = function(self) { + this.s = self.s; +} + +/** + * Add a single update document to the bulk operation + * + * @method + * @param {object} doc update operations + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +FindOperatorsOrdered.prototype.update = function(updateDocument) { + // Perform upsert + var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + var document = { + q: this.s.currentOp.selector + , u: updateDocument + , multi: true + , upsert: upsert + } + + // Clear out current Op + this.s.currentOp = null; + // Add the update document to the list + return addToOperationsList(this, common.UPDATE, document); +} + +/** + * Add a single update one document to the bulk operation + * + * @method + * @param {object} doc update operations + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +FindOperatorsOrdered.prototype.updateOne = function(updateDocument) { + // Perform upsert + var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + var document = { + q: this.s.currentOp.selector + , u: updateDocument + , multi: false + , upsert: upsert + } + + // Clear out current Op + this.s.currentOp = null; + // Add the update document to the list + return addToOperationsList(this, common.UPDATE, document); +} + +/** + * Add a replace one operation to the bulk operation + * + * @method + * @param {object} doc the new document to replace the existing one with + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +FindOperatorsOrdered.prototype.replaceOne = function(updateDocument) { + this.updateOne(updateDocument); +} + +/** + * Upsert modifier for update bulk operation + * + * @method + * @throws {MongoError} + * @return {FindOperatorsOrdered} + */ +FindOperatorsOrdered.prototype.upsert = function() { + this.s.currentOp.upsert = true; + return this; +} + +/** + * Add a remove one operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +FindOperatorsOrdered.prototype.deleteOne = function() { + // Establish the update command + var document = { + q: this.s.currentOp.selector + , limit: 1 + } + + // Clear out current Op + this.s.currentOp = null; + // Add the remove document to the list + return addToOperationsList(this, common.REMOVE, document); +} + +// Backward compatibility +FindOperatorsOrdered.prototype.removeOne = FindOperatorsOrdered.prototype.deleteOne; + +/** + * Add a remove operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +FindOperatorsOrdered.prototype.delete = function() { + // Establish the update command + var document = { + q: this.s.currentOp.selector + , limit: 0 + } + + // Clear out current Op + this.s.currentOp = null; + // Add the remove document to the list + return addToOperationsList(this, common.REMOVE, document); +} + +// Backward compatibility +FindOperatorsOrdered.prototype.remove = FindOperatorsOrdered.prototype.delete; + +// Add to internal list of documents +var addToOperationsList = function(_self, docType, document) { + // Get the bsonSize + var bsonSize = bson.calculateObjectSize(document, { + checkKeys: false, + }); + + // Throw error if the doc is bigger than the max BSON size + if(bsonSize >= _self.s.maxBatchSizeBytes) { + throw toError("document is larger than the maximum size " + _self.s.maxBatchSizeBytes); + } + + // Create a new batch object if we don't have a current one + if(_self.s.currentBatch == null) _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + + // Check if we need to create a new batch + if(((_self.s.currentBatchSize + 1) >= _self.s.maxWriteBatchSize) + || ((_self.s.currentBatchSizeBytes + _self.s.currentBatchSizeBytes) >= _self.s.maxBatchSizeBytes) + || (_self.s.currentBatch.batchType != docType)) { + // Save the batch to the execution stack + _self.s.batches.push(_self.s.currentBatch); + + // Create a new batch + _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + + // Reset the current size trackers + _self.s.currentBatchSize = 0; + _self.s.currentBatchSizeBytes = 0; + } else { + // Update current batch size + _self.s.currentBatchSize = _self.s.currentBatchSize + 1; + _self.s.currentBatchSizeBytes = _self.s.currentBatchSizeBytes + bsonSize; + } + + if(docType == common.INSERT) { + _self.s.bulkResult.insertedIds.push({index: _self.s.currentIndex, _id: document._id}); + } + + // We have an array of documents + if(Array.isArray(document)) { + throw toError("operation passed in cannot be an Array"); + } else { + _self.s.currentBatch.originalIndexes.push(_self.s.currentIndex); + _self.s.currentBatch.operations.push(document) + _self.s.currentBatchSizeBytes = _self.s.currentBatchSizeBytes + bsonSize; + _self.s.currentIndex = _self.s.currentIndex + 1; + } + + // Return self + return _self; +} + +/** + * Create a new OrderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @property {number} length Get the number of operations in the bulk. + * @return {OrderedBulkOperation} a OrderedBulkOperation instance. + */ +function OrderedBulkOperation(topology, collection, options) { + options = options == null ? {} : options; + // TODO Bring from driver information in isMaster + var executed = false; + + // Current item + var currentOp = null; + + // Handle to the bson serializer, used to calculate running sizes + var bson = topology.bson; + + // Namespace for the operation + var namespace = collection.collectionName; + + // Set max byte size + var maxBatchSizeBytes = topology.isMasterDoc && topology.isMasterDoc.maxBsonObjectSize + ? topology.isMasterDoc.maxBsonObjectSize : (1024*1025*16); + var maxWriteBatchSize = topology.isMasterDoc && topology.isMasterDoc.maxWriteBatchSize + ? topology.isMasterDoc.maxWriteBatchSize : 1000; + + // Get the write concern + var writeConcern = common.writeConcern(shallowClone(options), collection, options); + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Final results + var bulkResult = { + ok: 1 + , writeErrors: [] + , writeConcernErrors: [] + , insertedIds: [] + , nInserted: 0 + , nUpserted: 0 + , nMatched: 0 + , nModified: 0 + , nRemoved: 0 + , upserted: [] + }; + + // Internal state + this.s = { + // Final result + bulkResult: bulkResult + // Current batch state + , currentBatch: null + , currentIndex: 0 + , currentBatchSize: 0 + , currentBatchSizeBytes: 0 + , batches: [] + // Write concern + , writeConcern: writeConcern + // Max batch size options + , maxBatchSizeBytes: maxBatchSizeBytes + , maxWriteBatchSize: maxWriteBatchSize + // Namespace + , namespace: namespace + // BSON + , bson: bson + // Topology + , topology: topology + // Options + , options: options + // Current operation + , currentOp: currentOp + // Executed + , executed: executed + // Collection + , collection: collection + // Promise Library + , promiseLibrary: promiseLibrary + // Fundamental error + , err: null + // Bypass validation + , bypassDocumentValidation: typeof options.bypassDocumentValidation == 'boolean' ? options.bypassDocumentValidation : false + } +} + +var define = OrderedBulkOperation.define = new Define('OrderedBulkOperation', OrderedBulkOperation, false); + +OrderedBulkOperation.prototype.raw = function(op) { + var key = Object.keys(op)[0]; + + // Set up the force server object id + var forceServerObjectId = typeof this.s.options.forceServerObjectId == 'boolean' + ? this.s.options.forceServerObjectId : this.s.collection.s.db.options.forceServerObjectId; + + // Update operations + if((op.updateOne && op.updateOne.q) + || (op.updateMany && op.updateMany.q) + || (op.replaceOne && op.replaceOne.q)) { + op[key].multi = op.updateOne || op.replaceOne ? false : true; + return addToOperationsList(this, common.UPDATE, op[key]); + } + + // Crud spec update format + if(op.updateOne || op.updateMany || op.replaceOne) { + var multi = op.updateOne || op.replaceOne ? false : true; + var operation = {q: op[key].filter, u: op[key].update || op[key].replacement, multi: multi} + operation.upsert = op[key].upsert ? true: false; + if(op.collation) operation.collation = op.collation; + return addToOperationsList(this, common.UPDATE, operation); + } + + // Remove operations + if(op.removeOne || op.removeMany || (op.deleteOne && op.deleteOne.q) || op.deleteMany && op.deleteMany.q) { + op[key].limit = op.removeOne ? 1 : 0; + return addToOperationsList(this, common.REMOVE, op[key]); + } + + // Crud spec delete operations, less efficient + if(op.deleteOne || op.deleteMany) { + var limit = op.deleteOne ? 1 : 0; + operation = {q: op[key].filter, limit: limit} + if(op.collation) operation.collation = op.collation; + return addToOperationsList(this, common.REMOVE, operation); + } + + // Insert operations + if(op.insertOne && op.insertOne.document == null) { + if(forceServerObjectId !== true && op.insertOne._id == null) op.insertOne._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, op.insertOne); + } else if(op.insertOne && op.insertOne.document) { + if(forceServerObjectId !== true && op.insertOne.document._id == null) op.insertOne.document._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, op.insertOne.document); + } + + if(op.insertMany) { + for(var i = 0; i < op.insertMany.length; i++) { + if(forceServerObjectId !== true && op.insertMany[i]._id == null) op.insertMany[i]._id = new ObjectID(); + addToOperationsList(this, common.INSERT, op.insertMany[i]); + } + + return; + } + + // No valid type of operation + throw toError("bulkWrite only supports insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, deleteOne, deleteMany"); +} + +/** + * Add a single insert document to the bulk operation + * + * @param {object} doc the document to insert + * @throws {MongoError} + * @return {OrderedBulkOperation} + */ +OrderedBulkOperation.prototype.insert = function(document) { + if(this.s.collection.s.db.options.forceServerObjectId !== true && document._id == null) document._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, document); +} + +/** + * Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne + * + * @method + * @param {object} selector The selector for the bulk operation. + * @throws {MongoError} + * @return {FindOperatorsOrdered} + */ +OrderedBulkOperation.prototype.find = function(selector) { + if (!selector) { + throw toError("Bulk find operation must specify a selector"); + } + + // Save a current selector + this.s.currentOp = { + selector: selector + } + + return new FindOperatorsOrdered(this); +} + +Object.defineProperty(OrderedBulkOperation.prototype, 'length', { + enumerable: true, + get: function() { + return this.s.currentIndex; + } +}); + +// +// Execute next write command in a chain +var executeCommands = function(self, callback) { + if(self.s.batches.length == 0) { + return handleCallback(callback, null, new BulkWriteResult(self.s.bulkResult)); + } + + // Ordered execution of the command + var batch = self.s.batches.shift(); + + var resultHandler = function(err, result) { + // Error is a driver related error not a bulk op error, terminate + if(err && err.driver || err && err.message) { + return handleCallback(callback, err); + } + + // If we have and error + if(err) err.ok = 0; + // Merge the results together + var mergeResult = mergeBatchResults(true, batch, self.s.bulkResult, err, result); + if(mergeResult != null) { + return handleCallback(callback, null, new BulkWriteResult(self.s.bulkResult)); + } + + // If we are ordered and have errors and they are + // not all replication errors terminate the operation + if(self.s.bulkResult.writeErrors.length > 0) { + return handleCallback(callback, toError(self.s.bulkResult.writeErrors[0]), new BulkWriteResult(self.s.bulkResult)); + } + + // Execute the next command in line + executeCommands(self, callback); + } + + var finalOptions = {ordered: true} + if(self.s.writeConcern != null) { + finalOptions.writeConcern = self.s.writeConcern; + } + + // Set an operationIf if provided + if(self.operationId) { + resultHandler.operationId = self.operationId; + } + + // Serialize functions + if(self.s.options.serializeFunctions) { + finalOptions.serializeFunctions = true + } + + // Serialize functions + if(self.s.options.ignoreUndefined) { + finalOptions.ignoreUndefined = true + } + + // Is the bypassDocumentValidation options specific + if(self.s.bypassDocumentValidation == true) { + finalOptions.bypassDocumentValidation = true; + } + + try { + if(batch.batchType == common.INSERT) { + self.s.topology.insert(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } else if(batch.batchType == common.UPDATE) { + self.s.topology.update(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } else if(batch.batchType == common.REMOVE) { + self.s.topology.remove(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } + } catch(err) { + // Force top level error + err.ok = 0; + // Merge top level error and return + handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, null)); + } +} + +/** + * The callback format for results + * @callback OrderedBulkOperation~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {BulkWriteResult} result The bulk write result. + */ + +/** + * Execute the ordered bulk operation + * + * @method + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {OrderedBulkOperation~resultCallback} [callback] The result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +OrderedBulkOperation.prototype.execute = function(_writeConcern, callback) { + var self = this; + if (this.s.executed) { + var executedError = toError('batch cannot be re-executed'); + return (typeof callback === 'function') ? + callback(executedError, null) : this.s.promiseLibrary.reject(executedError); + } + + if (typeof _writeConcern === 'function') { + callback = _writeConcern; + } else if (_writeConcern && typeof _writeConcern === 'object') { + this.s.writeConcern = _writeConcern; + } + + // If we have current batch + if (this.s.currentBatch) this.s.batches.push(this.s.currentBatch) + + // If we have no operations in the bulk raise an error + if (this.s.batches.length == 0) { + var emptyBatchError = toError('Invalid Operation, no operations specified'); + return (typeof callback === 'function') ? + callback(emptyBatchError, null) : this.s.promiseLibrary.reject(emptyBatchError); + } + + // Execute using callback + if (typeof callback === 'function') { + return executeCommands(this, callback); + } + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + executeCommands(self, function(err, r) { + if (err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('execute', {callback: true, promise:false}); + +/** + * Returns an unordered batch object + * @ignore + */ +var initializeOrderedBulkOp = function(topology, collection, options) { + return new OrderedBulkOperation(topology, collection, options); +} + +initializeOrderedBulkOp.OrderedBulkOperation = OrderedBulkOperation; +module.exports = initializeOrderedBulkOp; +module.exports.Bulk = OrderedBulkOperation; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js b/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js new file mode 100644 index 0000000..f6a801e --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js @@ -0,0 +1,541 @@ +"use strict"; + +var common = require('./common') + , utils = require('../utils') + , toError = require('../utils').toError + , handleCallback = require('../utils').handleCallback + , shallowClone = utils.shallowClone + , BulkWriteResult = common.BulkWriteResult + , ObjectID = require('mongodb-core').BSON.ObjectID + , BSON = require('mongodb-core').BSON + , Define = require('../metadata') + , Batch = common.Batch + , mergeBatchResults = common.mergeBatchResults; + +var bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, + BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, + BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]); + +/** + * Create a FindOperatorsUnordered instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @property {number} length Get the number of operations in the bulk. + * @return {FindOperatorsUnordered} a FindOperatorsUnordered instance. + */ +var FindOperatorsUnordered = function(self) { + this.s = self.s; +} + +/** + * Add a single update document to the bulk operation + * + * @method + * @param {object} doc update operations + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +FindOperatorsUnordered.prototype.update = function(updateDocument) { + // Perform upsert + var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + var document = { + q: this.s.currentOp.selector + , u: updateDocument + , multi: true + , upsert: upsert + } + + // Clear out current Op + this.s.currentOp = null; + // Add the update document to the list + return addToOperationsList(this, common.UPDATE, document); +} + +/** + * Add a single update one document to the bulk operation + * + * @method + * @param {object} doc update operations + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +FindOperatorsUnordered.prototype.updateOne = function(updateDocument) { + // Perform upsert + var upsert = typeof this.s.currentOp.upsert == 'boolean' ? this.s.currentOp.upsert : false; + + // Establish the update command + var document = { + q: this.s.currentOp.selector + , u: updateDocument + , multi: false + , upsert: upsert + } + + // Clear out current Op + this.s.currentOp = null; + // Add the update document to the list + return addToOperationsList(this, common.UPDATE, document); +} + +/** + * Add a replace one operation to the bulk operation + * + * @method + * @param {object} doc the new document to replace the existing one with + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +FindOperatorsUnordered.prototype.replaceOne = function(updateDocument) { + this.updateOne(updateDocument); +} + +/** + * Upsert modifier for update bulk operation + * + * @method + * @throws {MongoError} + * @return {FindOperatorsUnordered} + */ +FindOperatorsUnordered.prototype.upsert = function() { + this.s.currentOp.upsert = true; + return this; +} + +/** + * Add a remove one operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +FindOperatorsUnordered.prototype.removeOne = function() { + // Establish the update command + var document = { + q: this.s.currentOp.selector + , limit: 1 + } + + // Clear out current Op + this.s.currentOp = null; + // Add the remove document to the list + return addToOperationsList(this, common.REMOVE, document); +} + +/** + * Add a remove operation to the bulk operation + * + * @method + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +FindOperatorsUnordered.prototype.remove = function() { + // Establish the update command + var document = { + q: this.s.currentOp.selector + , limit: 0 + } + + // Clear out current Op + this.s.currentOp = null; + // Add the remove document to the list + return addToOperationsList(this, common.REMOVE, document); +} + +// +// Add to the operations list +// +var addToOperationsList = function(_self, docType, document) { + // Get the bsonSize + var bsonSize = bson.calculateObjectSize(document, { + checkKeys: false, + }); + // Throw error if the doc is bigger than the max BSON size + if(bsonSize >= _self.s.maxBatchSizeBytes) throw toError("document is larger than the maximum size " + _self.s.maxBatchSizeBytes); + // Holds the current batch + _self.s.currentBatch = null; + // Get the right type of batch + if(docType == common.INSERT) { + _self.s.currentBatch = _self.s.currentInsertBatch; + } else if(docType == common.UPDATE) { + _self.s.currentBatch = _self.s.currentUpdateBatch; + } else if(docType == common.REMOVE) { + _self.s.currentBatch = _self.s.currentRemoveBatch; + } + + // Create a new batch object if we don't have a current one + if(_self.s.currentBatch == null) _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + + // Check if we need to create a new batch + if(((_self.s.currentBatch.size + 1) >= _self.s.maxWriteBatchSize) + || ((_self.s.currentBatch.sizeBytes + bsonSize) >= _self.s.maxBatchSizeBytes) + || (_self.s.currentBatch.batchType != docType)) { + // Save the batch to the execution stack + _self.s.batches.push(_self.s.currentBatch); + + // Create a new batch + _self.s.currentBatch = new Batch(docType, _self.s.currentIndex); + } + + // We have an array of documents + if(Array.isArray(document)) { + throw toError("operation passed in cannot be an Array"); + } else { + _self.s.currentBatch.operations.push(document); + _self.s.currentBatch.originalIndexes.push(_self.s.currentIndex); + _self.s.currentIndex = _self.s.currentIndex + 1; + } + + // Save back the current Batch to the right type + if(docType == common.INSERT) { + _self.s.currentInsertBatch = _self.s.currentBatch; + _self.s.bulkResult.insertedIds.push({index: _self.s.bulkResult.insertedIds.length, _id: document._id}); + } else if(docType == common.UPDATE) { + _self.s.currentUpdateBatch = _self.s.currentBatch; + } else if(docType == common.REMOVE) { + _self.s.currentRemoveBatch = _self.s.currentBatch; + } + + // Update current batch size + _self.s.currentBatch.size = _self.s.currentBatch.size + 1; + _self.s.currentBatch.sizeBytes = _self.s.currentBatch.sizeBytes + bsonSize; + + // Return self + return _self; +} + +/** + * Create a new UnorderedBulkOperation instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @property {number} length Get the number of operations in the bulk. + * @return {UnorderedBulkOperation} a UnorderedBulkOperation instance. + */ +var UnorderedBulkOperation = function(topology, collection, options) { + options = options == null ? {} : options; + + // Get the namespace for the write operations + var namespace = collection.collectionName; + // Used to mark operation as executed + var executed = false; + + // Current item + // var currentBatch = null; + var currentOp = null; + + // Handle to the bson serializer, used to calculate running sizes + var bson = topology.bson; + + // Set max byte size + var maxBatchSizeBytes = topology.isMasterDoc && topology.isMasterDoc.maxBsonObjectSize + ? topology.isMasterDoc.maxBsonObjectSize : (1024*1025*16); + var maxWriteBatchSize = topology.isMasterDoc && topology.isMasterDoc.maxWriteBatchSize + ? topology.isMasterDoc.maxWriteBatchSize : 1000; + + // Get the write concern + var writeConcern = common.writeConcern(shallowClone(options), collection, options); + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Final results + var bulkResult = { + ok: 1 + , writeErrors: [] + , writeConcernErrors: [] + , insertedIds: [] + , nInserted: 0 + , nUpserted: 0 + , nMatched: 0 + , nModified: 0 + , nRemoved: 0 + , upserted: [] + }; + + // Internal state + this.s = { + // Final result + bulkResult: bulkResult + // Current batch state + , currentInsertBatch: null + , currentUpdateBatch: null + , currentRemoveBatch: null + , currentBatch: null + , currentIndex: 0 + , batches: [] + // Write concern + , writeConcern: writeConcern + // Max batch size options + , maxBatchSizeBytes: maxBatchSizeBytes + , maxWriteBatchSize: maxWriteBatchSize + // Namespace + , namespace: namespace + // BSON + , bson: bson + // Topology + , topology: topology + // Options + , options: options + // Current operation + , currentOp: currentOp + // Executed + , executed: executed + // Collection + , collection: collection + // Promise Library + , promiseLibrary: promiseLibrary + // Bypass validation + , bypassDocumentValidation: typeof options.bypassDocumentValidation == 'boolean' ? options.bypassDocumentValidation : false + } +} + +var define = UnorderedBulkOperation.define = new Define('UnorderedBulkOperation', UnorderedBulkOperation, false); + +/** + * Add a single insert document to the bulk operation + * + * @param {object} doc the document to insert + * @throws {MongoError} + * @return {UnorderedBulkOperation} + */ +UnorderedBulkOperation.prototype.insert = function(document) { + if(this.s.collection.s.db.options.forceServerObjectId !== true && document._id == null) document._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, document); +} + +/** + * Initiate a find operation for an update/updateOne/remove/removeOne/replaceOne + * + * @method + * @param {object} selector The selector for the bulk operation. + * @throws {MongoError} + * @return {FindOperatorsUnordered} + */ +UnorderedBulkOperation.prototype.find = function(selector) { + if (!selector) { + throw toError("Bulk find operation must specify a selector"); + } + + // Save a current selector + this.s.currentOp = { + selector: selector + } + + return new FindOperatorsUnordered(this); +} + +Object.defineProperty(UnorderedBulkOperation.prototype, 'length', { + enumerable: true, + get: function() { + return this.s.currentIndex; + } +}); + +UnorderedBulkOperation.prototype.raw = function(op) { + var key = Object.keys(op)[0]; + + // Set up the force server object id + var forceServerObjectId = typeof this.s.options.forceServerObjectId == 'boolean' + ? this.s.options.forceServerObjectId : this.s.collection.s.db.options.forceServerObjectId; + + // Update operations + if((op.updateOne && op.updateOne.q) + || (op.updateMany && op.updateMany.q) + || (op.replaceOne && op.replaceOne.q)) { + op[key].multi = op.updateOne || op.replaceOne ? false : true; + return addToOperationsList(this, common.UPDATE, op[key]); + } + + // Crud spec update format + if(op.updateOne || op.updateMany || op.replaceOne) { + var multi = op.updateOne || op.replaceOne ? false : true; + var operation = {q: op[key].filter, u: op[key].update || op[key].replacement, multi: multi} + if(op[key].upsert) operation.upsert = true; + return addToOperationsList(this, common.UPDATE, operation); + } + + // Remove operations + if(op.removeOne || op.removeMany || (op.deleteOne && op.deleteOne.q) || op.deleteMany && op.deleteMany.q) { + op[key].limit = op.removeOne ? 1 : 0; + return addToOperationsList(this, common.REMOVE, op[key]); + } + + // Crud spec delete operations, less efficient + if(op.deleteOne || op.deleteMany) { + var limit = op.deleteOne ? 1 : 0; + operation = {q: op[key].filter, limit: limit} + return addToOperationsList(this, common.REMOVE, operation); + } + + // Insert operations + if(op.insertOne && op.insertOne.document == null) { + if(forceServerObjectId !== true && op.insertOne._id == null) op.insertOne._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, op.insertOne); + } else if(op.insertOne && op.insertOne.document) { + if(forceServerObjectId !== true && op.insertOne.document._id == null) op.insertOne.document._id = new ObjectID(); + return addToOperationsList(this, common.INSERT, op.insertOne.document); + } + + if(op.insertMany) { + for(var i = 0; i < op.insertMany.length; i++) { + if(forceServerObjectId !== true && op.insertMany[i]._id == null) op.insertMany[i]._id = new ObjectID(); + addToOperationsList(this, common.INSERT, op.insertMany[i]); + } + + return; + } + + // No valid type of operation + throw toError("bulkWrite only supports insertOne, insertMany, updateOne, updateMany, removeOne, removeMany, deleteOne, deleteMany"); +} + +// +// Execute the command +var executeBatch = function(self, batch, callback) { + var finalOptions = {ordered: false} + if(self.s.writeConcern != null) { + finalOptions.writeConcern = self.s.writeConcern; + } + + var resultHandler = function(err, result) { + // Error is a driver related error not a bulk op error, terminate + if(err && err.driver || err && err.message) { + return handleCallback(callback, err); + } + + // If we have and error + if(err) err.ok = 0; + handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, result)); + } + + // Set an operationIf if provided + if(self.operationId) { + resultHandler.operationId = self.operationId; + } + + // Serialize functions + if(self.s.options.serializeFunctions) { + finalOptions.serializeFunctions = true + } + + // Is the bypassDocumentValidation options specific + if(self.s.bypassDocumentValidation == true) { + finalOptions.bypassDocumentValidation = true; + } + + try { + if(batch.batchType == common.INSERT) { + self.s.topology.insert(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } else if(batch.batchType == common.UPDATE) { + self.s.topology.update(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } else if(batch.batchType == common.REMOVE) { + self.s.topology.remove(self.s.collection.namespace, batch.operations, finalOptions, resultHandler); + } + } catch(err) { + // Force top level error + err.ok = 0; + // Merge top level error and return + handleCallback(callback, null, mergeBatchResults(false, batch, self.s.bulkResult, err, null)); + } +} + +// +// Execute all the commands +var executeBatches = function(self, callback) { + var numberOfCommandsToExecute = self.s.batches.length; + // Execute over all the batches + for(var i = 0; i < self.s.batches.length; i++) { + executeBatch(self, self.s.batches[i], function(err) { + // Driver layer error capture it + if(err) error = err; + // Count down the number of commands left to execute + numberOfCommandsToExecute = numberOfCommandsToExecute - 1; + + // Execute + if(numberOfCommandsToExecute == 0) { + // Driver level error + if(error) return handleCallback(callback, error); + // Treat write errors + var error = self.s.bulkResult.writeErrors.length > 0 ? toError(self.s.bulkResult.writeErrors[0]) : null; + handleCallback(callback, error, new BulkWriteResult(self.s.bulkResult)); + } + }); + } +} + +/** + * The callback format for results + * @callback UnorderedBulkOperation~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {BulkWriteResult} result The bulk write result. + */ + +/** + * Execute the ordered bulk operation + * + * @method + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {UnorderedBulkOperation~resultCallback} [callback] The result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +UnorderedBulkOperation.prototype.execute = function(_writeConcern, callback) { + var self = this; + if (this.s.executed) { + var executedError = toError('batch cannot be re-executed'); + return (typeof callback === 'function') ? + callback(executedError, null) : this.s.promiseLibrary.reject(executedError); + } + + if (typeof _writeConcern === 'function') { + callback = _writeConcern; + } else if (_writeConcern && typeof _writeConcern === 'object') { + this.s.writeConcern = _writeConcern; + } + + // If we have current batch + if (this.s.currentInsertBatch) this.s.batches.push(this.s.currentInsertBatch); + if (this.s.currentUpdateBatch) this.s.batches.push(this.s.currentUpdateBatch); + if (this.s.currentRemoveBatch) this.s.batches.push(this.s.currentRemoveBatch); + + // If we have no operations in the bulk raise an error + if (this.s.batches.length == 0) { + var emptyBatchError = toError('Invalid Operation, no operations specified'); + return (typeof callback === 'function') ? + callback(emptyBatchError, null) : this.s.promiseLibrary.reject(emptyBatchError); + } + + // Execute using callback + if (typeof callback === 'function') return executeBatches(this, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + executeBatches(self, function(err, r) { + if (err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('execute', {callback: true, promise:false}); + +/** + * Returns an unordered batch object + * @ignore + */ +var initializeUnorderedBulkOp = function(topology, collection, options) { + return new UnorderedBulkOperation(topology, collection, options); +} + +initializeUnorderedBulkOp.UnorderedBulkOperation = UnorderedBulkOperation; +module.exports = initializeUnorderedBulkOp; +module.exports.Bulk = UnorderedBulkOperation; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/collection.js b/node_modules/mongoose/node_modules/mongodb/lib/collection.js new file mode 100644 index 0000000..dea16c1 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/collection.js @@ -0,0 +1,3377 @@ +"use strict"; + +var checkCollectionName = require('./utils').checkCollectionName + , ObjectID = require('mongodb-core').BSON.ObjectID + , Long = require('mongodb-core').BSON.Long + , Code = require('mongodb-core').BSON.Code + , f = require('util').format + , AggregationCursor = require('./aggregation_cursor') + , MongoError = require('mongodb-core').MongoError + , shallowClone = require('./utils').shallowClone + , isObject = require('./utils').isObject + , toError = require('./utils').toError + , normalizeHintField = require('./utils').normalizeHintField + , handleCallback = require('./utils').handleCallback + , decorateCommand = require('./utils').decorateCommand + , formattedOrderClause = require('./utils').formattedOrderClause + , ReadPreference = require('./read_preference') + , CoreReadPreference = require('mongodb-core').ReadPreference + , CommandCursor = require('./command_cursor') + , Define = require('./metadata') + , Cursor = require('./cursor') + , unordered = require('./bulk/unordered') + , ordered = require('./bulk/ordered') + , assign = require('./utils').assign; + +/** + * @fileOverview The **Collection** class is an internal class that embodies a MongoDB collection + * allowing for insert/update/remove/find and other command operation on that MongoDB collection. + * + * **COLLECTION Cannot directly be instantiated** + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Create a collection we want to drop later + * var col = db.collection('createIndexExample1'); + * // Show that duplicate records got dropped + * col.find({}).toArray(function(err, items) { + * test.equal(null, err); + * test.equal(4, items.length); + * db.close(); + * }); + * }); + */ + +var mergeKeys = ['readPreference', 'ignoreUndefined']; + +/** + * Create a new Collection instance (INTERNAL TYPE, do not instantiate directly) + * @class + * @property {string} collectionName Get the collection name. + * @property {string} namespace Get the full collection namespace. + * @property {object} writeConcern The current write concern values. + * @property {object} readConcern The current read concern values. + * @property {object} hint Get current index hint for collection. + * @return {Collection} a Collection instance. + */ +var Collection = function(db, topology, dbName, name, pkFactory, options) { + checkCollectionName(name); + + // Unpack variables + var internalHint = null; + var slaveOk = options == null || options.slaveOk == null ? db.slaveOk : options.slaveOk; + var serializeFunctions = options == null || options.serializeFunctions == null ? db.s.options.serializeFunctions : options.serializeFunctions; + var raw = options == null || options.raw == null ? db.s.options.raw : options.raw; + var promoteLongs = options == null || options.promoteLongs == null ? db.s.options.promoteLongs : options.promoteLongs; + var promoteValues = options == null || options.promoteValues == null ? db.s.options.promoteValues : options.promoteValues; + var promoteBuffers = options == null || options.promoteBuffers == null ? db.s.options.promoteBuffers : options.promoteBuffers; + var readPreference = null; + var collectionHint = null; + var namespace = f("%s.%s", dbName, name); + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Assign the right collection level readPreference + if(options && options.readPreference) { + readPreference = options.readPreference; + } else if(db.options.readPreference) { + readPreference = db.options.readPreference; + } + + // Set custom primary key factory if provided + pkFactory = pkFactory == null + ? ObjectID + : pkFactory; + + // Internal state + this.s = { + // Set custom primary key factory if provided + pkFactory: pkFactory + // Db + , db: db + // Topology + , topology: topology + // dbName + , dbName: dbName + // Options + , options: options + // Namespace + , namespace: namespace + // Read preference + , readPreference: readPreference + // SlaveOK + , slaveOk: slaveOk + // Serialize functions + , serializeFunctions: serializeFunctions + // Raw + , raw: raw + // promoteLongs + , promoteLongs: promoteLongs + // promoteValues + , promoteValues: promoteValues + // promoteBuffers + , promoteBuffers: promoteBuffers + // internalHint + , internalHint: internalHint + // collectionHint + , collectionHint: collectionHint + // Name + , name: name + // Promise library + , promiseLibrary: promiseLibrary + // Read Concern + , readConcern: options.readConcern + } +} + +var define = Collection.define = new Define('Collection', Collection, false); + +Object.defineProperty(Collection.prototype, 'collectionName', { + enumerable: true, get: function() { return this.s.name; } +}); + +Object.defineProperty(Collection.prototype, 'namespace', { + enumerable: true, get: function() { return this.s.namespace; } +}); + +Object.defineProperty(Collection.prototype, 'readConcern', { + enumerable: true, get: function() { return this.s.readConcern || {level: 'local'}; } +}); + +Object.defineProperty(Collection.prototype, 'writeConcern', { + enumerable:true, + get: function() { + var ops = {}; + if(this.s.options.w != null) ops.w = this.s.options.w; + if(this.s.options.j != null) ops.j = this.s.options.j; + if(this.s.options.fsync != null) ops.fsync = this.s.options.fsync; + if(this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; + return ops; + } +}); + +/** + * @ignore + */ +Object.defineProperty(Collection.prototype, "hint", { + enumerable: true + , get: function () { return this.s.collectionHint; } + , set: function (v) { this.s.collectionHint = normalizeHintField(v); } +}); + +/** + * Creates a cursor for a query that can be used to iterate over results from MongoDB + * @method + * @param {object} query The cursor query object. + * @throws {MongoError} + * @return {Cursor} + */ +Collection.prototype.find = function() { + var options + , args = Array.prototype.slice.call(arguments, 0) + , has_callback = typeof args[args.length - 1] === 'function' + , has_weird_callback = typeof args[0] === 'function' + , callback = has_callback ? args.pop() : (has_weird_callback ? args.shift() : null) + , len = args.length + , selector = len >= 1 ? args[0] : {} + , fields = len >= 2 ? args[1] : undefined; + + if(len === 1 && has_weird_callback) { + // backwards compat for callback?, options case + selector = {}; + options = args[0]; + } + + if(len === 2 && fields !== undefined && !Array.isArray(fields)) { + var fieldKeys = Object.keys(fields); + var is_option = false; + + for(var i = 0; i < fieldKeys.length; i++) { + if(testForFields[fieldKeys[i]] != null) { + is_option = true; + break; + } + } + + if(is_option) { + options = fields; + fields = undefined; + } else { + options = {}; + } + } else if(len === 2 && Array.isArray(fields) && !Array.isArray(fields[0])) { + var newFields = {}; + // Rewrite the array + for(i = 0; i < fields.length; i++) { + newFields[fields[i]] = 1; + } + // Set the fields + fields = newFields; + } + + if(3 === len) { + options = args[2]; + } + + // Ensure selector is not null + selector = selector == null ? {} : selector; + // Validate correctness off the selector + var object = selector; + if(Buffer.isBuffer(object)) { + var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24; + if(object_size != object.length) { + var error = new Error("query selector raw message size does not match message header size [" + object.length + "] != [" + object_size + "]"); + error.name = 'MongoError'; + throw error; + } + } + + // Validate correctness of the field selector + object = fields; + if(Buffer.isBuffer(object)) { + object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24; + if(object_size != object.length) { + error = new Error("query fields raw message size does not match message header size [" + object.length + "] != [" + object_size + "]"); + error.name = 'MongoError'; + throw error; + } + } + + // Check special case where we are using an objectId + if(selector != null && selector._bsontype == 'ObjectID') { + selector = {_id:selector}; + } + + // If it's a serialized fields field we need to just let it through + // user be warned it better be good + if(options && options.fields && !(Buffer.isBuffer(options.fields))) { + fields = {}; + + if(Array.isArray(options.fields)) { + if(!options.fields.length) { + fields['_id'] = 1; + } else { + var l = options.fields.length; + + for (i = 0; i < l; i++) { + fields[options.fields[i]] = 1; + } + } + } else { + fields = options.fields; + } + } + + if (!options) options = {}; + + var newOptions = {}; + + // Make a shallow copy of the collection options + for(var key in this.s.options) { + if(mergeKeys.indexOf(key) != -1) { + newOptions[key] = this.s.options[key]; + } + } + + // Make a shallow copy of options + for (var key in options) { + newOptions[key] = options[key]; + } + + // Unpack options + newOptions.skip = len > 3 ? args[2] : options.skip ? options.skip : 0; + newOptions.limit = len > 3 ? args[3] : options.limit ? options.limit : 0; + newOptions.raw = options.raw != null && typeof options.raw === 'boolean' ? options.raw : this.s.raw; + newOptions.hint = options.hint != null ? normalizeHintField(options.hint) : this.s.collectionHint; + newOptions.timeout = len == 5 ? args[4] : typeof options.timeout === 'undefined' ? undefined : options.timeout; + // // If we have overridden slaveOk otherwise use the default db setting + newOptions.slaveOk = options.slaveOk != null ? options.slaveOk : this.s.db.slaveOk; + + // Add read preference if needed + newOptions = getReadPreference(this, newOptions, this.s.db, this); + + // Set slave ok to true if read preference different from primary + if(newOptions.readPreference != null + && (newOptions.readPreference != 'primary' || newOptions.readPreference.mode != 'primary')) { + newOptions.slaveOk = true; + } + + // Ensure the query is an object + if(selector != null && typeof selector != 'object') { + throw MongoError.create({message: "query selector must be an object", driver:true }); + } + + // Build the find command + var findCommand = { + find: this.s.namespace + , limit: newOptions.limit + , skip: newOptions.skip + , query: selector + } + + // Ensure we use the right await data option + if(typeof newOptions.awaitdata == 'boolean') { + newOptions.awaitData = newOptions.awaitdata + } + + // Translate to new command option noCursorTimeout + if(typeof newOptions.timeout == 'boolean') newOptions.noCursorTimeout = newOptions.timeout; + + // Merge in options to command + for(var name in newOptions) { + if(newOptions[name] != null) findCommand[name] = newOptions[name]; + } + + // Format the fields + var formatFields = function(fields) { + var object = {}; + if(Array.isArray(fields)) { + for(var i = 0; i < fields.length; i++) { + if(Array.isArray(fields[i])) { + object[fields[i][0]] = fields[i][1]; + } else { + object[fields[i][0]] = 1; + } + } + } else { + object = fields; + } + + return object; + } + + // Special treatment for the fields selector + if(fields) findCommand.fields = formatFields(fields); + + // Add db object to the new options + newOptions.db = this.s.db; + + // Add the promise library + newOptions.promiseLibrary = this.s.promiseLibrary; + + // Set raw if available at collection level + if(newOptions.raw == null && typeof this.s.raw == 'boolean') newOptions.raw = this.s.raw; + // Set promoteLongs if available at collection level + if(newOptions.promoteLongs == null && typeof this.s.promoteLongs == 'boolean') newOptions.promoteLongs = this.s.promoteLongs; + if(newOptions.promoteValues == null && typeof this.s.promoteValues == 'boolean') newOptions.promoteValues = this.s.promoteValues; + if(newOptions.promoteBuffers == null && typeof this.s.promoteBuffers == 'boolean') newOptions.promoteBuffers = this.s.promoteBuffers; + + // Sort options + if(findCommand.sort) { + findCommand.sort = formattedOrderClause(findCommand.sort); + } + + // Set the readConcern + if(this.s.readConcern) { + findCommand.readConcern = this.s.readConcern; + } + + // Decorate find command with collation options + decorateWithCollation(findCommand, this, options); + + // Create the cursor + if(typeof callback == 'function') return handleCallback(callback, null, this.s.topology.cursor(this.s.namespace, findCommand, newOptions)); + return this.s.topology.cursor(this.s.namespace, findCommand, newOptions); +} + +define.classMethod('find', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field, + * one will be added to each of the documents missing it by the driver, mutating the document. This behavior + * can be overridden by setting the **forceServerObjectId** flag. + * + * @method + * @param {object} doc Document to insert. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~insertOneWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.insertOne = function(doc, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + if(Array.isArray(doc) && typeof callback == 'function') { + return callback(MongoError.create({message: 'doc parameter must be an object', driver:true })); + } else if(Array.isArray(doc)) { + return new this.s.promiseLibrary(function(resolve, reject) { + reject(MongoError.create({message: 'doc parameter must be an object', driver:true })); + }); + } + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return insertOne(self, doc, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + insertOne(self, doc, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var insertOne = function(self, doc, options, callback) { + insertDocuments(self, [doc], options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + // Workaround for pre 2.6 servers + if(r == null) return callback(null, {result: {ok:1}}); + // Add values to top level to ensure crud spec compatibility + r.insertedCount = r.result.n; + r.insertedId = doc._id; + if(callback) callback(null, r); + }); +} + +var mapInsertManyResults = function(docs, r) { + var ids = r.getInsertedIds(); + var keys = Object.keys(ids); + var finalIds = new Array(keys.length); + + for(var i = 0; i < keys.length; i++) { + if(ids[keys[i]]._id) { + finalIds[ids[keys[i]].index] = ids[keys[i]]._id; + } + } + + var finalResult = { + result: {ok: 1, n: r.insertedCount}, + ops: docs, + insertedCount: r.insertedCount, + insertedIds: finalIds + }; + + if(r.getLastOp()) { + finalResult.result.opTime = r.getLastOp(); + } + + return finalResult; +} + +define.classMethod('insertOne', {callback: true, promise:true}); + +/** + * Inserts an array of documents into MongoDB. If documents passed in do not contain the **_id** field, + * one will be added to each of the documents missing it by the driver, mutating the document. This behavior + * can be overridden by setting the **forceServerObjectId** flag. + * + * @method + * @param {object[]} docs Documents to insert. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {boolean} [options.ordered=true] If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + * @param {Collection~insertWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.insertMany = function(docs, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options ? shallowClone(options) : {ordered:true}; + if(!Array.isArray(docs) && typeof callback == 'function') { + return callback(MongoError.create({message: 'docs parameter must be an array of documents', driver:true })); + } else if(!Array.isArray(docs)) { + return new this.s.promiseLibrary(function(resolve, reject) { + reject(MongoError.create({message: 'docs parameter must be an array of documents', driver:true })); + }); + } + + // Get the write concern options + if(typeof options.checkKeys != 'boolean') { + options.checkKeys = true; + } + + // If keep going set unordered + options['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; + + // Set up the force server object id + var forceServerObjectId = typeof options.forceServerObjectId == 'boolean' + ? options.forceServerObjectId : self.s.db.options.forceServerObjectId; + + // Do we want to force the server to assign the _id key + if(forceServerObjectId !== true) { + // Add _id if not specified + for(var i = 0; i < docs.length; i++) { + if(docs[i]._id == null) docs[i]._id = self.s.pkFactory.createPk(); + } + } + + // Generate the bulk write operations + var operations = [{ + insertMany: docs + }]; + + // Execute using callback + if(typeof callback == 'function') return bulkWrite(self, operations, options, function(err, r) { + if(err) return callback(err, r); + callback(null, mapInsertManyResults(docs, r)); + }); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + bulkWrite(self, operations, options, function(err, r) { + if(err) return reject(err); + resolve(mapInsertManyResults(docs, r)); + }); + }); +} + +define.classMethod('insertMany', {callback: true, promise:true}); + +/** + * @typedef {Object} Collection~BulkWriteOpResult + * @property {number} insertedCount Number of documents inserted. + * @property {number} matchedCount Number of documents matched for update. + * @property {number} modifiedCount Number of documents modified. + * @property {number} deletedCount Number of documents deleted. + * @property {number} upsertedCount Number of documents upserted. + * @property {object} insertedIds Inserted document generated Id's, hash key is the index of the originating operation + * @property {object} upsertedIds Upserted document generated Id's, hash key is the index of the originating operation + * @property {object} result The command result object. + */ + +/** + * The callback format for inserts + * @callback Collection~bulkWriteOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~BulkWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * Perform a bulkWrite operation without a fluent API + * + * Legal operation types are + * + * { insertOne: { document: { a: 1 } } } + * + * { updateOne: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } } + * + * { updateMany: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } } + * + * { deleteOne: { filter: {c:1} } } + * + * { deleteMany: { filter: {c:1} } } + * + * { replaceOne: { filter: {c:3}, replacement: {c:4}, upsert:true}} + * + * If documents passed in do not contain the **_id** field, + * one will be added to each of the documents missing it by the driver, mutating the document. This behavior + * can be overridden by setting the **forceServerObjectId** flag. + * + * @method + * @param {object[]} operations Bulk operations to perform. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.ordered=true] Execute write operation in ordered or unordered fashion. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~bulkWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.bulkWrite = function(operations, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {ordered:true}; + + if(!Array.isArray(operations)) { + throw MongoError.create({message: "operations must be an array of documents", driver:true }); + } + + // Execute using callback + if(typeof callback == 'function') return bulkWrite(self, operations, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + bulkWrite(self, operations, options, function(err, r) { + if(err && r == null) return reject(err); + resolve(r); + }); + }); +} + +var bulkWrite = function(self, operations, options, callback) { + // Add ignoreUndefined + if(self.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = self.s.options.ignoreUndefined; + } + + // Create the bulk operation + var bulk = options.ordered == true || options.ordered == null ? self.initializeOrderedBulkOp(options) : self.initializeUnorderedBulkOp(options); + + // Do we have a collation + var collation = false; + + // for each op go through and add to the bulk + try { + for(var i = 0; i < operations.length; i++) { + // Get the operation type + var key = Object.keys(operations[i])[0]; + // Check if we have a collation + if(operations[i][key].collation) { + collation = true; + } + + // Pass to the raw bulk + bulk.raw(operations[i]); + } + } catch(err) { + return callback(err, null); + } + + // Final options for write concern + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + var writeCon = finalOptions.writeConcern ? finalOptions.writeConcern : {}; + var capabilities = self.s.topology.capabilities(); + + // Did the user pass in a collation, check if our write server supports it + if(collation && capabilities && !capabilities.commandsTakeCollation) { + return callback(new MongoError(f('server/primary/mongos does not support collation'))); + } + + // Execute the bulk + bulk.execute(writeCon, function(err, r) { + // We have connection level error + if(!r && err) return callback(err, null); + // We have single error + if(r && r.hasWriteErrors() && r.getWriteErrorCount() == 1) { + return callback(toError(r.getWriteErrorAt(0)), r); + } + + r.insertedCount = r.nInserted; + r.matchedCount = r.nMatched; + r.modifiedCount = r.nModified || 0; + r.deletedCount = r.nRemoved; + r.upsertedCount = r.getUpsertedIds().length; + r.upsertedIds = {}; + r.insertedIds = {}; + + // Update the n + r.n = r.insertedCount; + + // Inserted documents + var inserted = r.getInsertedIds(); + // Map inserted ids + for(var i = 0; i < inserted.length; i++) { + r.insertedIds[inserted[i].index] = inserted[i]._id; + } + + // Upserted documents + var upserted = r.getUpsertedIds(); + // Map upserted ids + for(i = 0; i < upserted.length; i++) { + r.upsertedIds[upserted[i].index] = upserted[i]._id; + } + + // Check if we have write errors + if(r.hasWriteErrors()) { + // Get all the errors + var errors = r.getWriteErrors(); + // Return the MongoError object + return callback(toError({ + message: 'write operation failed', code: errors[0].code, writeErrors: errors + }), r); + } + + // Check if we have a writeConcern error + if(r.getWriteConcernError()) { + // Return the MongoError object + return callback(toError(r.getWriteConcernError()), r); + } + + // Return the results + callback(null, r); + }); +} + +var insertDocuments = function(self, docs, options, callback) { + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + // Ensure we are operating on an array op docs + docs = Array.isArray(docs) ? docs : [docs]; + + // Get the write concern options + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + if(typeof finalOptions.checkKeys != 'boolean') finalOptions.checkKeys = true; + + // If keep going set unordered + if(finalOptions.keepGoing == true) finalOptions.ordered = false; + finalOptions['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; + + // Set up the force server object id + var forceServerObjectId = typeof options.forceServerObjectId == 'boolean' + ? options.forceServerObjectId : self.s.db.options.forceServerObjectId; + + // Add _id if not specified + if(forceServerObjectId !== true){ + for(var i = 0; i < docs.length; i++) { + if(docs[i]._id === void 0) docs[i]._id = self.s.pkFactory.createPk(); + } + } + + // File inserts + self.s.topology.insert(self.s.namespace, docs, finalOptions, function(err, result) { + if(callback == null) return; + if(err) return handleCallback(callback, err); + if(result == null) return handleCallback(callback, null, null); + if(result.result.code) return handleCallback(callback, toError(result.result)); + if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); + // Add docs to the list + result.ops = docs; + // Return the results + handleCallback(callback, null, result); + }); +} + +define.classMethod('bulkWrite', {callback: true, promise:true}); + +/** + * @typedef {Object} Collection~WriteOpResult + * @property {object[]} ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany + * @property {object} connection The connection object used for the operation. + * @property {object} result The command result object. + */ + +/** + * The callback format for inserts + * @callback Collection~writeOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~WriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * @typedef {Object} Collection~insertWriteOpResult + * @property {Number} insertedCount The total amount of documents inserted. + * @property {object[]} ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany + * @property {ObjectId[]} insertedIds All the generated _id's for the inserted documents. + * @property {object} connection The connection object used for the operation. + * @property {object} result The raw command result object returned from MongoDB (content might vary by server version). + * @property {Number} result.ok Is 1 if the command executed correctly. + * @property {Number} result.n The total count of documents inserted. + */ + +/** + * @typedef {Object} Collection~insertOneWriteOpResult + * @property {Number} insertedCount The total amount of documents inserted. + * @property {object[]} ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany + * @property {ObjectId} insertedId The driver generated ObjectId for the insert operation. + * @property {object} connection The connection object used for the operation. + * @property {object} result The raw command result object returned from MongoDB (content might vary by server version). + * @property {Number} result.ok Is 1 if the command executed correctly. + * @property {Number} result.n The total count of documents inserted. + */ + +/** + * The callback format for inserts + * @callback Collection~insertWriteOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~insertWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * The callback format for inserts + * @callback Collection~insertOneWriteOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~insertOneWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * Inserts a single document or a an array of documents into MongoDB. If documents passed in do not contain the **_id** field, + * one will be added to each of the documents missing it by the driver, mutating the document. This behavior + * can be overridden by setting the **forceServerObjectId** flag. + * + * @method + * @param {(object|object[])} docs Documents to insert. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~insertWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated Use insertOne, insertMany or bulkWrite + */ +Collection.prototype.insert = function(docs, options, callback) { + if(typeof options == 'function') callback = options, options = {}; + options = options || {ordered:false}; + docs = !Array.isArray(docs) ? [docs] : docs; + + if(options.keepGoing == true) { + options.ordered = false; + } + + return this.insertMany(docs, options, callback); +} + +define.classMethod('insert', {callback: true, promise:true}); + +/** + * @typedef {Object} Collection~updateWriteOpResult + * @property {Object} result The raw result returned from MongoDB, field will vary depending on server version. + * @property {Number} result.ok Is 1 if the command executed correctly. + * @property {Number} result.n The total count of documents scanned. + * @property {Number} result.nModified The total count of documents modified. + * @property {Object} connection The connection object used for the operation. + * @property {Number} matchedCount The number of documents that matched the filter. + * @property {Number} modifiedCount The number of documents that were modified. + * @property {Number} upsertedCount The number of documents upserted. + * @property {Object} upsertedId The upserted id. + * @property {ObjectId} upsertedId._id The upserted _id returned from the server. + */ + +/** + * The callback format for inserts + * @callback Collection~updateWriteOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~updateWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * Update a single document on MongoDB + * @method + * @param {object} filter The Filter used to select the document to update + * @param {object} update The update operations to be applied to the document + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.upsert=false] Update operation is an upsert. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.updateOne = function(filter, update, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = shallowClone(options) + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return updateOne(self, filter, update, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + updateOne(self, filter, update, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var updateOne = function(self, filter, update, options, callback) { + // Set single document update + options.multi = false; + // Execute update + updateDocuments(self, filter, update, options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + if(r == null) return callback(null, {result: {ok:1}}); + r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; + r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; + r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; + r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; + if(callback) callback(null, r); + }); +} + +define.classMethod('updateOne', {callback: true, promise:true}); + +/** + * Replace a document on MongoDB + * @method + * @param {object} filter The Filter used to select the document to update + * @param {object} doc The Document that replaces the matching document + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.upsert=false] Update operation is an upsert. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.replaceOne = function(filter, doc, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = shallowClone(options) + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return replaceOne(self, filter, doc, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + replaceOne(self, filter, doc, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var replaceOne = function(self, filter, doc, options, callback) { + // Set single document update + options.multi = false; + + // Execute update + updateDocuments(self, filter, doc, options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + if(r == null) return callback(null, {result: {ok:1}}); + + r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; + r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; + r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; + r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; + r.ops = [doc]; + if(callback) callback(null, r); + }); +} + +define.classMethod('replaceOne', {callback: true, promise:true}); + +/** + * Update multiple documents on MongoDB + * @method + * @param {object} filter The Filter used to select the document to update + * @param {object} update The update operations to be applied to the document + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.upsert=false] Update operation is an upsert. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~updateWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.updateMany = function(filter, update, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = shallowClone(options) + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return updateMany(self, filter, update, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + updateMany(self, filter, update, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var updateMany = function(self, filter, update, options, callback) { + // Set single document update + options.multi = true; + // Execute update + updateDocuments(self, filter, update, options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + if(r == null) return callback(null, {result: {ok:1}}); + r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n; + r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null; + r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0; + r.matchedCount = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? 0 : r.result.n; + if(callback) callback(null, r); + }); +} + +define.classMethod('updateMany', {callback: true, promise:true}); + +var updateDocuments = function(self, selector, document, options, callback) { + if('function' === typeof options) callback = options, options = null; + if(options == null) options = {}; + if(!('function' === typeof callback)) callback = null; + + // If we are not providing a selector or document throw + if(selector == null || typeof selector != 'object') return callback(toError("selector must be a valid JavaScript object")); + if(document == null || typeof document != 'object') return callback(toError("document must be a valid JavaScript object")); + + // Get the write concern options + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + + // Do we return the actual result document + // Either use override on the function, or go back to default on either the collection + // level or db + finalOptions['serializeFunctions'] = options['serializeFunctions'] || self.s.serializeFunctions; + + // Execute the operation + var op = {q: selector, u: document}; + op.upsert = options.upsert !== void 0 ? !!options.upsert : false; + op.multi = options.multi !== void 0 ? !!options.multi : false; + + // Have we specified collation + decorateWithCollation(finalOptions, self, options); + + // Update options + self.s.topology.update(self.s.namespace, [op], finalOptions, function(err, result) { + if(callback == null) return; + if(err) return handleCallback(callback, err, null); + if(result == null) return handleCallback(callback, null, null); + if(result.result.code) return handleCallback(callback, toError(result.result)); + if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); + // Return the results + handleCallback(callback, null, result); + }); +} + +/** + * Updates documents. + * @method + * @param {object} selector The selector for the update operation. + * @param {object} document The update document. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.upsert=false] Update operation is an upsert. + * @param {boolean} [options.multi=false] Update one/all documents with operation. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Collection~writeOpCallback} [callback] The command result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + * @deprecated use updateOne, updateMany or bulkWrite + */ +Collection.prototype.update = function(selector, document, options, callback) { + var self = this; + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return updateDocuments(self, selector, document, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + updateDocuments(self, selector, document, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('update', {callback: true, promise:true}); + +/** + * @typedef {Object} Collection~deleteWriteOpResult + * @property {Object} result The raw result returned from MongoDB, field will vary depending on server version. + * @property {Number} result.ok Is 1 if the command executed correctly. + * @property {Number} result.n The total count of documents deleted. + * @property {Object} connection The connection object used for the operation. + * @property {Number} deletedCount The number of documents deleted. + */ + +/** + * The callback format for inserts + * @callback Collection~deleteWriteOpCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~deleteWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * Delete a document on MongoDB + * @method + * @param {object} filter The Filter used to select the document to remove + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~deleteWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.deleteOne = function(filter, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = shallowClone(options); + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return deleteOne(self, filter, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + deleteOne(self, filter, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var deleteOne = function(self, filter, options, callback) { + options.single = true; + removeDocuments(self, filter, options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + if(r == null) return callback(null, {result: {ok:1}}); + r.deletedCount = r.result.n; + if(callback) callback(null, r); + }); +} + +define.classMethod('deleteOne', {callback: true, promise:true}); + +Collection.prototype.removeOne = Collection.prototype.deleteOne; + +define.classMethod('removeOne', {callback: true, promise:true}); + +/** + * Delete multiple documents on MongoDB + * @method + * @param {object} filter The Filter used to select the documents to remove + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~deleteWriteOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.deleteMany = function(filter, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = shallowClone(options); + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return deleteMany(self, filter, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + deleteMany(self, filter, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var deleteMany = function(self, filter, options, callback) { + options.single = false; + + removeDocuments(self, filter, options, function(err, r) { + if(callback == null) return; + if(err && callback) return callback(err); + if(r == null) return callback(null, {result: {ok:1}}); + r.deletedCount = r.result.n; + if(callback) callback(null, r); + }); +} + +var removeDocuments = function(self, selector, options, callback) { + if(typeof options == 'function') { + callback = options, options = {}; + } else if (typeof selector === 'function') { + callback = selector; + options = {}; + selector = {}; + } + + // Create an empty options object if the provided one is null + options = options || {}; + + // Get the write concern options + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + + // If selector is null set empty + if(selector == null) selector = {}; + + // Build the op + var op = {q: selector, limit: 0}; + if(options.single) op.limit = 1; + + // Have we specified collation + decorateWithCollation(finalOptions, self, options); + + // Execute the remove + self.s.topology.remove(self.s.namespace, [op], finalOptions, function(err, result) { + if(callback == null) return; + if(err) return handleCallback(callback, err, null); + if(result == null) return handleCallback(callback, null, null); + if(result.result.code) return handleCallback(callback, toError(result.result)); + if(result.result.writeErrors) return handleCallback(callback, toError(result.result.writeErrors[0])); + // Return the results + handleCallback(callback, null, result); + }); +} + +define.classMethod('deleteMany', {callback: true, promise:true}); + +Collection.prototype.removeMany = Collection.prototype.deleteMany; + +define.classMethod('removeMany', {callback: true, promise:true}); + +/** + * Remove documents. + * @method + * @param {object} selector The selector for the update operation. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.single=false] Removes the first document found. + * @param {Collection~writeOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated use deleteOne, deleteMany or bulkWrite + */ +Collection.prototype.remove = function(selector, options, callback) { + var self = this; + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return removeDocuments(self, selector, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + removeDocuments(self, selector, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('remove', {callback: true, promise:true}); + +/** + * Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic + * operators and update instead for more efficient operations. + * @method + * @param {object} doc Document to save + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~writeOpCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated use insertOne, insertMany, updateOne or updateMany + */ +Collection.prototype.save = function(doc, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Add ignoreUndefined + if(this.s.options.ignoreUndefined) { + options = shallowClone(options); + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Execute using callback + if(typeof callback == 'function') return save(self, doc, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + save(self, doc, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var save = function(self, doc, options, callback) { + // Get the write concern options + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + // Establish if we need to perform an insert or update + if(doc._id != null) { + finalOptions.upsert = true; + return updateDocuments(self, {_id: doc._id}, doc, finalOptions, callback); + } + + // Insert the document + insertDocuments(self, [doc], options, function(err, r) { + if(callback == null) return; + if(doc == null) return handleCallback(callback, null, null); + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, r); + }); +} + +define.classMethod('save', {callback: true, promise:true}); + +/** + * The callback format for results + * @callback Collection~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object} result The result object if the command was executed successfully. + */ + +/** + * Fetches the first document that matches the query + * @method + * @param {object} query Query for find Operation + * @param {object} [options=null] Optional settings. + * @param {number} [options.limit=0] Sets the limit of documents returned in the query. + * @param {(array|object)} [options.sort=null] Set to sort the documents coming back from the query. Array of indexes, [['a', 1]] etc. + * @param {object} [options.fields=null] The fields to return in the query. Object of fields to include or exclude (not both), {'a':1} + * @param {number} [options.skip=0] Set to skip N documents ahead in your query (useful for pagination). + * @param {Object} [options.hint=null] Tell the query to use specific indexes in the query. Object of indexes to use, {'_id':1} + * @param {boolean} [options.explain=false] Explain the query instead of returning the data. + * @param {boolean} [options.snapshot=false] Snapshot query. + * @param {boolean} [options.timeout=false] Specify if the cursor can timeout. + * @param {boolean} [options.tailable=false] Specify if the cursor is tailable. + * @param {number} [options.batchSize=0] Set the batchSize for the getMoreCommand when iterating over the query results. + * @param {boolean} [options.returnKey=false] Only return the index key. + * @param {number} [options.maxScan=null] Limit the number of items to scan. + * @param {number} [options.min=null] Set index bounds. + * @param {number} [options.max=null] Set index bounds. + * @param {boolean} [options.showDiskLoc=false] Show disk location of results. + * @param {string} [options.comment=null] You can put a $comment field on a query to make looking in the profiler logs simpler. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.partial=false] Specify if the cursor should return partial results when querying against a sharded system + * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.findOne = function() { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + var callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + + // Execute using callback + if(typeof callback == 'function') return findOne(self, args, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + findOne(self, args, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findOne = function(self, args, callback) { + var cursor = self.find.apply(self, args).limit(-1).batchSize(1); + // Return the item + cursor.next(function(err, item) { + if(err != null) return handleCallback(callback, toError(err), null); + handleCallback(callback, null, item); + }); +} + +define.classMethod('findOne', {callback: true, promise:true}); + +/** + * The callback format for the collection method, must be used if strict is specified + * @callback Collection~collectionResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection} collection The collection instance. + */ + +/** + * Rename the collection. + * + * @method + * @param {string} newName New name of of the collection. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.dropTarget=false] Drop the target name collection if it previously exists. + * @param {Collection~collectionResultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.rename = function(newName, opt, callback) { + var self = this; + if(typeof opt == 'function') callback = opt, opt = {}; + opt = assign({}, opt, {readPreference: ReadPreference.PRIMARY}); + + // Execute using callback + if(typeof callback == 'function') return rename(self, newName, opt, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + rename(self, newName, opt, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var rename = function(self, newName, opt, callback) { + // Check the collection name + checkCollectionName(newName); + // Build the command + var renameCollection = f("%s.%s", self.s.dbName, self.s.name); + var toCollection = f("%s.%s", self.s.dbName, newName); + var dropTarget = typeof opt.dropTarget == 'boolean' ? opt.dropTarget : false; + var cmd = {'renameCollection':renameCollection, 'to':toCollection, 'dropTarget':dropTarget}; + + // Decorate command with writeConcern if supported + decorateWithWriteConcern(cmd, self, opt); + + // Execute against admin + self.s.db.admin().command(cmd, opt, function(err, doc) { + if(err) return handleCallback(callback, err, null); + // We have an error + if(doc.errmsg) return handleCallback(callback, toError(doc), null); + try { + return handleCallback(callback, null, new Collection(self.s.db, self.s.topology, self.s.dbName, newName, self.s.pkFactory, self.s.options)); + } catch(err) { + return handleCallback(callback, toError(err), null); + } + }); +} + +define.classMethod('rename', {callback: true, promise:true}); + +/** + * Drop the collection from the database, removing it permanently. New accesses will create a new collection. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {Collection~resultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.drop = function(options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Execute using callback + if(typeof callback == 'function') return self.s.db.dropCollection(self.s.name, options, callback); + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.db.dropCollection(self.s.name, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('drop', {callback: true, promise:true}); + +/** + * Returns the options of the collection. + * + * @method + * @param {Collection~resultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.options = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return options(self, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + options(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var options = function(self, callback) { + self.s.db.listCollections({name: self.s.name}).toArray(function(err, collections) { + if(err) return handleCallback(callback, err); + if(collections.length == 0) { + return handleCallback(callback, MongoError.create({message: f("collection %s not found", self.s.namespace), driver:true })); + } + + handleCallback(callback, err, collections[0].options || null); + }); +} + +define.classMethod('options', {callback: true, promise:true}); + +/** + * Returns if the collection is a capped collection + * + * @method + * @param {Collection~resultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.isCapped = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return isCapped(self, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + isCapped(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var isCapped = function(self, callback) { + self.options(function(err, document) { + if(err) return handleCallback(callback, err); + handleCallback(callback, null, document && document.capped); + }); +} + +define.classMethod('isCapped', {callback: true, promise:true}); + +/** + * Creates an index on the db and collection collection. + * @method + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.unique=false] Creates an unique index. + * @param {boolean} [options.sparse=false] Creates a sparse index. + * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. + * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value + * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v=null] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {string} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.partialFilterExpression=null] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.createIndex = function(fieldOrSpec, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + options = typeof callback === 'function' ? options : callback; + options = options == null ? {} : options; + + // Execute using callback + if(typeof callback == 'function') return createIndex(self, fieldOrSpec, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + createIndex(self, fieldOrSpec, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var createIndex = function(self, fieldOrSpec, options, callback) { + self.s.db.createIndex(self.s.name, fieldOrSpec, options, callback); +} + +define.classMethod('createIndex', {callback: true, promise:true}); + +/** + * Creates multiple indexes in the collection, this method is only supported for + * MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported + * error. Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/. + * @method + * @param {array} indexSpecs An array of index specifications to be created + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.createIndexes = function(indexSpecs, callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return createIndexes(self, indexSpecs, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + createIndexes(self, indexSpecs, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var createIndexes = function(self, indexSpecs, callback) { + var capabilities = self.s.topology.capabilities(); + + // Ensure we generate the correct name if the parameter is not set + for(var i = 0; i < indexSpecs.length; i++) { + if(indexSpecs[i].name == null) { + var keys = []; + + // Did the user pass in a collation, check if our write server supports it + if(indexSpecs[i].collation && capabilities && !capabilities.commandsTakeCollation) { + return callback(new MongoError(f('server/primary/mongos does not support collation'))); + } + + for(var name in indexSpecs[i].key) { + keys.push(f('%s_%s', name, indexSpecs[i].key[name])); + } + + // Set the name + indexSpecs[i].name = keys.join('_'); + } + } + + // Execute the index + self.s.db.command({ + createIndexes: self.s.name, indexes: indexSpecs + }, { readPreference: ReadPreference.PRIMARY }, callback); +} + +define.classMethod('createIndexes', {callback: true, promise:true}); + +/** + * Drops an index from this collection. + * @method + * @param {string} indexName Name of the index to drop. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.dropIndex = function(indexName, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + // Run only against primary + options.readPreference = ReadPreference.PRIMARY; + + // Execute using callback + if(typeof callback == 'function') return dropIndex(self, indexName, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + dropIndex(self, indexName, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var dropIndex = function(self, indexName, options, callback) { + // Delete index command + var cmd = {'dropIndexes':self.s.name, 'index':indexName}; + + // Decorate command with writeConcern if supported + decorateWithWriteConcern(cmd, self, options); + + // Execute command + self.s.db.command(cmd, options, function(err, result) { + if(typeof callback != 'function') return; + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, result); + }); +} + +define.classMethod('dropIndex', {callback: true, promise:true}); + +/** + * Drops all indexes from this collection. + * @method + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.dropIndexes = function(options, callback) { + var self = this; + + // Do we have options + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Execute using callback + if(typeof callback == 'function') return dropIndexes(self, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + dropIndexes(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var dropIndexes = function(self, options, callback) { + self.dropIndex('*', options, function(err) { + if(err) return handleCallback(callback, err, false); + handleCallback(callback, null, true); + }); +} + +define.classMethod('dropIndexes', {callback: true, promise:true}); + +/** + * Drops all indexes from this collection. + * @method + * @deprecated use dropIndexes + * @param {Collection~resultCallback} callback The command result callback + * @return {Promise} returns Promise if no [callback] passed + */ +Collection.prototype.dropAllIndexes = Collection.prototype.dropIndexes; + +define.classMethod('dropAllIndexes', {callback: true, promise:true}); + +/** + * Reindex all indexes on the collection + * Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections. + * @method + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.reIndex = function(options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Execute using callback + if(typeof callback == 'function') return reIndex(self, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + reIndex(self, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var reIndex = function(self, options, callback) { + // Reindex + var cmd = {'reIndex':self.s.name}; + + // Execute the command + self.s.db.command(cmd, options, function(err, result) { + if(callback == null) return; + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }); +} + +define.classMethod('reIndex', {callback: true, promise:true}); + +/** + * Get the list of all indexes information for the collection. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {number} [options.batchSize=null] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @return {CommandCursor} + */ +Collection.prototype.listIndexes = function(options) { + options = options || {}; + // Clone the options + options = shallowClone(options); + // Determine the read preference in the options. + options = getReadPreference(this, options, this.s.db, this); + // Set the CommandCursor constructor + options.cursorFactory = CommandCursor; + // Set the promiseLibrary + options.promiseLibrary = this.s.promiseLibrary; + + if(!this.s.topology.capabilities()) { + throw new MongoError('cannot connect to server'); + } + + // We have a list collections command + if(this.s.topology.capabilities().hasListIndexesCommand) { + // Cursor options + var cursor = options.batchSize ? {batchSize: options.batchSize} : {} + // Build the command + var command = { listIndexes: this.s.name, cursor: cursor }; + // Execute the cursor + cursor = this.s.topology.cursor(f('%s.$cmd', this.s.dbName), command, options); + // Do we have a readPreference, apply it + if(options.readPreference) cursor.setReadPreference(options.readPreference); + // Return the cursor + return cursor; + } + + // Get the namespace + var ns = f('%s.system.indexes', this.s.dbName); + // Get the query + cursor = this.s.topology.cursor(ns, {find: ns, query: {ns: this.s.namespace}}, options); + // Do we have a readPreference, apply it + if(options.readPreference) cursor.setReadPreference(options.readPreference); + // Set the passed in batch size if one was provided + if(options.batchSize) cursor = cursor.batchSize(options.batchSize); + // Return the cursor + return cursor; +}; + +define.classMethod('listIndexes', {callback: false, promise:false, returns: [CommandCursor]}); + +/** + * Ensures that an index exists, if it does not it creates it + * @method + * @deprecated use createIndexes instead + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.unique=false] Creates an unique index. + * @param {boolean} [options.sparse=false] Creates a sparse index. + * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. + * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value + * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v=null] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.ensureIndex = function(fieldOrSpec, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Execute using callback + if(typeof callback == 'function') return ensureIndex(self, fieldOrSpec, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + ensureIndex(self, fieldOrSpec, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var ensureIndex = function(self, fieldOrSpec, options, callback) { + self.s.db.ensureIndex(self.s.name, fieldOrSpec, options, callback); +} + +define.classMethod('ensureIndex', {callback: true, promise:true}); + +/** + * Checks if one or more indexes exist on the collection, fails on first non-existing index + * @method + * @param {(string|array)} indexes One or more index names to check. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.indexExists = function(indexes, callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') return indexExists(self, indexes, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + indexExists(self, indexes, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var indexExists = function(self, indexes, callback) { + self.indexInformation(function(err, indexInformation) { + // If we have an error return + if(err != null) return handleCallback(callback, err, null); + // Let's check for the index names + if(!Array.isArray(indexes)) return handleCallback(callback, null, indexInformation[indexes] != null); + // Check in list of indexes + for(var i = 0; i < indexes.length; i++) { + if(indexInformation[indexes[i]] == null) { + return handleCallback(callback, null, false); + } + } + + // All keys found return true + return handleCallback(callback, null, true); + }); +} + +define.classMethod('indexExists', {callback: true, promise:true}); + +/** + * Retrieves this collections index info. + * @method + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.full=false] Returns the full raw index information. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.indexInformation = function(options, callback) { + var self = this; + // Unpack calls + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return indexInformation(self, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + indexInformation(self, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var indexInformation = function(self, options, callback) { + self.s.db.indexInformation(self.s.name, options, callback); +} + +define.classMethod('indexInformation', {callback: true, promise:true}); + +/** + * The callback format for results + * @callback Collection~countCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {number} result The count of documents that matched the query. + */ + +/** + * Count number of matching documents in the db to a query. + * @method + * @param {object} query The query for the count. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.limit=null] The limit of documents to count. + * @param {boolean} [options.skip=null] The number of documents to skip for the count. + * @param {string} [options.hint=null] An index name hint for the query. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {Collection~countCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.count = function(query, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + var queryOption = args.length ? args.shift() || {} : {}; + var optionsOption = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return count(self, queryOption, optionsOption, callback); + + // Check if query is empty + query = query || {}; + options = options || {}; + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + count(self, query, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var count = function(self, query, options, callback) { + var skip = options.skip; + var limit = options.limit; + var hint = options.hint; + var maxTimeMS = options.maxTimeMS; + + // Final query + var cmd = { + 'count': self.s.name, 'query': query + }; + + // Add limit, skip and maxTimeMS if defined + if(typeof skip == 'number') cmd.skip = skip; + if(typeof limit == 'number') cmd.limit = limit; + if(typeof maxTimeMS == 'number') cmd.maxTimeMS = maxTimeMS; + if(hint) cmd.hint = hint; + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Do we have a readConcern specified + if(self.s.readConcern) { + cmd.readConcern = self.s.readConcern; + } + + // Have we specified collation + decorateWithCollation(cmd, self, options); + + // Execute command + self.s.db.command(cmd, options, function(err, result) { + if(err) return handleCallback(callback, err); + handleCallback(callback, null, result.n); + }); +} + +define.classMethod('count', {callback: true, promise:true}); + +/** + * The distinct command returns returns a list of distinct values for the given key across a collection. + * @method + * @param {string} key Field of the document to find distinct values for. + * @param {object} query The query for filtering the set of documents to which we apply the distinct filter. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.distinct = function(key, query, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + var queryOption = args.length ? args.shift() || {} : {}; + var optionsOption = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return distinct(self, key, queryOption, optionsOption, callback); + + // Ensure the query and options are set + query = query || {}; + options = options || {}; + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + distinct(self, key, query, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var distinct = function(self, key, query, options, callback) { + // maxTimeMS option + var maxTimeMS = options.maxTimeMS; + + // Distinct command + var cmd = { + 'distinct': self.s.name, 'key': key, 'query': query + }; + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Add maxTimeMS if defined + if(typeof maxTimeMS == 'number') + cmd.maxTimeMS = maxTimeMS; + + // Do we have a readConcern specified + if(self.s.readConcern) { + cmd.readConcern = self.s.readConcern; + } + + // Have we specified collation + decorateWithCollation(cmd, self, options); + + // Execute the command + self.s.db.command(cmd, options, function(err, result) { + if(err) return handleCallback(callback, err); + handleCallback(callback, null, result.values); + }); +} + +define.classMethod('distinct', {callback: true, promise:true}); + +/** + * Retrieve all the indexes on the collection. + * @method + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.indexes = function(callback) { + var self = this; + // Execute using callback + if(typeof callback == 'function') return indexes(self, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + indexes(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var indexes = function(self, callback) { + self.s.db.indexInformation(self.s.name, {full:true}, callback); +} + +define.classMethod('indexes', {callback: true, promise:true}); + +/** + * Get all the collection statistics. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {number} [options.scale=null] Divide the returned sizes by scale value. + * @param {Collection~resultCallback} [callback] The collection result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.stats = function(options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + // Fetch all commands + options = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return stats(self, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + stats(self, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var stats = function(self, options, callback) { + // Build command object + var commandObject = { + collStats:self.s.name + } + + // Check if we have the scale value + if(options['scale'] != null) commandObject['scale'] = options['scale']; + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Execute the command + self.s.db.command(commandObject, options, callback); +} + +define.classMethod('stats', {callback: true, promise:true}); + +/** + * @typedef {Object} Collection~findAndModifyWriteOpResult + * @property {object} value Document returned from findAndModify command. + * @property {object} lastErrorObject The raw lastErrorObject returned from the command. + * @property {Number} ok Is 1 if the command executed correctly. + */ + +/** + * The callback format for inserts + * @callback Collection~findAndModifyCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection~findAndModifyWriteOpResult} result The result object if the command was executed successfully. + */ + +/** + * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation. + * + * @method + * @param {object} filter Document selection filter. + * @param {object} [options=null] Optional settings. + * @param {object} [options.projection=null] Limits the fields to return for all matching documents. + * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.findOneAndDelete = function(filter, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Basic validation + if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); + + // Execute using callback + if(typeof callback == 'function') return findOneAndDelete(self, filter, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + options = options || {}; + + findOneAndDelete(self, filter, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findOneAndDelete = function(self, filter, options, callback) { + // Final options + var finalOptions = shallowClone(options); + finalOptions['fields'] = options.projection; + finalOptions['remove'] = true; + // Execute find and Modify + self.findAndModify( + filter + , options.sort + , null + , finalOptions + , callback + ); +} + +define.classMethod('findOneAndDelete', {callback: true, promise:true}); + +/** + * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation. + * + * @method + * @param {object} filter Document selection filter. + * @param {object} replacement Document replacing the matching document. + * @param {object} [options=null] Optional settings. + * @param {object} [options.projection=null] Limits the fields to return for all matching documents. + * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {boolean} [options.upsert=false] Upsert the document if it does not exist. + * @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.findOneAndReplace = function(filter, replacement, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Basic validation + if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); + if(replacement == null || typeof replacement != 'object') throw toError('replacement parameter must be an object'); + + // Execute using callback + if(typeof callback == 'function') return findOneAndReplace(self, filter, replacement, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + options = options || {}; + + findOneAndReplace(self, filter, replacement, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findOneAndReplace = function(self, filter, replacement, options, callback) { + // Final options + var finalOptions = shallowClone(options); + finalOptions['fields'] = options.projection; + finalOptions['update'] = true; + finalOptions['new'] = typeof options.returnOriginal == 'boolean' ? !options.returnOriginal : false; + finalOptions['upsert'] = typeof options.upsert == 'boolean' ? options.upsert : false; + + // Execute findAndModify + self.findAndModify( + filter + , options.sort + , replacement + , finalOptions + , callback + ); +} + +define.classMethod('findOneAndReplace', {callback: true, promise:true}); + +/** + * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation. + * + * @method + * @param {object} filter Document selection filter. + * @param {object} update Update operations to be performed on the document + * @param {object} [options=null] Optional settings. + * @param {object} [options.projection=null] Limits the fields to return for all matching documents. + * @param {object} [options.sort=null] Determines which document the operation modifies if the query selects multiple documents. + * @param {number} [options.maxTimeMS=null] The maximum amount of time to allow the query to run. + * @param {boolean} [options.upsert=false] Upsert the document if it does not exist. + * @param {boolean} [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true. + * @param {Collection~findAndModifyCallback} [callback] The collection result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.findOneAndUpdate = function(filter, update, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Basic validation + if(filter == null || typeof filter != 'object') throw toError('filter parameter must be an object'); + if(update == null || typeof update != 'object') throw toError('update parameter must be an object'); + + // Execute using callback + if(typeof callback == 'function') return findOneAndUpdate(self, filter, update, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + options = options || {}; + + findOneAndUpdate(self, filter, update, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findOneAndUpdate = function(self, filter, update, options, callback) { + // Final options + var finalOptions = shallowClone(options); + finalOptions['fields'] = options.projection; + finalOptions['update'] = true; + finalOptions['new'] = options.returnOriginal !== void 0 ? !options.returnOriginal : false; + finalOptions['upsert'] = options.upsert !== void 0 ? !!options.upsert : false; + + // Execute findAndModify + self.findAndModify( + filter + , options.sort + , update + , finalOptions + , callback + ); +} + +define.classMethod('findOneAndUpdate', {callback: true, promise:true}); + +/** + * Find and update a document. + * @method + * @param {object} query Query object to locate the object to modify. + * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. + * @param {object} doc The fields/vals to be updated. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.remove=false] Set to true to remove the object before returning. + * @param {boolean} [options.upsert=false] Perform an upsert operation. + * @param {boolean} [options.new=false] Set to true if you want to return the modified object rather than the original. Ignored for remove. + * @param {object} [options.fields=null] Object containing the field projection for the result returned from the operation. + * @param {Collection~findAndModifyCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead + */ +Collection.prototype.findAndModify = function(query, sort, doc, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + sort = args.length ? args.shift() || [] : []; + doc = args.length ? args.shift() : null; + options = args.length ? args.shift() || {} : {}; + + // Clone options + options = shallowClone(options); + // Force read preference primary + options.readPreference = ReadPreference.PRIMARY; + + // Execute using callback + if(typeof callback == 'function') return findAndModify(self, query, sort, doc, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + options = options || {}; + + findAndModify(self, query, sort, doc, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findAndModify = function(self, query, sort, doc, options, callback) { + // Create findAndModify command object + var queryObject = { + 'findandmodify': self.s.name + , 'query': query + }; + + sort = formattedOrderClause(sort); + if(sort) { + queryObject.sort = sort; + } + + queryObject.new = options.new ? true : false; + queryObject.remove = options.remove ? true : false; + queryObject.upsert = options.upsert ? true : false; + + if(options.fields) { + queryObject.fields = options.fields; + } + + if(doc && !options.remove) { + queryObject.update = doc; + } + + if(options.maxTimeMS) + queryObject.maxTimeMS = options.maxTimeMS; + + // Either use override on the function, or go back to default on either the collection + // level or db + if(options['serializeFunctions'] != null) { + options['serializeFunctions'] = options['serializeFunctions']; + } else { + options['serializeFunctions'] = self.s.serializeFunctions; + } + + // No check on the documents + options.checkKeys = false; + + // Get the write concern settings + var finalOptions = writeConcern(options, self.s.db, self, options); + + // Decorate the findAndModify command with the write Concern + if(finalOptions.writeConcern) { + queryObject.writeConcern = finalOptions.writeConcern; + } + + // Have we specified bypassDocumentValidation + if(typeof finalOptions.bypassDocumentValidation == 'boolean') { + queryObject.bypassDocumentValidation = finalOptions.bypassDocumentValidation; + } + + // Have we specified collation + decorateWithCollation(queryObject, self, options); + + // Execute the command + self.s.db.command(queryObject + , options, function(err, result) { + if(err) return handleCallback(callback, err, null); + return handleCallback(callback, null, result); + }); +} + +define.classMethod('findAndModify', {callback: true, promise:true}); + +/** + * Find and remove a document. + * @method + * @param {object} query Query object to locate the object to modify. + * @param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated use findOneAndDelete instead + */ +Collection.prototype.findAndRemove = function(query, sort, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + sort = args.length ? args.shift() || [] : []; + options = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return findAndRemove(self, query, sort, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + findAndRemove(self, query, sort, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var findAndRemove = function(self, query, sort, options, callback) { + // Add the remove option + options['remove'] = true; + // Execute the callback + self.findAndModify(query, sort, null, options, callback); +} + +define.classMethod('findAndRemove', {callback: true, promise:true}); + +function decorateWithWriteConcern(command, self, options) { + // Do we support collation 3.4 and higher + var capabilities = self.s.topology.capabilities(); + // Do we support write concerns 3.4 and higher + if(capabilities && capabilities.commandsTakeWriteConcern) { + // Get the write concern settings + var finalOptions = writeConcern(shallowClone(options), self.s.db, self, options); + // Add the write concern to the command + if(finalOptions.writeConcern) { + command.writeConcern = finalOptions.writeConcern; + } + } +} + +function decorateWithCollation(command, self, options) { + // Do we support collation 3.4 and higher + var capabilities = self.s.topology.capabilities(); + // Do we support write concerns 3.4 and higher + if(capabilities && capabilities.commandsTakeCollation) { + if(options.collation && typeof options.collation == 'object') { + command.collation = options.collation; + } + } +} + +/** + * Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2 + * @method + * @param {object} pipeline Array containing all the aggregation framework commands for the execution. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.cursor=null] Return the query as cursor, on 2.6 > it returns as a real cursor on pre 2.6 it returns as an emulated cursor. + * @param {number} [options.cursor.batchSize=null] The batchSize for the cursor + * @param {boolean} [options.explain=false] Explain returns the aggregation execution plan (requires mongodb 2.6 >). + * @param {boolean} [options.allowDiskUse=false] allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 >). + * @param {number} [options.maxTimeMS=null] maxTimeMS specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Collection~resultCallback} callback The command result callback + * @return {(null|AggregationCursor)} + */ +Collection.prototype.aggregate = function(pipeline, options, callback) { + var self = this; + + if(Array.isArray(pipeline)) { + // Set up callback if one is provided + if(typeof options == 'function') { + callback = options; + options = {}; + } + + // If we have no options or callback we are doing + // a cursor based aggregation + if(options == null && callback == null) { + options = {}; + } + } else { + // Aggregation pipeline passed as arguments on the method + var args = Array.prototype.slice.call(arguments, 0); + // Get the callback + callback = args.pop(); + // Get the possible options object + var opts = args[args.length - 1]; + // If it contains any of the admissible options pop it of the args + options = opts && (opts.readPreference + || opts.explain || opts.cursor || opts.out + || opts.maxTimeMS || opts.allowDiskUse) ? args.pop() : {}; + // Left over arguments is the pipeline + pipeline = args; + } + + // Ignore readConcern option + var ignoreReadConcern = false; + + // Build the command + var command = { aggregate : this.s.name, pipeline : pipeline}; + + // If out was specified + if(typeof options.out == 'string') { + pipeline.push({$out: options.out}); + // Ignore read concern + ignoreReadConcern = true; + } else if(pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) { + ignoreReadConcern = true; + } + + // Decorate command with writeConcern if out has been specified + if(pipeline.length > 0 && pipeline[pipeline.length - 1]['$out']) { + decorateWithWriteConcern(command, self, options); + } + + // Have we specified collation + decorateWithCollation(command, self, options); + + // If we have bypassDocumentValidation set + if(typeof options.bypassDocumentValidation == 'boolean') { + command.bypassDocumentValidation = options.bypassDocumentValidation; + } + + // Do we have a readConcern specified + if(!ignoreReadConcern && this.s.readConcern) { + command.readConcern = this.s.readConcern; + } + + // If we have allowDiskUse defined + if(options.allowDiskUse) command.allowDiskUse = options.allowDiskUse; + if(typeof options.maxTimeMS == 'number') command.maxTimeMS = options.maxTimeMS; + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(this, options, this.s.db, this); + + // If explain has been specified add it + if (options.explain) command.explain = options.explain; + + // Validate that cursor options is valid + if(options.cursor != null && typeof options.cursor != 'object') { + throw toError('cursor options must be an object'); + } + + if (this.s.topology.capabilities().hasAggregationCursor) { + options.cursor = options.cursor || { batchSize : 1000 }; + command.cursor = options.cursor; + } + + // promiseLibrary + options.promiseLibrary = this.s.promiseLibrary; + + // Set the AggregationCursor constructor + options.cursorFactory = AggregationCursor; + if(typeof callback != 'function') { + if(!this.s.topology.capabilities()) { + throw new MongoError('cannot connect to server'); + } + + // Allow disk usage command + if(typeof options.allowDiskUse == 'boolean') command.allowDiskUse = options.allowDiskUse; + if(typeof options.maxTimeMS == 'number') command.maxTimeMS = options.maxTimeMS; + + // Execute the cursor + return this.s.topology.cursor(this.s.namespace, command, options); + } + + if (options.cursor) { + var cursor = this.s.topology.cursor(this.s.namespace, command, options); + return cursor.toArray(function(err, result) { + if (err) { + return handleCallback(callback, err); + } + + handleCallback(callback, null, result); + }); + } + + // For legacy server versions, we execute the command and format the result + this.s.db.command(command, options, function(err, result) { + if(err) { + handleCallback(callback, err); + } else if(result['err'] || result['errmsg']) { + handleCallback(callback, toError(result)); + } else if(typeof result == 'object' && result['serverPipeline']) { + handleCallback(callback, null, result['serverPipeline']); + } else if(typeof result == 'object' && result['stages']) { + handleCallback(callback, null, result['stages']); + } else { + handleCallback(callback, null, result.result); + } + }); +} + +define.classMethod('aggregate', {callback: true, promise:false}); + +/** + * The callback format for results + * @callback Collection~parallelCollectionScanCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Cursor[]} cursors A list of cursors returned allowing for parallel reading of collection. + */ + +/** + * Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are + * no ordering guarantees for returned results. + * @method + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.batchSize=null] Set the batchSize for the getMoreCommand when iterating over the query results. + * @param {number} [options.numCursors=1] The maximum number of parallel command cursors to return (the number of returned cursors will be in the range 1:numCursors) + * @param {boolean} [options.raw=false] Return all BSON documents as Raw Buffer documents. + * @param {Collection~parallelCollectionScanCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.parallelCollectionScan = function(options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {numCursors: 1}; + // Set number of cursors to 1 + options.numCursors = options.numCursors || 1; + options.batchSize = options.batchSize || 1000; + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(this, options, this.s.db, this); + + // Add a promiseLibrary + options.promiseLibrary = this.s.promiseLibrary; + + // Execute using callback + if(typeof callback == 'function') return parallelCollectionScan(self, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + parallelCollectionScan(self, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var parallelCollectionScan = function(self, options, callback) { + // Create command object + var commandObject = { + parallelCollectionScan: self.s.name + , numCursors: options.numCursors + } + + // Do we have a readConcern specified + if(self.s.readConcern) { + commandObject.readConcern = self.s.readConcern; + } + + // Store the raw value + var raw = options.raw; + delete options['raw']; + + // Execute the command + self.s.db.command(commandObject, options, function(err, result) { + if(err) return handleCallback(callback, err, null); + if(result == null) return handleCallback(callback, new Error("no result returned for parallelCollectionScan"), null); + + var cursors = []; + // Add the raw back to the option + if(raw) options.raw = raw; + // Create command cursors for each item + for(var i = 0; i < result.cursors.length; i++) { + var rawId = result.cursors[i].cursor.id + // Convert cursorId to Long if needed + var cursorId = typeof rawId == 'number' ? Long.fromNumber(rawId) : rawId; + // Add a command cursor + cursors.push(self.s.topology.cursor(self.s.namespace, cursorId, options)); + } + + handleCallback(callback, null, cursors); + }); +} + +define.classMethod('parallelCollectionScan', {callback: true, promise:true}); + +/** + * Execute the geoNear command to search for items in the collection + * + * @method + * @param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order. + * @param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.num=null] Max number of results to return. + * @param {number} [options.minDistance=null] Include results starting at minDistance from a point (2.6 or higher) + * @param {number} [options.maxDistance=null] Include results up to maxDistance from the point. + * @param {number} [options.distanceMultiplier=null] Include a value to multiply the distances with allowing for range conversions. + * @param {object} [options.query=null] Filter the results by a query. + * @param {boolean} [options.spherical=false] Perform query using a spherical model. + * @param {boolean} [options.uniqueDocs=false] The closest location in a document to the center of the search region will always be returned MongoDB > 2.X. + * @param {boolean} [options.includeLocs=false] Include the location data fields in the top level of the results MongoDB > 2.X. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.geoNear = function(x, y, options, callback) { + var self = this; + var point = typeof(x) == 'object' && x + , args = Array.prototype.slice.call(arguments, point?1:2); + + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + // Fetch all commands + options = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return geoNear(self, x, y, point, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + geoNear(self, x, y, point, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var geoNear = function(self, x, y, point, options, callback) { + // Build command object + var commandObject = { + geoNear:self.s.name, + near: point || [x, y] + } + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Exclude readPreference and existing options to prevent user from + // shooting themselves in the foot + var exclude = { + readPreference: true, + geoNear: true, + near: true + }; + + // Filter out any excluded objects + commandObject = decorateCommand(commandObject, options, exclude); + + // Do we have a readConcern specified + if(self.s.readConcern) { + commandObject.readConcern = self.s.readConcern; + } + + // Have we specified collation + decorateWithCollation(commandObject, self, options); + + // Execute the command + self.s.db.command(commandObject, options, function (err, res) { + if(err) return handleCallback(callback, err); + if(res.err || res.errmsg) return handleCallback(callback, toError(res)); + // should we only be returning res.results here? Not sure if the user + // should see the other return information + handleCallback(callback, null, res); + }); +} + +define.classMethod('geoNear', {callback: true, promise:true}); + +/** + * Execute a geo search using a geo haystack index on a collection. + * + * @method + * @param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order. + * @param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {number} [options.maxDistance=null] Include results up to maxDistance from the point. + * @param {object} [options.search=null] Filter the results by a query. + * @param {number} [options.limit=false] Max number of results to return. + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.geoHaystackSearch = function(x, y, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + // Fetch all commands + options = args.length ? args.shift() || {} : {}; + + // Execute using callback + if(typeof callback == 'function') return geoHaystackSearch(self, x, y, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + geoHaystackSearch(self, x, y, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var geoHaystackSearch = function(self, x, y, options, callback) { + // Build command object + var commandObject = { + geoSearch: self.s.name, + near: [x, y] + } + + // Remove read preference from hash if it exists + commandObject = decorateCommand(commandObject, options, {readPreference: true}); + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Do we have a readConcern specified + if(self.s.readConcern) { + commandObject.readConcern = self.s.readConcern; + } + + // Execute the command + self.s.db.command(commandObject, options, function (err, res) { + if(err) return handleCallback(callback, err); + if(res.err || res.errmsg) handleCallback(callback, toError(res)); + // should we only be returning res.results here? Not sure if the user + // should see the other return information + handleCallback(callback, null, res); + }); +} + +define.classMethod('geoHaystackSearch', {callback: true, promise:true}); + +/** + * Group function helper + * @ignore + */ +// var groupFunction = function () { +// var c = db[ns].find(condition); +// var map = new Map(); +// var reduce_function = reduce; +// +// while (c.hasNext()) { +// var obj = c.next(); +// var key = {}; +// +// for (var i = 0, len = keys.length; i < len; ++i) { +// var k = keys[i]; +// key[k] = obj[k]; +// } +// +// var aggObj = map.get(key); +// +// if (aggObj == null) { +// var newObj = Object.extend({}, key); +// aggObj = Object.extend(newObj, initial); +// map.put(key, aggObj); +// } +// +// reduce_function(obj, aggObj); +// } +// +// return { "result": map.values() }; +// }.toString(); +var groupFunction = 'function () {\nvar c = db[ns].find(condition);\nvar map = new Map();\nvar reduce_function = reduce;\n\nwhile (c.hasNext()) {\nvar obj = c.next();\nvar key = {};\n\nfor (var i = 0, len = keys.length; i < len; ++i) {\nvar k = keys[i];\nkey[k] = obj[k];\n}\n\nvar aggObj = map.get(key);\n\nif (aggObj == null) {\nvar newObj = Object.extend({}, key);\naggObj = Object.extend(newObj, initial);\nmap.put(key, aggObj);\n}\n\nreduce_function(obj, aggObj);\n}\n\nreturn { "result": map.values() };\n}'; + +/** + * Run a group command across a collection + * + * @method + * @param {(object|array|function|code)} keys An object, array or function expressing the keys to group by. + * @param {object} condition An optional condition that must be true for a row to be considered. + * @param {object} initial Initial value of the aggregation counter object. + * @param {(function|Code)} reduce The reduce function aggregates (reduces) the objects iterated + * @param {(function|Code)} finalize An optional function to be run on each item in the result set just before the item is returned. + * @param {boolean} command Specify if you wish to run using the internal group command or using eval, default is true. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {Collection~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated MongoDB 3.6 or higher will no longer support the group command. We recommend rewriting using the aggregation framework. + */ +Collection.prototype.group = function(keys, condition, initial, reduce, finalize, command, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 3); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + // Fetch all commands + reduce = args.length ? args.shift() : null; + finalize = args.length ? args.shift() : null; + command = args.length ? args.shift() : null; + options = args.length ? args.shift() || {} : {}; + + // Make sure we are backward compatible + if(!(typeof finalize == 'function')) { + command = finalize; + finalize = null; + } + + if (!Array.isArray(keys) && keys instanceof Object && typeof(keys) !== 'function' && !(keys._bsontype == 'Code')) { + keys = Object.keys(keys); + } + + if(typeof reduce === 'function') { + reduce = reduce.toString(); + } + + if(typeof finalize === 'function') { + finalize = finalize.toString(); + } + + // Set up the command as default + command = command == null ? true : command; + + // Execute using callback + if(typeof callback == 'function') return group(self, keys, condition, initial, reduce, finalize, command, options, callback); + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + group(self, keys, condition, initial, reduce, finalize, command, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var group = function(self, keys, condition, initial, reduce, finalize, command, options, callback) { + // Execute using the command + if(command) { + var reduceFunction = reduce && reduce._bsontype == 'Code' + ? reduce + : new Code(reduce); + + var selector = { + group: { + 'ns': self.s.name + , '$reduce': reduceFunction + , 'cond': condition + , 'initial': initial + , 'out': "inline" + } + }; + + // if finalize is defined + if(finalize != null) selector.group['finalize'] = finalize; + // Set up group selector + if ('function' === typeof keys || (keys && keys._bsontype == 'Code')) { + selector.group.$keyf = keys && keys._bsontype == 'Code' + ? keys + : new Code(keys); + } else { + var hash = {}; + keys.forEach(function (key) { + hash[key] = 1; + }); + selector.group.key = hash; + } + + options = shallowClone(options); + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // Do we have a readConcern specified + if(self.s.readConcern) { + selector.readConcern = self.s.readConcern; + } + + // Have we specified collation + decorateWithCollation(selector, self, options); + + // Execute command + self.s.db.command(selector, options, function(err, result) { + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.retval); + }); + } else { + // Create execution scope + var scope = reduce != null && reduce._bsontype == 'Code' + ? reduce.scope + : {}; + + scope.ns = self.s.name; + scope.keys = keys; + scope.condition = condition; + scope.initial = initial; + + // Pass in the function text to execute within mongodb. + var groupfn = groupFunction.replace(/ reduce;/, reduce.toString() + ';'); + + self.s.db.eval(new Code(groupfn, scope), function (err, results) { + if (err) return handleCallback(callback, err, null); + handleCallback(callback, null, results.result || results); + }); + } +} + +define.classMethod('group', {callback: true, promise:true}); + +/** + * Functions that are passed as scope args must + * be converted to Code instances. + * @ignore + */ +function processScope (scope) { + if(!isObject(scope) || scope._bsontype == 'ObjectID') { + return scope; + } + + var keys = Object.keys(scope); + var i = keys.length; + var key; + var new_scope = {}; + + while (i--) { + key = keys[i]; + if ('function' == typeof scope[key]) { + new_scope[key] = new Code(String(scope[key])); + } else { + new_scope[key] = processScope(scope[key]); + } + } + + return new_scope; +} + +/** + * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection. + * + * @method + * @param {(function|string)} map The mapping function. + * @param {(function|string)} reduce The reduce function. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.out=null] Sets the output target for the map reduce job. *{inline:1} | {replace:'collectionName'} | {merge:'collectionName'} | {reduce:'collectionName'}* + * @param {object} [options.query=null] Query filter object. + * @param {object} [options.sort=null] Sorts the input objects using this key. Useful for optimization, like sorting by the emit key for fewer reduces. + * @param {number} [options.limit=null] Number of objects to return from collection. + * @param {boolean} [options.keeptemp=false] Keep temporary data. + * @param {(function|string)} [options.finalize=null] Finalize function. + * @param {object} [options.scope=null] Can pass in variables that can be access from map/reduce/finalize. + * @param {boolean} [options.jsMode=false] It is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X. + * @param {boolean} [options.verbose=false] Provide statistics on job execution time. + * @param {boolean} [options.bypassDocumentValidation=false] Allow driver to bypass schema validation in MongoDB 3.2 or higher. + * @param {Collection~resultCallback} [callback] The command result callback + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +Collection.prototype.mapReduce = function(map, reduce, options, callback) { + var self = this; + if('function' === typeof options) callback = options, options = {}; + // Out must allways be defined (make sure we don't break weirdly on pre 1.8+ servers) + if(null == options.out) { + throw new Error("the out option parameter must be defined, see mongodb docs for possible values"); + } + + if('function' === typeof map) { + map = map.toString(); + } + + if('function' === typeof reduce) { + reduce = reduce.toString(); + } + + if('function' === typeof options.finalize) { + options.finalize = options.finalize.toString(); + } + + // Execute using callback + if(typeof callback == 'function') return mapReduce(self, map, reduce, options, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + mapReduce(self, map, reduce, options, function(err, r, r1) { + if(err) return reject(err); + if(!r1) return resolve(r); + resolve({results: r, stats: r1}); + }); + }); +} + +var mapReduce = function(self, map, reduce, options, callback) { + var mapCommandHash = { + mapreduce: self.s.name + , map: map + , reduce: reduce + }; + + // Exclusion list + var exclusionList = ['readPreference']; + + // Add any other options passed in + for(var n in options) { + if('scope' == n) { + mapCommandHash[n] = processScope(options[n]); + } else { + // Only include if not in exclusion list + if(exclusionList.indexOf(n) == -1) { + mapCommandHash[n] = options[n]; + } + } + } + + options = shallowClone(options); + + // Ensure we have the right read preference inheritance + options = getReadPreference(self, options, self.s.db, self); + + // If we have a read preference and inline is not set as output fail hard + if((options.readPreference != false && options.readPreference != 'primary') + && options['out'] && (options['out'].inline != 1 && options['out'] != 'inline')) { + // Force readPreference to primary + options.readPreference = 'primary'; + // Decorate command with writeConcern if supported + decorateWithWriteConcern(mapCommandHash, self, options); + } else if(self.s.readConcern) { + mapCommandHash.readConcern = self.s.readConcern; + } + + // Is bypassDocumentValidation specified + if(typeof options.bypassDocumentValidation == 'boolean') { + mapCommandHash.bypassDocumentValidation = options.bypassDocumentValidation; + } + + // Have we specified collation + decorateWithCollation(mapCommandHash, self, options); + + // Execute command + self.s.db.command(mapCommandHash, {readPreference:options.readPreference}, function (err, result) { + if(err) return handleCallback(callback, err); + // Check if we have an error + if(1 != result.ok || result.err || result.errmsg) { + return handleCallback(callback, toError(result)); + } + + // Create statistics value + var stats = {}; + if(result.timeMillis) stats['processtime'] = result.timeMillis; + if(result.counts) stats['counts'] = result.counts; + if(result.timing) stats['timing'] = result.timing; + + // invoked with inline? + if(result.results) { + // If we wish for no verbosity + if(options['verbose'] == null || !options['verbose']) { + return handleCallback(callback, null, result.results); + } + + return handleCallback(callback, null, result.results, stats); + } + + // The returned collection + var collection = null; + + // If we have an object it's a different db + if(result.result != null && typeof result.result == 'object') { + var doc = result.result; + collection = self.s.db.db(doc.db).collection(doc.collection); + } else { + // Create a collection object that wraps the result collection + collection = self.s.db.collection(result.result) + } + + // If we wish for no verbosity + if(options['verbose'] == null || !options['verbose']) { + return handleCallback(callback, err, collection); + } + + // Return stats as third set of values + handleCallback(callback, err, collection, stats); + }); +} + +define.classMethod('mapReduce', {callback: true, promise:true}); + +/** + * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @return {UnorderedBulkOperation} + */ +Collection.prototype.initializeUnorderedBulkOp = function(options) { + options = options || {}; + options.promiseLibrary = this.s.promiseLibrary; + return unordered(this.s.topology, this, options); +} + +define.classMethod('initializeUnorderedBulkOp', {callback: false, promise:false, returns: [ordered.UnorderedBulkOperation]}); + +/** + * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {OrderedBulkOperation} callback The command result callback + * @return {null} + */ +Collection.prototype.initializeOrderedBulkOp = function(options) { + options = options || {}; + options.promiseLibrary = this.s.promiseLibrary; + return ordered(this.s.topology, this, options); +} + +define.classMethod('initializeOrderedBulkOp', {callback: false, promise:false, returns: [ordered.OrderedBulkOperation]}); + +// Get write concern +var writeConcern = function(target, db, col, options) { + if(options.w != null || options.j != null || options.fsync != null) { + var opts = {}; + if(options.w != null) opts.w = options.w; + if(options.wtimeout != null) opts.wtimeout = options.wtimeout; + if(options.j != null) opts.j = options.j; + if(options.fsync != null) opts.fsync = options.fsync; + target.writeConcern = opts; + } else if(col.writeConcern.w != null || col.writeConcern.j != null || col.writeConcern.fsync != null) { + target.writeConcern = col.writeConcern; + } else if(db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null) { + target.writeConcern = db.writeConcern; + } + + return target +} + +// Figure out the read preference +var getReadPreference = function(self, options, db) { + var r = null + if(options.readPreference) { + r = options.readPreference + } else if(self.s.readPreference) { + r = self.s.readPreference + } else if(db.s.readPreference) { + r = db.s.readPreference; + } + + if(r instanceof ReadPreference) { + options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } else if(typeof r == 'string') { + options.readPreference = new CoreReadPreference(r); + } else if(r && !(r instanceof ReadPreference) && typeof r == 'object') { + var mode = r.mode || r.preference; + if (mode && typeof mode == 'string') { + options.readPreference = new CoreReadPreference(mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } + } + + return options; +} + +var testForFields = { + limit: 1, sort: 1, fields:1, skip: 1, hint: 1, explain: 1, snapshot: 1, timeout: 1, tailable: 1, tailableRetryInterval: 1 + , numberOfRetries: 1, awaitdata: 1, awaitData: 1, exhaust: 1, batchSize: 1, returnKey: 1, maxScan: 1, min: 1, max: 1, showDiskLoc: 1 + , comment: 1, raw: 1, readPreference: 1, partial: 1, read: 1, dbName: 1, oplogReplay: 1, connection: 1, maxTimeMS: 1, transforms: 1 + , collation: 1 + , noCursorTimeout: 1 +} + +module.exports = Collection; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js b/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js new file mode 100644 index 0000000..a29d1fc --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js @@ -0,0 +1,320 @@ +"use strict"; + +var inherits = require('util').inherits + , ReadPreference = require('./read_preference') + , MongoError = require('mongodb-core').MongoError + , Readable = require('stream').Readable || require('readable-stream').Readable + , Define = require('./metadata') + , CoreCursor = require('./cursor') + , CoreReadPreference = require('mongodb-core').ReadPreference; + +/** + * @fileOverview The **CommandCursor** class is an internal class that embodies a + * generalized cursor based on a MongoDB command allowing for iteration over the + * results returned. It supports one by one document iteration, conversion to an + * array or can be iterated as a Node 0.10.X or higher stream + * + * **CommandCursor Cannot directly be instantiated** + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Create a collection we want to drop later + * var col = db.collection('listCollectionsExample1'); + * // Insert a bunch of documents + * col.insert([{a:1, b:1} + * , {a:2, b:2}, {a:3, b:3} + * , {a:4, b:4}], {w:1}, function(err, result) { + * test.equal(null, err); + * + * // List the database collections available + * db.listCollections().toArray(function(err, items) { + * test.equal(null, err); + * db.close(); + * }); + * }); + * }); + */ + +/** + * Namespace provided by the browser. + * @external Readable + */ + +/** + * Creates a new Command Cursor instance (INTERNAL TYPE, do not instantiate directly) + * @class CommandCursor + * @extends external:Readable + * @fires CommandCursor#data + * @fires CommandCursor#end + * @fires CommandCursor#close + * @fires CommandCursor#readable + * @return {CommandCursor} an CommandCursor instance. + */ +var CommandCursor = function(bson, ns, cmd, options, topology, topologyOptions) { + CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0)); + var state = CommandCursor.INIT; + var streamOptions = {}; + + // MaxTimeMS + var maxTimeMS = null; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Set up + Readable.call(this, {objectMode: true}); + + // Internal state + this.s = { + // MaxTimeMS + maxTimeMS: maxTimeMS + // State + , state: state + // Stream options + , streamOptions: streamOptions + // BSON + , bson: bson + // Namespace + , ns: ns + // Command + , cmd: cmd + // Options + , options: options + // Topology + , topology: topology + // Topology Options + , topologyOptions: topologyOptions + // Promise library + , promiseLibrary: promiseLibrary + } +} + +/** + * CommandCursor stream data event, fired for each document in the cursor. + * + * @event CommandCursor#data + * @type {object} + */ + +/** + * CommandCursor stream end event + * + * @event CommandCursor#end + * @type {null} + */ + +/** + * CommandCursor stream close event + * + * @event CommandCursor#close + * @type {null} + */ + +/** + * CommandCursor stream readable event + * + * @event CommandCursor#readable + * @type {null} + */ + +// Inherit from Readable +inherits(CommandCursor, Readable); + +// Set the methods to inherit from prototype +var methodsToInherit = ['_next', 'next', 'hasNext', 'each', 'forEach', 'toArray' + , 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill', 'setCursorBatchSize' + , '_find', '_getmore', '_killcursor', 'isDead', 'explain', 'isNotified', 'isKilled']; + +// Only inherit the types we need +for(var i = 0; i < methodsToInherit.length; i++) { + CommandCursor.prototype[methodsToInherit[i]] = CoreCursor.prototype[methodsToInherit[i]]; +} + +var define = CommandCursor.define = new Define('CommandCursor', CommandCursor, true); + +/** + * Set the ReadPreference for the cursor. + * @method + * @param {(string|ReadPreference)} readPreference The new read preference for the cursor. + * @throws {MongoError} + * @return {Cursor} + */ +CommandCursor.prototype.setReadPreference = function(r) { + if(this.s.state == CommandCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(this.s.state != CommandCursor.INIT) throw MongoError.create({message: 'cannot change cursor readPreference after cursor has been accessed', driver:true}); + + if(r instanceof ReadPreference) { + this.s.options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } else if(typeof r == 'string') { + this.s.options.readPreference = new CoreReadPreference(r); + } else if(r instanceof CoreReadPreference) { + this.s.options.readPreference = r; + } + + return this; +} + +define.classMethod('setReadPreference', {callback: false, promise:false, returns: [CommandCursor]}); + +/** + * Set the batch size for the cursor. + * @method + * @param {number} value The batchSize for the cursor. + * @throws {MongoError} + * @return {CommandCursor} + */ +CommandCursor.prototype.batchSize = function(value) { + if(this.s.state == CommandCursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true}); + if(this.s.cmd.cursor) this.s.cmd.cursor.batchSize = value; + this.setCursorBatchSize(value); + return this; +} + +define.classMethod('batchSize', {callback: false, promise:false, returns: [CommandCursor]}); + +/** + * Add a maxTimeMS stage to the aggregation pipeline + * @method + * @param {number} value The state maxTimeMS value. + * @return {CommandCursor} + */ +CommandCursor.prototype.maxTimeMS = function(value) { + if(this.s.topology.lastIsMaster().minWireVersion > 2) { + this.s.cmd.maxTimeMS = value; + } + return this; +} + +define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [CommandCursor]}); + +CommandCursor.prototype.get = CommandCursor.prototype.toArray; + +define.classMethod('get', {callback: true, promise:false}); + +// Inherited methods +define.classMethod('toArray', {callback: true, promise:true}); +define.classMethod('each', {callback: true, promise:false}); +define.classMethod('forEach', {callback: true, promise:false}); +define.classMethod('next', {callback: true, promise:true}); +define.classMethod('hasNext', {callback: true, promise:true}); +define.classMethod('close', {callback: true, promise:true}); +define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); +define.classMethod('rewind', {callback: false, promise:false}); +define.classMethod('bufferedCount', {callback: false, promise:false, returns: [Number]}); +define.classMethod('readBufferedDocuments', {callback: false, promise:false, returns: [Array]}); + +/** + * Get the next available document from the cursor, returns null if no more documents are available. + * @function CommandCursor.prototype.next + * @param {CommandCursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * Check if there is any document still available in the cursor + * @function CommandCursor.prototype.hasNext + * @param {CommandCursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * The callback format for results + * @callback CommandCursor~toArrayResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object[]} documents All the documents the satisfy the cursor. + */ + +/** + * Returns an array of documents. The caller is responsible for making sure that there + * is enough memory to store the results. Note that the array only contain partial + * results when this cursor had been previously accessed. + * @method CommandCursor.prototype.toArray + * @param {CommandCursor~toArrayResultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ + +/** + * The callback format for results + * @callback CommandCursor~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {(object|null)} result The result object if the command was executed successfully. + */ + +/** + * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, + * not all of the elements will be iterated if this cursor had been previously accessed. + * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike + * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements + * at any given time if batch size is specified. Otherwise, the caller is responsible + * for making sure that the entire result can fit the memory. + * @method CommandCursor.prototype.each + * @param {CommandCursor~resultCallback} callback The result callback. + * @throws {MongoError} + * @return {null} + */ + +/** + * Close the cursor, sending a KillCursor command and emitting close. + * @method CommandCursor.prototype.close + * @param {CommandCursor~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ + +/** + * Is the cursor closed + * @method CommandCursor.prototype.isClosed + * @return {boolean} + */ + +/** + * Clone the cursor + * @function CommandCursor.prototype.clone + * @return {CommandCursor} + */ + +/** + * Resets the cursor + * @function CommandCursor.prototype.rewind + * @return {CommandCursor} + */ + +/** + * The callback format for the forEach iterator method + * @callback CommandCursor~iteratorCallback + * @param {Object} doc An emitted document for the iterator + */ + +/** + * The callback error format for the forEach iterator method + * @callback CommandCursor~endCallback + * @param {MongoError} error An error instance representing the error during the execution. + */ + +/* + * Iterates over all the documents for this cursor using the iterator, callback pattern. + * @method CommandCursor.prototype.forEach + * @param {CommandCursor~iteratorCallback} iterator The iteration callback. + * @param {CommandCursor~endCallback} callback The end callback. + * @throws {MongoError} + * @return {null} + */ + +CommandCursor.INIT = 0; +CommandCursor.OPEN = 1; +CommandCursor.CLOSED = 2; + +module.exports = CommandCursor; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/cursor.js b/node_modules/mongoose/node_modules/mongodb/lib/cursor.js new file mode 100644 index 0000000..9a9bd4d --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/cursor.js @@ -0,0 +1,1208 @@ +"use strict"; + +var inherits = require('util').inherits + , f = require('util').format + , formattedOrderClause = require('./utils').formattedOrderClause + , handleCallback = require('./utils').handleCallback + , ReadPreference = require('./read_preference') + , MongoError = require('mongodb-core').MongoError + , Readable = require('stream').Readable || require('readable-stream').Readable + , Define = require('./metadata') + , CoreCursor = require('mongodb-core').Cursor + , Map = require('mongodb-core').BSON.Map + , CoreReadPreference = require('mongodb-core').ReadPreference; + +/** + * @fileOverview The **Cursor** class is an internal class that embodies a cursor on MongoDB + * allowing for iteration over the results returned from the underlying query. It supports + * one by one document iteration, conversion to an array or can be iterated as a Node 0.10.X + * or higher stream + * + * **CURSORS Cannot directly be instantiated** + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Create a collection we want to drop later + * var col = db.collection('createIndexExample1'); + * // Insert a bunch of documents + * col.insert([{a:1, b:1} + * , {a:2, b:2}, {a:3, b:3} + * , {a:4, b:4}], {w:1}, function(err, result) { + * test.equal(null, err); + * + * // Show that duplicate records got dropped + * col.find({}).toArray(function(err, items) { + * test.equal(null, err); + * test.equal(4, items.length); + * db.close(); + * }); + * }); + * }); + */ + +/** + * Namespace provided by the mongodb-core and node.js + * @external CoreCursor + * @external Readable + */ + +// Flags allowed for cursor +var flags = ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'exhaust', 'partial']; +var fields = ['numberOfRetries', 'tailableRetryInterval']; +var push = Array.prototype.push; + +/** + * Creates a new Cursor instance (INTERNAL TYPE, do not instantiate directly) + * @class Cursor + * @extends external:CoreCursor + * @extends external:Readable + * @property {string} sortValue Cursor query sort setting. + * @property {boolean} timeout Is Cursor able to time out. + * @property {ReadPreference} readPreference Get cursor ReadPreference. + * @fires Cursor#data + * @fires Cursor#end + * @fires Cursor#close + * @fires Cursor#readable + * @return {Cursor} a Cursor instance. + * @example + * Cursor cursor options. + * + * collection.find({}).project({a:1}) // Create a projection of field a + * collection.find({}).skip(1).limit(10) // Skip 1 and limit 10 + * collection.find({}).batchSize(5) // Set batchSize on cursor to 5 + * collection.find({}).filter({a:1}) // Set query on the cursor + * collection.find({}).comment('add a comment') // Add a comment to the query, allowing to correlate queries + * collection.find({}).addCursorFlag('tailable', true) // Set cursor as tailable + * collection.find({}).addCursorFlag('oplogReplay', true) // Set cursor as oplogReplay + * collection.find({}).addCursorFlag('noCursorTimeout', true) // Set cursor as noCursorTimeout + * collection.find({}).addCursorFlag('awaitData', true) // Set cursor as awaitData + * collection.find({}).addCursorFlag('partial', true) // Set cursor as partial + * collection.find({}).addQueryModifier('$orderby', {a:1}) // Set $orderby {a:1} + * collection.find({}).max(10) // Set the cursor maxScan + * collection.find({}).maxScan(10) // Set the cursor maxScan + * collection.find({}).maxTimeMS(1000) // Set the cursor maxTimeMS + * collection.find({}).min(100) // Set the cursor min + * collection.find({}).returnKey(10) // Set the cursor returnKey + * collection.find({}).setReadPreference(ReadPreference.PRIMARY) // Set the cursor readPreference + * collection.find({}).showRecordId(true) // Set the cursor showRecordId + * collection.find({}).snapshot(true) // Set the cursor snapshot + * collection.find({}).sort([['a', 1]]) // Sets the sort order of the cursor query + * collection.find({}).hint('a_1') // Set the cursor hint + * + * All options are chainable, so one can do the following. + * + * collection.find({}).maxTimeMS(1000).maxScan(100).skip(1).toArray(..) + */ +var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) { + CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0)); + var self = this; + var state = Cursor.INIT; + var streamOptions = {}; + + // Tailable cursor options + var numberOfRetries = options.numberOfRetries || 5; + var tailableRetryInterval = options.tailableRetryInterval || 500; + var currentNumberOfRetries = numberOfRetries; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Set up + Readable.call(this, {objectMode: true}); + + // Internal cursor state + this.s = { + // Tailable cursor options + numberOfRetries: numberOfRetries + , tailableRetryInterval: tailableRetryInterval + , currentNumberOfRetries: currentNumberOfRetries + // State + , state: state + // Stream options + , streamOptions: streamOptions + // BSON + , bson: bson + // Namespace + , ns: ns + // Command + , cmd: cmd + // Options + , options: options + // Topology + , topology: topology + // Topology options + , topologyOptions: topologyOptions + // Promise library + , promiseLibrary: promiseLibrary + // Current doc + , currentDoc: null + } + + // Translate correctly + if(self.s.options.noCursorTimeout == true) { + self.addCursorFlag('noCursorTimeout', true); + } + + // Set the sort value + this.sortValue = self.s.cmd.sort; + + // Get the batchSize + var batchSize = cmd.cursor && cmd.cursor.batchSize + ? cmd.cursor && cmd.cursor.batchSize + : (options.cursor && options.cursor.batchSize ? options.cursor.batchSize : 1000); + + // Set the batchSize + this.setCursorBatchSize(batchSize); +} + +/** + * Cursor stream data event, fired for each document in the cursor. + * + * @event Cursor#data + * @type {object} + */ + +/** + * Cursor stream end event + * + * @event Cursor#end + * @type {null} + */ + +/** + * Cursor stream close event + * + * @event Cursor#close + * @type {null} + */ + +/** + * Cursor stream readable event + * + * @event Cursor#readable + * @type {null} + */ + +// Inherit from Readable +inherits(Cursor, Readable); + +// Map core cursor _next method so we can apply mapping +CoreCursor.prototype._next = CoreCursor.prototype.next; + +for(var name in CoreCursor.prototype) { + Cursor.prototype[name] = CoreCursor.prototype[name]; +} + +var define = Cursor.define = new Define('Cursor', Cursor, true); + +/** + * Check if there is any document still available in the cursor + * @method + * @param {Cursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.hasNext = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') { + if(self.s.currentDoc){ + return callback(null, true); + } else { + return nextObject(self, function(err, doc) { + if (err) return callback(err, null); + if (!doc) return callback(null, false); + self.s.currentDoc = doc; + callback(null, true); + }); + } + } + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + if(self.s.currentDoc){ + resolve(true); + } else { + nextObject(self, function(err, doc) { + if(self.s.state == Cursor.CLOSED || self.isDead()) return resolve(false); + if(err) return reject(err); + if(!doc) return resolve(false); + self.s.currentDoc = doc; + resolve(true); + }); + } + }); +} + +define.classMethod('hasNext', {callback: true, promise:true}); + +/** + * Get the next available document from the cursor, returns null if no more documents are available. + * @method + * @param {Cursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.next = function(callback) { + var self = this; + + // Execute using callback + if(typeof callback == 'function') { + // Return the currentDoc if someone called hasNext first + if(self.s.currentDoc) { + var doc = self.s.currentDoc; + self.s.currentDoc = null; + return callback(null, doc); + } + + // Return the next object + return nextObject(self, callback) + } + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + // Return the currentDoc if someone called hasNext first + if(self.s.currentDoc) { + var doc = self.s.currentDoc; + self.s.currentDoc = null; + return resolve(doc); + } + + nextObject(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('next', {callback: true, promise:true}); + +/** + * Set the cursor query + * @method + * @param {object} filter The filter object used for the cursor. + * @return {Cursor} + */ +Cursor.prototype.filter = function(filter) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.query = filter; + return this; +} + +define.classMethod('filter', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor maxScan + * @method + * @param {object} maxScan Constrains the query to only scan the specified number of documents when fulfilling the query + * @return {Cursor} + */ +Cursor.prototype.maxScan = function(maxScan) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.maxScan = maxScan; + return this; +} + +define.classMethod('maxScan', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor hint + * @method + * @param {object} hint If specified, then the query system will only consider plans using the hinted index. + * @return {Cursor} + */ +Cursor.prototype.hint = function(hint) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.hint = hint; + return this; +} + +define.classMethod('hint', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor min + * @method + * @param {object} min Specify a $min value to specify the inclusive lower bound for a specific index in order to constrain the results of find(). The $min specifies the lower bound for all keys of a specific index in order. + * @return {Cursor} + */ +Cursor.prototype.min = function(min) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.min = min; + return this; +} + +define.classMethod('min', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor max + * @method + * @param {object} max Specify a $max value to specify the exclusive upper bound for a specific index in order to constrain the results of find(). The $max specifies the upper bound for all keys of a specific index in order. + * @return {Cursor} + */ +Cursor.prototype.max = function(max) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.max = max; + return this; +} + +define.classMethod('max', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor returnKey + * @method + * @param {object} returnKey Only return the index field or fields for the results of the query. If $returnKey is set to true and the query does not use an index to perform the read operation, the returned documents will not contain any fields. Use one of the following forms: + * @return {Cursor} + */ +Cursor.prototype.returnKey = function(value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.returnKey = value; + return this; +} + +define.classMethod('returnKey', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor showRecordId + * @method + * @param {object} showRecordId The $showDiskLoc option has now been deprecated and replaced with the showRecordId field. $showDiskLoc will still be accepted for OP_QUERY stye find. + * @return {Cursor} + */ +Cursor.prototype.showRecordId = function(value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.showDiskLoc = value; + return this; +} + +define.classMethod('showRecordId', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the cursor snapshot + * @method + * @param {object} snapshot The $snapshot operator prevents the cursor from returning a document more than once because an intervening write operation results in a move of the document. + * @return {Cursor} + */ +Cursor.prototype.snapshot = function(value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.snapshot = value; + return this; +} + +define.classMethod('snapshot', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set a node.js specific cursor option + * @method + * @param {string} field The cursor option to set ['numberOfRetries', 'tailableRetryInterval']. + * @param {object} value The field value. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.setCursorOption = function(field, value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(fields.indexOf(field) == -1) throw MongoError.create({message: f("option %s not a supported option %s", field, fields), driver:true }); + this.s[field] = value; + if(field == 'numberOfRetries') + this.s.currentNumberOfRetries = value; + return this; +} + +define.classMethod('setCursorOption', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Add a cursor flag to the cursor + * @method + * @param {string} flag The flag to set, must be one of following ['tailable', 'oplogReplay', 'noCursorTimeout', 'awaitData', 'partial']. + * @param {boolean} value The flag boolean value. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.addCursorFlag = function(flag, value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(flags.indexOf(flag) == -1) throw MongoError.create({message: f("flag %s not a supported flag %s", flag, flags), driver:true }); + if(typeof value != 'boolean') throw MongoError.create({message: f("flag %s must be a boolean value", flag), driver:true}); + this.s.cmd[flag] = value; + return this; +} + +define.classMethod('addCursorFlag', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Add a query modifier to the cursor query + * @method + * @param {string} name The query modifier (must start with $, such as $orderby etc) + * @param {boolean} value The flag boolean value. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.addQueryModifier = function(name, value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(name[0] != '$') throw MongoError.create({message: f("%s is not a valid query modifier"), driver:true}); + // Strip of the $ + var field = name.substr(1); + // Set on the command + this.s.cmd[field] = value; + // Deal with the special case for sort + if(field == 'orderby') this.s.cmd.sort = this.s.cmd[field]; + return this; +} + +define.classMethod('addQueryModifier', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Add a comment to the cursor query allowing for tracking the comment in the log. + * @method + * @param {string} value The comment attached to this query. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.comment = function(value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.comment = value; + return this; +} + +define.classMethod('comment', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise) + * @method + * @param {number} value Number of milliseconds to wait before aborting the tailed query. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.maxAwaitTimeMS = function(value) { + if(typeof value != 'number') throw MongoError.create({message: "maxAwaitTimeMS must be a number", driver:true}); + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.maxAwaitTimeMS = value; + return this; +} + +define.classMethod('maxAwaitTimeMS', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set a maxTimeMS on the cursor query, allowing for hard timeout limits on queries (Only supported on MongoDB 2.6 or higher) + * @method + * @param {number} value Number of milliseconds to wait before aborting the query. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.maxTimeMS = function(value) { + if(typeof value != 'number') throw MongoError.create({message: "maxTimeMS must be a number", driver:true}); + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.maxTimeMS = value; + return this; +} + +define.classMethod('maxTimeMS', {callback: false, promise:false, returns: [Cursor]}); + +Cursor.prototype.maxTimeMs = Cursor.prototype.maxTimeMS; + +define.classMethod('maxTimeMs', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Sets a field projection for the query. + * @method + * @param {object} value The field projection object. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.project = function(value) { + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + this.s.cmd.fields = value; + return this; +} + +define.classMethod('project', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Sets the sort order of the cursor query. + * @method + * @param {(string|array|object)} keyOrList The key or keys set for the sort. + * @param {number} [direction] The direction of the sorting (1 or -1). + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.sort = function(keyOrList, direction) { + if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support sorting", driver:true}); + if(this.s.state == Cursor.CLOSED || this.s.state == Cursor.OPEN || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + var order = keyOrList; + + // We have an array of arrays, we need to preserve the order of the sort + // so we will us a Map + if(Array.isArray(order) && Array.isArray(order[0])) { + order = new Map(order.map(function(x) { + var value = [x[0], null]; + if(x[1] == 'asc') { + value[1] = 1; + } else if(x[1] == 'desc') { + value[1] = -1; + } else if(x[1] == 1 || x[1] == -1) { + value[1] = x[1]; + } else { + throw new MongoError("Illegal sort clause, must be of the form [['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]"); + } + + return value; + })); + } + + if(direction != null) { + order = [[keyOrList, direction]]; + } + + this.s.cmd.sort = order; + this.sortValue = order; + return this; +} + +define.classMethod('sort', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the batch size for the cursor. + * @method + * @param {number} value The batchSize for the cursor. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.batchSize = function(value) { + if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support batchSize", driver:true}); + if(this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(typeof value != 'number') throw MongoError.create({message: "batchSize requires an integer", driver:true}); + this.s.cmd.batchSize = value; + this.setCursorBatchSize(value); + return this; +} + +define.classMethod('batchSize', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the collation options for the cursor. + * @method + * @param {object} value The cursor collation options (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.collation = function(value) { + this.s.cmd.collation = value; + return this; +} + +define.classMethod('collation', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the limit for the cursor. + * @method + * @param {number} value The limit for the cursor query. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.limit = function(value) { + if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support limit", driver:true}); + if(this.s.state == Cursor.OPEN || this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(typeof value != 'number') throw MongoError.create({message: "limit requires an integer", driver:true}); + this.s.cmd.limit = value; + // this.cursorLimit = value; + this.setCursorLimit(value); + return this; +} + +define.classMethod('limit', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Set the skip for the cursor. + * @method + * @param {number} value The skip for the cursor query. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.skip = function(value) { + if(this.s.options.tailable) throw MongoError.create({message: "Tailable cursor doesn't support skip", driver:true}); + if(this.s.state == Cursor.OPEN || this.s.state == Cursor.CLOSED || this.isDead()) throw MongoError.create({message: "Cursor is closed", driver:true}); + if(typeof value != 'number') throw MongoError.create({message: "skip requires an integer", driver:true}); + this.s.cmd.skip = value; + this.setCursorSkip(value); + return this; +} + +define.classMethod('skip', {callback: false, promise:false, returns: [Cursor]}); + +/** + * The callback format for results + * @callback Cursor~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {(object|null|boolean)} result The result object if the command was executed successfully. + */ + +/** + * Clone the cursor + * @function external:CoreCursor#clone + * @return {Cursor} + */ + +/** + * Resets the cursor + * @function external:CoreCursor#rewind + * @return {null} + */ + +/** + * Get the next available document from the cursor, returns null if no more documents are available. + * @method + * @param {Cursor~resultCallback} [callback] The result callback. + * @throws {MongoError} + * @deprecated + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.nextObject = Cursor.prototype.next; + +var nextObject = function(self, callback) { + if(self.s.state == Cursor.CLOSED || self.isDead && self.isDead()) return handleCallback(callback, MongoError.create({message: "Cursor is closed", driver:true})); + if(self.s.state == Cursor.INIT && self.s.cmd.sort) { + try { + self.s.cmd.sort = formattedOrderClause(self.s.cmd.sort); + } catch(err) { + return handleCallback(callback, err); + } + } + + // Get the next object + self._next(function(err, doc) { + self.s.state = Cursor.OPEN; + if(err) return handleCallback(callback, err); + handleCallback(callback, null, doc); + }); +} + +define.classMethod('nextObject', {callback: true, promise:true}); + +// Trampoline emptying the number of retrieved items +// without incurring a nextTick operation +var loop = function(self, callback) { + // No more items we are done + if(self.bufferedCount() == 0) return; + // Get the next document + self._next(callback); + // Loop + return loop; +} + +Cursor.prototype.next = Cursor.prototype.nextObject; + +define.classMethod('next', {callback: true, promise:true}); + +/** + * Iterates over all the documents for this cursor. As with **{cursor.toArray}**, + * not all of the elements will be iterated if this cursor had been previously accessed. + * In that case, **{cursor.rewind}** can be used to reset the cursor. However, unlike + * **{cursor.toArray}**, the cursor will only hold a maximum of batch size elements + * at any given time if batch size is specified. Otherwise, the caller is responsible + * for making sure that the entire result can fit the memory. + * @method + * @deprecated + * @param {Cursor~resultCallback} callback The result callback. + * @throws {MongoError} + * @return {null} + */ +Cursor.prototype.each = function(callback) { + // Rewind cursor state + this.rewind(); + // Set current cursor to INIT + this.s.state = Cursor.INIT; + // Run the query + _each(this, callback); +}; + +define.classMethod('each', {callback: true, promise:false}); + +// Run the each loop +var _each = function(self, callback) { + if(!callback) throw MongoError.create({message: 'callback is mandatory', driver:true}); + if(self.isNotified()) return; + if(self.s.state == Cursor.CLOSED || self.isDead()) { + return handleCallback(callback, MongoError.create({message: "Cursor is closed", driver:true})); + } + + if(self.s.state == Cursor.INIT) self.s.state = Cursor.OPEN; + + // Define function to avoid global scope escape + var fn = null; + // Trampoline all the entries + if(self.bufferedCount() > 0) { + while(fn = loop(self, callback)) fn(self, callback); + _each(self, callback); + } else { + self.next(function(err, item) { + if(err) return handleCallback(callback, err); + if(item == null) { + self.s.state = Cursor.CLOSED; + return handleCallback(callback, null, null); + } + + if(handleCallback(callback, null, item) == false) return; + _each(self, callback); + }) + } +} + +/** + * The callback format for the forEach iterator method + * @callback Cursor~iteratorCallback + * @param {Object} doc An emitted document for the iterator + */ + +/** + * The callback error format for the forEach iterator method + * @callback Cursor~endCallback + * @param {MongoError} error An error instance representing the error during the execution. + */ + +/** + * Iterates over all the documents for this cursor using the iterator, callback pattern. + * @method + * @param {Cursor~iteratorCallback} iterator The iteration callback. + * @param {Cursor~endCallback} callback The end callback. + * @throws {MongoError} + * @return {null} + */ +Cursor.prototype.forEach = function(iterator, callback) { + this.each(function(err, doc){ + if(err) { callback(err); return false; } + if(doc != null) { iterator(doc); return true; } + if(doc == null && callback) { + var internalCallback = callback; + callback = null; + internalCallback(null); + return false; + } + }); +} + +define.classMethod('forEach', {callback: true, promise:false}); + +/** + * Set the ReadPreference for the cursor. + * @method + * @param {(string|ReadPreference)} readPreference The new read preference for the cursor. + * @throws {MongoError} + * @return {Cursor} + */ +Cursor.prototype.setReadPreference = function(r) { + if(this.s.state != Cursor.INIT) throw MongoError.create({message: 'cannot change cursor readPreference after cursor has been accessed', driver:true}); + if(r instanceof ReadPreference) { + this.s.options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } else if(typeof r == 'string'){ + this.s.options.readPreference = new CoreReadPreference(r); + } else if(r instanceof CoreReadPreference) { + this.s.options.readPreference = r; + } + + return this; +} + +define.classMethod('setReadPreference', {callback: false, promise:false, returns: [Cursor]}); + +/** + * The callback format for results + * @callback Cursor~toArrayResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object[]} documents All the documents the satisfy the cursor. + */ + +/** + * Returns an array of documents. The caller is responsible for making sure that there + * is enough memory to store the results. Note that the array only contain partial + * results when this cursor had been previously accessed. In that case, + * cursor.rewind() can be used to reset the cursor. + * @method + * @param {Cursor~toArrayResultCallback} [callback] The result callback. + * @throws {MongoError} + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.toArray = function(callback) { + var self = this; + if(self.s.options.tailable) throw MongoError.create({message: 'Tailable cursor cannot be converted to array', driver:true}); + + // Execute using callback + if(typeof callback == 'function') return toArray(self, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + toArray(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +var toArray = function(self, callback) { + var items = []; + + // Reset cursor + self.rewind(); + self.s.state = Cursor.INIT; + + // Fetch all the documents + var fetchDocs = function() { + self._next(function(err, doc) { + if(err) return handleCallback(callback, err); + if(doc == null) { + self.s.state = Cursor.CLOSED; + return handleCallback(callback, null, items); + } + + // Add doc to items + items.push(doc) + + // Get all buffered objects + if(self.bufferedCount() > 0) { + var docs = self.readBufferedDocuments(self.bufferedCount()) + + // Transform the doc if transform method added + if(self.s.transforms && typeof self.s.transforms.doc == 'function') { + docs = docs.map(self.s.transforms.doc); + } + + push.apply(items, docs); + } + + // Attempt a fetch + fetchDocs(); + }) + } + + fetchDocs(); +} + +define.classMethod('toArray', {callback: true, promise:true}); + +/** + * The callback format for results + * @callback Cursor~countResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {number} count The count of documents. + */ + +/** + * Get the count of documents for this cursor + * @method + * @param {boolean} [applySkipLimit=true] Should the count command apply limit and skip settings on the cursor or in the passed in options. + * @param {object} [options=null] Optional settings. + * @param {number} [options.skip=null] The number of documents to skip. + * @param {number} [options.limit=null] The maximum amounts to count before aborting. + * @param {number} [options.maxTimeMS=null] Number of milliseconds to wait before aborting the query. + * @param {string} [options.hint=null] An index name hint for the query. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {Cursor~countResultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.count = function(applySkipLimit, opts, callback) { + var self = this; + if(self.s.cmd.query == null) throw MongoError.create({message: "count can only be used with find command", driver:true}); + if(typeof opts == 'function') callback = opts, opts = {}; + opts = opts || {}; + + // Execute using callback + if(typeof callback == 'function') return count(self, applySkipLimit, opts, callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + count(self, applySkipLimit, opts, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var count = function(self, applySkipLimit, opts, callback) { + if(typeof applySkipLimit == 'function') { + callback = applySkipLimit; + applySkipLimit = true; + } + + if(applySkipLimit) { + if(typeof self.cursorSkip() == 'number') opts.skip = self.cursorSkip(); + if(typeof self.cursorLimit() == 'number') opts.limit = self.cursorLimit(); + } + + // Command + var delimiter = self.s.ns.indexOf('.'); + + var command = { + 'count': self.s.ns.substr(delimiter+1), 'query': self.s.cmd.query + } + + // Apply a readConcern if set + if(self.s.cmd.readConcern) { + command.readConcern = self.s.cmd.readConcern; + } + + // Apply a hint if set + if(self.s.cmd.hint) { + command.hint = self.s.cmd.hint; + } + + if(typeof opts.maxTimeMS == 'number') { + command.maxTimeMS = opts.maxTimeMS; + } else if(self.s.cmd && typeof self.s.cmd.maxTimeMS == 'number') { + command.maxTimeMS = self.s.cmd.maxTimeMS; + } + + // Merge in any options + if(opts.skip) command.skip = opts.skip; + if(opts.limit) command.limit = opts.limit; + if(self.s.options.hint) command.hint = self.s.options.hint; + + // Set cursor server to the same as the topology + self.server = self.topology; + + // Execute the command + self.topology.command(f("%s.$cmd", self.s.ns.substr(0, delimiter)) + , command, function(err, result) { + callback(err, result ? result.result.n : null) + }, self.options); +} + +define.classMethod('count', {callback: true, promise:true}); + +/** + * Close the cursor, sending a KillCursor command and emitting close. + * @method + * @param {Cursor~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.close = function(callback) { + this.s.state = Cursor.CLOSED; + // Kill the cursor + this.kill(); + // Emit the close event for the cursor + this.emit('close'); + // Callback if provided + if(typeof callback == 'function') return handleCallback(callback, null, this); + // Return a Promise + return new this.s.promiseLibrary(function(resolve) { + resolve(); + }); +} + +define.classMethod('close', {callback: true, promise:true}); + +/** + * Map all documents using the provided function + * @method + * @param {function} [transform] The mapping transformation method. + * @return {Cursor} + */ +Cursor.prototype.map = function(transform) { + if(this.cursorState.transforms && this.cursorState.transforms.doc) { + var oldTransform = this.cursorState.transforms.doc; + this.cursorState.transforms.doc = function (doc) { return transform(oldTransform(doc)); }; + } else { + this.cursorState.transforms = { doc: transform }; + } + return this; +} + +define.classMethod('map', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Is the cursor closed + * @method + * @return {boolean} + */ +Cursor.prototype.isClosed = function() { + return this.isDead(); +} + +define.classMethod('isClosed', {callback: false, promise:false, returns: [Boolean]}); + +Cursor.prototype.destroy = function(err) { + if(err) this.emit('error', err); + this.pause(); + this.close(); +} + +define.classMethod('destroy', {callback: false, promise:false}); + +/** + * Return a modified Readable stream including a possible transform method. + * @method + * @param {object} [options=null] Optional settings. + * @param {function} [options.transform=null] A transformation method applied to each document emitted by the stream. + * @return {Cursor} + */ +Cursor.prototype.stream = function(options) { + this.s.streamOptions = options || {}; + return this; +} + +define.classMethod('stream', {callback: false, promise:false, returns: [Cursor]}); + +/** + * Execute the explain for the cursor + * @method + * @param {Cursor~resultCallback} [callback] The result callback. + * @return {Promise} returns Promise if no callback passed + */ +Cursor.prototype.explain = function(callback) { + var self = this; + this.s.cmd.explain = true; + + // Do we have a readConcern + if(this.s.cmd.readConcern) { + delete this.s.cmd['readConcern']; + } + + // Execute using callback + if(typeof callback == 'function') return this._next(callback); + + // Return a Promise + return new this.s.promiseLibrary(function(resolve, reject) { + self._next(function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('explain', {callback: true, promise:true}); + +Cursor.prototype._read = function() { + var self = this; + if(self.s.state == Cursor.CLOSED || self.isDead()) { + return self.push(null); + } + + // Get the next item + self.nextObject(function(err, result) { + if(err) { + if(self.listeners('error') && self.listeners('error').length > 0) { + self.emit('error', err); + } + if(!self.isDead()) self.close(); + + // Emit end event + self.emit('end'); + return self.emit('finish'); + } + + // If we provided a transformation method + if(typeof self.s.streamOptions.transform == 'function' && result != null) { + return self.push(self.s.streamOptions.transform(result)); + } + + // If we provided a map function + if(self.cursorState.transforms && typeof self.cursorState.transforms.doc == 'function' && result != null) { + return self.push(self.cursorState.transforms.doc(result)); + } + + // Return the result + self.push(result); + }); +} + +Object.defineProperty(Cursor.prototype, 'readPreference', { + enumerable:true, + get: function() { + if (!this || !this.s) { + return null; + } + + return this.s.options.readPreference; + } +}); + +Object.defineProperty(Cursor.prototype, 'namespace', { + enumerable: true, + get: function() { + if (!this || !this.s) { + return null; + } + + // TODO: refactor this logic into core + var ns = this.s.ns || ''; + var firstDot = ns.indexOf('.'); + if (firstDot < 0) { + return { + database: this.s.ns, + collection: '' + }; + } + return { + database: ns.substr(0, firstDot), + collection: ns.substr(firstDot + 1) + }; + } +}); + +/** + * The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null. + * @function external:Readable#read + * @param {number} size Optional argument to specify how much data to read. + * @return {(String | Buffer | null)} + */ + +/** + * Call this function to cause the stream to return strings of the specified encoding instead of Buffer objects. + * @function external:Readable#setEncoding + * @param {string} encoding The encoding to use. + * @return {null} + */ + +/** + * This method will cause the readable stream to resume emitting data events. + * @function external:Readable#resume + * @return {null} + */ + +/** + * This method will cause a stream in flowing-mode to stop emitting data events. Any data that becomes available will remain in the internal buffer. + * @function external:Readable#pause + * @return {null} + */ + +/** + * This method pulls all the data out of a readable stream, and writes it to the supplied destination, automatically managing the flow so that the destination is not overwhelmed by a fast readable stream. + * @function external:Readable#pipe + * @param {Writable} destination The destination for writing data + * @param {object} [options] Pipe options + * @return {null} + */ + +/** + * This method will remove the hooks set up for a previous pipe() call. + * @function external:Readable#unpipe + * @param {Writable} [destination] The destination for writing data + * @return {null} + */ + +/** + * This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party. + * @function external:Readable#unshift + * @param {(Buffer|string)} chunk Chunk of data to unshift onto the read queue. + * @return {null} + */ + +/** + * Versions of Node prior to v0.10 had streams that did not implement the entire Streams API as it is today. (See "Compatibility" below for more information.) + * @function external:Readable#wrap + * @param {Stream} stream An "old style" readable stream. + * @return {null} + */ + +Cursor.INIT = 0; +Cursor.OPEN = 1; +Cursor.CLOSED = 2; +Cursor.GET_MORE = 3; + +module.exports = Cursor; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/db.js b/node_modules/mongoose/node_modules/mongodb/lib/db.js new file mode 100644 index 0000000..db878c5 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/db.js @@ -0,0 +1,1805 @@ +"use strict"; + +var EventEmitter = require('events').EventEmitter + , authenticate = require('./authenticate') + , inherits = require('util').inherits + , getSingleProperty = require('./utils').getSingleProperty + , shallowClone = require('./utils').shallowClone + , parseIndexOptions = require('./utils').parseIndexOptions + , debugOptions = require('./utils').debugOptions + , CommandCursor = require('./command_cursor') + , handleCallback = require('./utils').handleCallback + , filterOptions = require('./utils').filterOptions + , toError = require('./utils').toError + , ReadPreference = require('./read_preference') + , f = require('util').format + , Admin = require('./admin') + , Code = require('mongodb-core').BSON.Code + , CoreReadPreference = require('mongodb-core').ReadPreference + , MongoError = require('mongodb-core').MongoError + , ObjectID = require('mongodb-core').ObjectID + , Define = require('./metadata') + , Logger = require('mongodb-core').Logger + , Collection = require('./collection') + , crypto = require('crypto') + , mergeOptionsAndWriteConcern = require('./utils').mergeOptionsAndWriteConcern + , assign = require('./utils').assign; + +var debugFields = ['authSource', 'w', 'wtimeout', 'j', 'native_parser', 'forceServerObjectId' + , 'serializeFunctions', 'raw', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'bufferMaxEntries', 'numberOfRetries', 'retryMiliSeconds' + , 'readPreference', 'pkFactory', 'parentDb', 'promiseLibrary', 'noListener']; + +// Filter out any write concern options +var illegalCommandFields = ['w', 'wtimeout', 'j', 'fsync', 'autoIndexId' + , 'strict', 'serializeFunctions', 'pkFactory', 'raw', 'readPreference']; + +/** + * @fileOverview The **Db** class is a class that represents a MongoDB Database. + * + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Get an additional db + * var testDb = db.db('test'); + * db.close(); + * }); + */ + +// Allowed parameters +var legalOptionNames = ['w', 'wtimeout', 'fsync', 'j', 'readPreference', 'readPreferenceTags', 'native_parser' + , 'forceServerObjectId', 'pkFactory', 'serializeFunctions', 'raw', 'bufferMaxEntries', 'authSource' + , 'ignoreUndefined', 'promoteLongs', 'promiseLibrary', 'readConcern', 'retryMiliSeconds', 'numberOfRetries' + , 'parentDb', 'noListener', 'loggerLevel', 'logger', 'promoteBuffers', 'promoteLongs', 'promoteValues']; + +/** + * Creates a new Db instance + * @class + * @param {string} databaseName The name of the database this instance represents. + * @param {(Server|ReplSet|Mongos)} topology The server topology for the database. + * @param {object} [options=null] Optional settings. + * @param {string} [options.authSource=null] If the database authentication is dependent on another databaseName. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) + * @property {(Server|ReplSet|Mongos)} serverConfig Get the current db topology. + * @property {number} bufferMaxEntries Current bufferMaxEntries value for the database + * @property {string} databaseName The name of the database this instance represents. + * @property {object} options The options associated with the db instance. + * @property {boolean} native_parser The current value of the parameter native_parser. + * @property {boolean} slaveOk The current slaveOk value for the db instance. + * @property {object} writeConcern The current write concern values. + * @property {object} topology Access the topology object (single server, replicaset or mongos). + * @fires Db#close + * @fires Db#authenticated + * @fires Db#reconnect + * @fires Db#error + * @fires Db#timeout + * @fires Db#parseError + * @fires Db#fullsetup + * @return {Db} a Db instance. + */ +var Db = function(databaseName, topology, options) { + options = options || {}; + if(!(this instanceof Db)) return new Db(databaseName, topology, options); + EventEmitter.call(this); + var self = this; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Filter the options + options = filterOptions(options, legalOptionNames); + + // Ensure we put the promiseLib in the options + options.promiseLibrary = promiseLibrary; + + // var self = this; // Internal state of the db object + this.s = { + // Database name + databaseName: databaseName + // DbCache + , dbCache: {} + // Children db's + , children: [] + // Topology + , topology: topology + // Options + , options: options + // Logger instance + , logger: Logger('Db', options) + // Get the bson parser + , bson: topology ? topology.bson : null + // Authsource if any + , authSource: options.authSource + // Unpack read preference + , readPreference: options.readPreference + // Set buffermaxEntries + , bufferMaxEntries: typeof options.bufferMaxEntries == 'number' ? options.bufferMaxEntries : -1 + // Parent db (if chained) + , parentDb: options.parentDb || null + // Set up the primary key factory or fallback to ObjectID + , pkFactory: options.pkFactory || ObjectID + // Get native parser + , nativeParser: options.nativeParser || options.native_parser + // Promise library + , promiseLibrary: promiseLibrary + // No listener + , noListener: typeof options.noListener == 'boolean' ? options.noListener : false + // ReadConcern + , readConcern: options.readConcern + } + + // Ensure we have a valid db name + validateDatabaseName(self.s.databaseName); + + // Add a read Only property + getSingleProperty(this, 'serverConfig', self.s.topology); + getSingleProperty(this, 'bufferMaxEntries', self.s.bufferMaxEntries); + getSingleProperty(this, 'databaseName', self.s.databaseName); + + // This is a child db, do not register any listeners + if(options.parentDb) return; + if(this.s.noListener) return; + + // Add listeners + topology.on('error', createListener(self, 'error', self)); + topology.on('timeout', createListener(self, 'timeout', self)); + topology.on('close', createListener(self, 'close', self)); + topology.on('parseError', createListener(self, 'parseError', self)); + topology.once('open', createListener(self, 'open', self)); + topology.once('fullsetup', createListener(self, 'fullsetup', self)); + topology.once('all', createListener(self, 'all', self)); + topology.on('reconnect', createListener(self, 'reconnect', self)); + topology.on('reconnectFailed', createListener(self, 'reconnectFailed', self)); +} + +inherits(Db, EventEmitter); + +var define = Db.define = new Define('Db', Db, false); + +// Topology +Object.defineProperty(Db.prototype, 'topology', { + enumerable:true, + get: function() { return this.s.topology; } +}); + +// Options +Object.defineProperty(Db.prototype, 'options', { + enumerable:true, + get: function() { return this.s.options; } +}); + +// slaveOk specified +Object.defineProperty(Db.prototype, 'slaveOk', { + enumerable:true, + get: function() { + if(this.s.options.readPreference != null + && (this.s.options.readPreference != 'primary' || this.s.options.readPreference.mode != 'primary')) { + return true; + } + return false; + } +}); + +// get the write Concern +Object.defineProperty(Db.prototype, 'writeConcern', { + enumerable:true, + get: function() { + var ops = {}; + if(this.s.options.w != null) ops.w = this.s.options.w; + if(this.s.options.j != null) ops.j = this.s.options.j; + if(this.s.options.fsync != null) ops.fsync = this.s.options.fsync; + if(this.s.options.wtimeout != null) ops.wtimeout = this.s.options.wtimeout; + return ops; + } +}); + +/** + * The callback format for the Db.open method + * @callback Db~openCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Db} db The Db instance if the open method was successful. + */ + +// Internal method +var open = function(self, callback) { + self.s.topology.connect(self, self.s.options, function(err) { + if(callback == null) return; + var internalCallback = callback; + callback == null; + + if(err) { + self.close(); + return internalCallback(err); + } + + internalCallback(null, self); + }); +} + +/** + * Open the database + * @method + * @param {Db~openCallback} [callback] Callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.open = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return open(self, callback); + // Return promise + return new self.s.promiseLibrary(function(resolve, reject) { + open(self, function(err, db) { + if(err) return reject(err); + resolve(db); + }) + }); +} + +define.classMethod('open', {callback: true, promise:true}); + +/** + * Converts provided read preference to CoreReadPreference + * @param {(ReadPreference|string|object)} readPreference the user provided read preference + * @return {CoreReadPreference} + */ +var convertReadPreference = function(readPreference) { + if(readPreference && typeof readPreference == 'string') { + return new CoreReadPreference(readPreference); + } else if(readPreference instanceof ReadPreference) { + return new CoreReadPreference(readPreference.mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds}); + } else if(readPreference && typeof readPreference == 'object') { + var mode = readPreference.mode || readPreference.preference; + if (mode && typeof mode == 'string') { + readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessSeconds: readPreference.maxStalenessSeconds}); + } + } + return readPreference; +} + +/** + * The callback format for results + * @callback Db~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object} result The result object if the command was executed successfully. + */ + +var executeCommand = function(self, command, options, callback) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + // Get the db name we are executing against + var dbName = options.dbName || options.authdb || self.s.databaseName; + + // If we have a readPreference set + if(options.readPreference == null && self.s.readPreference) { + options.readPreference = self.s.readPreference; + } + + // Convert the readPreference if its not a write + if(options.readPreference) { + options.readPreference = convertReadPreference(options.readPreference); + } else { + options.readPreference = CoreReadPreference.primary; + } + + // Debug information + if(self.s.logger.isDebug()) self.s.logger.debug(f('executing command %s against %s with options [%s]' + , JSON.stringify(command), f('%s.$cmd', dbName), JSON.stringify(debugOptions(debugFields, options)))); + + // Execute command + self.s.topology.command(f('%s.$cmd', dbName), command, options, function(err, result) { + if(err) return handleCallback(callback, err); + if(options.full) return handleCallback(callback, null, result); + handleCallback(callback, null, result.result); + }); +} + +/** + * Execute a command + * @method + * @param {object} command The command hash + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.command = function(command, options, callback) { + var self = this; + // Change the callback + if(typeof options == 'function') callback = options, options = {}; + // Clone the options + options = shallowClone(options); + + // Do we have a callback + if(typeof callback == 'function') return executeCommand(self, command, options, callback); + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + executeCommand(self, command, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('command', {callback: true, promise:true}); + +/** + * The callback format for results + * @callback Db~noResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {null} result Is not set to a value + */ + +/** + * Close the db and its underlying connections + * @method + * @param {boolean} force Force close, emitting no events + * @param {Db~noResultCallback} [callback] The result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.close = function(force, callback) { + if(typeof force == 'function') callback = force, force = false; + this.s.topology.close(force); + var self = this; + + // Fire close event if any listeners + if(this.listeners('close').length > 0) { + this.emit('close'); + + // If it's the top level db emit close on all children + if(this.parentDb == null) { + // Fire close on all children + for(var i = 0; i < this.s.children.length; i++) { + this.s.children[i].emit('close'); + } + } + + // Remove listeners after emit + self.removeAllListeners('close'); + } + + // Close parent db if set + if(this.s.parentDb) this.s.parentDb.close(); + // Callback after next event loop tick + if(typeof callback == 'function') return process.nextTick(function() { + handleCallback(callback, null); + }) + + // Return dummy promise + return new this.s.promiseLibrary(function(resolve) { + resolve(); + }); +} + +define.classMethod('close', {callback: true, promise:true}); + +/** + * Return the Admin db instance + * @method + * @return {Admin} return the new Admin db instance + */ +Db.prototype.admin = function() { + return new Admin(this, this.s.topology, this.s.promiseLibrary); +}; + +define.classMethod('admin', {callback: false, promise:false, returns: [Admin]}); + +/** + * The callback format for the collection method, must be used if strict is specified + * @callback Db~collectionResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection} collection The collection instance. + */ + +var collectionKeys = ['pkFactory', 'readPreference' + , 'serializeFunctions', 'strict', 'readConcern', 'ignoreUndefined', 'promoteValues', 'promoteBuffers', 'promoteLongs']; + +/** + * Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can + * can use it without a callback in the following way: `var collection = db.collection('mycollection');` + * + * @method + * @param {string} name the collection name we wish to access. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.strict=false] Returns an error if the collection does not exist + * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {object} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) + * @param {Db~collectionResultCallback} callback The collection result callback + * @return {Collection} return the new Collection instance if not in strict mode + */ +Db.prototype.collection = function(name, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + options = shallowClone(options); + // Set the promise library + options.promiseLibrary = this.s.promiseLibrary; + + // If we have not set a collection level readConcern set the db level one + options.readConcern = options.readConcern || this.s.readConcern; + + // Do we have ignoreUndefined set + if(this.s.options.ignoreUndefined) { + options.ignoreUndefined = this.s.options.ignoreUndefined; + } + + // Merge in all needed options and ensure correct writeConcern merging from db level + options = mergeOptionsAndWriteConcern(options, this.s.options, collectionKeys, true); + + // Execute + if(options == null || !options.strict) { + try { + var collection = new Collection(this, this.s.topology, this.s.databaseName, name, this.s.pkFactory, options); + if(callback) callback(null, collection); + return collection; + } catch(err) { + // if(err instanceof MongoError && callback) return callback(err); + if(callback) return callback(err); + throw err; + } + } + + // Strict mode + if(typeof callback != 'function') { + throw toError(f("A callback is required in strict mode. While getting collection %s.", name)); + } + + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) { + return callback(new MongoError('topology was destroyed')); + } + + // Strict mode + this.listCollections({name:name}, options).toArray(function(err, collections) { + if(err != null) return handleCallback(callback, err, null); + if(collections.length == 0) return handleCallback(callback, toError(f("Collection %s does not exist. Currently in strict mode.", name)), null); + + try { + return handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); + } catch(err) { + return handleCallback(callback, err, null); + } + }); +} + +define.classMethod('collection', {callback: true, promise:false, returns: [Collection]}); + +function decorateWithWriteConcern(command, self, options) { + // Do we support write concerns 3.4 and higher + if(self.s.topology.capabilities().commandsTakeWriteConcern) { + // Get the write concern settings + var finalOptions = writeConcern(shallowClone(options), self, options); + // Add the write concern to the command + if(finalOptions.writeConcern) { + command.writeConcern = finalOptions.writeConcern; + } + } +} + +var createCollection = function(self, name, options, callback) { + // Get the write concern options + var finalOptions = writeConcern(shallowClone(options), self, options); + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + // Check if we have the name + self.listCollections({name: name}) + .setReadPreference(ReadPreference.PRIMARY) + .toArray(function(err, collections) { + if(err != null) return handleCallback(callback, err, null); + if(collections.length > 0 && finalOptions.strict) { + return handleCallback(callback, MongoError.create({message: f("Collection %s already exists. Currently in strict mode.", name), driver:true}), null); + } else if (collections.length > 0) { + try { return handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); } + catch(err) { return handleCallback(callback, err); } + } + + // Create collection command + var cmd = {'create':name}; + + // Decorate command with writeConcern if supported + decorateWithWriteConcern(cmd, self, options); + // Add all optional parameters + for(var n in options) { + if(options[n] != null + && typeof options[n] != 'function' && illegalCommandFields.indexOf(n) == -1) { + cmd[n] = options[n]; + } + } + + // Force a primary read Preference + finalOptions.readPreference = ReadPreference.PRIMARY; + + // Execute command + self.command(cmd, finalOptions, function(err) { + if(err) return handleCallback(callback, err); + handleCallback(callback, null, new Collection(self, self.s.topology, self.s.databaseName, name, self.s.pkFactory, options)); + }); + }); +} + +/** + * Create a new collection on a server with the specified options. Use this to create capped collections. + * More information about command options available at https://docs.mongodb.com/manual/reference/command/create/ + * + * @method + * @param {string} name the collection name we wish to access. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {boolean} [options.strict=false] Returns an error if the collection does not exist + * @param {boolean} [options.capped=false] Create a capped collection. + * @param {boolean} [options.autoIndexId=true] Create an index on the _id field of the document, True by default on MongoDB 2.2 or higher off for version < 2.2. + * @param {number} [options.size=null] The size of the capped collection in bytes. + * @param {number} [options.max=null] The maximum number of documents in the capped collection. + * @param {number} [options.flags=null] Optional. Available for the MMAPv1 storage engine only to set the usePowerOf2Sizes and the noPadding flag. + * @param {object} [options.storageEngine=null] Allows users to specify configuration to the storage engine on a per-collection basis when creating a collection on MongoDB 3.0 or higher. + * @param {object} [options.validator=null] Allows users to specify validation rules or expressions for the collection. For more information, see Document Validation on MongoDB 3.2 or higher. + * @param {string} [options.validationLevel=null] Determines how strictly MongoDB applies the validation rules to existing documents during an update on MongoDB 3.2 or higher. + * @param {string} [options.validationAction=null] Determines whether to error on invalid documents or just warn about the violations but allow invalid documents to be inserted on MongoDB 3.2 or higher. + * @param {object} [options.indexOptionDefaults=null] Allows users to specify a default configuration for indexes when creating a collection on MongoDB 3.2 or higher. + * @param {string} [options.viewOn=null] The name of the source collection or view from which to create the view. The name is not the full namespace of the collection or view; i.e. does not include the database name and implies the same database as the view to create on MongoDB 3.4 or higher. + * @param {array} [options.pipeline=null] An array that consists of the aggregation pipeline stage. create creates the view by applying the specified pipeline to the viewOn collection or view on MongoDB 3.4 or higher. + * @param {object} [options.collation=null] Specify collation (MongoDB 3.4 or higher) settings for update operation (see 3.4 documentation for available fields). + * @param {Db~collectionResultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.createCollection = function(name, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + name = args.length ? args.shift() : null; + options = args.length ? args.shift() || {} : {}; + + // Do we have a promisesLibrary + options.promiseLibrary = options.promiseLibrary || this.s.promiseLibrary; + + // Check if the callback is in fact a string + if(typeof callback == 'string') name = callback; + + // Execute the fallback callback + if(typeof callback == 'function') return createCollection(self, name, options, callback); + return new this.s.promiseLibrary(function(resolve, reject) { + createCollection(self, name, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +} + +define.classMethod('createCollection', {callback: true, promise:true}); + +/** + * Get all the db statistics. + * + * @method + * @param {object} [options=null] Optional settings. + * @param {number} [options.scale=null] Divide the returned sizes by scale value. + * @param {Db~resultCallback} [callback] The collection result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.stats = function(options, callback) { + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + // Build command object + var commandObject = { dbStats:true }; + // Check if we have the scale value + if(options['scale'] != null) commandObject['scale'] = options['scale']; + + // If we have a readPreference set + if(options.readPreference == null && this.s.readPreference) { + options.readPreference = this.s.readPreference; + } + + // Execute the command + return this.command(commandObject, options, callback); +} + +define.classMethod('stats', {callback: true, promise:true}); + +// Transformation methods for cursor results +var listCollectionsTranforms = function(databaseName) { + var matching = f('%s.', databaseName); + + return { + doc: function(doc) { + var index = doc.name.indexOf(matching); + // Remove database name if available + if(doc.name && index == 0) { + doc.name = doc.name.substr(index + matching.length); + } + + return doc; + } + } +} + +/** + * Get the list of all collection information for the specified db. + * + * @method + * @param {object} [filter={}] Query to filter collections by + * @param {object} [options=null] Optional settings. + * @param {number} [options.batchSize=null] The batchSize for the returned command cursor or if pre 2.8 the systems batch collection + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @return {CommandCursor} + */ +Db.prototype.listCollections = function(filter, options) { + filter = filter || {}; + options = options || {}; + + // Shallow clone the object + options = shallowClone(options); + // Set the promise library + options.promiseLibrary = this.s.promiseLibrary; + + // Ensure valid readPreference + if(options.readPreference) { + options.readPreference = convertReadPreference(options.readPreference); + } else { + options.readPreference = this.s.readPreference || CoreReadPreference.primary; + } + + // We have a list collections command + if(this.serverConfig.capabilities().hasListCollectionsCommand) { + // Cursor options + var cursor = options.batchSize ? {batchSize: options.batchSize} : {} + // Build the command + var command = { listCollections : true, filter: filter, cursor: cursor }; + // Set the AggregationCursor constructor + options.cursorFactory = CommandCursor; + // Create the cursor + cursor = this.s.topology.cursor(f('%s.$cmd', this.s.databaseName), command, options); + // Do we have a readPreference, apply it + if(options.readPreference) { + cursor.setReadPreference(options.readPreference); + } + // Return the cursor + return cursor; + } + + // We cannot use the listCollectionsCommand + if(!this.serverConfig.capabilities().hasListCollectionsCommand) { + // If we have legacy mode and have not provided a full db name filter it + if(typeof filter.name == 'string' && !(new RegExp('^' + this.databaseName + '\\.').test(filter.name))) { + filter = shallowClone(filter); + filter.name = f('%s.%s', this.s.databaseName, filter.name); + } + } + + // No filter, filter by current database + if(filter == null) { + filter.name = f('/%s/', this.s.databaseName); + } + + // Rewrite the filter to use $and to filter out indexes + if(filter.name) { + filter = {$and: [{name: filter.name}, {name:/^((?!\$).)*$/}]}; + } else { + filter = {name:/^((?!\$).)*$/}; + } + + // Return options + var _options = {transforms: listCollectionsTranforms(this.s.databaseName)} + // Get the cursor + cursor = this.collection(Db.SYSTEM_NAMESPACE_COLLECTION).find(filter, _options); + // Do we have a readPreference, apply it + if(options.readPreference) cursor.setReadPreference(options.readPreference); + // Set the passed in batch size if one was provided + if(options.batchSize) cursor = cursor.batchSize(options.batchSize); + // We have a fallback mode using legacy systems collections + return cursor; +}; + +define.classMethod('listCollections', {callback: false, promise:false, returns: [CommandCursor]}); + +var evaluate = function(self, code, parameters, options, callback) { + var finalCode = code; + var finalParameters = []; + + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + + // If not a code object translate to one + if(!(finalCode && finalCode._bsontype == 'Code')) finalCode = new Code(finalCode); + // Ensure the parameters are correct + if(parameters != null && !Array.isArray(parameters) && typeof parameters !== 'function') { + finalParameters = [parameters]; + } else if(parameters != null && Array.isArray(parameters) && typeof parameters !== 'function') { + finalParameters = parameters; + } + + // Create execution selector + var cmd = {'$eval':finalCode, 'args':finalParameters}; + // Check if the nolock parameter is passed in + if(options['nolock']) { + cmd['nolock'] = options['nolock']; + } + + // Set primary read preference + options.readPreference = new CoreReadPreference(ReadPreference.PRIMARY); + + // Execute the command + self.command(cmd, options, function(err, result) { + if(err) return handleCallback(callback, err, null); + if(result && result.ok == 1) return handleCallback(callback, null, result.retval); + if(result) return handleCallback(callback, MongoError.create({message: f("eval failed: %s", result.errmsg), driver:true}), null); + handleCallback(callback, err, result); + }); +} + +/** + * Evaluate JavaScript on the server + * + * @method + * @param {Code} code JavaScript to execute on server. + * @param {(object|array)} parameters The parameters for the call. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.nolock=false] Tell MongoDB not to block on the evaluation of the javascript. + * @param {Db~resultCallback} [callback] The results callback + * @deprecated Eval is deprecated on MongoDB 3.2 and forward + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.eval = function(code, parameters, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + parameters = args.length ? args.shift() : parameters; + options = args.length ? args.shift() || {} : {}; + + // Check if the callback is in fact a string + if(typeof callback == 'function') return evaluate(self, code, parameters, options, callback); + // Execute the command + return new this.s.promiseLibrary(function(resolve, reject) { + evaluate(self, code, parameters, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +define.classMethod('eval', {callback: true, promise:true}); + +/** + * Rename a collection. + * + * @method + * @param {string} fromCollection Name of current collection to rename. + * @param {string} toCollection New name of of the collection. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.dropTarget=false] Drop the target name collection if it previously exists. + * @param {Db~collectionResultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.renameCollection = function(fromCollection, toCollection, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + // Add return new collection + options.new_collection = true; + + // Check if the callback is in fact a string + if(typeof callback == 'function') { + return this.collection(fromCollection).rename(toCollection, options, callback); + } + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.collection(fromCollection).rename(toCollection, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +define.classMethod('renameCollection', {callback: true, promise:true}); + +/** + * Drop a collection from the database, removing it permanently. New accesses will create a new collection. + * + * @method + * @param {string} name Name of collection to drop + * @param {Db~resultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.dropCollection = function(name, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Command to execute + var cmd = {'drop':name} + + // Decorate with write concern + decorateWithWriteConcern(cmd, self, options); + + // options + options = assign({}, this.s.options, {readPreference: ReadPreference.PRIMARY}); + + // Check if the callback is in fact a string + if(typeof callback == 'function') return this.command(cmd, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + if(err) return handleCallback(callback, err); + if(result.ok) return handleCallback(callback, null, true); + handleCallback(callback, null, false); + }); + + // Clone the options + options = shallowClone(self.s.options); + // Set readPreference PRIMARY + options.readPreference = ReadPreference.PRIMARY; + + // Execute the command + return new this.s.promiseLibrary(function(resolve, reject) { + // Execute command + self.command(cmd, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); + if(err) return reject(err); + if(result.ok) return resolve(true); + resolve(false); + }); + }); +}; + +define.classMethod('dropCollection', {callback: true, promise:true}); + +/** + * Drop a database, removing it permanently from the server. + * + * @method + * @param {Db~resultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.dropDatabase = function(options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + // Drop database command + var cmd = {'dropDatabase':1}; + + // Decorate with write concern + decorateWithWriteConcern(cmd, self, options); + + // Ensure primary only + options = assign({}, this.s.options, {readPreference: ReadPreference.PRIMARY}); + + // Check if the callback is in fact a string + if(typeof callback == 'function') return this.command(cmd, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + if(callback == null) return; + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }); + + // Execute the command + return new this.s.promiseLibrary(function(resolve, reject) { + // Execute command + self.command(cmd, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); + if(err) return reject(err); + if(result.ok) return resolve(true); + resolve(false); + }); + }); +} + +define.classMethod('dropDatabase', {callback: true, promise:true}); + +/** + * The callback format for the collections method. + * @callback Db~collectionsResultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection[]} collections An array of all the collections objects for the db instance. + */ +var collections = function(self, callback) { + // Let's get the collection names + self.listCollections().toArray(function(err, documents) { + if(err != null) return handleCallback(callback, err, null); + // Filter collections removing any illegal ones + documents = documents.filter(function(doc) { + return doc.name.indexOf('$') == -1; + }); + + // Return the collection objects + handleCallback(callback, null, documents.map(function(d) { + return new Collection(self, self.s.topology, self.s.databaseName, d.name, self.s.pkFactory, self.s.options); + })); + }); +} + +/** + * Fetch all collections for the current db. + * + * @method + * @param {Db~collectionsResultCallback} [callback] The results callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.collections = function(callback) { + var self = this; + + // Return the callback + if(typeof callback == 'function') return collections(self, callback); + // Return the promise + return new self.s.promiseLibrary(function(resolve, reject) { + collections(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +define.classMethod('collections', {callback: true, promise:true}); + +/** + * Runs a command on the database as admin. + * @method + * @param {object} command The command hash + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.executeDbAdminCommand = function(selector, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Return the callback + if(typeof callback == 'function') { + // Convert read preference + if(options.readPreference) { + options.readPreference = convertReadPreference(options.readPreference) + } + + return self.s.topology.command('admin.$cmd', selector, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + if(err) return handleCallback(callback, err); + handleCallback(callback, null, result.result); + }); + } + + // Return promise + return new self.s.promiseLibrary(function(resolve, reject) { + self.s.topology.command('admin.$cmd', selector, options, function(err, result) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return reject(new MongoError('topology was destroyed')); + if(err) return reject(err); + resolve(result.result); + }); + }); +}; + +define.classMethod('executeDbAdminCommand', {callback: true, promise:true}); + +/** + * Creates an index on the db and collection collection. + * @method + * @param {string} name Name of the collection to create the index on. + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.unique=false] Creates an unique index. + * @param {boolean} [options.sparse=false] Creates a sparse index. + * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. + * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value + * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v=null] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {object} [options.partialFilterExpression=null] Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.createIndex = function(name, fieldOrSpec, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + options = typeof callback === 'function' ? options : callback; + options = options == null ? {} : options; + // Shallow clone the options + options = shallowClone(options); + + // If we have a callback fallback + if(typeof callback == 'function') return createIndex(self, name, fieldOrSpec, options, callback); + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + createIndex(self, name, fieldOrSpec, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var createIndex = function(self, name, fieldOrSpec, options, callback) { + // Get the write concern options + var finalOptions = writeConcern({}, self, options, { readPreference: ReadPreference.PRIMARY }); + // Ensure we have a callback + if(finalOptions.writeConcern && typeof callback != 'function') { + throw MongoError.create({message: "Cannot use a writeConcern without a provided callback", driver:true}); + } + + // Run only against primary + options.readPreference = ReadPreference.PRIMARY; + + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + + // Attempt to run using createIndexes command + createIndexUsingCreateIndexes(self, name, fieldOrSpec, options, function(err, result) { + if(err == null) return handleCallback(callback, err, result); + + // 67 = 'CannotCreateIndex' (malformed index options) + // 85 = 'IndexOptionsConflict' (index already exists with different options) + // 11000 = 'DuplicateKey' (couldn't build unique index because of dupes) + // 11600 = 'InterruptedAtShutdown' (interrupted at shutdown) + // These errors mean that the server recognized `createIndex` as a command + // and so we don't need to fallback to an insert. + if(err.code === 67 || err.code == 11000 || err.code === 85 || err.code == 11600) { + return handleCallback(callback, err, result); + } + + // Create command + var doc = createCreateIndexCommand(self, name, fieldOrSpec, options); + // Set no key checking + finalOptions.checkKeys = false; + // Insert document + self.s.topology.insert(f("%s.%s", self.s.databaseName, Db.SYSTEM_INDEX_COLLECTION), doc, finalOptions, function(err, result) { + if(callback == null) return; + if(err) return handleCallback(callback, err); + if(result == null) return handleCallback(callback, null, null); + if(result.result.writeErrors) return handleCallback(callback, MongoError.create(result.result.writeErrors[0]), null); + handleCallback(callback, null, doc.name); + }); + }); +} + +define.classMethod('createIndex', {callback: true, promise:true}); + +/** + * Ensures that an index exists, if it does not it creates it + * @method + * @deprecated since version 2.0 + * @param {string} name The index name + * @param {(string|object)} fieldOrSpec Defines the index. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.unique=false] Creates an unique index. + * @param {boolean} [options.sparse=false] Creates a sparse index. + * @param {boolean} [options.background=false] Creates the index in the background, yielding whenever possible. + * @param {boolean} [options.dropDups=false] A unique index cannot be created on a key that has pre-existing duplicate values. If you would like to create the index anyway, keeping the first document the database indexes and deleting all subsequent documents that have duplicate value + * @param {number} [options.min=null] For geospatial indexes set the lower bound for the co-ordinates. + * @param {number} [options.max=null] For geospatial indexes set the high bound for the co-ordinates. + * @param {number} [options.v=null] Specify the format version of the indexes. + * @param {number} [options.expireAfterSeconds=null] Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + * @param {number} [options.name=null] Override the autogenerated index name (useful if the resulting name is larger than 128 bytes) + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.ensureIndex = function(name, fieldOrSpec, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // If we have a callback fallback + if(typeof callback == 'function') return ensureIndex(self, name, fieldOrSpec, options, callback); + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + ensureIndex(self, name, fieldOrSpec, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var ensureIndex = function(self, name, fieldOrSpec, options, callback) { + // Get the write concern options + var finalOptions = writeConcern({}, self, options); + // Create command + var selector = createCreateIndexCommand(self, name, fieldOrSpec, options); + var index_name = selector.name; + + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + + // Merge primary readPreference + finalOptions.readPreference = ReadPreference.PRIMARY + + // Check if the index already exists + self.indexInformation(name, finalOptions, function(err, indexInformation) { + if(err != null && err.code != 26) return handleCallback(callback, err, null); + // If the index does not exist, create it + if(indexInformation == null || !indexInformation[index_name]) { + self.createIndex(name, fieldOrSpec, options, callback); + } else { + if(typeof callback === 'function') return handleCallback(callback, null, index_name); + } + }); +} + +define.classMethod('ensureIndex', {callback: true, promise:true}); + +Db.prototype.addChild = function(db) { + if(this.s.parentDb) return this.s.parentDb.addChild(db); + this.s.children.push(db); +} + +/** + * Create a new Db instance sharing the current socket connections. Be aware that the new db instances are + * related in a parent-child relationship to the original instance so that events are correctly emitted on child + * db instances. Child db instances are cached so performing db('db1') twice will return the same instance. + * You can control these behaviors with the options noListener and returnNonCachedInstance. + * + * @method + * @param {string} name The name of the database we want to use. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.noListener=false] Do not make the db an event listener to the original connection. + * @param {boolean} [options.returnNonCachedInstance=false] Control if you want to return a cached instance or have a new one created + * @return {Db} + */ +Db.prototype.db = function(dbName, options) { + options = options || {}; + + // Copy the options and add out internal override of the not shared flag + var finalOptions = assign({}, this.options, options); + + // Do we have the db in the cache already + if(this.s.dbCache[dbName] && finalOptions.returnNonCachedInstance !== true) { + return this.s.dbCache[dbName]; + } + + // Add current db as parentDb + if(finalOptions.noListener == null || finalOptions.noListener == false) { + finalOptions.parentDb = this; + } + + // Add promiseLibrary + finalOptions.promiseLibrary = this.s.promiseLibrary; + + // Return the db object + var db = new Db(dbName, this.s.topology, finalOptions) + + // Add as child + if(finalOptions.noListener == null || finalOptions.noListener == false) { + this.addChild(db); + } + + // Add the db to the cache + this.s.dbCache[dbName] = db; + // Return the database + return db; +}; + +define.classMethod('db', {callback: false, promise:false, returns: [Db]}); + +var _executeAuthCreateUserCommand = function(self, username, password, options, callback) { + // Special case where there is no password ($external users) + if(typeof username == 'string' + && password != null && typeof password == 'object') { + options = password; + password = null; + } + + // Unpack all options + if(typeof options == 'function') { + callback = options; + options = {}; + } + + // Error out if we digestPassword set + if(options.digestPassword != null) { + throw toError("The digestPassword option is not supported via add_user. Please use db.command('createUser', ...) instead for this option."); + } + + // Get additional values + var customData = options.customData != null ? options.customData : {}; + var roles = Array.isArray(options.roles) ? options.roles : []; + var maxTimeMS = typeof options.maxTimeMS == 'number' ? options.maxTimeMS : null; + + // If not roles defined print deprecated message + if(roles.length == 0) { + console.log("Creating a user without roles is deprecated in MongoDB >= 2.6"); + } + + // Get the error options + var commandOptions = {writeCommand:true}; + if(options['dbName']) commandOptions.dbName = options['dbName']; + + // Add maxTimeMS to options if set + if(maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; + + // Check the db name and add roles if needed + if((self.databaseName.toLowerCase() == 'admin' || options.dbName == 'admin') && !Array.isArray(options.roles)) { + roles = ['root'] + } else if(!Array.isArray(options.roles)) { + roles = ['dbOwner'] + } + + // Build the command to execute + var command = { + createUser: username + , customData: customData + , roles: roles + , digestPassword:false + } + + // Apply write concern to command + command = writeConcern(command, self, options); + + // Use node md5 generator + var md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ":mongo:" + password); + var userPassword = md5.digest('hex'); + + // No password + if(typeof password == 'string') { + command.pwd = userPassword; + } + + // Force write using primary + commandOptions.readPreference = ReadPreference.primary; + + // Execute the command + self.command(command, commandOptions, function(err, result) { + if(err && err.ok == 0 && err.code == undefined) return handleCallback(callback, {code: -5000}, null); + if(err) return handleCallback(callback, err, null); + handleCallback(callback, !result.ok ? toError(result) : null + , result.ok ? [{user: username, pwd: ''}] : null); + }) +} + +var addUser = function(self, username, password, options, callback) { + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + // Attempt to execute auth command + _executeAuthCreateUserCommand(self, username, password, options, function(err, r) { + // We need to perform the backward compatible insert operation + if(err && err.code == -5000) { + var finalOptions = writeConcern(shallowClone(options), self, options); + // Use node md5 generator + var md5 = crypto.createHash('md5'); + // Generate keys used for authentication + md5.update(username + ":mongo:" + password); + var userPassword = md5.digest('hex'); + + // If we have another db set + var db = options.dbName ? self.db(options.dbName) : self; + + // Fetch a user collection + var collection = db.collection(Db.SYSTEM_USER_COLLECTION); + + // Check if we are inserting the first user + collection.count({}, function(err, count) { + // We got an error (f.ex not authorized) + if(err != null) return handleCallback(callback, err, null); + // Check if the user exists and update i + collection.find({user: username}, {dbName: options['dbName']}).toArray(function(err) { + // We got an error (f.ex not authorized) + if(err != null) return handleCallback(callback, err, null); + // Add command keys + finalOptions.upsert = true; + + // We have a user, let's update the password or upsert if not + collection.update({user: username},{$set: {user: username, pwd: userPassword}}, finalOptions, function(err) { + if(count == 0 && err) return handleCallback(callback, null, [{user:username, pwd:userPassword}]); + if(err) return handleCallback(callback, err, null) + handleCallback(callback, null, [{user:username, pwd:userPassword}]); + }); + }); + }); + + return; + } + + if(err) return handleCallback(callback, err); + handleCallback(callback, err, r); + }); +} + +/** + * Add a user to the database. + * @method + * @param {string} username The username. + * @param {string} password The password. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {object} [options.customData=null] Custom data associated with the user (only Mongodb 2.6 or higher) + * @param {object[]} [options.roles=null] Roles associated with the created user (only Mongodb 2.6 or higher) + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.addUser = function(username, password, options, callback) { + // Unpack the parameters + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + + // If we have a callback fallback + if(typeof callback == 'function') return addUser(self, username, password, options, callback); + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + addUser(self, username, password, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +define.classMethod('addUser', {callback: true, promise:true}); + +var _executeAuthRemoveUserCommand = function(self, username, options, callback) { + if(typeof options == 'function') callback = options, options = {}; + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + // Get the error options + var commandOptions = {writeCommand:true}; + if(options['dbName']) commandOptions.dbName = options['dbName']; + + // Get additional values + var maxTimeMS = typeof options.maxTimeMS == 'number' ? options.maxTimeMS : null; + + // Add maxTimeMS to options if set + if(maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS; + + // Build the command to execute + var command = { + dropUser: username + } + + // Apply write concern to command + command = writeConcern(command, self, options); + + // Force write using primary + commandOptions.readPreference = ReadPreference.primary; + + // Execute the command + self.command(command, commandOptions, function(err, result) { + if(err && !err.ok && err.code == undefined) return handleCallback(callback, {code: -5000}); + if(err) return handleCallback(callback, err, null); + handleCallback(callback, null, result.ok ? true : false); + }) +} + +var removeUser = function(self, username, options, callback) { + // Attempt to execute command + _executeAuthRemoveUserCommand(self, username, options, function(err, result) { + if(err && err.code == -5000) { + var finalOptions = writeConcern(shallowClone(options), self, options); + // If we have another db set + var db = options.dbName ? self.db(options.dbName) : self; + + // Fetch a user collection + var collection = db.collection(Db.SYSTEM_USER_COLLECTION); + + // Locate the user + collection.findOne({user: username}, {}, function(err, user) { + if(user == null) return handleCallback(callback, err, false); + collection.remove({user: username}, finalOptions, function(err) { + handleCallback(callback, err, true); + }); + }); + + return; + } + + if(err) return handleCallback(callback, err); + handleCallback(callback, err, result); + }); +} + +define.classMethod('removeUser', {callback: true, promise:true}); + +/** + * Remove a user from a database + * @method + * @param {string} username The username. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.removeUser = function(username, options, callback) { + // Unpack the parameters + var self = this; + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() || {} : {}; + + // If we have a callback fallback + if(typeof callback == 'function') return removeUser(self, username, options, callback); + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + removeUser(self, username, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +/** + * Authenticate a user against the server. + * @method + * @param {string} username The username. + * @param {string} [password] The password. + * @param {object} [options=null] Optional settings. + * @param {string} [options.authMechanism=MONGODB-CR] The authentication mechanism to use, GSSAPI, MONGODB-CR, MONGODB-X509, PLAIN + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + * @deprecated This method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials. + */ +Db.prototype.authenticate = function(username, password, options, callback) { + console.warn("Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials."); + return authenticate.apply(this, [this].concat(Array.prototype.slice.call(arguments))); +}; + +define.classMethod('authenticate', {callback: true, promise:true}); + +/** + * Logout user from server, fire off on all connections and remove all auth info + * @method + * @param {object} [options=null] Optional settings. + * @param {string} [options.dbName=null] Logout against different database than current. + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.logout = function(options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // Establish the correct database name + var dbName = this.s.authSource ? this.s.authSource : this.s.databaseName; + dbName = options.dbName ? options.dbName : dbName; + + // If we have a callback + if(typeof callback == 'function') { + return self.s.topology.logout(dbName, function(err) { + if(err) return callback(err); + callback(null, true); + }); + } + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + self.s.topology.logout(dbName, function(err) { + if(err) return reject(err); + resolve(true); + }); + }); +} + +define.classMethod('logout', {callback: true, promise:true}); + +/** + * Retrieves this collections index info. + * @method + * @param {string} name The name of the collection. + * @param {object} [options=null] Optional settings. + * @param {boolean} [options.full=false] Returns the full raw index information. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {Db~resultCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +Db.prototype.indexInformation = function(name, options, callback) { + var self = this; + if(typeof options == 'function') callback = options, options = {}; + options = options || {}; + + // If we have a callback fallback + if(typeof callback == 'function') return indexInformation(self, name, options, callback); + + // Return a promise + return new this.s.promiseLibrary(function(resolve, reject) { + indexInformation(self, name, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }); + }); +}; + +var indexInformation = function(self, name, options, callback) { + // If we specified full information + var full = options['full'] == null ? false : options['full']; + + // Did the user destroy the topology + if(self.serverConfig && self.serverConfig.isDestroyed()) return callback(new MongoError('topology was destroyed')); + // Process all the results from the index command and collection + var processResults = function(indexes) { + // Contains all the information + var info = {}; + // Process all the indexes + for(var i = 0; i < indexes.length; i++) { + var index = indexes[i]; + // Let's unpack the object + info[index.name] = []; + for(var name in index.key) { + info[index.name].push([name, index.key[name]]); + } + } + + return info; + } + + // Get the list of indexes of the specified collection + self.collection(name).listIndexes(options).toArray(function(err, indexes) { + if(err) return callback(toError(err)); + if(!Array.isArray(indexes)) return handleCallback(callback, null, []); + if(full) return handleCallback(callback, null, indexes); + handleCallback(callback, null, processResults(indexes)); + }); +} + +define.classMethod('indexInformation', {callback: true, promise:true}); + +var createCreateIndexCommand = function(db, name, fieldOrSpec, options) { + var indexParameters = parseIndexOptions(fieldOrSpec); + var fieldHash = indexParameters.fieldHash; + + // Generate the index name + var indexName = typeof options.name == 'string' ? options.name : indexParameters.name; + var selector = { + 'ns': db.databaseName + "." + name, 'key': fieldHash, 'name': indexName + } + + // Ensure we have a correct finalUnique + var finalUnique = options == null || 'object' === typeof options ? false : options; + // Set up options + options = options == null || typeof options == 'boolean' ? {} : options; + + // Add all the options + var keysToOmit = Object.keys(selector); + for(var optionName in options) { + if(keysToOmit.indexOf(optionName) == -1) { + selector[optionName] = options[optionName]; + } + } + + if(selector['unique'] == null) selector['unique'] = finalUnique; + + // Remove any write concern operations + var removeKeys = ['w', 'wtimeout', 'j', 'fsync', 'readPreference']; + for(var i = 0; i < removeKeys.length; i++) { + delete selector[removeKeys[i]]; + } + + // Return the command creation selector + return selector; +} + +var createIndexUsingCreateIndexes = function(self, name, fieldOrSpec, options, callback) { + // Build the index + var indexParameters = parseIndexOptions(fieldOrSpec); + // Generate the index name + var indexName = typeof options.name == 'string' ? options.name : indexParameters.name; + // Set up the index + var indexes = [{ name: indexName, key: indexParameters.fieldHash }]; + // merge all the options + var keysToOmit = Object.keys(indexes[0]); + for(var optionName in options) { + if(keysToOmit.indexOf(optionName) == -1) { + indexes[0][optionName] = options[optionName]; + } + + // Remove any write concern operations + var removeKeys = ['w', 'wtimeout', 'j', 'fsync', 'readPreference']; + for(var i = 0; i < removeKeys.length; i++) { + delete indexes[0][removeKeys[i]]; + } + } + + // Get capabilities + var capabilities = self.s.topology.capabilities(); + + // Did the user pass in a collation, check if our write server supports it + if(indexes[0].collation && capabilities && !capabilities.commandsTakeCollation) { + // Create a new error + var error = new MongoError(f('server/primary/mongos does not support collation')); + error.code = 67; + // Return the error + return callback(error); + } + + // Create command, apply write concern to command + var cmd = writeConcern({createIndexes: name, indexes: indexes}, self, options); + + // Decorate command with writeConcern if supported + decorateWithWriteConcern(cmd, self, options); + + // ReadPreference primary + options.readPreference = ReadPreference.PRIMARY; + + // Build the command + self.command(cmd, options, function(err, result) { + if(err) return handleCallback(callback, err, null); + if(result.ok == 0) return handleCallback(callback, toError(result), null); + // Return the indexName for backward compatibility + handleCallback(callback, null, indexName); + }); +} + +// Validate the database name +var validateDatabaseName = function(databaseName) { + if(typeof databaseName !== 'string') throw MongoError.create({message: "database name must be a string", driver:true}); + if(databaseName.length === 0) throw MongoError.create({message: "database name cannot be the empty string", driver:true}); + if(databaseName == '$external') return; + + var invalidChars = [" ", ".", "$", "/", "\\"]; + for(var i = 0; i < invalidChars.length; i++) { + if(databaseName.indexOf(invalidChars[i]) != -1) throw MongoError.create({message: "database names cannot contain the character '" + invalidChars[i] + "'", driver:true}); + } +} + +// Get write concern +var writeConcern = function(target, db, options) { + if(options.w != null || options.j != null || options.fsync != null) { + var opts = {}; + if(options.w) opts.w = options.w; + if(options.wtimeout) opts.wtimeout = options.wtimeout; + if(options.j) opts.j = options.j; + if(options.fsync) opts.fsync = options.fsync; + target.writeConcern = opts; + } else if(db.writeConcern.w != null || db.writeConcern.j != null || db.writeConcern.fsync != null) { + target.writeConcern = db.writeConcern; + } + + return target +} + +// Add listeners to topology +var createListener = function(self, e, object) { + var listener = function(err) { + if(object.listeners(e).length > 0) { + object.emit(e, err, self); + + // Emit on all associated db's if available + for(var i = 0; i < self.s.children.length; i++) { + self.s.children[i].emit(e, err, self.s.children[i]); + } + } + } + return listener; +} + + +/** + * Unref all sockets + * @method + */ +Db.prototype.unref = function() { + this.s.topology.unref(); +} + +/** + * Db close event + * + * Emitted after a socket closed against a single server or mongos proxy. + * + * @event Db#close + * @type {MongoError} + */ + +/** + * Db authenticated event + * + * Emitted after all server members in the topology (single server, replicaset or mongos) have successfully authenticated. + * + * @event Db#authenticated + * @type {object} + */ + +/** + * Db reconnect event + * + * * Server: Emitted when the driver has reconnected and re-authenticated. + * * ReplicaSet: N/A + * * Mongos: Emitted when the driver reconnects and re-authenticates successfully against a Mongos. + * + * @event Db#reconnect + * @type {object} + */ + +/** + * Db error event + * + * Emitted after an error occurred against a single server or mongos proxy. + * + * @event Db#error + * @type {MongoError} + */ + +/** + * Db timeout event + * + * Emitted after a socket timeout occurred against a single server or mongos proxy. + * + * @event Db#timeout + * @type {MongoError} + */ + +/** + * Db parseError event + * + * The parseError event is emitted if the driver detects illegal or corrupt BSON being received from the server. + * + * @event Db#parseError + * @type {MongoError} + */ + +/** + * Db fullsetup event, emitted when all servers in the topology have been connected to at start up time. + * + * * Server: Emitted when the driver has connected to the single server and has authenticated. + * * ReplSet: Emitted after the driver has attempted to connect to all replicaset members. + * * Mongos: Emitted after the driver has attempted to connect to all mongos proxies. + * + * @event Db#fullsetup + * @type {Db} + */ + +// Constants +Db.SYSTEM_NAMESPACE_COLLECTION = "system.namespaces"; +Db.SYSTEM_INDEX_COLLECTION = "system.indexes"; +Db.SYSTEM_PROFILE_COLLECTION = "system.profile"; +Db.SYSTEM_USER_COLLECTION = "system.users"; +Db.SYSTEM_COMMAND_COLLECTION = "$cmd"; +Db.SYSTEM_JS_COLLECTION = "system.js"; + +module.exports = Db; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js new file mode 100644 index 0000000..b8e0a30 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js @@ -0,0 +1,409 @@ +var stream = require('stream'), + util = require('util'); + +module.exports = GridFSBucketReadStream; + +/** + * A readable stream that enables you to read buffers from GridFS. + * + * Do not instantiate this class directly. Use `openDownloadStream()` instead. + * + * @class + * @param {Collection} chunks Handle for chunks collection + * @param {Collection} files Handle for files collection + * @param {Object} readPreference The read preference to use + * @param {Object} filter The query to use to find the file document + * @param {Object} [options=null] Optional settings. + * @param {Number} [options.sort=null] Optional sort for the file find query + * @param {Number} [options.skip=null] Optional skip for the file find query + * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @fires GridFSBucketReadStream#error + * @fires GridFSBucketReadStream#file + * @return {GridFSBucketReadStream} a GridFSBucketReadStream instance. + */ + +function GridFSBucketReadStream(chunks, files, readPreference, filter, options) { + this.s = { + bytesRead: 0, + chunks: chunks, + cursor: null, + expected: 0, + files: files, + filter: filter, + init: false, + expectedEnd: 0, + file: null, + options: options, + readPreference: readPreference + }; + + stream.Readable.call(this); +} + +util.inherits(GridFSBucketReadStream, stream.Readable); + +/** + * An error occurred + * + * @event GridFSBucketReadStream#error + * @type {Error} + */ + +/** + * Fires when the stream loaded the file document corresponding to the + * provided id. + * + * @event GridFSBucketReadStream#file + * @type {object} + */ + +/** + * Emitted when a chunk of data is available to be consumed. + * + * @event GridFSBucketReadStream#data + * @type {object} + */ + +/** + * Fired when the stream is exhausted (no more data events). + * + * @event GridFSBucketReadStream#end + * @type {object} + */ + +/** + * Fired when the stream is exhausted and the underlying cursor is killed + * + * @event GridFSBucketReadStream#close + * @type {object} + */ + +/** + * Reads from the cursor and pushes to the stream. + * @method + */ + +GridFSBucketReadStream.prototype._read = function() { + var _this = this; + if (this.destroyed) { + return; + } + + waitForFile(_this, function() { + doRead(_this); + }); +}; + +/** + * Sets the 0-based offset in bytes to start streaming from. Throws + * an error if this stream has entered flowing mode + * (e.g. if you've already called `on('data')`) + * @method + * @param {Number} start Offset in bytes to start reading at + * @return {GridFSBucketReadStream} + */ + +GridFSBucketReadStream.prototype.start = function(start) { + throwIfInitialized(this); + this.s.options.start = start; + return this; +}; + +/** + * Sets the 0-based offset in bytes to start streaming from. Throws + * an error if this stream has entered flowing mode + * (e.g. if you've already called `on('data')`) + * @method + * @param {Number} end Offset in bytes to stop reading at + * @return {GridFSBucketReadStream} + */ + +GridFSBucketReadStream.prototype.end = function(end) { + throwIfInitialized(this); + this.s.options.end = end; + return this; +}; + +/** + * Marks this stream as aborted (will never push another `data` event) + * and kills the underlying cursor. Will emit the 'end' event, and then + * the 'close' event once the cursor is successfully killed. + * + * @method + * @param {GridFSBucket~errorCallback} [callback] called when the cursor is successfully closed or an error occurred. + * @fires GridFSBucketWriteStream#close + * @fires GridFSBucketWriteStream#end + */ + +GridFSBucketReadStream.prototype.abort = function(callback) { + var _this = this; + this.push(null); + this.destroyed = true; + if (this.s.cursor) { + this.s.cursor.close(function(error) { + _this.emit('close'); + callback && callback(error); + }); + } else { + if (!this.s.init) { + // If not initialized, fire close event because we will never + // get a cursor + _this.emit('close'); + } + callback && callback(); + } +}; + +/** + * @ignore + */ + +function throwIfInitialized(self) { + if (self.s.init) { + throw new Error('You cannot change options after the stream has entered' + + 'flowing mode!'); + } +} + +/** + * @ignore + */ + +function doRead(_this) { + if (_this.destroyed) { + return; + } + + _this.s.cursor.next(function(error, doc) { + if (_this.destroyed) { + return; + } + if (error) { + return __handleError(_this, error); + } + if (!doc) { + _this.push(null); + return _this.s.cursor.close(function(error) { + if (error) { + return __handleError(_this, error); + } + _this.emit('close'); + }); + } + + var bytesRemaining = _this.s.file.length - _this.s.bytesRead; + var expectedN = _this.s.expected++; + var expectedLength = Math.min(_this.s.file.chunkSize, + bytesRemaining); + + if (doc.n > expectedN) { + var errmsg = 'ChunkIsMissing: Got unexpected n: ' + doc.n + + ', expected: ' + expectedN; + return __handleError(_this, new Error(errmsg)); + } + + if (doc.n < expectedN) { + errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n + + ', expected: ' + expectedN; + return __handleError(_this, new Error(errmsg)); + } + + var buf = Buffer.isBuffer(doc.data) ? doc.data : doc.data.buffer; + + if (buf.length !== expectedLength) { + if (bytesRemaining <= 0) { + errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n; + return __handleError(_this, new Error(errmsg)); + } + + errmsg = 'ChunkIsWrongSize: Got unexpected length: ' + + buf.length + ', expected: ' + expectedLength; + return __handleError(_this, new Error(errmsg)); + } + + _this.s.bytesRead += buf.length; + + if (buf.length === 0) { + return _this.push(null); + } + + var sliceStart = null; + var sliceEnd = null; + + if (_this.s.bytesToSkip != null) { + sliceStart = _this.s.bytesToSkip; + _this.s.bytesToSkip = 0; + } + + if (expectedN === _this.s.expectedEnd && _this.s.bytesToTrim != null) { + sliceEnd = _this.s.bytesToTrim; + } + + // If the remaining amount of data left is < chunkSize read the right amount of data + if (_this.s.options.end && ( + (_this.s.options.end - _this.s.bytesToSkip) < buf.length + )) { + sliceEnd = (_this.s.options.end - _this.s.bytesToSkip); + } + + if (sliceStart != null || sliceEnd != null) { + buf = buf.slice(sliceStart || 0, sliceEnd || buf.length); + } + + _this.push(buf); + }) +} + +/** + * @ignore + */ + +function init(self) { + var findOneOptions = {}; + if (self.s.readPreference) { + findOneOptions.readPreference = self.s.readPreference; + } + if (self.s.options && self.s.options.sort) { + findOneOptions.sort = self.s.options.sort; + } + if (self.s.options && self.s.options.skip) { + findOneOptions.skip = self.s.options.skip; + } + + self.s.files.findOne(self.s.filter, findOneOptions, function(error, doc) { + if (error) { + return __handleError(self, error); + } + if (!doc) { + var identifier = self.s.filter._id ? + self.s.filter._id.toString() : self.s.filter.filename; + var errmsg = 'FileNotFound: file ' + identifier + ' was not found'; + var err = new Error(errmsg); + err.code = 'ENOENT'; + return __handleError(self, err); + } + + // If document is empty, kill the stream immediately and don't + // execute any reads + if (doc.length <= 0) { + self.push(null); + return; + } + + if (self.destroyed) { + // If user destroys the stream before we have a cursor, wait + // until the query is done to say we're 'closed' because we can't + // cancel a query. + self.emit('close'); + return; + } + + self.s.bytesToSkip = handleStartOption(self, doc, self.s.options); + + var filter = { files_id: doc._id }; + + // Currently (MongoDB 3.4.4) skip function does not support the index, + // it needs to retrieve all the documents first and then skip them. (CS-25811) + // As work around we use $gte on the "n" field. + if (self.s.options && self.s.options.start != null){ + var skip = Math.floor(self.s.options.start / doc.chunkSize); + if (skip > 0){ + filter["n"] = {"$gte": skip}; + } + } + self.s.cursor = self.s.chunks.find(filter).sort({ n: 1 }); + + if (self.s.readPreference) { + self.s.cursor.setReadPreference(self.s.readPreference); + } + + self.s.expectedEnd = Math.ceil(doc.length / doc.chunkSize); + self.s.file = doc; + self.s.bytesToTrim = handleEndOption(self, doc, self.s.cursor, + self.s.options); + self.emit('file', doc); + }); +} + +/** + * @ignore + */ + +function waitForFile(_this, callback) { + if (_this.s.file) { + return callback(); + } + + if (!_this.s.init) { + init(_this); + _this.s.init = true; + } + + _this.once('file', function() { + callback(); + }) +} + +/** + * @ignore + */ + +function handleStartOption(stream, doc, options) { + if (options && options.start != null) { + if (options.start > doc.length) { + throw new Error('Stream start (' + options.start + ') must not be ' + + 'more than the length of the file (' + doc.length +')'); + } + if (options.start < 0) { + throw new Error('Stream start (' + options.start + ') must not be ' + + 'negative'); + } + if (options.end != null && options.end < options.start) { + throw new Error('Stream start (' + options.start + ') must not be ' + + 'greater than stream end (' + options.end + ')'); + } + + stream.s.bytesRead = Math.floor(options.start / doc.chunkSize) * + doc.chunkSize; + stream.s.expected = Math.floor(options.start / doc.chunkSize); + + return options.start - stream.s.bytesRead; + } +} + +/** + * @ignore + */ + +function handleEndOption(stream, doc, cursor, options) { + if (options && options.end != null) { + if (options.end > doc.length) { + throw new Error('Stream end (' + options.end + ') must not be ' + + 'more than the length of the file (' + doc.length +')') + } + if (options.start < 0) { + throw new Error('Stream end (' + options.end + ') must not be ' + + 'negative'); + } + + var start = options.start != null ? + Math.floor(options.start / doc.chunkSize) : + 0; + + cursor.limit(Math.ceil(options.end / doc.chunkSize) - start); + + stream.s.expectedEnd = Math.ceil(options.end / doc.chunkSize); + + return (Math.ceil(options.end / doc.chunkSize) * doc.chunkSize) - + options.end; + } +} + +/** + * @ignore + */ + +function __handleError(_this, error) { + _this.emit('error', error); +} diff --git a/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js new file mode 100644 index 0000000..e0e02c0 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js @@ -0,0 +1,367 @@ +var Emitter = require('events').EventEmitter; +var GridFSBucketReadStream = require('./download'); +var GridFSBucketWriteStream = require('./upload'); +var shallowClone = require('../utils').shallowClone; +var toError = require('../utils').toError; +var util = require('util'); + +var DEFAULT_GRIDFS_BUCKET_OPTIONS = { + bucketName: 'fs', + chunkSizeBytes: 255 * 1024 +}; + +module.exports = GridFSBucket; + +/** + * Constructor for a streaming GridFS interface + * @class + * @param {Db} db A db handle + * @param {object} [options=null] Optional settings. + * @param {string} [options.bucketName="fs"] The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot. + * @param {number} [options.chunkSizeBytes=255 * 1024] Number of bytes stored in each chunk. Defaults to 255KB + * @param {object} [options.writeConcern=null] Optional write concern to be passed to write operations, for instance `{ w: 1 }` + * @param {object} [options.readPreference=null] Optional read preference to be passed to read operations + * @fires GridFSBucketWriteStream#index + * @return {GridFSBucket} + */ + +function GridFSBucket(db, options) { + Emitter.apply(this); + this.setMaxListeners(0); + + if (options && typeof options === 'object') { + options = shallowClone(options); + var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS); + for (var i = 0; i < keys.length; ++i) { + if (!options[keys[i]]) { + options[keys[i]] = DEFAULT_GRIDFS_BUCKET_OPTIONS[keys[i]]; + } + } + } else { + options = DEFAULT_GRIDFS_BUCKET_OPTIONS; + } + + this.s = { + db: db, + options: options, + _chunksCollection: db.collection(options.bucketName + '.chunks'), + _filesCollection: db.collection(options.bucketName + '.files'), + checkedIndexes: false, + calledOpenUploadStream: false, + promiseLibrary: db.s.promiseLibrary || + (typeof global.Promise == 'function' ? global.Promise : require('es6-promise').Promise) + }; +} + +util.inherits(GridFSBucket, Emitter); + +/** + * When the first call to openUploadStream is made, the upload stream will + * check to see if it needs to create the proper indexes on the chunks and + * files collections. This event is fired either when 1) it determines that + * no index creation is necessary, 2) when it successfully creates the + * necessary indexes. + * + * @event GridFSBucket#index + * @type {Error} + */ + +/** + * Returns a writable stream (GridFSBucketWriteStream) for writing + * buffers to GridFS. The stream's 'id' property contains the resulting + * file's id. + * @method + * @param {string} filename The value of the 'filename' key in the files doc + * @param {object} [options=null] Optional settings. + * @param {number} [options.chunkSizeBytes=null] Optional overwrite this bucket's chunkSizeBytes for this file + * @param {object} [options.metadata=null] Optional object to store in the file document's `metadata` field + * @param {string} [options.contentType=null] Optional string to store in the file document's `contentType` field + * @param {array} [options.aliases=null] Optional array of strings to store in the file document's `aliases` field + * @return {GridFSBucketWriteStream} + */ + +GridFSBucket.prototype.openUploadStream = function(filename, options) { + if (options) { + options = shallowClone(options); + } else { + options = {}; + } + if (!options.chunkSizeBytes) { + options.chunkSizeBytes = this.s.options.chunkSizeBytes; + } + return new GridFSBucketWriteStream(this, filename, options); +}; + +/** + * Returns a writable stream (GridFSBucketWriteStream) for writing + * buffers to GridFS for a custom file id. The stream's 'id' property contains the resulting + * file's id. + * @method + * @param {string|number|object} id A custom id used to identify the file + * @param {string} filename The value of the 'filename' key in the files doc + * @param {object} [options=null] Optional settings. + * @param {number} [options.chunkSizeBytes=null] Optional overwrite this bucket's chunkSizeBytes for this file + * @param {object} [options.metadata=null] Optional object to store in the file document's `metadata` field + * @param {string} [options.contentType=null] Optional string to store in the file document's `contentType` field + * @param {array} [options.aliases=null] Optional array of strings to store in the file document's `aliases` field + * @return {GridFSBucketWriteStream} + */ + +GridFSBucket.prototype.openUploadStreamWithId = function(id, filename, options) { + if (options) { + options = shallowClone(options); + } else { + options = {}; + } + + if (!options.chunkSizeBytes) { + options.chunkSizeBytes = this.s.options.chunkSizeBytes; + } + + options.id = id; + + return new GridFSBucketWriteStream(this, filename, options); +}; + +/** + * Returns a readable stream (GridFSBucketReadStream) for streaming file + * data from GridFS. + * @method + * @param {ObjectId} id The id of the file doc + * @param {Object} [options=null] Optional settings. + * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @return {GridFSBucketReadStream} + */ + +GridFSBucket.prototype.openDownloadStream = function(id, options) { + var filter = { _id: id }; + options = { + start: options && options.start, + end: options && options.end + }; + + return new GridFSBucketReadStream(this.s._chunksCollection, + this.s._filesCollection, this.s.options.readPreference, filter, options); +}; + +/** + * Deletes a file with the given id + * @method + * @param {ObjectId} id The id of the file doc + * @param {GridFSBucket~errorCallback} [callback] + */ + +GridFSBucket.prototype.delete = function(id, callback) { + if (typeof callback === 'function') { + return _delete(this, id, callback); + } + + var _this = this; + return new this.s.promiseLibrary(function(resolve, reject) { + _delete(_this, id, function(error, res) { + if (error) { + reject(error); + } else { + resolve(res); + } + }); + }); +}; + +/** + * @ignore + */ + +function _delete(_this, id, callback) { + _this.s._filesCollection.deleteOne({ _id: id }, function(error, res) { + if (error) { + return callback(error); + } + + _this.s._chunksCollection.deleteMany({ files_id: id }, function(error) { + if (error) { + return callback(error); + } + + // Delete orphaned chunks before returning FileNotFound + if (!res.result.n) { + var errmsg = 'FileNotFound: no file with id ' + id + ' found'; + return callback(new Error(errmsg)); + } + + callback(); + }); + }); +} + +/** + * Convenience wrapper around find on the files collection + * @method + * @param {Object} filter + * @param {Object} [options=null] Optional settings for cursor + * @param {number} [options.batchSize=null] Optional batch size for cursor + * @param {number} [options.limit=null] Optional limit for cursor + * @param {number} [options.maxTimeMS=null] Optional maxTimeMS for cursor + * @param {boolean} [options.noCursorTimeout=null] Optionally set cursor's `noCursorTimeout` flag + * @param {number} [options.skip=null] Optional skip for cursor + * @param {object} [options.sort=null] Optional sort for cursor + * @return {Cursor} + */ + +GridFSBucket.prototype.find = function(filter, options) { + filter = filter || {}; + options = options || {}; + + var cursor = this.s._filesCollection.find(filter); + + if (options.batchSize != null) { + cursor.batchSize(options.batchSize); + } + if (options.limit != null) { + cursor.limit(options.limit); + } + if (options.maxTimeMS != null) { + cursor.maxTimeMS(options.maxTimeMS); + } + if (options.noCursorTimeout != null) { + cursor.addCursorFlag('noCursorTimeout', options.noCursorTimeout); + } + if (options.skip != null) { + cursor.skip(options.skip); + } + if (options.sort != null) { + cursor.sort(options.sort); + } + + return cursor; +}; + +/** + * Returns a readable stream (GridFSBucketReadStream) for streaming the + * file with the given name from GridFS. If there are multiple files with + * the same name, this will stream the most recent file with the given name + * (as determined by the `uploadDate` field). You can set the `revision` + * option to change this behavior. + * @method + * @param {String} filename The name of the file to stream + * @param {Object} [options=null] Optional settings + * @param {number} [options.revision=-1] The revision number relative to the oldest file with the given filename. 0 gets you the oldest file, 1 gets you the 2nd oldest, -1 gets you the newest. + * @param {Number} [options.start=null] Optional 0-based offset in bytes to start streaming from + * @param {Number} [options.end=null] Optional 0-based offset in bytes to stop streaming before + * @return {GridFSBucketReadStream} + */ + +GridFSBucket.prototype.openDownloadStreamByName = function(filename, options) { + var sort = { uploadDate: -1 }; + var skip = null; + if (options && options.revision != null) { + if (options.revision >= 0) { + sort = { uploadDate: 1 }; + skip = options.revision; + } else { + skip = -options.revision - 1; + } + } + + var filter = { filename: filename }; + options = { + sort: sort, + skip: skip, + start: options && options.start, + end: options && options.end + }; + return new GridFSBucketReadStream(this.s._chunksCollection, + this.s._filesCollection, this.s.options.readPreference, filter, options); +}; + +/** + * Renames the file with the given _id to the given string + * @method + * @param {ObjectId} id the id of the file to rename + * @param {String} filename new name for the file + * @param {GridFSBucket~errorCallback} [callback] + */ + +GridFSBucket.prototype.rename = function(id, filename, callback) { + if (typeof callback === 'function') { + return _rename(this, id, filename, callback); + } + + var _this = this; + return new this.s.promiseLibrary(function(resolve, reject) { + _rename(_this, id, filename, function(error, res) { + if (error) { + reject(error); + } else { + resolve(res); + } + }); + }); +}; + +/** + * @ignore + */ + +function _rename(_this, id, filename, callback) { + var filter = { _id: id }; + var update = { $set: { filename: filename } }; + _this.s._filesCollection.updateOne(filter, update, function(error, res) { + if (error) { + return callback(error); + } + if (!res.result.n) { + return callback(toError('File with id ' + id + ' not found')); + } + callback(); + }); +} + +/** + * Removes this bucket's files collection, followed by its chunks collection. + * @method + * @param {GridFSBucket~errorCallback} [callback] + */ + +GridFSBucket.prototype.drop = function(callback) { + if (typeof callback === 'function') { + return _drop(this, callback); + } + + var _this = this; + return new this.s.promiseLibrary(function(resolve, reject) { + _drop(_this, function(error, res) { + if (error) { + reject(error); + } else { + resolve(res); + } + }); + }); +}; + +/** + * @ignore + */ + +function _drop(_this, callback) { + _this.s._filesCollection.drop(function(error) { + if (error) { + return callback(error); + } + _this.s._chunksCollection.drop(function(error) { + if (error) { + return callback(error); + } + + return callback(); + }); + }); +} + +/** + * Callback format for all GridFSBucket methods that can accept a callback. + * @callback GridFSBucket~errorCallback + * @param {MongoError} error An error instance representing any errors that occurred + */ diff --git a/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js new file mode 100644 index 0000000..180666e --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js @@ -0,0 +1,527 @@ +var core = require('mongodb-core'); +var crypto = require('crypto'); +var stream = require('stream'); +var util = require('util'); + +var ERROR_NAMESPACE_NOT_FOUND = 26; + +module.exports = GridFSBucketWriteStream; + +/** + * A writable stream that enables you to write buffers to GridFS. + * + * Do not instantiate this class directly. Use `openUploadStream()` instead. + * + * @class + * @param {GridFSBucket} bucket Handle for this stream's corresponding bucket + * @param {string} filename The value of the 'filename' key in the files doc + * @param {object} [options=null] Optional settings. + * @param {string|number|object} [options.id=null] Custom file id for the GridFS file. + * @param {number} [options.chunkSizeBytes=null] The chunk size to use, in bytes + * @param {number} [options.w=null] The write concern + * @param {number} [options.wtimeout=null] The write concern timeout + * @param {number} [options.j=null] The journal write concern + * @fires GridFSBucketWriteStream#error + * @fires GridFSBucketWriteStream#finish + * @return {GridFSBucketWriteStream} a GridFSBucketWriteStream instance. + */ + +function GridFSBucketWriteStream(bucket, filename, options) { + options = options || {}; + this.bucket = bucket; + this.chunks = bucket.s._chunksCollection; + this.filename = filename; + this.files = bucket.s._filesCollection; + this.options = options; + // Signals the write is all done + this.done = false; + + this.id = options.id ? options.id : core.BSON.ObjectId(); + this.chunkSizeBytes = this.options.chunkSizeBytes; + this.bufToStore = new Buffer(this.chunkSizeBytes); + this.length = 0; + this.md5 = crypto.createHash('md5'); + this.n = 0; + this.pos = 0; + this.state = { + streamEnd: false, + outstandingRequests: 0, + errored: false, + aborted: false, + promiseLibrary: this.bucket.s.promiseLibrary + }; + + if (!this.bucket.s.calledOpenUploadStream) { + this.bucket.s.calledOpenUploadStream = true; + + var _this = this; + checkIndexes(this, function() { + _this.bucket.s.checkedIndexes = true; + _this.bucket.emit('index'); + }); + } +} + +util.inherits(GridFSBucketWriteStream, stream.Writable); + +/** + * An error occurred + * + * @event GridFSBucketWriteStream#error + * @type {Error} + */ + +/** + * `end()` was called and the write stream successfully wrote the file + * metadata and all the chunks to MongoDB. + * + * @event GridFSBucketWriteStream#finish + * @type {object} + */ + +/** + * Write a buffer to the stream. + * + * @method + * @param {Buffer} chunk Buffer to write + * @param {String} encoding Optional encoding for the buffer + * @param {Function} callback Function to call when the chunk was added to the buffer, or if the entire chunk was persisted to MongoDB if this chunk caused a flush. + * @return {Boolean} False if this write required flushing a chunk to MongoDB. True otherwise. + */ + +GridFSBucketWriteStream.prototype.write = function(chunk, encoding, callback) { + var _this = this; + return waitForIndexes(this, function() { + return doWrite(_this, chunk, encoding, callback); + }); +}; + +/** + * Places this write stream into an aborted state (all future writes fail) + * and deletes all chunks that have already been written. + * + * @method + * @param {GridFSBucket~errorCallback} callback called when chunks are successfully removed or error occurred + * @return {Promise} if no callback specified + */ + +GridFSBucketWriteStream.prototype.abort = function(callback) { + if (this.state.streamEnd) { + var error = new Error('Cannot abort a stream that has already completed'); + if (typeof callback == 'function') { + return callback(error); + } + return this.state.promiseLibrary.reject(error); + } + if (this.state.aborted) { + error = new Error('Cannot call abort() on a stream twice'); + if (typeof callback == 'function') { + return callback(error); + } + return this.state.promiseLibrary.reject(error); + } + this.state.aborted = true; + this.chunks.deleteMany({ files_id: this.id }, function(error) { + if(typeof callback == 'function') callback(error); + }); +}; + +/** + * Tells the stream that no more data will be coming in. The stream will + * persist the remaining data to MongoDB, write the files document, and + * then emit a 'finish' event. + * + * @method + * @param {Buffer} chunk Buffer to write + * @param {String} encoding Optional encoding for the buffer + * @param {Function} callback Function to call when all files and chunks have been persisted to MongoDB + */ + +GridFSBucketWriteStream.prototype.end = function(chunk, encoding, callback) { + var _this = this; + if(typeof chunk == 'function') { + callback = chunk, chunk = null, encoding = null; + } else if(typeof encoding == 'function') { + callback = encoding, encoding = null; + } + + if (checkAborted(this, callback)) { + return; + } + this.state.streamEnd = true; + + if (callback) { + this.once('finish', function(result) { + callback(null, result); + }); + } + + if (!chunk) { + waitForIndexes(this, function() { + writeRemnant(_this); + }); + return; + } + + this.write(chunk, encoding, function() { + writeRemnant(_this); + }); +}; + +/** + * @ignore + */ + +function __handleError(_this, error, callback) { + if (_this.state.errored) { + return; + } + _this.state.errored = true; + if (callback) { + return callback(error); + } + _this.emit('error', error); +} + +/** + * @ignore + */ + +function createChunkDoc(filesId, n, data) { + return { + _id: core.BSON.ObjectId(), + files_id: filesId, + n: n, + data: data + }; +} + +/** + * @ignore + */ + +function checkChunksIndex(_this, callback) { + _this.chunks.listIndexes().toArray(function(error, indexes) { + if (error) { + // Collection doesn't exist so create index + if (error.code === ERROR_NAMESPACE_NOT_FOUND) { + var index = { files_id: 1, n: 1 }; + _this.chunks.createIndex(index, { background: false, unique: true }, function(error) { + if (error) { + return callback(error); + } + + callback(); + }); + return; + } + return callback(error); + } + + var hasChunksIndex = false; + indexes.forEach(function(index) { + if (index.key) { + var keys = Object.keys(index.key); + if (keys.length === 2 && index.key.files_id === 1 && + index.key.n === 1) { + hasChunksIndex = true; + } + } + }); + + if (hasChunksIndex) { + callback(); + } else { + index = { files_id: 1, n: 1 }; + var indexOptions = getWriteOptions(_this); + + indexOptions.background = false; + indexOptions.unique = true; + + _this.chunks.createIndex(index, indexOptions, function(error) { + if (error) { + return callback(error); + } + + callback(); + }); + } + }); +} + +/** + * @ignore + */ + +function checkDone(_this, callback) { + if(_this.done) return true; + if (_this.state.streamEnd && + _this.state.outstandingRequests === 0 && + !_this.state.errored) { + // Set done so we dont' trigger duplicate createFilesDoc + _this.done = true; + // Create a new files doc + var filesDoc = createFilesDoc(_this.id, _this.length, _this.chunkSizeBytes, + _this.md5.digest('hex'), _this.filename, _this.options.contentType, + _this.options.aliases, _this.options.metadata); + + if (checkAborted(_this, callback)) { + return false; + } + + _this.files.insert(filesDoc, getWriteOptions(_this), function(error) { + if (error) { + return __handleError(_this, error, callback); + } + _this.emit('finish', filesDoc); + }); + + return true; + } + + return false; +} + +/** + * @ignore + */ + +function checkIndexes(_this, callback) { + _this.files.findOne({}, { _id: 1 }, function(error, doc) { + if (error) { + return callback(error); + } + if (doc) { + return callback(); + } + + _this.files.listIndexes().toArray(function(error, indexes) { + if (error) { + // Collection doesn't exist so create index + if (error.code === ERROR_NAMESPACE_NOT_FOUND) { + var index = { filename: 1, uploadDate: 1 }; + _this.files.createIndex(index, { background: false }, function(error) { + if (error) { + return callback(error); + } + + checkChunksIndex(_this, callback); + }); + return; + } + return callback(error); + } + + var hasFileIndex = false; + indexes.forEach(function(index) { + var keys = Object.keys(index.key); + if (keys.length === 2 && index.key.filename === 1 && + index.key.uploadDate === 1) { + hasFileIndex = true; + } + }); + + if (hasFileIndex) { + checkChunksIndex(_this, callback); + } else { + index = { filename: 1, uploadDate: 1 }; + + var indexOptions = getWriteOptions(_this); + + indexOptions.background = false; + + _this.files.createIndex(index, indexOptions, function(error) { + if (error) { + return callback(error); + } + + checkChunksIndex(_this, callback); + }); + } + }); + }); +} + +/** + * @ignore + */ + +function createFilesDoc(_id, length, chunkSize, md5, filename, contentType, + aliases, metadata) { + var ret = { + _id: _id, + length: length, + chunkSize: chunkSize, + uploadDate: new Date(), + md5: md5, + filename: filename + }; + + if (contentType) { + ret.contentType = contentType; + } + + if (aliases) { + ret.aliases = aliases; + } + + if (metadata) { + ret.metadata = metadata; + } + + return ret; +} + +/** + * @ignore + */ + +function doWrite(_this, chunk, encoding, callback) { + if (checkAborted(_this, callback)) { + return false; + } + + var inputBuf = (Buffer.isBuffer(chunk)) ? + chunk : new Buffer(chunk, encoding); + + _this.length += inputBuf.length; + + // Input is small enough to fit in our buffer + if (_this.pos + inputBuf.length < _this.chunkSizeBytes) { + inputBuf.copy(_this.bufToStore, _this.pos); + _this.pos += inputBuf.length; + + callback && callback(); + + // Note that we reverse the typical semantics of write's return value + // to be compatible with node's `.pipe()` function. + // True means client can keep writing. + return true; + } + + // Otherwise, buffer is too big for current chunk, so we need to flush + // to MongoDB. + var inputBufRemaining = inputBuf.length; + var spaceRemaining = _this.chunkSizeBytes - _this.pos; + var numToCopy = Math.min(spaceRemaining, inputBuf.length); + var outstandingRequests = 0; + while (inputBufRemaining > 0) { + var inputBufPos = inputBuf.length - inputBufRemaining; + inputBuf.copy(_this.bufToStore, _this.pos, + inputBufPos, inputBufPos + numToCopy); + _this.pos += numToCopy; + spaceRemaining -= numToCopy; + if (spaceRemaining === 0) { + _this.md5.update(_this.bufToStore); + var doc = createChunkDoc(_this.id, _this.n, _this.bufToStore); + ++_this.state.outstandingRequests; + ++outstandingRequests; + + if (checkAborted(_this, callback)) { + return false; + } + + _this.chunks.insert(doc, getWriteOptions(_this), function(error) { + if (error) { + return __handleError(_this, error); + } + --_this.state.outstandingRequests; + --outstandingRequests; + + if (!outstandingRequests) { + _this.emit('drain', doc); + callback && callback(); + checkDone(_this); + } + }); + + spaceRemaining = _this.chunkSizeBytes; + _this.pos = 0; + ++_this.n; + } + inputBufRemaining -= numToCopy; + numToCopy = Math.min(spaceRemaining, inputBufRemaining); + } + + // Note that we reverse the typical semantics of write's return value + // to be compatible with node's `.pipe()` function. + // False means the client should wait for the 'drain' event. + return false; +} + +/** + * @ignore + */ + +function getWriteOptions(_this) { + var obj = {}; + if (_this.options.writeConcern) { + obj.w = _this.options.writeConcern.w; + obj.wtimeout = _this.options.writeConcern.wtimeout; + obj.j = _this.options.writeConcern.j; + } + return obj; +} + +/** + * @ignore + */ + +function waitForIndexes(_this, callback) { + if (_this.bucket.s.checkedIndexes) { + return callback(false); + } + + _this.bucket.once('index', function() { + callback(true); + }); + + return true; +} + +/** + * @ignore + */ + +function writeRemnant(_this, callback) { + // Buffer is empty, so don't bother to insert + if (_this.pos === 0) { + return checkDone(_this, callback); + } + + ++_this.state.outstandingRequests; + + // Create a new buffer to make sure the buffer isn't bigger than it needs + // to be. + var remnant = new Buffer(_this.pos); + _this.bufToStore.copy(remnant, 0, 0, _this.pos); + _this.md5.update(remnant); + var doc = createChunkDoc(_this.id, _this.n, remnant); + + // If the stream was aborted, do not write remnant + if (checkAborted(_this, callback)) { + return false; + } + + _this.chunks.insert(doc, getWriteOptions(_this), function(error) { + if (error) { + return __handleError(_this, error); + } + --_this.state.outstandingRequests; + checkDone(_this); + }); +} + +/** + * @ignore + */ + +function checkAborted(_this, callback) { + if (_this.state.aborted) { + if(typeof callback == 'function') { + callback(new Error('this stream has been aborted')); + } + return true; + } + return false; +} diff --git a/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js b/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js new file mode 100644 index 0000000..9100197 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js @@ -0,0 +1,230 @@ +"use strict"; + +var Binary = require('mongodb-core').BSON.Binary, + ObjectID = require('mongodb-core').BSON.ObjectID; + +/** + * Class for representing a single chunk in GridFS. + * + * @class + * + * @param file {GridStore} The {@link GridStore} object holding this chunk. + * @param mongoObject {object} The mongo object representation of this chunk. + * + * @throws Error when the type of data field for {@link mongoObject} is not + * supported. Currently supported types for data field are instances of + * {@link String}, {@link Array}, {@link Binary} and {@link Binary} + * from the bson module + * + * @see Chunk#buildMongoObject + */ +var Chunk = function(file, mongoObject, writeConcern) { + if(!(this instanceof Chunk)) return new Chunk(file, mongoObject); + + this.file = file; + var mongoObjectFinal = mongoObject == null ? {} : mongoObject; + this.writeConcern = writeConcern || {w:1}; + this.objectId = mongoObjectFinal._id == null ? new ObjectID() : mongoObjectFinal._id; + this.chunkNumber = mongoObjectFinal.n == null ? 0 : mongoObjectFinal.n; + this.data = new Binary(); + + if(typeof mongoObjectFinal.data == "string") { + var buffer = new Buffer(mongoObjectFinal.data.length); + buffer.write(mongoObjectFinal.data, 0, mongoObjectFinal.data.length, 'binary'); + this.data = new Binary(buffer); + } else if(Array.isArray(mongoObjectFinal.data)) { + buffer = new Buffer(mongoObjectFinal.data.length); + var data = mongoObjectFinal.data.join(''); + buffer.write(data, 0, data.length, 'binary'); + this.data = new Binary(buffer); + } else if(mongoObjectFinal.data && mongoObjectFinal.data._bsontype === 'Binary') { + this.data = mongoObjectFinal.data; + } else if(!Buffer.isBuffer(mongoObjectFinal.data) && !(mongoObjectFinal.data == null)){ + throw Error("Illegal chunk format"); + } + + // Update position + this.internalPosition = 0; +}; + +/** + * Writes a data to this object and advance the read/write head. + * + * @param data {string} the data to write + * @param callback {function(*, GridStore)} This will be called after executing + * this method. The first parameter will contain null and the second one + * will contain a reference to this object. + */ +Chunk.prototype.write = function(data, callback) { + this.data.write(data, this.internalPosition, data.length, 'binary'); + this.internalPosition = this.data.length(); + if(callback != null) return callback(null, this); + return this; +}; + +/** + * Reads data and advances the read/write head. + * + * @param length {number} The length of data to read. + * + * @return {string} The data read if the given length will not exceed the end of + * the chunk. Returns an empty String otherwise. + */ +Chunk.prototype.read = function(length) { + // Default to full read if no index defined + length = length == null || length == 0 ? this.length() : length; + + if(this.length() - this.internalPosition + 1 >= length) { + var data = this.data.read(this.internalPosition, length); + this.internalPosition = this.internalPosition + length; + return data; + } else { + return ''; + } +}; + +Chunk.prototype.readSlice = function(length) { + if ((this.length() - this.internalPosition) >= length) { + var data = null; + if (this.data.buffer != null) { //Pure BSON + data = this.data.buffer.slice(this.internalPosition, this.internalPosition + length); + } else { //Native BSON + data = new Buffer(length); + length = this.data.readInto(data, this.internalPosition); + } + this.internalPosition = this.internalPosition + length; + return data; + } else { + return null; + } +}; + +/** + * Checks if the read/write head is at the end. + * + * @return {boolean} Whether the read/write head has reached the end of this + * chunk. + */ +Chunk.prototype.eof = function() { + return this.internalPosition == this.length() ? true : false; +}; + +/** + * Reads one character from the data of this chunk and advances the read/write + * head. + * + * @return {string} a single character data read if the the read/write head is + * not at the end of the chunk. Returns an empty String otherwise. + */ +Chunk.prototype.getc = function() { + return this.read(1); +}; + +/** + * Clears the contents of the data in this chunk and resets the read/write head + * to the initial position. + */ +Chunk.prototype.rewind = function() { + this.internalPosition = 0; + this.data = new Binary(); +}; + +/** + * Saves this chunk to the database. Also overwrites existing entries having the + * same id as this chunk. + * + * @param callback {function(*, GridStore)} This will be called after executing + * this method. The first parameter will contain null and the second one + * will contain a reference to this object. + */ +Chunk.prototype.save = function(options, callback) { + var self = this; + if(typeof options == 'function') { + callback = options; + options = {}; + } + + self.file.chunkCollection(function(err, collection) { + if(err) return callback(err); + + // Merge the options + var writeOptions = { upsert: true }; + for(var name in options) writeOptions[name] = options[name]; + for(name in self.writeConcern) writeOptions[name] = self.writeConcern[name]; + + if(self.data.length() > 0) { + self.buildMongoObject(function(mongoObject) { + var options = {forceServerObjectId:true}; + for(var name in self.writeConcern) { + options[name] = self.writeConcern[name]; + } + + collection.replaceOne({'_id':self.objectId}, mongoObject, writeOptions, function(err) { + callback(err, self); + }); + }); + } else { + callback(null, self); + } + // }); + }); +}; + +/** + * Creates a mongoDB object representation of this chunk. + * + * @param callback {function(Object)} This will be called after executing this + * method. The object will be passed to the first parameter and will have + * the structure: + * + *

+ *        {
+ *          '_id' : , // {number} id for this chunk
+ *          'files_id' : , // {number} foreign key to the file collection
+ *          'n' : , // {number} chunk number
+ *          'data' : , // {bson#Binary} the chunk data itself
+ *        }
+ *        
+ * + * @see MongoDB GridFS Chunk Object Structure + */ +Chunk.prototype.buildMongoObject = function(callback) { + var mongoObject = { + 'files_id': this.file.fileId, + 'n': this.chunkNumber, + 'data': this.data}; + // If we are saving using a specific ObjectId + if(this.objectId != null) mongoObject._id = this.objectId; + + callback(mongoObject); +}; + +/** + * @return {number} the length of the data + */ +Chunk.prototype.length = function() { + return this.data.length(); +}; + +/** + * The position of the read/write head + * @name position + * @lends Chunk# + * @field + */ +Object.defineProperty(Chunk.prototype, "position", { enumerable: true + , get: function () { + return this.internalPosition; + } + , set: function(value) { + this.internalPosition = value; + } +}); + +/** + * The default chunk size + * @constant + */ +Chunk.DEFAULT_CHUNK_SIZE = 1024 * 255; + +module.exports = Chunk; diff --git a/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js b/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js new file mode 100644 index 0000000..ebf6613 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js @@ -0,0 +1,1954 @@ +"use strict"; + +/** + * @fileOverview GridFS is a tool for MongoDB to store files to the database. + * Because of the restrictions of the object size the database can hold, a + * facility to split a file into several chunks is needed. The {@link GridStore} + * class offers a simplified api to interact with files while managing the + * chunks of split files behind the scenes. More information about GridFS can be + * found here. + * + * @example + * var MongoClient = require('mongodb').MongoClient, + * GridStore = require('mongodb').GridStore, + * ObjectID = require('mongodb').ObjectID, + * test = require('assert'); + * + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * var gridStore = new GridStore(db, null, "w"); + * gridStore.open(function(err, gridStore) { + * gridStore.write("hello world!", function(err, gridStore) { + * gridStore.close(function(err, result) { + * + * // Let's read the file using object Id + * GridStore.read(db, result._id, function(err, data) { + * test.equal('hello world!', data); + * db.close(); + * test.done(); + * }); + * }); + * }); + * }); + * }); + */ +var Chunk = require('./chunk'), + ObjectID = require('mongodb-core').BSON.ObjectID, + ReadPreference = require('../read_preference'), + Buffer = require('buffer').Buffer, + Collection = require('../collection'), + fs = require('fs'), + f = require('util').format, + util = require('util'), + Define = require('../metadata'), + MongoError = require('mongodb-core').MongoError, + inherits = util.inherits, + Duplex = require('stream').Duplex || require('readable-stream').Duplex, + shallowClone = require('../utils').shallowClone; + +var REFERENCE_BY_FILENAME = 0, + REFERENCE_BY_ID = 1; + +/** + * Namespace provided by the mongodb-core and node.js + * @external Duplex + */ + +/** + * Create a new GridStore instance + * + * Modes + * - **"r"** - read only. This is the default mode. + * - **"w"** - write in truncate mode. Existing data will be overwritten. + * + * @class + * @param {Db} db A database instance to interact with. + * @param {object} [id] optional unique id for this file + * @param {string} [filename] optional filename for this file, no unique constrain on the field + * @param {string} mode set the mode for this file. + * @param {object} [options=null] Optional settings. + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.fsync=false] Specify a file sync write concern. + * @param {string} [options.root=null] Root collection to use. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. + * @param {string} [options.content_type=null] MIME type of the file. Defaults to **{GridStore.DEFAULT_CONTENT_TYPE}**. + * @param {number} [options.chunk_size=261120] Size for the chunk. Defaults to **{Chunk.DEFAULT_CHUNK_SIZE}**. + * @param {object} [options.metadata=null] Arbitrary data the user wants to store. + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @property {number} chunkSize Get the gridstore chunk size. + * @property {number} md5 The md5 checksum for this file. + * @property {number} chunkNumber The current chunk number the gridstore has materialized into memory + * @return {GridStore} a GridStore instance. + * @deprecated Use GridFSBucket API instead + */ +var GridStore = function GridStore(db, id, filename, mode, options) { + if(!(this instanceof GridStore)) return new GridStore(db, id, filename, mode, options); + this.db = db; + + // Handle options + if(typeof options === 'undefined') options = {}; + // Handle mode + if(typeof mode === 'undefined') { + mode = filename; + filename = undefined; + } else if(typeof mode == 'object') { + options = mode; + mode = filename; + filename = undefined; + } + + if(id && id._bsontype == 'ObjectID') { + this.referenceBy = REFERENCE_BY_ID; + this.fileId = id; + this.filename = filename; + } else if(typeof filename == 'undefined') { + this.referenceBy = REFERENCE_BY_FILENAME; + this.filename = id; + if (mode.indexOf('w') != null) { + this.fileId = new ObjectID(); + } + } else { + this.referenceBy = REFERENCE_BY_ID; + this.fileId = id; + this.filename = filename; + } + + // Set up the rest + this.mode = mode == null ? "r" : mode; + this.options = options || {}; + + // Opened + this.isOpen = false; + + // Set the root if overridden + this.root = this.options['root'] == null ? GridStore.DEFAULT_ROOT_COLLECTION : this.options['root']; + this.position = 0; + this.readPreference = this.options.readPreference || db.options.readPreference || ReadPreference.PRIMARY; + this.writeConcern = _getWriteConcern(db, this.options); + // Set default chunk size + this.internalChunkSize = this.options['chunkSize'] == null ? Chunk.DEFAULT_CHUNK_SIZE : this.options['chunkSize']; + + // Get the promiseLibrary + var promiseLibrary = this.options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Set the promiseLibrary + this.promiseLibrary = promiseLibrary; + + Object.defineProperty(this, "chunkSize", { enumerable: true + , get: function () { + return this.internalChunkSize; + } + , set: function(value) { + if(!(this.mode[0] == "w" && this.position == 0 && this.uploadDate == null)) { + this.internalChunkSize = this.internalChunkSize; + } else { + this.internalChunkSize = value; + } + } + }); + + Object.defineProperty(this, "md5", { enumerable: true + , get: function () { + return this.internalMd5; + } + }); + + Object.defineProperty(this, "chunkNumber", { enumerable: true + , get: function () { + return this.currentChunk && this.currentChunk.chunkNumber ? this.currentChunk.chunkNumber : null; + } + }); +} + +var define = GridStore.define = new Define('Gridstore', GridStore, true); + +/** + * The callback format for the Gridstore.open method + * @callback GridStore~openCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {GridStore} gridStore The GridStore instance if the open method was successful. + */ + +/** + * Opens the file from the database and initialize this object. Also creates a + * new one if file does not exist. + * + * @method + * @param {GridStore~openCallback} [callback] this will be called after executing this method + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.open = function(callback) { + var self = this; + if( this.mode != "w" && this.mode != "w+" && this.mode != "r"){ + throw MongoError.create({message: "Illegal mode " + this.mode, driver:true}); + } + + // We provided a callback leg + if(typeof callback == 'function') return open(self, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + open(self, function(err, store) { + if(err) return reject(err); + resolve(store); + }) + }); +}; + +var open = function(self, callback) { + // Get the write concern + var writeConcern = _getWriteConcern(self.db, self.options); + + // If we are writing we need to ensure we have the right indexes for md5's + if((self.mode == "w" || self.mode == "w+")) { + // Get files collection + var collection = self.collection(); + // Put index on filename + collection.ensureIndex([['filename', 1]], writeConcern, function() { + // Get chunk collection + var chunkCollection = self.chunkCollection(); + // Make an unique index for compatibility with mongo-cxx-driver:legacy + var chunkIndexOptions = shallowClone(writeConcern); + chunkIndexOptions.unique = true; + // Ensure index on chunk collection + chunkCollection.ensureIndex([['files_id', 1], ['n', 1]], chunkIndexOptions, function() { + // Open the connection + _open(self, writeConcern, function(err, r) { + if(err) return callback(err); + self.isOpen = true; + callback(err, r); + }); + }); + }); + } else { + // Open the gridstore + _open(self, writeConcern, function(err, r) { + if(err) return callback(err); + self.isOpen = true; + callback(err, r); + }); + } +} + +// Push the definition for open +define.classMethod('open', {callback: true, promise:true}); + +/** + * Verify if the file is at EOF. + * + * @method + * @return {boolean} true if the read/write head is at the end of this file. + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.eof = function() { + return this.position == this.length ? true : false; +} + +define.classMethod('eof', {callback: false, promise:false, returns: [Boolean]}); + +/** + * The callback result format. + * @callback GridStore~resultCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {object} result The result from the callback. + */ + +/** + * Retrieves a single character from this file. + * + * @method + * @param {GridStore~resultCallback} [callback] this gets called after this method is executed. Passes null to the first parameter and the character read to the second or null to the second if the read/write head is at the end of the file. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.getc = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return eof(self, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + eof(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +} + +var eof = function(self, callback) { + if(self.eof()) { + callback(null, null); + } else if(self.currentChunk.eof()) { + nthChunk(self, self.currentChunk.chunkNumber + 1, function(err, chunk) { + self.currentChunk = chunk; + self.position = self.position + 1; + callback(err, self.currentChunk.getc()); + }); + } else { + self.position = self.position + 1; + callback(null, self.currentChunk.getc()); + } +} + +define.classMethod('getc', {callback: true, promise:true}); + +/** + * Writes a string to the file with a newline character appended at the end if + * the given string does not have one. + * + * @method + * @param {string} string the string to write. + * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.puts = function(string, callback) { + var self = this; + var finalString = string.match(/\n$/) == null ? string + "\n" : string; + // We provided a callback leg + if(typeof callback == 'function') return this.write(finalString, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + self.write(finalString, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +} + +define.classMethod('puts', {callback: true, promise:true}); + +/** + * Return a modified Readable stream including a possible transform method. + * + * @method + * @return {GridStoreStream} + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.stream = function() { + return new GridStoreStream(this); +} + +define.classMethod('stream', {callback: false, promise:false, returns: [GridStoreStream]}); + +/** + * Writes some data. This method will work properly only if initialized with mode "w" or "w+". + * + * @method + * @param {(string|Buffer)} data the data to write. + * @param {boolean} [close] closes this file after writing if set to true. + * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.write = function write(data, close, callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return _writeNormal(this, data, close, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + _writeNormal(self, data, close, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +} + +define.classMethod('write', {callback: true, promise:true}); + +/** + * Handles the destroy part of a stream + * + * @method + * @result {null} + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.destroy = function destroy() { + // close and do not emit any more events. queued data is not sent. + if(!this.writable) return; + this.readable = false; + if(this.writable) { + this.writable = false; + this._q.length = 0; + this.emit('close'); + } +} + +define.classMethod('destroy', {callback: false, promise:false}); + +/** + * Stores a file from the file system to the GridFS database. + * + * @method + * @param {(string|Buffer|FileHandle)} file the file to store. + * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.writeFile = function (file, callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return writeFile(self, file, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + writeFile(self, file, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var writeFile = function(self, file, callback) { + if (typeof file === 'string') { + fs.open(file, 'r', function (err, fd) { + if(err) return callback(err); + self.writeFile(fd, callback); + }); + return; + } + + self.open(function (err, self) { + if(err) return callback(err, self); + + fs.fstat(file, function (err, stats) { + if(err) return callback(err, self); + + var offset = 0; + var index = 0; + + // Write a chunk + var writeChunk = function() { + // Allocate the buffer + var _buffer = new Buffer(self.chunkSize); + // Read the file + fs.read(file, _buffer, 0, _buffer.length, offset, function(err, bytesRead, data) { + if(err) return callback(err, self); + + offset = offset + bytesRead; + + // Create a new chunk for the data + var chunk = new Chunk(self, {n:index++}, self.writeConcern); + chunk.write(data.slice(0, bytesRead), function(err, chunk) { + if(err) return callback(err, self); + + chunk.save({}, function(err) { + if(err) return callback(err, self); + + self.position = self.position + bytesRead; + + // Point to current chunk + self.currentChunk = chunk; + + if(offset >= stats.size) { + fs.close(file); + self.close(function(err) { + if(err) return callback(err, self); + return callback(null, self); + }); + } else { + return process.nextTick(writeChunk); + } + }); + }); + }); + } + + // Process the first write + process.nextTick(writeChunk); + }); + }); +} + +define.classMethod('writeFile', {callback: true, promise:true}); + +/** + * Saves this file to the database. This will overwrite the old entry if it + * already exists. This will work properly only if mode was initialized to + * "w" or "w+". + * + * @method + * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.close = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return close(self, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + close(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var close = function(self, callback) { + if(self.mode[0] == "w") { + // Set up options + var options = self.writeConcern; + + if(self.currentChunk != null && self.currentChunk.position > 0) { + self.currentChunk.save({}, function(err) { + if(err && typeof callback == 'function') return callback(err); + + self.collection(function(err, files) { + if(err && typeof callback == 'function') return callback(err); + + // Build the mongo object + if(self.uploadDate != null) { + buildMongoObject(self, function(err, mongoObject) { + if(err) { + if(typeof callback == 'function') return callback(err); else throw err; + } + + files.save(mongoObject, options, function(err) { + if(typeof callback == 'function') + callback(err, mongoObject); + }); + }); + } else { + self.uploadDate = new Date(); + buildMongoObject(self, function(err, mongoObject) { + if(err) { + if(typeof callback == 'function') return callback(err); else throw err; + } + + files.save(mongoObject, options, function(err) { + if(typeof callback == 'function') + callback(err, mongoObject); + }); + }); + } + }); + }); + } else { + self.collection(function(err, files) { + if(err && typeof callback == 'function') return callback(err); + + self.uploadDate = new Date(); + buildMongoObject(self, function(err, mongoObject) { + if(err) { + if(typeof callback == 'function') return callback(err); else throw err; + } + + files.save(mongoObject, options, function(err) { + if(typeof callback == 'function') + callback(err, mongoObject); + }); + }); + }); + } + } else if(self.mode[0] == "r") { + if(typeof callback == 'function') + callback(null, null); + } else { + if(typeof callback == 'function') + callback(MongoError.create({message: f("Illegal mode %s", self.mode), driver:true})); + } +} + +define.classMethod('close', {callback: true, promise:true}); + +/** + * The collection callback format. + * @callback GridStore~collectionCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Collection} collection The collection from the command execution. + */ + +/** + * Retrieve this file's chunks collection. + * + * @method + * @param {GridStore~collectionCallback} callback the command callback. + * @return {Collection} + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.chunkCollection = function(callback) { + if(typeof callback == 'function') + return this.db.collection((this.root + ".chunks"), callback); + return this.db.collection((this.root + ".chunks")); +}; + +define.classMethod('chunkCollection', {callback: true, promise:false, returns: [Collection]}); + +/** + * Deletes all the chunks of this file in the database. + * + * @method + * @param {GridStore~resultCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.unlink = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return unlink(self, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + unlink(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var unlink = function(self, callback) { + deleteChunks(self, function(err) { + if(err!==null) { + err.message = "at deleteChunks: " + err.message; + return callback(err); + } + + self.collection(function(err, collection) { + if(err!==null) { + err.message = "at collection: " + err.message; + return callback(err); + } + + collection.remove({'_id':self.fileId}, self.writeConcern, function(err) { + callback(err, self); + }); + }); + }); +} + +define.classMethod('unlink', {callback: true, promise:true}); + +/** + * Retrieves the file collection associated with this object. + * + * @method + * @param {GridStore~collectionCallback} callback the command callback. + * @return {Collection} + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.collection = function(callback) { + if(typeof callback == 'function') + this.db.collection(this.root + ".files", callback); + return this.db.collection(this.root + ".files"); +}; + +define.classMethod('collection', {callback: true, promise:false, returns: [Collection]}); + +/** + * The readlines callback format. + * @callback GridStore~readlinesCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {string[]} strings The array of strings returned. + */ + +/** + * Read the entire file as a list of strings splitting by the provided separator. + * + * @method + * @param {string} [separator] The character to be recognized as the newline separator. + * @param {GridStore~readlinesCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.readlines = function(separator, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + separator = args.length ? args.shift() : "\n"; + separator = separator || "\n"; + + // We provided a callback leg + if(typeof callback == 'function') return readlines(self, separator, callback); + + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + readlines(self, separator, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var readlines = function(self, separator, callback) { + self.read(function(err, data) { + if(err) return callback(err); + + var items = data.toString().split(separator); + items = items.length > 0 ? items.splice(0, items.length - 1) : []; + for(var i = 0; i < items.length; i++) { + items[i] = items[i] + separator; + } + + callback(null, items); + }); +} + +define.classMethod('readlines', {callback: true, promise:true}); + +/** + * Deletes all the chunks of this file in the database if mode was set to "w" or + * "w+" and resets the read/write head to the initial position. + * + * @method + * @param {GridStore~resultCallback} [callback] this will be called after executing this method. The first parameter will contain null and the second one will contain a reference to this object. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.rewind = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return rewind(self, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + rewind(self, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var rewind = function(self, callback) { + if(self.currentChunk.chunkNumber != 0) { + if(self.mode[0] == "w") { + deleteChunks(self, function(err) { + if(err) return callback(err); + self.currentChunk = new Chunk(self, {'n': 0}, self.writeConcern); + self.position = 0; + callback(null, self); + }); + } else { + self.currentChunk(0, function(err, chunk) { + if(err) return callback(err); + self.currentChunk = chunk; + self.currentChunk.rewind(); + self.position = 0; + callback(null, self); + }); + } + } else { + self.currentChunk.rewind(); + self.position = 0; + callback(null, self); + } +} + +define.classMethod('rewind', {callback: true, promise:true}); + +/** + * The read callback format. + * @callback GridStore~readCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Buffer} data The data read from the GridStore object + */ + +/** + * Retrieves the contents of this file and advances the read/write head. Works with Buffers only. + * + * There are 3 signatures for this method: + * + * (callback) + * (length, callback) + * (length, buffer, callback) + * + * @method + * @param {number} [length] the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified. + * @param {(string|Buffer)} [buffer] a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method. + * @param {GridStore~readCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.read = function(length, buffer, callback) { + var self = this; + + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + length = args.length ? args.shift() : null; + buffer = args.length ? args.shift() : null; + // We provided a callback leg + if(typeof callback == 'function') return read(self, length, buffer, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + read(self, length, buffer, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +} + +var read = function(self, length, buffer, callback) { + // The data is a c-terminated string and thus the length - 1 + var finalLength = length == null ? self.length - self.position : length; + var finalBuffer = buffer == null ? new Buffer(finalLength) : buffer; + // Add a index to buffer to keep track of writing position or apply current index + finalBuffer._index = buffer != null && buffer._index != null ? buffer._index : 0; + + if((self.currentChunk.length() - self.currentChunk.position + finalBuffer._index) >= finalLength) { + var slice = self.currentChunk.readSlice(finalLength - finalBuffer._index); + // Copy content to final buffer + slice.copy(finalBuffer, finalBuffer._index); + // Update internal position + self.position = self.position + finalBuffer.length; + // Check if we don't have a file at all + if(finalLength == 0 && finalBuffer.length == 0) return callback(MongoError.create({message: "File does not exist", driver:true}), null); + // Else return data + return callback(null, finalBuffer); + } + + // Read the next chunk + slice = self.currentChunk.readSlice(self.currentChunk.length() - self.currentChunk.position); + // Copy content to final buffer + slice.copy(finalBuffer, finalBuffer._index); + // Update index position + finalBuffer._index += slice.length; + + // Load next chunk and read more + nthChunk(self, self.currentChunk.chunkNumber + 1, function(err, chunk) { + if(err) return callback(err); + + if(chunk.length() > 0) { + self.currentChunk = chunk; + self.read(length, finalBuffer, callback); + } else { + if(finalBuffer._index > 0) { + callback(null, finalBuffer) + } else { + callback(MongoError.create({message: "no chunks found for file, possibly corrupt", driver:true}), null); + } + } + }); +} + +define.classMethod('read', {callback: true, promise:true}); + +/** + * The tell callback format. + * @callback GridStore~tellCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {number} position The current read position in the GridStore. + */ + +/** + * Retrieves the position of the read/write head of this file. + * + * @method + * @param {number} [length] the number of characters to read. Reads all the characters from the read/write head to the EOF if not specified. + * @param {(string|Buffer)} [buffer] a string to hold temporary data. This is used for storing the string data read so far when recursively calling this method. + * @param {GridStore~tellCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.tell = function(callback) { + var self = this; + // We provided a callback leg + if(typeof callback == 'function') return callback(null, this.position); + // Return promise + return new self.promiseLibrary(function(resolve) { + resolve(self.position); + }); +}; + +define.classMethod('tell', {callback: true, promise:true}); + +/** + * The tell callback format. + * @callback GridStore~gridStoreCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {GridStore} gridStore The gridStore. + */ + +/** + * Moves the read/write head to a new location. + * + * There are 3 signatures for this method + * + * Seek Location Modes + * - **GridStore.IO_SEEK_SET**, **(default)** set the position from the start of the file. + * - **GridStore.IO_SEEK_CUR**, set the position from the current position in the file. + * - **GridStore.IO_SEEK_END**, set the position from the end of the file. + * + * @method + * @param {number} [position] the position to seek to + * @param {number} [seekLocation] seek mode. Use one of the Seek Location modes. + * @param {GridStore~gridStoreCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.prototype.seek = function(position, seekLocation, callback) { + var self = this; + + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + seekLocation = args.length ? args.shift() : null; + + // We provided a callback leg + if(typeof callback == 'function') return seek(self, position, seekLocation, callback); + // Return promise + return new self.promiseLibrary(function(resolve, reject) { + seek(self, position, seekLocation, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +} + +var seek = function(self, position, seekLocation, callback) { + // Seek only supports read mode + if(self.mode != 'r') { + return callback(MongoError.create({message: "seek is only supported for mode r", driver:true})) + } + + var seekLocationFinal = seekLocation == null ? GridStore.IO_SEEK_SET : seekLocation; + var finalPosition = position; + var targetPosition = 0; + + // Calculate the position + if(seekLocationFinal == GridStore.IO_SEEK_CUR) { + targetPosition = self.position + finalPosition; + } else if(seekLocationFinal == GridStore.IO_SEEK_END) { + targetPosition = self.length + finalPosition; + } else { + targetPosition = finalPosition; + } + + // Get the chunk + var newChunkNumber = Math.floor(targetPosition/self.chunkSize); + var seekChunk = function() { + nthChunk(self, newChunkNumber, function(err, chunk) { + if(err) return callback(err, null); + if(chunk == null) return callback(new Error('no chunk found')); + + // Set the current chunk + self.currentChunk = chunk; + self.position = targetPosition; + self.currentChunk.position = (self.position % self.chunkSize); + callback(err, self); + }); + }; + + seekChunk(); +} + +define.classMethod('seek', {callback: true, promise:true}); + +/** + * @ignore + */ +var _open = function(self, options, callback) { + var collection = self.collection(); + // Create the query + var query = self.referenceBy == REFERENCE_BY_ID ? {_id:self.fileId} : {filename:self.filename}; + query = null == self.fileId && self.filename == null ? null : query; + options.readPreference = self.readPreference; + + // Fetch the chunks + if(query != null) { + collection.findOne(query, options, function(err, doc) { + if(err) return error(err); + + // Check if the collection for the files exists otherwise prepare the new one + if(doc != null) { + self.fileId = doc._id; + // Prefer a new filename over the existing one if this is a write + self.filename = ((self.mode == 'r') || (self.filename == undefined)) ? doc.filename : self.filename; + self.contentType = doc.contentType; + self.internalChunkSize = doc.chunkSize; + self.uploadDate = doc.uploadDate; + self.aliases = doc.aliases; + self.length = doc.length; + self.metadata = doc.metadata; + self.internalMd5 = doc.md5; + } else if (self.mode != 'r') { + self.fileId = self.fileId == null ? new ObjectID() : self.fileId; + self.contentType = GridStore.DEFAULT_CONTENT_TYPE; + self.internalChunkSize = self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; + self.length = 0; + } else { + self.length = 0; + var txtId = self.fileId._bsontype == "ObjectID" ? self.fileId.toHexString() : self.fileId; + return error(MongoError.create({message: f("file with id %s not opened for writing", (self.referenceBy == REFERENCE_BY_ID ? txtId : self.filename)), driver:true}), self); + } + + // Process the mode of the object + if(self.mode == "r") { + nthChunk(self, 0, options, function(err, chunk) { + if(err) return error(err); + self.currentChunk = chunk; + self.position = 0; + callback(null, self); + }); + } else if(self.mode == "w" && doc) { + // Delete any existing chunks + deleteChunks(self, options, function(err) { + if(err) return error(err); + self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); + self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; + self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; + self.position = 0; + callback(null, self); + }); + } else if(self.mode == "w") { + self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); + self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; + self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; + self.position = 0; + callback(null, self); + } else if(self.mode == "w+") { + nthChunk(self, lastChunkNumber(self), options, function(err, chunk) { + if(err) return error(err); + // Set the current chunk + self.currentChunk = chunk == null ? new Chunk(self, {'n':0}, self.writeConcern) : chunk; + self.currentChunk.position = self.currentChunk.data.length(); + self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; + self.position = self.length; + callback(null, self); + }); + } + }); + } else { + // Write only mode + self.fileId = null == self.fileId ? new ObjectID() : self.fileId; + self.contentType = GridStore.DEFAULT_CONTENT_TYPE; + self.internalChunkSize = self.internalChunkSize == null ? Chunk.DEFAULT_CHUNK_SIZE : self.internalChunkSize; + self.length = 0; + + // No file exists set up write mode + if(self.mode == "w") { + // Delete any existing chunks + deleteChunks(self, options, function(err) { + if(err) return error(err); + self.currentChunk = new Chunk(self, {'n':0}, self.writeConcern); + self.contentType = self.options['content_type'] == null ? self.contentType : self.options['content_type']; + self.internalChunkSize = self.options['chunk_size'] == null ? self.internalChunkSize : self.options['chunk_size']; + self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; + self.position = 0; + callback(null, self); + }); + } else if(self.mode == "w+") { + nthChunk(self, lastChunkNumber(self), options, function(err, chunk) { + if(err) return error(err); + // Set the current chunk + self.currentChunk = chunk == null ? new Chunk(self, {'n':0}, self.writeConcern) : chunk; + self.currentChunk.position = self.currentChunk.data.length(); + self.metadata = self.options['metadata'] == null ? self.metadata : self.options['metadata']; + self.aliases = self.options['aliases'] == null ? self.aliases : self.options['aliases']; + self.position = self.length; + callback(null, self); + }); + } + } + + // only pass error to callback once + function error (err) { + if(error.err) return; + callback(error.err = err); + } +}; + +/** + * @ignore + */ +var writeBuffer = function(self, buffer, close, callback) { + if(typeof close === "function") { callback = close; close = null; } + var finalClose = typeof close == 'boolean' ? close : false; + + if(self.mode != "w") { + callback(MongoError.create({message: f("file with id %s not opened for writing", (self.referenceBy == REFERENCE_BY_ID ? self.referenceBy : self.filename)), driver:true}), null); + } else { + if(self.currentChunk.position + buffer.length >= self.chunkSize) { + // Write out the current Chunk and then keep writing until we have less data left than a chunkSize left + // to a new chunk (recursively) + var previousChunkNumber = self.currentChunk.chunkNumber; + var leftOverDataSize = self.chunkSize - self.currentChunk.position; + var firstChunkData = buffer.slice(0, leftOverDataSize); + var leftOverData = buffer.slice(leftOverDataSize); + // A list of chunks to write out + var chunksToWrite = [self.currentChunk.write(firstChunkData)]; + // If we have more data left than the chunk size let's keep writing new chunks + while(leftOverData.length >= self.chunkSize) { + // Create a new chunk and write to it + var newChunk = new Chunk(self, {'n': (previousChunkNumber + 1)}, self.writeConcern); + firstChunkData = leftOverData.slice(0, self.chunkSize); + leftOverData = leftOverData.slice(self.chunkSize); + // Update chunk number + previousChunkNumber = previousChunkNumber + 1; + // Write data + newChunk.write(firstChunkData); + // Push chunk to save list + chunksToWrite.push(newChunk); + } + + // Set current chunk with remaining data + self.currentChunk = new Chunk(self, {'n': (previousChunkNumber + 1)}, self.writeConcern); + // If we have left over data write it + if(leftOverData.length > 0) self.currentChunk.write(leftOverData); + + // Update the position for the gridstore + self.position = self.position + buffer.length; + // Total number of chunks to write + var numberOfChunksToWrite = chunksToWrite.length; + + for(var i = 0; i < chunksToWrite.length; i++) { + chunksToWrite[i].save({}, function(err) { + if(err) return callback(err); + + numberOfChunksToWrite = numberOfChunksToWrite - 1; + + if(numberOfChunksToWrite <= 0) { + // We care closing the file before returning + if(finalClose) { + return self.close(function(err) { + callback(err, self); + }); + } + + // Return normally + return callback(null, self); + } + }); + } + } else { + // Update the position for the gridstore + self.position = self.position + buffer.length; + // We have less data than the chunk size just write it and callback + self.currentChunk.write(buffer); + // We care closing the file before returning + if(finalClose) { + return self.close(function(err) { + callback(err, self); + }); + } + // Return normally + return callback(null, self); + } + } +}; + +/** + * Creates a mongoDB object representation of this object. + * + *

+ *        {
+ *          '_id' : , // {number} id for this file
+ *          'filename' : , // {string} name for this file
+ *          'contentType' : , // {string} mime type for this file
+ *          'length' : , // {number} size of this file?
+ *          'chunksize' : , // {number} chunk size used by this file
+ *          'uploadDate' : , // {Date}
+ *          'aliases' : , // {array of string}
+ *          'metadata' : , // {string}
+ *        }
+ *        
+ * + * @ignore + */ +var buildMongoObject = function(self, callback) { + // Calcuate the length + var mongoObject = { + '_id': self.fileId, + 'filename': self.filename, + 'contentType': self.contentType, + 'length': self.position ? self.position : 0, + 'chunkSize': self.chunkSize, + 'uploadDate': self.uploadDate, + 'aliases': self.aliases, + 'metadata': self.metadata + }; + + var md5Command = {filemd5:self.fileId, root:self.root}; + self.db.command(md5Command, function(err, results) { + if(err) return callback(err); + + mongoObject.md5 = results.md5; + callback(null, mongoObject); + }); +}; + +/** + * Gets the nth chunk of this file. + * @ignore + */ +var nthChunk = function(self, chunkNumber, options, callback) { + if(typeof options == 'function') { + callback = options; + options = {}; + } + + options = options || self.writeConcern; + options.readPreference = self.readPreference; + // Get the nth chunk + self.chunkCollection().findOne({'files_id':self.fileId, 'n':chunkNumber}, options, function(err, chunk) { + if(err) return callback(err); + + var finalChunk = chunk == null ? {} : chunk; + callback(null, new Chunk(self, finalChunk, self.writeConcern)); + }); +}; + +/** + * @ignore + */ +var lastChunkNumber = function(self) { + return Math.floor((self.length ? self.length - 1 : 0)/self.chunkSize); +}; + +/** + * Deletes all the chunks of this file in the database. + * + * @ignore + */ +var deleteChunks = function(self, options, callback) { + if(typeof options == 'function') { + callback = options; + options = {}; + } + + options = options || self.writeConcern; + + if(self.fileId != null) { + self.chunkCollection().remove({'files_id':self.fileId}, options, function(err) { + if(err) return callback(err, false); + callback(null, true); + }); + } else { + callback(null, true); + } +}; + +/** +* The collection to be used for holding the files and chunks collection. +* +* @classconstant DEFAULT_ROOT_COLLECTION +**/ +GridStore.DEFAULT_ROOT_COLLECTION = 'fs'; + +/** +* Default file mime type +* +* @classconstant DEFAULT_CONTENT_TYPE +**/ +GridStore.DEFAULT_CONTENT_TYPE = 'binary/octet-stream'; + +/** +* Seek mode where the given length is absolute. +* +* @classconstant IO_SEEK_SET +**/ +GridStore.IO_SEEK_SET = 0; + +/** +* Seek mode where the given length is an offset to the current read/write head. +* +* @classconstant IO_SEEK_CUR +**/ +GridStore.IO_SEEK_CUR = 1; + +/** +* Seek mode where the given length is an offset to the end of the file. +* +* @classconstant IO_SEEK_END +**/ +GridStore.IO_SEEK_END = 2; + +/** + * Checks if a file exists in the database. + * + * @method + * @static + * @param {Db} db the database to query. + * @param {string} name The name of the file to look for. + * @param {string} [rootCollection] The root collection that holds the files and chunks collection. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {GridStore~resultCallback} [callback] result from exists. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.exist = function(db, fileIdObject, rootCollection, options, callback) { + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + rootCollection = args.length ? args.shift() : null; + options = args.length ? args.shift() : {}; + options = options || {}; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // We provided a callback leg + if(typeof callback == 'function') return exists(db, fileIdObject, rootCollection, options, callback); + // Return promise + return new promiseLibrary(function(resolve, reject) { + exists(db, fileIdObject, rootCollection, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var exists = function(db, fileIdObject, rootCollection, options, callback) { + // Establish read preference + var readPreference = options.readPreference || ReadPreference.PRIMARY; + // Fetch collection + var rootCollectionFinal = rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; + db.collection(rootCollectionFinal + ".files", function(err, collection) { + if(err) return callback(err); + + // Build query + var query = (typeof fileIdObject == 'string' || Object.prototype.toString.call(fileIdObject) == '[object RegExp]' ) + ? {'filename':fileIdObject} + : {'_id':fileIdObject}; // Attempt to locate file + + // We have a specific query + if(fileIdObject != null + && typeof fileIdObject == 'object' + && Object.prototype.toString.call(fileIdObject) != '[object RegExp]') { + query = fileIdObject; + } + + // Check if the entry exists + collection.findOne(query, {readPreference:readPreference}, function(err, item) { + if(err) return callback(err); + callback(null, item == null ? false : true); + }); + }); +} + +define.staticMethod('exist', {callback: true, promise:true}); + +/** + * Gets the list of files stored in the GridFS. + * + * @method + * @static + * @param {Db} db the database to query. + * @param {string} [rootCollection] The root collection that holds the files and chunks collection. Defaults to **{GridStore.DEFAULT_ROOT_COLLECTION}**. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {GridStore~resultCallback} [callback] result from exists. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.list = function(db, rootCollection, options, callback) { + var args = Array.prototype.slice.call(arguments, 1); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + rootCollection = args.length ? args.shift() : null; + options = args.length ? args.shift() : {}; + options = options || {}; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // We provided a callback leg + if(typeof callback == 'function') return list(db, rootCollection, options, callback); + // Return promise + return new promiseLibrary(function(resolve, reject) { + list(db, rootCollection, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var list = function(db, rootCollection, options, callback) { + // Ensure we have correct values + if(rootCollection != null && typeof rootCollection == 'object') { + options = rootCollection; + rootCollection = null; + } + + // Establish read preference + var readPreference = options.readPreference || ReadPreference.PRIMARY; + // Check if we are returning by id not filename + var byId = options['id'] != null ? options['id'] : false; + // Fetch item + var rootCollectionFinal = rootCollection != null ? rootCollection : GridStore.DEFAULT_ROOT_COLLECTION; + var items = []; + db.collection((rootCollectionFinal + ".files"), function(err, collection) { + if(err) return callback(err); + + collection.find({}, {readPreference:readPreference}, function(err, cursor) { + if(err) return callback(err); + + cursor.each(function(err, item) { + if(item != null) { + items.push(byId ? item._id : item.filename); + } else { + callback(err, items); + } + }); + }); + }); +} + +define.staticMethod('list', {callback: true, promise:true}); + +/** + * Reads the contents of a file. + * + * This method has the following signatures + * + * (db, name, callback) + * (db, name, length, callback) + * (db, name, length, offset, callback) + * (db, name, length, offset, options, callback) + * + * @method + * @static + * @param {Db} db the database to query. + * @param {string} name The name of the file. + * @param {number} [length] The size of data to read. + * @param {number} [offset] The offset from the head of the file of which to start reading from. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {GridStore~readCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.read = function(db, name, length, offset, options, callback) { + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + length = args.length ? args.shift() : null; + offset = args.length ? args.shift() : null; + options = args.length ? args.shift() : null; + options = options || {}; + + // Get the promiseLibrary + var promiseLibrary = options ? options.promiseLibrary : null; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // We provided a callback leg + if(typeof callback == 'function') return readStatic(db, name, length, offset, options, callback); + // Return promise + return new promiseLibrary(function(resolve, reject) { + readStatic(db, name, length, offset, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var readStatic = function(db, name, length, offset, options, callback) { + new GridStore(db, name, "r", options).open(function(err, gridStore) { + if(err) return callback(err); + // Make sure we are not reading out of bounds + if(offset && offset >= gridStore.length) return callback("offset larger than size of file", null); + if(length && length > gridStore.length) return callback("length is larger than the size of the file", null); + if(offset && length && (offset + length) > gridStore.length) return callback("offset and length is larger than the size of the file", null); + + if(offset != null) { + gridStore.seek(offset, function(err, gridStore) { + if(err) return callback(err); + gridStore.read(length, callback); + }); + } else { + gridStore.read(length, callback); + } + }); +} + +define.staticMethod('read', {callback: true, promise:true}); + +/** + * Read the entire file as a list of strings splitting by the provided separator. + * + * @method + * @static + * @param {Db} db the database to query. + * @param {(String|object)} name the name of the file. + * @param {string} [separator] The character to be recognized as the newline separator. + * @param {object} [options=null] Optional settings. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {GridStore~readlinesCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.readlines = function(db, name, separator, options, callback) { + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + separator = args.length ? args.shift() : null; + options = args.length ? args.shift() : null; + options = options || {}; + + // Get the promiseLibrary + var promiseLibrary = options ? options.promiseLibrary : null; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // We provided a callback leg + if(typeof callback == 'function') return readlinesStatic(db, name, separator, options, callback); + // Return promise + return new promiseLibrary(function(resolve, reject) { + readlinesStatic(db, name, separator, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var readlinesStatic = function(db, name, separator, options, callback) { + var finalSeperator = separator == null ? "\n" : separator; + new GridStore(db, name, "r", options).open(function(err, gridStore) { + if(err) return callback(err); + gridStore.readlines(finalSeperator, callback); + }); +} + +define.staticMethod('readlines', {callback: true, promise:true}); + +/** + * Deletes the chunks and metadata information of a file from GridFS. + * + * @method + * @static + * @param {Db} db The database to query. + * @param {(string|array)} names The name/names of the files to delete. + * @param {object} [options=null] Optional settings. + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {GridStore~resultCallback} [callback] the command callback. + * @return {Promise} returns Promise if no callback passed + * @deprecated Use GridFSBucket API instead + */ +GridStore.unlink = function(db, names, options, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 2); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + options = args.length ? args.shift() : {}; + options = options || {}; + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // We provided a callback leg + if(typeof callback == 'function') return unlinkStatic(self, db, names, options, callback); + + // Return promise + return new promiseLibrary(function(resolve, reject) { + unlinkStatic(self, db, names, options, function(err, r) { + if(err) return reject(err); + resolve(r); + }) + }); +}; + +var unlinkStatic = function(self, db, names, options, callback) { + // Get the write concern + var writeConcern = _getWriteConcern(db, options); + + // List of names + if(names.constructor == Array) { + var tc = 0; + for(var i = 0; i < names.length; i++) { + ++tc; + GridStore.unlink(db, names[i], options, function() { + if(--tc == 0) { + callback(null, self); + } + }); + } + } else { + new GridStore(db, names, "w", options).open(function(err, gridStore) { + if(err) return callback(err); + deleteChunks(gridStore, function(err) { + if(err) return callback(err); + gridStore.collection(function(err, collection) { + if(err) return callback(err); + collection.remove({'_id':gridStore.fileId}, writeConcern, function(err) { + callback(err, self); + }); + }); + }); + }); + } +} + +define.staticMethod('unlink', {callback: true, promise:true}); + +/** + * @ignore + */ +var _writeNormal = function(self, data, close, callback) { + // If we have a buffer write it using the writeBuffer method + if(Buffer.isBuffer(data)) { + return writeBuffer(self, data, close, callback); + } else { + return writeBuffer(self, new Buffer(data, 'binary'), close, callback); + } +} + +/** + * @ignore + */ +var _setWriteConcernHash = function(options) { + var finalOptions = {}; + if(options.w != null) finalOptions.w = options.w; + if(options.journal == true) finalOptions.j = options.journal; + if(options.j == true) finalOptions.j = options.j; + if(options.fsync == true) finalOptions.fsync = options.fsync; + if(options.wtimeout != null) finalOptions.wtimeout = options.wtimeout; + return finalOptions; +} + +/** + * @ignore + */ +var _getWriteConcern = function(self, options) { + // Final options + var finalOptions = {w:1}; + options = options || {}; + + // Local options verification + if(options.w != null || typeof options.j == 'boolean' || typeof options.journal == 'boolean' || typeof options.fsync == 'boolean') { + finalOptions = _setWriteConcernHash(options); + } else if(options.safe != null && typeof options.safe == 'object') { + finalOptions = _setWriteConcernHash(options.safe); + } else if(typeof options.safe == "boolean") { + finalOptions = {w: (options.safe ? 1 : 0)}; + } else if(self.options.w != null || typeof self.options.j == 'boolean' || typeof self.options.journal == 'boolean' || typeof self.options.fsync == 'boolean') { + finalOptions = _setWriteConcernHash(self.options); + } else if(self.safe && (self.safe.w != null || typeof self.safe.j == 'boolean' || typeof self.safe.journal == 'boolean' || typeof self.safe.fsync == 'boolean')) { + finalOptions = _setWriteConcernHash(self.safe); + } else if(typeof self.safe == "boolean") { + finalOptions = {w: (self.safe ? 1 : 0)}; + } + + // Ensure we don't have an invalid combination of write concerns + if(finalOptions.w < 1 + && (finalOptions.journal == true || finalOptions.j == true || finalOptions.fsync == true)) throw MongoError.create({message: "No acknowledgement using w < 1 cannot be combined with journal:true or fsync:true", driver:true}); + + // Return the options + return finalOptions; +} + +/** + * Create a new GridStoreStream instance (INTERNAL TYPE, do not instantiate directly) + * + * @class + * @extends external:Duplex + * @return {GridStoreStream} a GridStoreStream instance. + * @deprecated Use GridFSBucket API instead + */ +var GridStoreStream = function(gs) { + // Initialize the duplex stream + Duplex.call(this); + + // Get the gridstore + this.gs = gs; + + // End called + this.endCalled = false; + + // If we have a seek + this.totalBytesToRead = this.gs.length - this.gs.position; + this.seekPosition = this.gs.position; +} + +// +// Inherit duplex +inherits(GridStoreStream, Duplex); + +GridStoreStream.prototype._pipe = GridStoreStream.prototype.pipe; + +// Set up override +GridStoreStream.prototype.pipe = function(destination) { + var self = this; + + // Only open gridstore if not already open + if(!self.gs.isOpen) { + self.gs.open(function(err) { + if(err) return self.emit('error', err); + self.totalBytesToRead = self.gs.length - self.gs.position; + self._pipe.apply(self, [destination]); + }); + } else { + self.totalBytesToRead = self.gs.length - self.gs.position; + self._pipe.apply(self, [destination]); + } + + return destination; +} + +// Called by stream +GridStoreStream.prototype._read = function() { + var self = this; + + var read = function() { + // Read data + self.gs.read(length, function(err, buffer) { + if(err && !self.endCalled) return self.emit('error', err); + + // Stream is closed + if(self.endCalled || buffer == null) return self.push(null); + // Remove bytes read + if(buffer.length <= self.totalBytesToRead) { + self.totalBytesToRead = self.totalBytesToRead - buffer.length; + self.push(buffer); + } else if(buffer.length > self.totalBytesToRead) { + self.totalBytesToRead = self.totalBytesToRead - buffer._index; + self.push(buffer.slice(0, buffer._index)); + } + + // Finished reading + if(self.totalBytesToRead <= 0) { + self.endCalled = true; + } + }); + } + + // Set read length + var length = self.gs.length < self.gs.chunkSize ? self.gs.length - self.seekPosition : self.gs.chunkSize; + if(!self.gs.isOpen) { + self.gs.open(function(err) { + self.totalBytesToRead = self.gs.length - self.gs.position; + if(err) return self.emit('error', err); + read(); + }); + } else { + read(); + } +} + +GridStoreStream.prototype.destroy = function() { + this.pause(); + this.endCalled = true; + this.gs.close(); + this.emit('end'); +} + +GridStoreStream.prototype.write = function(chunk) { + var self = this; + if(self.endCalled) return self.emit('error', MongoError.create({message: 'attempting to write to stream after end called', driver:true})) + // Do we have to open the gridstore + if(!self.gs.isOpen) { + self.gs.open(function() { + self.gs.isOpen = true; + self.gs.write(chunk, function() { + process.nextTick(function() { + self.emit('drain'); + }); + }); + }); + return false; + } else { + self.gs.write(chunk, function() { + self.emit('drain'); + }); + return true; + } +} + +GridStoreStream.prototype.end = function(chunk, encoding, callback) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + callback = args.pop(); + if(typeof callback != 'function') args.push(callback); + chunk = args.length ? args.shift() : null; + encoding = args.length ? args.shift() : null; + self.endCalled = true; + + if(chunk) { + self.gs.write(chunk, function() { + self.gs.close(function() { + if(typeof callback == 'function') callback(); + self.emit('end') + }); + }); + } + + self.gs.close(function() { + if(typeof callback == 'function') callback(); + self.emit('end') + }); +} + +/** + * The read() method pulls some data out of the internal buffer and returns it. If there is no data available, then it will return null. + * @function external:Duplex#read + * @param {number} size Optional argument to specify how much data to read. + * @return {(String | Buffer | null)} + */ + +/** + * Call this function to cause the stream to return strings of the specified encoding instead of Buffer objects. + * @function external:Duplex#setEncoding + * @param {string} encoding The encoding to use. + * @return {null} + */ + +/** + * This method will cause the readable stream to resume emitting data events. + * @function external:Duplex#resume + * @return {null} + */ + +/** + * This method will cause a stream in flowing-mode to stop emitting data events. Any data that becomes available will remain in the internal buffer. + * @function external:Duplex#pause + * @return {null} + */ + +/** + * This method pulls all the data out of a readable stream, and writes it to the supplied destination, automatically managing the flow so that the destination is not overwhelmed by a fast readable stream. + * @function external:Duplex#pipe + * @param {Writable} destination The destination for writing data + * @param {object} [options] Pipe options + * @return {null} + */ + +/** + * This method will remove the hooks set up for a previous pipe() call. + * @function external:Duplex#unpipe + * @param {Writable} [destination] The destination for writing data + * @return {null} + */ + +/** + * This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party. + * @function external:Duplex#unshift + * @param {(Buffer|string)} chunk Chunk of data to unshift onto the read queue. + * @return {null} + */ + +/** + * Versions of Node prior to v0.10 had streams that did not implement the entire Streams API as it is today. (See "Compatibility" below for more information.) + * @function external:Duplex#wrap + * @param {Stream} stream An "old style" readable stream. + * @return {null} + */ + +/** + * This method writes some data to the underlying system, and calls the supplied callback once the data has been fully handled. + * @function external:Duplex#write + * @param {(string|Buffer)} chunk The data to write + * @param {string} encoding The encoding, if chunk is a String + * @param {function} callback Callback for when this chunk of data is flushed + * @return {boolean} + */ + +/** + * Call this method when no more data will be written to the stream. If supplied, the callback is attached as a listener on the finish event. + * @function external:Duplex#end + * @param {(string|Buffer)} chunk The data to write + * @param {string} encoding The encoding, if chunk is a String + * @param {function} callback Callback for when this chunk of data is flushed + * @return {null} + */ + +/** + * GridStoreStream stream data event, fired for each document in the cursor. + * + * @event GridStoreStream#data + * @type {object} + */ + +/** + * GridStoreStream stream end event + * + * @event GridStoreStream#end + * @type {null} + */ + +/** + * GridStoreStream stream close event + * + * @event GridStoreStream#close + * @type {null} + */ + +/** + * GridStoreStream stream readable event + * + * @event GridStoreStream#readable + * @type {null} + */ + +/** + * GridStoreStream stream drain event + * + * @event GridStoreStream#drain + * @type {null} + */ + +/** + * GridStoreStream stream finish event + * + * @event GridStoreStream#finish + * @type {null} + */ + +/** + * GridStoreStream stream pipe event + * + * @event GridStoreStream#pipe + * @type {null} + */ + +/** + * GridStoreStream stream unpipe event + * + * @event GridStoreStream#unpipe + * @type {null} + */ + +/** + * GridStoreStream stream error event + * + * @event GridStoreStream#error + * @type {null} + */ + +/** + * @ignore + */ +module.exports = GridStore; diff --git a/node_modules/mongodb/lib/metadata.js b/node_modules/mongoose/node_modules/mongodb/lib/metadata.js similarity index 100% rename from node_modules/mongodb/lib/metadata.js rename to node_modules/mongoose/node_modules/mongodb/lib/metadata.js diff --git a/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js b/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js new file mode 100644 index 0000000..76fd309 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js @@ -0,0 +1,531 @@ +"use strict"; + +var parse = require('./url_parser') + , Server = require('./server') + , Mongos = require('./mongos') + , ReplSet = require('./replset') + , EventEmitter = require('events').EventEmitter + , inherits = require('util').inherits + , Define = require('./metadata') + , ReadPreference = require('./read_preference') + , Logger = require('mongodb-core').Logger + , MongoError = require('mongodb-core').MongoError + , Db = require('./db') + , f = require('util').format + , assign = require('./utils').assign + , shallowClone = require('./utils').shallowClone + , authenticate = require('./authenticate'); + +/** + * @fileOverview The **MongoClient** class is a class that allows for making Connections to MongoDB. + * + * @example + * var MongoClient = require('mongodb').MongoClient, + * test = require('assert'); + * // Connection url + * var url = 'mongodb://localhost:27017/test'; + * // Connect using MongoClient + * MongoClient.connect(url, function(err, db) { + * // Get an additional db + * db.close(); + * }); + */ +var validOptionNames = ['poolSize', 'ssl', 'sslValidate', 'sslCA', 'sslCert', 'ciphers', 'ecdhCurve', + 'sslKey', 'sslPass', 'sslCRL', 'autoReconnect', 'noDelay', 'keepAlive', 'connectTimeoutMS', 'family', + 'socketTimeoutMS', 'reconnectTries', 'reconnectInterval', 'ha', 'haInterval', + 'replicaSet', 'secondaryAcceptableLatencyMS', 'acceptableLatencyMS', + 'connectWithNoPrimary', 'authSource', 'w', 'wtimeout', 'j', 'forceServerObjectId', + 'serializeFunctions', 'ignoreUndefined', 'raw', 'bufferMaxEntries', + 'readPreference', 'pkFactory', 'promiseLibrary', 'readConcern', 'maxStalenessSeconds', + 'loggerLevel', 'logger', 'promoteValues', 'promoteBuffers', 'promoteLongs', + 'domainsEnabled', 'keepAliveInitialDelay', 'checkServerIdentity', 'validateOptions', 'appname', 'auth']; +var ignoreOptionNames = ['native_parser']; +var legacyOptionNames = ['server', 'replset', 'replSet', 'mongos', 'db']; + +function validOptions(options) { + var _validOptions = validOptionNames.concat(legacyOptionNames); + + for(var name in options) { + if(ignoreOptionNames.indexOf(name) != -1) { + continue; + } + + if(_validOptions.indexOf(name) == -1 && options.validateOptions) { + return new MongoError(f('option %s is not supported', name)); + } else if(_validOptions.indexOf(name) == -1) { + console.warn(f('the options [%s] is not supported', name)); + } + + if(legacyOptionNames.indexOf(name) != -1) { + console.warn(f('the server/replset/mongos options are deprecated, ' + + 'all their options are supported at the top level of the options object [%s]', validOptionNames)); + } + } +} + +/** + * Creates a new MongoClient instance + * @class + * @return {MongoClient} a MongoClient instance. + */ +function MongoClient() { + if(!(this instanceof MongoClient)) return new MongoClient(); + + // Set up event emitter + EventEmitter.call(this); + + /** + * The callback format for results + * @callback MongoClient~connectCallback + * @param {MongoError} error An error instance representing the error during the execution. + * @param {Db} db The connected database. + */ + + /** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @param {string} url The connection URI string + * @param {object} [options] Optional settings. + * @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool. + * @param {boolean} [options.ssl=false] Enable SSL connection. + * @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer + * @param {Buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer + * @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer + * @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer + * @param {string} [options.sslPass=undefined] SSL Certificate pass phrase + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.family=4] Version of IP stack. Defaults to 4. + * @param {number} [options.keepAlive=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket. + * @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting + * @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies. + * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry + * @param {string} [options.replicaSet=undefined] The Replicaset set name + * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection + * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection. + * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available + * @param {string} [options.authSource=undefined] Define the database to authenticate against + * @param {string} [options.auth.user=undefined] The username for auth + * @param {string} [options.auth.password=undefined] The password for auth + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) + * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections. + * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) + * @param {object} [options.logger=undefined] Custom logger object + * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness. + * @param {MongoClient~connectCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ + this.connect = MongoClient.connect; +} + +/** + * @ignore + */ +inherits(MongoClient, EventEmitter); + +var define = MongoClient.define = new Define('MongoClient', MongoClient, false); + +/** + * Connect to MongoDB using a url as documented at + * + * docs.mongodb.org/manual/reference/connection-string/ + * + * Note that for replicasets the replicaSet query parameter is required in the 2.0 driver + * + * @method + * @static + * @param {string} url The connection URI string + * @param {object} [options] Optional settings. + * @param {number} [options.poolSize=5] poolSize The maximum size of the individual server pool. + * @param {boolean} [options.ssl=false] Enable SSL connection. + * @param {Buffer} [options.sslCA=undefined] SSL Certificate store binary buffer + * @param {Buffer} [options.sslCRL=undefined] SSL Certificate revocation list binary buffer + * @param {Buffer} [options.sslCert=undefined] SSL Certificate binary buffer + * @param {Buffer} [options.sslKey=undefined] SSL Key file binary buffer + * @param {string} [options.sslPass=undefined] SSL Certificate pass phrase + * @param {boolean|function} [options.checkServerIdentity=true] Ensure we check server identify during SSL, set to false to disable checking. Only works for Node 0.12.x or higher. You can pass in a boolean or your own checkServerIdentity override function. + * @param {boolean} [options.autoReconnect=true] Enable autoReconnect for single server instances + * @param {boolean} [options.noDelay=true] TCP Connection no delay + * @param {number} [options.family=4] Version of IP stack. Defaults to 4. + * @param {boolean} [options.keepAlive=30000] The number of milliseconds to wait before initiating keepAlive on the TCP socket. + * @param {number} [options.connectTimeoutMS=30000] TCP Connection timeout setting + * @param {number} [options.socketTimeoutMS=360000] TCP Socket timeout setting + * @param {number} [options.reconnectTries=30] Server attempt to reconnect #times + * @param {number} [options.reconnectInterval=1000] Server will wait # milliseconds between retries + * @param {boolean} [options.ha=true] Control if high availability monitoring runs for Replicaset or Mongos proxies. + * @param {number} [options.haInterval=10000] The High availability period for replicaset inquiry + * @param {string} [options.replicaSet=undefined] The Replicaset set name + * @param {number} [options.secondaryAcceptableLatencyMS=15] Cutoff latency point in MS for Replicaset member selection + * @param {number} [options.acceptableLatencyMS=15] Cutoff latency point in MS for Mongos proxies selection. + * @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available + * @param {string} [options.authSource=undefined] Define the database to authenticate against + * @param {string} [options.auth.user=undefined] The username for auth + * @param {string} [options.auth.password=undefined] The password for auth + * @param {(number|string)} [options.w=null] The write concern. + * @param {number} [options.wtimeout=null] The write concern timeout. + * @param {boolean} [options.j=false] Specify a journal write concern. + * @param {boolean} [options.forceServerObjectId=false] Force server to assign _id values instead of driver. + * @param {boolean} [options.serializeFunctions=false] Serialize functions on any object. + * @param {Boolean} [options.ignoreUndefined=false] Specify if the BSON serializer should ignore undefined fields. + * @param {boolean} [options.raw=false] Return document results as raw BSON buffers. + * @param {boolean} [options.promoteLongs=true] Promotes Long values to number if they fit inside the 53 bits resolution. + * @param {boolean} [options.promoteBuffers=false] Promotes Binary BSON values to native Node Buffers. + * @param {boolean} [options.promoteValues=true] Promotes BSON values to native types where possible, set to false to only receive wrapper types. + * @param {number} [options.bufferMaxEntries=-1] Sets a cap on how many operations the driver will buffer up before giving up on getting a working connection, default is -1 which is unlimited. + * @param {(ReadPreference|string)} [options.readPreference=null] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST). + * @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit. + * @param {object} [options.pkFactory=null] A primary key factory object for generation of custom _id keys. + * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible + * @param {object} [options.readConcern=null] Specify a read concern for the collection. (only MongoDB 3.2 or higher supported) + * @param {string} [options.readConcern.level='local'] Specify a read concern level for the collection operations, one of [local|majority]. (only MongoDB 3.2 or higher supported) + * @param {number} [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + * @param {string} [options.appname=undefined] The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections. + * @param {string} [options.loggerLevel=undefined] The logging level (error/warn/info/debug) + * @param {object} [options.logger=undefined] Custom logger object + * @param {object} [options.validateOptions=false] Validate MongoClient passed in options for correctness. + * @param {MongoClient~connectCallback} [callback] The command result callback + * @return {Promise} returns Promise if no callback passed + */ +MongoClient.connect = function(url, options, callback) { + var args = Array.prototype.slice.call(arguments, 1); + callback = typeof args[args.length - 1] == 'function' ? args.pop() : null; + options = args.length ? args.shift() : null; + options = options || {}; + var self = this; + + // Validate options object + var err = validOptions(options); + + // Get the promiseLibrary + var promiseLibrary = options.promiseLibrary; + + // No promise library selected fall back + if(!promiseLibrary) { + promiseLibrary = typeof global.Promise == 'function' ? + global.Promise : require('es6-promise').Promise; + } + + // Return a promise + if(typeof callback != 'function') { + return new promiseLibrary(function(resolve, reject) { + // Did we have a validation error + if(err) return reject(err); + // Attempt to connect + connect(self, url, options, function(err, db) { + if(err) return reject(err); + resolve(db); + }); + }); + } + + // Did we have a validation error + if(err) return callback(err); + // Fallback to callback based connect + connect(self, url, options, callback); +} + +define.staticMethod('connect', {callback: true, promise:true}); + +var mergeOptions = function(target, source, flatten) { + for(var name in source) { + if(source[name] && typeof source[name] == 'object' && flatten) { + target = mergeOptions(target, source[name], flatten); + } else { + target[name] = source[name]; + } + } + + return target; +} + +var createUnifiedOptions = function(finalOptions, options) { + var childOptions = ['mongos', 'server', 'db' + , 'replset', 'db_options', 'server_options', 'rs_options', 'mongos_options']; + var noMerge = ['readconcern']; + + for(var name in options) { + if(noMerge.indexOf(name.toLowerCase()) != -1) { + finalOptions[name] = options[name]; + } else if(childOptions.indexOf(name.toLowerCase()) != -1) { + finalOptions = mergeOptions(finalOptions, options[name], false); + } else { + if(options[name] && typeof options[name] == 'object' && !Buffer.isBuffer(options[name]) && !Array.isArray(options[name])) { + finalOptions = mergeOptions(finalOptions, options[name], true); + } else { + finalOptions[name] = options[name]; + } + } + } + + return finalOptions; +} + +function translateOptions(options) { + // If we have a readPreference passed in by the db options + if(typeof options.readPreference == 'string' || typeof options.read_preference == 'string') { + options.readPreference = new ReadPreference(options.readPreference || options.read_preference); + } + + // Do we have readPreference tags, add them + if(options.readPreference && (options.readPreferenceTags || options.read_preference_tags)) { + options.readPreference.tags = options.readPreferenceTags || options.read_preference_tags; + } + + // Do we have maxStalenessSeconds + if(options.maxStalenessSeconds) { + options.readPreference.maxStalenessSeconds = options.maxStalenessSeconds; + } + + // Set the socket and connection timeouts + if(options.socketTimeoutMS == null) options.socketTimeoutMS = 360000; + if(options.connectTimeoutMS == null) options.connectTimeoutMS = 30000; + + // Create server instances + return options.servers.map(function(serverObj) { + return serverObj.domain_socket ? + new Server(serverObj.domain_socket, 27017, options) + : new Server(serverObj.host, serverObj.port, options); + }); +} + +// +// Collect all events in order from SDAM +// +function collectEvents(self, db) { + var collectedEvents = []; + + if(self instanceof MongoClient) { + var events = ["timeout", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening', + 'topologyClosed', 'topologyDescriptionChanged', 'joined', 'left', 'ping', 'ha', 'all', 'fullsetup']; + events.forEach(function(event) { + db.serverConfig.on(event, function(object1, object2) { + collectedEvents.push({ + event: event, object1: object1, object2: object2 + }); + }); + }); + } + + return collectedEvents; +} + +// +// Replay any events due to single server connection switching to Mongos +// +function replayEvents(self, events) { + for(var i = 0; i < events.length; i++) { + self.emit(events[i].event, events[i].object1, events[i].object2); + } +} + +function relayEvents(self, db) { + if(self instanceof MongoClient) { + var events = ["timeout", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted', + 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening', + 'topologyClosed', 'topologyDescriptionChanged', 'joined', 'left', 'ping', 'ha', 'all', 'fullsetup']; + events.forEach(function(event) { + db.serverConfig.on(event, function(object1, object2) { + self.emit(event, object1, object2); + }); + }); + } +} + +function createReplicaset(self, options, callback) { + // Set default options + var servers = translateOptions(options); + // Create Db instance + var db = new Db(options.dbName, new ReplSet(servers, options), options); + // Propegate the events to the client + relayEvents(self, db); + // Open the connection + db.open(callback); +} + +function createMongos(self, options, callback) { + // Set default options + var servers = translateOptions(options); + // Create Db instance + var db = new Db(options.dbName, new Mongos(servers, options), options) + // Propegate the events to the client + relayEvents(self, db); + // Open the connection + db.open(callback); +} + +function createServer(self, options, callback) { + // Set default options + var servers = translateOptions(options); + // Create db instance + var db = new Db(options.dbName, servers[0], options); + // Propegate the events to the client + var collectedEvents = collectEvents(self, db); + // Create Db instance + db.open(function(err, db) { + if(err) return callback(err); + // Check if we are really speaking to a mongos + var ismaster = db.serverConfig.lastIsMaster(); + + // Do we actually have a mongos + if(ismaster && ismaster.msg == 'isdbgrid') { + // Destroy the current connection + db.close(); + // Create mongos connection instead + return createMongos(self, options, callback); + } + + // Fire all the events + replayEvents(self, collectedEvents); + // Propegate the events to the client + relayEvents(self, db); + // Otherwise callback + callback(err, db); + }); +} + +function connectHandler(options, callback) { + return function (err, db) { + if(err) { + return process.nextTick(function() { + try { + callback(err, null); + } catch (err) { + if(db) db.close(); + throw err + } + }); + } + + // No authentication just reconnect + if(!options.auth) { + return process.nextTick(function() { + try { + callback(err, db); + } catch (err) { + if(db) db.close(); + throw err + } + }) + } + + // What db to authenticate against + var authentication_db = db; + if(options.authSource) { + authentication_db = db.db(options.authSource); + } + + // Authenticate + authenticate(authentication_db, options.user, options.password, options, function(err, success) { + if(success){ + process.nextTick(function() { + try { + callback(null, db); + } catch (err) { + if(db) db.close(); + throw err + } + }); + } else { + if(db) db.close(); + process.nextTick(function() { + try { + callback(err ? err : new Error('Could not authenticate user ' + options.auth[0]), null); + } catch (err) { + if(db) db.close(); + throw err + } + }); + } + }); + } +} + +/* + * Connect using MongoClient + */ +var connect = function(self, url, options, callback) { + options = options || {}; + options = shallowClone(options); + + // If callback is null throw an exception + if(callback == null) { + throw new Error("no callback function provided"); + } + + // Get a logger for MongoClient + var logger = Logger('MongoClient', options); + + parse(url, options, function(err, object) { + if (err) return callback(err); + + // Parse the string + var _finalOptions = createUnifiedOptions({}, object); + _finalOptions = mergeOptions(_finalOptions, object, false); + _finalOptions = createUnifiedOptions(_finalOptions, options); + + // Check if we have connection and socket timeout set + if(_finalOptions.socketTimeoutMS == null) _finalOptions.socketTimeoutMS = 360000; + if(_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 30000; + + if (_finalOptions.db_options && _finalOptions.db_options.auth) { + delete _finalOptions.db_options.auth; + } + + // Failure modes + if(object.servers.length == 0) { + throw new Error("connection string must contain at least one seed host"); + } + + // Do we have a replicaset then skip discovery and go straight to connectivity + if(_finalOptions.replicaSet || _finalOptions.rs_name) { + return createReplicaset(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); + } else if(object.servers.length > 1) { + return createMongos(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); + } else { + return createServer(self, _finalOptions, connectHandler(_finalOptions, connectCallback)); + } + }); + + function connectCallback(err, db) { + if(err && err.message == 'no mongos proxies found in seed list') { + if(logger.isWarn()) { + logger.warn(f('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name')); + } + + // Return a more specific error message for MongoClient.connect + return callback(new MongoError('seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name')); + } + + // Return the error and db instance + callback(err, db); + } +} + +module.exports = MongoClient diff --git a/node_modules/mongodb/lib/mongos.js b/node_modules/mongoose/node_modules/mongodb/lib/mongos.js similarity index 100% rename from node_modules/mongodb/lib/mongos.js rename to node_modules/mongoose/node_modules/mongodb/lib/mongos.js diff --git a/node_modules/mongodb/lib/read_preference.js b/node_modules/mongoose/node_modules/mongodb/lib/read_preference.js similarity index 100% rename from node_modules/mongodb/lib/read_preference.js rename to node_modules/mongoose/node_modules/mongodb/lib/read_preference.js diff --git a/node_modules/mongodb/lib/replset.js b/node_modules/mongoose/node_modules/mongodb/lib/replset.js similarity index 100% rename from node_modules/mongodb/lib/replset.js rename to node_modules/mongoose/node_modules/mongodb/lib/replset.js diff --git a/node_modules/mongodb/lib/server.js b/node_modules/mongoose/node_modules/mongodb/lib/server.js similarity index 100% rename from node_modules/mongodb/lib/server.js rename to node_modules/mongoose/node_modules/mongodb/lib/server.js diff --git a/node_modules/mongodb/lib/topology_base.js b/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js similarity index 100% rename from node_modules/mongodb/lib/topology_base.js rename to node_modules/mongoose/node_modules/mongodb/lib/topology_base.js diff --git a/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js b/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js new file mode 100644 index 0000000..963cdbe --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js @@ -0,0 +1,526 @@ +"use strict"; + +var ReadPreference = require('./read_preference'), + parser = require('url'), + f = require('util').format, + assign = require('./utils').assign, + dns = require('dns'); + +module.exports = function(url, options, callback) { + if (typeof options === 'function') (callback = options), (options = {}); + options = options || {}; + + var result = parser.parse(url, true); + if (result.protocol !== 'mongodb:' && result.protocol !== 'mongodb+srv:') { + return callback(new Error('invalid schema, expected mongodb or mongodb+srv')); + } + + if (result.protocol === 'mongodb+srv:') { + + if (result.hostname.split('.').length < 3) { + return callback(new Error('uri does not have hostname, domainname and tld')); + } + + result.domainLength = result.hostname.split('.').length; + + if (result.pathname && result.pathname.match(',')) { + return callback(new Error('invalid uri, cannot contain multiple hostnames')); + } + + if (result.port) { + return callback(new Error('Ports not accepted with mongodb+srv')); + } + + var srvAddress = '_mongodb._tcp.' + result.host; + dns.resolveSrv(srvAddress, function(err, addresses) { + if (err) return callback(err); + + if (addresses.length === 0) { + return callback(new Error('No addresses found at host')); + } + + for (var i = 0; i < addresses.length; i++) { + if (!matchesParentDomain(addresses[i].name, result.hostname, result.domainLength)) { + return callback(new Error('srv record does not share hostname with parent uri')); + } + } + + var connectionStrings = addresses.map(function(address, i) { + if (i === 0) return 'mongodb://' + address.name + ':' + address.port; + else return address.name + ':' + address.port; + }); + + var connectionString = connectionStrings.join(',') + '/'; + var connectionStringOptions = []; + + // Default to SSL true + if (!options.ssl && !result.search) { + connectionStringOptions.push('ssl=true'); + } else if (!options.ssl && result.search && !result.search.match('ssl')) { + connectionStringOptions.push('ssl=true'); + } + + // Keep original uri options + if (result.search) { + connectionStringOptions.push(result.search.replace('?', '')); + } + + dns.resolveTxt(result.host, function(err, record) { + if (err && err.code !== 'ENODATA') return callback(err); + if (err && err.code === 'ENODATA') record = null; + + if (record) { + if (record.length > 1) { + return callback(new Error('multiple text records not allowed')); + } + + record = record[0]; + if (record.length > 1) record = record.join(''); + else record = record[0]; + + if (!record.includes('authSource') && !record.includes('replicaSet')) { + return callback(new Error('text record must only set `authSource` or `replicaSet`')); + } + + connectionStringOptions.push(record); + } + + // Add any options to the connection string + if (connectionStringOptions.length) { + connectionString += '?' + connectionStringOptions.join('&'); + } + + parseHandler(connectionString, options, callback); + }); + }); + } else { + parseHandler(url, options, callback); + } +}; + +function matchesParentDomain(srvAddress, parentDomain) { + var regex = /^.*?\./; + var srv = '.' + srvAddress.replace(regex, ''); + var parent = '.' + parentDomain.replace(regex, ''); + if (srv.endsWith(parent)) return true; + else return false; +} + +function parseHandler(address, options, callback) { + var result, err; + try { + result = parseConnectionString(address, options); + } catch (e) { + err = e; + } + + return err ? callback(err, null) : callback(null, result); +} + +function parseConnectionString(url, options) { + // Variables + var connection_part = ''; + var auth_part = ''; + var query_string_part = ''; + var dbName = 'admin'; + + // Url parser result + var result = parser.parse(url, true); + + if((result.hostname == null || result.hostname == '') && url.indexOf('.sock') == -1) { + throw new Error('no hostname or hostnames provided in connection string'); + } + + if(result.port == '0') { + throw new Error('invalid port (zero) with hostname'); + } + + if(!isNaN(parseInt(result.port, 10)) && parseInt(result.port, 10) > 65535) { + throw new Error('invalid port (larger than 65535) with hostname'); + } + + if(result.path + && result.path.length > 0 + && result.path[0] != '/' + && url.indexOf('.sock') == -1) { + throw new Error('missing delimiting slash between hosts and options'); + } + + if(result.query) { + for(var name in result.query) { + if(name.indexOf('::') != -1) { + throw new Error('double colon in host identifier'); + } + + if(result.query[name] == '') { + throw new Error('query parameter ' + name + ' is an incomplete value pair'); + } + } + } + + if(result.auth) { + var parts = result.auth.split(':'); + if(url.indexOf(result.auth) != -1 && parts.length > 2) { + throw new Error('Username with password containing an unescaped colon'); + } + + if(url.indexOf(result.auth) != -1 && result.auth.indexOf('@') != -1) { + throw new Error('Username containing an unescaped at-sign'); + } + } + + // Remove query + var clean = url.split('?').shift(); + + // Extract the list of hosts + var strings = clean.split(','); + var hosts = []; + + for(var i = 0; i < strings.length; i++) { + var hostString = strings[i]; + + if(hostString.indexOf('mongodb') != -1) { + if(hostString.indexOf('@') != -1) { + hosts.push(hostString.split('@').pop()) + } else { + hosts.push(hostString.substr('mongodb://'.length)); + } + } else if(hostString.indexOf('/') != -1) { + hosts.push(hostString.split('/').shift()); + } else if(hostString.indexOf('/') == -1) { + hosts.push(hostString.trim()); + } + } + + for(i = 0; i < hosts.length; i++) { + var r = parser.parse(f('mongodb://%s', hosts[i].trim())); + if(r.path && r.path.indexOf(':') != -1) { + // Not connecting to a socket so check for an extra slash in the hostname. + // Using String#split as perf is better than match. + if (r.path.split('/').length > 1) { + throw new Error('slash in host identifier'); + } else { + throw new Error('double colon in host identifier'); + } + } + } + + // If we have a ? mark cut the query elements off + if(url.indexOf("?") != -1) { + query_string_part = url.substr(url.indexOf("?") + 1); + connection_part = url.substring("mongodb://".length, url.indexOf("?")) + } else { + connection_part = url.substring("mongodb://".length); + } + + // Check if we have auth params + if(connection_part.indexOf("@") != -1) { + auth_part = connection_part.split("@")[0]; + connection_part = connection_part.split("@")[1]; + } + + // Check if the connection string has a db + if(connection_part.indexOf(".sock") != -1) { + if(connection_part.indexOf(".sock/") != -1) { + dbName = connection_part.split(".sock/")[1]; + // Check if multiple database names provided, or just an illegal trailing backslash + if (dbName.indexOf("/") != -1) { + if (dbName.split("/").length == 2 && dbName.split("/")[1].length == 0) { + throw new Error('Illegal trailing backslash after database name'); + } + throw new Error('More than 1 database name in URL'); + } + connection_part = connection_part.split("/", connection_part.indexOf(".sock") + ".sock".length); + } + } else if(connection_part.indexOf("/") != -1) { + // Check if multiple database names provided, or just an illegal trailing backslash + if (connection_part.split("/").length > 2) { + if (connection_part.split("/")[2].length == 0) { + throw new Error('Illegal trailing backslash after database name'); + } + throw new Error('More than 1 database name in URL'); + } + dbName = connection_part.split("/")[1]; + connection_part = connection_part.split("/")[0]; + } + + // Result object + var object = {}; + + // Pick apart the authentication part of the string + var authPart = auth_part || ''; + var auth = authPart.split(':', 2); + + // Decode the URI components + auth[0] = decodeURIComponent(auth[0]); + if(auth[1]){ + auth[1] = decodeURIComponent(auth[1]); + } + + // Add auth to final object if we have 2 elements + if(auth.length == 2) object.auth = {user: auth[0], password: auth[1]}; + // if user provided auth options, use that + if(options && options.auth != null) object.auth = options.auth; + + // Variables used for temporary storage + var hostPart; + var urlOptions; + var servers; + var serverOptions = {socketOptions: {}}; + var dbOptions = {read_preference_tags: []}; + var replSetServersOptions = {socketOptions: {}}; + var mongosOptions = {socketOptions: {}}; + // Add server options to final object + object.server_options = serverOptions; + object.db_options = dbOptions; + object.rs_options = replSetServersOptions; + object.mongos_options = mongosOptions; + + // Let's check if we are using a domain socket + if(url.match(/\.sock/)) { + // Split out the socket part + var domainSocket = url.substring( + url.indexOf("mongodb://") + "mongodb://".length + , url.lastIndexOf(".sock") + ".sock".length); + // Clean out any auth stuff if any + if(domainSocket.indexOf("@") != -1) domainSocket = domainSocket.split("@")[1]; + servers = [{domain_socket: domainSocket}]; + } else { + // Split up the db + hostPart = connection_part; + // Deduplicate servers + var deduplicatedServers = {}; + + // Parse all server results + servers = hostPart.split(',').map(function(h) { + var _host, _port, ipv6match; + //check if it matches [IPv6]:port, where the port number is optional + if ((ipv6match = /\[([^\]]+)\](?:\:(.+))?/.exec(h))) { + _host = ipv6match[1]; + _port = parseInt(ipv6match[2], 10) || 27017; + } else { + //otherwise assume it's IPv4, or plain hostname + var hostPort = h.split(':', 2); + _host = hostPort[0] || 'localhost'; + _port = hostPort[1] != null ? parseInt(hostPort[1], 10) : 27017; + // Check for localhost?safe=true style case + if(_host.indexOf("?") != -1) _host = _host.split(/\?/)[0]; + } + + // No entry returned for duplicate server + if(deduplicatedServers[_host + "_" + _port]) return null; + deduplicatedServers[_host + "_" + _port] = 1; + + // Return the mapped object + return {host: _host, port: _port}; + }).filter(function(x) { + return x != null; + }); + } + + // Get the db name + object.dbName = dbName || 'admin'; + // Split up all the options + urlOptions = (query_string_part || '').split(/[&;]/); + // Ugh, we have to figure out which options go to which constructor manually. + urlOptions.forEach(function(opt) { + if(!opt) return; + var splitOpt = opt.split('='), name = splitOpt[0], value = splitOpt[1]; + // Options implementations + switch(name) { + case 'slaveOk': + case 'slave_ok': + serverOptions.slave_ok = (value == 'true'); + dbOptions.slaveOk = (value == 'true'); + break; + case 'maxPoolSize': + case 'poolSize': + serverOptions.poolSize = parseInt(value, 10); + replSetServersOptions.poolSize = parseInt(value, 10); + break; + case 'appname': + object.appname = decodeURIComponent(value); + break; + case 'autoReconnect': + case 'auto_reconnect': + serverOptions.auto_reconnect = (value == 'true'); + break; + case 'minPoolSize': + throw new Error("minPoolSize not supported"); + case 'maxIdleTimeMS': + throw new Error("maxIdleTimeMS not supported"); + case 'waitQueueMultiple': + throw new Error("waitQueueMultiple not supported"); + case 'waitQueueTimeoutMS': + throw new Error("waitQueueTimeoutMS not supported"); + case 'uuidRepresentation': + throw new Error("uuidRepresentation not supported"); + case 'ssl': + if(value == 'prefer') { + serverOptions.ssl = value; + replSetServersOptions.ssl = value; + mongosOptions.ssl = value; + break; + } + serverOptions.ssl = (value == 'true'); + replSetServersOptions.ssl = (value == 'true'); + mongosOptions.ssl = (value == 'true'); + break; + case 'sslValidate': + serverOptions.sslValidate = (value == 'true'); + replSetServersOptions.sslValidate = (value == 'true'); + mongosOptions.sslValidate = (value == 'true'); + break; + case 'replicaSet': + case 'rs_name': + replSetServersOptions.rs_name = value; + break; + case 'reconnectWait': + replSetServersOptions.reconnectWait = parseInt(value, 10); + break; + case 'retries': + replSetServersOptions.retries = parseInt(value, 10); + break; + case 'readSecondary': + case 'read_secondary': + replSetServersOptions.read_secondary = (value == 'true'); + break; + case 'fsync': + dbOptions.fsync = (value == 'true'); + break; + case 'journal': + dbOptions.j = (value == 'true'); + break; + case 'safe': + dbOptions.safe = (value == 'true'); + break; + case 'nativeParser': + case 'native_parser': + dbOptions.native_parser = (value == 'true'); + break; + case 'readConcernLevel': + dbOptions.readConcern = {level: value}; + break; + case 'connectTimeoutMS': + serverOptions.socketOptions.connectTimeoutMS = parseInt(value, 10); + replSetServersOptions.socketOptions.connectTimeoutMS = parseInt(value, 10); + mongosOptions.socketOptions.connectTimeoutMS = parseInt(value, 10); + break; + case 'socketTimeoutMS': + serverOptions.socketOptions.socketTimeoutMS = parseInt(value, 10); + replSetServersOptions.socketOptions.socketTimeoutMS = parseInt(value, 10); + mongosOptions.socketOptions.socketTimeoutMS = parseInt(value, 10); + break; + case 'w': + dbOptions.w = parseInt(value, 10); + if(isNaN(dbOptions.w)) dbOptions.w = value; + break; + case 'authSource': + dbOptions.authSource = value; + break; + case 'gssapiServiceName': + dbOptions.gssapiServiceName = value; + break; + case 'authMechanism': + if(value == 'GSSAPI') { + // If no password provided decode only the principal + if(object.auth == null) { + var urlDecodeAuthPart = decodeURIComponent(authPart); + if(urlDecodeAuthPart.indexOf("@") == -1) throw new Error("GSSAPI requires a provided principal"); + object.auth = {user: urlDecodeAuthPart, password: null}; + } else { + object.auth.user = decodeURIComponent(object.auth.user); + } + } else if(value == 'MONGODB-X509') { + object.auth = {user: decodeURIComponent(authPart)}; + } + + // Only support GSSAPI or MONGODB-CR for now + if(value != 'GSSAPI' + && value != 'MONGODB-X509' + && value != 'MONGODB-CR' + && value != 'DEFAULT' + && value != 'SCRAM-SHA-1' + && value != 'PLAIN') + throw new Error("only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, SCRAM-SHA-1 or MONGODB-CR is supported by authMechanism"); + + // Authentication mechanism + dbOptions.authMechanism = value; + break; + case 'authMechanismProperties': + // Split up into key, value pairs + var values = value.split(','); + var o = {}; + // For each value split into key, value + values.forEach(function(x) { + var v = x.split(':'); + o[v[0]] = v[1]; + }); + + // Set all authMechanismProperties + dbOptions.authMechanismProperties = o; + // Set the service name value + if(typeof o.SERVICE_NAME == 'string') dbOptions.gssapiServiceName = o.SERVICE_NAME; + if(typeof o.SERVICE_REALM == 'string') dbOptions.gssapiServiceRealm = o.SERVICE_REALM; + if(typeof o.CANONICALIZE_HOST_NAME == 'string') dbOptions.gssapiCanonicalizeHostName = o.CANONICALIZE_HOST_NAME == 'true' ? true : false; + break; + case 'wtimeoutMS': + dbOptions.wtimeout = parseInt(value, 10); + break; + case 'readPreference': + if(!ReadPreference.isValid(value)) throw new Error("readPreference must be either primary/primaryPreferred/secondary/secondaryPreferred/nearest"); + dbOptions.readPreference = value; + break; + case 'maxStalenessSeconds': + dbOptions.maxStalenessSeconds = parseInt(value, 10); + break; + case 'readPreferenceTags': + // Decode the value + value = decodeURIComponent(value); + // Contains the tag object + var tagObject = {}; + if(value == null || value == '') { + dbOptions.read_preference_tags.push(tagObject); + break; + } + + // Split up the tags + var tags = value.split(/\,/); + for(var i = 0; i < tags.length; i++) { + var parts = tags[i].trim().split(/\:/); + tagObject[parts[0]] = parts[1]; + } + + // Set the preferences tags + dbOptions.read_preference_tags.push(tagObject); + break; + default: + break; + } + }); + + // No tags: should be null (not []) + if(dbOptions.read_preference_tags.length === 0) { + dbOptions.read_preference_tags = null; + } + + // Validate if there are an invalid write concern combinations + if((dbOptions.w == -1 || dbOptions.w == 0) && ( + dbOptions.journal == true + || dbOptions.fsync == true + || dbOptions.safe == true)) throw new Error("w set to -1 or 0 cannot be combined with safe/w/journal/fsync") + + // If no read preference set it to primary + if(!dbOptions.readPreference) { + dbOptions.readPreference = 'primary'; + } + + // make sure that user-provided options are applied with priority + dbOptions = assign(dbOptions, options); + + // Add servers to result + object.servers = servers; + + // Returned parsed object + return object; +} diff --git a/node_modules/mongoose/node_modules/mongodb/lib/utils.js b/node_modules/mongoose/node_modules/mongodb/lib/utils.js new file mode 100644 index 0000000..c4efe49 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/lib/utils.js @@ -0,0 +1,375 @@ +"use strict"; + +var MongoError = require('mongodb-core').MongoError, + ReadPreference = require('./read_preference'), + CoreReadPreference = require('mongodb-core').ReadPreference; + +var shallowClone = function(obj) { + var copy = {}; + for(var name in obj) copy[name] = obj[name]; + return copy; +} + +// Figure out the read preference +var getReadPreference = function(options) { + var r = null + if(options.readPreference) { + r = options.readPreference + } else { + return options; + } + + if(r instanceof ReadPreference) { + options.readPreference = new CoreReadPreference(r.mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } else if(typeof r == 'string') { + options.readPreference = new CoreReadPreference(r); + } else if(r && !(r instanceof ReadPreference) && typeof r == 'object') { + var mode = r.mode || r.preference; + if (mode && typeof mode == 'string') { + options.readPreference = new CoreReadPreference(mode, r.tags, {maxStalenessSeconds: r.maxStalenessSeconds}); + } + } + + return options; +} + +// Set simple property +var getSingleProperty = function(obj, name, value) { + Object.defineProperty(obj, name, { + enumerable:true, + get: function() { + return value + } + }); +} + +var formatSortValue = exports.formatSortValue = function(sortDirection) { + var value = ("" + sortDirection).toLowerCase(); + + switch (value) { + case 'ascending': + case 'asc': + case '1': + return 1; + case 'descending': + case 'desc': + case '-1': + return -1; + default: + throw new Error("Illegal sort clause, must be of the form " + + "[['field1', '(ascending|descending)'], " + + "['field2', '(ascending|descending)']]"); + } +}; + +var formattedOrderClause = exports.formattedOrderClause = function(sortValue) { + var orderBy = {}; + if(sortValue == null) return null; + if (Array.isArray(sortValue)) { + if(sortValue.length === 0) { + return null; + } + + for(var i = 0; i < sortValue.length; i++) { + if(sortValue[i].constructor == String) { + orderBy[sortValue[i]] = 1; + } else { + orderBy[sortValue[i][0]] = formatSortValue(sortValue[i][1]); + } + } + } else if(sortValue != null && typeof sortValue == 'object') { + orderBy = sortValue; + } else if (typeof sortValue == 'string') { + orderBy[sortValue] = 1; + } else { + throw new Error("Illegal sort clause, must be of the form " + + "[['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]"); + } + + return orderBy; +}; + +var checkCollectionName = function checkCollectionName (collectionName) { + if('string' !== typeof collectionName) { + throw new MongoError("collection name must be a String"); + } + + if(!collectionName || collectionName.indexOf('..') != -1) { + throw new MongoError("collection names cannot be empty"); + } + + if(collectionName.indexOf('$') != -1 && + collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null) { + throw new MongoError("collection names must not contain '$'"); + } + + if(collectionName.match(/^\.|\.$/) != null) { + throw new MongoError("collection names must not start or end with '.'"); + } + + // Validate that we are not passing 0x00 in the collection name + if(!!~collectionName.indexOf("\x00")) { + throw new MongoError("collection names cannot contain a null character"); + } +}; + +var handleCallback = function(callback, err, value1, value2) { + try { + if(callback == null) return; + if(callback) { + return value2 ? callback(err, value1, value2) : callback(err, value1); + } + } catch(err) { + process.nextTick(function() { throw err; }); + return false; + } + + return true; +} + +/** + * Wrap a Mongo error document in an Error instance + * @ignore + * @api private + */ +var toError = function(error) { + if (error instanceof Error) return error; + + var msg = error.err || error.errmsg || error.errMessage || error; + var e = MongoError.create({message: msg, driver:true}); + + // Get all object keys + var keys = typeof error == 'object' + ? Object.keys(error) + : []; + + for(var i = 0; i < keys.length; i++) { + try { + e[keys[i]] = error[keys[i]]; + } catch(err) { + // continue + } + } + + return e; +} + +/** + * @ignore + */ +var normalizeHintField = function normalizeHintField(hint) { + var finalHint = null; + + if(typeof hint == 'string') { + finalHint = hint; + } else if(Array.isArray(hint)) { + finalHint = {}; + + hint.forEach(function(param) { + finalHint[param] = 1; + }); + } else if(hint != null && typeof hint == 'object') { + finalHint = {}; + for (var name in hint) { + finalHint[name] = hint[name]; + } + } + + return finalHint; +}; + +/** + * Create index name based on field spec + * + * @ignore + * @api private + */ +var parseIndexOptions = function(fieldOrSpec) { + var fieldHash = {}; + var indexes = []; + var keys; + + // Get all the fields accordingly + if('string' == typeof fieldOrSpec) { + // 'type' + indexes.push(fieldOrSpec + '_' + 1); + fieldHash[fieldOrSpec] = 1; + } else if(Array.isArray(fieldOrSpec)) { + fieldOrSpec.forEach(function(f) { + if('string' == typeof f) { + // [{location:'2d'}, 'type'] + indexes.push(f + '_' + 1); + fieldHash[f] = 1; + } else if(Array.isArray(f)) { + // [['location', '2d'],['type', 1]] + indexes.push(f[0] + '_' + (f[1] || 1)); + fieldHash[f[0]] = f[1] || 1; + } else if(isObject(f)) { + // [{location:'2d'}, {type:1}] + keys = Object.keys(f); + keys.forEach(function(k) { + indexes.push(k + '_' + f[k]); + fieldHash[k] = f[k]; + }); + } else { + // undefined (ignore) + } + }); + } else if(isObject(fieldOrSpec)) { + // {location:'2d', type:1} + keys = Object.keys(fieldOrSpec); + keys.forEach(function(key) { + indexes.push(key + '_' + fieldOrSpec[key]); + fieldHash[key] = fieldOrSpec[key]; + }); + } + + return { + name: indexes.join("_"), keys: keys, fieldHash: fieldHash + } +} + +var isObject = exports.isObject = function (arg) { + return '[object Object]' == Object.prototype.toString.call(arg) +} + +var debugOptions = function(debugFields, options) { + var finaloptions = {}; + debugFields.forEach(function(n) { + finaloptions[n] = options[n]; + }); + + return finaloptions; +} + +var decorateCommand = function(command, options, exclude) { + for(var name in options) { + if(exclude[name] == null) command[name] = options[name]; + } + + return command; +} + +var mergeOptions = function(target, source) { + for(var name in source) { + target[name] = source[name]; + } + + return target; +} + +// Merge options with translation +var translateOptions = function(target, source) { + var translations = { + // SSL translation options + 'sslCA': 'ca', 'sslCRL': 'crl', 'sslValidate': 'rejectUnauthorized', 'sslKey': 'key', + 'sslCert': 'cert', 'sslPass': 'passphrase', + // SocketTimeout translation options + 'socketTimeoutMS': 'socketTimeout', 'connectTimeoutMS': 'connectionTimeout', + // Replicaset options + 'replicaSet': 'setName', 'rs_name': 'setName', 'secondaryAcceptableLatencyMS': 'acceptableLatency', + 'connectWithNoPrimary': 'secondaryOnlyConnectionAllowed', + // Mongos options + 'acceptableLatencyMS': 'localThresholdMS' + } + + for(var name in source) { + if(translations[name]) { + target[translations[name]] = source[name]; + } else { + target[name] = source[name]; + } + } + + return target; +} + +var filterOptions = function(options, names) { + var filterOptions = {}; + + for(var name in options) { + if(names.indexOf(name) != -1) filterOptions[name] = options[name]; + } + + // Filtered options + return filterOptions; +} + +// Object.assign method or polyfill +var assign = Object.assign ? Object.assign : function assign(target) { + if (target === undefined || target === null) { + throw new TypeError('Cannot convert first argument to object'); + } + + var to = Object(target); + for (var i = 1; i < arguments.length; i++) { + var nextSource = arguments[i]; + if (nextSource === undefined || nextSource === null) { + continue; + } + + var keysArray = Object.keys(Object(nextSource)); + for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { + var nextKey = keysArray[nextIndex]; + var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); + if (desc !== undefined && desc.enumerable) { + to[nextKey] = nextSource[nextKey]; + } + } + } + return to; +} + +// Write concern keys +var writeConcernKeys = ['w', 'j', 'wtimeout', 'fsync']; + +// Merge the write concern options +var mergeOptionsAndWriteConcern = function(targetOptions, sourceOptions, keys, mergeWriteConcern) { + // Mix in any allowed options + for(var i = 0; i < keys.length; i++) { + if(!targetOptions[keys[i]] && sourceOptions[keys[i]] != undefined) { + targetOptions[keys[i]] = sourceOptions[keys[i]]; + } + } + + // No merging of write concern + if(!mergeWriteConcern) return targetOptions; + + // Found no write Concern options + var found = false; + for(var i = 0; i < writeConcernKeys.length; i++) { + if(targetOptions[writeConcernKeys[i]]) { + found = true; + break; + } + } + + if(!found) { + for(var i = 0; i < writeConcernKeys.length; i++) { + if(sourceOptions[writeConcernKeys[i]]) { + targetOptions[writeConcernKeys[i]] = sourceOptions[writeConcernKeys[i]]; + } + } + } + + return targetOptions; +} + +exports.filterOptions = filterOptions; +exports.mergeOptions = mergeOptions; +exports.translateOptions = translateOptions; +exports.shallowClone = shallowClone; +exports.getSingleProperty = getSingleProperty; +exports.checkCollectionName = checkCollectionName; +exports.toError = toError; +exports.formattedOrderClause = formattedOrderClause; +exports.parseIndexOptions = parseIndexOptions; +exports.normalizeHintField = normalizeHintField; +exports.handleCallback = handleCallback; +exports.decorateCommand = decorateCommand; +exports.isObject = isObject; +exports.debugOptions = debugOptions; +exports.MAX_JS_INT = 0x20000000000000; +exports.assign = assign; +exports.mergeOptionsAndWriteConcern = mergeOptionsAndWriteConcern; +exports.getReadPreference = getReadPreference; diff --git a/node_modules/mongoose/node_modules/mongodb/package.json b/node_modules/mongoose/node_modules/mongodb/package.json new file mode 100644 index 0000000..d251f9c --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/package.json @@ -0,0 +1,90 @@ +{ + "_from": "mongodb@2.2.34", + "_id": "mongodb@2.2.34", + "_inBundle": false, + "_integrity": "sha1-o09Zu+thdUrsQy3nLD/iFSakTBo=", + "_location": "/mongoose/mongodb", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "mongodb@2.2.34", + "name": "mongodb", + "escapedName": "mongodb", + "rawSpec": "2.2.34", + "saveSpec": null, + "fetchSpec": "2.2.34" + }, + "_requiredBy": [ + "/mongoose" + ], + "_resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.34.tgz", + "_shasum": "a34f59bbeb61754aec432de72c3fe21526a44c1a", + "_spec": "mongodb@2.2.34", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "author": { + "name": "Christian Kvalheim" + }, + "bugs": { + "url": "https://github.com/mongodb/node-mongodb-native/issues" + }, + "bundleDependencies": false, + "dependencies": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.18", + "readable-stream": "2.2.7" + }, + "deprecated": false, + "description": "The official MongoDB driver for Node.js", + "devDependencies": { + "JSONStream": "^1.0.7", + "betterbenchmarks": "^0.1.0", + "bluebird": "3.4.6", + "bson": "latest", + "cli-table": "^0.3.1", + "co": "4.6.0", + "colors": "^1.1.2", + "coveralls": "^2.11.6", + "eslint": "^3.8.1", + "event-stream": "^3.3.2", + "gleak": "0.5.0", + "integra": "0.1.8", + "jsdoc": "3.4.0", + "ldjson-stream": "^1.2.1", + "mongodb-extended-json": "1.7.1", + "mongodb-topology-manager": "1.0.x", + "mongodb-version-manager": "github:christkv/mongodb-version-manager#master", + "nyc": "^8.1.0", + "optimist": "0.6.1", + "rimraf": "2.5.4", + "semver": "5.3.0", + "worker-farm": "^1.3.1" + }, + "engines": { + "node": ">=0.10.3" + }, + "homepage": "https://github.com/mongodb/node-mongodb-native", + "keywords": [ + "mongodb", + "driver", + "official" + ], + "license": "Apache-2.0", + "main": "index.js", + "name": "mongodb", + "nyc": { + "include": [ + "lib/**/*.js" + ] + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/mongodb/node-mongodb-native.git" + }, + "scripts": { + "coverage": "nyc node test/runner.js -t functional && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls", + "lint": "eslint lib", + "test": "node test/runner.js -t functional" + }, + "version": "2.2.34" +} diff --git a/node_modules/mongodb/rev.md b/node_modules/mongoose/node_modules/mongodb/rev.md similarity index 100% rename from node_modules/mongodb/rev.md rename to node_modules/mongoose/node_modules/mongodb/rev.md diff --git a/node_modules/mongoose/node_modules/mongodb/yarn.lock b/node_modules/mongoose/node_modules/mongodb/yarn.lock new file mode 100644 index 0000000..479c574 --- /dev/null +++ b/node_modules/mongoose/node_modules/mongodb/yarn.lock @@ -0,0 +1,3299 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +JSONStream@^1.0.7, JSONStream@^1.1.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" + dependencies: + jsonparse "^1.2.0" + through ">=2.2.7 <3" + +acorn-jsx@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" + dependencies: + acorn "^3.0.4" + +acorn@^3.0.4: + version "3.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" + +acorn@^5.2.1: + version "5.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" + +ajv-keywords@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" + +ajv@^4.7.0: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ajv@^5.1.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ampersand-events@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ampersand-events/-/ampersand-events-2.0.2.tgz#f402bc2e18305fabd995dbdcd3b7057bbdd7d347" + dependencies: + ampersand-version "^1.0.2" + lodash "^4.6.1" + +ampersand-state@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/ampersand-state/-/ampersand-state-5.0.3.tgz#33402ea604375af64a249f664a0312c1160da475" + dependencies: + ampersand-events "^2.0.1" + ampersand-version "^1.0.0" + array-next "~0.0.1" + key-tree-store "^1.3.0" + lodash "^4.12.0" + +ampersand-version@^1.0.0, ampersand-version@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/ampersand-version/-/ampersand-version-1.0.2.tgz#ff8f3d4ceac4d32ccd83f6bd6697397f7b59e2c0" + dependencies: + find-root "^0.1.1" + through2 "^0.6.3" + +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi@^0.3.0, ansi@~0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21" + +append-transform@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" + dependencies: + default-require-extensions "^1.0.0" + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + +are-we-there-yet@~1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.0.6.tgz#a2d28c93102aa6cc96245a26cb954de06ec53f0c" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +argparse@^1.0.7: + version "1.0.9" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" + dependencies: + sprintf-js "~1.0.2" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-next@~0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/array-next/-/array-next-0.0.1.tgz#e5e4660a4c27fda8151ff7764275d00900062be1" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0, arrify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +async@^1.4.0, async@^1.4.2, async@^1.5.0, async@~1.5.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@~0.2.6: + version "0.2.10" + resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + +async@~1.4.0: + version "1.4.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.4.2.tgz#6c9edcb11ced4f0dd2f2d40db0d49a109c088aab" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1, aws4@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-code-frame@^6.16.0, babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-core@^6.2.1, babel-core@^6.25.0, babel-core@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.0" + debug "^2.6.8" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.7" + slash "^1.0.0" + source-map "^0.5.6" + +babel-generator@^6.18.0, babel-generator@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5" + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.17.4" + source-map "^0.5.6" + trim-right "^1.0.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-polyfill@^6.2.0, babel-polyfill@^6.23.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" + dependencies: + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" + +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" + dependencies: + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + home-or-tmp "^2.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + source-map-support "^0.4.15" + +babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + +babel-traverse@^6.18.0, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.18.0, babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +betterbenchmarks@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/betterbenchmarks/-/betterbenchmarks-0.1.0.tgz#c07ac937e215d3d7a91a460eefb039b7c9002e43" + dependencies: + babel-core "^6.2.1" + babel-polyfill "^6.2.0" + cli-table "^0.3.1" + co "^4.6.0" + colors "^1.1.2" + fast-stats "0.0.3" + table "^3.7.4" + +"binary@>= 0.3.0 < 1": + version "0.3.0" + resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" + dependencies: + buffers "~0.1.1" + chainsaw "~0.1.0" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +bluebird@3.4.6: + version "3.4.6" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f" + +bluebird@^3.5.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" + +bluebird@~2.9.34: + version "2.9.34" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.9.34.tgz#2f7b4ec80216328a9fddebdf69c8d4942feff7d8" + +boolbase@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +boom@4.x.x: + version "4.3.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +bson@^0.5.2: + version "0.5.7" + resolved "https://registry.yarnpkg.com/bson/-/bson-0.5.7.tgz#0d11fe0936c1fee029e11f7063f5d0ab2422ea3e" + +bson@latest, bson@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c" + +buffer-shims@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +buffers@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" + +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +caching-transform@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/caching-transform/-/caching-transform-1.0.1.tgz#6dbdb2f20f8d8fbce79f3e94e9d1742dcdf5c0a1" + dependencies: + md5-hex "^1.2.0" + mkdirp "^0.5.1" + write-file-atomic "^1.1.4" + +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + dependencies: + callsites "^0.2.0" + +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +camelcase@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +catharsis@~0.8.7: + version "0.8.9" + resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b" + dependencies: + underscore-contrib "~0.3.0" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chainsaw@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" + dependencies: + traverse ">=0.3.0 <0.4" + +chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +cheerio@^0.19.0: + version "0.19.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.19.0.tgz#772e7015f2ee29965096d71ea4175b75ab354925" + dependencies: + css-select "~1.0.0" + dom-serializer "~0.1.0" + entities "~1.1.1" + htmlparser2 "~3.8.1" + lodash "^3.2.0" + +circular-json@^0.3.1: + version "0.3.3" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" + +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + dependencies: + restore-cursor "^1.0.1" + +cli-table@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" + dependencies: + colors "1.0.3" + +cli-width@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +cliui@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +co@4.6.0, co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +colors@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" + +colors@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@^2.9.0: + version "2.12.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" + +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@^1.5.2: + version "1.6.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" + dependencies: + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +convert-source-map@^1.3.0, convert-source-map@^1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" + +core-js@^2.4.0, core-js@^2.5.0: + version "2.5.3" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +coveralls@^2.11.6: + version "2.13.3" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.13.3.tgz#9ad7c2ae527417f361e8b626483f48ee92dd2bc7" + dependencies: + js-yaml "3.6.1" + lcov-parse "0.0.10" + log-driver "1.2.5" + minimist "1.2.0" + request "2.79.0" + +cross-spawn@^4: + version "4.0.2" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" + dependencies: + lru-cache "^4.0.1" + which "^1.2.9" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +cryptiles@3.x.x: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + +css-select@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.0.0.tgz#b1121ca51848dd264e2244d058cee254deeb44b0" + dependencies: + boolbase "~1.0.0" + css-what "1.0" + domutils "1.4" + nth-check "~1.0.0" + +css-what@1.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/css-what/-/css-what-1.0.0.tgz#d7cc2df45180666f99d2b14462639469e00f736c" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.6.8: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + +debug@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + +default-require-extensions@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8" + dependencies: + strip-bom "^2.0.0" + +del@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +docopt@~0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11" + +doctrine@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075" + dependencies: + esutils "^2.0.2" + +dom-serializer@0, dom-serializer@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" + dependencies: + domelementtype "~1.1.1" + entities "~1.1.1" + +domelementtype@1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" + +domelementtype@~1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" + +domhandler@2.3: + version "2.3.0" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" + dependencies: + domelementtype "1" + +domutils@1.4: + version "1.4.3" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.4.3.tgz#0865513796c6b306031850e175516baf80b72a6f" + dependencies: + domelementtype "1" + +domutils@1.5: + version "1.5.1" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" + dependencies: + dom-serializer "0" + domelementtype "1" + +downcache@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/downcache/-/downcache-0.0.8.tgz#332320dde5806ea55d2e6d2ea674990bda4e8b75" + dependencies: + extend "2.0.x" + graceful-fs "2.0.3" + limiter "1.0.x" + mkdirp "~0.3.5" + npmlog "1.0.0" + request "^2.34.0" + +duplexer@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +entities@1.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" + +entities@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" + +errno@^0.1.4: + version "0.1.6" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.6.tgz#c386ce8a6283f14fc09563b71560908c9bf53026" + dependencies: + prr "~1.0.1" + +error-ex@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" + dependencies: + is-arrayish "^0.2.1" + +es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: + version "0.10.37" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.37.tgz#0ee741d148b80069ba27d020393756af257defc3" + dependencies: + es6-iterator "~2.0.1" + es6-symbol "~3.1.1" + +es6-iterator@^2.0.1, es6-iterator@~2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-map@^0.1.3: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.5.tgz#9136e0503dcc06a301690f0bb14ff4e364e949f0" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-set "~0.1.5" + es6-symbol "~3.1.1" + event-emitter "~0.3.5" + +es6-promise@3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.2.1.tgz#ec56233868032909207170c39448e24449dd1fc4" + +es6-set@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" + dependencies: + d "1" + es5-ext "~0.10.14" + es6-iterator "~2.0.1" + es6-symbol "3.1.1" + event-emitter "~0.3.5" + +es6-symbol@3.1.1, es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.3: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +escodegen@1.1.x: + version "1.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.1.0.tgz#c663923f6e20aad48d0c0fa49f31c6d4f49360cf" + dependencies: + esprima "~1.0.4" + estraverse "~1.5.0" + esutils "~1.0.0" + optionalDependencies: + source-map "~0.1.30" + +escope@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" + dependencies: + es6-map "^0.1.3" + es6-weak-map "^2.0.1" + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint@^3.8.1: + version "3.19.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc" + dependencies: + babel-code-frame "^6.16.0" + chalk "^1.1.3" + concat-stream "^1.5.2" + debug "^2.1.1" + doctrine "^2.0.0" + escope "^3.6.0" + espree "^3.4.0" + esquery "^1.0.0" + estraverse "^4.2.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + glob "^7.0.3" + globals "^9.14.0" + ignore "^3.2.0" + imurmurhash "^0.1.4" + inquirer "^0.12.0" + is-my-json-valid "^2.10.0" + is-resolvable "^1.0.0" + js-yaml "^3.5.1" + json-stable-stringify "^1.0.0" + levn "^0.3.0" + lodash "^4.0.0" + mkdirp "^0.5.0" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.1" + pluralize "^1.2.1" + progress "^1.1.8" + require-uncached "^1.0.2" + shelljs "^0.7.5" + strip-bom "^3.0.0" + strip-json-comments "~2.0.1" + table "^3.7.8" + text-table "~0.2.0" + user-home "^2.0.0" + +espree@^3.4.0: + version "3.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" + dependencies: + acorn "^5.2.1" + acorn-jsx "^3.0.0" + +espree@~2.2.3: + version "2.2.5" + resolved "https://registry.yarnpkg.com/espree/-/espree-2.2.5.tgz#df691b9310889402aeb29cc066708c56690b854b" + +esprima@1.0.x, esprima@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-1.0.4.tgz#9f557e08fc3b4d26ece9dd34f8fbf476b62585ad" + +esprima@^2.6.0: + version "2.7.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" + +esprima@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" + +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" + +esrecurse@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163" + dependencies: + estraverse "^4.1.0" + object-assign "^4.0.1" + +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + +estraverse@~1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.5.1.tgz#867a3e8e58a9f84618afb6c2ddbcd916b7cbaf71" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +esutils@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.0.0.tgz#8151d358e20c8acc7fb745e7472c0025fe496570" + +event-emitter@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + +event-stream@^3.3.1, event-stream@^3.3.2: + version "3.3.4" + resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" + dependencies: + duplexer "~0.1.1" + from "~0" + map-stream "~0.1.0" + pause-stream "0.0.11" + split "0.3" + stream-combiner "~0.0.4" + through "~2.3.1" + +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +extend@2.0.x: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-2.0.1.tgz#1ee8010689e7395ff9448241c98652bc759a8260" + +extend@~3.0.0, extend@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + +fast-stats@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/fast-stats/-/fast-stats-0.0.3.tgz#650af963c3ff85c496a3610f20d40cd4c164594d" + +figures@^1.3.5, figures@^1.4.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + +filename-regex@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +find-cache-dir@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" + dependencies: + commondir "^1.0.1" + mkdirp "^0.5.1" + pkg-dir "^1.0.0" + +find-root@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/find-root/-/find-root-0.1.2.tgz#98d2267cff1916ccaf2743b3a0eea81d79d7dcd1" + +find-up@^1.0.0, find-up@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +flat-cache@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + +for-in@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +for-own@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + +foreground-child@^1.5.3, foreground-child@^1.5.6: + version "1.5.6" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" + dependencies: + cross-spawn "^4" + signal-exit "^3.0.0" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +form-data@~2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +from@~0: + version "0.1.7" + resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" + +fs-extra@^0.22.1: + version "0.22.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.22.1.tgz#5fd6f8049dc976ca19eb2355d658173cabcce056" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + rimraf "^2.2.8" + +fs-extra@~0.30.0: + version "0.30.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + path-is-absolute "^1.0.0" + rimraf "^2.2.8" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +"fstream@>= 0.1.30 < 1": + version "0.1.31" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-0.1.31.tgz#7337f058fbbbbefa8c9f561a28cab0849202c988" + dependencies: + graceful-fs "~3.0.2" + inherits "~2.0.0" + mkdirp "0.5" + rimraf "2" + +fstream@^1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-1.0.2.tgz#53e25965dfaf1c85be3a2a0633306a24a67dc2f9" + dependencies: + ansi "^0.3.0" + has-unicode "^1.0.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-caller-file@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" + +get-mongodb-version@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/get-mongodb-version/-/get-mongodb-version-0.0.1.tgz#bc8aa433ba2fdd57fa33312dcf89f06f3a908caa" + dependencies: + debug "^2.2.0" + lodash.startswith "^3.0.1" + minimist "^1.1.1" + mongodb "^2.0.39" + which "^1.1.1" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +gleak@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/gleak/-/gleak-0.5.0.tgz#9cd7694be50d6dbeb842021ed8160814c51faddf" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.14.0, globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +graceful-fs@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-2.0.3.tgz#7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0" + +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +graceful-fs@~3.0.2: + version "3.0.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + dependencies: + natives "^1.1.0" + +handlebars@2.0.0-alpha.1: + version "2.0.0-alpha.1" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-2.0.0-alpha.1.tgz#c4d149068c713de0afa7f45bbb88a2ca73715afd" + dependencies: + optimist "~0.3" + optionalDependencies: + uglify-js "~2.3" + +handlebars@^4.0.3: + version "4.0.11" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +har-validator@~5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-unicode@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-1.0.1.tgz#c46fceea053eb8ec789bffbba25fca52dfdcf38e" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hawk@~6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +hoek@4.x.x: + version "4.2.0" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +hosted-git-info@^2.1.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" + +htmlparser2@~3.8.1: + version "3.8.3" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" + dependencies: + domelementtype "1" + domhandler "2.3" + domutils "1.5" + entities "1.0" + readable-stream "1.1" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +ignore@^3.2.0: + version "3.3.7" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inquirer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" + dependencies: + ansi-escapes "^1.1.0" + ansi-regex "^2.0.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + figures "^1.3.5" + lodash "^4.3.0" + readline2 "^1.0.1" + run-async "^0.1.0" + rx-lite "^3.1.2" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + +integra@0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/integra/-/integra-0.1.8.tgz#8d5b8019f87ea3704e6c97da2c912e14ec3bece7" + dependencies: + escodegen "1.1.x" + esprima "1.0.x" + handlebars "2.0.0-alpha.1" + mkdirp latest + rimraf "2.2.6" + +interpret@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" + +invariant@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-dotfile@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: + version "2.17.1" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + +is-path-in-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + dependencies: + path-is-inside "^1.0.1" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-resolvable@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.1.tgz#acca1cd36dbe44b974b924321555a70ba03b1cf4" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" + +istanbul-lib-hook@^1.0.0-alpha.4: + version "1.1.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.1.0.tgz#8538d970372cb3716d53e55523dd54b557a8d89b" + dependencies: + append-transform "^0.4.0" + +istanbul-lib-instrument@^1.2.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.18.0" + istanbul-lib-coverage "^1.1.1" + semver "^5.3.0" + +istanbul-lib-report@^1.0.0-alpha.3: + version "1.1.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.2.tgz#922be27c13b9511b979bd1587359f69798c1d425" + dependencies: + istanbul-lib-coverage "^1.1.1" + mkdirp "^0.5.1" + path-parse "^1.0.5" + supports-color "^3.1.2" + +istanbul-lib-source-maps@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.2.tgz#750578602435f28a0c04ee6d7d9e0f2960e62c1c" + dependencies: + debug "^3.1.0" + istanbul-lib-coverage "^1.1.1" + mkdirp "^0.5.1" + rimraf "^2.6.1" + source-map "^0.5.3" + +istanbul-reports@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.1.3.tgz#3b9e1e8defb6d18b1d425da8e8b32c5a163f2d10" + dependencies: + handlebars "^4.0.3" + +js-tokens@^3.0.0, js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + +js-yaml@3.6.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" + dependencies: + argparse "^1.0.7" + esprima "^2.6.0" + +js-yaml@^3.5.1: + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js2xmlparser@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-1.0.0.tgz#5a170f2e8d6476ce45405e04823242513782fe30" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +jsdoc@3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.4.0.tgz#341cdb06e44a113d9541efd212c95a488064e9ee" + dependencies: + async "~1.4.0" + bluebird "~2.9.34" + catharsis "~0.8.7" + escape-string-regexp "~1.0.3" + espree "~2.2.3" + js2xmlparser "~1.0.0" + marked "~0.3.4" + requizzle "~0.2.0" + strip-json-comments "~1.0.2" + taffydb "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e" + underscore "~1.8.3" + wrench "~1.5.8" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json5@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonparse@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +kerberos@^0.0.23: + version "0.0.23" + resolved "https://registry.yarnpkg.com/kerberos/-/kerberos-0.0.23.tgz#6aa46afdb9786c6919388cc5b408f012c71f0fd1" + dependencies: + nan "~2.5.1" + +key-tree-store@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/key-tree-store/-/key-tree-store-1.3.0.tgz#5ea29afc2529a425938437d6955b714ce6a9791f" + +kind-of@^3.0.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" + +klaw@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + optionalDependencies: + graceful-fs "^4.1.9" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +lcov-parse@0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" + +ldjson-stream@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ldjson-stream/-/ldjson-stream-1.2.1.tgz#91beceda5ac4ed2b17e649fb777e7abfa0189c2b" + dependencies: + split2 "^0.2.1" + through2 "^0.6.1" + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +limiter@1.0.x: + version "1.0.5" + resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.0.5.tgz#9630b2a0d3bad63203f96e3d96f32f83d442dfc8" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +lodash._arrayeach@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecallback@^3.0.0: + version "3.3.1" + resolved "https://registry.yarnpkg.com/lodash._basecallback/-/lodash._basecallback-3.3.1.tgz#b7b2bb43dc2160424a21ccf26c57e443772a8e27" + dependencies: + lodash._baseisequal "^3.0.0" + lodash._bindcallback "^3.0.0" + lodash.isarray "^3.0.0" + lodash.pairs "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._basefor@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2" + +lodash._baseisequal@^3.0.0: + version "3.0.7" + resolved "https://registry.yarnpkg.com/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz#d8025f76339d29342767dcc887ce5cb95a5b51f1" + dependencies: + lodash.isarray "^3.0.0" + lodash.istypedarray "^3.0.0" + lodash.keys "^3.0.0" + +lodash._bindcallback@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" + +lodash._createassigner@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" + dependencies: + lodash._bindcallback "^3.0.0" + lodash._isiterateecall "^3.0.0" + lodash.restparam "^3.0.0" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash._root@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + +lodash.assign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-3.2.0.tgz#3ce9f0234b4b2223e296b8fa0ac1fee8ebca64fa" + dependencies: + lodash._baseassign "^3.0.0" + lodash._createassigner "^3.0.0" + lodash.keys "^3.0.0" + +lodash.defaults@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-3.1.2.tgz#c7308b18dbf8bc9372d701a73493c61192bd2e2c" + dependencies: + lodash.assign "^3.0.0" + lodash.restparam "^3.0.0" + +lodash.defaults@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + +lodash.difference@^4.1.1: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.isfunction@^3.0.0, lodash.isfunction@^3.0.6: + version "3.0.8" + resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.8.tgz#4db709fc81bc4a8fd7127a458a5346c5cdce2c6b" + +lodash.istypedarray@^3.0.0: + version "3.0.6" + resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.pairs@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash.pairs/-/lodash.pairs-3.0.1.tgz#bbe08d5786eeeaa09a15c91ebf0dcb7d2be326a9" + dependencies: + lodash.keys "^3.0.0" + +lodash.restparam@^3.0.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + +lodash.startswith@^3.0.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.startswith/-/lodash.startswith-3.2.0.tgz#fc2e1ed2c6df8c777117632e87fe4a9181d483fb" + dependencies: + lodash._root "^3.0.0" + +lodash.transform@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.transform/-/lodash.transform-3.0.4.tgz#8ebe53fbae15857ade36eca67fc559b78bb3ebe9" + dependencies: + lodash._arrayeach "^3.0.0" + lodash._basecallback "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._basefor "^3.0.0" + lodash.isarray "^3.0.0" + lodash.isfunction "^3.0.0" + lodash.istypedarray "^3.0.0" + lodash.keys "^3.0.0" + +lodash@^3.2.0: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + +lodash@^4.0.0, lodash@^4.12.0, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +log-driver@1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +loose-envify@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lru-cache@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +map-stream@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" + +marked@~0.3.4: + version "0.3.9" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.9.tgz#54ce6a57e720c3ac6098374ec625fcbcc97ff290" + +"match-stream@>= 0.0.2 < 1": + version "0.0.2" + resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf" + dependencies: + buffers "~0.1.1" + readable-stream "~1.0.0" + +md5-hex@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-1.3.0.tgz#d2c4afe983c4370662179b8cad145219135046c4" + dependencies: + md5-o-matic "^0.1.1" + +md5-o-matic@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3" + +meow@^3.1.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +micromatch@^2.3.11: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.30.0: + version "1.30.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" + +mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.7: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" + dependencies: + mime-db "~1.30.0" + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +mkdirp@0.5, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@latest: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mkdirp@~0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.5.tgz#de3e5f8961c88c787ee1368df849ac4413eca8d7" + +moment@^2.10.6: + version "2.20.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" + +mongodb-core@2.1.17: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8" + dependencies: + bson "~1.0.4" + require_optional "~1.0.0" + +mongodb-core@2.1.18, mongodb-core@^2.1.12: + version "2.1.18" + resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.18.tgz#4c46139bdf3a1f032ded91db49f38eec01659050" + dependencies: + bson "~1.0.4" + require_optional "~1.0.0" + +mongodb-download-url@^0.1.10: + version "0.1.10" + resolved "https://registry.yarnpkg.com/mongodb-download-url/-/mongodb-download-url-0.1.10.tgz#a7047eec95001de9f4df39f7e4030dc87eb3f806" + dependencies: + async "^1.5.0" + debug "^2.2.0" + lodash.defaults "^4.0.0" + minimist "^1.2.0" + mongodb-version-list "^0.0.3" + request "^2.65.0" + semver "^5.0.3" + +mongodb-extended-json@1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/mongodb-extended-json/-/mongodb-extended-json-1.7.1.tgz#457ec1fe3582eb1c70c4c12a979d831c01344812" + dependencies: + JSONStream "^1.1.1" + async "^1.4.2" + bson "^0.5.2" + event-stream "^3.3.1" + lodash.isfunction "^3.0.6" + lodash.transform "^3.0.4" + moment "^2.10.6" + raf "^3.1.0" + +mongodb-topology-manager@1.0.x: + version "1.0.13" + resolved "https://registry.yarnpkg.com/mongodb-topology-manager/-/mongodb-topology-manager-1.0.13.tgz#053577386c587d2cfcc1cc45a0567b93b0f8710b" + dependencies: + babel-core "^6.25.0" + babel-polyfill "^6.23.0" + bluebird "^3.5.0" + co "^4.6.0" + kerberos "^0.0.23" + mkdirp "^0.5.1" + mongodb-core "^2.1.12" + rimraf "^2.6.1" + +mongodb-version-list@0.0.3, mongodb-version-list@^0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/mongodb-version-list/-/mongodb-version-list-0.0.3.tgz#bbb261861f041fcfc5bc72b5fe2681788bd52cef" + dependencies: + cheerio "^0.19.0" + debug "^2.2.0" + downcache "0.0.8" + fs-extra "^0.22.1" + minimist "^1.1.1" + semver "^5.0.1" + +mongodb-version-manager@christkv/mongodb-version-manager#master: + version "1.0.7" + resolved "https://codeload.github.com/christkv/mongodb-version-manager/tar.gz/3ea7c20925d6a0b3a9243d341d3c69abf95e66b6" + dependencies: + ampersand-state "^5.0.1" + async "~1.5.0" + chalk "^1.1.1" + debug "~2.2.0" + docopt "~0.6.2" + figures "^1.4.0" + fs-extra "~0.30.0" + get-mongodb-version "0.0.1" + lodash.defaults "^3.1.2" + lodash.difference "^4.1.1" + mongodb-download-url "^0.1.10" + mongodb-version-list "0.0.3" + nugget "^2.0.0" + semver "~5.1.0" + tar "~2.2.1" + tildify "~1.2.0" + untildify "~2.1.0" + unzip "^0.1.11" + +mongodb@^2.0.39: + version "2.2.33" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.33.tgz#b537c471d34a6651b48f36fdbf29750340e08b50" + dependencies: + es6-promise "3.2.1" + mongodb-core "2.1.17" + readable-stream "2.2.7" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +mute-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" + +nan@~2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" + +natives@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.1.tgz#011acce1f7cbd87f7ba6b3093d6cd9392be1c574" + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.4.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" + +npmlog@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-1.0.0.tgz#ed2f290b60316887c39e0da9f09f8d13847cef0f" + dependencies: + ansi "~0.3.0" + are-we-there-yet "~1.0.0" + gauge "~1.0.2" + +nth-check@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.1.tgz#9929acdf628fc2c41098deab82ac580cf149aae4" + dependencies: + boolbase "~1.0.0" + +nugget@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/nugget/-/nugget-2.0.1.tgz#201095a487e1ad36081b3432fa3cada4f8d071b0" + dependencies: + debug "^2.1.3" + minimist "^1.1.0" + pretty-bytes "^1.0.2" + progress-stream "^1.1.0" + request "^2.45.0" + single-line-log "^1.1.2" + throttleit "0.0.2" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +nyc@^8.1.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/nyc/-/nyc-8.4.0.tgz#660371c807caef0427fb9b0948f74180624ea6e4" + dependencies: + archy "^1.0.0" + arrify "^1.0.1" + caching-transform "^1.0.0" + convert-source-map "^1.3.0" + default-require-extensions "^1.0.0" + find-cache-dir "^0.1.1" + find-up "^1.1.2" + foreground-child "^1.5.3" + glob "^7.0.6" + istanbul-lib-coverage "^1.0.0" + istanbul-lib-hook "^1.0.0-alpha.4" + istanbul-lib-instrument "^1.2.0" + istanbul-lib-report "^1.0.0-alpha.3" + istanbul-lib-source-maps "^1.0.2" + istanbul-reports "^1.0.0" + md5-hex "^1.2.0" + micromatch "^2.3.11" + mkdirp "^0.5.0" + resolve-from "^2.0.0" + rimraf "^2.5.4" + signal-exit "^3.0.1" + spawn-wrap "^1.2.4" + test-exclude "^2.1.3" + yargs "^6.0.0" + yargs-parser "^4.0.2" + +oauth-sign@~0.8.1, oauth-sign@~0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.0.1, object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-keys@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + +optimist@0.6.1, optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optimist@~0.3, optimist@~0.3.5: + version "0.3.7" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.7.tgz#c90941ad59e4273328923074d2cf2e7cbc6ec0d9" + dependencies: + wordwrap "~0.0.2" + +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-homedir@^1.0.0, os-homedir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + dependencies: + lcid "^1.0.0" + +os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +"over@>= 0.0.5 < 1": + version "0.0.5" + resolved "https://registry.yarnpkg.com/over/-/over-0.0.5.tgz#f29852e70fd7e25f360e013a8ec44c82aedb5708" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-is-inside@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +pause-stream@0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + dependencies: + through "~2.3" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pkg-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" + dependencies: + find-up "^1.0.0" + +pluralize@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +pretty-bytes@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" + dependencies: + get-stdin "^4.0.1" + meow "^3.1.0" + +private@^0.1.7: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +progress-stream@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/progress-stream/-/progress-stream-1.2.0.tgz#2cd3cfea33ba3a89c9c121ec3347abe9ab125f77" + dependencies: + speedometer "~0.1.2" + through2 "~0.2.3" + +progress@^1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + +prr@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +"pullstream@>= 0.4.1 < 1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/pullstream/-/pullstream-0.4.1.tgz#d6fb3bf5aed697e831150eb1002c25a3f8ae1314" + dependencies: + over ">= 0.0.5 < 1" + readable-stream "~1.0.31" + setimmediate ">= 1.0.2 < 2" + slice-stream ">= 1.0.0 < 2" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.3.0: + version "6.3.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" + +qs@~6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +raf@^3.1.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.0.tgz#a28876881b4bc2ca9117d4138163ddb80f781575" + dependencies: + performance-now "^2.1.0" + +randomatic@^1.1.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@1.1: + version "1.1.13" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@2.2.7: + version "2.2.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.7.tgz#07057acbe2467b22042d36f98c5ad507054e95b1" + dependencies: + buffer-shims "~1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~1.0.0" + util-deprecate "~1.0.1" + +"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.0, readable-stream@~1.0.31: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.2.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readline2@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + mute-stream "0.0.5" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +regenerator-runtime@^0.10.5: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +regex-cache@^0.4.2: + version "0.4.4" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" + dependencies: + is-equal-shallow "^0.1.3" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@2.79.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + qs "~6.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + uuid "^3.0.0" + +request@^2.34.0, request@^2.45.0, request@^2.65.0: + version "2.83.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + +require-uncached@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + +require_optional@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" + dependencies: + resolve-from "^2.0.0" + semver "^5.1.0" + +requizzle@~0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde" + dependencies: + underscore "~1.6.0" + +resolve-from@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" + +resolve-from@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" + +resolve@^1.1.6: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + dependencies: + path-parse "^1.0.5" + +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@2, rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +rimraf@2.2.6: + version "2.2.6" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.6.tgz#c59597569b14d956ad29cacc42bdddf5f0ea4f4c" + +rimraf@2.5.4: + version "2.5.4" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + dependencies: + glob "^7.0.5" + +run-async@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" + dependencies: + once "^1.3.0" + +rx-lite@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" + +semver@5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +semver@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.1.1.tgz#a3292a373e6f3e0798da0b20641b9a9c5bc47e19" + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +"setimmediate@>= 1.0.1 < 2", "setimmediate@>= 1.0.2 < 2": + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + +shelljs@^0.7.5: + version "0.7.8" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + +signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +single-line-log@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/single-line-log/-/single-line-log-1.1.2.tgz#c2f83f273a3e1a16edb0995661da0ed5ef033364" + dependencies: + string-width "^1.0.1" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +slice-ansi@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" + +"slice-stream@>= 1.0.0 < 2": + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-stream/-/slice-stream-1.0.0.tgz#5b33bd66f013b1a7f86460b03d463dec39ad3ea0" + dependencies: + readable-stream "~1.0.31" + +slide@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +sntp@2.x.x: + version "2.1.0" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + dependencies: + hoek "4.x.x" + +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + dependencies: + source-map "^0.5.6" + +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +source-map@~0.1.30, source-map@~0.1.7: + version "0.1.43" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + dependencies: + amdefine ">=0.0.4" + +spawn-wrap@^1.2.4: + version "1.4.2" + resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c" + dependencies: + foreground-child "^1.5.6" + mkdirp "^0.5.0" + os-homedir "^1.0.1" + rimraf "^2.6.2" + signal-exit "^3.0.2" + which "^1.3.0" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +speedometer@~0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-0.1.4.tgz#9876dbd2a169d3115402d48e6ea6329c8816a50d" + +split2@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/split2/-/split2-0.2.1.tgz#02ddac9adc03ec0bb78c1282ec079ca6e85ae900" + dependencies: + through2 "~0.6.1" + +split@0.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + dependencies: + through "2" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + +sshpk@^1.7.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +stream-combiner@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + dependencies: + duplexer "~0.1.1" + +string-width@^1.0.1, string-width@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string-width@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.0, string_decoder@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +stringstream@~0.0.4, stringstream@~0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@~1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^3.1.2: + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + dependencies: + has-flag "^1.0.0" + +table@^3.7.4, table@^3.7.8: + version "3.8.3" + resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" + dependencies: + ajv "^4.7.0" + ajv-keywords "^1.0.0" + chalk "^1.1.1" + lodash "^4.0.0" + slice-ansi "0.0.4" + string-width "^2.0.0" + +"taffydb@https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e": + version "2.6.2" + resolved "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e#3c549d2f5712d7d1d109ad6bb1a4084f1b7add4e" + +tar@~2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +test-exclude@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-2.1.3.tgz#a8d8968e1da83266f9864f2852c55e220f06434a" + dependencies: + arrify "^1.0.1" + micromatch "^2.3.11" + object-assign "^4.1.0" + read-pkg-up "^1.0.1" + require-main-filename "^1.0.1" + +text-table@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + +throttleit@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf" + +through2@^0.6.1, through2@^0.6.3, through2@~0.6.1: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.2.3.tgz#eb3284da4ea311b6cc8ace3653748a52abf25a3f" + dependencies: + readable-stream "~1.1.9" + xtend "~2.1.1" + +through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3, through@~2.3.1: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +tildify@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + dependencies: + os-homedir "^1.0.0" + +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + +tough-cookie@~2.3.0, tough-cookie@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" + dependencies: + punycode "^1.4.1" + +"traverse@>=0.3.0 <0.4": + version "0.3.9" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +uglify-js@^2.6: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-js@~2.3: + version "2.3.6" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.3.6.tgz#fa0984770b428b7a9b2a8058f46355d14fef211a" + dependencies: + async "~0.2.6" + optimist "~0.3.5" + source-map "~0.1.7" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +underscore-contrib@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7" + dependencies: + underscore "1.6.0" + +underscore@1.6.0, underscore@~1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" + +underscore@~1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + +untildify@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-2.1.0.tgz#17eb2807987f76952e9c0485fc311d06a826a2e0" + dependencies: + os-homedir "^1.0.0" + +unzip@^0.1.11: + version "0.1.11" + resolved "https://registry.yarnpkg.com/unzip/-/unzip-0.1.11.tgz#89749c63b058d7d90d619f86b98aa1535d3b97f0" + dependencies: + binary ">= 0.3.0 < 1" + fstream ">= 0.1.30 < 1" + match-stream ">= 0.0.2 < 1" + pullstream ">= 0.4.1 < 1" + readable-stream "~1.0.31" + setimmediate ">= 1.0.1 < 2" + +user-home@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" + dependencies: + os-homedir "^1.0.0" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^3.0.0, uuid@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +which-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" + +which@^1.1.1, which@^1.2.9, which@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + dependencies: + isexe "^2.0.0" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + +worker-farm@^1.3.1: + version "1.5.2" + resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.5.2.tgz#32b312e5dc3d5d45d79ef44acc2587491cd729ae" + dependencies: + errno "^0.1.4" + xtend "^4.0.1" + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +wrench@~1.5.8: + version "1.5.9" + resolved "https://registry.yarnpkg.com/wrench/-/wrench-1.5.9.tgz#411691c63a9b2531b1700267279bdeca23b2142a" + +write-file-atomic@^1.1.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + slide "^1.1.5" + +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +xtend@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" + dependencies: + object-keys "~0.4.0" + +y18n@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yargs-parser@^4.0.2, yargs-parser@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c" + dependencies: + camelcase "^3.0.0" + +yargs@^6.0.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208" + dependencies: + camelcase "^3.0.0" + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + os-locale "^1.4.0" + read-pkg-up "^1.0.1" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^1.0.2" + which-module "^1.0.0" + y18n "^3.2.1" + yargs-parser "^4.2.0" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" diff --git a/node_modules/mongoose/package.json b/node_modules/mongoose/package.json index 5db8720..4b623f6 100644 --- a/node_modules/mongoose/package.json +++ b/node_modules/mongoose/package.json @@ -1,26 +1,36 @@ { - "_from": "mongoose@^4.4.1", + "_args": [ + [ + "mongoose@4.13.14", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "mongoose@4.13.14", "_id": "mongoose@4.13.14", "_inBundle": false, "_integrity": "sha512-20zynb1fvCO37AP+0iTPGDbt4dJJkzM9fNK5BwKf5n+gFU5YYdXpnhxs9Kf8C+Fe0xY8vpUKV8wA7VGWcmDaFw==", "_location": "/mongoose", - "_phantomChildren": {}, + "_phantomChildren": { + "bson": "1.0.9", + "es6-promise": "3.2.1", + "readable-stream": "2.2.7", + "require_optional": "1.0.1" + }, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "mongoose@^4.4.1", + "raw": "mongoose@4.13.14", "name": "mongoose", "escapedName": "mongoose", - "rawSpec": "^4.4.1", + "rawSpec": "4.13.14", "saveSpec": null, - "fetchSpec": "^4.4.1" + "fetchSpec": "4.13.14" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.13.14.tgz", - "_shasum": "0eb6d4fc6a15c9834994ab4102da614421d1dff0", - "_spec": "mongoose@^4.4.1", + "_spec": "4.13.14", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Guillermo Rauch", @@ -40,7 +50,6 @@ "url": "https://github.com/Automattic/mongoose/issues/new", "email": "mongoose-orm@googlegroups.com" }, - "bundleDependencies": false, "dependencies": { "async": "2.6.0", "bson": "~1.0.4", @@ -56,7 +65,6 @@ "regexp-clone": "0.0.1", "sliced": "1.0.1" }, - "deprecated": false, "description": "Mongoose MongoDB ODM", "devDependencies": { "acquit": "0.4.1", diff --git a/node_modules/morgan/node_modules/basic-auth/package.json b/node_modules/morgan/node_modules/basic-auth/package.json index 39d0e32..1ed39eb 100644 --- a/node_modules/morgan/node_modules/basic-auth/package.json +++ b/node_modules/morgan/node_modules/basic-auth/package.json @@ -1,76 +1,65 @@ { - "name": "basic-auth", - "description": "node.js basic auth parser", - "version": "1.0.4", - "license": "MIT", - "keywords": [ - "basic", - "auth", - "authorization", - "basicauth" + "_args": [ + [ + "basic-auth@1.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/basic-auth.git" + "_from": "basic-auth@1.0.4", + "_id": "basic-auth@1.0.4", + "_inBundle": false, + "_integrity": "sha1-Awk1sB3nyblKgksp8/zLdQ06UpA=", + "_location": "/morgan/basic-auth", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "basic-auth@1.0.4", + "name": "basic-auth", + "escapedName": "basic-auth", + "rawSpec": "1.0.4", + "saveSpec": null, + "fetchSpec": "1.0.4" }, + "_requiredBy": [ + "/morgan" + ], + "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.0.4.tgz", + "_spec": "1.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/basic-auth/issues" + }, + "description": "node.js basic auth parser", "devDependencies": { "istanbul": "0.4.3", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/basic-auth#readme", + "keywords": [ + "basic", + "auth", + "authorization", + "basicauth" + ], + "license": "MIT", + "name": "basic-auth", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/basic-auth.git" }, "scripts": { "test": "mocha --check-leaks --reporter spec --bail", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "4682d99600383bad5a266efbaa5055657dd9891d", - "bugs": { - "url": "https://github.com/jshttp/basic-auth/issues" - }, - "homepage": "https://github.com/jshttp/basic-auth#readme", - "_id": "basic-auth@1.0.4", - "_shasum": "030935b01de7c9b94a824b29f3fccb750d3a5290", - "_from": "basic-auth@>=1.0.3 <1.1.0", - "_npmVersion": "2.15.1", - "_nodeVersion": "4.4.3", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "dist": { - "shasum": "030935b01de7c9b94a824b29f3fccb750d3a5290", - "tarball": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.0.4.tgz" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/basic-auth-1.0.4.tgz_1462938878912_0.717464140150696" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.0.4.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.4" } diff --git a/node_modules/morgan/node_modules/debug/node_modules/ms/package.json b/node_modules/morgan/node_modules/debug/node_modules/ms/package.json index e36489e..09bee65 100644 --- a/node_modules/morgan/node_modules/debug/node_modules/ms/package.json +++ b/node_modules/morgan/node_modules/debug/node_modules/ms/package.json @@ -1,48 +1,52 @@ { - "name": "ms", - "version": "0.7.1", - "description": "Tiny ms conversion utility", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" + "_args": [ + [ + "ms@0.7.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.1", + "_id": "ms@0.7.1", + "_inBundle": false, + "_integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "_location": "/morgan/debug/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.1", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.1", + "saveSpec": null, + "fetchSpec": "0.7.1" }, - "main": "./index", - "devDependencies": { - "mocha": "*", - "expect.js": "*", - "serve": "*" + "_requiredBy": [ + "/morgan/debug" + ], + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "_spec": "0.7.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/guille/ms.js/issues" }, "component": { "scripts": { "ms/index.js": "index.js" } }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "homepage": "https://github.com/guille/ms.js", - "_id": "ms@0.7.1", - "scripts": {}, - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_from": "ms@0.7.1", - "_npmVersion": "2.7.5", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" + "description": "Tiny ms conversion utility", + "devDependencies": { + "expect.js": "*", + "mocha": "*", + "serve": "*" }, - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + "homepage": "https://github.com/guille/ms.js#readme", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git://github.com/guille/ms.js.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "readme": "ERROR: No README data found!" + "version": "0.7.1" } diff --git a/node_modules/morgan/node_modules/debug/package.json b/node_modules/morgan/node_modules/debug/package.json index f2148c9..938bebb 100644 --- a/node_modules/morgan/node_modules/debug/package.json +++ b/node_modules/morgan/node_modules/debug/package.json @@ -1,20 +1,46 @@ { - "name": "debug", - "version": "2.2.0", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" + "_args": [ + [ + "debug@2.2.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "debug@2.2.0", + "_id": "debug@2.2.0", + "_inBundle": false, + "_integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "_location": "/morgan/debug", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "debug@2.2.0", + "name": "debug", + "escapedName": "debug", + "rawSpec": "2.2.0", + "saveSpec": null, + "fetchSpec": "2.2.0" }, - "description": "small debugging utility", - "keywords": [ - "debug", - "log", - "debugger" + "_requiredBy": [ + "/morgan" ], + "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "_spec": "2.2.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, + "browser": "./browser.js", + "bugs": { + "url": "https://github.com/visionmedia/debug/issues" + }, + "component": { + "scripts": { + "debug/index.js": "browser.js", + "debug/debug.js": "debug.js" + } + }, "contributors": [ { "name": "Nathan Rajlich", @@ -22,52 +48,26 @@ "url": "http://n8.io" } ], - "license": "MIT", "dependencies": { "ms": "0.7.1" }, + "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", "mocha": "*" }, - "main": "./node.js", - "browser": "./browser.js", - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "homepage": "https://github.com/visionmedia/debug", - "_id": "debug@2.2.0", - "scripts": {}, - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_from": "debug@>=2.2.0 <2.3.0", - "_npmVersion": "2.7.4", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } + "homepage": "https://github.com/visionmedia/debug#readme", + "keywords": [ + "debug", + "log", + "debugger" ], - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + "license": "MIT", + "main": "./node.js", + "name": "debug", + "repository": { + "type": "git", + "url": "git://github.com/visionmedia/debug.git" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.2.0" } diff --git a/node_modules/morgan/node_modules/depd/package.json b/node_modules/morgan/node_modules/depd/package.json index edfc0b2..ea61e9f 100644 --- a/node_modules/morgan/node_modules/depd/package.json +++ b/node_modules/morgan/node_modules/depd/package.json @@ -1,27 +1,50 @@ { - "name": "depd", - "description": "Deprecate all the things", - "version": "1.1.0", + "_args": [ + [ + "depd@1.1.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "depd@1.1.0", + "_id": "depd@1.1.0", + "_inBundle": false, + "_integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=", + "_location": "/morgan/depd", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "depd@1.1.0", + "name": "depd", + "escapedName": "depd", + "rawSpec": "1.1.0", + "saveSpec": null, + "fetchSpec": "1.1.0" + }, + "_requiredBy": [ + "/morgan" + ], + "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", + "_spec": "1.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "deprecate", - "deprecated" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/dougwilson/nodejs-depd.git" - }, "browser": "lib/browser/index.js", + "bugs": { + "url": "https://github.com/dougwilson/nodejs-depd/issues" + }, + "description": "Deprecate all the things", "devDependencies": { - "benchmark": "1.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0", "istanbul": "0.3.5", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "lib/", "History.md", @@ -29,8 +52,16 @@ "index.js", "Readme.md" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/dougwilson/nodejs-depd#readme", + "keywords": [ + "deprecate", + "deprecated" + ], + "license": "MIT", + "name": "depd", + "repository": { + "type": "git", + "url": "git+https://github.com/dougwilson/nodejs-depd.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -38,30 +69,5 @@ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" }, - "gitHead": "78c659de20283e3a6bee92bda455e6daff01686a", - "bugs": { - "url": "https://github.com/dougwilson/nodejs-depd/issues" - }, - "homepage": "https://github.com/dougwilson/nodejs-depd", - "_id": "depd@1.1.0", - "_shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "_from": "depd@>=1.1.0 <1.2.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "e1bd82c6aab6ced965b97b88b17ed3e528ca18c3", - "tarball": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.0" } diff --git a/node_modules/morgan/node_modules/on-finished/node_modules/ee-first/package.json b/node_modules/morgan/node_modules/on-finished/node_modules/ee-first/package.json index c67faf1..275e104 100644 --- a/node_modules/morgan/node_modules/on-finished/node_modules/ee-first/package.json +++ b/node_modules/morgan/node_modules/on-finished/node_modules/ee-first/package.json @@ -1,23 +1,47 @@ { - "name": "ee-first", - "description": "return the first event in a set of ee/event pairs", - "version": "1.1.1", + "_args": [ + [ + "ee-first@1.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ee-first@1.1.1", + "_id": "ee-first@1.1.1", + "_inBundle": false, + "_integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", + "_location": "/morgan/on-finished/ee-first", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ee-first@1.1.1", + "name": "ee-first", + "escapedName": "ee-first", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/morgan/on-finished" + ], + "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/jonathanong/ee-first/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jonathanong/ee-first.git" - }, + "description": "return the first event in a set of ee/event pairs", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -26,39 +50,17 @@ "index.js", "LICENSE" ], + "homepage": "https://github.com/jonathanong/ee-first#readme", + "license": "MIT", + "name": "ee-first", + "repository": { + "type": "git", + "url": "git+https://github.com/jonathanong/ee-first.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "512e0ce4cc3643f603708f965a97b61b1a9c0441", - "bugs": { - "url": "https://github.com/jonathanong/ee-first/issues" - }, - "homepage": "https://github.com/jonathanong/ee-first", - "_id": "ee-first@1.1.1", - "_shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "_from": "ee-first@1.1.1", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "590c61156b0ae2f4f0255732a158b266bc56b21d", - "tarball": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.1.1" } diff --git a/node_modules/morgan/node_modules/on-finished/package.json b/node_modules/morgan/node_modules/on-finished/package.json index 97a5680..d38ce62 100644 --- a/node_modules/morgan/node_modules/on-finished/package.json +++ b/node_modules/morgan/node_modules/on-finished/package.json @@ -1,7 +1,35 @@ { - "name": "on-finished", - "description": "Execute a callback when a request closes, finishes, or errors", - "version": "2.3.0", + "_args": [ + [ + "on-finished@2.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "on-finished@2.3.0", + "_id": "on-finished@2.3.0", + "_inBundle": false, + "_integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "_location": "/morgan/on-finished", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "on-finished@2.3.0", + "name": "on-finished", + "escapedName": "on-finished", + "rawSpec": "2.3.0", + "saveSpec": null, + "fetchSpec": "2.3.0" + }, + "_requiredBy": [ + "/morgan" + ], + "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "_spec": "2.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/on-finished/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,14 +41,10 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/on-finished.git" - }, "dependencies": { "ee-first": "1.1.1" }, + "description": "Execute a callback when a request closes, finishes, or errors", "devDependencies": { "istanbul": "0.3.9", "mocha": "2.2.5" @@ -33,39 +57,17 @@ "LICENSE", "index.js" ], + "homepage": "https://github.com/jshttp/on-finished#readme", + "license": "MIT", + "name": "on-finished", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-finished.git" + }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "34babcb58126a416fcf5205768204f2e12699dda", - "bugs": { - "url": "https://github.com/jshttp/on-finished/issues" - }, - "homepage": "https://github.com/jshttp/on-finished", - "_id": "on-finished@2.3.0", - "_shasum": "20f1336481b083cd75337992a16971aa2d906947", - "_from": "on-finished@>=2.3.0 <2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "20f1336481b083cd75337992a16971aa2d906947", - "tarball": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "2.3.0" } diff --git a/node_modules/morgan/node_modules/on-headers/package.json b/node_modules/morgan/node_modules/on-headers/package.json index cf1eed5..aa626a7 100644 --- a/node_modules/morgan/node_modules/on-headers/package.json +++ b/node_modules/morgan/node_modules/on-headers/package.json @@ -1,70 +1,72 @@ { - "name": "on-headers", - "description": "Execute a listener when a response is about to write headers", - "version": "1.0.1", + "_args": [ + [ + "on-headers@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "on-headers@1.0.1", + "_id": "on-headers@1.0.1", + "_inBundle": false, + "_integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", + "_location": "/morgan/on-headers", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "on-headers@1.0.1", + "name": "on-headers", + "escapedName": "on-headers", + "rawSpec": "1.0.1", + "saveSpec": null, + "fetchSpec": "1.0.1" + }, + "_requiredBy": [ + "/morgan" + ], + "_resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "event", - "headers", - "http", - "onheaders" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/on-headers.git" + "bugs": { + "url": "https://github.com/jshttp/on-headers/issues" }, "dependencies": {}, + "description": "Execute a listener when a response is about to write headers", "devDependencies": { "istanbul": "0.3.21", "mocha": "2.3.3", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/jshttp/on-headers#readme", + "keywords": [ + "event", + "headers", + "http", + "onheaders" + ], + "license": "MIT", + "name": "on-headers", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-headers.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "ab0156a979d72353cfe666cccb3639e016b00280", - "bugs": { - "url": "https://github.com/jshttp/on-headers/issues" - }, - "homepage": "https://github.com/jshttp/on-headers", - "_id": "on-headers@1.0.1", - "_shasum": "928f5d0f470d49342651ea6794b0857c100693f7", - "_from": "on-headers@>=1.0.1 <1.1.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "928f5d0f470d49342651ea6794b0857c100693f7", - "tarball": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.0.1" } diff --git a/node_modules/morgan/package.json b/node_modules/morgan/package.json index d6194e4..7a45a5b 100644 --- a/node_modules/morgan/package.json +++ b/node_modules/morgan/package.json @@ -1,7 +1,35 @@ { - "name": "morgan", - "description": "HTTP request logger middleware for node.js", - "version": "1.7.0", + "_args": [ + [ + "morgan@1.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "morgan@1.7.0", + "_id": "morgan@1.7.0", + "_inBundle": false, + "_integrity": "sha1-6xDKjlDRq+D409rVwCAdBS2YHGI=", + "_location": "/morgan", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "morgan@1.7.0", + "name": "morgan", + "escapedName": "morgan", + "rawSpec": "1.7.0", + "saveSpec": null, + "fetchSpec": "1.7.0" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/morgan/-/morgan-1.7.0.tgz", + "_spec": "1.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/expressjs/morgan/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -13,11 +41,6 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/morgan.git" - }, "dependencies": { "basic-auth": "~1.0.3", "debug": "~2.2.0", @@ -25,74 +48,33 @@ "on-finished": "~2.3.0", "on-headers": "~1.0.1" }, + "description": "HTTP request logger middleware for node.js", "devDependencies": { "istanbul": "0.4.2", "mocha": "2.4.5", "split": "1.0.0", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8.0" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8.0" + "homepage": "https://github.com/expressjs/morgan#readme", + "license": "MIT", + "name": "morgan", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/morgan.git" }, "scripts": { "test": "mocha --check-leaks --reporter spec --bail", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec" }, - "gitHead": "5da5ff1f5446e3f3ff29d29a2d6582712612bf89", - "bugs": { - "url": "https://github.com/expressjs/morgan/issues" - }, - "homepage": "https://github.com/expressjs/morgan", - "_id": "morgan@1.7.0", - "_shasum": "eb10ca8e50d1abe0f8d3dad5c0201d052d981c62", - "_from": "morgan@>=1.7.0 <1.8.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - } - ], - "dist": { - "shasum": "eb10ca8e50d1abe0f8d3dad5c0201d052d981c62", - "tarball": "https://registry.npmjs.org/morgan/-/morgan-1.7.0.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-6-west.internal.npmjs.com", - "tmp": "tmp/morgan-1.7.0.tgz_1455857999079_0.07957377028651536" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/morgan/-/morgan-1.7.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.7.0" } diff --git a/node_modules/mpath/package.json b/node_modules/mpath/package.json index b72eb6b..11dd0ca 100644 --- a/node_modules/mpath/package.json +++ b/node_modules/mpath/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "mpath@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "mpath@0.3.0", "_id": "mpath@0.3.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz", - "_shasum": "7a58f789e9b5fd3c94520634157960f26bd5ef44", - "_spec": "mpath@0.3.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/aheckmann/mpath/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "{G,S}et object values using MongoDB-like path notation", "devDependencies": { "benchmark": "~1.0.0", diff --git a/node_modules/mpromise/package.json b/node_modules/mpromise/package.json index 8dc3368..c686864 100644 --- a/node_modules/mpromise/package.json +++ b/node_modules/mpromise/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "mpromise@0.5.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "mpromise@0.5.5", "_id": "mpromise@0.5.5", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz", - "_shasum": "f5b24259d763acc2257b0a0c8c6d866fd51732e6", - "_spec": "mpromise@0.5.5", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "0.5.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -29,7 +34,6 @@ "bugs": { "url": "https://github.com/aheckmann/mpromise/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Refael Ackermann", @@ -37,7 +41,6 @@ "url": "http://node.org.il/" } ], - "deprecated": false, "description": "Promises A+ conformant implementation", "devDependencies": { "mocha": "1.21.4", diff --git a/node_modules/mquery/node_modules/debug/package.json b/node_modules/mquery/node_modules/debug/package.json index f28d790..eb5cba2 100644 --- a/node_modules/mquery/node_modules/debug/package.json +++ b/node_modules/mquery/node_modules/debug/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "debug@2.6.9", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "debug@2.6.9", "_id": "debug@2.6.9", "_inBundle": false, @@ -19,9 +25,8 @@ "/mquery" ], "_resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "_shasum": "5d128515df134ff327e90a4c93f4e077a536341f", - "_spec": "debug@2.6.9", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mquery", + "_spec": "2.6.9", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" @@ -30,7 +35,6 @@ "bugs": { "url": "https://github.com/visionmedia/debug/issues" }, - "bundleDependencies": false, "component": { "scripts": { "debug/index.js": "browser.js", @@ -51,7 +55,6 @@ "dependencies": { "ms": "2.0.0" }, - "deprecated": false, "description": "small debugging utility", "devDependencies": { "browserify": "9.0.3", diff --git a/node_modules/mquery/node_modules/sliced/package.json b/node_modules/mquery/node_modules/sliced/package.json index a36ffc9..c97f2a9 100644 --- a/node_modules/mquery/node_modules/sliced/package.json +++ b/node_modules/mquery/node_modules/sliced/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "sliced@0.0.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "sliced@0.0.5", "_id": "sliced@0.0.5", "_inBundle": false, @@ -19,9 +25,8 @@ "/mquery" ], "_resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", - "_shasum": "5edc044ca4eb6f7816d50ba2fc63e25d8fe4707f", - "_spec": "sliced@0.0.5", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mquery", + "_spec": "0.0.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/aheckmann/sliced/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "A faster Node.js alternative to Array.prototype.slice.call(arguments)", "devDependencies": { "benchmark": "~1.0.0", diff --git a/node_modules/mquery/package.json b/node_modules/mquery/package.json index 33ea5cd..63e3288 100644 --- a/node_modules/mquery/package.json +++ b/node_modules/mquery/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "mquery@2.3.3", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "mquery@2.3.3", "_id": "mquery@2.3.3", "_inBundle": false, @@ -21,9 +27,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.3.tgz", - "_shasum": "221412e5d4e7290ca5582dd16ea8f190a506b518", - "_spec": "mquery@2.3.3", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "2.3.3", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -31,14 +36,12 @@ "bugs": { "url": "https://github.com/aheckmann/mquery/issues/new" }, - "bundleDependencies": false, "dependencies": { "bluebird": "3.5.0", "debug": "2.6.9", "regexp-clone": "0.0.1", "sliced": "0.0.5" }, - "deprecated": false, "description": "Expressive query building for MongoDB", "devDependencies": { "istanbul": "0.3.2", diff --git a/node_modules/ms/package.json b/node_modules/ms/package.json index 55b0559..e411167 100644 --- a/node_modules/ms/package.json +++ b/node_modules/ms/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "ms@2.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "ms@2.0.0", "_id": "ms@2.0.0", "_inBundle": false, @@ -21,14 +27,11 @@ "/mquery/debug" ], "_resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "_shasum": "5608aeadfc00be6c2901df5f9861788de0d597c8", - "_spec": "ms@2.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session/node_modules/debug", + "_spec": "2.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/zeit/ms/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Tiny milisecond conversion utility", "devDependencies": { "eslint": "3.19.0", diff --git a/node_modules/multer/CHANGELOG.md b/node_modules/multer/CHANGELOG.md index 2703f1b..e1791b0 100644 --- a/node_modules/multer/CHANGELOG.md +++ b/node_modules/multer/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 1.3.1 - 2018-06-28 + +- Bugfix: Bump vulnerable dependency + ## 1.3.0 - 2017-01-25 - Feature: Expose preservePath option diff --git a/node_modules/multer/README.md b/node_modules/multer/README.md index d656cc2..b1b321f 100644 --- a/node_modules/multer/README.md +++ b/node_modules/multer/README.md @@ -10,6 +10,7 @@ on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency. This README is also available in other languages: - [简体中文](https://github.com/expressjs/multer/blob/master/doc/README-zh-cn.md) (Chinese) +- [한국어](https://github.com/expressjs/multer/blob/master/doc/README-ko.md) (Korean) ## Installation diff --git a/node_modules/multer/node_modules/.bin/mkdirp b/node_modules/multer/node_modules/.bin/mkdirp deleted file mode 100755 index d95de15..0000000 --- a/node_modules/multer/node_modules/.bin/mkdirp +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -var mkdirp = require('../'); -var minimist = require('minimist'); -var fs = require('fs'); - -var argv = minimist(process.argv.slice(2), { - alias: { m: 'mode', h: 'help' }, - string: [ 'mode' ] -}); -if (argv.help) { - fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout); - return; -} - -var paths = argv._.slice(); -var mode = argv.mode ? parseInt(argv.mode, 8) : undefined; - -(function next () { - if (paths.length === 0) return; - var p = paths.shift(); - - if (mode === undefined) mkdirp(p, cb) - else mkdirp(p, mode, cb) - - function cb (err) { - if (err) { - console.error(err.message); - process.exit(1); - } - else next(); - } -})(); diff --git a/node_modules/multer/node_modules/.bin/mkdirp b/node_modules/multer/node_modules/.bin/mkdirp new file mode 120000 index 0000000..017896c --- /dev/null +++ b/node_modules/multer/node_modules/.bin/mkdirp @@ -0,0 +1 @@ +../mkdirp/bin/cmd.js \ No newline at end of file diff --git a/node_modules/multer/node_modules/append-field/.npmignore b/node_modules/multer/node_modules/append-field/.npmignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/.npmignore @@ -0,0 +1 @@ +node_modules/ diff --git a/node_modules/multer/node_modules/append-field/LICENSE b/node_modules/multer/node_modules/append-field/LICENSE new file mode 100644 index 0000000..14b1f89 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Linus Unnebäck + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/multer/node_modules/append-field/README.md b/node_modules/multer/node_modules/append-field/README.md new file mode 100644 index 0000000..62b901b --- /dev/null +++ b/node_modules/multer/node_modules/append-field/README.md @@ -0,0 +1,44 @@ +# `append-field` + +A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant +field appender (for lack of a better name). Useful for people implementing +`application/x-www-form-urlencoded` and `multipart/form-data` parsers. + +It works best on objects created with `Object.create(null)`. Otherwise it might +conflict with variables from the prototype (e.g. `hasOwnProperty`). + +## Installation + +```sh +npm install --save append-field +``` + +## Usage + +```javascript +var appendField = require('append-field') +var obj = Object.create(null) + +appendField(obj, 'pets[0][species]', 'Dahut') +appendField(obj, 'pets[0][name]', 'Hypatia') +appendField(obj, 'pets[1][species]', 'Felis Stultus') +appendField(obj, 'pets[1][name]', 'Billie') + +console.log(obj) +``` + +```text +{ pets: + [ { species: 'Dahut', name: 'Hypatia' }, + { species: 'Felis Stultus', name: 'Billie' } ] } +``` + +## API + +### `appendField(store, key, value)` + +Adds the field named `key` with the value `value` to the object `store`. + +## License + +MIT diff --git a/node_modules/multer/node_modules/append-field/index.js b/node_modules/multer/node_modules/append-field/index.js new file mode 100644 index 0000000..fc5acc8 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/index.js @@ -0,0 +1,12 @@ +var parsePath = require('./lib/parse-path') +var setValue = require('./lib/set-value') + +function appendField (store, key, value) { + var steps = parsePath(key) + + steps.reduce(function (context, step) { + return setValue(context, step, context[step.key], value) + }, store) +} + +module.exports = appendField diff --git a/node_modules/multer/node_modules/append-field/lib/parse-path.js b/node_modules/multer/node_modules/append-field/lib/parse-path.js new file mode 100644 index 0000000..31d6179 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/lib/parse-path.js @@ -0,0 +1,53 @@ +var reFirstKey = /^[^\[]*/ +var reDigitPath = /^\[(\d+)\]/ +var reNormalPath = /^\[([^\]]+)\]/ + +function parsePath (key) { + function failure () { + return [{ type: 'object', key: key, last: true }] + } + + var firstKey = reFirstKey.exec(key)[0] + if (!firstKey) return failure() + + var len = key.length + var pos = firstKey.length + var tail = { type: 'object', key: firstKey } + var steps = [tail] + + while (pos < len) { + var m + + if (key[pos] === '[' && key[pos + 1] === ']') { + pos += 2 + tail.append = true + if (pos !== len) return failure() + continue + } + + m = reDigitPath.exec(key.substring(pos)) + if (m !== null) { + pos += m[0].length + tail.nextType = 'array' + tail = { type: 'array', key: parseInt(m[1], 10) } + steps.push(tail) + continue + } + + m = reNormalPath.exec(key.substring(pos)) + if (m !== null) { + pos += m[0].length + tail.nextType = 'object' + tail = { type: 'object', key: m[1] } + steps.push(tail) + continue + } + + return failure() + } + + tail.last = true + return steps +} + +module.exports = parsePath diff --git a/node_modules/multer/node_modules/append-field/lib/set-value.js b/node_modules/multer/node_modules/append-field/lib/set-value.js new file mode 100644 index 0000000..c15e873 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/lib/set-value.js @@ -0,0 +1,64 @@ +function valueType (value) { + if (value === undefined) return 'undefined' + if (Array.isArray(value)) return 'array' + if (typeof value === 'object') return 'object' + return 'scalar' +} + +function setLastValue (context, step, currentValue, entryValue) { + switch (valueType(currentValue)) { + case 'undefined': + if (step.append) { + context[step.key] = [entryValue] + } else { + context[step.key] = entryValue + } + break + case 'array': + context[step.key].push(entryValue) + break + case 'object': + return setLastValue(currentValue, { type: 'object', key: '', last: true }, currentValue[''], entryValue) + case 'scalar': + context[step.key] = [context[step.key], entryValue] + break + } + + return context +} + +function setValue (context, step, currentValue, entryValue) { + if (step.last) return setLastValue(context, step, currentValue, entryValue) + + var obj + switch (valueType(currentValue)) { + case 'undefined': + if (step.nextType === 'array') { + context[step.key] = [] + } else { + context[step.key] = Object.create(null) + } + return context[step.key] + case 'object': + return context[step.key] + case 'array': + if (step.nextType === 'array') { + return currentValue + } + + obj = Object.create(null) + context[step.key] = obj + currentValue.forEach(function (item, i) { + if (item !== undefined) obj['' + i] = item + }) + + return obj + case 'scalar': + obj = Object.create(null) + obj[''] = currentValue + context[step.key] = obj + return obj + } +} + +module.exports = setValue diff --git a/node_modules/multer/node_modules/append-field/package.json b/node_modules/multer/node_modules/append-field/package.json new file mode 100644 index 0000000..2d9b7f6 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/package.json @@ -0,0 +1,52 @@ +{ + "_from": "append-field@^0.1.0", + "_id": "append-field@0.1.0", + "_inBundle": false, + "_integrity": "sha1-bdxY+gg8e8VF08WZWygwzCNm1Eo=", + "_location": "/multer/append-field", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "append-field@^0.1.0", + "name": "append-field", + "escapedName": "append-field", + "rawSpec": "^0.1.0", + "saveSpec": null, + "fetchSpec": "^0.1.0" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz", + "_shasum": "6ddc58fa083c7bc545d3c5995b2830cc2366d44a", + "_spec": "append-field@^0.1.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "author": { + "name": "Linus Unnebäck", + "email": "linus@folkdatorn.se" + }, + "bugs": { + "url": "https://github.com/LinusU/node-append-field/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A [W3C HTML JSON forms spec](http://www.w3.org/TR/html-json-forms/) compliant field appender (for lack of a better name). Useful for people implementing `application/x-www-form-urlencoded` and `multipart/form-data` parsers.", + "devDependencies": { + "mocha": "^2.2.4", + "standard": "^3.7.2", + "testdata-w3c-json-form": "^0.2.0" + }, + "homepage": "https://github.com/LinusU/node-append-field#readme", + "license": "MIT", + "main": "index.js", + "name": "append-field", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/LinusU/node-append-field.git" + }, + "scripts": { + "test": "standard && mocha" + }, + "version": "0.1.0" +} diff --git a/node_modules/multer/node_modules/append-field/test/forms.js b/node_modules/multer/node_modules/append-field/test/forms.js new file mode 100644 index 0000000..dd6fbc9 --- /dev/null +++ b/node_modules/multer/node_modules/append-field/test/forms.js @@ -0,0 +1,19 @@ +/* eslint-env mocha */ + +var assert = require('assert') +var appendField = require('../') +var testData = require('testdata-w3c-json-form') + +describe('Append Field', function () { + for (var test of testData) { + it('handles ' + test.name, function () { + var store = Object.create(null) + + for (var field of test.fields) { + appendField(store, field.key, field.value) + } + + assert.deepEqual(store, test.expected) + }) + } +}) diff --git a/node_modules/multer/node_modules/mkdirp/package.json b/node_modules/multer/node_modules/mkdirp/package.json index fd29382..5fe5da2 100644 --- a/node_modules/multer/node_modules/mkdirp/package.json +++ b/node_modules/multer/node_modules/mkdirp/package.json @@ -1,17 +1,56 @@ { - "name": "mkdirp", - "description": "Recursively mkdir, like `mkdir -p`", - "version": "0.5.1", + "_from": "mkdirp@^0.5.1", + "_id": "mkdirp@0.5.1", + "_inBundle": false, + "_integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "_location": "/multer/mkdirp", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "mkdirp@^0.5.1", + "name": "mkdirp", + "escapedName": "mkdirp", + "rawSpec": "^0.5.1", + "saveSpec": null, + "fetchSpec": "^0.5.1" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", + "_spec": "mkdirp@^0.5.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, - "main": "index.js", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "bugs": { + "url": "https://github.com/substack/node-mkdirp/issues" + }, + "bundleDependencies": false, + "dependencies": { + "minimist": "0.0.8" + }, + "deprecated": false, + "description": "Recursively mkdir, like `mkdir -p`", + "devDependencies": { + "mock-fs": "2 >=2.7.0", + "tap": "1" + }, + "homepage": "https://github.com/substack/node-mkdirp#readme", "keywords": [ "mkdir", "directory" ], + "license": "MIT", + "main": "index.js", + "name": "mkdirp", "repository": { "type": "git", "url": "git+https://github.com/substack/node-mkdirp.git" @@ -19,41 +58,5 @@ "scripts": { "test": "tap test/*.js" }, - "dependencies": { - "minimist": "0.0.8" - }, - "devDependencies": { - "tap": "1", - "mock-fs": "2 >=2.7.0" - }, - "bin": { - "mkdirp": "bin/cmd.js" - }, - "license": "MIT", - "gitHead": "d4eff0f06093aed4f387e88e9fc301cb76beedc7", - "bugs": { - "url": "https://github.com/substack/node-mkdirp/issues" - }, - "homepage": "https://github.com/substack/node-mkdirp#readme", - "_id": "mkdirp@0.5.1", - "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", - "_from": "mkdirp@>=0.5.1 <0.6.0", - "_npmVersion": "2.9.0", - "_nodeVersion": "2.0.0", - "_npmUser": { - "name": "substack", - "email": "substack@gmail.com" - }, - "dist": { - "shasum": "30057438eac6cf7f8c4767f38648d6697d75c903", - "tarball": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" + "version": "0.5.1" } diff --git a/node_modules/multer/package.json b/node_modules/multer/package.json index 12f9bdb..3ff4609 100644 --- a/node_modules/multer/package.json +++ b/node_modules/multer/package.json @@ -1,7 +1,33 @@ { - "name": "multer", - "description": "Middleware for handling `multipart/form-data`.", - "version": "1.3.0", + "_from": "multer@latest", + "_id": "multer@1.3.1", + "_inBundle": false, + "_integrity": "sha512-JHdEoxkA/5NgZRo91RNn4UT+HdcJV9XUo01DTkKC7vo1erNIngtuaw9Y0WI8RdTlyi+wMIbunflhghzVLuGJyw==", + "_location": "/multer", + "_phantomChildren": { + "minimist": "0.0.8" + }, + "_requested": { + "type": "tag", + "registry": true, + "raw": "multer@latest", + "name": "multer", + "escapedName": "multer", + "rawSpec": "latest", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/multer/-/multer-1.3.1.tgz", + "_shasum": "c3fb3b35f50c7eefe873532f90d3dde02ce6e040", + "_spec": "multer@latest", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/expressjs/multer/issues" + }, + "bundleDependencies": false, "contributors": [ { "name": "Hage Yaapa", @@ -17,30 +43,18 @@ "email": "linus@folkdatorn.se" } ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/expressjs/multer.git" - }, - "keywords": [ - "form", - "post", - "multipart", - "form-data", - "formdata", - "express", - "middleware" - ], "dependencies": { "append-field": "^0.1.0", "busboy": "^0.2.11", - "concat-stream": "^1.5.0", + "concat-stream": "^1.5.2", "mkdirp": "^0.5.1", "object-assign": "^3.0.0", "on-finished": "^2.3.0", "type-is": "^1.6.4", "xtend": "^4.0.0" }, + "deprecated": false, + "description": "Middleware for handling `multipart/form-data`.", "devDependencies": { "express": "^4.13.1", "form-data": "^1.0.0-rc1", @@ -59,45 +73,24 @@ "storage/", "lib/" ], - "scripts": { - "test": "standard && mocha" - }, - "gitHead": "7ef2e81215e9b773204df44fb4aee29e58340061", - "bugs": { - "url": "https://github.com/expressjs/multer/issues" - }, "homepage": "https://github.com/expressjs/multer#readme", - "_id": "multer@1.3.0", - "_shasum": "092b2670f6846fa4914965efc8cf94c20fec6cd2", - "_from": "multer@latest", - "_npmVersion": "4.0.5", - "_nodeVersion": "7.4.0", - "_npmUser": { - "name": "linusu", - "email": "linus@folkdatorn.se" - }, - "dist": { - "shasum": "092b2670f6846fa4914965efc8cf94c20fec6cd2", - "tarball": "https://registry.npmjs.org/multer/-/multer-1.3.0.tgz" - }, - "maintainers": [ - { - "name": "hacksparrow", - "email": "captain@hacksparrow.com" - }, - { - "name": "linusu", - "email": "linus@folkdatorn.se" - }, - { - "name": "jpfluger", - "email": "japes@aberlorn.com" - } + "keywords": [ + "form", + "post", + "multipart", + "form-data", + "formdata", + "express", + "middleware" ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/multer-1.3.0.tgz_1485368514719_0.7731788263190538" + "license": "MIT", + "name": "multer", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/multer.git" + }, + "scripts": { + "test": "standard && mocha" }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/multer/-/multer-1.3.0.tgz" + "version": "1.3.1" } diff --git a/node_modules/muri/package.json b/node_modules/muri/package.json index 00cb908..42dd99e 100644 --- a/node_modules/muri/package.json +++ b/node_modules/muri/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "muri@1.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "muri@1.3.0", "_id": "muri@1.3.0", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/muri/-/muri-1.3.0.tgz", - "_shasum": "aeccf3db64c56aa7c5b34e00f95b7878527a4721", - "_spec": "muri@1.3.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "1.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/aheckmann/muri/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "MongoDB URI parser", "devDependencies": { "mocha": "1.21.5" diff --git a/node_modules/nodemailer/CHANGELOG.md b/node_modules/nodemailer/CHANGELOG.md new file mode 100644 index 0000000..242d28c --- /dev/null +++ b/node_modules/nodemailer/CHANGELOG.md @@ -0,0 +1,522 @@ +# CHANGELOG + +## 4.6.8 2018-08-15 + +- Use first IP address from DNS resolution when using a proxy (Limbozz) [d4ca847c] +- Return raw email from SES transport (gabegorelick) [3aa08967] + +## 4.6.7 2018-06-15 + +- Added option `skipEncoding` to JSONTransport + +## 4.6.6 2018-06-10 + +- Fixes mime encoded-word compatibility issue with invalid clients like Zimbra + +## 4.6.5 2018-05-23 + +- Fixed broken DKIM stream in Node.js v10 +- Updated error messages for SMTP responses to not include a newline + +## 4.6.4 2018-03-31 + +- Readded logo author link to README that was accidentally removed a while ago + +## 4.6.3 2018-03-13 + +- Removed unneeded dependency + +## 4.6.2 2018-03-06 + +- When redirecting URL calls then do not include original POST content + +## 4.6.1 2018-03-06 + +- Fixed Smtp connection freezing, when trying to send after close / quit (twawszczak) [73d3911c] + +## 4.6.0 2018-02-22 + +- Support socks module v2 in addition to v1 [e228bcb2] +- Fixed invalid promise return value when using createTestAccount [5524e627] +- Allow using local addresses [8f6fa35f] + +## 4.5.0 2018-02-21 + +- Added new message transport option `normalizeHeaderKey(key)=>normalizedKey` for custom header formatting + +## 4.4.2 2018-01-20 + +- Added sponsors section to README +- enclose encodeURIComponent in try..catch to handle invalid urls + +## 4.4.1 2017-12-08 + +- Better handling of unexpectedly dropping connections + +## 4.4.0 2017-11-10 + +- Changed default behavior for attachment option contentTransferEncoding. If it is unset then base64 encoding is used for the attachment. If it is set to false then previous default applies (base64 for most, 7bit for text) + +## 4.3.1 2017-10-25 + +- Fixed a confict with Electron.js where timers do not have unref method + +## 4.3.0 2017-10-23 + +- Added new mail object method `mail.normalize(cb)` that should make creating HTTP API based transports much easier + +## 4.2.0 2017-10-13 + +- Expose streamed messages size and timers in info response + +## v4.1.3 2017-10-06 + +- Allow generating preview links without calling createTestAccount first + +## v4.1.2 2017-10-03 + +- No actual changes. Needed to push updated README to npmjs + +## v4.1.1 2017-09-25 + +- Fixed JSONTransport attachment handling + +## v4.1.0 2017-08-28 + +- Added new methods `createTestAccount` and `getTestMessageUrl` to use autogenerated email accounts from https://Ethereal.email + +## v4.0.1 2017-04-13 + +- Fixed issue with LMTP and STARTTLS + +## v4.0.0 2017-04-06 + +- License changed from EUPLv1.1 to MIT + +## v3.1.8 2017-03-21 + +- Fixed invalid List-\* header generation + +## v3.1.7 2017-03-14 + +- Emit an error if STARTTLS ends with connection being closed + +## v3.1.6 2017-03-14 + +- Expose last server response for smtpConnection + +## v3.1.5 2017-03-08 + +- Fixed SES transport, added missing `response` value + +## v3.1.4 2017-02-26 + +- Fixed DKIM calculation for empty body +- Ensure linebreak after message content. This fixes DKIM signatures for non-multipart messages where input did not end with a newline + +## v3.1.3 2017-02-17 + +- Fixed missing `transport.verify()` methods for SES transport + +## v3.1.2 2017-02-17 + +- Added missing error handlers for Sendmail, SES and Stream transports. If a messages contained an invalid URL as attachment then these transports threw an uncatched error + +## v3.1.1 2017-02-13 + +- Fixed missing `transport.on('idle')` and `transport.isIdle()` methods for SES transports + +## v3.1.0 2017-02-13 + +- Added built-in transport for AWS SES. [Docs](http://localhost:1313/transports/ses/) +- Updated stream transport to allow building JSON strings. [Docs](http://localhost:1313/transports/stream/#json-transport) +- Added new method _mail.resolveAll_ that fetches all attachments and such to be able to more easily build API-based transports + +## v3.0.2 2017-02-04 + +- Fixed a bug with OAuth2 login where error callback was fired twice if getToken was not available. + +## v3.0.1 2017-02-03 + +- Fixed a bug where Nodemailer threw an exception if `disableFileAccess` option was used +- Added FLOSS [exception declaration](FLOSS_EXCEPTIONS.md) + +## v3.0.0 2017-01-31 + +- Initial version of Nodemailer 3 + +This update brings a lot of breaking changes: + +- License changed from MIT to **EUPL-1.1**. This was possible as the new version of Nodemailer is a major rewrite. The features I don't have ownership for, were removed or reimplemented. If there's still some snippets in the code that have vague ownership then notify about the conflicting code and I'll fix it. +- Requires **Node.js v6+** +- All **templating is gone**. It was too confusing to use and to be really universal a huge list of different renderers would be required. Nodemailer is about email, not about parsing different template syntaxes +- **No NTLM authentication**. It was too difficult to re-implement. If you still need it then it would be possible to introduce a pluggable SASL interface where you could load the NTLM module in your own code and pass it to Nodemailer. Currently this is not possible. +- **OAuth2 authentication** is built in and has a different [configuration](https://nodemailer.com/smtp/oauth2/). You can use both user (3LO) and service (2LO) accounts to generate access tokens from Nodemailer. Additionally there's a new feature to authenticate differently for every message – useful if your application sends on behalf of different users instead of a single sender. +- **Improved Calendaring**. Provide an ical file to Nodemailer to send out [calendar events](https://nodemailer.com/message/calendar-events/). + +And also some non-breaking changes: + +- All **dependencies were dropped**. There is exactly 0 dependencies needed to use Nodemailer. This brings the installation time of Nodemailer from NPM down to less than 2 seconds +- **Delivery status notifications** added to Nodemailer +- Improved and built-in **DKIM** signing of messages. Previously you needed an external module for this and it did quite a lousy job with larger messages +- **Stream transport** to return a RFC822 formatted message as a stream. Useful if you want to use Nodemailer as a preprocessor and not for actual delivery. +- **Sendmail** transport built-in, no need for external transport plugin + +See [Nodemailer.com](https://nodemailer.com/) for full documentation + +## 2.7.0 2016-12-08 + +- Bumped mailcomposer that generates encoded-words differently which might break some tests + +## 2.6.0 2016-09-05 + +- Added new options disableFileAccess and disableUrlAccess +- Fixed envelope handling where cc/bcc fields were ignored in the envelope object + +## 2.4.2 2016-05-25 + +- Removed shrinkwrap file. Seemed to cause more trouble than help + +## 2.4.1 2016-05-12 + +- Fixed outdated shrinkwrap file + +## 2.4.0 2016-05-11 + +- Bumped mailcomposer module to allow using `false` as attachment filename (suppresses filename usage) +- Added NTLM authentication support + +## 2.3.2 2016-04-11 + +- Bumped smtp transport modules to get newest smtp-connection that fixes SMTPUTF8 support for internationalized email addresses + +## 2.3.1 2016-04-08 + +- Bumped mailcomposer to have better support for message/822 attachments + +## 2.3.0 2016-03-03 + +- Fixed a bug with attachment filename that contains mixed unicode and dashes +- Added built-in support for proxies by providing a new SMTP option `proxy` that takes a proxy configuration url as its value +- Added option `transport` to dynamically load transport plugins +- Do not require globally installed grunt-cli + +## 2.2.1 2016-02-20 + +- Fixed a bug in SMTP requireTLS option that was broken + +## 2.2.0 2016-02-18 + +- Removed the need to use `clone` dependency +- Added new method `verify` to check SMTP configuration +- Direct transport uses STARTTLS by default, fallbacks to plaintext if STARTTLS fails +- Added new message option `list` for setting List-\* headers +- Add simple proxy support with `getSocket` method +- Added new message option `textEncoding`. If `textEncoding` is not set then detect best encoding automatically +- Added new message option `icalEvent` to embed iCalendar events. Example [here](examples/ical-event.js) +- Added new attachment option `raw` to use prepared MIME contents instead of generating a new one. This might be useful when you want to handcraft some parts of the message yourself, for example if you want to inject a PGP encrypted message as the contents of a MIME node +- Added new message option `raw` to use an existing MIME message instead of generating a new one + +## 2.1.0 2016-02-01 + +Republishing 2.1.0-rc.1 as stable. To recap, here's the notable changes between v2.0 and v2.1: + +- Implemented templating support. You can either use a simple built-in renderer or some external advanced renderer, eg. [node-email-templates](https://github.com/niftylettuce/node-email-templates). Templating [docs](http://nodemailer.com/2-0-0-beta/templating/). +- Updated smtp-pool to emit 'idle' events in order to handle message queue more effectively +- Updated custom header handling, works everywhere the same now, no differences between adding custom headers to the message or to an attachment + +## 2.1.0-rc.1 2016-01-25 + +Sneaked in some new features even though it is already rc + +- If a SMTP pool is closed while there are still messages in a queue, the message callbacks are invoked with an error +- In case of SMTP pool the transporter emits 'idle' when there is a free connection slot available +- Added method `isIdle()` that checks if a pool has still some free connection slots available + +## 2.1.0-rc.0 2016-01-20 + +- Bumped dependency versions + +## 2.1.0-beta.3 2016-01-20 + +- Added support for node-email-templates templating in addition to the built-in renderer + +## 2.1.0-beta.2 2016-01-20 + +- Implemented simple templating feature + +## 2.1.0-beta.1 2016-01-20 + +- Allow using prepared header values that are not folded or encoded by Nodemailer + +## 2.1.0-beta.0 2016-01-20 + +- Use the same header custom structure for message root, attachments and alternatives +- Ensure that Message-Id exists when accessing message +- Allow using array values for custom headers (inserts every value in its own row) + +## 2.0.0 2016-01-11 + +- Released rc.2 as stable + +## 2.0.0-rc.2 2016-01-04 + +- Locked dependencies + +## 2.0.0-beta.2 2016-01-04 + +- Updated documentation to reflect changes with SMTP handling +- Use beta versions for smtp/pool/direct transports +- Updated logging + +## 2.0.0-beta.1 2016-01-03 + +- Use bunyan compatible logger instead of the emit('log') style +- Outsourced some reusable methods to nodemailer-shared +- Support setting direct/smtp/pool with the default configuration + +## 2.0.0-beta.0 2015-12-31 + +- Stream errors are not silently swallowed +- Do not use format=flowed +- Use nodemailer-fetch to fetch URL streams +- jshint replaced by eslint + +## v1.11.0 2015-12-28 + +Allow connection url based SMTP configurations + +## v1.10.0 2015-11-13 + +Added `defaults` argument for `createTransport` to predefine commonn values (eg. `from` address) + +## v1.9.0 2015-11-09 + +Returns a Promise for `sendMail` if callback is not defined + +## v1.8.0 2015-10-08 + +Added priority option (high, normal, low) for setting Importance header + +## v1.7.0 2015-10-06 + +Replaced hyperquest with needle. Fixes issues with compressed data and redirects + +## v1.6.0 2015-10-05 + +Maintenance release. Bumped dependencies to get support for unicode filenames for QQ webmail and to support emoji in filenames + +## v1.5.0 2015-09-24 + +Use mailcomposer instead of built in solution to generate message sources. Bumped libmime gives better quoted-printable handling. + +## v1.4.0 2015-06-27 + +Added new message option `watchHtml` to specify Apple Watch specific HTML part of the message. See [this post](https://litmus.com/blog/how-to-send-hidden-version-email-apple-watch) for details + +## v1.3.4 2015-04-25 + +Maintenance release, bumped buildmail version to get fixed format=flowed handling + +## v1.3.3 2015-04-25 + +Maintenance release, bumped dependencies + +## v1.3.2 2015-03-09 + +Maintenance release, upgraded dependencies. Replaced simplesmtp based tests with smtp-server based ones. + +## v1.3.0 2014-09-12 + +Maintenance release, upgrades buildmail and libmime. Allows using functions as transform plugins and fixes issue with unicode filenames in Gmail. + +## v1.2.2 2014-09-05 + +Proper handling of data uris as attachments. Attachment `path` property can also be defined as a data uri, not just regular url or file path. + +## v1.2.1 2014-08-21 + +Bumped libmime and mailbuild versions to properly handle filenames with spaces (short ascii only filenames with spaces were left unquoted). + +## v1.2.0 2014-08-18 + +Allow using encoded strings as attachments. Added new property `encoding` which defines the encoding used for a `content` string. If encoding is set, the content value is converted to a Buffer value using the defined encoding before usage. Useful for including binary attachemnts in JSON formatted email objects. + +## v1.1.2 2014-08-18 + +Return deprecatin error for v0.x style configuration + +## v1.1.1 2014-07-30 + +Bumped nodemailer-direct-transport dependency. Updated version includes a bugfix for Stream nodes handling. Important only if use direct-transport with Streams (not file paths or urls) as attachment content. + +## v1.1.0 2014-07-29 + +Added new method `resolveContent()` to get the html/text/attachment content as a String or Buffer. + +## v1.0.4 2014-07-23 + +Bugfix release. HTML node was instered twice if the message consisted of a HTML content (but no text content) + at least one attachment with CID + at least one attachment without CID. In this case the HTML node was inserted both to the root level multipart/mixed section and to the multipart/related sub section + +## v1.0.3 2014-07-16 + +Fixed a bug where Nodemailer crashed if the message content type was multipart/related + +## v1.0.2 2014-07-16 + +Upgraded nodemailer-smtp-transport to 0.1.11\. The docs state that for SSL you should use 'secure' option but the underlying smtp-connection module used 'secureConnection' for this purpose. Fixed smpt-connection to match the docs. + +## v1.0.1 2014-07-15 + +Implemented missing #close method that is passed to the underlying transport object. Required by the smtp pool. + +## v1.0.0 2014-07-15 + +Total rewrite. See migration guide here: + +## v0.7.1 2014-07-09 + +- Upgraded aws-sdk to 2.0.5 + +## v0.7.0 2014-06-17 + +- Bumped version to v0.7.0 +- Fix AWS-SES usage [5b6bc144] +- Replace current SES with new SES using AWS-SDK (Elanorr) [c79d797a] +- Updated README.md about Node Email Templates (niftylettuce) [e52bef81] + +## v0.6.5 2014-05-15 + +- Bumped version to v0.6.5 +- Use tildes instead of carets for dependency listing [5296ce41] +- Allow clients to set a custom identityString (venables) [5373287d] +- bugfix (adding "-i" to sendmail command line for each new mail) by copying this.args (vrodic) [05a8a9a3] +- update copyright (gdi2290) [3a6cba3a] + +## v0.6.4 2014-05-13 + +- Bumped version to v0.6.4 +- added npmignore, bumped dependencies [21bddcd9] +- Add AOL to well-known services (msouce) [da7dd3b7] + +## v0.6.3 2014-04-16 + +- Bumped version to v0.6.3 +- Upgraded simplesmtp dependency [dd367f59] + +## v0.6.2 2014-04-09 + +- Bumped version to v0.6.2 +- Added error option to Stub transport [c423acad] +- Use SVG npm badge (t3chnoboy) [677117b7] +- add SendCloud to well known services (haio) [43c358e0] +- High-res build-passing and NPM module badges (sahat) [9fdc37cd] + +## v0.6.1 2014-01-26 + +- Bumped version to v0.6.1 +- Do not throw on multiple errors from sendmail command [c6e2cd12] +- Do not require callback for pickup, fixes #238 [93eb3214] +- Added AWSSecurityToken information to README, fixes #235 [58e921d1] +- Added Nodemailer logo [06b7d1a8] + +## v0.6.0 2013-12-30 + +- Bumped version to v0.6.0 +- Allow defining custom transport methods [ec5b48ce] +- Return messageId with responseObject for all built in transport methods [74445cec] +- Bumped dependency versions for mailcomposer and readable-stream [9a034c34] +- Changed pickup argument name to 'directory' [01c3ea53] +- Added support for IIS pickup directory with PICKUP transport (philipproplesch) [36940b59..360a2878] +- Applied common styles [9e93a409] +- Updated readme [c78075e7] + +## v0.5.15 2013-12-13 + +- bumped version to v0.5.15 +- Updated README, added global options info for setting uo transports [554bb0e5] +- Resolve public hostname, if resolveHostname property for a transport object is set to `true` [9023a6e1..4c66b819] + +## v0.5.14 2013-12-05 + +- bumped version to v0.5.14 +- Expose status for direct messages [f0312df6] +- Allow to skip the X-Mailer header if xMailer value is set to 'false' [f2c20a68] + +## v0.5.13 2013-12-03 + +- bumped version to v0.5.13 +- Use the name property from the transport object to use for the domain part of message-id values (1598eee9) + +## v0.5.12 2013-12-02 + +- bumped version to v0.5.12 +- Expose transport method and transport module version if available [a495106e] +- Added 'he' module instead of using custom html entity decoding [c197d102] +- Added xMailer property for transport configuration object to override X-Mailer value [e8733a61] +- Updated README, added description for 'mail' method [e1f5f3a6] + +## v0.5.11 2013-11-28 + +- bumped version to v0.5.11 +- Updated mailcomposer version. Replaces ent with he [6a45b790e] + +## v0.5.10 2013-11-26 + +- bumped version to v0.5.10 +- added shorthand function mail() for direct transport type [88129bd7] +- minor tweaks and typo fixes [f797409e..ceac0ca4] + +## v0.5.9 2013-11-25 + +- bumped version to v0.5.9 +- Update for 'direct' handling [77b84e2f] +- do not require callback to be provided for 'direct' type [ec51c79f] + +## v0.5.8 2013-11-22 + +- bumped version to v0.5.8 +- Added support for 'direct' transport [826f226d..0dbbcbbc] + +## v0.5.7 2013-11-18 + +- bumped version to v0.5.7 +- Replace \r\n by \n in Sendmail transport (rolftimmermans) [fed2089e..616ec90c] A lot of sendmail implementations choke on \r\n newlines and require \n This commit addresses this by transforming all \r\n sequences passed to the sendmail command with \n + +## v0.5.6 2013-11-15 + +- bumped version to v0.5.6 +- Upgraded mailcomposer dependency to 0.2.4 [e5ff9c40] +- Removed noCR option [e810d1b8] +- Update wellknown.js, added FastMail (k-j-kleist) [cf930f6d] + +## v0.5.5 2013-10-30 + +- bumped version to v0.5.5 +- Updated mailcomposer dependnecy version to 0.2.3 +- Remove legacy code - node v0.4 is not supported anymore anyway +- Use hostname (autodetected or from the options.name property) for Message-Id instead of "Nodemailer" (helps a bit when messages are identified as spam) +- Added maxMessages info to README + +## v0.5.4 2013-10-29 + +- bumped version to v0.5.4 +- added "use strict" statements +- Added DSN info to README +- add support for QQ enterprise email (coderhaoxin) +- Add a Bitdeli Badge to README +- DSN options Passthrought into simplesmtp. (irvinzz) + +## v0.5.3 2013-10-03 + +- bumped version v0.5.3 +- Using a stub transport to prevent sendmail from being called during a test. (jsdevel) +- closes #78: sendmail transport does not work correctly on Unix machines. (jsdevel) +- Updated PaaS Support list to include Modulus. (fiveisprime) +- Translate self closing break tags to newline (kosmasgiannis) +- fix typos (aeosynth) + +## v0.5.2 2013-07-25 + +- bumped version v0.5.2 +- Merge pull request #177 from MrSwitch/master Fixing Amazon SES, fatal error caused by bad connection diff --git a/node_modules/nodemailer/CONTRIBUTING.md b/node_modules/nodemailer/CONTRIBUTING.md new file mode 100644 index 0000000..3978539 --- /dev/null +++ b/node_modules/nodemailer/CONTRIBUTING.md @@ -0,0 +1,67 @@ +# Contribute + +## Introduction + +First, thank you for considering contributing to nodemailer! It's people like you that make the open source community such a great community! 😊 + +We welcome any type of contribution, not only code. You can help with +- **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open) +- **Marketing**: writing blog posts, howto's, printing stickers, ... +- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ... +- **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them. +- **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/nodemailer). + +## Your First Contribution + +Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). + +## Submitting code + +Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests. + +## Code review process + +The bigger the pull request, the longer it will take to review and merge. Try to break down large pull requests in smaller chunks that are easier to review and merge. +It is also always helpful to have some context for your pull request. What was the purpose? Why does it matter to you? + +## Financial contributions + +We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/nodemailer). +Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed. + +## Questions + +If you have any questions, create an [issue](issue) (protip: do a quick search first to see if someone else didn't ask the same question before!). +You can also reach us at hello@nodemailer.opencollective.com. + +## Credits + +### Contributors + +Thank you to all the people who have already contributed to nodemailer! + + + +### Backers + +Thank you to all our backers! [[Become a backer](https://opencollective.com/nodemailer#backer)] + + + + +### Sponsors + +Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/nodemailer#sponsor)) + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/nodemailer/LICENSE b/node_modules/nodemailer/LICENSE new file mode 100644 index 0000000..26b5254 --- /dev/null +++ b/node_modules/nodemailer/LICENSE @@ -0,0 +1,16 @@ +Copyright (c) 2011-2017 Andris Reinman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/nodemailer/README.md b/node_modules/nodemailer/README.md new file mode 100644 index 0000000..1d4611e --- /dev/null +++ b/node_modules/nodemailer/README.md @@ -0,0 +1,77 @@ +# Nodemailer +[![Backers on Open Collective](https://opencollective.com/nodemailer/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/nodemailer/sponsors/badge.svg)](#sponsors) + +[![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)](https://nodemailer.com/about/) + +Send e-mails from Node.js – easy as cake! 🍰✉️ + +[![NPM](https://nodei.co/npm/nodemailer.png?downloads=true&downloadRank=true&stars=true)](https://nodemailer.com/about/) + +See [nodemailer.com](https://nodemailer.com/) for documentation and terms. + +## Having an issue? + +#### First review the docs + +Documentation for Nodemailer can be found at [nodemailer.com](https://nodemailer.com/about/) + +#### Nodemailer throws a SyntaxError for "..." + +You are using older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator + +#### I'm having issues with Gmail + +Gmail either works well or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you then don't use it. + +#### I get ETIMEDOUT errors + +Check your firewall settings. Timeout usually occurs when you try to open a connection to a port that is firewalled either on the server or on your machine + +#### I get TLS errors + +If you are running the code in your own machine, then check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using. + +#### I have a different problem + +If you are having issues with Nodemailer, then the best way to find help would be [Stack Overflow](https://stackoverflow.com/search?q=nodemailer) or revisit the [docs](https://nodemailer.com/about/). + + + +## Contributors + +This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. + + + +## Backers + +Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/nodemailer#backer)] + + + + +## Sponsors + +Support this project by becoming a sponsor. Your logo will show up on our README on Github with a link to your website. [[Become a sponsor](https://opencollective.com/nodemailer#sponsor)] + + + + + + + + + + + + + + +### License + +Nodemailer is licensed under the **MIT license** + +-------------------------------------------------------------------------------- + +The Nodemailer logo was designed by [Sven Kristjansen](https://www.behance.net/kristjansen). + diff --git a/node_modules/nodemailer/lib/addressparser/index.js b/node_modules/nodemailer/lib/addressparser/index.js new file mode 100644 index 0000000..0c66df3 --- /dev/null +++ b/node_modules/nodemailer/lib/addressparser/index.js @@ -0,0 +1,292 @@ +'use strict'; + +/** + * Converts tokens for a single address into an address object + * + * @param {Array} tokens Tokens object + * @return {Object} Address object + */ +function _handleAddress(tokens) { + let token; + let isGroup = false; + let state = 'text'; + let address; + let addresses = []; + let data = { + address: [], + comment: [], + group: [], + text: [] + }; + let i; + let len; + + // Filter out , (comments) and regular text + for (i = 0, len = tokens.length; i < len; i++) { + token = tokens[i]; + if (token.type === 'operator') { + switch (token.value) { + case '<': + state = 'address'; + break; + case '(': + state = 'comment'; + break; + case ':': + state = 'group'; + isGroup = true; + break; + default: + state = 'text'; + } + } else if (token.value) { + if (state === 'address') { + // handle use case where unquoted name includes a "<" + // Apple Mail truncates everything between an unexpected < and an address + // and so will we + token.value = token.value.replace(/^[^<]*<\s*/, ''); + } + data[state].push(token.value); + } + } + + // If there is no text but a comment, replace the two + if (!data.text.length && data.comment.length) { + data.text = data.comment; + data.comment = []; + } + + if (isGroup) { + // http://tools.ietf.org/html/rfc2822#appendix-A.1.3 + data.text = data.text.join(' '); + addresses.push({ + name: data.text || (address && address.name), + group: data.group.length ? addressparser(data.group.join(',')) : [] + }); + } else { + // If no address was found, try to detect one from regular text + if (!data.address.length && data.text.length) { + for (i = data.text.length - 1; i >= 0; i--) { + if (data.text[i].match(/^[^@\s]+@[^@\s]+$/)) { + data.address = data.text.splice(i, 1); + break; + } + } + + let _regexHandler = function(address) { + if (!data.address.length) { + data.address = [address.trim()]; + return ' '; + } else { + return address; + } + }; + + // still no address + if (!data.address.length) { + for (i = data.text.length - 1; i >= 0; i--) { + // fixed the regex to parse email address correctly when email address has more than one @ + data.text[i] = data.text[i].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/, _regexHandler).trim(); + if (data.address.length) { + break; + } + } + } + } + + // If there's still is no text but a comment exixts, replace the two + if (!data.text.length && data.comment.length) { + data.text = data.comment; + data.comment = []; + } + + // Keep only the first address occurence, push others to regular text + if (data.address.length > 1) { + data.text = data.text.concat(data.address.splice(1)); + } + + // Join values with spaces + data.text = data.text.join(' '); + data.address = data.address.join(' '); + + if (!data.address && isGroup) { + return []; + } else { + address = { + address: data.address || data.text || '', + name: data.text || data.address || '' + }; + + if (address.address === address.name) { + if ((address.address || '').match(/@/)) { + address.name = ''; + } else { + address.address = ''; + } + } + + addresses.push(address); + } + } + + return addresses; +} + +/** + * Creates a Tokenizer object for tokenizing address field strings + * + * @constructor + * @param {String} str Address field string + */ +class Tokenizer { + constructor(str) { + this.str = (str || '').toString(); + this.operatorCurrent = ''; + this.operatorExpecting = ''; + this.node = null; + this.escaped = false; + + this.list = []; + /** + * Operator tokens and which tokens are expected to end the sequence + */ + this.operators = { + '"': '"', + '(': ')', + '<': '>', + ',': '', + ':': ';', + // Semicolons are not a legal delimiter per the RFC2822 grammar other + // than for terminating a group, but they are also not valid for any + // other use in this context. Given that some mail clients have + // historically allowed the semicolon as a delimiter equivalent to the + // comma in their UI, it makes sense to treat them the same as a comma + // when used outside of a group. + ';': '' + }; + } + + /** + * Tokenizes the original input string + * + * @return {Array} An array of operator|text tokens + */ + tokenize() { + let chr, + list = []; + for (let i = 0, len = this.str.length; i < len; i++) { + chr = this.str.charAt(i); + this.checkChar(chr); + } + + this.list.forEach(node => { + node.value = (node.value || '').toString().trim(); + if (node.value) { + list.push(node); + } + }); + + return list; + } + + /** + * Checks if a character is an operator or text and acts accordingly + * + * @param {String} chr Character from the address field + */ + checkChar(chr) { + if ((chr in this.operators || chr === '\\') && this.escaped) { + this.escaped = false; + } else if (this.operatorExpecting && chr === this.operatorExpecting) { + this.node = { + type: 'operator', + value: chr + }; + this.list.push(this.node); + this.node = null; + this.operatorExpecting = ''; + this.escaped = false; + return; + } else if (!this.operatorExpecting && chr in this.operators) { + this.node = { + type: 'operator', + value: chr + }; + this.list.push(this.node); + this.node = null; + this.operatorExpecting = this.operators[chr]; + this.escaped = false; + return; + } + + if (!this.escaped && chr === '\\') { + this.escaped = true; + return; + } + + if (!this.node) { + this.node = { + type: 'text', + value: '' + }; + this.list.push(this.node); + } + + if (this.escaped && chr !== '\\') { + this.node.value += '\\'; + } + + this.node.value += chr; + this.escaped = false; + } +} + +/** + * Parses structured e-mail addresses from an address field + * + * Example: + * + * 'Name ' + * + * will be converted to + * + * [{name: 'Name', address: 'address@domain'}] + * + * @param {String} str Address field + * @return {Array} An array of address objects + */ +function addressparser(str) { + let tokenizer = new Tokenizer(str); + let tokens = tokenizer.tokenize(); + + let addresses = []; + let address = []; + let parsedAddresses = []; + + tokens.forEach(token => { + if (token.type === 'operator' && (token.value === ',' || token.value === ';')) { + if (address.length) { + addresses.push(address); + } + address = []; + } else { + address.push(token); + } + }); + + if (address.length) { + addresses.push(address); + } + + addresses.forEach(address => { + address = _handleAddress(address); + if (address.length) { + parsedAddresses = parsedAddresses.concat(address); + } + }); + + return parsedAddresses; +} + +// expose to the world +module.exports = addressparser; diff --git a/node_modules/nodemailer/lib/base64/index.js b/node_modules/nodemailer/lib/base64/index.js new file mode 100644 index 0000000..7e3a585 --- /dev/null +++ b/node_modules/nodemailer/lib/base64/index.js @@ -0,0 +1,142 @@ +'use strict'; + +const Transform = require('stream').Transform; + +/** + * Encodes a Buffer into a base64 encoded string + * + * @param {Buffer} buffer Buffer to convert + * @returns {String} base64 encoded string + */ +function encode(buffer) { + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer, 'utf-8'); + } + + return buffer.toString('base64'); +} + +/** + * Adds soft line breaks to a base64 string + * + * @param {String} str base64 encoded string that might need line wrapping + * @param {Number} [lineLength=76] Maximum allowed length for a line + * @returns {String} Soft-wrapped base64 encoded string + */ +function wrap(str, lineLength) { + str = (str || '').toString(); + lineLength = lineLength || 76; + + if (str.length <= lineLength) { + return str; + } + + let result = []; + let pos = 0; + let chunkLength = lineLength * 1024; + while (pos < str.length) { + let wrappedLines = str + .substr(pos, chunkLength) + .replace(new RegExp('.{' + lineLength + '}', 'g'), '$&\r\n') + .trim(); + result.push(wrappedLines); + pos += chunkLength; + } + + return result.join('\r\n').trim(); +} + +/** + * Creates a transform stream for encoding data to base64 encoding + * + * @constructor + * @param {Object} options Stream options + * @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping + */ +class Encoder extends Transform { + constructor(options) { + super(); + // init Transform + this.options = options || {}; + + if (this.options.lineLength !== false) { + this.options.lineLength = this.options.lineLength || 76; + } + + this._curLine = ''; + this._remainingBytes = false; + + this.inputBytes = 0; + this.outputBytes = 0; + } + + _transform(chunk, encoding, done) { + if (encoding !== 'buffer') { + chunk = Buffer.from(chunk, encoding); + } + + if (!chunk || !chunk.length) { + return setImmediate(done); + } + + this.inputBytes += chunk.length; + + if (this._remainingBytes && this._remainingBytes.length) { + chunk = Buffer.concat([this._remainingBytes, chunk], this._remainingBytes.length + chunk.length); + this._remainingBytes = false; + } + + if (chunk.length % 3) { + this._remainingBytes = chunk.slice(chunk.length - chunk.length % 3); + chunk = chunk.slice(0, chunk.length - chunk.length % 3); + } else { + this._remainingBytes = false; + } + + let b64 = this._curLine + encode(chunk); + + if (this.options.lineLength) { + b64 = wrap(b64, this.options.lineLength); + + // remove last line as it is still most probably incomplete + let lastLF = b64.lastIndexOf('\n'); + if (lastLF < 0) { + this._curLine = b64; + b64 = ''; + } else if (lastLF === b64.length - 1) { + this._curLine = ''; + } else { + this._curLine = b64.substr(lastLF + 1); + b64 = b64.substr(0, lastLF + 1); + } + } + + if (b64) { + this.outputBytes += b64.length; + this.push(Buffer.from(b64, 'ascii')); + } + + setImmediate(done); + } + + _flush(done) { + if (this._remainingBytes && this._remainingBytes.length) { + this._curLine += encode(this._remainingBytes); + } + + if (this._curLine) { + this._curLine = wrap(this._curLine, this.options.lineLength); + this.outputBytes += this._curLine.length; + this.push(this._curLine, 'ascii'); + this._curLine = ''; + } + done(); + } +} + +// expose to the world +module.exports = { + encode, + wrap, + Encoder +}; diff --git a/node_modules/nodemailer/lib/dkim/index.js b/node_modules/nodemailer/lib/dkim/index.js new file mode 100644 index 0000000..7b242be --- /dev/null +++ b/node_modules/nodemailer/lib/dkim/index.js @@ -0,0 +1,251 @@ +'use strict'; + +// FIXME: +// replace this Transform mess with a method that pipes input argument to output argument + +const MessageParser = require('./message-parser'); +const RelaxedBody = require('./relaxed-body'); +const sign = require('./sign'); +const PassThrough = require('stream').PassThrough; +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); + +const DKIM_ALGO = 'sha256'; +const MAX_MESSAGE_SIZE = 128 * 1024; // buffer messages larger than this to disk + +/* +// Usage: + +let dkim = new DKIM({ + domainName: 'example.com', + keySelector: 'key-selector', + privateKey, + cacheDir: '/tmp' +}); +dkim.sign(input).pipe(process.stdout); + +// Where inputStream is a rfc822 message (either a stream, string or Buffer) +// and outputStream is a DKIM signed rfc822 message +*/ + +class DKIMSigner { + constructor(options, keys, input, output) { + this.options = options || {}; + this.keys = keys; + + this.cacheTreshold = Number(this.options.cacheTreshold) || MAX_MESSAGE_SIZE; + this.hashAlgo = this.options.hashAlgo || DKIM_ALGO; + + this.cacheDir = this.options.cacheDir || false; + + this.chunks = []; + this.chunklen = 0; + this.readPos = 0; + this.cachePath = this.cacheDir ? path.join(this.cacheDir, 'message.' + Date.now() + '-' + crypto.randomBytes(14).toString('hex')) : false; + this.cache = false; + + this.headers = false; + this.bodyHash = false; + this.parser = false; + this.relaxedBody = false; + + this.input = input; + this.output = output; + this.output.usingCache = false; + + this.errored = false; + + this.input.on('error', err => { + this.errored = true; + this.cleanup(); + output.emit('error', err); + }); + } + + cleanup() { + if (!this.cache || !this.cachePath) { + return; + } + fs.unlink(this.cachePath, () => false); + } + + createReadCache() { + // pipe remainings to cache file + this.cache = fs.createReadStream(this.cachePath); + this.cache.once('error', err => { + this.cleanup(); + this.output.emit('error', err); + }); + this.cache.once('close', () => { + this.cleanup(); + }); + this.cache.pipe(this.output); + } + + sendNextChunk() { + if (this.errored) { + return; + } + + if (this.readPos >= this.chunks.length) { + if (!this.cache) { + return this.output.end(); + } + return this.createReadCache(); + } + let chunk = this.chunks[this.readPos++]; + if (this.output.write(chunk) === false) { + return this.output.once('drain', () => { + this.sendNextChunk(); + }); + } + setImmediate(() => this.sendNextChunk()); + } + + sendSignedOutput() { + let keyPos = 0; + let signNextKey = () => { + if (keyPos >= this.keys.length) { + this.output.write(this.parser.rawHeaders); + return setImmediate(() => this.sendNextChunk()); + } + let key = this.keys[keyPos++]; + let dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, { + domainName: key.domainName, + keySelector: key.keySelector, + privateKey: key.privateKey, + headerFieldNames: this.options.headerFieldNames, + skipFields: this.options.skipFields + }); + if (dkimField) { + this.output.write(Buffer.from(dkimField + '\r\n')); + } + return setImmediate(signNextKey); + }; + + if (this.bodyHash && this.headers) { + return signNextKey(); + } + + this.output.write(this.parser.rawHeaders); + this.sendNextChunk(); + } + + createWriteCache() { + this.output.usingCache = true; + // pipe remainings to cache file + this.cache = fs.createWriteStream(this.cachePath); + this.cache.once('error', err => { + this.cleanup(); + // drain input + this.relaxedBody.unpipe(this.cache); + this.relaxedBody.on('readable', () => { + while (this.relaxedBody.read() !== null) { + // do nothing + } + }); + this.errored = true; + // emit error + this.output.emit('error', err); + }); + this.cache.once('close', () => { + this.sendSignedOutput(); + }); + this.relaxedBody.removeAllListeners('readable'); + this.relaxedBody.pipe(this.cache); + } + + signStream() { + this.parser = new MessageParser(); + this.relaxedBody = new RelaxedBody({ + hashAlgo: this.hashAlgo + }); + + this.parser.on('headers', value => { + this.headers = value; + }); + + this.relaxedBody.on('hash', value => { + this.bodyHash = value; + }); + + this.relaxedBody.on('readable', () => { + let chunk; + if (this.cache) { + return; + } + while ((chunk = this.relaxedBody.read()) !== null) { + this.chunks.push(chunk); + this.chunklen += chunk.length; + if (this.chunklen >= this.cacheTreshold && this.cachePath) { + return this.createWriteCache(); + } + } + }); + + this.relaxedBody.on('end', () => { + if (this.cache) { + return; + } + this.sendSignedOutput(); + }); + + this.parser.pipe(this.relaxedBody); + setImmediate(() => this.input.pipe(this.parser)); + } +} + +class DKIM { + constructor(options) { + this.options = options || {}; + this.keys = [].concat( + this.options.keys || { + domainName: options.domainName, + keySelector: options.keySelector, + privateKey: options.privateKey + } + ); + } + + sign(input, extraOptions) { + let output = new PassThrough(); + let inputStream = input; + let writeValue = false; + + if (Buffer.isBuffer(input)) { + writeValue = input; + inputStream = new PassThrough(); + } else if (typeof input === 'string') { + writeValue = Buffer.from(input); + inputStream = new PassThrough(); + } + + let options = this.options; + if (extraOptions && Object.keys(extraOptions).length) { + options = {}; + Object.keys(this.options || {}).forEach(key => { + options[key] = this.options[key]; + }); + Object.keys(extraOptions || {}).forEach(key => { + if (!(key in options)) { + options[key] = extraOptions[key]; + } + }); + } + + let signer = new DKIMSigner(options, this.keys, inputStream, output); + setImmediate(() => { + signer.signStream(); + if (writeValue) { + setImmediate(() => { + inputStream.end(writeValue); + }); + } + }); + + return output; + } +} + +module.exports = DKIM; diff --git a/node_modules/nodemailer/lib/dkim/message-parser.js b/node_modules/nodemailer/lib/dkim/message-parser.js new file mode 100644 index 0000000..f81de2f --- /dev/null +++ b/node_modules/nodemailer/lib/dkim/message-parser.js @@ -0,0 +1,156 @@ +'use strict'; + +const Transform = require('stream').Transform; + +/** + * MessageParser instance is a transform stream that separates message headers + * from the rest of the body. Headers are emitted with the 'headers' event. Message + * body is passed on as the resulting stream. + */ +class MessageParser extends Transform { + constructor(options) { + super(options); + this.lastBytes = Buffer.alloc(4); + this.headersParsed = false; + this.headerBytes = 0; + this.headerChunks = []; + this.rawHeaders = false; + this.bodySize = 0; + } + + /** + * Keeps count of the last 4 bytes in order to detect line breaks on chunk boundaries + * + * @param {Buffer} data Next data chunk from the stream + */ + updateLastBytes(data) { + let lblen = this.lastBytes.length; + let nblen = Math.min(data.length, lblen); + + // shift existing bytes + for (let i = 0, len = lblen - nblen; i < len; i++) { + this.lastBytes[i] = this.lastBytes[i + nblen]; + } + + // add new bytes + for (let i = 1; i <= nblen; i++) { + this.lastBytes[lblen - i] = data[data.length - i]; + } + } + + /** + * Finds and removes message headers from the remaining body. We want to keep + * headers separated until final delivery to be able to modify these + * + * @param {Buffer} data Next chunk of data + * @return {Boolean} Returns true if headers are already found or false otherwise + */ + checkHeaders(data) { + if (this.headersParsed) { + return true; + } + + let lblen = this.lastBytes.length; + let headerPos = 0; + this.curLinePos = 0; + for (let i = 0, len = this.lastBytes.length + data.length; i < len; i++) { + let chr; + if (i < lblen) { + chr = this.lastBytes[i]; + } else { + chr = data[i - lblen]; + } + if (chr === 0x0a && i) { + let pr1 = i - 1 < lblen ? this.lastBytes[i - 1] : data[i - 1 - lblen]; + let pr2 = i > 1 ? (i - 2 < lblen ? this.lastBytes[i - 2] : data[i - 2 - lblen]) : false; + if (pr1 === 0x0a) { + this.headersParsed = true; + headerPos = i - lblen + 1; + this.headerBytes += headerPos; + break; + } else if (pr1 === 0x0d && pr2 === 0x0a) { + this.headersParsed = true; + headerPos = i - lblen + 1; + this.headerBytes += headerPos; + break; + } + } + } + + if (this.headersParsed) { + this.headerChunks.push(data.slice(0, headerPos)); + this.rawHeaders = Buffer.concat(this.headerChunks, this.headerBytes); + this.headerChunks = null; + this.emit('headers', this.parseHeaders()); + if (data.length - 1 > headerPos) { + let chunk = data.slice(headerPos); + this.bodySize += chunk.length; + // this would be the first chunk of data sent downstream + setImmediate(() => this.push(chunk)); + } + return false; + } else { + this.headerBytes += data.length; + this.headerChunks.push(data); + } + + // store last 4 bytes to catch header break + this.updateLastBytes(data); + + return false; + } + + _transform(chunk, encoding, callback) { + if (!chunk || !chunk.length) { + return callback(); + } + + if (typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + + let headersFound; + + try { + headersFound = this.checkHeaders(chunk); + } catch (E) { + return callback(E); + } + + if (headersFound) { + this.bodySize += chunk.length; + this.push(chunk); + } + + setImmediate(callback); + } + + _flush(callback) { + if (this.headerChunks) { + let chunk = Buffer.concat(this.headerChunks, this.headerBytes); + this.bodySize += chunk.length; + this.push(chunk); + this.headerChunks = null; + } + callback(); + } + + parseHeaders() { + let lines = (this.rawHeaders || '').toString().split(/\r?\n/); + for (let i = lines.length - 1; i > 0; i--) { + if (/^\s/.test(lines[i])) { + lines[i - 1] += '\n' + lines[i]; + lines.splice(i, 1); + } + } + return lines.filter(line => line.trim()).map(line => ({ + key: line + .substr(0, line.indexOf(':')) + .trim() + .toLowerCase(), + line + })); + } +} + +module.exports = MessageParser; diff --git a/node_modules/nodemailer/lib/dkim/relaxed-body.js b/node_modules/nodemailer/lib/dkim/relaxed-body.js new file mode 100644 index 0000000..03558e8 --- /dev/null +++ b/node_modules/nodemailer/lib/dkim/relaxed-body.js @@ -0,0 +1,154 @@ +'use strict'; + +// streams through a message body and calculates relaxed body hash + +const Transform = require('stream').Transform; +const crypto = require('crypto'); + +class RelaxedBody extends Transform { + constructor(options) { + super(); + options = options || {}; + this.chunkBuffer = []; + this.chunkBufferLen = 0; + this.bodyHash = crypto.createHash(options.hashAlgo || 'sha1'); + this.remainder = ''; + this.byteLength = 0; + + this.debug = options.debug; + this._debugBody = options.debug ? [] : false; + } + + updateHash(chunk) { + let bodyStr; + + // find next remainder + let nextRemainder = ''; + + // This crux finds and removes the spaces from the last line and the newline characters after the last non-empty line + // If we get another chunk that does not match this description then we can restore the previously processed data + let state = 'file'; + for (let i = chunk.length - 1; i >= 0; i--) { + let c = chunk[i]; + + if (state === 'file' && (c === 0x0a || c === 0x0d)) { + // do nothing, found \n or \r at the end of chunk, stil end of file + } else if (state === 'file' && (c === 0x09 || c === 0x20)) { + // switch to line ending mode, this is the last non-empty line + state = 'line'; + } else if (state === 'line' && (c === 0x09 || c === 0x20)) { + // do nothing, found ' ' or \t at the end of line, keep processing the last non-empty line + } else if (state === 'file' || state === 'line') { + // non line/file ending character found, switch to body mode + state = 'body'; + if (i === chunk.length - 1) { + // final char is not part of line end or file end, so do nothing + break; + } + } + + if (i === 0) { + // reached to the beginning of the chunk, check if it is still about the ending + // and if the remainder also matches + if ( + (state === 'file' && (!this.remainder || /[\r\n]$/.test(this.remainder))) || + (state === 'line' && (!this.remainder || /[ \t]$/.test(this.remainder))) + ) { + // keep everything + this.remainder += chunk.toString('binary'); + return; + } else if (state === 'line' || state === 'file') { + // process existing remainder as normal line but store the current chunk + nextRemainder = chunk.toString('binary'); + chunk = false; + break; + } + } + + if (state !== 'body') { + continue; + } + + // reached first non ending byte + nextRemainder = chunk.slice(i + 1).toString('binary'); + chunk = chunk.slice(0, i + 1); + break; + } + + let needsFixing = !!this.remainder; + if (chunk && !needsFixing) { + // check if we even need to change anything + for (let i = 0, len = chunk.length; i < len; i++) { + if (i && chunk[i] === 0x0a && chunk[i - 1] !== 0x0d) { + // missing \r before \n + needsFixing = true; + break; + } else if (i && chunk[i] === 0x0d && chunk[i - 1] === 0x20) { + // trailing WSP found + needsFixing = true; + break; + } else if (i && chunk[i] === 0x20 && chunk[i - 1] === 0x20) { + // multiple spaces found, needs to be replaced with just one + needsFixing = true; + break; + } else if (chunk[i] === 0x09) { + // TAB found, needs to be replaced with a space + needsFixing = true; + break; + } + } + } + + if (needsFixing) { + bodyStr = this.remainder + (chunk ? chunk.toString('binary') : ''); + this.remainder = nextRemainder; + bodyStr = bodyStr + .replace(/\r?\n/g, '\n') // use js line endings + .replace(/[ \t]*$/gm, '') // remove line endings, rtrim + .replace(/[ \t]+/gm, ' ') // single spaces + .replace(/\n/g, '\r\n'); // restore rfc822 line endings + chunk = Buffer.from(bodyStr, 'binary'); + } else if (nextRemainder) { + this.remainder = nextRemainder; + } + + if (this.debug) { + this._debugBody.push(chunk); + } + this.bodyHash.update(chunk); + } + + _transform(chunk, encoding, callback) { + if (!chunk || !chunk.length) { + return callback(); + } + + if (typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + + this.updateHash(chunk); + + this.byteLength += chunk.length; + this.push(chunk); + callback(); + } + + _flush(callback) { + // generate final hash and emit it + if (/[\r\n]$/.test(this.remainder) && this.byteLength > 2) { + // add terminating line end + this.bodyHash.update(Buffer.from('\r\n')); + } + if (!this.byteLength) { + // emit empty line buffer to keep the stream flowing + this.push(Buffer.from('\r\n')); + // this.bodyHash.update(Buffer.from('\r\n')); + } + + this.emit('hash', this.bodyHash.digest('base64'), this.debug ? Buffer.concat(this._debugBody) : false); + callback(); + } +} + +module.exports = RelaxedBody; diff --git a/node_modules/nodemailer/lib/dkim/sign.js b/node_modules/nodemailer/lib/dkim/sign.js new file mode 100644 index 0000000..b243dc3 --- /dev/null +++ b/node_modules/nodemailer/lib/dkim/sign.js @@ -0,0 +1,117 @@ +'use strict'; + +const punycode = require('punycode'); +const mimeFuncs = require('../mime-funcs'); +const crypto = require('crypto'); + +/** + * Returns DKIM signature header line + * + * @param {Object} headers Parsed headers object from MessageParser + * @param {String} bodyHash Base64 encoded hash of the message + * @param {Object} options DKIM options + * @param {String} options.domainName Domain name to be signed for + * @param {String} options.keySelector DKIM key selector to use + * @param {String} options.privateKey DKIM private key to use + * @return {String} Complete header line + */ + +module.exports = (headers, hashAlgo, bodyHash, options) => { + options = options || {}; + + // all listed fields from RFC4871 #5.5 + let defaultFieldNames = + 'From:Sender:Reply-To:Subject:Date:Message-ID:To:' + + 'Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:' + + 'Content-Description:Resent-Date:Resent-From:Resent-Sender:' + + 'Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:' + + 'List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:' + + 'List-Owner:List-Archive'; + + let fieldNames = options.headerFieldNames || defaultFieldNames; + + let canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields); + let dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash); + + let signer, signature; + + canonicalizedHeaderData.headers += 'dkim-signature:' + relaxedHeaderLine(dkimHeader); + + signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase()); + signer.update(canonicalizedHeaderData.headers); + try { + signature = signer.sign(options.privateKey, 'base64'); + } catch (E) { + return false; + } + + return dkimHeader + signature.replace(/(^.{73}|.{75}(?!\r?\n|\r))/g, '$&\r\n ').trim(); +}; + +module.exports.relaxedHeaders = relaxedHeaders; + +function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) { + let dkim = [ + 'v=1', + 'a=rsa-' + hashAlgo, + 'c=relaxed/relaxed', + 'd=' + punycode.toASCII(domainName), + 'q=dns/txt', + 's=' + keySelector, + 'bh=' + bodyHash, + 'h=' + fieldNames + ].join('; '); + + return mimeFuncs.foldLines('DKIM-Signature: ' + dkim, 76) + ';\r\n b='; +} + +function relaxedHeaders(headers, fieldNames, skipFields) { + let includedFields = new Set(); + let skip = new Set(); + let headerFields = new Map(); + + (skipFields || '') + .toLowerCase() + .split(':') + .forEach(field => { + skip.add(field.trim()); + }); + + (fieldNames || '') + .toLowerCase() + .split(':') + .filter(field => !skip.has(field.trim())) + .forEach(field => { + includedFields.add(field.trim()); + }); + + for (let i = headers.length - 1; i >= 0; i--) { + let line = headers[i]; + // only include the first value from bottom to top + if (includedFields.has(line.key) && !headerFields.has(line.key)) { + headerFields.set(line.key, relaxedHeaderLine(line.line)); + } + } + + let headersList = []; + let fields = []; + includedFields.forEach(field => { + if (headerFields.has(field)) { + fields.push(field); + headersList.push(field + ':' + headerFields.get(field)); + } + }); + + return { + headers: headersList.join('\r\n') + '\r\n', + fieldNames: fields.join(':') + }; +} + +function relaxedHeaderLine(line) { + return line + .substr(line.indexOf(':') + 1) + .replace(/\r?\n/g, '') + .replace(/\s+/g, ' ') + .trim(); +} diff --git a/node_modules/nodemailer/lib/fetch/cookies.js b/node_modules/nodemailer/lib/fetch/cookies.js new file mode 100644 index 0000000..3fbd988 --- /dev/null +++ b/node_modules/nodemailer/lib/fetch/cookies.js @@ -0,0 +1,284 @@ +'use strict'; + +// module to handle cookies + +const urllib = require('url'); + +const SESSION_TIMEOUT = 1800; // 30 min + +/** + * Creates a biskviit cookie jar for managing cookie values in memory + * + * @constructor + * @param {Object} [options] Optional options object + */ +class Cookies { + constructor(options) { + this.options = options || {}; + this.cookies = []; + } + + /** + * Stores a cookie string to the cookie storage + * + * @param {String} cookieStr Value from the 'Set-Cookie:' header + * @param {String} url Current URL + */ + set(cookieStr, url) { + let urlparts = urllib.parse(url || ''); + let cookie = this.parse(cookieStr); + let domain; + + if (cookie.domain) { + domain = cookie.domain.replace(/^\./, ''); + + // do not allow cross origin cookies + if ( + // can't be valid if the requested domain is shorter than current hostname + urlparts.hostname.length < domain.length || + // prefix domains with dot to be sure that partial matches are not used + ('.' + urlparts.hostname).substr(-domain.length + 1) !== '.' + domain + ) { + cookie.domain = urlparts.hostname; + } + } else { + cookie.domain = urlparts.hostname; + } + + if (!cookie.path) { + cookie.path = this.getPath(urlparts.pathname); + } + + // if no expire date, then use sessionTimeout value + if (!cookie.expires) { + cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1000); + } + + return this.add(cookie); + } + + /** + * Returns cookie string for the 'Cookie:' header. + * + * @param {String} url URL to check for + * @returns {String} Cookie header or empty string if no matches were found + */ + get(url) { + return this.list(url) + .map(cookie => cookie.name + '=' + cookie.value) + .join('; '); + } + + /** + * Lists all valied cookie objects for the specified URL + * + * @param {String} url URL to check for + * @returns {Array} An array of cookie objects + */ + list(url) { + let result = []; + let i; + let cookie; + + for (i = this.cookies.length - 1; i >= 0; i--) { + cookie = this.cookies[i]; + + if (this.isExpired(cookie)) { + this.cookies.splice(i, i); + continue; + } + + if (this.match(cookie, url)) { + result.unshift(cookie); + } + } + + return result; + } + + /** + * Parses cookie string from the 'Set-Cookie:' header + * + * @param {String} cookieStr String from the 'Set-Cookie:' header + * @returns {Object} Cookie object + */ + parse(cookieStr) { + let cookie = {}; + + (cookieStr || '') + .toString() + .split(';') + .forEach(cookiePart => { + let valueParts = cookiePart.split('='); + let key = valueParts + .shift() + .trim() + .toLowerCase(); + let value = valueParts.join('=').trim(); + let domain; + + if (!key) { + // skip empty parts + return; + } + + switch (key) { + case 'expires': + value = new Date(value); + // ignore date if can not parse it + if (value.toString() !== 'Invalid Date') { + cookie.expires = value; + } + break; + + case 'path': + cookie.path = value; + break; + + case 'domain': + domain = value.toLowerCase(); + if (domain.length && domain.charAt(0) !== '.') { + domain = '.' + domain; // ensure preceeding dot for user set domains + } + cookie.domain = domain; + break; + + case 'max-age': + cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000); + break; + + case 'secure': + cookie.secure = true; + break; + + case 'httponly': + cookie.httponly = true; + break; + + default: + if (!cookie.name) { + cookie.name = key; + cookie.value = value; + } + } + }); + + return cookie; + } + + /** + * Checks if a cookie object is valid for a specified URL + * + * @param {Object} cookie Cookie object + * @param {String} url URL to check for + * @returns {Boolean} true if cookie is valid for specifiec URL + */ + match(cookie, url) { + let urlparts = urllib.parse(url || ''); + + // check if hostname matches + // .foo.com also matches subdomains, foo.com does not + if ( + urlparts.hostname !== cookie.domain && + (cookie.domain.charAt(0) !== '.' || ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain) + ) { + return false; + } + + // check if path matches + let path = this.getPath(urlparts.pathname); + if (path.substr(0, cookie.path.length) !== cookie.path) { + return false; + } + + // check secure argument + if (cookie.secure && urlparts.protocol !== 'https:') { + return false; + } + + return true; + } + + /** + * Adds (or updates/removes if needed) a cookie object to the cookie storage + * + * @param {Object} cookie Cookie value to be stored + */ + add(cookie) { + let i; + let len; + + // nothing to do here + if (!cookie || !cookie.name) { + return false; + } + + // overwrite if has same params + for (i = 0, len = this.cookies.length; i < len; i++) { + if (this.compare(this.cookies[i], cookie)) { + // check if the cookie needs to be removed instead + if (this.isExpired(cookie)) { + this.cookies.splice(i, 1); // remove expired/unset cookie + return false; + } + + this.cookies[i] = cookie; + return true; + } + } + + // add as new if not already expired + if (!this.isExpired(cookie)) { + this.cookies.push(cookie); + } + + return true; + } + + /** + * Checks if two cookie objects are the same + * + * @param {Object} a Cookie to check against + * @param {Object} b Cookie to check against + * @returns {Boolean} True, if the cookies are the same + */ + compare(a, b) { + return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === a.httponly; + } + + /** + * Checks if a cookie is expired + * + * @param {Object} cookie Cookie object to check against + * @returns {Boolean} True, if the cookie is expired + */ + isExpired(cookie) { + return (cookie.expires && cookie.expires < new Date()) || !cookie.value; + } + + /** + * Returns normalized cookie path for an URL path argument + * + * @param {String} pathname + * @returns {String} Normalized path + */ + getPath(pathname) { + let path = (pathname || '/').split('/'); + path.pop(); // remove filename part + path = path.join('/').trim(); + + // ensure path prefix / + if (path.charAt(0) !== '/') { + path = '/' + path; + } + + // ensure path suffix / + if (path.substr(-1) !== '/') { + path += '/'; + } + + return path; + } +} + +module.exports = Cookies; diff --git a/node_modules/nodemailer/lib/fetch/index.js b/node_modules/nodemailer/lib/fetch/index.js new file mode 100644 index 0000000..ca7874e --- /dev/null +++ b/node_modules/nodemailer/lib/fetch/index.js @@ -0,0 +1,277 @@ +'use strict'; + +const http = require('http'); +const https = require('https'); +const urllib = require('url'); +const zlib = require('zlib'); +const PassThrough = require('stream').PassThrough; +const Cookies = require('./cookies'); +const packageData = require('../../package.json'); + +const MAX_REDIRECTS = 5; + +module.exports = function(url, options) { + return fetch(url, options); +}; + +module.exports.Cookies = Cookies; + +function fetch(url, options) { + options = options || {}; + + options.fetchRes = options.fetchRes || new PassThrough(); + options.cookies = options.cookies || new Cookies(); + options.redirects = options.redirects || 0; + options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects; + + if (options.cookie) { + [].concat(options.cookie || []).forEach(cookie => { + options.cookies.set(cookie, url); + }); + options.cookie = false; + } + + let fetchRes = options.fetchRes; + let parsed = urllib.parse(url); + let method = + (options.method || '') + .toString() + .trim() + .toUpperCase() || 'GET'; + let finished = false; + let cookies; + let body; + + let handler = parsed.protocol === 'https:' ? https : http; + + let headers = { + 'accept-encoding': 'gzip,deflate', + 'user-agent': 'nodemailer/' + packageData.version + }; + + Object.keys(options.headers || {}).forEach(key => { + headers[key.toLowerCase().trim()] = options.headers[key]; + }); + + if (options.userAgent) { + headers['user-agent'] = options.userAgent; + } + + if (parsed.auth) { + headers.Authorization = 'Basic ' + Buffer.from(parsed.auth).toString('base64'); + } + + if ((cookies = options.cookies.get(url))) { + headers.cookie = cookies; + } + + if (options.body) { + if (options.contentType !== false) { + headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded'; + } + + if (typeof options.body.pipe === 'function') { + // it's a stream + headers['Transfer-Encoding'] = 'chunked'; + body = options.body; + body.on('error', err => { + if (finished) { + return; + } + finished = true; + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + }); + } else { + if (options.body instanceof Buffer) { + body = options.body; + } else if (typeof options.body === 'object') { + try { + // encodeURIComponent can fail on invalid input (partial emoji etc.) + body = Buffer.from( + Object.keys(options.body) + .map(key => { + let value = options.body[key].toString().trim(); + return encodeURIComponent(key) + '=' + encodeURIComponent(value); + }) + .join('&') + ); + } catch (E) { + if (finished) { + return; + } + finished = true; + E.type = 'FETCH'; + E.sourceUrl = url; + fetchRes.emit('error', E); + return; + } + } else { + body = Buffer.from(options.body.toString().trim()); + } + + headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded'; + headers['Content-Length'] = body.length; + } + // if method is not provided, use POST instead of GET + method = + (options.method || '') + .toString() + .trim() + .toUpperCase() || 'POST'; + } + + let req; + let reqOptions = { + method, + host: parsed.hostname, + path: parsed.path, + port: parsed.port ? parsed.port : parsed.protocol === 'https:' ? 443 : 80, + headers, + rejectUnauthorized: false, + agent: false + }; + + if (options.tls) { + Object.keys(options.tls).forEach(key => { + reqOptions[key] = options.tls[key]; + }); + } + + try { + req = handler.request(reqOptions); + } catch (E) { + finished = true; + setImmediate(() => { + E.type = 'FETCH'; + E.sourceUrl = url; + fetchRes.emit('error', E); + }); + return fetchRes; + } + + if (options.timeout) { + req.setTimeout(options.timeout, () => { + if (finished) { + return; + } + finished = true; + req.abort(); + let err = new Error('Request Timeout'); + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + }); + } + + req.on('error', err => { + if (finished) { + return; + } + finished = true; + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + }); + + req.on('response', res => { + let inflate; + + if (finished) { + return; + } + + switch (res.headers['content-encoding']) { + case 'gzip': + case 'deflate': + inflate = zlib.createUnzip(); + break; + } + + if (res.headers['set-cookie']) { + [].concat(res.headers['set-cookie'] || []).forEach(cookie => { + options.cookies.set(cookie, url); + }); + } + + if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) { + // redirect + options.redirects++; + if (options.redirects > options.maxRedirects) { + finished = true; + let err = new Error('Maximum redirect count exceeded'); + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + req.abort(); + return; + } + // redirect does not include POST body + options.method = 'GET'; + options.body = false; + return fetch(urllib.resolve(url, res.headers.location), options); + } + + fetchRes.statusCode = res.statusCode; + fetchRes.headers = res.headers; + + if (res.statusCode >= 300 && !options.allowErrorResponse) { + finished = true; + let err = new Error('Invalid status code ' + res.statusCode); + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + req.abort(); + return; + } + + res.on('error', err => { + if (finished) { + return; + } + finished = true; + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + req.abort(); + }); + + if (inflate) { + res.pipe(inflate).pipe(fetchRes); + inflate.on('error', err => { + if (finished) { + return; + } + finished = true; + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + req.abort(); + }); + } else { + res.pipe(fetchRes); + } + }); + + setImmediate(() => { + if (body) { + try { + if (typeof body.pipe === 'function') { + return body.pipe(req); + } else { + req.write(body); + } + } catch (err) { + finished = true; + err.type = 'FETCH'; + err.sourceUrl = url; + fetchRes.emit('error', err); + return; + } + } + req.end(); + }); + + return fetchRes; +} diff --git a/node_modules/nodemailer/lib/json-transport/index.js b/node_modules/nodemailer/lib/json-transport/index.js new file mode 100644 index 0000000..769bde6 --- /dev/null +++ b/node_modules/nodemailer/lib/json-transport/index.js @@ -0,0 +1,82 @@ +'use strict'; + +const packageData = require('../../package.json'); +const shared = require('../shared'); + +/** + * Generates a Transport object to generate JSON output + * + * @constructor + * @param {Object} optional config parameter + */ +class JSONTransport { + constructor(options) { + options = options || {}; + + this.options = options || {}; + + this.name = 'JSONTransport'; + this.version = packageData.version; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'json-transport' + }); + } + + /** + *

Compiles a mailcomposer message and forwards it to handler that sends it.

+ * + * @param {Object} emailMessage MailComposer object + * @param {Function} callback Callback function to run when the sending is completed + */ + send(mail, done) { + // Sendmail strips this header line by itself + mail.message.keepBcc = true; + + let envelope = mail.data.envelope || mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + this.logger.info( + { + tnx: 'send', + messageId + }, + 'Composing JSON structure of %s to <%s>', + messageId, + recipients.join(', ') + ); + + setImmediate(() => { + mail.normalize((err, data) => { + if (err) { + this.logger.error( + { + err, + tnx: 'send', + messageId + }, + 'Failed building JSON structure for %s. %s', + messageId, + err.message + ); + return done(err); + } + + delete data.envelope; + delete data.normalizedHeaders; + + return done(null, { + envelope, + messageId, + message: this.options.skipEncoding ? data : JSON.stringify(data) + }); + }); + }); + } +} + +module.exports = JSONTransport; diff --git a/node_modules/nodemailer/lib/mail-composer/index.js b/node_modules/nodemailer/lib/mail-composer/index.js new file mode 100644 index 0000000..ed05b79 --- /dev/null +++ b/node_modules/nodemailer/lib/mail-composer/index.js @@ -0,0 +1,545 @@ +/* eslint no-undefined: 0 */ + +'use strict'; + +const MimeNode = require('../mime-node'); +const mimeFuncs = require('../mime-funcs'); + +/** + * Creates the object for composing a MimeNode instance out from the mail options + * + * @constructor + * @param {Object} mail Mail options + */ +class MailComposer { + constructor(mail) { + this.mail = mail || {}; + this.message = false; + } + + /** + * Builds MimeNode instance + */ + compile() { + this._alternatives = this.getAlternatives(); + this._htmlNode = this._alternatives.filter(alternative => /^text\/html\b/i.test(alternative.contentType)).pop(); + this._attachments = this.getAttachments(!!this._htmlNode); + + this._useRelated = !!(this._htmlNode && this._attachments.related.length); + this._useAlternative = this._alternatives.length > 1; + this._useMixed = this._attachments.attached.length > 1 || (this._alternatives.length && this._attachments.attached.length === 1); + + // Compose MIME tree + if (this.mail.raw) { + this.message = new MimeNode().setRaw(this.mail.raw); + } else if (this._useMixed) { + this.message = this._createMixed(); + } else if (this._useAlternative) { + this.message = this._createAlternative(); + } else if (this._useRelated) { + this.message = this._createRelated(); + } else { + this.message = this._createContentNode( + false, + [] + .concat(this._alternatives || []) + .concat(this._attachments.attached || []) + .shift() || { + contentType: 'text/plain', + content: '' + } + ); + } + + // Add custom headers + if (this.mail.headers) { + this.message.addHeader(this.mail.headers); + } + + // Add headers to the root node, always overrides custom headers + ['from', 'sender', 'to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'message-id', 'date'].forEach(header => { + let key = header.replace(/-(\w)/g, (o, c) => c.toUpperCase()); + if (this.mail[key]) { + this.message.setHeader(header, this.mail[key]); + } + }); + + // Sets custom envelope + if (this.mail.envelope) { + this.message.setEnvelope(this.mail.envelope); + } + + // ensure Message-Id value + this.message.messageId(); + + return this.message; + } + + /** + * List all attachments. Resulting attachment objects can be used as input for MimeNode nodes + * + * @param {Boolean} findRelated If true separate related attachments from attached ones + * @returns {Object} An object of arrays (`related` and `attached`) + */ + getAttachments(findRelated) { + let icalEvent, eventObject; + let attachments = [].concat(this.mail.attachments || []).map((attachment, i) => { + let data; + let isMessageNode = /^message\//i.test(attachment.contentType); + + if (/^data:/i.test(attachment.path || attachment.href)) { + attachment = this._processDataUrl(attachment); + } + + data = { + contentType: attachment.contentType || mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin'), + contentDisposition: attachment.contentDisposition || (isMessageNode ? 'inline' : 'attachment'), + contentTransferEncoding: 'contentTransferEncoding' in attachment ? attachment.contentTransferEncoding : 'base64' + }; + + if (attachment.filename) { + data.filename = attachment.filename; + } else if (!isMessageNode && attachment.filename !== false) { + data.filename = + (attachment.path || attachment.href || '') + .split('/') + .pop() + .split('?') + .shift() || 'attachment-' + (i + 1); + if (data.filename.indexOf('.') < 0) { + data.filename += '.' + mimeFuncs.detectExtension(data.contentType); + } + } + + if (/^https?:\/\//i.test(attachment.path)) { + attachment.href = attachment.path; + attachment.path = undefined; + } + + if (attachment.cid) { + data.cid = attachment.cid; + } + + if (attachment.raw) { + data.raw = attachment.raw; + } else if (attachment.path) { + data.content = { + path: attachment.path + }; + } else if (attachment.href) { + data.content = { + href: attachment.href + }; + } else { + data.content = attachment.content || ''; + } + + if (attachment.encoding) { + data.encoding = attachment.encoding; + } + + if (attachment.headers) { + data.headers = attachment.headers; + } + + return data; + }); + + if (this.mail.icalEvent) { + if ( + typeof this.mail.icalEvent === 'object' && + (this.mail.icalEvent.content || this.mail.icalEvent.path || this.mail.icalEvent.href || this.mail.icalEvent.raw) + ) { + icalEvent = this.mail.icalEvent; + } else { + icalEvent = { + content: this.mail.icalEvent + }; + } + + eventObject = {}; + Object.keys(icalEvent).forEach(key => { + eventObject[key] = icalEvent[key]; + }); + + eventObject.contentType = 'application/ics'; + if (!eventObject.headers) { + eventObject.headers = {}; + } + eventObject.filename = eventObject.filename || 'invite.ics'; + eventObject.headers['Content-Disposition'] = 'attachment'; + eventObject.headers['Content-Transfer-Encoding'] = 'base64'; + } + + if (!findRelated) { + return { + attached: attachments.concat(eventObject || []), + related: [] + }; + } else { + return { + attached: attachments.filter(attachment => !attachment.cid).concat(eventObject || []), + related: attachments.filter(attachment => !!attachment.cid) + }; + } + } + + /** + * List alternatives. Resulting objects can be used as input for MimeNode nodes + * + * @returns {Array} An array of alternative elements. Includes the `text` and `html` values as well + */ + getAlternatives() { + let alternatives = [], + text, + html, + watchHtml, + icalEvent, + eventObject; + + if (this.mail.text) { + if (typeof this.mail.text === 'object' && (this.mail.text.content || this.mail.text.path || this.mail.text.href || this.mail.text.raw)) { + text = this.mail.text; + } else { + text = { + content: this.mail.text + }; + } + text.contentType = 'text/plain' + (!text.encoding && mimeFuncs.isPlainText(text.content) ? '' : '; charset=utf-8'); + } + + if (this.mail.watchHtml) { + if ( + typeof this.mail.watchHtml === 'object' && + (this.mail.watchHtml.content || this.mail.watchHtml.path || this.mail.watchHtml.href || this.mail.watchHtml.raw) + ) { + watchHtml = this.mail.watchHtml; + } else { + watchHtml = { + content: this.mail.watchHtml + }; + } + watchHtml.contentType = 'text/watch-html' + (!watchHtml.encoding && mimeFuncs.isPlainText(watchHtml.content) ? '' : '; charset=utf-8'); + } + + // only include the calendar alternative if there are no attachments + // otherwise you might end up in a blank screen on some clients + if (this.mail.icalEvent && !(this.mail.attachments && this.mail.attachments.length)) { + if ( + typeof this.mail.icalEvent === 'object' && + (this.mail.icalEvent.content || this.mail.icalEvent.path || this.mail.icalEvent.href || this.mail.icalEvent.raw) + ) { + icalEvent = this.mail.icalEvent; + } else { + icalEvent = { + content: this.mail.icalEvent + }; + } + + eventObject = {}; + Object.keys(icalEvent).forEach(key => { + eventObject[key] = icalEvent[key]; + }); + + if (eventObject.content && typeof eventObject.content === 'object') { + // we are going to have the same attachment twice, so mark this to be + // resolved just once + eventObject.content._resolve = true; + } + + eventObject.filename = false; + eventObject.contentType = + 'text/calendar; charset="utf-8"; method=' + + (eventObject.method || 'PUBLISH') + .toString() + .trim() + .toUpperCase(); + if (!eventObject.headers) { + eventObject.headers = {}; + } + } + + if (this.mail.html) { + if (typeof this.mail.html === 'object' && (this.mail.html.content || this.mail.html.path || this.mail.html.href || this.mail.html.raw)) { + html = this.mail.html; + } else { + html = { + content: this.mail.html + }; + } + html.contentType = 'text/html' + (!html.encoding && mimeFuncs.isPlainText(html.content) ? '' : '; charset=utf-8'); + } + + [] + .concat(text || []) + .concat(watchHtml || []) + .concat(html || []) + .concat(eventObject || []) + .concat(this.mail.alternatives || []) + .forEach(alternative => { + let data; + + if (/^data:/i.test(alternative.path || alternative.href)) { + alternative = this._processDataUrl(alternative); + } + + data = { + contentType: alternative.contentType || mimeFuncs.detectMimeType(alternative.filename || alternative.path || alternative.href || 'txt'), + contentTransferEncoding: alternative.contentTransferEncoding + }; + + if (alternative.filename) { + data.filename = alternative.filename; + } + + if (/^https?:\/\//i.test(alternative.path)) { + alternative.href = alternative.path; + alternative.path = undefined; + } + + if (alternative.raw) { + data.raw = alternative.raw; + } else if (alternative.path) { + data.content = { + path: alternative.path + }; + } else if (alternative.href) { + data.content = { + href: alternative.href + }; + } else { + data.content = alternative.content || ''; + } + + if (alternative.encoding) { + data.encoding = alternative.encoding; + } + + if (alternative.headers) { + data.headers = alternative.headers; + } + + alternatives.push(data); + }); + + return alternatives; + } + + /** + * Builds multipart/mixed node. It should always contain different type of elements on the same level + * eg. text + attachments + * + * @param {Object} parentNode Parent for this note. If it does not exist, a root node is created + * @returns {Object} MimeNode node element + */ + _createMixed(parentNode) { + let node; + + if (!parentNode) { + node = new MimeNode('multipart/mixed', { + baseBoundary: this.mail.baseBoundary, + textEncoding: this.mail.textEncoding, + boundaryPrefix: this.mail.boundaryPrefix, + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } else { + node = parentNode.createChild('multipart/mixed', { + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } + + if (this._useAlternative) { + this._createAlternative(node); + } else if (this._useRelated) { + this._createRelated(node); + } + + [] + .concat((!this._useAlternative && this._alternatives) || []) + .concat(this._attachments.attached || []) + .forEach(element => { + // if the element is a html node from related subpart then ignore it + if (!this._useRelated || element !== this._htmlNode) { + this._createContentNode(node, element); + } + }); + + return node; + } + + /** + * Builds multipart/alternative node. It should always contain same type of elements on the same level + * eg. text + html view of the same data + * + * @param {Object} parentNode Parent for this note. If it does not exist, a root node is created + * @returns {Object} MimeNode node element + */ + _createAlternative(parentNode) { + let node; + + if (!parentNode) { + node = new MimeNode('multipart/alternative', { + baseBoundary: this.mail.baseBoundary, + textEncoding: this.mail.textEncoding, + boundaryPrefix: this.mail.boundaryPrefix, + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } else { + node = parentNode.createChild('multipart/alternative', { + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } + + this._alternatives.forEach(alternative => { + if (this._useRelated && this._htmlNode === alternative) { + this._createRelated(node); + } else { + this._createContentNode(node, alternative); + } + }); + + return node; + } + + /** + * Builds multipart/related node. It should always contain html node with related attachments + * + * @param {Object} parentNode Parent for this note. If it does not exist, a root node is created + * @returns {Object} MimeNode node element + */ + _createRelated(parentNode) { + let node; + + if (!parentNode) { + node = new MimeNode('multipart/related; type="text/html"', { + baseBoundary: this.mail.baseBoundary, + textEncoding: this.mail.textEncoding, + boundaryPrefix: this.mail.boundaryPrefix, + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } else { + node = parentNode.createChild('multipart/related; type="text/html"', { + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } + + this._createContentNode(node, this._htmlNode); + + this._attachments.related.forEach(alternative => this._createContentNode(node, alternative)); + + return node; + } + + /** + * Creates a regular node with contents + * + * @param {Object} parentNode Parent for this note. If it does not exist, a root node is created + * @param {Object} element Node data + * @returns {Object} MimeNode node element + */ + _createContentNode(parentNode, element) { + element = element || {}; + element.content = element.content || ''; + + let node; + let encoding = (element.encoding || 'utf8') + .toString() + .toLowerCase() + .replace(/[-_\s]/g, ''); + + if (!parentNode) { + node = new MimeNode(element.contentType, { + filename: element.filename, + baseBoundary: this.mail.baseBoundary, + textEncoding: this.mail.textEncoding, + boundaryPrefix: this.mail.boundaryPrefix, + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess + }); + } else { + node = parentNode.createChild(element.contentType, { + filename: element.filename, + disableUrlAccess: this.mail.disableUrlAccess, + disableFileAccess: this.mail.disableFileAccess, + normalizeHeaderKey: this.mail.normalizeHeaderKey + }); + } + + // add custom headers + if (element.headers) { + node.addHeader(element.headers); + } + + if (element.cid) { + node.setHeader('Content-Id', '<' + element.cid.replace(/[<>]/g, '') + '>'); + } + + if (element.contentTransferEncoding) { + node.setHeader('Content-Transfer-Encoding', element.contentTransferEncoding); + } else if (this.mail.encoding && /^text\//i.test(element.contentType)) { + node.setHeader('Content-Transfer-Encoding', this.mail.encoding); + } + + if (!/^text\//i.test(element.contentType) || element.contentDisposition) { + node.setHeader('Content-Disposition', element.contentDisposition || (element.cid ? 'inline' : 'attachment')); + } + + if (typeof element.content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) { + element.content = Buffer.from(element.content, encoding); + } + + // prefer pregenerated raw content + if (element.raw) { + node.setRaw(element.raw); + } else { + node.setContent(element.content); + } + + return node; + } + + /** + * Parses data uri and converts it to a Buffer + * + * @param {Object} element Content element + * @return {Object} Parsed element + */ + _processDataUrl(element) { + let parts = (element.path || element.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i); + if (!parts) { + return element; + } + + element.content = /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2])); + + if ('path' in element) { + element.path = false; + } + + if ('href' in element) { + element.href = false; + } + + parts[1].split(';').forEach(item => { + if (/^\w+\/[^/]+$/i.test(item)) { + element.contentType = element.contentType || item.toLowerCase(); + } + }); + + return element; + } +} + +module.exports = MailComposer; diff --git a/node_modules/nodemailer/lib/mailer/index.js b/node_modules/nodemailer/lib/mailer/index.js new file mode 100644 index 0000000..da4eedd --- /dev/null +++ b/node_modules/nodemailer/lib/mailer/index.js @@ -0,0 +1,423 @@ +'use strict'; + +const EventEmitter = require('events'); +const shared = require('../shared'); +const mimeTypes = require('../mime-funcs/mime-types'); +const MailComposer = require('../mail-composer'); +const DKIM = require('../dkim'); +const httpProxyClient = require('../smtp-connection/http-proxy-client'); +const util = require('util'); +const urllib = require('url'); +const packageData = require('../../package.json'); +const MailMessage = require('./mail-message'); +const net = require('net'); +const dns = require('dns'); +const crypto = require('crypto'); + +/** + * Creates an object for exposing the Mail API + * + * @constructor + * @param {Object} transporter Transport object instance to pass the mails to + */ +class Mail extends EventEmitter { + constructor(transporter, options, defaults) { + super(); + + this.options = options || {}; + this._defaults = defaults || {}; + + this._defaultPlugins = { + compile: [(...args) => this._convertDataImages(...args)], + stream: [] + }; + + this._userPlugins = { + compile: [], + stream: [] + }; + + this.meta = new Map(); + + this.dkim = this.options.dkim ? new DKIM(this.options.dkim) : false; + + this.transporter = transporter; + this.transporter.mailer = this; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'mail' + }); + + this.logger.debug( + { + tnx: 'create' + }, + 'Creating transport: %s', + this.getVersionString() + ); + + // setup emit handlers for the transporter + if (typeof transporter.on === 'function') { + // deprecated log interface + this.transporter.on('log', log => { + this.logger.debug( + { + tnx: 'transport' + }, + '%s: %s', + log.type, + log.message + ); + }); + + // transporter errors + this.transporter.on('error', err => { + this.logger.error( + { + err, + tnx: 'transport' + }, + 'Transport Error: %s', + err.message + ); + this.emit('error', err); + }); + + // indicates if the sender has became idle + this.transporter.on('idle', (...args) => { + this.emit('idle', ...args); + }); + } + + /** + * Optional methods passed to the underlying transport object + */ + ['close', 'isIdle', 'verify'].forEach(method => { + this[method] = (...args) => { + if (typeof this.transporter[method] === 'function') { + return this.transporter[method](...args); + } else { + this.logger.warn( + { + tnx: 'transport', + methodName: method + }, + 'Non existing method %s called for transport', + method + ); + return false; + } + }; + }); + + // setup proxy handling + if (this.options.proxy && typeof this.options.proxy === 'string') { + this.setupProxy(this.options.proxy); + } + } + + use(step, plugin) { + step = (step || '').toString(); + if (!this._userPlugins.hasOwnProperty(step)) { + this._userPlugins[step] = [plugin]; + } else { + this._userPlugins[step].push(plugin); + } + + return this; + } + + /** + * Sends an email using the preselected transport object + * + * @param {Object} data E-data description + * @param {Function?} callback Callback to run once the sending succeeded or failed + */ + sendMail(data, callback) { + let promise; + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = shared.callbackPromise(resolve, reject); + }); + } + + if (typeof this.getSocket === 'function') { + this.transporter.getSocket = this.getSocket; + this.getSocket = false; + } + + let mail = new MailMessage(this, data); + + this.logger.debug( + { + tnx: 'transport', + name: this.transporter.name, + version: this.transporter.version, + action: 'send' + }, + 'Sending mail using %s/%s', + this.transporter.name, + this.transporter.version + ); + + this._processPlugins('compile', mail, err => { + if (err) { + this.logger.error( + { + err, + tnx: 'plugin', + action: 'compile' + }, + 'PluginCompile Error: %s', + err.message + ); + return callback(err); + } + + mail.message = new MailComposer(mail.data).compile(); + + mail.setMailerHeader(); + mail.setPriorityHeaders(); + mail.setListHeaders(); + + this._processPlugins('stream', mail, err => { + if (err) { + this.logger.error( + { + err, + tnx: 'plugin', + action: 'stream' + }, + 'PluginStream Error: %s', + err.message + ); + return callback(err); + } + + if (mail.data.dkim || this.dkim) { + mail.message.processFunc(input => { + let dkim = mail.data.dkim ? new DKIM(mail.data.dkim) : this.dkim; + this.logger.debug( + { + tnx: 'DKIM', + messageId: mail.message.messageId(), + dkimDomains: dkim.keys.map(key => key.keySelector + '.' + key.domainName).join(', ') + }, + 'Signing outgoing message with %s keys', + dkim.keys.length + ); + return dkim.sign(input, mail.data._dkim); + }); + } + + this.transporter.send(mail, (...args) => { + if (args[0]) { + this.logger.error( + { + err: args[0], + tnx: 'transport', + action: 'send' + }, + 'Send Error: %s', + args[0].message + ); + } + callback(...args); + }); + }); + }); + + return promise; + } + + getVersionString() { + return util.format('%s (%s; +%s; %s/%s)', packageData.name, packageData.version, packageData.homepage, this.transporter.name, this.transporter.version); + } + + _processPlugins(step, mail, callback) { + step = (step || '').toString(); + + if (!this._userPlugins.hasOwnProperty(step)) { + return callback(); + } + + let userPlugins = this._userPlugins[step] || []; + let defaultPlugins = this._defaultPlugins[step] || []; + + if (userPlugins.length) { + this.logger.debug( + { + tnx: 'transaction', + pluginCount: userPlugins.length, + step + }, + 'Using %s plugins for %s', + userPlugins.length, + step + ); + } + + if (userPlugins.length + defaultPlugins.length === 0) { + return callback(); + } + + let pos = 0; + let block = 'default'; + let processPlugins = () => { + let curplugins = block === 'default' ? defaultPlugins : userPlugins; + if (pos >= curplugins.length) { + if (block === 'default' && userPlugins.length) { + block = 'user'; + pos = 0; + curplugins = userPlugins; + } else { + return callback(); + } + } + let plugin = curplugins[pos++]; + plugin(mail, err => { + if (err) { + return callback(err); + } + processPlugins(); + }); + }; + + processPlugins(); + } + + /** + * Sets up proxy handler for a Nodemailer object + * + * @param {String} proxyUrl Proxy configuration url + */ + setupProxy(proxyUrl) { + let proxy = urllib.parse(proxyUrl); + + // setup socket handler for the mailer object + this.getSocket = (options, callback) => { + let protocol = proxy.protocol.replace(/:$/, '').toLowerCase(); + + if (this.meta.has('proxy_handler_' + protocol)) { + return this.meta.get('proxy_handler_' + protocol)(proxy, options, callback); + } + + switch (protocol) { + // Connect using a HTTP CONNECT method + case 'http': + case 'https': + httpProxyClient(proxy.href, options.port, options.host, (err, socket) => { + if (err) { + return callback(err); + } + return callback(null, { + connection: socket + }); + }); + return; + case 'socks': + case 'socks5': + case 'socks4': + case 'socks4a': { + if (!this.meta.has('proxy_socks_module')) { + return callback(new Error('Socks module not loaded')); + } + let connect = ipaddress => { + let proxyV2 = !!this.meta.get('proxy_socks_module').SocksClient; + let socksClient = proxyV2 ? this.meta.get('proxy_socks_module').SocksClient : this.meta.get('proxy_socks_module'); + let proxyType = Number(proxy.protocol.replace(/\D/g, '')) || 5; + let connectionOpts = { + proxy: { + ipaddress, + port: Number(proxy.port), + type: proxyType + }, + [proxyV2 ? 'destination' : 'target']: { + host: options.host, + port: options.port + }, + command: 'connect' + }; + + if (proxy.auth) { + let username = decodeURIComponent(proxy.auth.split(':').shift()); + let password = decodeURIComponent(proxy.auth.split(':').pop()); + if (proxyV2) { + connectionOpts.userId = username; + connectionOpts.password = password; + } else if (proxyType === 4) { + connectionOpts.userid = username; + } else { + connectionOpts.authentication = { + username, + password + }; + } + } + + socksClient.createConnection(connectionOpts, (err, info) => { + if (err) { + return callback(err); + } + return callback(null, { + connection: info.socket || info + }); + }); + }; + + if (net.isIP(proxy.hostname)) { + return connect(proxy.hostname); + } + + return dns.resolve(proxy.hostname, (err, address) => { + if (err) { + return callback(err); + } + connect(Array.isArray(address) ? address[0] : address); + }); + } + } + callback(new Error('Unknown proxy configuration')); + }; + } + + _convertDataImages(mail, callback) { + if ((!this.options.attachDataUrls && !mail.data.attachDataUrls) || !mail.data.html) { + return callback(); + } + mail.resolveContent(mail.data, 'html', (err, html) => { + if (err) { + return callback(err); + } + let cidCounter = 0; + html = (html || '').toString().replace(/(]* src\s*=[\s"']*)(data:([^;]+);[^"'>\s]+)/gi, (match, prefix, dataUri, mimeType) => { + let cid = crypto.randomBytes(10).toString('hex') + '@localhost'; + if (!mail.data.attachments) { + mail.data.attachments = []; + } + if (!Array.isArray(mail.data.attachments)) { + mail.data.attachments = [].concat(mail.data.attachments || []); + } + mail.data.attachments.push({ + path: dataUri, + cid, + filename: 'image-' + ++cidCounter + '.' + mimeTypes.detectExtension(mimeType) + }); + return prefix + 'cid:' + cid; + }); + mail.data.html = html; + callback(); + }); + } + + set(key, value) { + return this.meta.set(key, value); + } + + get(key) { + return this.meta.get(key); + } +} + +module.exports = Mail; diff --git a/node_modules/nodemailer/lib/mailer/mail-message.js b/node_modules/nodemailer/lib/mailer/mail-message.js new file mode 100644 index 0000000..edec358 --- /dev/null +++ b/node_modules/nodemailer/lib/mailer/mail-message.js @@ -0,0 +1,295 @@ +'use strict'; + +const shared = require('../shared'); +const MimeNode = require('../mime-node'); +const mimeFuncs = require('../mime-funcs'); + +class MailMessage { + constructor(mailer, data) { + this.mailer = mailer; + this.data = {}; + this.message = null; + + data = data || {}; + let options = mailer.options || {}; + let defaults = mailer._defaults || {}; + + Object.keys(data).forEach(key => { + this.data[key] = data[key]; + }); + + this.data.headers = this.data.headers || {}; + + // apply defaults + Object.keys(defaults).forEach(key => { + if (!(key in this.data)) { + this.data[key] = defaults[key]; + } else if (key === 'headers') { + // headers is a special case. Allow setting individual default headers + Object.keys(defaults.headers).forEach(key => { + if (!(key in this.data.headers)) { + this.data.headers[key] = defaults.headers[key]; + } + }); + } + }); + + // force specific keys from transporter options + ['disableFileAccess', 'disableUrlAccess', 'normalizeHeaderKey'].forEach(key => { + if (key in options) { + this.data[key] = options[key]; + } + }); + } + + resolveContent(...args) { + return shared.resolveContent(...args); + } + + resolveAll(callback) { + let keys = [[this.data, 'html'], [this.data, 'text'], [this.data, 'watchHtml'], [this.data, 'icalEvent']]; + + if (this.data.alternatives && this.data.alternatives.length) { + this.data.alternatives.forEach((alternative, i) => { + keys.push([this.data.alternatives, i]); + }); + } + + if (this.data.attachments && this.data.attachments.length) { + this.data.attachments.forEach((attachment, i) => { + if (!attachment.filename) { + attachment.filename = + (attachment.path || attachment.href || '') + .split('/') + .pop() + .split('?') + .shift() || 'attachment-' + (i + 1); + if (attachment.filename.indexOf('.') < 0) { + attachment.filename += '.' + mimeFuncs.detectExtension(attachment.contentType); + } + } + + if (!attachment.contentType) { + attachment.contentType = mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin'); + } + + keys.push([this.data.attachments, i]); + }); + } + + let mimeNode = new MimeNode(); + + let addressKeys = ['from', 'to', 'cc', 'bcc', 'sender', 'replyTo']; + + addressKeys.forEach(address => { + let value; + if (this.message) { + value = [].concat(mimeNode._parseAddresses(this.message.getHeader(address === 'replyTo' ? 'reply-to' : address)) || []); + } else if (this.data[address]) { + value = [].concat(mimeNode._parseAddresses(this.data[address]) || []); + } + if (value && value.length) { + this.data[address] = value; + } else if (address in this.data) { + this.data[address] = null; + } + }); + + let singleKeys = ['from', 'sender', 'replyTo']; + singleKeys.forEach(address => { + if (this.data[address]) { + this.data[address] = this.data[address].shift(); + } + }); + + let pos = 0; + let resolveNext = () => { + if (pos >= keys.length) { + return callback(null, this.data); + } + let args = keys[pos++]; + if (!args[0] || !args[0][args[1]]) { + return resolveNext(); + } + shared.resolveContent(...args, (err, value) => { + if (err) { + return callback(err); + } + + let node = { + content: value + }; + if (args[0][args[1]] && typeof args[0][args[1]] === 'object' && !Buffer.isBuffer(args[0][args[1]])) { + Object.keys(args[0][args[1]]).forEach(key => { + if (!(key in node) && !['content', 'path', 'href', 'raw'].includes(key)) { + node[key] = args[0][args[1]][key]; + } + }); + } + + args[0][args[1]] = node; + resolveNext(); + }); + }; + + setImmediate(() => resolveNext()); + } + + normalize(callback) { + let envelope = this.data.envelope || this.message.getEnvelope(); + let messageId = this.message.messageId(); + + this.resolveAll((err, data) => { + if (err) { + return callback(err); + } + + data.envelope = envelope; + data.messageId = messageId; + + ['html', 'text', 'watchHtml'].forEach(key => { + if (data[key] && data[key].content) { + if (typeof data[key].content === 'string') { + data[key] = data[key].content; + } else if (Buffer.isBuffer(data[key].content)) { + data[key] = data[key].content.toString(); + } + } + }); + + if (data.icalEvent && Buffer.isBuffer(data.icalEvent.content)) { + data.icalEvent.content = data.icalEvent.content.toString('base64'); + data.icalEvent.encoding = 'base64'; + } + + if (data.alternatives && data.alternatives.length) { + data.alternatives.forEach(alternative => { + if (alternative && alternative.content && Buffer.isBuffer(alternative.content)) { + alternative.content = alternative.content.toString('base64'); + alternative.encoding = 'base64'; + } + }); + } + + if (data.attachments && data.attachments.length) { + data.attachments.forEach(attachment => { + if (attachment && attachment.content && Buffer.isBuffer(attachment.content)) { + attachment.content = attachment.content.toString('base64'); + attachment.encoding = 'base64'; + } + }); + } + + data.normalizedHeaders = {}; + Object.keys(data.headers || {}).forEach(key => { + let value = [].concat(data.headers[key] || []).shift(); + value = (value && value.value) || value; + if (value) { + if (['references', 'in-reply-to', 'message-id', 'content-id'].includes(key)) { + value = this.message._encodeHeaderValue(key, value); + } + data.normalizedHeaders[key] = value; + } + }); + + if (data.list && typeof data.list === 'object') { + let listHeaders = this._getListHeaders(data.list); + listHeaders.forEach(entry => { + data.normalizedHeaders[entry.key] = entry.value.map(val => (val && val.value) || val).join(', '); + }); + } + + if (data.references) { + data.normalizedHeaders.references = this.message._encodeHeaderValue('references', data.references); + } + + if (data.inReplyTo) { + data.normalizedHeaders['in-reply-to'] = this.message._encodeHeaderValue('in-reply-to', data.inReplyTo); + } + + return callback(null, data); + }); + } + + setMailerHeader() { + if (!this.message || !this.data.xMailer) { + return; + } + this.message.setHeader('X-Mailer', this.data.xMailer); + } + + setPriorityHeaders() { + if (!this.message || !this.data.priority) { + return; + } + switch ((this.data.priority || '').toString().toLowerCase()) { + case 'high': + this.message.setHeader('X-Priority', '1 (Highest)'); + this.message.setHeader('X-MSMail-Priority', 'High'); + this.message.setHeader('Importance', 'High'); + break; + case 'low': + this.message.setHeader('X-Priority', '5 (Lowest)'); + this.message.setHeader('X-MSMail-Priority', 'Low'); + this.message.setHeader('Importance', 'Low'); + break; + default: + // do not add anything, since all messages are 'Normal' by default + } + } + + setListHeaders() { + if (!this.message || !this.data.list || typeof this.data.list !== 'object') { + return; + } + // add optional List-* headers + if (this.data.list && typeof this.data.list === 'object') { + this._getListHeaders(this.data.list).forEach(listHeader => { + listHeader.value.forEach(value => { + this.message.addHeader(listHeader.key, value); + }); + }); + } + } + + _getListHeaders(listData) { + // make sure an url looks like + return Object.keys(listData).map(key => ({ + key: 'list-' + key.toLowerCase().trim(), + value: [].concat(listData[key] || []).map(value => { + if (typeof value === 'string') { + return this._formatListUrl(value); + } + return { + prepared: true, + value: [] + .concat(value || []) + .map(value => { + if (typeof value === 'string') { + return this._formatListUrl(value); + } + if (value && value.url) { + return this._formatListUrl(value.url) + (value.comment ? ' (' + value.comment + ')' : ''); + } + return ''; + }) + .join(', ') + }; + }) + })); + } + + _formatListUrl(url) { + url = url.replace(/[\s<]+|[\s>]+/g, ''); + if (/^(https?|mailto|ftp):/.test(url)) { + return '<' + url + '>'; + } + if (/^[^@]+@[^@]+$/.test(url)) { + return ''; + } + + return ''; + } +} + +module.exports = MailMessage; diff --git a/node_modules/nodemailer/lib/mime-funcs/index.js b/node_modules/nodemailer/lib/mime-funcs/index.js new file mode 100644 index 0000000..dad3034 --- /dev/null +++ b/node_modules/nodemailer/lib/mime-funcs/index.js @@ -0,0 +1,628 @@ +/* eslint no-control-regex:0 */ + +'use strict'; + +const base64 = require('../base64'); +const qp = require('../qp'); +const mimeTypes = require('./mime-types'); + +module.exports = { + /** + * Checks if a value is plaintext string (uses only printable 7bit chars) + * + * @param {String} value String to be tested + * @returns {Boolean} true if it is a plaintext string + */ + isPlainText(value) { + if (typeof value !== 'string' || /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/.test(value)) { + return false; + } else { + return true; + } + }, + + /** + * Checks if a multi line string containes lines longer than the selected value. + * + * Useful when detecting if a mail message needs any processing at all – + * if only plaintext characters are used and lines are short, then there is + * no need to encode the values in any way. If the value is plaintext but has + * longer lines then allowed, then use format=flowed + * + * @param {Number} lineLength Max line length to check for + * @returns {Boolean} Returns true if there is at least one line longer than lineLength chars + */ + hasLongerLines(str, lineLength) { + if (str.length > 128 * 1024) { + // do not test strings longer than 128kB + return true; + } + return new RegExp('^.{' + (lineLength + 1) + ',}', 'm').test(str); + }, + + /** + * Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047) + * + * @param {String|Buffer} data String to be encoded + * @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B + * @param {Number} [maxLength=0] If set, split mime words into several chunks if needed + * @return {String} Single or several mime words joined together + */ + encodeWord(data, mimeWordEncoding, maxLength) { + mimeWordEncoding = (mimeWordEncoding || 'Q') + .toString() + .toUpperCase() + .trim() + .charAt(0); + maxLength = maxLength || 0; + + let encodedStr; + let toCharset = 'UTF-8'; + + if (maxLength && maxLength > 7 + toCharset.length) { + maxLength -= 7 + toCharset.length; + } + + if (mimeWordEncoding === 'Q') { + // https://tools.ietf.org/html/rfc2047#section-5 rule (3) + encodedStr = qp.encode(data).replace(/[^a-z0-9!*+\-/=]/gi, chr => { + let ord = chr + .charCodeAt(0) + .toString(16) + .toUpperCase(); + if (chr === ' ') { + return '_'; + } else { + return '=' + (ord.length === 1 ? '0' + ord : ord); + } + }); + } else if (mimeWordEncoding === 'B') { + encodedStr = typeof data === 'string' ? data : base64.encode(data); + maxLength = maxLength ? Math.max(3, (maxLength - maxLength % 4) / 4 * 3) : 0; + } + + if (maxLength && (mimeWordEncoding !== 'B' ? encodedStr : base64.encode(data)).length > maxLength) { + if (mimeWordEncoding === 'Q') { + encodedStr = this.splitMimeEncodedString(encodedStr, maxLength).join('?= =?' + toCharset + '?' + mimeWordEncoding + '?'); + } else { + // RFC2047 6.3 (2) states that encoded-word must include an integral number of characters, so no chopping unicode sequences + let parts = []; + let lpart = ''; + for (let i = 0, len = encodedStr.length; i < len; i++) { + let chr = encodedStr.charAt(i); + // check if we can add this character to the existing string + // without breaking byte length limit + if (Buffer.byteLength(lpart + chr) <= maxLength || i === 0) { + lpart += chr; + } else { + // we hit the length limit, so push the existing string and start over + parts.push(base64.encode(lpart)); + lpart = chr; + } + } + if (lpart) { + parts.push(base64.encode(lpart)); + } + + if (parts.length > 1) { + encodedStr = parts.join('?= =?' + toCharset + '?' + mimeWordEncoding + '?'); + } else { + encodedStr = parts.join(''); + } + } + } else if (mimeWordEncoding === 'B') { + encodedStr = base64.encode(data); + } + + return '=?' + toCharset + '?' + mimeWordEncoding + '?' + encodedStr + (encodedStr.substr(-2) === '?=' ? '' : '?='); + }, + + /** + * Finds word sequences with non ascii text and converts these to mime words + * + * @param {String} value String to be encoded + * @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B + * @param {Number} [maxLength=0] If set, split mime words into several chunks if needed + * @param {Boolean} [encodeAll=false] If true and the value needs encoding then encodes entire string, not just the smallest match + * @return {String} String with possible mime words + */ + encodeWords(value, mimeWordEncoding, maxLength, encodeAll) { + maxLength = maxLength || 0; + + let encodedValue; + + // find first word with a non-printable ascii in it + let firstMatch = value.match(/(?:^|\s)([^\s]*[\u0080-\uFFFF])/); + if (!firstMatch) { + return value; + } + + if (encodeAll) { + // if it is requested to encode everything or the string contains something that resebles encoded word, then encode everything + + return this.encodeWord(value, mimeWordEncoding, maxLength); + } + + // find the last word with a non-printable ascii in it + let lastMatch = value.match(/([\u0080-\uFFFF][^\s]*)[^\u0080-\uFFFF]*$/); + if (!lastMatch) { + // should not happen + return value; + } + + let startIndex = + firstMatch.index + + ( + firstMatch[0].match(/[^\s]/) || { + index: 0 + } + ).index; + let endIndex = lastMatch.index + (lastMatch[1] || '').length; + + encodedValue = + (startIndex ? value.substr(0, startIndex) : '') + + this.encodeWord(value.substring(startIndex, endIndex), mimeWordEncoding || 'Q', maxLength) + + (endIndex < value.length ? value.substr(endIndex) : ''); + + return encodedValue; + }, + + /** + * Joins parsed header value together as 'value; param1=value1; param2=value2' + * PS: We are following RFC 822 for the list of special characters that we need to keep in quotes. + * Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html + * @param {Object} structured Parsed header value + * @return {String} joined header value + */ + buildHeaderValue(structured) { + let paramsArray = []; + + Object.keys(structured.params || {}).forEach(param => { + // filename might include unicode characters so it is a special case + // other values probably do not + let value = structured.params[param]; + if (!this.isPlainText(value) || value.length >= 75) { + this.buildHeaderParam(param, value, 50).forEach(encodedParam => { + if (!/[\s"\\;:/=(),<>@[\]?]|^[-']|'$/.test(encodedParam.value) || encodedParam.key.substr(-1) === '*') { + paramsArray.push(encodedParam.key + '=' + encodedParam.value); + } else { + paramsArray.push(encodedParam.key + '=' + JSON.stringify(encodedParam.value)); + } + }); + } else if (/[\s'"\\;:/=(),<>@[\]?]|^-/.test(value)) { + paramsArray.push(param + '=' + JSON.stringify(value)); + } else { + paramsArray.push(param + '=' + value); + } + }); + + return structured.value + (paramsArray.length ? '; ' + paramsArray.join('; ') : ''); + }, + + /** + * Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231) + * Useful for splitting long parameter values. + * + * For example + * title="unicode string" + * becomes + * title*0*=utf-8''unicode + * title*1*=%20string + * + * @param {String|Buffer} data String to be encoded + * @param {Number} [maxLength=50] Max length for generated chunks + * @param {String} [fromCharset='UTF-8'] Source sharacter set + * @return {Array} A list of encoded keys and headers + */ + buildHeaderParam(key, data, maxLength) { + let list = []; + let encodedStr = typeof data === 'string' ? data : (data || '').toString(); + let encodedStrArr; + let chr, ord; + let line; + let startPos = 0; + let i, len; + + maxLength = maxLength || 50; + + // process ascii only text + if (this.isPlainText(data)) { + // check if conversion is even needed + if (encodedStr.length <= maxLength) { + return [ + { + key, + value: encodedStr + } + ]; + } + + encodedStr = encodedStr.replace(new RegExp('.{' + maxLength + '}', 'g'), str => { + list.push({ + line: str + }); + return ''; + }); + + if (encodedStr) { + list.push({ + line: encodedStr + }); + } + } else { + if (/[\uD800-\uDBFF]/.test(encodedStr)) { + // string containts surrogate pairs, so normalize it to an array of bytes + encodedStrArr = []; + for (i = 0, len = encodedStr.length; i < len; i++) { + chr = encodedStr.charAt(i); + ord = chr.charCodeAt(0); + if (ord >= 0xd800 && ord <= 0xdbff && i < len - 1) { + chr += encodedStr.charAt(i + 1); + encodedStrArr.push(chr); + i++; + } else { + encodedStrArr.push(chr); + } + } + encodedStr = encodedStrArr; + } + + // first line includes the charset and language info and needs to be encoded + // even if it does not contain any unicode characters + line = 'utf-8\x27\x27'; + let encoded = true; + startPos = 0; + + // process text with unicode or special chars + for (i = 0, len = encodedStr.length; i < len; i++) { + chr = encodedStr[i]; + + if (encoded) { + chr = this.safeEncodeURIComponent(chr); + } else { + // try to urlencode current char + chr = chr === ' ' ? chr : this.safeEncodeURIComponent(chr); + // By default it is not required to encode a line, the need + // only appears when the string contains unicode or special chars + // in this case we start processing the line over and encode all chars + if (chr !== encodedStr[i]) { + // Check if it is even possible to add the encoded char to the line + // If not, there is no reason to use this line, just push it to the list + // and start a new line with the char that needs encoding + if ((this.safeEncodeURIComponent(line) + chr).length >= maxLength) { + list.push({ + line, + encoded + }); + line = ''; + startPos = i - 1; + } else { + encoded = true; + i = startPos; + line = ''; + continue; + } + } + } + + // if the line is already too long, push it to the list and start a new one + if ((line + chr).length >= maxLength) { + list.push({ + line, + encoded + }); + line = chr = encodedStr[i] === ' ' ? ' ' : this.safeEncodeURIComponent(encodedStr[i]); + if (chr === encodedStr[i]) { + encoded = false; + startPos = i - 1; + } else { + encoded = true; + } + } else { + line += chr; + } + } + + if (line) { + list.push({ + line, + encoded + }); + } + } + + return list.map((item, i) => ({ + // encoded lines: {name}*{part}* + // unencoded lines: {name}*{part} + // if any line needs to be encoded then the first line (part==0) is always encoded + key: key + '*' + i + (item.encoded ? '*' : ''), + value: item.line + })); + }, + + /** + * Parses a header value with key=value arguments into a structured + * object. + * + * parseHeaderValue('content-type: text/plain; CHARSET='UTF-8'') -> + * { + * 'value': 'text/plain', + * 'params': { + * 'charset': 'UTF-8' + * } + * } + * + * @param {String} str Header value + * @return {Object} Header value as a parsed structure + */ + parseHeaderValue(str) { + let response = { + value: false, + params: {} + }; + let key = false; + let value = ''; + let type = 'value'; + let quote = false; + let escaped = false; + let chr; + + for (let i = 0, len = str.length; i < len; i++) { + chr = str.charAt(i); + if (type === 'key') { + if (chr === '=') { + key = value.trim().toLowerCase(); + type = 'value'; + value = ''; + continue; + } + value += chr; + } else { + if (escaped) { + value += chr; + } else if (chr === '\\') { + escaped = true; + continue; + } else if (quote && chr === quote) { + quote = false; + } else if (!quote && chr === '"') { + quote = chr; + } else if (!quote && chr === ';') { + if (key === false) { + response.value = value.trim(); + } else { + response.params[key] = value.trim(); + } + type = 'key'; + value = ''; + } else { + value += chr; + } + escaped = false; + } + } + + if (type === 'value') { + if (key === false) { + response.value = value.trim(); + } else { + response.params[key] = value.trim(); + } + } else if (value.trim()) { + response.params[value.trim().toLowerCase()] = ''; + } + + // handle parameter value continuations + // https://tools.ietf.org/html/rfc2231#section-3 + + // preprocess values + Object.keys(response.params).forEach(key => { + let actualKey, nr, match, value; + if ((match = key.match(/(\*(\d+)|\*(\d+)\*|\*)$/))) { + actualKey = key.substr(0, match.index); + nr = Number(match[2] || match[3]) || 0; + + if (!response.params[actualKey] || typeof response.params[actualKey] !== 'object') { + response.params[actualKey] = { + charset: false, + values: [] + }; + } + + value = response.params[key]; + + if (nr === 0 && match[0].substr(-1) === '*' && (match = value.match(/^([^']*)'[^']*'(.*)$/))) { + response.params[actualKey].charset = match[1] || 'iso-8859-1'; + value = match[2]; + } + + response.params[actualKey].values[nr] = value; + + // remove the old reference + delete response.params[key]; + } + }); + + // concatenate split rfc2231 strings and convert encoded strings to mime encoded words + Object.keys(response.params).forEach(key => { + let value; + if (response.params[key] && Array.isArray(response.params[key].values)) { + value = response.params[key].values.map(val => val || '').join(''); + + if (response.params[key].charset) { + // convert "%AB" to "=?charset?Q?=AB?=" + response.params[key] = + '=?' + + response.params[key].charset + + '?Q?' + + value + // fix invalidly encoded chars + .replace(/[=?_\s]/g, s => { + let c = s.charCodeAt(0).toString(16); + if (s === ' ') { + return '_'; + } else { + return '%' + (c.length < 2 ? '0' : '') + c; + } + }) + // change from urlencoding to percent encoding + .replace(/%/g, '=') + + '?='; + } else { + response.params[key] = value; + } + } + }); + + return response; + }, + + /** + * Returns file extension for a content type string. If no suitable extensions + * are found, 'bin' is used as the default extension + * + * @param {String} mimeType Content type to be checked for + * @return {String} File extension + */ + detectExtension: mimeType => mimeTypes.detectExtension(mimeType), + + /** + * Returns content type for a file extension. If no suitable content types + * are found, 'application/octet-stream' is used as the default content type + * + * @param {String} extension Extension to be checked for + * @return {String} File extension + */ + detectMimeType: extension => mimeTypes.detectMimeType(extension), + + /** + * Folds long lines, useful for folding header lines (afterSpace=false) and + * flowed text (afterSpace=true) + * + * @param {String} str String to be folded + * @param {Number} [lineLength=76] Maximum length of a line + * @param {Boolean} afterSpace If true, leave a space in th end of a line + * @return {String} String with folded lines + */ + foldLines(str, lineLength, afterSpace) { + str = (str || '').toString(); + lineLength = lineLength || 76; + + let pos = 0, + len = str.length, + result = '', + line, + match; + + while (pos < len) { + line = str.substr(pos, lineLength); + if (line.length < lineLength) { + result += line; + break; + } + if ((match = line.match(/^[^\n\r]*(\r?\n|\r)/))) { + line = match[0]; + result += line; + pos += line.length; + continue; + } else if ((match = line.match(/(\s+)[^\s]*$/)) && match[0].length - (afterSpace ? (match[1] || '').length : 0) < line.length) { + line = line.substr(0, line.length - (match[0].length - (afterSpace ? (match[1] || '').length : 0))); + } else if ((match = str.substr(pos + line.length).match(/^[^\s]+(\s*)/))) { + line = line + match[0].substr(0, match[0].length - (!afterSpace ? (match[1] || '').length : 0)); + } + + result += line; + pos += line.length; + if (pos < len) { + result += '\r\n'; + } + } + + return result; + }, + + /** + * Splits a mime encoded string. Needed for dividing mime words into smaller chunks + * + * @param {String} str Mime encoded string to be split up + * @param {Number} maxlen Maximum length of characters for one part (minimum 12) + * @return {Array} Split string + */ + splitMimeEncodedString: (str, maxlen) => { + let curLine, + match, + chr, + done, + lines = []; + + // require at least 12 symbols to fit possible 4 octet UTF-8 sequences + maxlen = Math.max(maxlen || 0, 12); + + while (str.length) { + curLine = str.substr(0, maxlen); + + // move incomplete escaped char back to main + if ((match = curLine.match(/[=][0-9A-F]?$/i))) { + curLine = curLine.substr(0, match.index); + } + + done = false; + while (!done) { + done = true; + // check if not middle of a unicode char sequence + if ((match = str.substr(curLine.length).match(/^[=]([0-9A-F]{2})/i))) { + chr = parseInt(match[1], 16); + // invalid sequence, move one char back anc recheck + if (chr < 0xc2 && chr > 0x7f) { + curLine = curLine.substr(0, curLine.length - 3); + done = false; + } + } + } + + if (curLine.length) { + lines.push(curLine); + } + str = str.substr(curLine.length); + } + + return lines; + }, + + encodeURICharComponent: chr => { + let res = ''; + let ord = chr + .charCodeAt(0) + .toString(16) + .toUpperCase(); + + if (ord.length % 2) { + ord = '0' + ord; + } + + if (ord.length > 2) { + for (let i = 0, len = ord.length / 2; i < len; i++) { + res += '%' + ord.substr(i, 2); + } + } else { + res += '%' + ord; + } + + return res; + }, + + safeEncodeURIComponent(str) { + str = (str || '').toString(); + + try { + // might throw if we try to encode invalid sequences, eg. partial emoji + str = encodeURIComponent(str); + } catch (E) { + // should never run + return str.replace(/[^\x00-\x1F *'()<>@,;:\\"[\]?=\u007F-\uFFFF]+/g, ''); + } + + // ensure chars that are not handled by encodeURICompent are converted as well + return str.replace(/[\x00-\x1F *'()<>@,;:\\"[\]?=\u007F-\uFFFF]/g, chr => this.encodeURICharComponent(chr)); + } +}; diff --git a/node_modules/nodemailer/lib/mime-funcs/mime-types.js b/node_modules/nodemailer/lib/mime-funcs/mime-types.js new file mode 100644 index 0000000..85f7be6 --- /dev/null +++ b/node_modules/nodemailer/lib/mime-funcs/mime-types.js @@ -0,0 +1,2109 @@ +/* eslint quote-props: 0 */ + +'use strict'; + +const path = require('path'); + +const defaultMimeType = 'application/octet-stream'; +const defaultExtension = 'bin'; + +const mimeTypes = new Map([ + ['application/acad', 'dwg'], + ['application/applixware', 'aw'], + ['application/arj', 'arj'], + ['application/atom+xml', 'xml'], + ['application/atomcat+xml', 'atomcat'], + ['application/atomsvc+xml', 'atomsvc'], + ['application/base64', ['mm', 'mme']], + ['application/binhex', 'hqx'], + ['application/binhex4', 'hqx'], + ['application/book', ['book', 'boo']], + ['application/ccxml+xml,', 'ccxml'], + ['application/cdf', 'cdf'], + ['application/cdmi-capability', 'cdmia'], + ['application/cdmi-container', 'cdmic'], + ['application/cdmi-domain', 'cdmid'], + ['application/cdmi-object', 'cdmio'], + ['application/cdmi-queue', 'cdmiq'], + ['application/clariscad', 'ccad'], + ['application/commonground', 'dp'], + ['application/cu-seeme', 'cu'], + ['application/davmount+xml', 'davmount'], + ['application/drafting', 'drw'], + ['application/dsptype', 'tsp'], + ['application/dssc+der', 'dssc'], + ['application/dssc+xml', 'xdssc'], + ['application/dxf', 'dxf'], + ['application/ecmascript', ['js', 'es']], + ['application/emma+xml', 'emma'], + ['application/envoy', 'evy'], + ['application/epub+zip', 'epub'], + ['application/excel', ['xls', 'xl', 'xla', 'xlb', 'xlc', 'xld', 'xlk', 'xll', 'xlm', 'xlt', 'xlv', 'xlw']], + ['application/exi', 'exi'], + ['application/font-tdpfr', 'pfr'], + ['application/fractals', 'fif'], + ['application/freeloader', 'frl'], + ['application/futuresplash', 'spl'], + ['application/gnutar', 'tgz'], + ['application/groupwise', 'vew'], + ['application/hlp', 'hlp'], + ['application/hta', 'hta'], + ['application/hyperstudio', 'stk'], + ['application/i-deas', 'unv'], + ['application/iges', ['iges', 'igs']], + ['application/inf', 'inf'], + ['application/internet-property-stream', 'acx'], + ['application/ipfix', 'ipfix'], + ['application/java', 'class'], + ['application/java-archive', 'jar'], + ['application/java-byte-code', 'class'], + ['application/java-serialized-object', 'ser'], + ['application/java-vm', 'class'], + ['application/javascript', 'js'], + ['application/json', 'json'], + ['application/lha', 'lha'], + ['application/lzx', 'lzx'], + ['application/mac-binary', 'bin'], + ['application/mac-binhex', 'hqx'], + ['application/mac-binhex40', 'hqx'], + ['application/mac-compactpro', 'cpt'], + ['application/macbinary', 'bin'], + ['application/mads+xml', 'mads'], + ['application/marc', 'mrc'], + ['application/marcxml+xml', 'mrcx'], + ['application/mathematica', 'ma'], + ['application/mathml+xml', 'mathml'], + ['application/mbedlet', 'mbd'], + ['application/mbox', 'mbox'], + ['application/mcad', 'mcd'], + ['application/mediaservercontrol+xml', 'mscml'], + ['application/metalink4+xml', 'meta4'], + ['application/mets+xml', 'mets'], + ['application/mime', 'aps'], + ['application/mods+xml', 'mods'], + ['application/mp21', 'm21'], + ['application/mp4', 'mp4'], + ['application/mspowerpoint', ['ppt', 'pot', 'pps', 'ppz']], + ['application/msword', ['doc', 'dot', 'w6w', 'wiz', 'word']], + ['application/mswrite', 'wri'], + ['application/mxf', 'mxf'], + ['application/netmc', 'mcp'], + ['application/octet-stream', ['*']], + ['application/oda', 'oda'], + ['application/oebps-package+xml', 'opf'], + ['application/ogg', 'ogx'], + ['application/olescript', 'axs'], + ['application/onenote', 'onetoc'], + ['application/patch-ops-error+xml', 'xer'], + ['application/pdf', 'pdf'], + ['application/pgp-encrypted', 'asc'], + ['application/pgp-signature', 'pgp'], + ['application/pics-rules', 'prf'], + ['application/pkcs-12', 'p12'], + ['application/pkcs-crl', 'crl'], + ['application/pkcs10', 'p10'], + ['application/pkcs7-mime', ['p7c', 'p7m']], + ['application/pkcs7-signature', 'p7s'], + ['application/pkcs8', 'p8'], + ['application/pkix-attr-cert', 'ac'], + ['application/pkix-cert', ['cer', 'crt']], + ['application/pkix-crl', 'crl'], + ['application/pkix-pkipath', 'pkipath'], + ['application/pkixcmp', 'pki'], + ['application/plain', 'text'], + ['application/pls+xml', 'pls'], + ['application/postscript', ['ps', 'ai', 'eps']], + ['application/powerpoint', 'ppt'], + ['application/pro_eng', ['part', 'prt']], + ['application/prs.cww', 'cww'], + ['application/pskc+xml', 'pskcxml'], + ['application/rdf+xml', 'rdf'], + ['application/reginfo+xml', 'rif'], + ['application/relax-ng-compact-syntax', 'rnc'], + ['application/resource-lists+xml', 'rl'], + ['application/resource-lists-diff+xml', 'rld'], + ['application/ringing-tones', 'rng'], + ['application/rls-services+xml', 'rs'], + ['application/rsd+xml', 'rsd'], + ['application/rss+xml', 'xml'], + ['application/rtf', ['rtf', 'rtx']], + ['application/sbml+xml', 'sbml'], + ['application/scvp-cv-request', 'scq'], + ['application/scvp-cv-response', 'scs'], + ['application/scvp-vp-request', 'spq'], + ['application/scvp-vp-response', 'spp'], + ['application/sdp', 'sdp'], + ['application/sea', 'sea'], + ['application/set', 'set'], + ['application/set-payment-initiation', 'setpay'], + ['application/set-registration-initiation', 'setreg'], + ['application/shf+xml', 'shf'], + ['application/sla', 'stl'], + ['application/smil', ['smi', 'smil']], + ['application/smil+xml', 'smi'], + ['application/solids', 'sol'], + ['application/sounder', 'sdr'], + ['application/sparql-query', 'rq'], + ['application/sparql-results+xml', 'srx'], + ['application/srgs', 'gram'], + ['application/srgs+xml', 'grxml'], + ['application/sru+xml', 'sru'], + ['application/ssml+xml', 'ssml'], + ['application/step', ['step', 'stp']], + ['application/streamingmedia', 'ssm'], + ['application/tei+xml', 'tei'], + ['application/thraud+xml', 'tfi'], + ['application/timestamped-data', 'tsd'], + ['application/toolbook', 'tbk'], + ['application/vda', 'vda'], + ['application/vnd.3gpp.pic-bw-large', 'plb'], + ['application/vnd.3gpp.pic-bw-small', 'psb'], + ['application/vnd.3gpp.pic-bw-var', 'pvb'], + ['application/vnd.3gpp2.tcap', 'tcap'], + ['application/vnd.3m.post-it-notes', 'pwn'], + ['application/vnd.accpac.simply.aso', 'aso'], + ['application/vnd.accpac.simply.imp', 'imp'], + ['application/vnd.acucobol', 'acu'], + ['application/vnd.acucorp', 'atc'], + ['application/vnd.adobe.air-application-installer-package+zip', 'air'], + ['application/vnd.adobe.fxp', 'fxp'], + ['application/vnd.adobe.xdp+xml', 'xdp'], + ['application/vnd.adobe.xfdf', 'xfdf'], + ['application/vnd.ahead.space', 'ahead'], + ['application/vnd.airzip.filesecure.azf', 'azf'], + ['application/vnd.airzip.filesecure.azs', 'azs'], + ['application/vnd.amazon.ebook', 'azw'], + ['application/vnd.americandynamics.acc', 'acc'], + ['application/vnd.amiga.ami', 'ami'], + ['application/vnd.android.package-archive', 'apk'], + ['application/vnd.anser-web-certificate-issue-initiation', 'cii'], + ['application/vnd.anser-web-funds-transfer-initiation', 'fti'], + ['application/vnd.antix.game-component', 'atx'], + ['application/vnd.apple.installer+xml', 'mpkg'], + ['application/vnd.apple.mpegurl', 'm3u8'], + ['application/vnd.aristanetworks.swi', 'swi'], + ['application/vnd.audiograph', 'aep'], + ['application/vnd.blueice.multipass', 'mpm'], + ['application/vnd.bmi', 'bmi'], + ['application/vnd.businessobjects', 'rep'], + ['application/vnd.chemdraw+xml', 'cdxml'], + ['application/vnd.chipnuts.karaoke-mmd', 'mmd'], + ['application/vnd.cinderella', 'cdy'], + ['application/vnd.claymore', 'cla'], + ['application/vnd.cloanto.rp9', 'rp9'], + ['application/vnd.clonk.c4group', 'c4g'], + ['application/vnd.cluetrust.cartomobile-config', 'c11amc'], + ['application/vnd.cluetrust.cartomobile-config-pkg', 'c11amz'], + ['application/vnd.commonspace', 'csp'], + ['application/vnd.contact.cmsg', 'cdbcmsg'], + ['application/vnd.cosmocaller', 'cmc'], + ['application/vnd.crick.clicker', 'clkx'], + ['application/vnd.crick.clicker.keyboard', 'clkk'], + ['application/vnd.crick.clicker.palette', 'clkp'], + ['application/vnd.crick.clicker.template', 'clkt'], + ['application/vnd.crick.clicker.wordbank', 'clkw'], + ['application/vnd.criticaltools.wbs+xml', 'wbs'], + ['application/vnd.ctc-posml', 'pml'], + ['application/vnd.cups-ppd', 'ppd'], + ['application/vnd.curl.car', 'car'], + ['application/vnd.curl.pcurl', 'pcurl'], + ['application/vnd.data-vision.rdz', 'rdz'], + ['application/vnd.denovo.fcselayout-link', 'fe_launch'], + ['application/vnd.dna', 'dna'], + ['application/vnd.dolby.mlp', 'mlp'], + ['application/vnd.dpgraph', 'dpg'], + ['application/vnd.dreamfactory', 'dfac'], + ['application/vnd.dvb.ait', 'ait'], + ['application/vnd.dvb.service', 'svc'], + ['application/vnd.dynageo', 'geo'], + ['application/vnd.ecowin.chart', 'mag'], + ['application/vnd.enliven', 'nml'], + ['application/vnd.epson.esf', 'esf'], + ['application/vnd.epson.msf', 'msf'], + ['application/vnd.epson.quickanime', 'qam'], + ['application/vnd.epson.salt', 'slt'], + ['application/vnd.epson.ssf', 'ssf'], + ['application/vnd.eszigno3+xml', 'es3'], + ['application/vnd.ezpix-album', 'ez2'], + ['application/vnd.ezpix-package', 'ez3'], + ['application/vnd.fdf', 'fdf'], + ['application/vnd.fdsn.seed', 'seed'], + ['application/vnd.flographit', 'gph'], + ['application/vnd.fluxtime.clip', 'ftc'], + ['application/vnd.framemaker', 'fm'], + ['application/vnd.frogans.fnc', 'fnc'], + ['application/vnd.frogans.ltf', 'ltf'], + ['application/vnd.fsc.weblaunch', 'fsc'], + ['application/vnd.fujitsu.oasys', 'oas'], + ['application/vnd.fujitsu.oasys2', 'oa2'], + ['application/vnd.fujitsu.oasys3', 'oa3'], + ['application/vnd.fujitsu.oasysgp', 'fg5'], + ['application/vnd.fujitsu.oasysprs', 'bh2'], + ['application/vnd.fujixerox.ddd', 'ddd'], + ['application/vnd.fujixerox.docuworks', 'xdw'], + ['application/vnd.fujixerox.docuworks.binder', 'xbd'], + ['application/vnd.fuzzysheet', 'fzs'], + ['application/vnd.genomatix.tuxedo', 'txd'], + ['application/vnd.geogebra.file', 'ggb'], + ['application/vnd.geogebra.tool', 'ggt'], + ['application/vnd.geometry-explorer', 'gex'], + ['application/vnd.geonext', 'gxt'], + ['application/vnd.geoplan', 'g2w'], + ['application/vnd.geospace', 'g3w'], + ['application/vnd.gmx', 'gmx'], + ['application/vnd.google-earth.kml+xml', 'kml'], + ['application/vnd.google-earth.kmz', 'kmz'], + ['application/vnd.grafeq', 'gqf'], + ['application/vnd.groove-account', 'gac'], + ['application/vnd.groove-help', 'ghf'], + ['application/vnd.groove-identity-message', 'gim'], + ['application/vnd.groove-injector', 'grv'], + ['application/vnd.groove-tool-message', 'gtm'], + ['application/vnd.groove-tool-template', 'tpl'], + ['application/vnd.groove-vcard', 'vcg'], + ['application/vnd.hal+xml', 'hal'], + ['application/vnd.handheld-entertainment+xml', 'zmm'], + ['application/vnd.hbci', 'hbci'], + ['application/vnd.hhe.lesson-player', 'les'], + ['application/vnd.hp-hpgl', ['hgl', 'hpg', 'hpgl']], + ['application/vnd.hp-hpid', 'hpid'], + ['application/vnd.hp-hps', 'hps'], + ['application/vnd.hp-jlyt', 'jlt'], + ['application/vnd.hp-pcl', 'pcl'], + ['application/vnd.hp-pclxl', 'pclxl'], + ['application/vnd.hydrostatix.sof-data', 'sfd-hdstx'], + ['application/vnd.hzn-3d-crossword', 'x3d'], + ['application/vnd.ibm.minipay', 'mpy'], + ['application/vnd.ibm.modcap', 'afp'], + ['application/vnd.ibm.rights-management', 'irm'], + ['application/vnd.ibm.secure-container', 'sc'], + ['application/vnd.iccprofile', 'icc'], + ['application/vnd.igloader', 'igl'], + ['application/vnd.immervision-ivp', 'ivp'], + ['application/vnd.immervision-ivu', 'ivu'], + ['application/vnd.insors.igm', 'igm'], + ['application/vnd.intercon.formnet', 'xpw'], + ['application/vnd.intergeo', 'i2g'], + ['application/vnd.intu.qbo', 'qbo'], + ['application/vnd.intu.qfx', 'qfx'], + ['application/vnd.ipunplugged.rcprofile', 'rcprofile'], + ['application/vnd.irepository.package+xml', 'irp'], + ['application/vnd.is-xpr', 'xpr'], + ['application/vnd.isac.fcs', 'fcs'], + ['application/vnd.jam', 'jam'], + ['application/vnd.jcp.javame.midlet-rms', 'rms'], + ['application/vnd.jisp', 'jisp'], + ['application/vnd.joost.joda-archive', 'joda'], + ['application/vnd.kahootz', 'ktz'], + ['application/vnd.kde.karbon', 'karbon'], + ['application/vnd.kde.kchart', 'chrt'], + ['application/vnd.kde.kformula', 'kfo'], + ['application/vnd.kde.kivio', 'flw'], + ['application/vnd.kde.kontour', 'kon'], + ['application/vnd.kde.kpresenter', 'kpr'], + ['application/vnd.kde.kspread', 'ksp'], + ['application/vnd.kde.kword', 'kwd'], + ['application/vnd.kenameaapp', 'htke'], + ['application/vnd.kidspiration', 'kia'], + ['application/vnd.kinar', 'kne'], + ['application/vnd.koan', 'skp'], + ['application/vnd.kodak-descriptor', 'sse'], + ['application/vnd.las.las+xml', 'lasxml'], + ['application/vnd.llamagraphics.life-balance.desktop', 'lbd'], + ['application/vnd.llamagraphics.life-balance.exchange+xml', 'lbe'], + ['application/vnd.lotus-1-2-3', '123'], + ['application/vnd.lotus-approach', 'apr'], + ['application/vnd.lotus-freelance', 'pre'], + ['application/vnd.lotus-notes', 'nsf'], + ['application/vnd.lotus-organizer', 'org'], + ['application/vnd.lotus-screencam', 'scm'], + ['application/vnd.lotus-wordpro', 'lwp'], + ['application/vnd.macports.portpkg', 'portpkg'], + ['application/vnd.mcd', 'mcd'], + ['application/vnd.medcalcdata', 'mc1'], + ['application/vnd.mediastation.cdkey', 'cdkey'], + ['application/vnd.mfer', 'mwf'], + ['application/vnd.mfmp', 'mfm'], + ['application/vnd.micrografx.flo', 'flo'], + ['application/vnd.micrografx.igx', 'igx'], + ['application/vnd.mif', 'mif'], + ['application/vnd.mobius.daf', 'daf'], + ['application/vnd.mobius.dis', 'dis'], + ['application/vnd.mobius.mbk', 'mbk'], + ['application/vnd.mobius.mqy', 'mqy'], + ['application/vnd.mobius.msl', 'msl'], + ['application/vnd.mobius.plc', 'plc'], + ['application/vnd.mobius.txf', 'txf'], + ['application/vnd.mophun.application', 'mpn'], + ['application/vnd.mophun.certificate', 'mpc'], + ['application/vnd.mozilla.xul+xml', 'xul'], + ['application/vnd.ms-artgalry', 'cil'], + ['application/vnd.ms-cab-compressed', 'cab'], + ['application/vnd.ms-excel', ['xls', 'xla', 'xlc', 'xlm', 'xlt', 'xlw', 'xlb', 'xll']], + ['application/vnd.ms-excel.addin.macroenabled.12', 'xlam'], + ['application/vnd.ms-excel.sheet.binary.macroenabled.12', 'xlsb'], + ['application/vnd.ms-excel.sheet.macroenabled.12', 'xlsm'], + ['application/vnd.ms-excel.template.macroenabled.12', 'xltm'], + ['application/vnd.ms-fontobject', 'eot'], + ['application/vnd.ms-htmlhelp', 'chm'], + ['application/vnd.ms-ims', 'ims'], + ['application/vnd.ms-lrm', 'lrm'], + ['application/vnd.ms-officetheme', 'thmx'], + ['application/vnd.ms-outlook', 'msg'], + ['application/vnd.ms-pki.certstore', 'sst'], + ['application/vnd.ms-pki.pko', 'pko'], + ['application/vnd.ms-pki.seccat', 'cat'], + ['application/vnd.ms-pki.stl', 'stl'], + ['application/vnd.ms-pkicertstore', 'sst'], + ['application/vnd.ms-pkiseccat', 'cat'], + ['application/vnd.ms-pkistl', 'stl'], + ['application/vnd.ms-powerpoint', ['ppt', 'pot', 'pps', 'ppa', 'pwz']], + ['application/vnd.ms-powerpoint.addin.macroenabled.12', 'ppam'], + ['application/vnd.ms-powerpoint.presentation.macroenabled.12', 'pptm'], + ['application/vnd.ms-powerpoint.slide.macroenabled.12', 'sldm'], + ['application/vnd.ms-powerpoint.slideshow.macroenabled.12', 'ppsm'], + ['application/vnd.ms-powerpoint.template.macroenabled.12', 'potm'], + ['application/vnd.ms-project', 'mpp'], + ['application/vnd.ms-word.document.macroenabled.12', 'docm'], + ['application/vnd.ms-word.template.macroenabled.12', 'dotm'], + ['application/vnd.ms-works', ['wks', 'wcm', 'wdb', 'wps']], + ['application/vnd.ms-wpl', 'wpl'], + ['application/vnd.ms-xpsdocument', 'xps'], + ['application/vnd.mseq', 'mseq'], + ['application/vnd.musician', 'mus'], + ['application/vnd.muvee.style', 'msty'], + ['application/vnd.neurolanguage.nlu', 'nlu'], + ['application/vnd.noblenet-directory', 'nnd'], + ['application/vnd.noblenet-sealer', 'nns'], + ['application/vnd.noblenet-web', 'nnw'], + ['application/vnd.nokia.configuration-message', 'ncm'], + ['application/vnd.nokia.n-gage.data', 'ngdat'], + ['application/vnd.nokia.n-gage.symbian.install', 'n-gage'], + ['application/vnd.nokia.radio-preset', 'rpst'], + ['application/vnd.nokia.radio-presets', 'rpss'], + ['application/vnd.nokia.ringing-tone', 'rng'], + ['application/vnd.novadigm.edm', 'edm'], + ['application/vnd.novadigm.edx', 'edx'], + ['application/vnd.novadigm.ext', 'ext'], + ['application/vnd.oasis.opendocument.chart', 'odc'], + ['application/vnd.oasis.opendocument.chart-template', 'otc'], + ['application/vnd.oasis.opendocument.database', 'odb'], + ['application/vnd.oasis.opendocument.formula', 'odf'], + ['application/vnd.oasis.opendocument.formula-template', 'odft'], + ['application/vnd.oasis.opendocument.graphics', 'odg'], + ['application/vnd.oasis.opendocument.graphics-template', 'otg'], + ['application/vnd.oasis.opendocument.image', 'odi'], + ['application/vnd.oasis.opendocument.image-template', 'oti'], + ['application/vnd.oasis.opendocument.presentation', 'odp'], + ['application/vnd.oasis.opendocument.presentation-template', 'otp'], + ['application/vnd.oasis.opendocument.spreadsheet', 'ods'], + ['application/vnd.oasis.opendocument.spreadsheet-template', 'ots'], + ['application/vnd.oasis.opendocument.text', 'odt'], + ['application/vnd.oasis.opendocument.text-master', 'odm'], + ['application/vnd.oasis.opendocument.text-template', 'ott'], + ['application/vnd.oasis.opendocument.text-web', 'oth'], + ['application/vnd.olpc-sugar', 'xo'], + ['application/vnd.oma.dd2+xml', 'dd2'], + ['application/vnd.openofficeorg.extension', 'oxt'], + ['application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx'], + ['application/vnd.openxmlformats-officedocument.presentationml.slide', 'sldx'], + ['application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppsx'], + ['application/vnd.openxmlformats-officedocument.presentationml.template', 'potx'], + ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx'], + ['application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xltx'], + ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx'], + ['application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dotx'], + ['application/vnd.osgeo.mapguide.package', 'mgp'], + ['application/vnd.osgi.dp', 'dp'], + ['application/vnd.palm', 'pdb'], + ['application/vnd.pawaafile', 'paw'], + ['application/vnd.pg.format', 'str'], + ['application/vnd.pg.osasli', 'ei6'], + ['application/vnd.picsel', 'efif'], + ['application/vnd.pmi.widget', 'wg'], + ['application/vnd.pocketlearn', 'plf'], + ['application/vnd.powerbuilder6', 'pbd'], + ['application/vnd.previewsystems.box', 'box'], + ['application/vnd.proteus.magazine', 'mgz'], + ['application/vnd.publishare-delta-tree', 'qps'], + ['application/vnd.pvi.ptid1', 'ptid'], + ['application/vnd.quark.quarkxpress', 'qxd'], + ['application/vnd.realvnc.bed', 'bed'], + ['application/vnd.recordare.musicxml', 'mxl'], + ['application/vnd.recordare.musicxml+xml', 'musicxml'], + ['application/vnd.rig.cryptonote', 'cryptonote'], + ['application/vnd.rim.cod', 'cod'], + ['application/vnd.rn-realmedia', 'rm'], + ['application/vnd.rn-realplayer', 'rnx'], + ['application/vnd.route66.link66+xml', 'link66'], + ['application/vnd.sailingtracker.track', 'st'], + ['application/vnd.seemail', 'see'], + ['application/vnd.sema', 'sema'], + ['application/vnd.semd', 'semd'], + ['application/vnd.semf', 'semf'], + ['application/vnd.shana.informed.formdata', 'ifm'], + ['application/vnd.shana.informed.formtemplate', 'itp'], + ['application/vnd.shana.informed.interchange', 'iif'], + ['application/vnd.shana.informed.package', 'ipk'], + ['application/vnd.simtech-mindmapper', 'twd'], + ['application/vnd.smaf', 'mmf'], + ['application/vnd.smart.teacher', 'teacher'], + ['application/vnd.solent.sdkm+xml', 'sdkm'], + ['application/vnd.spotfire.dxp', 'dxp'], + ['application/vnd.spotfire.sfs', 'sfs'], + ['application/vnd.stardivision.calc', 'sdc'], + ['application/vnd.stardivision.draw', 'sda'], + ['application/vnd.stardivision.impress', 'sdd'], + ['application/vnd.stardivision.math', 'smf'], + ['application/vnd.stardivision.writer', 'sdw'], + ['application/vnd.stardivision.writer-global', 'sgl'], + ['application/vnd.stepmania.stepchart', 'sm'], + ['application/vnd.sun.xml.calc', 'sxc'], + ['application/vnd.sun.xml.calc.template', 'stc'], + ['application/vnd.sun.xml.draw', 'sxd'], + ['application/vnd.sun.xml.draw.template', 'std'], + ['application/vnd.sun.xml.impress', 'sxi'], + ['application/vnd.sun.xml.impress.template', 'sti'], + ['application/vnd.sun.xml.math', 'sxm'], + ['application/vnd.sun.xml.writer', 'sxw'], + ['application/vnd.sun.xml.writer.global', 'sxg'], + ['application/vnd.sun.xml.writer.template', 'stw'], + ['application/vnd.sus-calendar', 'sus'], + ['application/vnd.svd', 'svd'], + ['application/vnd.symbian.install', 'sis'], + ['application/vnd.syncml+xml', 'xsm'], + ['application/vnd.syncml.dm+wbxml', 'bdm'], + ['application/vnd.syncml.dm+xml', 'xdm'], + ['application/vnd.tao.intent-module-archive', 'tao'], + ['application/vnd.tmobile-livetv', 'tmo'], + ['application/vnd.trid.tpt', 'tpt'], + ['application/vnd.triscape.mxs', 'mxs'], + ['application/vnd.trueapp', 'tra'], + ['application/vnd.ufdl', 'ufd'], + ['application/vnd.uiq.theme', 'utz'], + ['application/vnd.umajin', 'umj'], + ['application/vnd.unity', 'unityweb'], + ['application/vnd.uoml+xml', 'uoml'], + ['application/vnd.vcx', 'vcx'], + ['application/vnd.visio', 'vsd'], + ['application/vnd.visionary', 'vis'], + ['application/vnd.vsf', 'vsf'], + ['application/vnd.wap.wbxml', 'wbxml'], + ['application/vnd.wap.wmlc', 'wmlc'], + ['application/vnd.wap.wmlscriptc', 'wmlsc'], + ['application/vnd.webturbo', 'wtb'], + ['application/vnd.wolfram.player', 'nbp'], + ['application/vnd.wordperfect', 'wpd'], + ['application/vnd.wqd', 'wqd'], + ['application/vnd.wt.stf', 'stf'], + ['application/vnd.xara', ['web', 'xar']], + ['application/vnd.xfdl', 'xfdl'], + ['application/vnd.yamaha.hv-dic', 'hvd'], + ['application/vnd.yamaha.hv-script', 'hvs'], + ['application/vnd.yamaha.hv-voice', 'hvp'], + ['application/vnd.yamaha.openscoreformat', 'osf'], + ['application/vnd.yamaha.openscoreformat.osfpvg+xml', 'osfpvg'], + ['application/vnd.yamaha.smaf-audio', 'saf'], + ['application/vnd.yamaha.smaf-phrase', 'spf'], + ['application/vnd.yellowriver-custom-menu', 'cmp'], + ['application/vnd.zul', 'zir'], + ['application/vnd.zzazz.deck+xml', 'zaz'], + ['application/vocaltec-media-desc', 'vmd'], + ['application/vocaltec-media-file', 'vmf'], + ['application/voicexml+xml', 'vxml'], + ['application/widget', 'wgt'], + ['application/winhlp', 'hlp'], + ['application/wordperfect', ['wp', 'wp5', 'wp6', 'wpd']], + ['application/wordperfect6.0', ['w60', 'wp5']], + ['application/wordperfect6.1', 'w61'], + ['application/wsdl+xml', 'wsdl'], + ['application/wspolicy+xml', 'wspolicy'], + ['application/x-123', 'wk1'], + ['application/x-7z-compressed', '7z'], + ['application/x-abiword', 'abw'], + ['application/x-ace-compressed', 'ace'], + ['application/x-aim', 'aim'], + ['application/x-authorware-bin', 'aab'], + ['application/x-authorware-map', 'aam'], + ['application/x-authorware-seg', 'aas'], + ['application/x-bcpio', 'bcpio'], + ['application/x-binary', 'bin'], + ['application/x-binhex40', 'hqx'], + ['application/x-bittorrent', 'torrent'], + ['application/x-bsh', ['bsh', 'sh', 'shar']], + ['application/x-bytecode.elisp', 'elc'], + ['applicaiton/x-bytecode.python', 'pyc'], + ['application/x-bzip', 'bz'], + ['application/x-bzip2', ['boz', 'bz2']], + ['application/x-cdf', 'cdf'], + ['application/x-cdlink', 'vcd'], + ['application/x-chat', ['cha', 'chat']], + ['application/x-chess-pgn', 'pgn'], + ['application/x-cmu-raster', 'ras'], + ['application/x-cocoa', 'cco'], + ['application/x-compactpro', 'cpt'], + ['application/x-compress', 'z'], + ['application/x-compressed', ['tgz', 'gz', 'z', 'zip']], + ['application/x-conference', 'nsc'], + ['application/x-cpio', 'cpio'], + ['application/x-cpt', 'cpt'], + ['application/x-csh', 'csh'], + ['application/x-debian-package', 'deb'], + ['application/x-deepv', 'deepv'], + ['application/x-director', ['dir', 'dcr', 'dxr']], + ['application/x-doom', 'wad'], + ['application/x-dtbncx+xml', 'ncx'], + ['application/x-dtbook+xml', 'dtb'], + ['application/x-dtbresource+xml', 'res'], + ['application/x-dvi', 'dvi'], + ['application/x-elc', 'elc'], + ['application/x-envoy', ['env', 'evy']], + ['application/x-esrehber', 'es'], + ['application/x-excel', ['xls', 'xla', 'xlb', 'xlc', 'xld', 'xlk', 'xll', 'xlm', 'xlt', 'xlv', 'xlw']], + ['application/x-font-bdf', 'bdf'], + ['application/x-font-ghostscript', 'gsf'], + ['application/x-font-linux-psf', 'psf'], + ['application/x-font-otf', 'otf'], + ['application/x-font-pcf', 'pcf'], + ['application/x-font-snf', 'snf'], + ['application/x-font-ttf', 'ttf'], + ['application/x-font-type1', 'pfa'], + ['application/x-font-woff', 'woff'], + ['application/x-frame', 'mif'], + ['application/x-freelance', 'pre'], + ['application/x-futuresplash', 'spl'], + ['application/x-gnumeric', 'gnumeric'], + ['application/x-gsp', 'gsp'], + ['application/x-gss', 'gss'], + ['application/x-gtar', 'gtar'], + ['application/x-gzip', ['gz', 'gzip']], + ['application/x-hdf', 'hdf'], + ['application/x-helpfile', ['help', 'hlp']], + ['application/x-httpd-imap', 'imap'], + ['application/x-ima', 'ima'], + ['application/x-internet-signup', ['ins', 'isp']], + ['application/x-internett-signup', 'ins'], + ['application/x-inventor', 'iv'], + ['application/x-ip2', 'ip'], + ['application/x-iphone', 'iii'], + ['application/x-java-class', 'class'], + ['application/x-java-commerce', 'jcm'], + ['application/x-java-jnlp-file', 'jnlp'], + ['application/x-javascript', 'js'], + ['application/x-koan', ['skd', 'skm', 'skp', 'skt']], + ['application/x-ksh', 'ksh'], + ['application/x-latex', ['latex', 'ltx']], + ['application/x-lha', 'lha'], + ['application/x-lisp', 'lsp'], + ['application/x-livescreen', 'ivy'], + ['application/x-lotus', 'wq1'], + ['application/x-lotusscreencam', 'scm'], + ['application/x-lzh', 'lzh'], + ['application/x-lzx', 'lzx'], + ['application/x-mac-binhex40', 'hqx'], + ['application/x-macbinary', 'bin'], + ['application/x-magic-cap-package-1.0', 'mc$'], + ['application/x-mathcad', 'mcd'], + ['application/x-meme', 'mm'], + ['application/x-midi', ['mid', 'midi']], + ['application/x-mif', 'mif'], + ['application/x-mix-transfer', 'nix'], + ['application/x-mobipocket-ebook', 'prc'], + ['application/x-mplayer2', 'asx'], + ['application/x-ms-application', 'application'], + ['application/x-ms-wmd', 'wmd'], + ['application/x-ms-wmz', 'wmz'], + ['application/x-ms-xbap', 'xbap'], + ['application/x-msaccess', 'mdb'], + ['application/x-msbinder', 'obd'], + ['application/x-mscardfile', 'crd'], + ['application/x-msclip', 'clp'], + ['application/x-msdownload', ['exe', 'dll']], + ['application/x-msexcel', ['xls', 'xla', 'xlw']], + ['application/x-msmediaview', ['mvb', 'm13', 'm14']], + ['application/x-msmetafile', 'wmf'], + ['application/x-msmoney', 'mny'], + ['application/x-mspowerpoint', 'ppt'], + ['application/x-mspublisher', 'pub'], + ['application/x-msschedule', 'scd'], + ['application/x-msterminal', 'trm'], + ['application/x-mswrite', 'wri'], + ['application/x-navi-animation', 'ani'], + ['application/x-navidoc', 'nvd'], + ['application/x-navimap', 'map'], + ['application/x-navistyle', 'stl'], + ['application/x-netcdf', ['cdf', 'nc']], + ['application/x-newton-compatible-pkg', 'pkg'], + ['application/x-nokia-9000-communicator-add-on-software', 'aos'], + ['application/x-omc', 'omc'], + ['application/x-omcdatamaker', 'omcd'], + ['application/x-omcregerator', 'omcr'], + ['application/x-pagemaker', ['pm4', 'pm5']], + ['application/x-pcl', 'pcl'], + ['application/x-perfmon', ['pma', 'pmc', 'pml', 'pmr', 'pmw']], + ['application/x-pixclscript', 'plx'], + ['application/x-pkcs10', 'p10'], + ['application/x-pkcs12', ['p12', 'pfx']], + ['application/x-pkcs7-certificates', ['p7b', 'spc']], + ['application/x-pkcs7-certreqresp', 'p7r'], + ['application/x-pkcs7-mime', ['p7m', 'p7c']], + ['application/x-pkcs7-signature', ['p7s', 'p7a']], + ['application/x-pointplus', 'css'], + ['application/x-portable-anymap', 'pnm'], + ['application/x-project', ['mpc', 'mpt', 'mpv', 'mpx']], + ['application/x-qpro', 'wb1'], + ['application/x-rar-compressed', 'rar'], + ['application/x-rtf', 'rtf'], + ['application/x-sdp', 'sdp'], + ['application/x-sea', 'sea'], + ['application/x-seelogo', 'sl'], + ['application/x-sh', 'sh'], + ['application/x-shar', ['shar', 'sh']], + ['application/x-shockwave-flash', 'swf'], + ['application/x-silverlight-app', 'xap'], + ['application/x-sit', 'sit'], + ['application/x-sprite', ['spr', 'sprite']], + ['application/x-stuffit', 'sit'], + ['application/x-stuffitx', 'sitx'], + ['application/x-sv4cpio', 'sv4cpio'], + ['application/x-sv4crc', 'sv4crc'], + ['application/x-tar', 'tar'], + ['application/x-tbook', ['sbk', 'tbk']], + ['application/x-tcl', 'tcl'], + ['application/x-tex', 'tex'], + ['application/x-tex-tfm', 'tfm'], + ['application/x-texinfo', ['texi', 'texinfo']], + ['application/x-troff', ['roff', 't', 'tr']], + ['application/x-troff-man', 'man'], + ['application/x-troff-me', 'me'], + ['application/x-troff-ms', 'ms'], + ['application/x-troff-msvideo', 'avi'], + ['application/x-ustar', 'ustar'], + ['application/x-visio', ['vsd', 'vst', 'vsw']], + ['application/x-vnd.audioexplosion.mzz', 'mzz'], + ['application/x-vnd.ls-xpix', 'xpix'], + ['application/x-vrml', 'vrml'], + ['application/x-wais-source', ['src', 'wsrc']], + ['application/x-winhelp', 'hlp'], + ['application/x-wintalk', 'wtk'], + ['application/x-world', ['wrl', 'svr']], + ['application/x-wpwin', 'wpd'], + ['application/x-wri', 'wri'], + ['application/x-x509-ca-cert', ['cer', 'crt', 'der']], + ['application/x-x509-user-cert', 'crt'], + ['application/x-xfig', 'fig'], + ['application/x-xpinstall', 'xpi'], + ['application/x-zip-compressed', 'zip'], + ['application/xcap-diff+xml', 'xdf'], + ['application/xenc+xml', 'xenc'], + ['application/xhtml+xml', 'xhtml'], + ['application/xml', 'xml'], + ['application/xml-dtd', 'dtd'], + ['application/xop+xml', 'xop'], + ['application/xslt+xml', 'xslt'], + ['application/xspf+xml', 'xspf'], + ['application/xv+xml', 'mxml'], + ['application/yang', 'yang'], + ['application/yin+xml', 'yin'], + ['application/ynd.ms-pkipko', 'pko'], + ['application/zip', 'zip'], + ['audio/adpcm', 'adp'], + ['audio/aiff', ['aiff', 'aif', 'aifc']], + ['audio/basic', ['snd', 'au']], + ['audio/it', 'it'], + ['audio/make', ['funk', 'my', 'pfunk']], + ['audio/make.my.funk', 'pfunk'], + ['audio/mid', ['mid', 'rmi']], + ['audio/midi', ['midi', 'kar', 'mid']], + ['audio/mod', 'mod'], + ['audio/mp4', 'mp4a'], + ['audio/mpeg', ['mpga', 'mp3', 'm2a', 'mp2', 'mpa', 'mpg']], + ['audio/mpeg3', 'mp3'], + ['audio/nspaudio', ['la', 'lma']], + ['audio/ogg', 'oga'], + ['audio/s3m', 's3m'], + ['audio/tsp-audio', 'tsi'], + ['audio/tsplayer', 'tsp'], + ['audio/vnd.dece.audio', 'uva'], + ['audio/vnd.digital-winds', 'eol'], + ['audio/vnd.dra', 'dra'], + ['audio/vnd.dts', 'dts'], + ['audio/vnd.dts.hd', 'dtshd'], + ['audio/vnd.lucent.voice', 'lvp'], + ['audio/vnd.ms-playready.media.pya', 'pya'], + ['audio/vnd.nuera.ecelp4800', 'ecelp4800'], + ['audio/vnd.nuera.ecelp7470', 'ecelp7470'], + ['audio/vnd.nuera.ecelp9600', 'ecelp9600'], + ['audio/vnd.qcelp', 'qcp'], + ['audio/vnd.rip', 'rip'], + ['audio/voc', 'voc'], + ['audio/voxware', 'vox'], + ['audio/wav', 'wav'], + ['audio/webm', 'weba'], + ['audio/x-aac', 'aac'], + ['audio/x-adpcm', 'snd'], + ['audio/x-aiff', ['aiff', 'aif', 'aifc']], + ['audio/x-au', 'au'], + ['audio/x-gsm', ['gsd', 'gsm']], + ['audio/x-jam', 'jam'], + ['audio/x-liveaudio', 'lam'], + ['audio/x-mid', ['mid', 'midi']], + ['audio/x-midi', ['midi', 'mid']], + ['audio/x-mod', 'mod'], + ['audio/x-mpeg', 'mp2'], + ['audio/x-mpeg-3', 'mp3'], + ['audio/x-mpegurl', 'm3u'], + ['audio/x-mpequrl', 'm3u'], + ['audio/x-ms-wax', 'wax'], + ['audio/x-ms-wma', 'wma'], + ['audio/x-nspaudio', ['la', 'lma']], + ['audio/x-pn-realaudio', ['ra', 'ram', 'rm', 'rmm', 'rmp']], + ['audio/x-pn-realaudio-plugin', ['ra', 'rmp', 'rpm']], + ['audio/x-psid', 'sid'], + ['audio/x-realaudio', 'ra'], + ['audio/x-twinvq', 'vqf'], + ['audio/x-twinvq-plugin', ['vqe', 'vql']], + ['audio/x-vnd.audioexplosion.mjuicemediafile', 'mjf'], + ['audio/x-voc', 'voc'], + ['audio/x-wav', 'wav'], + ['audio/xm', 'xm'], + ['chemical/x-cdx', 'cdx'], + ['chemical/x-cif', 'cif'], + ['chemical/x-cmdf', 'cmdf'], + ['chemical/x-cml', 'cml'], + ['chemical/x-csml', 'csml'], + ['chemical/x-pdb', ['pdb', 'xyz']], + ['chemical/x-xyz', 'xyz'], + ['drawing/x-dwf', 'dwf'], + ['i-world/i-vrml', 'ivr'], + ['image/bmp', ['bmp', 'bm']], + ['image/cgm', 'cgm'], + ['image/cis-cod', 'cod'], + ['image/cmu-raster', ['ras', 'rast']], + ['image/fif', 'fif'], + ['image/florian', ['flo', 'turbot']], + ['image/g3fax', 'g3'], + ['image/gif', 'gif'], + ['image/ief', ['ief', 'iefs']], + ['image/jpeg', ['jpeg', 'jpe', 'jpg', 'jfif', 'jfif-tbnl']], + ['image/jutvision', 'jut'], + ['image/ktx', 'ktx'], + ['image/naplps', ['nap', 'naplps']], + ['image/pict', ['pic', 'pict']], + ['image/pipeg', 'jfif'], + ['image/pjpeg', ['jfif', 'jpe', 'jpeg', 'jpg']], + ['image/png', ['png', 'x-png']], + ['image/prs.btif', 'btif'], + ['image/svg+xml', 'svg'], + ['image/tiff', ['tif', 'tiff']], + ['image/vasa', 'mcf'], + ['image/vnd.adobe.photoshop', 'psd'], + ['image/vnd.dece.graphic', 'uvi'], + ['image/vnd.djvu', 'djvu'], + ['image/vnd.dvb.subtitle', 'sub'], + ['image/vnd.dwg', ['dwg', 'dxf', 'svf']], + ['image/vnd.dxf', 'dxf'], + ['image/vnd.fastbidsheet', 'fbs'], + ['image/vnd.fpx', 'fpx'], + ['image/vnd.fst', 'fst'], + ['image/vnd.fujixerox.edmics-mmr', 'mmr'], + ['image/vnd.fujixerox.edmics-rlc', 'rlc'], + ['image/vnd.ms-modi', 'mdi'], + ['image/vnd.net-fpx', ['fpx', 'npx']], + ['image/vnd.rn-realflash', 'rf'], + ['image/vnd.rn-realpix', 'rp'], + ['image/vnd.wap.wbmp', 'wbmp'], + ['image/vnd.xiff', 'xif'], + ['image/webp', 'webp'], + ['image/x-cmu-raster', 'ras'], + ['image/x-cmx', 'cmx'], + ['image/x-dwg', ['dwg', 'dxf', 'svf']], + ['image/x-freehand', 'fh'], + ['image/x-icon', 'ico'], + ['image/x-jg', 'art'], + ['image/x-jps', 'jps'], + ['image/x-niff', ['niff', 'nif']], + ['image/x-pcx', 'pcx'], + ['image/x-pict', ['pct', 'pic']], + ['image/x-portable-anymap', 'pnm'], + ['image/x-portable-bitmap', 'pbm'], + ['image/x-portable-graymap', 'pgm'], + ['image/x-portable-greymap', 'pgm'], + ['image/x-portable-pixmap', 'ppm'], + ['image/x-quicktime', ['qif', 'qti', 'qtif']], + ['image/x-rgb', 'rgb'], + ['image/x-tiff', ['tif', 'tiff']], + ['image/x-windows-bmp', 'bmp'], + ['image/x-xbitmap', 'xbm'], + ['image/x-xbm', 'xbm'], + ['image/x-xpixmap', ['xpm', 'pm']], + ['image/x-xwd', 'xwd'], + ['image/x-xwindowdump', 'xwd'], + ['image/xbm', 'xbm'], + ['image/xpm', 'xpm'], + ['message/rfc822', ['eml', 'mht', 'mhtml', 'nws', 'mime']], + ['model/iges', ['iges', 'igs']], + ['model/mesh', 'msh'], + ['model/vnd.collada+xml', 'dae'], + ['model/vnd.dwf', 'dwf'], + ['model/vnd.gdl', 'gdl'], + ['model/vnd.gtw', 'gtw'], + ['model/vnd.mts', 'mts'], + ['model/vnd.vtu', 'vtu'], + ['model/vrml', ['vrml', 'wrl', 'wrz']], + ['model/x-pov', 'pov'], + ['multipart/x-gzip', 'gzip'], + ['multipart/x-ustar', 'ustar'], + ['multipart/x-zip', 'zip'], + ['music/crescendo', ['mid', 'midi']], + ['music/x-karaoke', 'kar'], + ['paleovu/x-pv', 'pvu'], + ['text/asp', 'asp'], + ['text/calendar', 'ics'], + ['text/css', 'css'], + ['text/csv', 'csv'], + ['text/ecmascript', 'js'], + ['text/h323', '323'], + ['text/html', ['html', 'htm', 'stm', 'acgi', 'htmls', 'htx', 'shtml']], + ['text/iuls', 'uls'], + ['text/javascript', 'js'], + ['text/mcf', 'mcf'], + ['text/n3', 'n3'], + ['text/pascal', 'pas'], + [ + 'text/plain', + [ + 'txt', + 'bas', + 'c', + 'h', + 'c++', + 'cc', + 'com', + 'conf', + 'cxx', + 'def', + 'f', + 'f90', + 'for', + 'g', + 'hh', + 'idc', + 'jav', + 'java', + 'list', + 'log', + 'lst', + 'm', + 'mar', + 'pl', + 'sdml', + 'text' + ] + ], + ['text/plain-bas', 'par'], + ['text/prs.lines.tag', 'dsc'], + ['text/richtext', ['rtx', 'rt', 'rtf']], + ['text/scriplet', 'wsc'], + ['text/scriptlet', 'sct'], + ['text/sgml', ['sgm', 'sgml']], + ['text/tab-separated-values', 'tsv'], + ['text/troff', 't'], + ['text/turtle', 'ttl'], + ['text/uri-list', ['uni', 'unis', 'uri', 'uris']], + ['text/vnd.abc', 'abc'], + ['text/vnd.curl', 'curl'], + ['text/vnd.curl.dcurl', 'dcurl'], + ['text/vnd.curl.mcurl', 'mcurl'], + ['text/vnd.curl.scurl', 'scurl'], + ['text/vnd.fly', 'fly'], + ['text/vnd.fmi.flexstor', 'flx'], + ['text/vnd.graphviz', 'gv'], + ['text/vnd.in3d.3dml', '3dml'], + ['text/vnd.in3d.spot', 'spot'], + ['text/vnd.rn-realtext', 'rt'], + ['text/vnd.sun.j2me.app-descriptor', 'jad'], + ['text/vnd.wap.wml', 'wml'], + ['text/vnd.wap.wmlscript', 'wmls'], + ['text/webviewhtml', 'htt'], + ['text/x-asm', ['asm', 's']], + ['text/x-audiosoft-intra', 'aip'], + ['text/x-c', ['c', 'cc', 'cpp']], + ['text/x-component', 'htc'], + ['text/x-fortran', ['for', 'f', 'f77', 'f90']], + ['text/x-h', ['h', 'hh']], + ['text/x-java-source', ['java', 'jav']], + ['text/x-java-source,java', 'java'], + ['text/x-la-asf', 'lsx'], + ['text/x-m', 'm'], + ['text/x-pascal', 'p'], + ['text/x-script', 'hlb'], + ['text/x-script.csh', 'csh'], + ['text/x-script.elisp', 'el'], + ['text/x-script.guile', 'scm'], + ['text/x-script.ksh', 'ksh'], + ['text/x-script.lisp', 'lsp'], + ['text/x-script.perl', 'pl'], + ['text/x-script.perl-module', 'pm'], + ['text/x-script.phyton', 'py'], + ['text/x-script.rexx', 'rexx'], + ['text/x-script.scheme', 'scm'], + ['text/x-script.sh', 'sh'], + ['text/x-script.tcl', 'tcl'], + ['text/x-script.tcsh', 'tcsh'], + ['text/x-script.zsh', 'zsh'], + ['text/x-server-parsed-html', ['shtml', 'ssi']], + ['text/x-setext', 'etx'], + ['text/x-sgml', ['sgm', 'sgml']], + ['text/x-speech', ['spc', 'talk']], + ['text/x-uil', 'uil'], + ['text/x-uuencode', ['uu', 'uue']], + ['text/x-vcalendar', 'vcs'], + ['text/x-vcard', 'vcf'], + ['text/xml', 'xml'], + ['video/3gpp', '3gp'], + ['video/3gpp2', '3g2'], + ['video/animaflex', 'afl'], + ['video/avi', 'avi'], + ['video/avs-video', 'avs'], + ['video/dl', 'dl'], + ['video/fli', 'fli'], + ['video/gl', 'gl'], + ['video/h261', 'h261'], + ['video/h263', 'h263'], + ['video/h264', 'h264'], + ['video/jpeg', 'jpgv'], + ['video/jpm', 'jpm'], + ['video/mj2', 'mj2'], + ['video/mp4', 'mp4'], + ['video/mpeg', ['mpeg', 'mp2', 'mpa', 'mpe', 'mpg', 'mpv2', 'm1v', 'm2v', 'mp3']], + ['video/msvideo', 'avi'], + ['video/ogg', 'ogv'], + ['video/quicktime', ['mov', 'qt', 'moov']], + ['video/vdo', 'vdo'], + ['video/vivo', ['viv', 'vivo']], + ['video/vnd.dece.hd', 'uvh'], + ['video/vnd.dece.mobile', 'uvm'], + ['video/vnd.dece.pd', 'uvp'], + ['video/vnd.dece.sd', 'uvs'], + ['video/vnd.dece.video', 'uvv'], + ['video/vnd.fvt', 'fvt'], + ['video/vnd.mpegurl', 'mxu'], + ['video/vnd.ms-playready.media.pyv', 'pyv'], + ['video/vnd.rn-realvideo', 'rv'], + ['video/vnd.uvvu.mp4', 'uvu'], + ['video/vnd.vivo', ['viv', 'vivo']], + ['video/vosaic', 'vos'], + ['video/webm', 'webm'], + ['video/x-amt-demorun', 'xdr'], + ['video/x-amt-showrun', 'xsr'], + ['video/x-atomic3d-feature', 'fmf'], + ['video/x-dl', 'dl'], + ['video/x-dv', ['dif', 'dv']], + ['video/x-f4v', 'f4v'], + ['video/x-fli', 'fli'], + ['video/x-flv', 'flv'], + ['video/x-gl', 'gl'], + ['video/x-isvideo', 'isu'], + ['video/x-la-asf', ['lsf', 'lsx']], + ['video/x-m4v', 'm4v'], + ['video/x-motion-jpeg', 'mjpg'], + ['video/x-mpeg', ['mp3', 'mp2']], + ['video/x-mpeq2a', 'mp2'], + ['video/x-ms-asf', ['asf', 'asr', 'asx']], + ['video/x-ms-asf-plugin', 'asx'], + ['video/x-ms-wm', 'wm'], + ['video/x-ms-wmv', 'wmv'], + ['video/x-ms-wmx', 'wmx'], + ['video/x-ms-wvx', 'wvx'], + ['video/x-msvideo', 'avi'], + ['video/x-qtc', 'qtc'], + ['video/x-scm', 'scm'], + ['video/x-sgi-movie', ['movie', 'mv']], + ['windows/metafile', 'wmf'], + ['www/mime', 'mime'], + ['x-conference/x-cooltalk', 'ice'], + ['x-music/x-midi', ['mid', 'midi']], + ['x-world/x-3dmf', ['3dm', '3dmf', 'qd3', 'qd3d']], + ['x-world/x-svr', 'svr'], + ['x-world/x-vrml', ['flr', 'vrml', 'wrl', 'wrz', 'xaf', 'xof']], + ['x-world/x-vrt', 'vrt'], + ['xgl/drawing', 'xgz'], + ['xgl/movie', 'xmz'] +]); +const extensions = new Map([ + ['123', 'application/vnd.lotus-1-2-3'], + ['323', 'text/h323'], + ['*', 'application/octet-stream'], + ['3dm', 'x-world/x-3dmf'], + ['3dmf', 'x-world/x-3dmf'], + ['3dml', 'text/vnd.in3d.3dml'], + ['3g2', 'video/3gpp2'], + ['3gp', 'video/3gpp'], + ['7z', 'application/x-7z-compressed'], + ['a', 'application/octet-stream'], + ['aab', 'application/x-authorware-bin'], + ['aac', 'audio/x-aac'], + ['aam', 'application/x-authorware-map'], + ['aas', 'application/x-authorware-seg'], + ['abc', 'text/vnd.abc'], + ['abw', 'application/x-abiword'], + ['ac', 'application/pkix-attr-cert'], + ['acc', 'application/vnd.americandynamics.acc'], + ['ace', 'application/x-ace-compressed'], + ['acgi', 'text/html'], + ['acu', 'application/vnd.acucobol'], + ['acx', 'application/internet-property-stream'], + ['adp', 'audio/adpcm'], + ['aep', 'application/vnd.audiograph'], + ['afl', 'video/animaflex'], + ['afp', 'application/vnd.ibm.modcap'], + ['ahead', 'application/vnd.ahead.space'], + ['ai', 'application/postscript'], + ['aif', ['audio/aiff', 'audio/x-aiff']], + ['aifc', ['audio/aiff', 'audio/x-aiff']], + ['aiff', ['audio/aiff', 'audio/x-aiff']], + ['aim', 'application/x-aim'], + ['aip', 'text/x-audiosoft-intra'], + ['air', 'application/vnd.adobe.air-application-installer-package+zip'], + ['ait', 'application/vnd.dvb.ait'], + ['ami', 'application/vnd.amiga.ami'], + ['ani', 'application/x-navi-animation'], + ['aos', 'application/x-nokia-9000-communicator-add-on-software'], + ['apk', 'application/vnd.android.package-archive'], + ['application', 'application/x-ms-application'], + ['apr', 'application/vnd.lotus-approach'], + ['aps', 'application/mime'], + ['arc', 'application/octet-stream'], + ['arj', ['application/arj', 'application/octet-stream']], + ['art', 'image/x-jg'], + ['asf', 'video/x-ms-asf'], + ['asm', 'text/x-asm'], + ['aso', 'application/vnd.accpac.simply.aso'], + ['asp', 'text/asp'], + ['asr', 'video/x-ms-asf'], + ['asx', ['video/x-ms-asf', 'application/x-mplayer2', 'video/x-ms-asf-plugin']], + ['atc', 'application/vnd.acucorp'], + ['atomcat', 'application/atomcat+xml'], + ['atomsvc', 'application/atomsvc+xml'], + ['atx', 'application/vnd.antix.game-component'], + ['au', ['audio/basic', 'audio/x-au']], + ['avi', ['video/avi', 'video/msvideo', 'application/x-troff-msvideo', 'video/x-msvideo']], + ['avs', 'video/avs-video'], + ['aw', 'application/applixware'], + ['axs', 'application/olescript'], + ['azf', 'application/vnd.airzip.filesecure.azf'], + ['azs', 'application/vnd.airzip.filesecure.azs'], + ['azw', 'application/vnd.amazon.ebook'], + ['bas', 'text/plain'], + ['bcpio', 'application/x-bcpio'], + ['bdf', 'application/x-font-bdf'], + ['bdm', 'application/vnd.syncml.dm+wbxml'], + ['bed', 'application/vnd.realvnc.bed'], + ['bh2', 'application/vnd.fujitsu.oasysprs'], + ['bin', ['application/octet-stream', 'application/mac-binary', 'application/macbinary', 'application/x-macbinary', 'application/x-binary']], + ['bm', 'image/bmp'], + ['bmi', 'application/vnd.bmi'], + ['bmp', ['image/bmp', 'image/x-windows-bmp']], + ['boo', 'application/book'], + ['book', 'application/book'], + ['box', 'application/vnd.previewsystems.box'], + ['boz', 'application/x-bzip2'], + ['bsh', 'application/x-bsh'], + ['btif', 'image/prs.btif'], + ['bz', 'application/x-bzip'], + ['bz2', 'application/x-bzip2'], + ['c', ['text/plain', 'text/x-c']], + ['c++', 'text/plain'], + ['c11amc', 'application/vnd.cluetrust.cartomobile-config'], + ['c11amz', 'application/vnd.cluetrust.cartomobile-config-pkg'], + ['c4g', 'application/vnd.clonk.c4group'], + ['cab', 'application/vnd.ms-cab-compressed'], + ['car', 'application/vnd.curl.car'], + ['cat', ['application/vnd.ms-pkiseccat', 'application/vnd.ms-pki.seccat']], + ['cc', ['text/plain', 'text/x-c']], + ['ccad', 'application/clariscad'], + ['cco', 'application/x-cocoa'], + ['ccxml', 'application/ccxml+xml,'], + ['cdbcmsg', 'application/vnd.contact.cmsg'], + ['cdf', ['application/cdf', 'application/x-cdf', 'application/x-netcdf']], + ['cdkey', 'application/vnd.mediastation.cdkey'], + ['cdmia', 'application/cdmi-capability'], + ['cdmic', 'application/cdmi-container'], + ['cdmid', 'application/cdmi-domain'], + ['cdmio', 'application/cdmi-object'], + ['cdmiq', 'application/cdmi-queue'], + ['cdx', 'chemical/x-cdx'], + ['cdxml', 'application/vnd.chemdraw+xml'], + ['cdy', 'application/vnd.cinderella'], + ['cer', ['application/pkix-cert', 'application/x-x509-ca-cert']], + ['cgm', 'image/cgm'], + ['cha', 'application/x-chat'], + ['chat', 'application/x-chat'], + ['chm', 'application/vnd.ms-htmlhelp'], + ['chrt', 'application/vnd.kde.kchart'], + ['cif', 'chemical/x-cif'], + ['cii', 'application/vnd.anser-web-certificate-issue-initiation'], + ['cil', 'application/vnd.ms-artgalry'], + ['cla', 'application/vnd.claymore'], + ['class', ['application/octet-stream', 'application/java', 'application/java-byte-code', 'application/java-vm', 'application/x-java-class']], + ['clkk', 'application/vnd.crick.clicker.keyboard'], + ['clkp', 'application/vnd.crick.clicker.palette'], + ['clkt', 'application/vnd.crick.clicker.template'], + ['clkw', 'application/vnd.crick.clicker.wordbank'], + ['clkx', 'application/vnd.crick.clicker'], + ['clp', 'application/x-msclip'], + ['cmc', 'application/vnd.cosmocaller'], + ['cmdf', 'chemical/x-cmdf'], + ['cml', 'chemical/x-cml'], + ['cmp', 'application/vnd.yellowriver-custom-menu'], + ['cmx', 'image/x-cmx'], + ['cod', ['image/cis-cod', 'application/vnd.rim.cod']], + ['com', ['application/octet-stream', 'text/plain']], + ['conf', 'text/plain'], + ['cpio', 'application/x-cpio'], + ['cpp', 'text/x-c'], + ['cpt', ['application/mac-compactpro', 'application/x-compactpro', 'application/x-cpt']], + ['crd', 'application/x-mscardfile'], + ['crl', ['application/pkix-crl', 'application/pkcs-crl']], + ['crt', ['application/pkix-cert', 'application/x-x509-user-cert', 'application/x-x509-ca-cert']], + ['cryptonote', 'application/vnd.rig.cryptonote'], + ['csh', ['text/x-script.csh', 'application/x-csh']], + ['csml', 'chemical/x-csml'], + ['csp', 'application/vnd.commonspace'], + ['css', ['text/css', 'application/x-pointplus']], + ['csv', 'text/csv'], + ['cu', 'application/cu-seeme'], + ['curl', 'text/vnd.curl'], + ['cww', 'application/prs.cww'], + ['cxx', 'text/plain'], + ['dae', 'model/vnd.collada+xml'], + ['daf', 'application/vnd.mobius.daf'], + ['davmount', 'application/davmount+xml'], + ['dcr', 'application/x-director'], + ['dcurl', 'text/vnd.curl.dcurl'], + ['dd2', 'application/vnd.oma.dd2+xml'], + ['ddd', 'application/vnd.fujixerox.ddd'], + ['deb', 'application/x-debian-package'], + ['deepv', 'application/x-deepv'], + ['def', 'text/plain'], + ['der', 'application/x-x509-ca-cert'], + ['dfac', 'application/vnd.dreamfactory'], + ['dif', 'video/x-dv'], + ['dir', 'application/x-director'], + ['dis', 'application/vnd.mobius.dis'], + ['djvu', 'image/vnd.djvu'], + ['dl', ['video/dl', 'video/x-dl']], + ['dll', 'application/x-msdownload'], + ['dms', 'application/octet-stream'], + ['dna', 'application/vnd.dna'], + ['doc', 'application/msword'], + ['docm', 'application/vnd.ms-word.document.macroenabled.12'], + ['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'], + ['dot', 'application/msword'], + ['dotm', 'application/vnd.ms-word.template.macroenabled.12'], + ['dotx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'], + ['dp', ['application/commonground', 'application/vnd.osgi.dp']], + ['dpg', 'application/vnd.dpgraph'], + ['dra', 'audio/vnd.dra'], + ['drw', 'application/drafting'], + ['dsc', 'text/prs.lines.tag'], + ['dssc', 'application/dssc+der'], + ['dtb', 'application/x-dtbook+xml'], + ['dtd', 'application/xml-dtd'], + ['dts', 'audio/vnd.dts'], + ['dtshd', 'audio/vnd.dts.hd'], + ['dump', 'application/octet-stream'], + ['dv', 'video/x-dv'], + ['dvi', 'application/x-dvi'], + ['dwf', ['model/vnd.dwf', 'drawing/x-dwf']], + ['dwg', ['application/acad', 'image/vnd.dwg', 'image/x-dwg']], + ['dxf', ['application/dxf', 'image/vnd.dwg', 'image/vnd.dxf', 'image/x-dwg']], + ['dxp', 'application/vnd.spotfire.dxp'], + ['dxr', 'application/x-director'], + ['ecelp4800', 'audio/vnd.nuera.ecelp4800'], + ['ecelp7470', 'audio/vnd.nuera.ecelp7470'], + ['ecelp9600', 'audio/vnd.nuera.ecelp9600'], + ['edm', 'application/vnd.novadigm.edm'], + ['edx', 'application/vnd.novadigm.edx'], + ['efif', 'application/vnd.picsel'], + ['ei6', 'application/vnd.pg.osasli'], + ['el', 'text/x-script.elisp'], + ['elc', ['application/x-elc', 'application/x-bytecode.elisp']], + ['eml', 'message/rfc822'], + ['emma', 'application/emma+xml'], + ['env', 'application/x-envoy'], + ['eol', 'audio/vnd.digital-winds'], + ['eot', 'application/vnd.ms-fontobject'], + ['eps', 'application/postscript'], + ['epub', 'application/epub+zip'], + ['es', ['application/ecmascript', 'application/x-esrehber']], + ['es3', 'application/vnd.eszigno3+xml'], + ['esf', 'application/vnd.epson.esf'], + ['etx', 'text/x-setext'], + ['evy', ['application/envoy', 'application/x-envoy']], + ['exe', ['application/octet-stream', 'application/x-msdownload']], + ['exi', 'application/exi'], + ['ext', 'application/vnd.novadigm.ext'], + ['ez2', 'application/vnd.ezpix-album'], + ['ez3', 'application/vnd.ezpix-package'], + ['f', ['text/plain', 'text/x-fortran']], + ['f4v', 'video/x-f4v'], + ['f77', 'text/x-fortran'], + ['f90', ['text/plain', 'text/x-fortran']], + ['fbs', 'image/vnd.fastbidsheet'], + ['fcs', 'application/vnd.isac.fcs'], + ['fdf', 'application/vnd.fdf'], + ['fe_launch', 'application/vnd.denovo.fcselayout-link'], + ['fg5', 'application/vnd.fujitsu.oasysgp'], + ['fh', 'image/x-freehand'], + ['fif', ['application/fractals', 'image/fif']], + ['fig', 'application/x-xfig'], + ['fli', ['video/fli', 'video/x-fli']], + ['flo', ['image/florian', 'application/vnd.micrografx.flo']], + ['flr', 'x-world/x-vrml'], + ['flv', 'video/x-flv'], + ['flw', 'application/vnd.kde.kivio'], + ['flx', 'text/vnd.fmi.flexstor'], + ['fly', 'text/vnd.fly'], + ['fm', 'application/vnd.framemaker'], + ['fmf', 'video/x-atomic3d-feature'], + ['fnc', 'application/vnd.frogans.fnc'], + ['for', ['text/plain', 'text/x-fortran']], + ['fpx', ['image/vnd.fpx', 'image/vnd.net-fpx']], + ['frl', 'application/freeloader'], + ['fsc', 'application/vnd.fsc.weblaunch'], + ['fst', 'image/vnd.fst'], + ['ftc', 'application/vnd.fluxtime.clip'], + ['fti', 'application/vnd.anser-web-funds-transfer-initiation'], + ['funk', 'audio/make'], + ['fvt', 'video/vnd.fvt'], + ['fxp', 'application/vnd.adobe.fxp'], + ['fzs', 'application/vnd.fuzzysheet'], + ['g', 'text/plain'], + ['g2w', 'application/vnd.geoplan'], + ['g3', 'image/g3fax'], + ['g3w', 'application/vnd.geospace'], + ['gac', 'application/vnd.groove-account'], + ['gdl', 'model/vnd.gdl'], + ['geo', 'application/vnd.dynageo'], + ['gex', 'application/vnd.geometry-explorer'], + ['ggb', 'application/vnd.geogebra.file'], + ['ggt', 'application/vnd.geogebra.tool'], + ['ghf', 'application/vnd.groove-help'], + ['gif', 'image/gif'], + ['gim', 'application/vnd.groove-identity-message'], + ['gl', ['video/gl', 'video/x-gl']], + ['gmx', 'application/vnd.gmx'], + ['gnumeric', 'application/x-gnumeric'], + ['gph', 'application/vnd.flographit'], + ['gqf', 'application/vnd.grafeq'], + ['gram', 'application/srgs'], + ['grv', 'application/vnd.groove-injector'], + ['grxml', 'application/srgs+xml'], + ['gsd', 'audio/x-gsm'], + ['gsf', 'application/x-font-ghostscript'], + ['gsm', 'audio/x-gsm'], + ['gsp', 'application/x-gsp'], + ['gss', 'application/x-gss'], + ['gtar', 'application/x-gtar'], + ['gtm', 'application/vnd.groove-tool-message'], + ['gtw', 'model/vnd.gtw'], + ['gv', 'text/vnd.graphviz'], + ['gxt', 'application/vnd.geonext'], + ['gz', ['application/x-gzip', 'application/x-compressed']], + ['gzip', ['multipart/x-gzip', 'application/x-gzip']], + ['h', ['text/plain', 'text/x-h']], + ['h261', 'video/h261'], + ['h263', 'video/h263'], + ['h264', 'video/h264'], + ['hal', 'application/vnd.hal+xml'], + ['hbci', 'application/vnd.hbci'], + ['hdf', 'application/x-hdf'], + ['help', 'application/x-helpfile'], + ['hgl', 'application/vnd.hp-hpgl'], + ['hh', ['text/plain', 'text/x-h']], + ['hlb', 'text/x-script'], + ['hlp', ['application/winhlp', 'application/hlp', 'application/x-helpfile', 'application/x-winhelp']], + ['hpg', 'application/vnd.hp-hpgl'], + ['hpgl', 'application/vnd.hp-hpgl'], + ['hpid', 'application/vnd.hp-hpid'], + ['hps', 'application/vnd.hp-hps'], + [ + 'hqx', + [ + 'application/mac-binhex40', + 'application/binhex', + 'application/binhex4', + 'application/mac-binhex', + 'application/x-binhex40', + 'application/x-mac-binhex40' + ] + ], + ['hta', 'application/hta'], + ['htc', 'text/x-component'], + ['htke', 'application/vnd.kenameaapp'], + ['htm', 'text/html'], + ['html', 'text/html'], + ['htmls', 'text/html'], + ['htt', 'text/webviewhtml'], + ['htx', 'text/html'], + ['hvd', 'application/vnd.yamaha.hv-dic'], + ['hvp', 'application/vnd.yamaha.hv-voice'], + ['hvs', 'application/vnd.yamaha.hv-script'], + ['i2g', 'application/vnd.intergeo'], + ['icc', 'application/vnd.iccprofile'], + ['ice', 'x-conference/x-cooltalk'], + ['ico', 'image/x-icon'], + ['ics', 'text/calendar'], + ['idc', 'text/plain'], + ['ief', 'image/ief'], + ['iefs', 'image/ief'], + ['ifm', 'application/vnd.shana.informed.formdata'], + ['iges', ['application/iges', 'model/iges']], + ['igl', 'application/vnd.igloader'], + ['igm', 'application/vnd.insors.igm'], + ['igs', ['application/iges', 'model/iges']], + ['igx', 'application/vnd.micrografx.igx'], + ['iif', 'application/vnd.shana.informed.interchange'], + ['iii', 'application/x-iphone'], + ['ima', 'application/x-ima'], + ['imap', 'application/x-httpd-imap'], + ['imp', 'application/vnd.accpac.simply.imp'], + ['ims', 'application/vnd.ms-ims'], + ['inf', 'application/inf'], + ['ins', ['application/x-internet-signup', 'application/x-internett-signup']], + ['ip', 'application/x-ip2'], + ['ipfix', 'application/ipfix'], + ['ipk', 'application/vnd.shana.informed.package'], + ['irm', 'application/vnd.ibm.rights-management'], + ['irp', 'application/vnd.irepository.package+xml'], + ['isp', 'application/x-internet-signup'], + ['isu', 'video/x-isvideo'], + ['it', 'audio/it'], + ['itp', 'application/vnd.shana.informed.formtemplate'], + ['iv', 'application/x-inventor'], + ['ivp', 'application/vnd.immervision-ivp'], + ['ivr', 'i-world/i-vrml'], + ['ivu', 'application/vnd.immervision-ivu'], + ['ivy', 'application/x-livescreen'], + ['jad', 'text/vnd.sun.j2me.app-descriptor'], + ['jam', ['application/vnd.jam', 'audio/x-jam']], + ['jar', 'application/java-archive'], + ['jav', ['text/plain', 'text/x-java-source']], + ['java', ['text/plain', 'text/x-java-source,java', 'text/x-java-source']], + ['jcm', 'application/x-java-commerce'], + ['jfif', ['image/pipeg', 'image/jpeg', 'image/pjpeg']], + ['jfif-tbnl', 'image/jpeg'], + ['jisp', 'application/vnd.jisp'], + ['jlt', 'application/vnd.hp-jlyt'], + ['jnlp', 'application/x-java-jnlp-file'], + ['joda', 'application/vnd.joost.joda-archive'], + ['jpe', ['image/jpeg', 'image/pjpeg']], + ['jpeg', ['image/jpeg', 'image/pjpeg']], + ['jpg', ['image/jpeg', 'image/pjpeg']], + ['jpgv', 'video/jpeg'], + ['jpm', 'video/jpm'], + ['jps', 'image/x-jps'], + ['js', ['application/javascript', 'application/ecmascript', 'text/javascript', 'text/ecmascript', 'application/x-javascript']], + ['json', 'application/json'], + ['jut', 'image/jutvision'], + ['kar', ['audio/midi', 'music/x-karaoke']], + ['karbon', 'application/vnd.kde.karbon'], + ['kfo', 'application/vnd.kde.kformula'], + ['kia', 'application/vnd.kidspiration'], + ['kml', 'application/vnd.google-earth.kml+xml'], + ['kmz', 'application/vnd.google-earth.kmz'], + ['kne', 'application/vnd.kinar'], + ['kon', 'application/vnd.kde.kontour'], + ['kpr', 'application/vnd.kde.kpresenter'], + ['ksh', ['application/x-ksh', 'text/x-script.ksh']], + ['ksp', 'application/vnd.kde.kspread'], + ['ktx', 'image/ktx'], + ['ktz', 'application/vnd.kahootz'], + ['kwd', 'application/vnd.kde.kword'], + ['la', ['audio/nspaudio', 'audio/x-nspaudio']], + ['lam', 'audio/x-liveaudio'], + ['lasxml', 'application/vnd.las.las+xml'], + ['latex', 'application/x-latex'], + ['lbd', 'application/vnd.llamagraphics.life-balance.desktop'], + ['lbe', 'application/vnd.llamagraphics.life-balance.exchange+xml'], + ['les', 'application/vnd.hhe.lesson-player'], + ['lha', ['application/octet-stream', 'application/lha', 'application/x-lha']], + ['lhx', 'application/octet-stream'], + ['link66', 'application/vnd.route66.link66+xml'], + ['list', 'text/plain'], + ['lma', ['audio/nspaudio', 'audio/x-nspaudio']], + ['log', 'text/plain'], + ['lrm', 'application/vnd.ms-lrm'], + ['lsf', 'video/x-la-asf'], + ['lsp', ['application/x-lisp', 'text/x-script.lisp']], + ['lst', 'text/plain'], + ['lsx', ['video/x-la-asf', 'text/x-la-asf']], + ['ltf', 'application/vnd.frogans.ltf'], + ['ltx', 'application/x-latex'], + ['lvp', 'audio/vnd.lucent.voice'], + ['lwp', 'application/vnd.lotus-wordpro'], + ['lzh', ['application/octet-stream', 'application/x-lzh']], + ['lzx', ['application/lzx', 'application/octet-stream', 'application/x-lzx']], + ['m', ['text/plain', 'text/x-m']], + ['m13', 'application/x-msmediaview'], + ['m14', 'application/x-msmediaview'], + ['m1v', 'video/mpeg'], + ['m21', 'application/mp21'], + ['m2a', 'audio/mpeg'], + ['m2v', 'video/mpeg'], + ['m3u', ['audio/x-mpegurl', 'audio/x-mpequrl']], + ['m3u8', 'application/vnd.apple.mpegurl'], + ['m4v', 'video/x-m4v'], + ['ma', 'application/mathematica'], + ['mads', 'application/mads+xml'], + ['mag', 'application/vnd.ecowin.chart'], + ['man', 'application/x-troff-man'], + ['map', 'application/x-navimap'], + ['mar', 'text/plain'], + ['mathml', 'application/mathml+xml'], + ['mbd', 'application/mbedlet'], + ['mbk', 'application/vnd.mobius.mbk'], + ['mbox', 'application/mbox'], + ['mc$', 'application/x-magic-cap-package-1.0'], + ['mc1', 'application/vnd.medcalcdata'], + ['mcd', ['application/mcad', 'application/vnd.mcd', 'application/x-mathcad']], + ['mcf', ['image/vasa', 'text/mcf']], + ['mcp', 'application/netmc'], + ['mcurl', 'text/vnd.curl.mcurl'], + ['mdb', 'application/x-msaccess'], + ['mdi', 'image/vnd.ms-modi'], + ['me', 'application/x-troff-me'], + ['meta4', 'application/metalink4+xml'], + ['mets', 'application/mets+xml'], + ['mfm', 'application/vnd.mfmp'], + ['mgp', 'application/vnd.osgeo.mapguide.package'], + ['mgz', 'application/vnd.proteus.magazine'], + ['mht', 'message/rfc822'], + ['mhtml', 'message/rfc822'], + ['mid', ['audio/mid', 'audio/midi', 'music/crescendo', 'x-music/x-midi', 'audio/x-midi', 'application/x-midi', 'audio/x-mid']], + ['midi', ['audio/midi', 'music/crescendo', 'x-music/x-midi', 'audio/x-midi', 'application/x-midi', 'audio/x-mid']], + ['mif', ['application/vnd.mif', 'application/x-mif', 'application/x-frame']], + ['mime', ['message/rfc822', 'www/mime']], + ['mj2', 'video/mj2'], + ['mjf', 'audio/x-vnd.audioexplosion.mjuicemediafile'], + ['mjpg', 'video/x-motion-jpeg'], + ['mlp', 'application/vnd.dolby.mlp'], + ['mm', ['application/base64', 'application/x-meme']], + ['mmd', 'application/vnd.chipnuts.karaoke-mmd'], + ['mme', 'application/base64'], + ['mmf', 'application/vnd.smaf'], + ['mmr', 'image/vnd.fujixerox.edmics-mmr'], + ['mny', 'application/x-msmoney'], + ['mod', ['audio/mod', 'audio/x-mod']], + ['mods', 'application/mods+xml'], + ['moov', 'video/quicktime'], + ['mov', 'video/quicktime'], + ['movie', 'video/x-sgi-movie'], + ['mp2', ['video/mpeg', 'audio/mpeg', 'video/x-mpeg', 'audio/x-mpeg', 'video/x-mpeq2a']], + ['mp3', ['audio/mpeg', 'audio/mpeg3', 'video/mpeg', 'audio/x-mpeg-3', 'video/x-mpeg']], + ['mp4', ['video/mp4', 'application/mp4']], + ['mp4a', 'audio/mp4'], + ['mpa', ['video/mpeg', 'audio/mpeg']], + ['mpc', ['application/vnd.mophun.certificate', 'application/x-project']], + ['mpe', 'video/mpeg'], + ['mpeg', 'video/mpeg'], + ['mpg', ['video/mpeg', 'audio/mpeg']], + ['mpga', 'audio/mpeg'], + ['mpkg', 'application/vnd.apple.installer+xml'], + ['mpm', 'application/vnd.blueice.multipass'], + ['mpn', 'application/vnd.mophun.application'], + ['mpp', 'application/vnd.ms-project'], + ['mpt', 'application/x-project'], + ['mpv', 'application/x-project'], + ['mpv2', 'video/mpeg'], + ['mpx', 'application/x-project'], + ['mpy', 'application/vnd.ibm.minipay'], + ['mqy', 'application/vnd.mobius.mqy'], + ['mrc', 'application/marc'], + ['mrcx', 'application/marcxml+xml'], + ['ms', 'application/x-troff-ms'], + ['mscml', 'application/mediaservercontrol+xml'], + ['mseq', 'application/vnd.mseq'], + ['msf', 'application/vnd.epson.msf'], + ['msg', 'application/vnd.ms-outlook'], + ['msh', 'model/mesh'], + ['msl', 'application/vnd.mobius.msl'], + ['msty', 'application/vnd.muvee.style'], + ['mts', 'model/vnd.mts'], + ['mus', 'application/vnd.musician'], + ['musicxml', 'application/vnd.recordare.musicxml+xml'], + ['mv', 'video/x-sgi-movie'], + ['mvb', 'application/x-msmediaview'], + ['mwf', 'application/vnd.mfer'], + ['mxf', 'application/mxf'], + ['mxl', 'application/vnd.recordare.musicxml'], + ['mxml', 'application/xv+xml'], + ['mxs', 'application/vnd.triscape.mxs'], + ['mxu', 'video/vnd.mpegurl'], + ['my', 'audio/make'], + ['mzz', 'application/x-vnd.audioexplosion.mzz'], + ['n-gage', 'application/vnd.nokia.n-gage.symbian.install'], + ['n3', 'text/n3'], + ['nap', 'image/naplps'], + ['naplps', 'image/naplps'], + ['nbp', 'application/vnd.wolfram.player'], + ['nc', 'application/x-netcdf'], + ['ncm', 'application/vnd.nokia.configuration-message'], + ['ncx', 'application/x-dtbncx+xml'], + ['ngdat', 'application/vnd.nokia.n-gage.data'], + ['nif', 'image/x-niff'], + ['niff', 'image/x-niff'], + ['nix', 'application/x-mix-transfer'], + ['nlu', 'application/vnd.neurolanguage.nlu'], + ['nml', 'application/vnd.enliven'], + ['nnd', 'application/vnd.noblenet-directory'], + ['nns', 'application/vnd.noblenet-sealer'], + ['nnw', 'application/vnd.noblenet-web'], + ['npx', 'image/vnd.net-fpx'], + ['nsc', 'application/x-conference'], + ['nsf', 'application/vnd.lotus-notes'], + ['nvd', 'application/x-navidoc'], + ['nws', 'message/rfc822'], + ['o', 'application/octet-stream'], + ['oa2', 'application/vnd.fujitsu.oasys2'], + ['oa3', 'application/vnd.fujitsu.oasys3'], + ['oas', 'application/vnd.fujitsu.oasys'], + ['obd', 'application/x-msbinder'], + ['oda', 'application/oda'], + ['odb', 'application/vnd.oasis.opendocument.database'], + ['odc', 'application/vnd.oasis.opendocument.chart'], + ['odf', 'application/vnd.oasis.opendocument.formula'], + ['odft', 'application/vnd.oasis.opendocument.formula-template'], + ['odg', 'application/vnd.oasis.opendocument.graphics'], + ['odi', 'application/vnd.oasis.opendocument.image'], + ['odm', 'application/vnd.oasis.opendocument.text-master'], + ['odp', 'application/vnd.oasis.opendocument.presentation'], + ['ods', 'application/vnd.oasis.opendocument.spreadsheet'], + ['odt', 'application/vnd.oasis.opendocument.text'], + ['oga', 'audio/ogg'], + ['ogv', 'video/ogg'], + ['ogx', 'application/ogg'], + ['omc', 'application/x-omc'], + ['omcd', 'application/x-omcdatamaker'], + ['omcr', 'application/x-omcregerator'], + ['onetoc', 'application/onenote'], + ['opf', 'application/oebps-package+xml'], + ['org', 'application/vnd.lotus-organizer'], + ['osf', 'application/vnd.yamaha.openscoreformat'], + ['osfpvg', 'application/vnd.yamaha.openscoreformat.osfpvg+xml'], + ['otc', 'application/vnd.oasis.opendocument.chart-template'], + ['otf', 'application/x-font-otf'], + ['otg', 'application/vnd.oasis.opendocument.graphics-template'], + ['oth', 'application/vnd.oasis.opendocument.text-web'], + ['oti', 'application/vnd.oasis.opendocument.image-template'], + ['otp', 'application/vnd.oasis.opendocument.presentation-template'], + ['ots', 'application/vnd.oasis.opendocument.spreadsheet-template'], + ['ott', 'application/vnd.oasis.opendocument.text-template'], + ['oxt', 'application/vnd.openofficeorg.extension'], + ['p', 'text/x-pascal'], + ['p10', ['application/pkcs10', 'application/x-pkcs10']], + ['p12', ['application/pkcs-12', 'application/x-pkcs12']], + ['p7a', 'application/x-pkcs7-signature'], + ['p7b', 'application/x-pkcs7-certificates'], + ['p7c', ['application/pkcs7-mime', 'application/x-pkcs7-mime']], + ['p7m', ['application/pkcs7-mime', 'application/x-pkcs7-mime']], + ['p7r', 'application/x-pkcs7-certreqresp'], + ['p7s', ['application/pkcs7-signature', 'application/x-pkcs7-signature']], + ['p8', 'application/pkcs8'], + ['par', 'text/plain-bas'], + ['part', 'application/pro_eng'], + ['pas', 'text/pascal'], + ['paw', 'application/vnd.pawaafile'], + ['pbd', 'application/vnd.powerbuilder6'], + ['pbm', 'image/x-portable-bitmap'], + ['pcf', 'application/x-font-pcf'], + ['pcl', ['application/vnd.hp-pcl', 'application/x-pcl']], + ['pclxl', 'application/vnd.hp-pclxl'], + ['pct', 'image/x-pict'], + ['pcurl', 'application/vnd.curl.pcurl'], + ['pcx', 'image/x-pcx'], + ['pdb', ['application/vnd.palm', 'chemical/x-pdb']], + ['pdf', 'application/pdf'], + ['pfa', 'application/x-font-type1'], + ['pfr', 'application/font-tdpfr'], + ['pfunk', ['audio/make', 'audio/make.my.funk']], + ['pfx', 'application/x-pkcs12'], + ['pgm', ['image/x-portable-graymap', 'image/x-portable-greymap']], + ['pgn', 'application/x-chess-pgn'], + ['pgp', 'application/pgp-signature'], + ['pic', ['image/pict', 'image/x-pict']], + ['pict', 'image/pict'], + ['pkg', 'application/x-newton-compatible-pkg'], + ['pki', 'application/pkixcmp'], + ['pkipath', 'application/pkix-pkipath'], + ['pko', ['application/ynd.ms-pkipko', 'application/vnd.ms-pki.pko']], + ['pl', ['text/plain', 'text/x-script.perl']], + ['plb', 'application/vnd.3gpp.pic-bw-large'], + ['plc', 'application/vnd.mobius.plc'], + ['plf', 'application/vnd.pocketlearn'], + ['pls', 'application/pls+xml'], + ['plx', 'application/x-pixclscript'], + ['pm', ['text/x-script.perl-module', 'image/x-xpixmap']], + ['pm4', 'application/x-pagemaker'], + ['pm5', 'application/x-pagemaker'], + ['pma', 'application/x-perfmon'], + ['pmc', 'application/x-perfmon'], + ['pml', ['application/vnd.ctc-posml', 'application/x-perfmon']], + ['pmr', 'application/x-perfmon'], + ['pmw', 'application/x-perfmon'], + ['png', 'image/png'], + ['pnm', ['application/x-portable-anymap', 'image/x-portable-anymap']], + ['portpkg', 'application/vnd.macports.portpkg'], + ['pot', ['application/vnd.ms-powerpoint', 'application/mspowerpoint']], + ['potm', 'application/vnd.ms-powerpoint.template.macroenabled.12'], + ['potx', 'application/vnd.openxmlformats-officedocument.presentationml.template'], + ['pov', 'model/x-pov'], + ['ppa', 'application/vnd.ms-powerpoint'], + ['ppam', 'application/vnd.ms-powerpoint.addin.macroenabled.12'], + ['ppd', 'application/vnd.cups-ppd'], + ['ppm', 'image/x-portable-pixmap'], + ['pps', ['application/vnd.ms-powerpoint', 'application/mspowerpoint']], + ['ppsm', 'application/vnd.ms-powerpoint.slideshow.macroenabled.12'], + ['ppsx', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'], + ['ppt', ['application/vnd.ms-powerpoint', 'application/mspowerpoint', 'application/powerpoint', 'application/x-mspowerpoint']], + ['pptm', 'application/vnd.ms-powerpoint.presentation.macroenabled.12'], + ['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'], + ['ppz', 'application/mspowerpoint'], + ['prc', 'application/x-mobipocket-ebook'], + ['pre', ['application/vnd.lotus-freelance', 'application/x-freelance']], + ['prf', 'application/pics-rules'], + ['prt', 'application/pro_eng'], + ['ps', 'application/postscript'], + ['psb', 'application/vnd.3gpp.pic-bw-small'], + ['psd', ['application/octet-stream', 'image/vnd.adobe.photoshop']], + ['psf', 'application/x-font-linux-psf'], + ['pskcxml', 'application/pskc+xml'], + ['ptid', 'application/vnd.pvi.ptid1'], + ['pub', 'application/x-mspublisher'], + ['pvb', 'application/vnd.3gpp.pic-bw-var'], + ['pvu', 'paleovu/x-pv'], + ['pwn', 'application/vnd.3m.post-it-notes'], + ['pwz', 'application/vnd.ms-powerpoint'], + ['py', 'text/x-script.phyton'], + ['pya', 'audio/vnd.ms-playready.media.pya'], + ['pyc', 'applicaiton/x-bytecode.python'], + ['pyv', 'video/vnd.ms-playready.media.pyv'], + ['qam', 'application/vnd.epson.quickanime'], + ['qbo', 'application/vnd.intu.qbo'], + ['qcp', 'audio/vnd.qcelp'], + ['qd3', 'x-world/x-3dmf'], + ['qd3d', 'x-world/x-3dmf'], + ['qfx', 'application/vnd.intu.qfx'], + ['qif', 'image/x-quicktime'], + ['qps', 'application/vnd.publishare-delta-tree'], + ['qt', 'video/quicktime'], + ['qtc', 'video/x-qtc'], + ['qti', 'image/x-quicktime'], + ['qtif', 'image/x-quicktime'], + ['qxd', 'application/vnd.quark.quarkxpress'], + ['ra', ['audio/x-realaudio', 'audio/x-pn-realaudio', 'audio/x-pn-realaudio-plugin']], + ['ram', 'audio/x-pn-realaudio'], + ['rar', 'application/x-rar-compressed'], + ['ras', ['image/cmu-raster', 'application/x-cmu-raster', 'image/x-cmu-raster']], + ['rast', 'image/cmu-raster'], + ['rcprofile', 'application/vnd.ipunplugged.rcprofile'], + ['rdf', 'application/rdf+xml'], + ['rdz', 'application/vnd.data-vision.rdz'], + ['rep', 'application/vnd.businessobjects'], + ['res', 'application/x-dtbresource+xml'], + ['rexx', 'text/x-script.rexx'], + ['rf', 'image/vnd.rn-realflash'], + ['rgb', 'image/x-rgb'], + ['rif', 'application/reginfo+xml'], + ['rip', 'audio/vnd.rip'], + ['rl', 'application/resource-lists+xml'], + ['rlc', 'image/vnd.fujixerox.edmics-rlc'], + ['rld', 'application/resource-lists-diff+xml'], + ['rm', ['application/vnd.rn-realmedia', 'audio/x-pn-realaudio']], + ['rmi', 'audio/mid'], + ['rmm', 'audio/x-pn-realaudio'], + ['rmp', ['audio/x-pn-realaudio-plugin', 'audio/x-pn-realaudio']], + ['rms', 'application/vnd.jcp.javame.midlet-rms'], + ['rnc', 'application/relax-ng-compact-syntax'], + ['rng', ['application/ringing-tones', 'application/vnd.nokia.ringing-tone']], + ['rnx', 'application/vnd.rn-realplayer'], + ['roff', 'application/x-troff'], + ['rp', 'image/vnd.rn-realpix'], + ['rp9', 'application/vnd.cloanto.rp9'], + ['rpm', 'audio/x-pn-realaudio-plugin'], + ['rpss', 'application/vnd.nokia.radio-presets'], + ['rpst', 'application/vnd.nokia.radio-preset'], + ['rq', 'application/sparql-query'], + ['rs', 'application/rls-services+xml'], + ['rsd', 'application/rsd+xml'], + ['rt', ['text/richtext', 'text/vnd.rn-realtext']], + ['rtf', ['application/rtf', 'text/richtext', 'application/x-rtf']], + ['rtx', ['text/richtext', 'application/rtf']], + ['rv', 'video/vnd.rn-realvideo'], + ['s', 'text/x-asm'], + ['s3m', 'audio/s3m'], + ['saf', 'application/vnd.yamaha.smaf-audio'], + ['saveme', 'application/octet-stream'], + ['sbk', 'application/x-tbook'], + ['sbml', 'application/sbml+xml'], + ['sc', 'application/vnd.ibm.secure-container'], + ['scd', 'application/x-msschedule'], + ['scm', ['application/vnd.lotus-screencam', 'video/x-scm', 'text/x-script.guile', 'application/x-lotusscreencam', 'text/x-script.scheme']], + ['scq', 'application/scvp-cv-request'], + ['scs', 'application/scvp-cv-response'], + ['sct', 'text/scriptlet'], + ['scurl', 'text/vnd.curl.scurl'], + ['sda', 'application/vnd.stardivision.draw'], + ['sdc', 'application/vnd.stardivision.calc'], + ['sdd', 'application/vnd.stardivision.impress'], + ['sdkm', 'application/vnd.solent.sdkm+xml'], + ['sdml', 'text/plain'], + ['sdp', ['application/sdp', 'application/x-sdp']], + ['sdr', 'application/sounder'], + ['sdw', 'application/vnd.stardivision.writer'], + ['sea', ['application/sea', 'application/x-sea']], + ['see', 'application/vnd.seemail'], + ['seed', 'application/vnd.fdsn.seed'], + ['sema', 'application/vnd.sema'], + ['semd', 'application/vnd.semd'], + ['semf', 'application/vnd.semf'], + ['ser', 'application/java-serialized-object'], + ['set', 'application/set'], + ['setpay', 'application/set-payment-initiation'], + ['setreg', 'application/set-registration-initiation'], + ['sfd-hdstx', 'application/vnd.hydrostatix.sof-data'], + ['sfs', 'application/vnd.spotfire.sfs'], + ['sgl', 'application/vnd.stardivision.writer-global'], + ['sgm', ['text/sgml', 'text/x-sgml']], + ['sgml', ['text/sgml', 'text/x-sgml']], + ['sh', ['application/x-shar', 'application/x-bsh', 'application/x-sh', 'text/x-script.sh']], + ['shar', ['application/x-bsh', 'application/x-shar']], + ['shf', 'application/shf+xml'], + ['shtml', ['text/html', 'text/x-server-parsed-html']], + ['sid', 'audio/x-psid'], + ['sis', 'application/vnd.symbian.install'], + ['sit', ['application/x-stuffit', 'application/x-sit']], + ['sitx', 'application/x-stuffitx'], + ['skd', 'application/x-koan'], + ['skm', 'application/x-koan'], + ['skp', ['application/vnd.koan', 'application/x-koan']], + ['skt', 'application/x-koan'], + ['sl', 'application/x-seelogo'], + ['sldm', 'application/vnd.ms-powerpoint.slide.macroenabled.12'], + ['sldx', 'application/vnd.openxmlformats-officedocument.presentationml.slide'], + ['slt', 'application/vnd.epson.salt'], + ['sm', 'application/vnd.stepmania.stepchart'], + ['smf', 'application/vnd.stardivision.math'], + ['smi', ['application/smil', 'application/smil+xml']], + ['smil', 'application/smil'], + ['snd', ['audio/basic', 'audio/x-adpcm']], + ['snf', 'application/x-font-snf'], + ['sol', 'application/solids'], + ['spc', ['text/x-speech', 'application/x-pkcs7-certificates']], + ['spf', 'application/vnd.yamaha.smaf-phrase'], + ['spl', ['application/futuresplash', 'application/x-futuresplash']], + ['spot', 'text/vnd.in3d.spot'], + ['spp', 'application/scvp-vp-response'], + ['spq', 'application/scvp-vp-request'], + ['spr', 'application/x-sprite'], + ['sprite', 'application/x-sprite'], + ['src', 'application/x-wais-source'], + ['sru', 'application/sru+xml'], + ['srx', 'application/sparql-results+xml'], + ['sse', 'application/vnd.kodak-descriptor'], + ['ssf', 'application/vnd.epson.ssf'], + ['ssi', 'text/x-server-parsed-html'], + ['ssm', 'application/streamingmedia'], + ['ssml', 'application/ssml+xml'], + ['sst', ['application/vnd.ms-pkicertstore', 'application/vnd.ms-pki.certstore']], + ['st', 'application/vnd.sailingtracker.track'], + ['stc', 'application/vnd.sun.xml.calc.template'], + ['std', 'application/vnd.sun.xml.draw.template'], + ['step', 'application/step'], + ['stf', 'application/vnd.wt.stf'], + ['sti', 'application/vnd.sun.xml.impress.template'], + ['stk', 'application/hyperstudio'], + ['stl', ['application/vnd.ms-pkistl', 'application/sla', 'application/vnd.ms-pki.stl', 'application/x-navistyle']], + ['stm', 'text/html'], + ['stp', 'application/step'], + ['str', 'application/vnd.pg.format'], + ['stw', 'application/vnd.sun.xml.writer.template'], + ['sub', 'image/vnd.dvb.subtitle'], + ['sus', 'application/vnd.sus-calendar'], + ['sv4cpio', 'application/x-sv4cpio'], + ['sv4crc', 'application/x-sv4crc'], + ['svc', 'application/vnd.dvb.service'], + ['svd', 'application/vnd.svd'], + ['svf', ['image/vnd.dwg', 'image/x-dwg']], + ['svg', 'image/svg+xml'], + ['svr', ['x-world/x-svr', 'application/x-world']], + ['swf', 'application/x-shockwave-flash'], + ['swi', 'application/vnd.aristanetworks.swi'], + ['sxc', 'application/vnd.sun.xml.calc'], + ['sxd', 'application/vnd.sun.xml.draw'], + ['sxg', 'application/vnd.sun.xml.writer.global'], + ['sxi', 'application/vnd.sun.xml.impress'], + ['sxm', 'application/vnd.sun.xml.math'], + ['sxw', 'application/vnd.sun.xml.writer'], + ['t', ['text/troff', 'application/x-troff']], + ['talk', 'text/x-speech'], + ['tao', 'application/vnd.tao.intent-module-archive'], + ['tar', 'application/x-tar'], + ['tbk', ['application/toolbook', 'application/x-tbook']], + ['tcap', 'application/vnd.3gpp2.tcap'], + ['tcl', ['text/x-script.tcl', 'application/x-tcl']], + ['tcsh', 'text/x-script.tcsh'], + ['teacher', 'application/vnd.smart.teacher'], + ['tei', 'application/tei+xml'], + ['tex', 'application/x-tex'], + ['texi', 'application/x-texinfo'], + ['texinfo', 'application/x-texinfo'], + ['text', ['application/plain', 'text/plain']], + ['tfi', 'application/thraud+xml'], + ['tfm', 'application/x-tex-tfm'], + ['tgz', ['application/gnutar', 'application/x-compressed']], + ['thmx', 'application/vnd.ms-officetheme'], + ['tif', ['image/tiff', 'image/x-tiff']], + ['tiff', ['image/tiff', 'image/x-tiff']], + ['tmo', 'application/vnd.tmobile-livetv'], + ['torrent', 'application/x-bittorrent'], + ['tpl', 'application/vnd.groove-tool-template'], + ['tpt', 'application/vnd.trid.tpt'], + ['tr', 'application/x-troff'], + ['tra', 'application/vnd.trueapp'], + ['trm', 'application/x-msterminal'], + ['tsd', 'application/timestamped-data'], + ['tsi', 'audio/tsp-audio'], + ['tsp', ['application/dsptype', 'audio/tsplayer']], + ['tsv', 'text/tab-separated-values'], + ['ttf', 'application/x-font-ttf'], + ['ttl', 'text/turtle'], + ['turbot', 'image/florian'], + ['twd', 'application/vnd.simtech-mindmapper'], + ['txd', 'application/vnd.genomatix.tuxedo'], + ['txf', 'application/vnd.mobius.txf'], + ['txt', 'text/plain'], + ['ufd', 'application/vnd.ufdl'], + ['uil', 'text/x-uil'], + ['uls', 'text/iuls'], + ['umj', 'application/vnd.umajin'], + ['uni', 'text/uri-list'], + ['unis', 'text/uri-list'], + ['unityweb', 'application/vnd.unity'], + ['unv', 'application/i-deas'], + ['uoml', 'application/vnd.uoml+xml'], + ['uri', 'text/uri-list'], + ['uris', 'text/uri-list'], + ['ustar', ['application/x-ustar', 'multipart/x-ustar']], + ['utz', 'application/vnd.uiq.theme'], + ['uu', ['application/octet-stream', 'text/x-uuencode']], + ['uue', 'text/x-uuencode'], + ['uva', 'audio/vnd.dece.audio'], + ['uvh', 'video/vnd.dece.hd'], + ['uvi', 'image/vnd.dece.graphic'], + ['uvm', 'video/vnd.dece.mobile'], + ['uvp', 'video/vnd.dece.pd'], + ['uvs', 'video/vnd.dece.sd'], + ['uvu', 'video/vnd.uvvu.mp4'], + ['uvv', 'video/vnd.dece.video'], + ['vcd', 'application/x-cdlink'], + ['vcf', 'text/x-vcard'], + ['vcg', 'application/vnd.groove-vcard'], + ['vcs', 'text/x-vcalendar'], + ['vcx', 'application/vnd.vcx'], + ['vda', 'application/vda'], + ['vdo', 'video/vdo'], + ['vew', 'application/groupwise'], + ['vis', 'application/vnd.visionary'], + ['viv', ['video/vivo', 'video/vnd.vivo']], + ['vivo', ['video/vivo', 'video/vnd.vivo']], + ['vmd', 'application/vocaltec-media-desc'], + ['vmf', 'application/vocaltec-media-file'], + ['voc', ['audio/voc', 'audio/x-voc']], + ['vos', 'video/vosaic'], + ['vox', 'audio/voxware'], + ['vqe', 'audio/x-twinvq-plugin'], + ['vqf', 'audio/x-twinvq'], + ['vql', 'audio/x-twinvq-plugin'], + ['vrml', ['model/vrml', 'x-world/x-vrml', 'application/x-vrml']], + ['vrt', 'x-world/x-vrt'], + ['vsd', ['application/vnd.visio', 'application/x-visio']], + ['vsf', 'application/vnd.vsf'], + ['vst', 'application/x-visio'], + ['vsw', 'application/x-visio'], + ['vtu', 'model/vnd.vtu'], + ['vxml', 'application/voicexml+xml'], + ['w60', 'application/wordperfect6.0'], + ['w61', 'application/wordperfect6.1'], + ['w6w', 'application/msword'], + ['wad', 'application/x-doom'], + ['wav', ['audio/wav', 'audio/x-wav']], + ['wax', 'audio/x-ms-wax'], + ['wb1', 'application/x-qpro'], + ['wbmp', 'image/vnd.wap.wbmp'], + ['wbs', 'application/vnd.criticaltools.wbs+xml'], + ['wbxml', 'application/vnd.wap.wbxml'], + ['wcm', 'application/vnd.ms-works'], + ['wdb', 'application/vnd.ms-works'], + ['web', 'application/vnd.xara'], + ['weba', 'audio/webm'], + ['webm', 'video/webm'], + ['webp', 'image/webp'], + ['wg', 'application/vnd.pmi.widget'], + ['wgt', 'application/widget'], + ['wiz', 'application/msword'], + ['wk1', 'application/x-123'], + ['wks', 'application/vnd.ms-works'], + ['wm', 'video/x-ms-wm'], + ['wma', 'audio/x-ms-wma'], + ['wmd', 'application/x-ms-wmd'], + ['wmf', ['windows/metafile', 'application/x-msmetafile']], + ['wml', 'text/vnd.wap.wml'], + ['wmlc', 'application/vnd.wap.wmlc'], + ['wmls', 'text/vnd.wap.wmlscript'], + ['wmlsc', 'application/vnd.wap.wmlscriptc'], + ['wmv', 'video/x-ms-wmv'], + ['wmx', 'video/x-ms-wmx'], + ['wmz', 'application/x-ms-wmz'], + ['woff', 'application/x-font-woff'], + ['word', 'application/msword'], + ['wp', 'application/wordperfect'], + ['wp5', ['application/wordperfect', 'application/wordperfect6.0']], + ['wp6', 'application/wordperfect'], + ['wpd', ['application/wordperfect', 'application/vnd.wordperfect', 'application/x-wpwin']], + ['wpl', 'application/vnd.ms-wpl'], + ['wps', 'application/vnd.ms-works'], + ['wq1', 'application/x-lotus'], + ['wqd', 'application/vnd.wqd'], + ['wri', ['application/mswrite', 'application/x-wri', 'application/x-mswrite']], + ['wrl', ['model/vrml', 'x-world/x-vrml', 'application/x-world']], + ['wrz', ['model/vrml', 'x-world/x-vrml']], + ['wsc', 'text/scriplet'], + ['wsdl', 'application/wsdl+xml'], + ['wspolicy', 'application/wspolicy+xml'], + ['wsrc', 'application/x-wais-source'], + ['wtb', 'application/vnd.webturbo'], + ['wtk', 'application/x-wintalk'], + ['wvx', 'video/x-ms-wvx'], + ['x-png', 'image/png'], + ['x3d', 'application/vnd.hzn-3d-crossword'], + ['xaf', 'x-world/x-vrml'], + ['xap', 'application/x-silverlight-app'], + ['xar', 'application/vnd.xara'], + ['xbap', 'application/x-ms-xbap'], + ['xbd', 'application/vnd.fujixerox.docuworks.binder'], + ['xbm', ['image/xbm', 'image/x-xbm', 'image/x-xbitmap']], + ['xdf', 'application/xcap-diff+xml'], + ['xdm', 'application/vnd.syncml.dm+xml'], + ['xdp', 'application/vnd.adobe.xdp+xml'], + ['xdr', 'video/x-amt-demorun'], + ['xdssc', 'application/dssc+xml'], + ['xdw', 'application/vnd.fujixerox.docuworks'], + ['xenc', 'application/xenc+xml'], + ['xer', 'application/patch-ops-error+xml'], + ['xfdf', 'application/vnd.adobe.xfdf'], + ['xfdl', 'application/vnd.xfdl'], + ['xgz', 'xgl/drawing'], + ['xhtml', 'application/xhtml+xml'], + ['xif', 'image/vnd.xiff'], + ['xl', 'application/excel'], + ['xla', ['application/vnd.ms-excel', 'application/excel', 'application/x-msexcel', 'application/x-excel']], + ['xlam', 'application/vnd.ms-excel.addin.macroenabled.12'], + ['xlb', ['application/excel', 'application/vnd.ms-excel', 'application/x-excel']], + ['xlc', ['application/vnd.ms-excel', 'application/excel', 'application/x-excel']], + ['xld', ['application/excel', 'application/x-excel']], + ['xlk', ['application/excel', 'application/x-excel']], + ['xll', ['application/excel', 'application/vnd.ms-excel', 'application/x-excel']], + ['xlm', ['application/vnd.ms-excel', 'application/excel', 'application/x-excel']], + ['xls', ['application/vnd.ms-excel', 'application/excel', 'application/x-msexcel', 'application/x-excel']], + ['xlsb', 'application/vnd.ms-excel.sheet.binary.macroenabled.12'], + ['xlsm', 'application/vnd.ms-excel.sheet.macroenabled.12'], + ['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], + ['xlt', ['application/vnd.ms-excel', 'application/excel', 'application/x-excel']], + ['xltm', 'application/vnd.ms-excel.template.macroenabled.12'], + ['xltx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'], + ['xlv', ['application/excel', 'application/x-excel']], + ['xlw', ['application/vnd.ms-excel', 'application/excel', 'application/x-msexcel', 'application/x-excel']], + ['xm', 'audio/xm'], + ['xml', ['application/xml', 'text/xml', 'application/atom+xml', 'application/rss+xml']], + ['xmz', 'xgl/movie'], + ['xo', 'application/vnd.olpc-sugar'], + ['xof', 'x-world/x-vrml'], + ['xop', 'application/xop+xml'], + ['xpi', 'application/x-xpinstall'], + ['xpix', 'application/x-vnd.ls-xpix'], + ['xpm', ['image/xpm', 'image/x-xpixmap']], + ['xpr', 'application/vnd.is-xpr'], + ['xps', 'application/vnd.ms-xpsdocument'], + ['xpw', 'application/vnd.intercon.formnet'], + ['xslt', 'application/xslt+xml'], + ['xsm', 'application/vnd.syncml+xml'], + ['xspf', 'application/xspf+xml'], + ['xsr', 'video/x-amt-showrun'], + ['xul', 'application/vnd.mozilla.xul+xml'], + ['xwd', ['image/x-xwd', 'image/x-xwindowdump']], + ['xyz', ['chemical/x-xyz', 'chemical/x-pdb']], + ['yang', 'application/yang'], + ['yin', 'application/yin+xml'], + ['z', ['application/x-compressed', 'application/x-compress']], + ['zaz', 'application/vnd.zzazz.deck+xml'], + ['zip', ['application/zip', 'multipart/x-zip', 'application/x-zip-compressed', 'application/x-compressed']], + ['zir', 'application/vnd.zul'], + ['zmm', 'application/vnd.handheld-entertainment+xml'], + ['zoo', 'application/octet-stream'], + ['zsh', 'text/x-script.zsh'] +]); + +module.exports = { + detectMimeType(filename) { + if (!filename) { + return defaultMimeType; + } + + let parsed = path.parse(filename); + let extension = (parsed.ext.substr(1) || parsed.name || '') + .split('?') + .shift() + .trim() + .toLowerCase(); + let value = defaultMimeType; + + if (extensions.has(extension)) { + value = extensions.get(extension); + } + + if (Array.isArray(value)) { + return value[0]; + } + return value; + }, + + detectExtension(mimeType) { + if (!mimeType) { + return defaultExtension; + } + let parts = (mimeType || '') + .toLowerCase() + .trim() + .split('/'); + let rootType = parts.shift().trim(); + let subType = parts.join('/').trim(); + + if (mimeTypes.has(rootType + '/' + subType)) { + let value = mimeTypes.get(rootType + '/' + subType); + if (Array.isArray(value)) { + return value[0]; + } + return value; + } + + switch (rootType) { + case 'text': + return 'txt'; + default: + return 'bin'; + } + } +}; diff --git a/node_modules/nodemailer/lib/mime-node/index.js b/node_modules/nodemailer/lib/mime-node/index.js new file mode 100644 index 0000000..e9caf04 --- /dev/null +++ b/node_modules/nodemailer/lib/mime-node/index.js @@ -0,0 +1,1242 @@ +/* eslint no-undefined: 0, prefer-spread: 0 */ + +'use strict'; + +const crypto = require('crypto'); +const os = require('os'); +const fs = require('fs'); +const punycode = require('punycode'); +const PassThrough = require('stream').PassThrough; + +const mimeFuncs = require('../mime-funcs'); +const qp = require('../qp'); +const base64 = require('../base64'); +const addressparser = require('../addressparser'); +const fetch = require('../fetch'); +const LastNewline = require('./last-newline'); + +/** + * Creates a new mime tree node. Assumes 'multipart/*' as the content type + * if it is a branch, anything else counts as leaf. If rootNode is missing from + * the options, assumes this is the root. + * + * @param {String} contentType Define the content type for the node. Can be left blank for attachments (derived from filename) + * @param {Object} [options] optional options + * @param {Object} [options.rootNode] root node for this tree + * @param {Object} [options.parentNode] immediate parent for this node + * @param {Object} [options.filename] filename for an attachment node + * @param {String} [options.baseBoundary] shared part of the unique multipart boundary + * @param {Boolean} [options.keepBcc] If true, do not exclude Bcc from the generated headers + * @param {Function} [options.normalizeHeaderKey] method to normalize header keys for custom caseing + * @param {String} [options.textEncoding] either 'Q' (the default) or 'B' + */ +class MimeNode { + constructor(contentType, options) { + this.nodeCounter = 0; + + options = options || {}; + + /** + * shared part of the unique multipart boundary + */ + this.baseBoundary = options.baseBoundary || crypto.randomBytes(8).toString('hex'); + this.boundaryPrefix = options.boundaryPrefix || '--_NmP'; + + this.disableFileAccess = !!options.disableFileAccess; + this.disableUrlAccess = !!options.disableUrlAccess; + + this.normalizeHeaderKey = options.normalizeHeaderKey; + + /** + * If date headers is missing and current node is the root, this value is used instead + */ + this.date = new Date(); + + /** + * Root node for current mime tree + */ + this.rootNode = options.rootNode || this; + + /** + * If true include Bcc in generated headers (if available) + */ + this.keepBcc = !!options.keepBcc; + + /** + * If filename is specified but contentType is not (probably an attachment) + * detect the content type from filename extension + */ + if (options.filename) { + /** + * Filename for this node. Useful with attachments + */ + this.filename = options.filename; + if (!contentType) { + contentType = mimeFuncs.detectMimeType(this.filename.split('.').pop()); + } + } + + /** + * Indicates which encoding should be used for header strings: "Q" or "B" + */ + this.textEncoding = (options.textEncoding || '') + .toString() + .trim() + .charAt(0) + .toUpperCase(); + + /** + * Immediate parent for this node (or undefined if not set) + */ + this.parentNode = options.parentNode; + + /** + * Hostname for default message-id values + */ + this.hostname = options.hostname; + + /** + * An array for possible child nodes + */ + this.childNodes = []; + + /** + * Used for generating unique boundaries (prepended to the shared base) + */ + this._nodeId = ++this.rootNode.nodeCounter; + + /** + * A list of header values for this node in the form of [{key:'', value:''}] + */ + this._headers = []; + + /** + * True if the content only uses ASCII printable characters + * @type {Boolean} + */ + this._isPlainText = false; + + /** + * True if the content is plain text but has longer lines than allowed + * @type {Boolean} + */ + this._hasLongLines = false; + + /** + * If set, use instead this value for envelopes instead of generating one + * @type {Boolean} + */ + this._envelope = false; + + /** + * If set then use this value as the stream content instead of building it + * @type {String|Buffer|Stream} + */ + this._raw = false; + + /** + * Additional transform streams that the message will be piped before + * exposing by createReadStream + * @type {Array} + */ + this._transforms = []; + + /** + * Additional process functions that the message will be piped through before + * exposing by createReadStream. These functions are run after transforms + * @type {Array} + */ + this._processFuncs = []; + + /** + * If content type is set (or derived from the filename) add it to headers + */ + if (contentType) { + this.setHeader('Content-Type', contentType); + } + } + + /////// PUBLIC METHODS + + /** + * Creates and appends a child node.Arguments provided are passed to MimeNode constructor + * + * @param {String} [contentType] Optional content type + * @param {Object} [options] Optional options object + * @return {Object} Created node object + */ + createChild(contentType, options) { + if (!options && typeof contentType === 'object') { + options = contentType; + contentType = undefined; + } + let node = new MimeNode(contentType, options); + this.appendChild(node); + return node; + } + + /** + * Appends an existing node to the mime tree. Removes the node from an existing + * tree if needed + * + * @param {Object} childNode node to be appended + * @return {Object} Appended node object + */ + appendChild(childNode) { + if (childNode.rootNode !== this.rootNode) { + childNode.rootNode = this.rootNode; + childNode._nodeId = ++this.rootNode.nodeCounter; + } + + childNode.parentNode = this; + + this.childNodes.push(childNode); + return childNode; + } + + /** + * Replaces current node with another node + * + * @param {Object} node Replacement node + * @return {Object} Replacement node + */ + replace(node) { + if (node === this) { + return this; + } + + this.parentNode.childNodes.forEach((childNode, i) => { + if (childNode === this) { + node.rootNode = this.rootNode; + node.parentNode = this.parentNode; + node._nodeId = this._nodeId; + + this.rootNode = this; + this.parentNode = undefined; + + node.parentNode.childNodes[i] = node; + } + }); + + return node; + } + + /** + * Removes current node from the mime tree + * + * @return {Object} removed node + */ + remove() { + if (!this.parentNode) { + return this; + } + + for (let i = this.parentNode.childNodes.length - 1; i >= 0; i--) { + if (this.parentNode.childNodes[i] === this) { + this.parentNode.childNodes.splice(i, 1); + this.parentNode = undefined; + this.rootNode = this; + return this; + } + } + } + + /** + * Sets a header value. If the value for selected key exists, it is overwritten. + * You can set multiple values as well by using [{key:'', value:''}] or + * {key: 'value'} as the first argument. + * + * @param {String|Array|Object} key Header key or a list of key value pairs + * @param {String} value Header value + * @return {Object} current node + */ + setHeader(key, value) { + let added = false, + headerValue; + + // Allow setting multiple headers at once + if (!value && key && typeof key === 'object') { + // allow {key:'content-type', value: 'text/plain'} + if (key.key && 'value' in key) { + this.setHeader(key.key, key.value); + } else if (Array.isArray(key)) { + // allow [{key:'content-type', value: 'text/plain'}] + key.forEach(i => { + this.setHeader(i.key, i.value); + }); + } else { + // allow {'content-type': 'text/plain'} + Object.keys(key).forEach(i => { + this.setHeader(i, key[i]); + }); + } + return this; + } + + key = this._normalizeHeaderKey(key); + + headerValue = { + key, + value + }; + + // Check if the value exists and overwrite + for (let i = 0, len = this._headers.length; i < len; i++) { + if (this._headers[i].key === key) { + if (!added) { + // replace the first match + this._headers[i] = headerValue; + added = true; + } else { + // remove following matches + this._headers.splice(i, 1); + i--; + len--; + } + } + } + + // match not found, append the value + if (!added) { + this._headers.push(headerValue); + } + + return this; + } + + /** + * Adds a header value. If the value for selected key exists, the value is appended + * as a new field and old one is not touched. + * You can set multiple values as well by using [{key:'', value:''}] or + * {key: 'value'} as the first argument. + * + * @param {String|Array|Object} key Header key or a list of key value pairs + * @param {String} value Header value + * @return {Object} current node + */ + addHeader(key, value) { + // Allow setting multiple headers at once + if (!value && key && typeof key === 'object') { + // allow {key:'content-type', value: 'text/plain'} + if (key.key && key.value) { + this.addHeader(key.key, key.value); + } else if (Array.isArray(key)) { + // allow [{key:'content-type', value: 'text/plain'}] + key.forEach(i => { + this.addHeader(i.key, i.value); + }); + } else { + // allow {'content-type': 'text/plain'} + Object.keys(key).forEach(i => { + this.addHeader(i, key[i]); + }); + } + return this; + } else if (Array.isArray(value)) { + value.forEach(val => { + this.addHeader(key, val); + }); + return this; + } + + this._headers.push({ + key: this._normalizeHeaderKey(key), + value + }); + + return this; + } + + /** + * Retrieves the first mathcing value of a selected key + * + * @param {String} key Key to search for + * @retun {String} Value for the key + */ + getHeader(key) { + key = this._normalizeHeaderKey(key); + for (let i = 0, len = this._headers.length; i < len; i++) { + if (this._headers[i].key === key) { + return this._headers[i].value; + } + } + } + + /** + * Sets body content for current node. If the value is a string, charset is added automatically + * to Content-Type (if it is text/*). If the value is a Buffer, you need to specify + * the charset yourself + * + * @param (String|Buffer) content Body content + * @return {Object} current node + */ + setContent(content) { + this.content = content; + if (typeof this.content.pipe === 'function') { + // pre-stream handler. might be triggered if a stream is set as content + // and 'error' fires before anything is done with this stream + this._contentErrorHandler = err => { + this.content.removeListener('error', this._contentErrorHandler); + this.content = err; + }; + this.content.once('error', this._contentErrorHandler); + } else if (typeof this.content === 'string') { + this._isPlainText = mimeFuncs.isPlainText(this.content); + if (this._isPlainText && mimeFuncs.hasLongerLines(this.content, 76)) { + // If there are lines longer than 76 symbols/bytes do not use 7bit + this._hasLongLines = true; + } + } + return this; + } + + build(callback) { + let stream = this.createReadStream(); + let buf = []; + let buflen = 0; + let returned = false; + + stream.on('readable', () => { + let chunk; + + while ((chunk = stream.read()) !== null) { + buf.push(chunk); + buflen += chunk.length; + } + }); + + stream.once('error', err => { + if (returned) { + return; + } + returned = true; + + return callback(err); + }); + + stream.once('end', chunk => { + if (returned) { + return; + } + returned = true; + + if (chunk && chunk.length) { + buf.push(chunk); + buflen += chunk.length; + } + return callback(null, Buffer.concat(buf, buflen)); + }); + } + + getTransferEncoding() { + let transferEncoding = false; + let contentType = (this.getHeader('Content-Type') || '') + .toString() + .toLowerCase() + .trim(); + + if (this.content) { + transferEncoding = (this.getHeader('Content-Transfer-Encoding') || '') + .toString() + .toLowerCase() + .trim(); + if (!transferEncoding || !['base64', 'quoted-printable'].includes(transferEncoding)) { + if (/^text\//i.test(contentType)) { + // If there are no special symbols, no need to modify the text + if (this._isPlainText && !this._hasLongLines) { + transferEncoding = '7bit'; + } else if (typeof this.content === 'string' || this.content instanceof Buffer) { + // detect preferred encoding for string value + transferEncoding = this._getTextEncoding(this.content) === 'Q' ? 'quoted-printable' : 'base64'; + } else { + // we can not check content for a stream, so either use preferred encoding or fallback to QP + transferEncoding = this.transferEncoding === 'B' ? 'base64' : 'quoted-printable'; + } + } else if (!/^(multipart|message)\//i.test(contentType)) { + transferEncoding = transferEncoding || 'base64'; + } + } + } + return transferEncoding; + } + + /** + * Builds the header block for the mime node. Append \r\n\r\n before writing the content + * + * @returns {String} Headers + */ + buildHeaders() { + let transferEncoding = this.getTransferEncoding(); + let headers = []; + + if (transferEncoding) { + this.setHeader('Content-Transfer-Encoding', transferEncoding); + } + + if (this.filename && !this.getHeader('Content-Disposition')) { + this.setHeader('Content-Disposition', 'attachment'); + } + + // Ensure mandatory header fields + if (this.rootNode === this) { + if (!this.getHeader('Date')) { + this.setHeader('Date', this.date.toUTCString().replace(/GMT/, '+0000')); + } + + // ensure that Message-Id is present + this.messageId(); + + if (!this.getHeader('MIME-Version')) { + this.setHeader('MIME-Version', '1.0'); + } + } + + this._headers.forEach(header => { + let key = header.key; + let value = header.value; + let structured; + let param; + let options = {}; + let formattedHeaders = ['From', 'Sender', 'To', 'Cc', 'Bcc', 'Reply-To', 'Date', 'References']; + + if (value && typeof value === 'object' && !formattedHeaders.includes(key)) { + Object.keys(value).forEach(key => { + if (key !== 'value') { + options[key] = value[key]; + } + }); + value = (value.value || '').toString(); + if (!value.trim()) { + return; + } + } + + if (options.prepared) { + // header value is + headers.push(key + ': ' + value); + return; + } + + switch (header.key) { + case 'Content-Disposition': + structured = mimeFuncs.parseHeaderValue(value); + if (this.filename) { + structured.params.filename = this.filename; + } + value = mimeFuncs.buildHeaderValue(structured); + break; + case 'Content-Type': + structured = mimeFuncs.parseHeaderValue(value); + + this._handleContentType(structured); + + if (structured.value.match(/^text\/plain\b/) && typeof this.content === 'string' && /[\u0080-\uFFFF]/.test(this.content)) { + structured.params.charset = 'utf-8'; + } + + value = mimeFuncs.buildHeaderValue(structured); + + if (this.filename) { + // add support for non-compliant clients like QQ webmail + // we can't build the value with buildHeaderValue as the value is non standard and + // would be converted to parameter continuation encoding that we do not want + param = this._encodeWords(this.filename); + + if (param !== this.filename || /[\s'"\\;:/=(),<>@[\]?]|^-/.test(param)) { + // include value in quotes if needed + param = '"' + param + '"'; + } + value += '; name=' + param; + } + break; + case 'Bcc': + if (!this.keepBcc) { + // skip BCC values + return; + } + break; + } + + value = this._encodeHeaderValue(key, value); + + // skip empty lines + if (!(value || '').toString().trim()) { + return; + } + + if (typeof this.normalizeHeaderKey === 'function') { + let normalized = this.normalizeHeaderKey(key, value); + if (normalized && typeof normalized === 'string' && normalized.length) { + key = normalized; + } + } + + headers.push(mimeFuncs.foldLines(key + ': ' + value, 76)); + }); + + return headers.join('\r\n'); + } + + /** + * Streams the rfc2822 message from the current node. If this is a root node, + * mandatory header fields are set if missing (Date, Message-Id, MIME-Version) + * + * @return {String} Compiled message + */ + createReadStream(options) { + options = options || {}; + + let stream = new PassThrough(options); + let outputStream = stream; + let transform; + + this.stream(stream, options, err => { + if (err) { + outputStream.emit('error', err); + return; + } + stream.end(); + }); + + for (let i = 0, len = this._transforms.length; i < len; i++) { + transform = typeof this._transforms[i] === 'function' ? this._transforms[i]() : this._transforms[i]; + outputStream.once('error', err => { + transform.emit('error', err); + }); + outputStream = outputStream.pipe(transform); + } + + // ensure terminating newline after possible user transforms + transform = new LastNewline(); + outputStream.once('error', err => { + transform.emit('error', err); + }); + outputStream = outputStream.pipe(transform); + + // dkim and stuff + for (let i = 0, len = this._processFuncs.length; i < len; i++) { + transform = this._processFuncs[i]; + outputStream = transform(outputStream); + } + + return outputStream; + } + + /** + * Appends a transform stream object to the transforms list. Final output + * is passed through this stream before exposing + * + * @param {Object} transform Read-Write stream + */ + transform(transform) { + this._transforms.push(transform); + } + + /** + * Appends a post process function. The functon is run after transforms and + * uses the following syntax + * + * processFunc(input) -> outputStream + * + * @param {Object} processFunc Read-Write stream + */ + processFunc(processFunc) { + this._processFuncs.push(processFunc); + } + + stream(outputStream, options, done) { + let transferEncoding = this.getTransferEncoding(); + let contentStream; + let localStream; + + // protect actual callback against multiple triggering + let returned = false; + let callback = err => { + if (returned) { + return; + } + returned = true; + done(err); + }; + + // for multipart nodes, push child nodes + // for content nodes end the stream + let finalize = () => { + let childId = 0; + let processChildNode = () => { + if (childId >= this.childNodes.length) { + outputStream.write('\r\n--' + this.boundary + '--\r\n'); + return callback(); + } + let child = this.childNodes[childId++]; + outputStream.write((childId > 1 ? '\r\n' : '') + '--' + this.boundary + '\r\n'); + child.stream(outputStream, options, err => { + if (err) { + return callback(err); + } + setImmediate(processChildNode); + }); + }; + + if (this.multipart) { + setImmediate(processChildNode); + } else { + return callback(); + } + }; + + // pushes node content + let sendContent = () => { + if (this.content) { + if (Object.prototype.toString.call(this.content) === '[object Error]') { + // content is already errored + return callback(this.content); + } + + if (typeof this.content.pipe === 'function') { + this.content.removeListener('error', this._contentErrorHandler); + this._contentErrorHandler = err => callback(err); + this.content.once('error', this._contentErrorHandler); + } + + let createStream = () => { + if (['quoted-printable', 'base64'].includes(transferEncoding)) { + contentStream = new (transferEncoding === 'base64' ? base64 : qp).Encoder(options); + + contentStream.pipe(outputStream, { + end: false + }); + contentStream.once('end', finalize); + contentStream.once('error', err => callback(err)); + + localStream = this._getStream(this.content); + localStream.pipe(contentStream); + } else { + // anything that is not QP or Base54 passes as-is + localStream = this._getStream(this.content); + localStream.pipe(outputStream, { + end: false + }); + localStream.once('end', finalize); + } + + localStream.once('error', err => callback(err)); + }; + + if (this.content._resolve) { + let chunks = []; + let chunklen = 0; + let returned = false; + let sourceStream = this._getStream(this.content); + sourceStream.on('error', err => { + if (returned) { + return; + } + returned = true; + callback(err); + }); + sourceStream.on('readable', () => { + let chunk; + while ((chunk = sourceStream.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + sourceStream.on('end', () => { + if (returned) { + return; + } + returned = true; + this.content._resolve = false; + this.content._resolvedValue = Buffer.concat(chunks, chunklen); + setImmediate(createStream); + }); + } else { + setImmediate(createStream); + } + return; + } else { + return setImmediate(finalize); + } + }; + + if (this._raw) { + setImmediate(() => { + if (Object.prototype.toString.call(this._raw) === '[object Error]') { + // content is already errored + return callback(this._raw); + } + + // remove default error handler (if set) + if (typeof this._raw.pipe === 'function') { + this._raw.removeListener('error', this._contentErrorHandler); + } + + let raw = this._getStream(this._raw); + raw.pipe(outputStream, { + end: false + }); + raw.on('error', err => outputStream.emit('error', err)); + raw.on('end', finalize); + }); + } else { + outputStream.write(this.buildHeaders() + '\r\n\r\n'); + setImmediate(sendContent); + } + } + + /** + * Sets envelope to be used instead of the generated one + * + * @return {Object} SMTP envelope in the form of {from: 'from@example.com', to: ['to@example.com']} + */ + setEnvelope(envelope) { + let list; + + this._envelope = { + from: false, + to: [] + }; + + if (envelope.from) { + list = []; + this._convertAddresses(this._parseAddresses(envelope.from), list); + list = list.filter(address => address && address.address); + if (list.length && list[0]) { + this._envelope.from = list[0].address; + } + } + ['to', 'cc', 'bcc'].forEach(key => { + if (envelope[key]) { + this._convertAddresses(this._parseAddresses(envelope[key]), this._envelope.to); + } + }); + + this._envelope.to = this._envelope.to.map(to => to.address).filter(address => address); + + let standardFields = ['to', 'cc', 'bcc', 'from']; + Object.keys(envelope).forEach(key => { + if (!standardFields.includes(key)) { + this._envelope[key] = envelope[key]; + } + }); + + return this; + } + + /** + * Generates and returns an object with parsed address fields + * + * @return {Object} Address object + */ + getAddresses() { + let addresses = {}; + + this._headers.forEach(header => { + let key = header.key.toLowerCase(); + if (['from', 'sender', 'reply-to', 'to', 'cc', 'bcc'].includes(key)) { + if (!Array.isArray(addresses[key])) { + addresses[key] = []; + } + + this._convertAddresses(this._parseAddresses(header.value), addresses[key]); + } + }); + + return addresses; + } + + /** + * Generates and returns SMTP envelope with the sender address and a list of recipients addresses + * + * @return {Object} SMTP envelope in the form of {from: 'from@example.com', to: ['to@example.com']} + */ + getEnvelope() { + if (this._envelope) { + return this._envelope; + } + + let envelope = { + from: false, + to: [] + }; + this._headers.forEach(header => { + let list = []; + if (header.key === 'From' || (!envelope.from && ['Reply-To', 'Sender'].includes(header.key))) { + this._convertAddresses(this._parseAddresses(header.value), list); + if (list.length && list[0]) { + envelope.from = list[0].address; + } + } else if (['To', 'Cc', 'Bcc'].includes(header.key)) { + this._convertAddresses(this._parseAddresses(header.value), envelope.to); + } + }); + + envelope.to = envelope.to.map(to => to.address); + + return envelope; + } + + /** + * Returns Message-Id value. If it does not exist, then creates one + * + * @return {String} Message-Id value + */ + messageId() { + let messageId = this.getHeader('Message-ID'); + // You really should define your own Message-Id field! + if (!messageId) { + messageId = this._generateMessageId(); + this.setHeader('Message-ID', messageId); + } + return messageId; + } + + /** + * Sets pregenerated content that will be used as the output of this node + * + * @param {String|Buffer|Stream} Raw MIME contents + */ + setRaw(raw) { + this._raw = raw; + + if (this._raw && typeof this._raw.pipe === 'function') { + // pre-stream handler. might be triggered if a stream is set as content + // and 'error' fires before anything is done with this stream + this._contentErrorHandler = err => { + this._raw.removeListener('error', this._contentErrorHandler); + this._raw = err; + }; + this._raw.once('error', this._contentErrorHandler); + } + + return this; + } + + /////// PRIVATE METHODS + + /** + * Detects and returns handle to a stream related with the content. + * + * @param {Mixed} content Node content + * @returns {Object} Stream object + */ + _getStream(content) { + let contentStream; + + if (content._resolvedValue) { + // pass string or buffer content as a stream + contentStream = new PassThrough(); + setImmediate(() => contentStream.end(content._resolvedValue)); + return contentStream; + } else if (typeof content.pipe === 'function') { + // assume as stream + return content; + } else if (content && typeof content.path === 'string' && !content.href) { + if (this.disableFileAccess) { + contentStream = new PassThrough(); + setImmediate(() => contentStream.emit('error', new Error('File access rejected for ' + content.path))); + return contentStream; + } + // read file + return fs.createReadStream(content.path); + } else if (content && typeof content.href === 'string') { + if (this.disableUrlAccess) { + contentStream = new PassThrough(); + setImmediate(() => contentStream.emit('error', new Error('Url access rejected for ' + content.href))); + return contentStream; + } + // fetch URL + return fetch(content.href); + } else { + // pass string or buffer content as a stream + contentStream = new PassThrough(); + setImmediate(() => contentStream.end(content || '')); + return contentStream; + } + } + + /** + * Parses addresses. Takes in a single address or an array or an + * array of address arrays (eg. To: [[first group], [second group],...]) + * + * @param {Mixed} addresses Addresses to be parsed + * @return {Array} An array of address objects + */ + _parseAddresses(addresses) { + return [].concat.apply( + [], + [].concat(addresses).map(address => { + // eslint-disable-line prefer-spread + if (address && address.address) { + address.address = this._normalizeAddress(address.address); + address.name = address.name || ''; + return [address]; + } + return addressparser(address); + }) + ); + } + + /** + * Normalizes a header key, uses Camel-Case form, except for uppercase MIME- + * + * @param {String} key Key to be normalized + * @return {String} key in Camel-Case form + */ + _normalizeHeaderKey(key) { + key = (key || '') + .toString() + // no newlines in keys + .replace(/\r?\n|\r/g, ' ') + .trim() + .toLowerCase() + // use uppercase words, except MIME + .replace(/^X-SMTPAPI$|^(MIME|DKIM)\b|^[a-z]|-(SPF|FBL|ID|MD5)$|-[a-z]/gi, c => c.toUpperCase()) + // special case + .replace(/^Content-Features$/i, 'Content-features'); + + return key; + } + + /** + * Checks if the content type is multipart and defines boundary if needed. + * Doesn't return anything, modifies object argument instead. + * + * @param {Object} structured Parsed header value for 'Content-Type' key + */ + _handleContentType(structured) { + this.contentType = structured.value.trim().toLowerCase(); + + this.multipart = this.contentType.split('/').reduce((prev, value) => (prev === 'multipart' ? value : false)); + + if (this.multipart) { + this.boundary = structured.params.boundary = structured.params.boundary || this.boundary || this._generateBoundary(); + } else { + this.boundary = false; + } + } + + /** + * Generates a multipart boundary value + * + * @return {String} boundary value + */ + _generateBoundary() { + return this.rootNode.boundaryPrefix + '-' + this.rootNode.baseBoundary + '-Part_' + this._nodeId; + } + + /** + * Encodes a header value for use in the generated rfc2822 email. + * + * @param {String} key Header key + * @param {String} value Header value + */ + _encodeHeaderValue(key, value) { + key = this._normalizeHeaderKey(key); + + switch (key) { + // Structured headers + case 'From': + case 'Sender': + case 'To': + case 'Cc': + case 'Bcc': + case 'Reply-To': + return this._convertAddresses(this._parseAddresses(value)); + + // values enclosed in <> + case 'Message-ID': + case 'In-Reply-To': + case 'Content-Id': + value = (value || '').toString().replace(/\r?\n|\r/g, ' '); + + if (value.charAt(0) !== '<') { + value = '<' + value; + } + + if (value.charAt(value.length - 1) !== '>') { + value = value + '>'; + } + return value; + + // space separated list of values enclosed in <> + case 'References': + value = [].concat + .apply( + [], + [].concat(value || '').map(elm => { + // eslint-disable-line prefer-spread + elm = (elm || '') + .toString() + .replace(/\r?\n|\r/g, ' ') + .trim(); + return elm.replace(/<[^>]*>/g, str => str.replace(/\s/g, '')).split(/\s+/); + }) + ) + .map(elm => { + if (elm.charAt(0) !== '<') { + elm = '<' + elm; + } + if (elm.charAt(elm.length - 1) !== '>') { + elm = elm + '>'; + } + return elm; + }); + + return value.join(' ').trim(); + + case 'Date': + if (Object.prototype.toString.call(value) === '[object Date]') { + return value.toUTCString().replace(/GMT/, '+0000'); + } + + value = (value || '').toString().replace(/\r?\n|\r/g, ' '); + return this._encodeWords(value); + + default: + value = (value || '').toString().replace(/\r?\n|\r/g, ' '); + // encodeWords only encodes if needed, otherwise the original string is returned + return this._encodeWords(value); + } + } + + /** + * Rebuilds address object using punycode and other adjustments + * + * @param {Array} addresses An array of address objects + * @param {Array} [uniqueList] An array to be populated with addresses + * @return {String} address string + */ + _convertAddresses(addresses, uniqueList) { + let values = []; + + uniqueList = uniqueList || []; + + [].concat(addresses || []).forEach(address => { + if (address.address) { + address.address = this._normalizeAddress(address.address); + + if (!address.name) { + values.push(address.address); + } else if (address.name) { + values.push(this._encodeAddressName(address.name) + ' <' + address.address + '>'); + } + + if (address.address) { + if (!uniqueList.filter(a => a.address === address.address).length) { + uniqueList.push(address); + } + } + } else if (address.group) { + values.push( + this._encodeAddressName(address.name) + ':' + (address.group.length ? this._convertAddresses(address.group, uniqueList) : '').trim() + ';' + ); + } + }); + + return values.join(', '); + } + + /** + * Normalizes an email address + * + * @param {Array} address An array of address objects + * @return {String} address string + */ + _normalizeAddress(address) { + address = (address || '').toString().trim(); + + let lastAt = address.lastIndexOf('@'); + if (lastAt < 0) { + // Bare username + return address; + } + let user = address.substr(0, lastAt); + let domain = address.substr(lastAt + 1); + + // Usernames are not touched and are kept as is even if these include unicode + // Domains are punycoded by default + // 'jõgeva.ee' will be converted to 'xn--jgeva-dua.ee' + // non-unicode domains are left as is + + return user + '@' + punycode.toASCII(domain.toLowerCase()); + } + + /** + * If needed, mime encodes the name part + * + * @param {String} name Name part of an address + * @returns {String} Mime word encoded string if needed + */ + _encodeAddressName(name) { + if (!/^[\w ']*$/.test(name)) { + if (/^[\x20-\x7e]*$/.test(name)) { + return '"' + name.replace(/([\\"])/g, '\\$1') + '"'; + } else { + return mimeFuncs.encodeWord(name, this._getTextEncoding(name), 52); + } + } + return name; + } + + /** + * If needed, mime encodes the name part + * + * @param {String} name Name part of an address + * @returns {String} Mime word encoded string if needed + */ + _encodeWords(value) { + // set encodeAll parameter to true even though it is against the recommendation of RFC2047, + // by default only words that include non-ascii should be converted into encoded words + // but some clients (eg. Zimbra) do not handle it properly and remove surrounding whitespace + return mimeFuncs.encodeWords(value, this._getTextEncoding(value), 52, true); + } + + /** + * Detects best mime encoding for a text value + * + * @param {String} value Value to check for + * @return {String} either 'Q' or 'B' + */ + _getTextEncoding(value) { + value = (value || '').toString(); + + let encoding = this.textEncoding; + let latinLen; + let nonLatinLen; + + if (!encoding) { + // count latin alphabet symbols and 8-bit range symbols + control symbols + // if there are more latin characters, then use quoted-printable + // encoding, otherwise use base64 + nonLatinLen = (value.match(/[\x00-\x08\x0B\x0C\x0E-\x1F\u0080-\uFFFF]/g) || []).length; // eslint-disable-line no-control-regex + latinLen = (value.match(/[a-z]/gi) || []).length; + // if there are more latin symbols than binary/unicode, then prefer Q, otherwise B + encoding = nonLatinLen < latinLen ? 'Q' : 'B'; + } + return encoding; + } + + /** + * Generates a message id + * + * @return {String} Random Message-ID value + */ + _generateMessageId() { + return ( + '<' + + [2, 2, 2, 6].reduce( + // crux to generate UUID-like random strings + (prev, len) => prev + '-' + crypto.randomBytes(len).toString('hex'), + crypto.randomBytes(4).toString('hex') + ) + + '@' + + // try to use the domain of the FROM address or fallback to server hostname + (this.getEnvelope().from || this.hostname || os.hostname() || 'localhost').split('@').pop() + + '>' + ); + } +} + +module.exports = MimeNode; diff --git a/node_modules/nodemailer/lib/mime-node/last-newline.js b/node_modules/nodemailer/lib/mime-node/last-newline.js new file mode 100644 index 0000000..5fcd057 --- /dev/null +++ b/node_modules/nodemailer/lib/mime-node/last-newline.js @@ -0,0 +1,33 @@ +'use strict'; + +const Transform = require('stream').Transform; + +class LastNewline extends Transform { + constructor() { + super(); + this.lastByte = false; + } + + _transform(chunk, encoding, done) { + if (chunk.length) { + this.lastByte = chunk[chunk.length - 1]; + } + + this.push(chunk); + done(); + } + + _flush(done) { + if (this.lastByte === 0x0a) { + return done(); + } + if (this.lastByte === 0x0d) { + this.push(Buffer.from('\n')); + return done(); + } + this.push(Buffer.from('\r\n')); + return done(); + } +} + +module.exports = LastNewline; diff --git a/node_modules/nodemailer/lib/nodemailer.js b/node_modules/nodemailer/lib/nodemailer.js new file mode 100644 index 0000000..1b17288 --- /dev/null +++ b/node_modules/nodemailer/lib/nodemailer.js @@ -0,0 +1,148 @@ +'use strict'; + +const Mailer = require('./mailer'); +const shared = require('./shared'); +const SMTPPool = require('./smtp-pool'); +const SMTPTransport = require('./smtp-transport'); +const SendmailTransport = require('./sendmail-transport'); +const StreamTransport = require('./stream-transport'); +const JSONTransport = require('./json-transport'); +const SESTransport = require('./ses-transport'); +const fetch = require('./fetch'); +const packageData = require('../package.json'); + +const ETHEREAL_API = (process.env.ETHEREAL_API || 'https://api.nodemailer.com').replace(/\/+$/, ''); +const ETHEREAL_WEB = (process.env.ETHEREAL_WEB || 'https://ethereal.email').replace(/\/+$/, ''); +const ETHEREAL_CACHE = ['true', 'yes', 'y', '1'].includes( + (process.env.ETHEREAL_CACHE || 'yes') + .toString() + .trim() + .toLowerCase() +); + +let testAccount = false; + +module.exports.createTransport = function(transporter, defaults) { + let urlConfig; + let options; + let mailer; + + if ( + // provided transporter is a configuration object, not transporter plugin + (typeof transporter === 'object' && typeof transporter.send !== 'function') || + // provided transporter looks like a connection url + (typeof transporter === 'string' && /^(smtps?|direct):/i.test(transporter)) + ) { + if ((urlConfig = typeof transporter === 'string' ? transporter : transporter.url)) { + // parse a configuration URL into configuration options + options = shared.parseConnectionUrl(urlConfig); + } else { + options = transporter; + } + + if (options.pool) { + transporter = new SMTPPool(options); + } else if (options.sendmail) { + transporter = new SendmailTransport(options); + } else if (options.streamTransport) { + transporter = new StreamTransport(options); + } else if (options.jsonTransport) { + transporter = new JSONTransport(options); + } else if (options.SES) { + transporter = new SESTransport(options); + } else { + transporter = new SMTPTransport(options); + } + } + + mailer = new Mailer(transporter, options, defaults); + + return mailer; +}; + +module.exports.createTestAccount = function(apiUrl, callback) { + let promise; + + if (!callback && typeof apiUrl === 'function') { + callback = apiUrl; + apiUrl = false; + } + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = shared.callbackPromise(resolve, reject); + }); + } + + if (ETHEREAL_CACHE && testAccount) { + setImmediate(() => callback(null, testAccount)); + return promise; + } + + apiUrl = apiUrl || ETHEREAL_API; + + let chunks = []; + let chunklen = 0; + + let req = fetch(apiUrl + '/user', { + contentType: 'application/json', + method: 'POST', + body: Buffer.from( + JSON.stringify({ + requestor: packageData.name, + version: packageData.version + }) + ) + }); + + req.on('readable', () => { + let chunk; + while ((chunk = req.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + + req.once('error', err => callback(err)); + + req.once('end', () => { + let res = Buffer.concat(chunks, chunklen); + let data; + let err; + try { + data = JSON.parse(res.toString()); + } catch (E) { + err = E; + } + if (err) { + return callback(err); + } + if (data.status !== 'success' || data.error) { + return callback(new Error(data.error || 'Request failed')); + } + delete data.status; + testAccount = data; + callback(null, testAccount); + }); + + return promise; +}; + +module.exports.getTestMessageUrl = function(info) { + if (!info || !info.response) { + return false; + } + + let infoProps = new Map(); + info.response.replace(/\[([^\]]+)\]$/, (m, props) => { + props.replace(/\b([A-Z0-9]+)=([^\s]+)/g, (m, key, value) => { + infoProps.set(key, value); + }); + }); + + if (infoProps.has('STATUS') && infoProps.has('MSGID')) { + return (testAccount.web || ETHEREAL_WEB) + '/message/' + infoProps.get('MSGID'); + } + + return false; +}; diff --git a/node_modules/nodemailer/lib/qp/index.js b/node_modules/nodemailer/lib/qp/index.js new file mode 100644 index 0000000..e2e1ab8 --- /dev/null +++ b/node_modules/nodemailer/lib/qp/index.js @@ -0,0 +1,219 @@ +'use strict'; + +const Transform = require('stream').Transform; + +/** + * Encodes a Buffer into a Quoted-Printable encoded string + * + * @param {Buffer} buffer Buffer to convert + * @returns {String} Quoted-Printable encoded string + */ +function encode(buffer) { + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer, 'utf-8'); + } + + // usable characters that do not need encoding + let ranges = [ + // https://tools.ietf.org/html/rfc2045#section-6.7 + [0x09], // + [0x0a], // + [0x0d], // + [0x20, 0x3c], // !"#$%&'()*+,-./0123456789:; + [0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} + ]; + let result = ''; + let ord; + + for (let i = 0, len = buffer.length; i < len; i++) { + ord = buffer[i]; + // if the char is in allowed range, then keep as is, unless it is a WS in the end of a line + if (checkRanges(ord, ranges) && !((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))) { + result += String.fromCharCode(ord); + continue; + } + result += '=' + (ord < 0x10 ? '0' : '') + ord.toString(16).toUpperCase(); + } + + return result; +} + +/** + * Adds soft line breaks to a Quoted-Printable string + * + * @param {String} str Quoted-Printable encoded string that might need line wrapping + * @param {Number} [lineLength=76] Maximum allowed length for a line + * @returns {String} Soft-wrapped Quoted-Printable encoded string + */ +function wrap(str, lineLength) { + str = (str || '').toString(); + lineLength = lineLength || 76; + + if (str.length <= lineLength) { + return str; + } + + let pos = 0; + let len = str.length; + let match, code, line; + let lineMargin = Math.floor(lineLength / 3); + let result = ''; + + // insert soft linebreaks where needed + while (pos < len) { + line = str.substr(pos, lineLength); + if ((match = line.match(/\r\n/))) { + line = line.substr(0, match.index + match[0].length); + result += line; + pos += line.length; + continue; + } + + if (line.substr(-1) === '\n') { + // nothing to change here + result += line; + pos += line.length; + continue; + } else if ((match = line.substr(-lineMargin).match(/\n.*?$/))) { + // truncate to nearest line break + line = line.substr(0, line.length - (match[0].length - 1)); + result += line; + pos += line.length; + continue; + } else if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) { + // truncate to nearest space + line = line.substr(0, line.length - (match[0].length - 1)); + } else if (line.match(/[=][\da-f]{0,2}$/i)) { + // push incomplete encoding sequences to the next line + if ((match = line.match(/[=][\da-f]{0,1}$/i))) { + line = line.substr(0, line.length - match[0].length); + } + + // ensure that utf-8 sequences are not split + while (line.length > 3 && line.length < len - pos && !line.match(/^(?:=[\da-f]{2}){1,4}$/i) && (match = line.match(/[=][\da-f]{2}$/gi))) { + code = parseInt(match[0].substr(1, 2), 16); + if (code < 128) { + break; + } + + line = line.substr(0, line.length - 3); + + if (code >= 0xc0) { + break; + } + } + } + + if (pos + line.length < len && line.substr(-1) !== '\n') { + if (line.length === lineLength && line.match(/[=][\da-f]{2}$/i)) { + line = line.substr(0, line.length - 3); + } else if (line.length === lineLength) { + line = line.substr(0, line.length - 1); + } + pos += line.length; + line += '=\r\n'; + } else { + pos += line.length; + } + + result += line; + } + + return result; +} + +/** + * Helper function to check if a number is inside provided ranges + * + * @param {Number} nr Number to check for + * @param {Array} ranges An Array of allowed values + * @returns {Boolean} True if the value was found inside allowed ranges, false otherwise + */ +function checkRanges(nr, ranges) { + for (let i = ranges.length - 1; i >= 0; i--) { + if (!ranges[i].length) { + continue; + } + if (ranges[i].length === 1 && nr === ranges[i][0]) { + return true; + } + if (ranges[i].length === 2 && nr >= ranges[i][0] && nr <= ranges[i][1]) { + return true; + } + } + return false; +} + +/** + * Creates a transform stream for encoding data to Quoted-Printable encoding + * + * @constructor + * @param {Object} options Stream options + * @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping + */ +class Encoder extends Transform { + constructor(options) { + super(); + + // init Transform + this.options = options || {}; + + if (this.options.lineLength !== false) { + this.options.lineLength = this.options.lineLength || 76; + } + + this._curLine = ''; + + this.inputBytes = 0; + this.outputBytes = 0; + } + + _transform(chunk, encoding, done) { + let qp; + + if (encoding !== 'buffer') { + chunk = Buffer.from(chunk, encoding); + } + + if (!chunk || !chunk.length) { + return done(); + } + + this.inputBytes += chunk.length; + + if (this.options.lineLength) { + qp = this._curLine + encode(chunk); + qp = wrap(qp, this.options.lineLength); + qp = qp.replace(/(^|\n)([^\n]*)$/, (match, lineBreak, lastLine) => { + this._curLine = lastLine; + return lineBreak; + }); + + if (qp) { + this.outputBytes += qp.length; + this.push(qp); + } + } else { + qp = encode(chunk); + this.outputBytes += qp.length; + this.push(qp, 'ascii'); + } + + done(); + } + + _flush(done) { + if (this._curLine) { + this.outputBytes += this._curLine.length; + this.push(this._curLine, 'ascii'); + } + done(); + } +} + +// expose to the world +module.exports = { + encode, + wrap, + Encoder +}; diff --git a/node_modules/nodemailer/lib/sendmail-transport/index.js b/node_modules/nodemailer/lib/sendmail-transport/index.js new file mode 100644 index 0000000..0e59221 --- /dev/null +++ b/node_modules/nodemailer/lib/sendmail-transport/index.js @@ -0,0 +1,208 @@ +'use strict'; + +const spawn = require('child_process').spawn; +const packageData = require('../../package.json'); +const LeWindows = require('./le-windows'); +const LeUnix = require('./le-unix'); +const shared = require('../shared'); + +/** + * Generates a Transport object for Sendmail + * + * Possible options can be the following: + * + * * **path** optional path to sendmail binary + * * **newline** either 'windows' or 'unix' + * * **args** an array of arguments for the sendmail binary + * + * @constructor + * @param {Object} optional config parameter for Sendmail + */ +class SendmailTransport { + constructor(options) { + options = options || {}; + + // use a reference to spawn for mocking purposes + this._spawn = spawn; + + this.options = options || {}; + + this.name = 'Sendmail'; + this.version = packageData.version; + + this.path = 'sendmail'; + this.args = false; + this.winbreak = false; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'sendmail' + }); + + if (options) { + if (typeof options === 'string') { + this.path = options; + } else if (typeof options === 'object') { + if (options.path) { + this.path = options.path; + } + if (Array.isArray(options.args)) { + this.args = options.args; + } + this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase()); + } + } + } + + /** + *

Compiles a mailcomposer message and forwards it to handler that sends it.

+ * + * @param {Object} emailMessage MailComposer object + * @param {Function} callback Callback function to run when the sending is completed + */ + send(mail, done) { + // Sendmail strips this header line by itself + mail.message.keepBcc = true; + + let envelope = mail.data.envelope || mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + let args; + let sendmail; + let returned; + let transform; + + if (this.args) { + // force -i to keep single dots + args = ['-i'].concat(this.args).concat(envelope.to); + } else { + args = ['-i'].concat(envelope.from ? ['-f', envelope.from] : []).concat(envelope.to); + } + + let callback = err => { + if (returned) { + // ignore any additional responses, already done + return; + } + returned = true; + if (typeof done === 'function') { + if (err) { + return done(err); + } else { + return done(null, { + envelope: mail.data.envelope || mail.message.getEnvelope(), + messageId, + response: 'Messages queued for delivery' + }); + } + } + }; + + try { + sendmail = this._spawn(this.path, args); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'spawn', + messageId + }, + 'Error occurred while spawning sendmail. %s', + E.message + ); + return callback(E); + } + + if (sendmail) { + sendmail.on('error', err => { + this.logger.error( + { + err, + tnx: 'spawn', + messageId + }, + 'Error occurred when sending message %s. %s', + messageId, + err.message + ); + callback(err); + }); + + sendmail.once('exit', code => { + if (!code) { + return callback(); + } + let err; + if (code === 127) { + err = new Error('Sendmail command not found, process exited with code ' + code); + } else { + err = new Error('Sendmail exited with code ' + code); + } + + this.logger.error( + { + err, + tnx: 'stdin', + messageId + }, + 'Error sending message %s to sendmail. %s', + messageId, + err.message + ); + callback(err); + }); + sendmail.once('close', callback); + + sendmail.stdin.on('error', err => { + this.logger.error( + { + err, + tnx: 'stdin', + messageId + }, + 'Error occurred when piping message %s to sendmail. %s', + messageId, + err.message + ); + callback(err); + }); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + this.logger.info( + { + tnx: 'send', + messageId + }, + 'Sending message %s to <%s>', + messageId, + recipients.join(', ') + ); + + transform = this.winbreak ? new LeWindows() : new LeUnix(); + let sourceStream = mail.message.createReadStream(); + + transform.once('error', err => { + this.logger.error( + { + err, + tnx: 'stdin', + messageId + }, + 'Error occurred when generating message %s. %s', + messageId, + err.message + ); + sendmail.kill('SIGINT'); // do not deliver the message + callback(err); + }); + + sourceStream.once('error', err => transform.emit('error', err)); + sourceStream.pipe(transform).pipe(sendmail.stdin); + } else { + return callback(new Error('sendmail was not found')); + } + } +} + +module.exports = SendmailTransport; diff --git a/node_modules/nodemailer/lib/sendmail-transport/le-unix.js b/node_modules/nodemailer/lib/sendmail-transport/le-unix.js new file mode 100644 index 0000000..5feacd3 --- /dev/null +++ b/node_modules/nodemailer/lib/sendmail-transport/le-unix.js @@ -0,0 +1,43 @@ +'use strict'; + +const stream = require('stream'); +const Transform = stream.Transform; + +/** + * Ensures that only is used for linebreaks + * + * @param {Object} options Stream options + */ +class LeWindows extends Transform { + constructor(options) { + super(options); + // init Transform + this.options = options || {}; + } + + /** + * Escapes dots + */ + _transform(chunk, encoding, done) { + let buf; + let lastPos = 0; + + for (let i = 0, len = chunk.length; i < len; i++) { + if (chunk[i] === 0x0d) { + // \n + buf = chunk.slice(lastPos, i); + lastPos = i + 1; + this.push(buf); + } + } + if (lastPos && lastPos < chunk.length) { + buf = chunk.slice(lastPos); + this.push(buf); + } else if (!lastPos) { + this.push(chunk); + } + done(); + } +} + +module.exports = LeWindows; diff --git a/node_modules/nodemailer/lib/sendmail-transport/le-windows.js b/node_modules/nodemailer/lib/sendmail-transport/le-windows.js new file mode 100644 index 0000000..b156a7c --- /dev/null +++ b/node_modules/nodemailer/lib/sendmail-transport/le-windows.js @@ -0,0 +1,52 @@ +'use strict'; + +const stream = require('stream'); +const Transform = stream.Transform; + +/** + * Ensures that only sequences are used for linebreaks + * + * @param {Object} options Stream options + */ +class LeWindows extends Transform { + constructor(options) { + super(options); + // init Transform + this.options = options || {}; + this.lastByte = false; + } + + /** + * Escapes dots + */ + _transform(chunk, encoding, done) { + let buf; + let lastPos = 0; + + for (let i = 0, len = chunk.length; i < len; i++) { + if (chunk[i] === 0x0a) { + // \n + if ((i && chunk[i - 1] !== 0x0d) || (!i && this.lastByte !== 0x0d)) { + if (i > lastPos) { + buf = chunk.slice(lastPos, i); + this.push(buf); + } + this.push(Buffer.from('\r\n')); + lastPos = i + 1; + } + } + } + + if (lastPos && lastPos < chunk.length) { + buf = chunk.slice(lastPos); + this.push(buf); + } else if (!lastPos) { + this.push(chunk); + } + + this.lastByte = chunk[chunk.length - 1]; + done(); + } +} + +module.exports = LeWindows; diff --git a/node_modules/nodemailer/lib/ses-transport/index.js b/node_modules/nodemailer/lib/ses-transport/index.js new file mode 100644 index 0000000..62901e0 --- /dev/null +++ b/node_modules/nodemailer/lib/ses-transport/index.js @@ -0,0 +1,312 @@ +'use strict'; + +const EventEmitter = require('events'); +const packageData = require('../../package.json'); +const shared = require('../shared'); +const LeWindows = require('../sendmail-transport/le-windows'); + +/** + * Generates a Transport object for AWS SES + * + * Possible options can be the following: + * + * * **sendingRate** optional Number specifying how many messages per second should be delivered to SES + * * **maxConnections** optional Number specifying max number of parallel connections to SES + * + * @constructor + * @param {Object} optional config parameter + */ +class SESTransport extends EventEmitter { + constructor(options) { + super(); + options = options || {}; + + this.options = options || {}; + this.ses = this.options.SES; + + this.name = 'SESTransport'; + this.version = packageData.version; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'ses-transport' + }); + + // parallel sending connections + this.maxConnections = Number(this.options.maxConnections) || Infinity; + this.connections = 0; + + // max messages per second + this.sendingRate = Number(this.options.sendingRate) || Infinity; + this.sendingRateTTL = null; + this.rateInterval = 1000; + this.rateMessages = []; + + this.pending = []; + + this.idling = true; + + setImmediate(() => { + if (this.idling) { + this.emit('idle'); + } + }); + } + + /** + * Schedules a sending of a message + * + * @param {Object} emailMessage MailComposer object + * @param {Function} callback Callback function to run when the sending is completed + */ + send(mail, callback) { + if (this.connections >= this.maxConnections) { + this.idling = false; + return this.pending.push({ + mail, + callback + }); + } + + if (!this._checkSendingRate()) { + this.idling = false; + return this.pending.push({ + mail, + callback + }); + } + + this._send(mail, (...args) => { + setImmediate(() => callback(...args)); + this._sent(); + }); + } + + _checkRatedQueue() { + if (this.connections >= this.maxConnections || !this._checkSendingRate()) { + return; + } + + if (!this.pending.length) { + if (!this.idling) { + this.idling = true; + this.emit('idle'); + } + return; + } + + let next = this.pending.shift(); + this._send(next.mail, (...args) => { + setImmediate(() => next.callback(...args)); + this._sent(); + }); + } + + _checkSendingRate() { + clearTimeout(this.sendingRateTTL); + + let now = Date.now(); + let oldest = false; + // delete older messages + for (let i = this.rateMessages.length - 1; i >= 0; i--) { + if (this.rateMessages[i].ts >= now - this.rateInterval && (!oldest || this.rateMessages[i].ts < oldest)) { + oldest = this.rateMessages[i].ts; + } + + if (this.rateMessages[i].ts < now - this.rateInterval && !this.rateMessages[i].pending) { + this.rateMessages.splice(i, 1); + } + } + + if (this.rateMessages.length < this.sendingRate) { + return true; + } + + let delay = Math.max(oldest + 1001, now + 20); + this.sendingRateTTL = setTimeout(() => this._checkRatedQueue(), now - delay); + + try { + this.sendingRateTTL.unref(); + } catch (E) { + // Ignore. Happens on envs with non-node timer implementation + } + + return false; + } + + _sent() { + this.connections--; + this._checkRatedQueue(); + } + + /** + * Returns true if there are free slots in the queue + */ + isIdle() { + return this.idling; + } + + /** + * Compiles a mailcomposer message and forwards it to SES + * + * @param {Object} emailMessage MailComposer object + * @param {Function} callback Callback function to run when the sending is completed + */ + _send(mail, callback) { + let statObject = { + ts: Date.now(), + pending: true + }; + this.connections++; + this.rateMessages.push(statObject); + + let envelope = mail.data.envelope || mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + this.logger.info( + { + tnx: 'send', + messageId + }, + 'Sending message %s to <%s>', + messageId, + recipients.join(', ') + ); + + let getRawMessage = next => { + // do not use Message-ID and Date in DKIM signature + if (!mail.data._dkim) { + mail.data._dkim = {}; + } + if (mail.data._dkim.skipFields && typeof mail.data._dkim.skipFields === 'string') { + mail.data._dkim.skipFields += ':date:message-id'; + } else { + mail.data._dkim.skipFields = 'date:message-id'; + } + + let sourceStream = mail.message.createReadStream(); + let stream = sourceStream.pipe(new LeWindows()); + let chunks = []; + let chunklen = 0; + + stream.on('readable', () => { + let chunk; + while ((chunk = stream.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + + sourceStream.once('error', err => stream.emit('error', err)); + + stream.once('error', err => { + next(err); + }); + + stream.once('end', () => next(null, Buffer.concat(chunks, chunklen))); + }; + + setImmediate(() => + getRawMessage((err, raw) => { + if (err) { + this.logger.error( + { + err, + tnx: 'send', + messageId + }, + 'Failed creating message for %s. %s', + messageId, + err.message + ); + statObject.pending = false; + return callback(err); + } + + let sesMessage = { + RawMessage: { + // required + Data: raw // required + }, + Source: envelope.from, + Destinations: envelope.to + }; + + Object.keys(mail.data.ses || {}).forEach(key => { + sesMessage[key] = mail.data.ses[key]; + }); + + this.ses.sendRawEmail(sesMessage, (err, data) => { + if (err) { + this.logger.error( + { + err, + tnx: 'send' + }, + 'Send error for %s: %s', + messageId, + err.message + ); + statObject.pending = false; + return callback(err); + } + + let region = (this.ses.config && this.ses.config.region) || 'us-east-1'; + if (region === 'us-east-1') { + region = 'email'; + } + + statObject.pending = false; + callback(null, { + envelope: { + from: envelope.from, + to: envelope.to + }, + messageId: '<' + data.MessageId + (!/@/.test(data.MessageId) ? '@' + region + '.amazonses.com' : '') + '>', + response: data.MessageId, + raw + }); + }); + }) + ); + } + + /** + * Verifies SES configuration + * + * @param {Function} callback Callback function + */ + verify(callback) { + let promise; + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = shared.callbackPromise(resolve, reject); + }); + } + + this.ses.sendRawEmail( + { + RawMessage: { + // required + Data: 'From: invalid@invalid\r\nTo: invalid@invalid\r\n Subject: Invalid\r\n\r\nInvalid' + }, + Source: 'invalid@invalid', + Destinations: ['invalid@invalid'] + }, + err => { + if (err && err.code !== 'InvalidParameterValue') { + return callback(err); + } + return callback(null, true); + } + ); + + return promise; + } +} + +module.exports = SESTransport; diff --git a/node_modules/nodemailer/lib/shared/index.js b/node_modules/nodemailer/lib/shared/index.js new file mode 100644 index 0000000..c5e88ee --- /dev/null +++ b/node_modules/nodemailer/lib/shared/index.js @@ -0,0 +1,387 @@ +/* eslint no-console: 0 */ + +'use strict'; + +const urllib = require('url'); +const util = require('util'); +const fs = require('fs'); +const fetch = require('../fetch'); + +/** + * Parses connection url to a structured configuration object + * + * @param {String} str Connection url + * @return {Object} Configuration object + */ +module.exports.parseConnectionUrl = str => { + str = str || ''; + let options = {}; + + [urllib.parse(str, true)].forEach(url => { + let auth; + + switch (url.protocol) { + case 'smtp:': + options.secure = false; + break; + case 'smtps:': + options.secure = true; + break; + case 'direct:': + options.direct = true; + break; + } + + if (!isNaN(url.port) && Number(url.port)) { + options.port = Number(url.port); + } + + if (url.hostname) { + options.host = url.hostname; + } + + if (url.auth) { + auth = url.auth.split(':'); + + if (!options.auth) { + options.auth = {}; + } + + options.auth.user = auth.shift(); + options.auth.pass = auth.join(':'); + } + + Object.keys(url.query || {}).forEach(key => { + let obj = options; + let lKey = key; + let value = url.query[key]; + + if (!isNaN(value)) { + value = Number(value); + } + + switch (value) { + case 'true': + value = true; + break; + case 'false': + value = false; + break; + } + + // tls is nested object + if (key.indexOf('tls.') === 0) { + lKey = key.substr(4); + if (!options.tls) { + options.tls = {}; + } + obj = options.tls; + } else if (key.indexOf('.') >= 0) { + // ignore nested properties besides tls + return; + } + + if (!(lKey in obj)) { + obj[lKey] = value; + } + }); + }); + + return options; +}; + +module.exports._logFunc = (logger, level, defaults, data, message, ...args) => { + let entry = {}; + + Object.keys(defaults || {}).forEach(key => { + if (key !== 'level') { + entry[key] = defaults[key]; + } + }); + + Object.keys(data || {}).forEach(key => { + if (key !== 'level') { + entry[key] = data[key]; + } + }); + + logger[level](entry, message, ...args); +}; + +/** + * Returns a bunyan-compatible logger interface. Uses either provided logger or + * creates a default console logger + * + * @param {Object} [options] Options object that might include 'logger' value + * @return {Object} bunyan compatible logger + */ +module.exports.getLogger = (options, defaults) => { + options = options || {}; + + let response = {}; + let levels = ['trace', 'debug', 'info', 'warn', 'error', 'fatal']; + + if (!options.logger) { + // use vanity logger + levels.forEach(level => { + response[level] = () => false; + }); + return response; + } + + let logger = options.logger; + + if (options.logger === true) { + // create console logger + logger = createDefaultLogger(levels); + } + + levels.forEach(level => { + response[level] = (data, message, ...args) => { + module.exports._logFunc(logger, level, defaults, data, message, ...args); + }; + }); + + return response; +}; + +/** + * Wrapper for creating a callback than either resolves or rejects a promise + * based on input + * + * @param {Function} resolve Function to run if callback is called + * @param {Function} reject Function to run if callback ends with an error + */ +module.exports.callbackPromise = (resolve, reject) => + function() { + let args = Array.from(arguments); + let err = args.shift(); + if (err) { + reject(err); + } else { + resolve(...args); + } + }; + +/** + * Resolves a String or a Buffer value for content value. Useful if the value + * is a Stream or a file or an URL. If the value is a Stream, overwrites + * the stream object with the resolved value (you can't stream a value twice). + * + * This is useful when you want to create a plugin that needs a content value, + * for example the `html` or `text` value as a String or a Buffer but not as + * a file path or an URL. + * + * @param {Object} data An object or an Array you want to resolve an element for + * @param {String|Number} key Property name or an Array index + * @param {Function} callback Callback function with (err, value) + */ +module.exports.resolveContent = (data, key, callback) => { + let promise; + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = module.exports.callbackPromise(resolve, reject); + }); + } + + let content = (data && data[key] && data[key].content) || data[key]; + let contentStream; + let encoding = ((typeof data[key] === 'object' && data[key].encoding) || 'utf8') + .toString() + .toLowerCase() + .replace(/[-_\s]/g, ''); + + if (!content) { + return callback(null, content); + } + + if (typeof content === 'object') { + if (typeof content.pipe === 'function') { + return resolveStream(content, (err, value) => { + if (err) { + return callback(err); + } + // we can't stream twice the same content, so we need + // to replace the stream object with the streaming result + data[key] = value; + callback(null, value); + }); + } else if (/^https?:\/\//i.test(content.path || content.href)) { + contentStream = fetch(content.path || content.href); + return resolveStream(contentStream, callback); + } else if (/^data:/i.test(content.path || content.href)) { + let parts = (content.path || content.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i); + if (!parts) { + return callback(null, Buffer.from(0)); + } + return callback(null, /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2]))); + } else if (content.path) { + return resolveStream(fs.createReadStream(content.path), callback); + } + } + + if (typeof data[key].content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) { + content = Buffer.from(data[key].content, encoding); + } + + // default action, return as is + setImmediate(() => callback(null, content)); + + return promise; +}; + +/** + * Copies properties from source objects to target objects + */ +module.exports.assign = function(/* target, ... sources */) { + let args = Array.from(arguments); + let target = args.shift() || {}; + + args.forEach(source => { + Object.keys(source || {}).forEach(key => { + if (['tls', 'auth'].includes(key) && source[key] && typeof source[key] === 'object') { + // tls and auth are special keys that need to be enumerated separately + // other objects are passed as is + if (!target[key]) { + // ensure that target has this key + target[key] = {}; + } + Object.keys(source[key]).forEach(subKey => { + target[key][subKey] = source[key][subKey]; + }); + } else { + target[key] = source[key]; + } + }); + }); + return target; +}; + +module.exports.encodeXText = str => { + // ! 0x21 + // + 0x2B + // = 0x3D + // ~ 0x7E + if (!/[^\x21-\x2A\x2C-\x3C\x3E-\x7E]/.test(str)) { + return str; + } + let buf = Buffer.from(str); + let result = ''; + for (let i = 0, len = buf.length; i < len; i++) { + let c = buf[i]; + if (c < 0x21 || c > 0x7e || c === 0x2b || c === 0x3d) { + result += '+' + (c < 0x10 ? '0' : '') + c.toString(16).toUpperCase(); + } else { + result += String.fromCharCode(c); + } + } + return result; +}; + +/** + * Streams a stream value into a Buffer + * + * @param {Object} stream Readable stream + * @param {Function} callback Callback function with (err, value) + */ +function resolveStream(stream, callback) { + let responded = false; + let chunks = []; + let chunklen = 0; + + stream.on('error', err => { + if (responded) { + return; + } + + responded = true; + callback(err); + }); + + stream.on('readable', () => { + let chunk; + while ((chunk = stream.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + + stream.on('end', () => { + if (responded) { + return; + } + responded = true; + + let value; + + try { + value = Buffer.concat(chunks, chunklen); + } catch (E) { + return callback(E); + } + callback(null, value); + }); +} + +/** + * Generates a bunyan-like logger that prints to console + * + * @returns {Object} Bunyan logger instance + */ +function createDefaultLogger(levels) { + let levelMaxLen = 0; + let levelNames = new Map(); + levels.forEach(level => { + if (level.length > levelMaxLen) { + levelMaxLen = level.length; + } + }); + + levels.forEach(level => { + let levelName = level.toUpperCase(); + if (levelName.length < levelMaxLen) { + levelName += ' '.repeat(levelMaxLen - levelName.length); + } + levelNames.set(level, levelName); + }); + + let print = (level, entry, message, ...args) => { + let prefix = ''; + if (entry) { + if (entry.tnx === 'server') { + prefix = 'S: '; + } else if (entry.tnx === 'client') { + prefix = 'C: '; + } + + if (entry.sid) { + prefix = '[' + entry.sid + '] ' + prefix; + } + + if (entry.cid) { + prefix = '[#' + entry.cid + '] ' + prefix; + } + } + + message = util.format(message, ...args); + message.split(/\r?\n/).forEach(line => { + console.log( + '[%s] %s %s', + new Date() + .toISOString() + .substr(0, 19) + .replace(/T/, ' '), + levelNames.get(level), + prefix + line + ); + }); + }; + + let logger = {}; + levels.forEach(level => { + logger[level] = print.bind(null, level); + }); + + return logger; +} diff --git a/node_modules/nodemailer/lib/smtp-connection/data-stream.js b/node_modules/nodemailer/lib/smtp-connection/data-stream.js new file mode 100644 index 0000000..5efa087 --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-connection/data-stream.js @@ -0,0 +1,108 @@ +'use strict'; + +const stream = require('stream'); +const Transform = stream.Transform; + +/** + * Escapes dots in the beginning of lines. Ends the stream with . + * Also makes sure that only sequences are used for linebreaks + * + * @param {Object} options Stream options + */ +class DataStream extends Transform { + constructor(options) { + super(options); + // init Transform + this.options = options || {}; + this._curLine = ''; + + this.inByteCount = 0; + this.outByteCount = 0; + this.lastByte = false; + } + + /** + * Escapes dots + */ + _transform(chunk, encoding, done) { + let chunks = []; + let chunklen = 0; + let i, + len, + lastPos = 0; + let buf; + + if (!chunk || !chunk.length) { + return done(); + } + + if (typeof chunk === 'string') { + chunk = Buffer.from(chunk); + } + + this.inByteCount += chunk.length; + + for (i = 0, len = chunk.length; i < len; i++) { + if (chunk[i] === 0x2e) { + // . + if ((i && chunk[i - 1] === 0x0a) || (!i && (!this.lastByte || this.lastByte === 0x0a))) { + buf = chunk.slice(lastPos, i + 1); + chunks.push(buf); + chunks.push(Buffer.from('.')); + chunklen += buf.length + 1; + lastPos = i + 1; + } + } else if (chunk[i] === 0x0a) { + // . + if ((i && chunk[i - 1] !== 0x0d) || (!i && this.lastByte !== 0x0d)) { + if (i > lastPos) { + buf = chunk.slice(lastPos, i); + chunks.push(buf); + chunklen += buf.length + 2; + } else { + chunklen += 2; + } + chunks.push(Buffer.from('\r\n')); + lastPos = i + 1; + } + } + } + + if (chunklen) { + // add last piece + if (lastPos < chunk.length) { + buf = chunk.slice(lastPos); + chunks.push(buf); + chunklen += buf.length; + } + + this.outByteCount += chunklen; + this.push(Buffer.concat(chunks, chunklen)); + } else { + this.outByteCount += chunk.length; + this.push(chunk); + } + + this.lastByte = chunk[chunk.length - 1]; + done(); + } + + /** + * Finalizes the stream with a dot on a single line + */ + _flush(done) { + let buf; + if (this.lastByte === 0x0a) { + buf = Buffer.from('.\r\n'); + } else if (this.lastByte === 0x0d) { + buf = Buffer.from('\n.\r\n'); + } else { + buf = Buffer.from('\r\n.\r\n'); + } + this.outByteCount += buf.length; + this.push(buf); + done(); + } +} + +module.exports = DataStream; diff --git a/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js b/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js new file mode 100644 index 0000000..efb2503 --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js @@ -0,0 +1,131 @@ +'use strict'; + +/** + * Minimal HTTP/S proxy client + */ + +const net = require('net'); +const tls = require('tls'); +const urllib = require('url'); + +/** + * Establishes proxied connection to destinationPort + * + * httpProxyClient("http://localhost:3128/", 80, "google.com", function(err, socket){ + * socket.write("GET / HTTP/1.0\r\n\r\n"); + * }); + * + * @param {String} proxyUrl proxy configuration, etg "http://proxy.host:3128/" + * @param {Number} destinationPort Port to open in destination host + * @param {String} destinationHost Destination hostname + * @param {Function} callback Callback to run with the rocket object once connection is established + */ +function httpProxyClient(proxyUrl, destinationPort, destinationHost, callback) { + let proxy = urllib.parse(proxyUrl); + + // create a socket connection to the proxy server + let options; + let connect; + let socket; + + options = { + host: proxy.hostname, + port: Number(proxy.port) ? Number(proxy.port) : proxy.protocol === 'https:' ? 443 : 80 + }; + + if (proxy.protocol === 'https:') { + // we can use untrusted proxies as long as we verify actual SMTP certificates + options.rejectUnauthorized = false; + connect = tls.connect.bind(tls); + } else { + connect = net.connect.bind(net); + } + + // Error harness for initial connection. Once connection is established, the responsibility + // to handle errors is passed to whoever uses this socket + let finished = false; + let tempSocketErr = function(err) { + if (finished) { + return; + } + finished = true; + try { + socket.destroy(); + } catch (E) { + // ignore + } + callback(err); + }; + + socket = connect(options, () => { + if (finished) { + return; + } + + let reqHeaders = { + Host: destinationHost + ':' + destinationPort, + Connection: 'close' + }; + if (proxy.auth) { + reqHeaders['Proxy-Authorization'] = 'Basic ' + Buffer.from(proxy.auth).toString('base64'); + } + + socket.write( + // HTTP method + 'CONNECT ' + + destinationHost + + ':' + + destinationPort + + ' HTTP/1.1\r\n' + + // HTTP request headers + Object.keys(reqHeaders) + .map(key => key + ': ' + reqHeaders[key]) + .join('\r\n') + + // End request + '\r\n\r\n' + ); + + let headers = ''; + let onSocketData = chunk => { + let match; + let remainder; + + if (finished) { + return; + } + + headers += chunk.toString('binary'); + if ((match = headers.match(/\r\n\r\n/))) { + socket.removeListener('data', onSocketData); + + remainder = headers.substr(match.index + match[0].length); + headers = headers.substr(0, match.index); + if (remainder) { + socket.unshift(Buffer.from(remainder, 'binary')); + } + + // proxy connection is now established + finished = true; + + // check response code + match = headers.match(/^HTTP\/\d+\.\d+ (\d+)/i); + if (!match || (match[1] || '').charAt(0) !== '2') { + try { + socket.destroy(); + } catch (E) { + // ignore + } + return callback(new Error('Invalid response from proxy' + ((match && ': ' + match[1]) || ''))); + } + + socket.removeListener('error', tempSocketErr); + return callback(null, socket); + } + }; + socket.on('data', onSocketData); + }); + + socket.once('error', tempSocketErr); +} + +module.exports = httpProxyClient; diff --git a/node_modules/nodemailer/lib/smtp-connection/index.js b/node_modules/nodemailer/lib/smtp-connection/index.js new file mode 100644 index 0000000..20a8feb --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-connection/index.js @@ -0,0 +1,1569 @@ +'use strict'; + +const packageInfo = require('../../package.json'); +const EventEmitter = require('events').EventEmitter; +const net = require('net'); +const tls = require('tls'); +const os = require('os'); +const crypto = require('crypto'); +const DataStream = require('./data-stream'); +const PassThrough = require('stream').PassThrough; +const shared = require('../shared'); + +// default timeout values in ms +const CONNECTION_TIMEOUT = 2 * 60 * 1000; // how much to wait for the connection to be established +const SOCKET_TIMEOUT = 10 * 60 * 1000; // how much to wait for socket inactivity before disconnecting the client +const GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is established but SMTP greeting is not receieved + +/** + * Generates a SMTP connection object + * + * Optional options object takes the following possible properties: + * + * * **port** - is the port to connect to (defaults to 587 or 465) + * * **host** - is the hostname or IP address to connect to (defaults to 'localhost') + * * **secure** - use SSL + * * **ignoreTLS** - ignore server support for STARTTLS + * * **requireTLS** - forces the client to use STARTTLS + * * **name** - the name of the client server + * * **localAddress** - outbound address to bind to (see: http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener) + * * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 10000) + * * **connectionTimeout** - how many milliseconds to wait for the connection to establish + * * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 1 hour) + * * **lmtp** - if true, uses LMTP instead of SMTP protocol + * * **logger** - bunyan compatible logger interface + * * **debug** - if true pass SMTP traffic to the logger + * * **tls** - options for createCredentials + * * **socket** - existing socket to use instead of creating a new one (see: http://nodejs.org/api/net.html#net_class_net_socket) + * * **secured** - boolean indicates that the provided socket has already been upgraded to tls + * + * @constructor + * @namespace SMTP Client module + * @param {Object} [options] Option properties + */ +class SMTPConnection extends EventEmitter { + constructor(options) { + super(options); + + this.id = crypto + .randomBytes(8) + .toString('base64') + .replace(/\W/g, ''); + this.stage = 'init'; + + this.options = options || {}; + + this.secureConnection = !!this.options.secure; + this.alreadySecured = !!this.options.secured; + + this.port = Number(this.options.port) || (this.secureConnection ? 465 : 587); + this.host = this.options.host || 'localhost'; + + if (typeof this.options.secure === 'undefined' && this.port === 465) { + // if secure option is not set but port is 465, then default to secure + this.secureConnection = true; + } + + this.name = this.options.name || this._getHostname(); + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'smtp-connection', + sid: this.id + }); + + /** + * Expose version nr, just for the reference + * @type {String} + */ + this.version = packageInfo.version; + + /** + * If true, then the user is authenticated + * @type {Boolean} + */ + this.authenticated = false; + + /** + * If set to true, this instance is no longer active + * @private + */ + this.destroyed = false; + + /** + * Defines if the current connection is secure or not. If not, + * STARTTLS can be used if available + * @private + */ + this.secure = !!this.secureConnection; + + /** + * Store incomplete messages coming from the server + * @private + */ + this._remainder = ''; + + /** + * Unprocessed responses from the server + * @type {Array} + */ + this._responseQueue = []; + + this.lastServerResponse = false; + + /** + * The socket connecting to the server + * @publick + */ + this._socket = false; + + /** + * Lists supported auth mechanisms + * @private + */ + this._supportedAuth = []; + + /** + * Includes current envelope (from, to) + * @private + */ + this._envelope = false; + + /** + * Lists supported extensions + * @private + */ + this._supportedExtensions = []; + + /** + * Defines the maximum allowed size for a single message + * @private + */ + this._maxAllowedSize = 0; + + /** + * Function queue to run if a data chunk comes from the server + * @private + */ + this._responseActions = []; + this._recipientQueue = []; + + /** + * Timeout variable for waiting the greeting + * @private + */ + this._greetingTimeout = false; + + /** + * Timeout variable for waiting the connection to start + * @private + */ + this._connectionTimeout = false; + + /** + * If the socket is deemed already closed + * @private + */ + this._destroyed = false; + + /** + * If the socket is already being closed + * @private + */ + this._closing = false; + } + + /** + * Creates a connection to a SMTP server and sets up connection + * listener + */ + connect(connectCallback) { + if (typeof connectCallback === 'function') { + this.once('connect', () => { + this.logger.debug( + { + tnx: 'smtp' + }, + 'SMTP handshake finished' + ); + connectCallback(); + }); + + const isDestroyedMessage = this._isDestroyedMessage('connect'); + if (isDestroyedMessage) { + return connectCallback(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'CONN')); + } + } + + let opts = { + port: this.port, + host: this.host + }; + + if (this.options.localAddress) { + opts.localAddress = this.options.localAddress; + } + + if (this.options.connection) { + // connection is already opened + this._socket = this.options.connection; + if (this.secureConnection && !this.alreadySecured) { + setImmediate(() => + this._upgradeConnection(err => { + if (err) { + this._onError(new Error('Error initiating TLS - ' + (err.message || err)), 'ETLS', false, 'CONN'); + return; + } + this._onConnect(); + }) + ); + } else { + setImmediate(() => this._onConnect()); + } + } else if (this.options.socket) { + // socket object is set up but not yet connected + this._socket = this.options.socket; + try { + this._socket.connect(this.port, this.host, () => { + this._socket.setKeepAlive(true); + this._onConnect(); + }); + } catch (E) { + return setImmediate(() => this._onError(E, 'ECONNECTION', false, 'CONN')); + } + } else if (this.secureConnection) { + // connect using tls + if (this.options.tls) { + Object.keys(this.options.tls).forEach(key => { + opts[key] = this.options.tls[key]; + }); + } + try { + this._socket = tls.connect(this.port, this.host, opts, () => { + this._socket.setKeepAlive(true); + this._onConnect(); + }); + } catch (E) { + return setImmediate(() => this._onError(E, 'ECONNECTION', false, 'CONN')); + } + } else { + // connect using plaintext + try { + this._socket = net.connect(opts, () => { + this._socket.setKeepAlive(true); + this._onConnect(); + }); + } catch (E) { + return setImmediate(() => this._onError(E, 'ECONNECTION', false, 'CONN')); + } + } + + this._connectionTimeout = setTimeout(() => { + this._onError('Connection timeout', 'ETIMEDOUT', false, 'CONN'); + }, this.options.connectionTimeout || CONNECTION_TIMEOUT); + + this._socket.on('error', err => { + this._onError(err, 'ECONNECTION', false, 'CONN'); + }); + } + + /** + * Sends QUIT + */ + quit() { + this._sendCommand('QUIT'); + this._responseActions.push(this.close); + } + + /** + * Closes the connection to the server + */ + close() { + clearTimeout(this._connectionTimeout); + clearTimeout(this._greetingTimeout); + this._responseActions = []; + + // allow to run this function only once + if (this._closing) { + return; + } + this._closing = true; + + let closeMethod = 'end'; + + if (this.stage === 'init') { + // Close the socket immediately when connection timed out + closeMethod = 'destroy'; + } + + this.logger.debug( + { + tnx: 'smtp' + }, + 'Closing connection to the server using "%s"', + closeMethod + ); + + let socket = (this._socket && this._socket.socket) || this._socket; + + if (socket && !socket.destroyed) { + try { + this._socket[closeMethod](); + } catch (E) { + // just ignore + } + } + + this._destroy(); + } + + /** + * Authenticate user + */ + login(authData, callback) { + const isDestroyedMessage = this._isDestroyedMessage('login'); + if (isDestroyedMessage) { + return callback(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'API')); + } + + this._auth = authData || {}; + + // Select SASL authentication method + this._authMethod = + (this._auth.method || '') + .toString() + .trim() + .toUpperCase() || false; + if (!this._authMethod && this._auth.oauth2 && !this._auth.credentials) { + this._authMethod = 'XOAUTH2'; + } else if (!this._authMethod || (this._authMethod === 'XOAUTH2' && !this._auth.oauth2)) { + // use first supported + this._authMethod = (this._supportedAuth[0] || 'PLAIN').toUpperCase().trim(); + } + + if (this._authMethod !== 'XOAUTH2' && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) { + if (this._auth.user && this._auth.pass) { + this._auth.credentials = { + user: this._auth.user, + pass: this._auth.pass + }; + } else { + return callback(this._formatError('Missing credentials for "' + this._authMethod + '"', 'EAUTH', false, 'API')); + } + } + + switch (this._authMethod) { + case 'XOAUTH2': + this._handleXOauth2Token(false, callback); + return; + case 'LOGIN': + this._responseActions.push(str => { + this._actionAUTH_LOGIN_USER(str, callback); + }); + this._sendCommand('AUTH LOGIN'); + return; + case 'PLAIN': + this._responseActions.push(str => { + this._actionAUTHComplete(str, callback); + }); + this._sendCommand( + 'AUTH PLAIN ' + + Buffer.from( + //this._auth.user+'\u0000'+ + '\u0000' + // skip authorization identity as it causes problems with some servers + this._auth.credentials.user + + '\u0000' + + this._auth.credentials.pass, + 'utf-8' + ).toString('base64') + ); + return; + case 'CRAM-MD5': + this._responseActions.push(str => { + this._actionAUTH_CRAM_MD5(str, callback); + }); + this._sendCommand('AUTH CRAM-MD5'); + return; + } + + return callback(this._formatError('Unknown authentication method "' + this._authMethod + '"', 'EAUTH', false, 'API')); + } + + /** + * Sends a message + * + * @param {Object} envelope Envelope object, {from: addr, to: [addr]} + * @param {Object} message String, Buffer or a Stream + * @param {Function} callback Callback to return once sending is completed + */ + send(envelope, message, done) { + if (!message) { + return done(this._formatError('Empty message', 'EMESSAGE', false, 'API')); + } + + const isDestroyedMessage = this._isDestroyedMessage('send message'); + if (isDestroyedMessage) { + return done(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'API')); + } + + // reject larger messages than allowed + if (this._maxAllowedSize && envelope.size > this._maxAllowedSize) { + return setImmediate(() => { + done(this._formatError('Message size larger than allowed ' + this._maxAllowedSize, 'EMESSAGE', false, 'MAIL FROM')); + }); + } + + // ensure that callback is only called once + let returned = false; + let callback = function() { + if (returned) { + return; + } + returned = true; + + done(...arguments); + }; + + if (typeof message.on === 'function') { + message.on('error', err => callback(this._formatError(err, 'ESTREAM', false, 'API'))); + } + + let startTime = Date.now(); + this._setEnvelope(envelope, (err, info) => { + if (err) { + return callback(err); + } + let envelopeTime = Date.now(); + let stream = this._createSendStream((err, str) => { + if (err) { + return callback(err); + } + + info.envelopeTime = envelopeTime - startTime; + info.messageTime = Date.now() - envelopeTime; + info.messageSize = stream.outByteCount; + info.response = str; + + return callback(null, info); + }); + if (typeof message.pipe === 'function') { + message.pipe(stream); + } else { + stream.write(message); + stream.end(); + } + }); + } + + /** + * Resets connection state + * + * @param {Function} callback Callback to return once connection is reset + */ + reset(callback) { + this._sendCommand('RSET'); + this._responseActions.push(str => { + if (str.charAt(0) !== '2') { + return callback(this._formatError('Could not reset session state. response=' + str, 'EPROTOCOL', str, 'RSET')); + } + this._envelope = false; + return callback(null, true); + }); + } + + /** + * Connection listener that is run when the connection to + * the server is opened + * + * @event + */ + _onConnect() { + clearTimeout(this._connectionTimeout); + + this.logger.info( + { + tnx: 'network', + localAddress: this._socket.localAddress, + localPort: this._socket.localPort, + remoteAddress: this._socket.remoteAddress, + remotePort: this._socket.remotePort + }, + '%s established to %s:%s', + this.secure ? 'Secure connection' : 'Connection', + this._socket.remoteAddress, + this._socket.remotePort + ); + + if (this._destroyed) { + // Connection was established after we already had canceled it + this.close(); + return; + } + + this.stage = 'connected'; + + // clear existing listeners for the socket + this._socket.removeAllListeners('data'); + this._socket.removeAllListeners('timeout'); + this._socket.removeAllListeners('close'); + this._socket.removeAllListeners('end'); + + this._socket.on('data', chunk => this._onData(chunk)); + this._socket.once('close', errored => this._onClose(errored)); + this._socket.once('end', () => this._onEnd()); + + this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT); + this._socket.on('timeout', () => this._onTimeout()); + + this._greetingTimeout = setTimeout(() => { + // if still waiting for greeting, give up + if (this._socket && !this._destroyed && this._responseActions[0] === this._actionGreeting) { + this._onError('Greeting never received', 'ETIMEDOUT', false, 'CONN'); + } + }, this.options.greetingTimeout || GREETING_TIMEOUT); + + this._responseActions.push(this._actionGreeting); + + // we have a 'data' listener set up so resume socket if it was paused + this._socket.resume(); + } + + /** + * 'data' listener for data coming from the server + * + * @event + * @param {Buffer} chunk Data chunk coming from the server + */ + _onData(chunk) { + if (this._destroyed || !chunk || !chunk.length) { + return; + } + + let data = (chunk || '').toString('binary'); + let lines = (this._remainder + data).split(/\r?\n/); + let lastline; + + this._remainder = lines.pop(); + + for (let i = 0, len = lines.length; i < len; i++) { + if (this._responseQueue.length) { + lastline = this._responseQueue[this._responseQueue.length - 1]; + if (/^\d+-/.test(lastline.split('\n').pop())) { + this._responseQueue[this._responseQueue.length - 1] += '\n' + lines[i]; + continue; + } + } + this._responseQueue.push(lines[i]); + } + + this._processResponse(); + } + + /** + * 'error' listener for the socket + * + * @event + * @param {Error} err Error object + * @param {String} type Error name + */ + _onError(err, type, data, command) { + clearTimeout(this._connectionTimeout); + clearTimeout(this._greetingTimeout); + + if (this._destroyed) { + // just ignore, already closed + // this might happen when a socket is canceled because of reached timeout + // but the socket timeout error itself receives only after + return; + } + + err = this._formatError(err, type, data, command); + + let entry = { + err + }; + if (type) { + entry.errorType = type; + } + if (data) { + entry.errorData = data; + } + if (command) { + entry.command = command; + } + + this.logger.error(data, err.message); + + this.emit('error', err); + this.close(); + } + + _formatError(message, type, response, command) { + let err; + + if (/Error\]$/i.test(Object.prototype.toString.call(message))) { + err = message; + } else { + err = new Error(message); + } + + if (type && type !== 'Error') { + err.code = type; + } + + if (response) { + err.response = response; + err.message += ': ' + response; + } + + let responseCode = (typeof response === 'string' && Number((response.match(/^\d+/) || [])[0])) || false; + if (responseCode) { + err.responseCode = responseCode; + } + + if (command) { + err.command = command; + } + + return err; + } + + /** + * 'close' listener for the socket + * + * @event + */ + _onClose() { + this.logger.info( + { + tnx: 'network' + }, + 'Connection closed' + ); + + if (this.upgrading && !this._destroyed) { + return this._onError(new Error('Connection closed unexpectedly'), 'ETLS', false, 'CONN'); + } else if (![this._actionGreeting, this.close].includes(this._responseActions[0]) && !this._destroyed) { + return this._onError(new Error('Connection closed unexpectedly'), 'ECONNECTION', false, 'CONN'); + } + + this._destroy(); + } + + /** + * 'end' listener for the socket + * + * @event + */ + _onEnd() { + this._destroy(); + } + + /** + * 'timeout' listener for the socket + * + * @event + */ + _onTimeout() { + return this._onError(new Error('Timeout'), 'ETIMEDOUT', false, 'CONN'); + } + + /** + * Destroys the client, emits 'end' + */ + _destroy() { + if (this._destroyed) { + return; + } + this._destroyed = true; + this.emit('end'); + } + + /** + * Upgrades the connection to TLS + * + * @param {Function} callback Callback function to run when the connection + * has been secured + */ + _upgradeConnection(callback) { + // do not remove all listeners or it breaks node v0.10 as there's + // apparently a 'finish' event set that would be cleared as well + + // we can safely keep 'error', 'end', 'close' etc. events + this._socket.removeAllListeners('data'); // incoming data is going to be gibberish from this point onwards + this._socket.removeAllListeners('timeout'); // timeout will be re-set for the new socket object + + let socketPlain = this._socket; + let opts = { + socket: this._socket, + host: this.host + }; + + Object.keys(this.options.tls || {}).forEach(key => { + opts[key] = this.options.tls[key]; + }); + + this.upgrading = true; + this._socket = tls.connect(opts, () => { + this.secure = true; + this.upgrading = false; + this._socket.on('data', chunk => this._onData(chunk)); + + socketPlain.removeAllListeners('close'); + socketPlain.removeAllListeners('end'); + + return callback(null, true); + }); + + this._socket.on('error', err => this._onError(err, 'ESOCKET', false, 'CONN')); + this._socket.once('close', errored => this._onClose(errored)); + this._socket.once('end', () => this._onEnd()); + + this._socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT); // 10 min. + this._socket.on('timeout', () => this._onTimeout()); + + // resume in case the socket was paused + socketPlain.resume(); + } + + /** + * Processes queued responses from the server + * + * @param {Boolean} force If true, ignores _processing flag + */ + _processResponse() { + if (!this._responseQueue.length) { + return false; + } + + let str = (this.lastServerResponse = (this._responseQueue.shift() || '').toString()); + + if (/^\d+-/.test(str.split('\n').pop())) { + // keep waiting for the final part of multiline response + return; + } + + if (this.options.debug || this.options.transactionLog) { + this.logger.debug( + { + tnx: 'server' + }, + str.replace(/\r?\n$/, '') + ); + } + + if (!str.trim()) { + // skip unexpected empty lines + setImmediate(() => this._processResponse(true)); + } + + let action = this._responseActions.shift(); + + if (typeof action === 'function') { + action.call(this, str); + setImmediate(() => this._processResponse(true)); + } else { + return this._onError(new Error('Unexpected Response'), 'EPROTOCOL', str, 'CONN'); + } + } + + /** + * Send a command to the server, append \r\n + * + * @param {String} str String to be sent to the server + */ + _sendCommand(str) { + if (this._destroyed) { + // Connection already closed, can't send any more data + return; + } + + if (this._socket.destroyed) { + return this.close(); + } + + if (this.options.debug || this.options.transactionLog) { + this.logger.debug( + { + tnx: 'client' + }, + (str || '').toString().replace(/\r?\n$/, '') + ); + } + + this._socket.write(Buffer.from(str + '\r\n', 'utf-8')); + } + + /** + * Initiates a new message by submitting envelope data, starting with + * MAIL FROM: command + * + * @param {Object} envelope Envelope object in the form of + * {from:'...', to:['...']} + * or + * {from:{address:'...',name:'...'}, to:[address:'...',name:'...']} + */ + _setEnvelope(envelope, callback) { + let args = []; + let useSmtpUtf8 = false; + + this._envelope = envelope || {}; + this._envelope.from = ((this._envelope.from && this._envelope.from.address) || this._envelope.from || '').toString().trim(); + + this._envelope.to = [].concat(this._envelope.to || []).map(to => ((to && to.address) || to || '').toString().trim()); + + if (!this._envelope.to.length) { + return callback(this._formatError('No recipients defined', 'EENVELOPE', false, 'API')); + } + + if (this._envelope.from && /[\r\n<>]/.test(this._envelope.from)) { + return callback(this._formatError('Invalid sender ' + JSON.stringify(this._envelope.from), 'EENVELOPE', false, 'API')); + } + + // check if the sender address uses only ASCII characters, + // otherwise require usage of SMTPUTF8 extension + if (/[\x80-\uFFFF]/.test(this._envelope.from)) { + useSmtpUtf8 = true; + } + + for (let i = 0, len = this._envelope.to.length; i < len; i++) { + if (!this._envelope.to[i] || /[\r\n<>]/.test(this._envelope.to[i])) { + return callback(this._formatError('Invalid recipient ' + JSON.stringify(this._envelope.to[i]), 'EENVELOPE', false, 'API')); + } + + // check if the recipients addresses use only ASCII characters, + // otherwise require usage of SMTPUTF8 extension + if (/[\x80-\uFFFF]/.test(this._envelope.to[i])) { + useSmtpUtf8 = true; + } + } + + // clone the recipients array for latter manipulation + this._envelope.rcptQueue = JSON.parse(JSON.stringify(this._envelope.to || [])); + this._envelope.rejected = []; + this._envelope.rejectedErrors = []; + this._envelope.accepted = []; + + if (this._envelope.dsn) { + try { + this._envelope.dsn = this._setDsnEnvelope(this._envelope.dsn); + } catch (err) { + return callback(this._formatError('Invalid DSN ' + err.message, 'EENVELOPE', false, 'API')); + } + } + + this._responseActions.push(str => { + this._actionMAIL(str, callback); + }); + + // If the server supports SMTPUTF8 and the envelope includes an internationalized + // email address then append SMTPUTF8 keyword to the MAIL FROM command + if (useSmtpUtf8 && this._supportedExtensions.includes('SMTPUTF8')) { + args.push('SMTPUTF8'); + this._usingSmtpUtf8 = true; + } + + // If the server supports 8BITMIME and the message might contain non-ascii bytes + // then append the 8BITMIME keyword to the MAIL FROM command + if (this._envelope.use8BitMime && this._supportedExtensions.includes('8BITMIME')) { + args.push('BODY=8BITMIME'); + this._using8BitMime = true; + } + + if (this._envelope.size && this._supportedExtensions.includes('SIZE')) { + args.push('SIZE=' + this._envelope.size); + } + + // If the server supports DSN and the envelope includes an DSN prop + // then append DSN params to the MAIL FROM command + if (this._envelope.dsn && this._supportedExtensions.includes('DSN')) { + if (this._envelope.dsn.ret) { + args.push('RET=' + shared.encodeXText(this._envelope.dsn.ret)); + } + if (this._envelope.dsn.envid) { + args.push('ENVID=' + shared.encodeXText(this._envelope.dsn.envid)); + } + } + + this._sendCommand('MAIL FROM:<' + this._envelope.from + '>' + (args.length ? ' ' + args.join(' ') : '')); + } + + _setDsnEnvelope(params) { + let ret = (params.ret || params.return || '').toString().toUpperCase() || null; + if (ret) { + switch (ret) { + case 'HDRS': + case 'HEADERS': + ret = 'HDRS'; + break; + case 'FULL': + case 'BODY': + ret = 'full'; + break; + } + } + + if (ret && !['FULL', 'HDRS'].includes(ret)) { + throw new Error('ret: ' + JSON.stringify(ret)); + } + + let envid = (params.envid || params.id || '').toString() || null; + + let notify = params.notify || null; + if (notify) { + if (typeof notify === 'string') { + notify = notify.split(','); + } + notify = notify.map(n => n.trim().toUpperCase()); + let validNotify = ['NEVER', 'SUCCESS', 'FAILURE', 'DELAY']; + let invaliNotify = notify.filter(n => !validNotify.includes(n)); + if (invaliNotify.length || (notify.length > 1 && notify.includes('NEVER'))) { + throw new Error('notify: ' + JSON.stringify(notify.join(','))); + } + notify = notify.join(','); + } + + let orcpt = (params.orcpt || params.recipient || '').toString() || null; + if (orcpt && orcpt.indexOf(';') < 0) { + orcpt = 'rfc822;' + orcpt; + } + + return { + ret, + envid, + notify, + orcpt + }; + } + + _getDsnRcptToArgs() { + let args = []; + // If the server supports DSN and the envelope includes an DSN prop + // then append DSN params to the RCPT TO command + if (this._envelope.dsn && this._supportedExtensions.includes('DSN')) { + if (this._envelope.dsn.notify) { + args.push('NOTIFY=' + shared.encodeXText(this._envelope.dsn.notify)); + } + if (this._envelope.dsn.orcpt) { + args.push('ORCPT=' + shared.encodeXText(this._envelope.dsn.orcpt)); + } + } + return args.length ? ' ' + args.join(' ') : ''; + } + + _createSendStream(callback) { + let dataStream = new DataStream(); + let logStream; + + if (this.options.lmtp) { + this._envelope.accepted.forEach((recipient, i) => { + let final = i === this._envelope.accepted.length - 1; + this._responseActions.push(str => { + this._actionLMTPStream(recipient, final, str, callback); + }); + }); + } else { + this._responseActions.push(str => { + this._actionSMTPStream(str, callback); + }); + } + + dataStream.pipe(this._socket, { + end: false + }); + + if (this.options.debug) { + logStream = new PassThrough(); + logStream.on('readable', () => { + let chunk; + while ((chunk = logStream.read())) { + this.logger.debug( + { + tnx: 'message' + }, + chunk.toString('binary').replace(/\r?\n$/, '') + ); + } + }); + dataStream.pipe(logStream); + } + + dataStream.once('end', () => { + this.logger.info( + { + tnx: 'message', + inByteCount: dataStream.inByteCount, + outByteCount: dataStream.outByteCount + }, + '<%s bytes encoded mime message (source size %s bytes)>', + dataStream.outByteCount, + dataStream.inByteCount + ); + }); + + return dataStream; + } + + /** ACTIONS **/ + + /** + * Will be run after the connection is created and the server sends + * a greeting. If the incoming message starts with 220 initiate + * SMTP session by sending EHLO command + * + * @param {String} str Message from the server + */ + _actionGreeting(str) { + clearTimeout(this._greetingTimeout); + + if (str.substr(0, 3) !== '220') { + this._onError(new Error('Invalid greeting. response=' + str), 'EPROTOCOL', str, 'CONN'); + return; + } + + if (this.options.lmtp) { + this._responseActions.push(this._actionLHLO); + this._sendCommand('LHLO ' + this.name); + } else { + this._responseActions.push(this._actionEHLO); + this._sendCommand('EHLO ' + this.name); + } + } + + /** + * Handles server response for LHLO command. If it yielded in + * error, emit 'error', otherwise treat this as an EHLO response + * + * @param {String} str Message from the server + */ + _actionLHLO(str) { + if (str.charAt(0) !== '2') { + this._onError(new Error('Invalid LHLO. response=' + str), 'EPROTOCOL', str, 'LHLO'); + return; + } + + this._actionEHLO(str); + } + + /** + * Handles server response for EHLO command. If it yielded in + * error, try HELO instead, otherwise initiate TLS negotiation + * if STARTTLS is supported by the server or move into the + * authentication phase. + * + * @param {String} str Message from the server + */ + _actionEHLO(str) { + let match; + + if (str.substr(0, 3) === '421') { + this._onError(new Error('Server terminates connection. response=' + str), 'ECONNECTION', str, 'EHLO'); + return; + } + + if (str.charAt(0) !== '2') { + if (this.options.requireTLS) { + this._onError(new Error('EHLO failed but HELO does not support required STARTTLS. response=' + str), 'ECONNECTION', str, 'EHLO'); + return; + } + + // Try HELO instead + this._responseActions.push(this._actionHELO); + this._sendCommand('HELO ' + this.name); + return; + } + + // Detect if the server supports STARTTLS + if (!this.secure && !this.options.ignoreTLS && (/[ -]STARTTLS\b/im.test(str) || this.options.requireTLS)) { + this._sendCommand('STARTTLS'); + this._responseActions.push(this._actionSTARTTLS); + return; + } + + // Detect if the server supports SMTPUTF8 + if (/[ -]SMTPUTF8\b/im.test(str)) { + this._supportedExtensions.push('SMTPUTF8'); + } + + // Detect if the server supports DSN + if (/[ -]DSN\b/im.test(str)) { + this._supportedExtensions.push('DSN'); + } + + // Detect if the server supports 8BITMIME + if (/[ -]8BITMIME\b/im.test(str)) { + this._supportedExtensions.push('8BITMIME'); + } + + // Detect if the server supports PIPELINING + if (/[ -]PIPELINING\b/im.test(str)) { + this._supportedExtensions.push('PIPELINING'); + } + + // Detect if the server supports PLAIN auth + if (/AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)PLAIN/i.test(str)) { + this._supportedAuth.push('PLAIN'); + } + + // Detect if the server supports LOGIN auth + if (/AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)LOGIN/i.test(str)) { + this._supportedAuth.push('LOGIN'); + } + + // Detect if the server supports CRAM-MD5 auth + if (/AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)CRAM-MD5/i.test(str)) { + this._supportedAuth.push('CRAM-MD5'); + } + + // Detect if the server supports XOAUTH2 auth + if (/AUTH(?:(\s+|=)[^\n]*\s+|\s+|=)XOAUTH2/i.test(str)) { + this._supportedAuth.push('XOAUTH2'); + } + + // Detect if the server supports SIZE extensions (and the max allowed size) + if ((match = str.match(/[ -]SIZE(?:[ \t]+(\d+))?/im))) { + this._supportedExtensions.push('SIZE'); + this._maxAllowedSize = Number(match[1]) || 0; + } + + this.emit('connect'); + } + + /** + * Handles server response for HELO command. If it yielded in + * error, emit 'error', otherwise move into the authentication phase. + * + * @param {String} str Message from the server + */ + _actionHELO(str) { + if (str.charAt(0) !== '2') { + this._onError(new Error('Invalid HELO. response=' + str), 'EPROTOCOL', str, 'HELO'); + return; + } + + this.emit('connect'); + } + + /** + * Handles server response for STARTTLS command. If there's an error + * try HELO instead, otherwise initiate TLS upgrade. If the upgrade + * succeedes restart the EHLO + * + * @param {String} str Message from the server + */ + _actionSTARTTLS(str) { + if (str.charAt(0) !== '2') { + if (this.options.opportunisticTLS) { + this.logger.info( + { + tnx: 'smtp' + }, + 'Failed STARTTLS upgrade, continuing unencrypted' + ); + return this.emit('connect'); + } + this._onError(new Error('Error upgrading connection with STARTTLS'), 'ETLS', str, 'STARTTLS'); + return; + } + + this._upgradeConnection((err, secured) => { + if (err) { + this._onError(new Error('Error initiating TLS - ' + (err.message || err)), 'ETLS', false, 'STARTTLS'); + return; + } + + this.logger.info( + { + tnx: 'smtp' + }, + 'Connection upgraded with STARTTLS' + ); + + if (secured) { + // restart session + if (this.options.lmtp) { + this._responseActions.push(this._actionLHLO); + this._sendCommand('LHLO ' + this.name); + } else { + this._responseActions.push(this._actionEHLO); + this._sendCommand('EHLO ' + this.name); + } + } else { + this.emit('connect'); + } + }); + } + + /** + * Handle the response for AUTH LOGIN command. We are expecting + * '334 VXNlcm5hbWU6' (base64 for 'Username:'). Data to be sent as + * response needs to be base64 encoded username. We do not need + * exact match but settle with 334 response in general as some + * hosts invalidly use a longer message than VXNlcm5hbWU6 + * + * @param {String} str Message from the server + */ + _actionAUTH_LOGIN_USER(str, callback) { + if (!/^334[ -]/.test(str)) { + // expecting '334 VXNlcm5hbWU6' + callback(this._formatError('Invalid login sequence while waiting for "334 VXNlcm5hbWU6"', 'EAUTH', str, 'AUTH LOGIN')); + return; + } + + this._responseActions.push(str => { + this._actionAUTH_LOGIN_PASS(str, callback); + }); + + this._sendCommand(Buffer.from(this._auth.credentials.user + '', 'utf-8').toString('base64')); + } + + /** + * Handle the response for AUTH CRAM-MD5 command. We are expecting + * '334 '. Data to be sent as response needs to be + * base64 decoded challenge string, MD5 hashed using the password as + * a HMAC key, prefixed by the username and a space, and finally all + * base64 encoded again. + * + * @param {String} str Message from the server + */ + _actionAUTH_CRAM_MD5(str, callback) { + let challengeMatch = str.match(/^334\s+(.+)$/); + let challengeString = ''; + + if (!challengeMatch) { + return callback(this._formatError('Invalid login sequence while waiting for server challenge string', 'EAUTH', str, 'AUTH CRAM-MD5')); + } else { + challengeString = challengeMatch[1]; + } + + // Decode from base64 + let base64decoded = Buffer.from(challengeString, 'base64').toString('ascii'), + hmac_md5 = crypto.createHmac('md5', this._auth.credentials.pass); + + hmac_md5.update(base64decoded); + + let hex_hmac = hmac_md5.digest('hex'); + let prepended = this._auth.credentials.user + ' ' + hex_hmac; + + this._responseActions.push(str => { + this._actionAUTH_CRAM_MD5_PASS(str, callback); + }); + + this._sendCommand(Buffer.from(prepended).toString('base64')); + } + + /** + * Handles the response to CRAM-MD5 authentication, if there's no error, + * the user can be considered logged in. Start waiting for a message to send + * + * @param {String} str Message from the server + */ + _actionAUTH_CRAM_MD5_PASS(str, callback) { + if (!str.match(/^235\s+/)) { + return callback(this._formatError('Invalid login sequence while waiting for "235"', 'EAUTH', str, 'AUTH CRAM-MD5')); + } + + this.logger.info( + { + tnx: 'smtp', + username: this._auth.user, + action: 'authenticated', + method: this._authMethod + }, + 'User %s authenticated', + JSON.stringify(this._auth.user) + ); + this.authenticated = true; + callback(null, true); + } + + /** + * Handle the response for AUTH LOGIN command. We are expecting + * '334 UGFzc3dvcmQ6' (base64 for 'Password:'). Data to be sent as + * response needs to be base64 encoded password. + * + * @param {String} str Message from the server + */ + _actionAUTH_LOGIN_PASS(str, callback) { + if (!/^334[ -]/.test(str)) { + // expecting '334 UGFzc3dvcmQ6' + return callback(this._formatError('Invalid login sequence while waiting for "334 UGFzc3dvcmQ6"', 'EAUTH', str, 'AUTH LOGIN')); + } + + this._responseActions.push(str => { + this._actionAUTHComplete(str, callback); + }); + + this._sendCommand(Buffer.from(this._auth.credentials.pass + '', 'utf-8').toString('base64')); + } + + /** + * Handles the response for authentication, if there's no error, + * the user can be considered logged in. Start waiting for a message to send + * + * @param {String} str Message from the server + */ + _actionAUTHComplete(str, isRetry, callback) { + if (!callback && typeof isRetry === 'function') { + callback = isRetry; + isRetry = false; + } + + if (str.substr(0, 3) === '334') { + this._responseActions.push(str => { + if (isRetry || this._authMethod !== 'XOAUTH2') { + this._actionAUTHComplete(str, true, callback); + } else { + // fetch a new OAuth2 access token + setImmediate(() => this._handleXOauth2Token(true, callback)); + } + }); + this._sendCommand(''); + return; + } + + if (str.charAt(0) !== '2') { + this.logger.info( + { + tnx: 'smtp', + username: this._auth.user, + action: 'authfail', + method: this._authMethod + }, + 'User %s failed to authenticate', + JSON.stringify(this._auth.user) + ); + return callback(this._formatError('Invalid login', 'EAUTH', str, 'AUTH ' + this._authMethod)); + } + + this.logger.info( + { + tnx: 'smtp', + username: this._auth.user, + action: 'authenticated', + method: this._authMethod + }, + 'User %s authenticated', + JSON.stringify(this._auth.user) + ); + this.authenticated = true; + callback(null, true); + } + + /** + * Handle response for a MAIL FROM: command + * + * @param {String} str Message from the server + */ + _actionMAIL(str, callback) { + let message, curRecipient; + if (Number(str.charAt(0)) !== 2) { + if (this._usingSmtpUtf8 && /^550 /.test(str) && /[\x80-\uFFFF]/.test(this._envelope.from)) { + message = 'Internationalized mailbox name not allowed'; + } else { + message = 'Mail command failed'; + } + return callback(this._formatError(message, 'EENVELOPE', str, 'MAIL FROM')); + } + + if (!this._envelope.rcptQueue.length) { + return callback(this._formatError('Can\x27t send mail - no recipients defined', 'EENVELOPE', false, 'API')); + } else { + this._recipientQueue = []; + + if (this._supportedExtensions.includes('PIPELINING')) { + while (this._envelope.rcptQueue.length) { + curRecipient = this._envelope.rcptQueue.shift(); + this._recipientQueue.push(curRecipient); + this._responseActions.push(str => { + this._actionRCPT(str, callback); + }); + this._sendCommand('RCPT TO:<' + curRecipient + '>' + this._getDsnRcptToArgs()); + } + } else { + curRecipient = this._envelope.rcptQueue.shift(); + this._recipientQueue.push(curRecipient); + this._responseActions.push(str => { + this._actionRCPT(str, callback); + }); + this._sendCommand('RCPT TO:<' + curRecipient + '>' + this._getDsnRcptToArgs()); + } + } + } + + /** + * Handle response for a RCPT TO: command + * + * @param {String} str Message from the server + */ + _actionRCPT(str, callback) { + let message, + err, + curRecipient = this._recipientQueue.shift(); + if (Number(str.charAt(0)) !== 2) { + // this is a soft error + if (this._usingSmtpUtf8 && /^553 /.test(str) && /[\x80-\uFFFF]/.test(curRecipient)) { + message = 'Internationalized mailbox name not allowed'; + } else { + message = 'Recipient command failed'; + } + this._envelope.rejected.push(curRecipient); + // store error for the failed recipient + err = this._formatError(message, 'EENVELOPE', str, 'RCPT TO'); + err.recipient = curRecipient; + this._envelope.rejectedErrors.push(err); + } else { + this._envelope.accepted.push(curRecipient); + } + + if (!this._envelope.rcptQueue.length && !this._recipientQueue.length) { + if (this._envelope.rejected.length < this._envelope.to.length) { + this._responseActions.push(str => { + this._actionDATA(str, callback); + }); + this._sendCommand('DATA'); + } else { + err = this._formatError('Can\x27t send mail - all recipients were rejected', 'EENVELOPE', str, 'RCPT TO'); + err.rejected = this._envelope.rejected; + err.rejectedErrors = this._envelope.rejectedErrors; + return callback(err); + } + } else if (this._envelope.rcptQueue.length) { + curRecipient = this._envelope.rcptQueue.shift(); + this._recipientQueue.push(curRecipient); + this._responseActions.push(str => { + this._actionRCPT(str, callback); + }); + this._sendCommand('RCPT TO:<' + curRecipient + '>' + this._getDsnRcptToArgs()); + } + } + + /** + * Handle response for a DATA command + * + * @param {String} str Message from the server + */ + _actionDATA(str, callback) { + // response should be 354 but according to this issue https://github.com/eleith/emailjs/issues/24 + // some servers might use 250 instead, so lets check for 2 or 3 as the first digit + if (!/^[23]/.test(str)) { + return callback(this._formatError('Data command failed', 'EENVELOPE', str, 'DATA')); + } + + let response = { + accepted: this._envelope.accepted, + rejected: this._envelope.rejected + }; + + if (this._envelope.rejectedErrors.length) { + response.rejectedErrors = this._envelope.rejectedErrors; + } + + callback(null, response); + } + + /** + * Handle response for a DATA stream when using SMTP + * We expect a single response that defines if the sending succeeded or failed + * + * @param {String} str Message from the server + */ + _actionSMTPStream(str, callback) { + if (Number(str.charAt(0)) !== 2) { + // Message failed + return callback(this._formatError('Message failed', 'EMESSAGE', str, 'DATA')); + } else { + // Message sent succesfully + return callback(null, str); + } + } + + /** + * Handle response for a DATA stream + * We expect a separate response for every recipient. All recipients can either + * succeed or fail separately + * + * @param {String} recipient The recipient this response applies to + * @param {Boolean} final Is this the final recipient? + * @param {String} str Message from the server + */ + _actionLMTPStream(recipient, final, str, callback) { + let err; + if (Number(str.charAt(0)) !== 2) { + // Message failed + err = this._formatError('Message failed for recipient ' + recipient, 'EMESSAGE', str, 'DATA'); + err.recipient = recipient; + this._envelope.rejected.push(recipient); + this._envelope.rejectedErrors.push(err); + for (let i = 0, len = this._envelope.accepted.length; i < len; i++) { + if (this._envelope.accepted[i] === recipient) { + this._envelope.accepted.splice(i, 1); + } + } + } + if (final) { + return callback(null, str); + } + } + + _handleXOauth2Token(isRetry, callback) { + this._auth.oauth2.getToken(isRetry, (err, accessToken) => { + if (err) { + this.logger.info( + { + tnx: 'smtp', + username: this._auth.user, + action: 'authfail', + method: this._authMethod + }, + 'User %s failed to authenticate', + JSON.stringify(this._auth.user) + ); + return callback(this._formatError(err, 'EAUTH', false, 'AUTH XOAUTH2')); + } + this._responseActions.push(str => { + this._actionAUTHComplete(str, isRetry, callback); + }); + this._sendCommand('AUTH XOAUTH2 ' + this._auth.oauth2.buildXOAuth2Token(accessToken)); + }); + } + + /** + * + * @param {string} command + * @private + */ + _isDestroyedMessage(command) { + if (this._destroyed) { + return 'Cannot ' + command + ' - smtp connection is already destroyed.'; + } + + if (this._socket) { + if (this._socket.destroyed) { + return 'Cannot ' + command + ' - smtp connection socket is already destroyed.'; + } + + if (!this._socket.writable) { + return 'Cannot ' + command + ' - smtp connection socket is already half-closed.'; + } + } + } + + _getHostname() { + // defaul hostname is machine hostname or [IP] + let defaultHostname = os.hostname() || ''; + + // ignore if not FQDN + if (defaultHostname.indexOf('.') < 0) { + defaultHostname = '[127.0.0.1]'; + } + + // IP should be enclosed in [] + if (defaultHostname.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)) { + defaultHostname = '[' + defaultHostname + ']'; + } + + return defaultHostname; + } +} + +module.exports = SMTPConnection; diff --git a/node_modules/nodemailer/lib/smtp-pool/index.js b/node_modules/nodemailer/lib/smtp-pool/index.js new file mode 100644 index 0000000..557351e --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-pool/index.js @@ -0,0 +1,600 @@ +'use strict'; + +const EventEmitter = require('events'); +const PoolResource = require('./pool-resource'); +const SMTPConnection = require('../smtp-connection'); +const wellKnown = require('../well-known'); +const shared = require('../shared'); +const packageData = require('../../package.json'); + +/** + * Creates a SMTP pool transport object for Nodemailer + * + * @constructor + * @param {Object} options SMTP Connection options + */ +class SMTPPool extends EventEmitter { + constructor(options) { + super(); + + options = options || {}; + if (typeof options === 'string') { + options = { + url: options + }; + } + + let urlData; + let service = options.service; + + if (typeof options.getSocket === 'function') { + this.getSocket = options.getSocket; + } + + if (options.url) { + urlData = shared.parseConnectionUrl(options.url); + service = service || urlData.service; + } + + this.options = shared.assign( + false, // create new object + options, // regular options + urlData, // url options + service && wellKnown(service) // wellknown options + ); + + this.options.maxConnections = this.options.maxConnections || 5; + this.options.maxMessages = this.options.maxMessages || 100; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'smtp-pool' + }); + + // temporary object + let connection = new SMTPConnection(this.options); + + this.name = 'SMTP (pool)'; + this.version = packageData.version + '[client:' + connection.version + ']'; + + this._rateLimit = { + counter: 0, + timeout: null, + waiting: [], + checkpoint: false, + delta: Number(this.options.rateDelta) || 1000, + limit: Number(this.options.rateLimit) || 0 + }; + this._closed = false; + this._queue = []; + this._connections = []; + this._connectionCounter = 0; + + this.idling = true; + + setImmediate(() => { + if (this.idling) { + this.emit('idle'); + } + }); + } + + /** + * Placeholder function for creating proxy sockets. This method immediatelly returns + * without a socket + * + * @param {Object} options Connection options + * @param {Function} callback Callback function to run with the socket keys + */ + getSocket(options, callback) { + // return immediatelly + return setImmediate(() => callback(null, false)); + } + + /** + * Queues an e-mail to be sent using the selected settings + * + * @param {Object} mail Mail object + * @param {Function} callback Callback function + */ + send(mail, callback) { + if (this._closed) { + return false; + } + + this._queue.push({ + mail, + callback + }); + + if (this.idling && this._queue.length >= this.options.maxConnections) { + this.idling = false; + } + + setImmediate(() => this._processMessages()); + + return true; + } + + /** + * Closes all connections in the pool. If there is a message being sent, the connection + * is closed later + */ + close() { + let connection; + let len = this._connections.length; + this._closed = true; + + // clear rate limit timer if it exists + clearTimeout(this._rateLimit.timeout); + + if (!len && !this._queue.length) { + return; + } + + // remove all available connections + for (let i = len - 1; i >= 0; i--) { + if (this._connections[i] && this._connections[i].available) { + connection = this._connections[i]; + connection.close(); + this.logger.info( + { + tnx: 'connection', + cid: connection.id, + action: 'removed' + }, + 'Connection #%s removed', + connection.id + ); + } + } + + if (len && !this._connections.length) { + this.logger.debug( + { + tnx: 'connection' + }, + 'All connections removed' + ); + } + + if (!this._queue.length) { + return; + } + + // make sure that entire queue would be cleaned + let invokeCallbacks = () => { + if (!this._queue.length) { + this.logger.debug( + { + tnx: 'connection' + }, + 'Pending queue entries cleared' + ); + return; + } + let entry = this._queue.shift(); + if (entry && typeof entry.callback === 'function') { + try { + entry.callback(new Error('Connection pool was closed')); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'callback', + cid: connection.id + }, + 'Callback error for #%s: %s', + connection.id, + E.message + ); + } + } + setImmediate(invokeCallbacks); + }; + setImmediate(invokeCallbacks); + } + + /** + * Check the queue and available connections. If there is a message to be sent and there is + * an available connection, then use this connection to send the mail + */ + _processMessages() { + let connection; + let i, len; + + // do nothing if already closed + if (this._closed) { + return; + } + + // do nothing if queue is empty + if (!this._queue.length) { + if (!this.idling) { + // no pending jobs + this.idling = true; + this.emit('idle'); + } + return; + } + + // find first available connection + for (i = 0, len = this._connections.length; i < len; i++) { + if (this._connections[i].available) { + connection = this._connections[i]; + break; + } + } + + if (!connection && this._connections.length < this.options.maxConnections) { + connection = this._createConnection(); + } + + if (!connection) { + // no more free connection slots available + this.idling = false; + return; + } + + // check if there is free space in the processing queue + if (!this.idling && this._queue.length < this.options.maxConnections) { + this.idling = true; + this.emit('idle'); + } + + let entry = (connection.queueEntry = this._queue.shift()); + entry.messageId = (connection.queueEntry.mail.message.getHeader('message-id') || '').replace(/[<>\s]/g, ''); + + connection.available = false; + + this.logger.debug( + { + tnx: 'pool', + cid: connection.id, + messageId: entry.messageId, + action: 'assign' + }, + 'Assigned message <%s> to #%s (%s)', + entry.messageId, + connection.id, + connection.messages + 1 + ); + + if (this._rateLimit.limit) { + this._rateLimit.counter++; + if (!this._rateLimit.checkpoint) { + this._rateLimit.checkpoint = Date.now(); + } + } + + connection.send(entry.mail, (err, info) => { + // only process callback if current handler is not changed + if (entry === connection.queueEntry) { + try { + entry.callback(err, info); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'callback', + cid: connection.id + }, + 'Callback error for #%s: %s', + connection.id, + E.message + ); + } + connection.queueEntry = false; + } + }); + } + + /** + * Creates a new pool resource + */ + _createConnection() { + let connection = new PoolResource(this); + + connection.id = ++this._connectionCounter; + + this.logger.info( + { + tnx: 'pool', + cid: connection.id, + action: 'conection' + }, + 'Created new pool resource #%s', + connection.id + ); + + // resource comes available + connection.on('available', () => { + this.logger.debug( + { + tnx: 'connection', + cid: connection.id, + action: 'available' + }, + 'Connection #%s became available', + connection.id + ); + + if (this._closed) { + // if already closed run close() that will remove this connections from connections list + this.close(); + } else { + // check if there's anything else to send + this._processMessages(); + } + }); + + // resource is terminated with an error + connection.once('error', err => { + if (err.code !== 'EMAXLIMIT') { + this.logger.error( + { + err, + tnx: 'pool', + cid: connection.id + }, + 'Pool Error for #%s: %s', + connection.id, + err.message + ); + } else { + this.logger.debug( + { + tnx: 'pool', + cid: connection.id, + action: 'maxlimit' + }, + 'Max messages limit exchausted for #%s', + connection.id + ); + } + + if (connection.queueEntry) { + try { + connection.queueEntry.callback(err); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'callback', + cid: connection.id + }, + 'Callback error for #%s: %s', + connection.id, + E.message + ); + } + connection.queueEntry = false; + } + + // remove the erroneus connection from connections list + this._removeConnection(connection); + + this._continueProcessing(); + }); + + connection.once('close', () => { + this.logger.info( + { + tnx: 'connection', + cid: connection.id, + action: 'closed' + }, + 'Connection #%s was closed', + connection.id + ); + + this._removeConnection(connection); + + if (connection.queueEntry) { + // If the connection closed when sending, add the message to the queue again + // Note that we must wait a bit.. because the callback of the 'error' handler might be called + // in the next event loop + setTimeout(() => { + if (connection.queueEntry) { + this.logger.debug( + { + tnx: 'pool', + cid: connection.id, + messageId: connection.queueEntry.messageId, + action: 'requeue' + }, + 'Re-queued message <%s> for #%s', + connection.queueEntry.messageId, + connection.id + ); + this._queue.unshift(connection.queueEntry); + connection.queueEntry = false; + } + this._continueProcessing(); + }, 50); + } else { + this._continueProcessing(); + } + }); + + this._connections.push(connection); + + return connection; + } + + /** + * Continue to process message if the pool hasn't closed + */ + _continueProcessing() { + if (this._closed) { + this.close(); + } else { + setTimeout(() => this._processMessages(), 100); + } + } + + /** + * Remove resource from pool + * + * @param {Object} connection The PoolResource to remove + */ + _removeConnection(connection) { + let index = this._connections.indexOf(connection); + + if (index !== -1) { + this._connections.splice(index, 1); + } + } + + /** + * Checks if connections have hit current rate limit and if so, queues the availability callback + * + * @param {Function} callback Callback function to run once rate limiter has been cleared + */ + _checkRateLimit(callback) { + if (!this._rateLimit.limit) { + return callback(); + } + + let now = Date.now(); + + if (this._rateLimit.counter < this._rateLimit.limit) { + return callback(); + } + + this._rateLimit.waiting.push(callback); + + if (this._rateLimit.checkpoint <= now - this._rateLimit.delta) { + return this._clearRateLimit(); + } else if (!this._rateLimit.timeout) { + this._rateLimit.timeout = setTimeout(() => this._clearRateLimit(), this._rateLimit.delta - (now - this._rateLimit.checkpoint)); + this._rateLimit.checkpoint = now; + } + } + + /** + * Clears current rate limit limitation and runs paused callback + */ + _clearRateLimit() { + clearTimeout(this._rateLimit.timeout); + this._rateLimit.timeout = null; + this._rateLimit.counter = 0; + this._rateLimit.checkpoint = false; + + // resume all paused connections + while (this._rateLimit.waiting.length) { + let cb = this._rateLimit.waiting.shift(); + setImmediate(cb); + } + } + + /** + * Returns true if there are free slots in the queue + */ + isIdle() { + return this.idling; + } + + /** + * Verifies SMTP configuration + * + * @param {Function} callback Callback function + */ + verify(callback) { + let promise; + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = shared.callbackPromise(resolve, reject); + }); + } + + let auth = new PoolResource(this).auth; + + this.getSocket(this.options, (err, socketOptions) => { + if (err) { + return callback(err); + } + + let options = this.options; + if (socketOptions && socketOptions.connection) { + this.logger.info( + { + tnx: 'proxy', + remoteAddress: socketOptions.connection.remoteAddress, + remotePort: socketOptions.connection.remotePort, + destHost: options.host || '', + destPort: options.port || '', + action: 'connected' + }, + 'Using proxied socket from %s:%s to %s:%s', + socketOptions.connection.remoteAddress, + socketOptions.connection.remotePort, + options.host || '', + options.port || '' + ); + options = shared.assign(false, options); + Object.keys(socketOptions).forEach(key => { + options[key] = socketOptions[key]; + }); + } + + let connection = new SMTPConnection(options); + let returned = false; + + connection.once('error', err => { + if (returned) { + return; + } + returned = true; + connection.close(); + return callback(err); + }); + + connection.once('end', () => { + if (returned) { + return; + } + returned = true; + return callback(new Error('Connection closed')); + }); + + let finalize = () => { + if (returned) { + return; + } + returned = true; + connection.quit(); + return callback(null, true); + }; + + connection.connect(() => { + if (returned) { + return; + } + + if (auth) { + connection.login(auth, err => { + if (returned) { + return; + } + + if (err) { + returned = true; + connection.close(); + return callback(err); + } + + finalize(); + }); + } else { + finalize(); + } + }); + }); + + return promise; + } +} + +// expose to the world +module.exports = SMTPPool; diff --git a/node_modules/nodemailer/lib/smtp-pool/pool-resource.js b/node_modules/nodemailer/lib/smtp-pool/pool-resource.js new file mode 100644 index 0000000..a3ca1a3 --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-pool/pool-resource.js @@ -0,0 +1,252 @@ +'use strict'; + +const SMTPConnection = require('../smtp-connection'); +const assign = require('../shared').assign; +const XOAuth2 = require('../xoauth2'); +const EventEmitter = require('events'); + +/** + * Creates an element for the pool + * + * @constructor + * @param {Object} options SMTPPool instance + */ +class PoolResource extends EventEmitter { + constructor(pool) { + super(); + + this.pool = pool; + this.options = pool.options; + this.logger = this.pool.logger; + + if (this.options.auth) { + switch ((this.options.auth.type || '').toString().toUpperCase()) { + case 'OAUTH2': { + let oauth2 = new XOAuth2(this.options.auth, this.logger); + oauth2.provisionCallback = (this.pool.mailer && this.pool.mailer.get('oauth2_provision_cb')) || oauth2.provisionCallback; + this.auth = { + type: 'OAUTH2', + user: this.options.auth.user, + oauth2, + method: 'XOAUTH2' + }; + oauth2.on('token', token => this.pool.mailer.emit('token', token)); + oauth2.on('error', err => this.emit('error', err)); + break; + } + default: + if (!this.options.auth.user && !this.options.auth.pass) { + break; + } + this.auth = { + type: 'LOGIN', + user: this.options.auth.user, + credentials: { + user: this.options.auth.user || '', + pass: this.options.auth.pass + }, + method: (this.options.auth.method || '').trim().toUpperCase() || false + }; + } + } + + this._connection = false; + this._connected = false; + + this.messages = 0; + this.available = true; + } + + /** + * Initiates a connection to the SMTP server + * + * @param {Function} callback Callback function to run once the connection is established or failed + */ + connect(callback) { + this.pool.getSocket(this.options, (err, socketOptions) => { + if (err) { + return callback(err); + } + + let returned = false; + let options = this.options; + if (socketOptions && socketOptions.connection) { + this.logger.info( + { + tnx: 'proxy', + remoteAddress: socketOptions.connection.remoteAddress, + remotePort: socketOptions.connection.remotePort, + destHost: options.host || '', + destPort: options.port || '', + action: 'connected' + }, + 'Using proxied socket from %s:%s to %s:%s', + socketOptions.connection.remoteAddress, + socketOptions.connection.remotePort, + options.host || '', + options.port || '' + ); + + options = assign(false, options); + Object.keys(socketOptions).forEach(key => { + options[key] = socketOptions[key]; + }); + } + + this.connection = new SMTPConnection(options); + + this.connection.once('error', err => { + this.emit('error', err); + if (returned) { + return; + } + returned = true; + return callback(err); + }); + + this.connection.once('end', () => { + this.close(); + if (returned) { + return; + } + returned = true; + + let timer = setTimeout(() => { + if (returned) { + return; + } + // still have not returned, this means we have an unexpected connection close + let err = new Error('Unexpected socket close'); + if (this.connection && this.connection._socket && this.connection._socket.upgrading) { + // starttls connection errors + err.code = 'ETLS'; + } + callback(err); + }, 1000); + + try { + timer.unref(); + } catch (E) { + // Ignore. Happens on envs with non-node timer implementation + } + }); + + this.connection.connect(() => { + if (returned) { + return; + } + + if (this.auth) { + this.connection.login(this.auth, err => { + if (returned) { + return; + } + returned = true; + + if (err) { + this.connection.close(); + this.emit('error', err); + return callback(err); + } + + this._connected = true; + callback(null, true); + }); + } else { + returned = true; + this._connected = true; + return callback(null, true); + } + }); + }); + } + + /** + * Sends an e-mail to be sent using the selected settings + * + * @param {Object} mail Mail object + * @param {Function} callback Callback function + */ + send(mail, callback) { + if (!this._connected) { + return this.connect(err => { + if (err) { + return callback(err); + } + return this.send(mail, callback); + }); + } + + let envelope = mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + this.logger.info( + { + tnx: 'send', + messageId, + cid: this.id + }, + 'Sending message %s using #%s to <%s>', + messageId, + this.id, + recipients.join(', ') + ); + + if (mail.data.dsn) { + envelope.dsn = mail.data.dsn; + } + + this.connection.send(envelope, mail.message.createReadStream(), (err, info) => { + this.messages++; + + if (err) { + this.connection.close(); + this.emit('error', err); + return callback(err); + } + + info.envelope = { + from: envelope.from, + to: envelope.to + }; + info.messageId = messageId; + + setImmediate(() => { + let err; + if (this.messages >= this.options.maxMessages) { + err = new Error('Resource exhausted'); + err.code = 'EMAXLIMIT'; + this.connection.close(); + this.emit('error', err); + } else { + this.pool._checkRateLimit(() => { + this.available = true; + this.emit('available'); + }); + } + }); + + callback(null, info); + }); + } + + /** + * Closes the connection + */ + close() { + this._connected = false; + if (this.auth && this.auth.oauth2) { + this.auth.oauth2.removeAllListeners(); + } + if (this.connection) { + this.connection.close(); + } + this.emit('close'); + } +} + +module.exports = PoolResource; diff --git a/node_modules/nodemailer/lib/smtp-transport/index.js b/node_modules/nodemailer/lib/smtp-transport/index.js new file mode 100644 index 0000000..646a47f --- /dev/null +++ b/node_modules/nodemailer/lib/smtp-transport/index.js @@ -0,0 +1,407 @@ +'use strict'; + +const EventEmitter = require('events'); +const SMTPConnection = require('../smtp-connection'); +const wellKnown = require('../well-known'); +const shared = require('../shared'); +const XOAuth2 = require('../xoauth2'); +const packageData = require('../../package.json'); + +/** + * Creates a SMTP transport object for Nodemailer + * + * @constructor + * @param {Object} options Connection options + */ +class SMTPTransport extends EventEmitter { + constructor(options) { + super(); + + options = options || {}; + if (typeof options === 'string') { + options = { + url: options + }; + } + + let urlData; + let service = options.service; + + if (typeof options.getSocket === 'function') { + this.getSocket = options.getSocket; + } + + if (options.url) { + urlData = shared.parseConnectionUrl(options.url); + service = service || urlData.service; + } + + this.options = shared.assign( + false, // create new object + options, // regular options + urlData, // url options + service && wellKnown(service) // wellknown options + ); + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'smtp-transport' + }); + + // temporary object + let connection = new SMTPConnection(this.options); + + this.name = 'SMTP'; + this.version = packageData.version + '[client:' + connection.version + ']'; + + if (this.options.auth) { + this.auth = this.getAuth({}); + } + } + + /** + * Placeholder function for creating proxy sockets. This method immediatelly returns + * without a socket + * + * @param {Object} options Connection options + * @param {Function} callback Callback function to run with the socket keys + */ + getSocket(options, callback) { + // return immediatelly + return setImmediate(() => callback(null, false)); + } + + getAuth(authOpts) { + if (!authOpts) { + return this.auth; + } + + let hasAuth = false; + let authData = {}; + + if (this.options.auth && typeof this.options.auth === 'object') { + Object.keys(this.options.auth).forEach(key => { + hasAuth = true; + authData[key] = this.options.auth[key]; + }); + } + + if (authOpts && typeof authOpts === 'object') { + Object.keys(authOpts).forEach(key => { + hasAuth = true; + authData[key] = authOpts[key]; + }); + } + + if (!hasAuth) { + return false; + } + + switch ((authData.type || '').toString().toUpperCase()) { + case 'OAUTH2': { + if (!authData.service && !authData.user) { + return false; + } + let oauth2 = new XOAuth2(authData, this.logger); + oauth2.provisionCallback = (this.mailer && this.mailer.get('oauth2_provision_cb')) || oauth2.provisionCallback; + oauth2.on('token', token => this.mailer.emit('token', token)); + oauth2.on('error', err => this.emit('error', err)); + return { + type: 'OAUTH2', + user: authData.user, + oauth2, + method: 'XOAUTH2' + }; + } + default: + return { + type: 'LOGIN', + user: authData.user, + credentials: { + user: authData.user || '', + pass: authData.pass + }, + method: (authData.method || '').trim().toUpperCase() || false + }; + } + } + + /** + * Sends an e-mail using the selected settings + * + * @param {Object} mail Mail object + * @param {Function} callback Callback function + */ + send(mail, callback) { + this.getSocket(this.options, (err, socketOptions) => { + if (err) { + return callback(err); + } + + let returned = false; + let options = this.options; + if (socketOptions && socketOptions.connection) { + this.logger.info( + { + tnx: 'proxy', + remoteAddress: socketOptions.connection.remoteAddress, + remotePort: socketOptions.connection.remotePort, + destHost: options.host || '', + destPort: options.port || '', + action: 'connected' + }, + 'Using proxied socket from %s:%s to %s:%s', + socketOptions.connection.remoteAddress, + socketOptions.connection.remotePort, + options.host || '', + options.port || '' + ); + + // only copy options if we need to modify it + options = shared.assign(false, options); + Object.keys(socketOptions).forEach(key => { + options[key] = socketOptions[key]; + }); + } + + let connection = new SMTPConnection(options); + + connection.once('error', err => { + if (returned) { + return; + } + returned = true; + connection.close(); + return callback(err); + }); + + connection.once('end', () => { + if (returned) { + return; + } + + let timer = setTimeout(() => { + if (returned) { + return; + } + returned = true; + // still have not returned, this means we have an unexpected connection close + let err = new Error('Unexpected socket close'); + if (connection && connection._socket && connection._socket.upgrading) { + // starttls connection errors + err.code = 'ETLS'; + } + callback(err); + }, 1000); + + try { + timer.unref(); + } catch (E) { + // Ignore. Happens on envs with non-node timer implementation + } + }); + + let sendMessage = () => { + let envelope = mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + + if (mail.data.dsn) { + envelope.dsn = mail.data.dsn; + } + + this.logger.info( + { + tnx: 'send', + messageId + }, + 'Sending message %s to <%s>', + messageId, + recipients.join(', ') + ); + + connection.send(envelope, mail.message.createReadStream(), (err, info) => { + returned = true; + connection.close(); + if (err) { + this.logger.error( + { + err, + tnx: 'send' + }, + 'Send error for %s: %s', + messageId, + err.message + ); + return callback(err); + } + info.envelope = { + from: envelope.from, + to: envelope.to + }; + info.messageId = messageId; + try { + return callback(null, info); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'callback' + }, + 'Callback error for %s: %s', + messageId, + E.message + ); + } + }); + }; + + connection.connect(() => { + if (returned) { + return; + } + + let auth = this.getAuth(mail.data.auth); + + if (auth) { + connection.login(auth, err => { + if (auth && auth !== this.auth && auth.oauth2) { + auth.oauth2.removeAllListeners(); + } + if (returned) { + return; + } + + if (err) { + returned = true; + connection.close(); + return callback(err); + } + + sendMessage(); + }); + } else { + sendMessage(); + } + }); + }); + } + + /** + * Verifies SMTP configuration + * + * @param {Function} callback Callback function + */ + verify(callback) { + let promise; + + if (!callback && typeof Promise === 'function') { + promise = new Promise((resolve, reject) => { + callback = shared.callbackPromise(resolve, reject); + }); + } + + this.getSocket(this.options, (err, socketOptions) => { + if (err) { + return callback(err); + } + + let options = this.options; + if (socketOptions && socketOptions.connection) { + this.logger.info( + { + tnx: 'proxy', + remoteAddress: socketOptions.connection.remoteAddress, + remotePort: socketOptions.connection.remotePort, + destHost: options.host || '', + destPort: options.port || '', + action: 'connected' + }, + 'Using proxied socket from %s:%s to %s:%s', + socketOptions.connection.remoteAddress, + socketOptions.connection.remotePort, + options.host || '', + options.port || '' + ); + + options = shared.assign(false, options); + Object.keys(socketOptions).forEach(key => { + options[key] = socketOptions[key]; + }); + } + + let connection = new SMTPConnection(options); + let returned = false; + + connection.once('error', err => { + if (returned) { + return; + } + returned = true; + connection.close(); + return callback(err); + }); + + connection.once('end', () => { + if (returned) { + return; + } + returned = true; + return callback(new Error('Connection closed')); + }); + + let finalize = () => { + if (returned) { + return; + } + returned = true; + connection.quit(); + return callback(null, true); + }; + + connection.connect(() => { + if (returned) { + return; + } + + let authData = this.getAuth({}); + + if (authData) { + connection.login(authData, err => { + if (returned) { + return; + } + + if (err) { + returned = true; + connection.close(); + return callback(err); + } + + finalize(); + }); + } else { + finalize(); + } + }); + }); + + return promise; + } + + /** + * Releases resources + */ + close() { + if (this.auth && this.auth.oauth2) { + this.auth.oauth2.removeAllListeners(); + } + this.emit('close'); + } +} + +// expose to the world +module.exports = SMTPTransport; diff --git a/node_modules/nodemailer/lib/stream-transport/index.js b/node_modules/nodemailer/lib/stream-transport/index.js new file mode 100644 index 0000000..a39fac4 --- /dev/null +++ b/node_modules/nodemailer/lib/stream-transport/index.js @@ -0,0 +1,142 @@ +'use strict'; + +const packageData = require('../../package.json'); +const shared = require('../shared'); +const LeWindows = require('../sendmail-transport/le-windows'); +const LeUnix = require('../sendmail-transport/le-unix'); + +/** + * Generates a Transport object for streaming + * + * Possible options can be the following: + * + * * **buffer** if true, then returns the message as a Buffer object instead of a stream + * * **newline** either 'windows' or 'unix' + * + * @constructor + * @param {Object} optional config parameter + */ +class StreamTransport { + constructor(options) { + options = options || {}; + + this.options = options || {}; + + this.name = 'StreamTransport'; + this.version = packageData.version; + + this.logger = shared.getLogger(this.options, { + component: this.options.component || 'stream-transport' + }); + + this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase()); + } + + /** + * Compiles a mailcomposer message and forwards it to handler that sends it + * + * @param {Object} emailMessage MailComposer object + * @param {Function} callback Callback function to run when the sending is completed + */ + send(mail, done) { + // We probably need this in the output + mail.message.keepBcc = true; + + let envelope = mail.data.envelope || mail.message.getEnvelope(); + let messageId = mail.message.messageId(); + + let recipients = [].concat(envelope.to || []); + if (recipients.length > 3) { + recipients.push('...and ' + recipients.splice(2).length + ' more'); + } + this.logger.info( + { + tnx: 'send', + messageId + }, + 'Sending message %s to <%s> using %s line breaks', + messageId, + recipients.join(', '), + this.winbreak ? '' : '' + ); + + setImmediate(() => { + let sourceStream; + let stream; + let transform; + + try { + transform = this.winbreak ? new LeWindows() : new LeUnix(); + sourceStream = mail.message.createReadStream(); + stream = sourceStream.pipe(transform); + sourceStream.on('error', err => stream.emit('error', err)); + } catch (E) { + this.logger.error( + { + err: E, + tnx: 'send', + messageId + }, + 'Creating send stream failed for %s. %s', + messageId, + E.message + ); + return done(E); + } + + if (!this.options.buffer) { + stream.once('error', err => { + this.logger.error( + { + err, + tnx: 'send', + messageId + }, + 'Failed creating message for %s. %s', + messageId, + err.message + ); + }); + return done(null, { + envelope: mail.data.envelope || mail.message.getEnvelope(), + messageId, + message: stream + }); + } + + let chunks = []; + let chunklen = 0; + stream.on('readable', () => { + let chunk; + while ((chunk = stream.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + + stream.once('error', err => { + this.logger.error( + { + err, + tnx: 'send', + messageId + }, + 'Failed creating message for %s. %s', + messageId, + err.message + ); + return done(err); + }); + + stream.on('end', () => + done(null, { + envelope: mail.data.envelope || mail.message.getEnvelope(), + messageId, + message: Buffer.concat(chunks, chunklen) + }) + ); + }); + } +} + +module.exports = StreamTransport; diff --git a/node_modules/nodemailer/lib/well-known/index.js b/node_modules/nodemailer/lib/well-known/index.js new file mode 100644 index 0000000..ca4c537 --- /dev/null +++ b/node_modules/nodemailer/lib/well-known/index.js @@ -0,0 +1,47 @@ +'use strict'; + +const services = require('./services.json'); +const normalized = {}; + +Object.keys(services).forEach(key => { + let service = services[key]; + + normalized[normalizeKey(key)] = normalizeService(service); + + [].concat(service.aliases || []).forEach(alias => { + normalized[normalizeKey(alias)] = normalizeService(service); + }); + + [].concat(service.domains || []).forEach(domain => { + normalized[normalizeKey(domain)] = normalizeService(service); + }); +}); + +function normalizeKey(key) { + return key.replace(/[^a-zA-Z0-9.-]/g, '').toLowerCase(); +} + +function normalizeService(service) { + let filter = ['domains', 'aliases']; + let response = {}; + + Object.keys(service).forEach(key => { + if (filter.indexOf(key) < 0) { + response[key] = service[key]; + } + }); + + return response; +} + +/** + * Resolves SMTP config for given key. Key can be a name (like 'Gmail'), alias (like 'Google Mail') or + * an email address (like 'test@googlemail.com'). + * + * @param {String} key [description] + * @returns {Object} SMTP config or false if not found + */ +module.exports = function(key) { + key = normalizeKey(key.split('@').pop()); + return normalized[key] || false; +}; diff --git a/node_modules/nodemailer/lib/well-known/services.json b/node_modules/nodemailer/lib/well-known/services.json new file mode 100644 index 0000000..fec47eb --- /dev/null +++ b/node_modules/nodemailer/lib/well-known/services.json @@ -0,0 +1,265 @@ +{ + "1und1": { + "host": "smtp.1und1.de", + "port": 465, + "secure": true, + "authMethod": "LOGIN" + }, + + "AOL": { + "domains": ["aol.com"], + "host": "smtp.aol.com", + "port": 587 + }, + + "DebugMail": { + "host": "debugmail.io", + "port": 25 + }, + + "DynectEmail": { + "aliases": ["Dynect"], + "host": "smtp.dynect.net", + "port": 25 + }, + + "FastMail": { + "domains": ["fastmail.fm"], + "host": "smtp.fastmail.com", + "port": 465, + "secure": true + }, + + "GandiMail": { + "aliases": ["Gandi", "Gandi Mail"], + "host": "mail.gandi.net", + "port": 587 + }, + + "Gmail": { + "aliases": ["Google Mail"], + "domains": ["gmail.com", "googlemail.com"], + "host": "smtp.gmail.com", + "port": 465, + "secure": true + }, + + "Godaddy": { + "host": "smtpout.secureserver.net", + "port": 25 + }, + + "GodaddyAsia": { + "host": "smtp.asia.secureserver.net", + "port": 25 + }, + + "GodaddyEurope": { + "host": "smtp.europe.secureserver.net", + "port": 25 + }, + + "hot.ee": { + "host": "mail.hot.ee" + }, + + "Hotmail": { + "aliases": ["Outlook", "Outlook.com", "Hotmail.com"], + "domains": ["hotmail.com", "outlook.com"], + "host": "smtp.live.com", + "port": 587, + "tls": { + "ciphers": "SSLv3" + } + }, + + "iCloud": { + "aliases": ["Me", "Mac"], + "domains": ["me.com", "mac.com"], + "host": "smtp.mail.me.com", + "port": 587 + }, + + "mail.ee": { + "host": "smtp.mail.ee" + }, + + "Mail.ru": { + "host": "smtp.mail.ru", + "port": 465, + "secure": true + }, + + "Maildev": { + "port": 1025, + "ignoreTLS": true + }, + + "Mailgun": { + "host": "smtp.mailgun.org", + "port": 465, + "secure": true + }, + + "Mailjet": { + "host": "in.mailjet.com", + "port": 587 + }, + + "Mailosaur": { + "host": "mailosaur.io", + "port": 25 + }, + + "Mailtrap": { + "host": "smtp.mailtrap.io", + "port": 2525 + }, + + "Mandrill": { + "host": "smtp.mandrillapp.com", + "port": 587 + }, + + "Naver": { + "host": "smtp.naver.com", + "port": 587 + }, + + "One": { + "host": "send.one.com", + "port": 465, + "secure": true + }, + + "OpenMailBox": { + "aliases": ["OMB", "openmailbox.org"], + "host": "smtp.openmailbox.org", + "port": 465, + "secure": true + }, + + "Outlook365": { + "host": "smtp.office365.com", + "port": 587, + "secure": false + }, + + "Postmark": { + "aliases": ["PostmarkApp"], + "host": "smtp.postmarkapp.com", + "port": 2525 + }, + + "qiye.aliyun": { + "host": "smtp.mxhichina.com", + "port": "465", + "secure": true + }, + + "QQ": { + "domains": ["qq.com"], + "host": "smtp.qq.com", + "port": 465, + "secure": true + }, + + "QQex": { + "aliases": ["QQ Enterprise"], + "domains": ["exmail.qq.com"], + "host": "smtp.exmail.qq.com", + "port": 465, + "secure": true + }, + + "SendCloud": { + "host": "smtpcloud.sohu.com", + "port": 25 + }, + + "SendGrid": { + "host": "smtp.sendgrid.net", + "port": 587 + }, + + "SendinBlue": { + "host": "smtp-relay.sendinblue.com", + "port": 587 + }, + + "SendPulse": { + "host": "smtp-pulse.com", + "port": 465, + "secure": true + }, + + "SES": { + "host": "email-smtp.us-east-1.amazonaws.com", + "port": 465, + "secure": true + }, + + "SES-US-EAST-1": { + "host": "email-smtp.us-east-1.amazonaws.com", + "port": 465, + "secure": true + }, + + "SES-US-WEST-2": { + "host": "email-smtp.us-west-2.amazonaws.com", + "port": 465, + "secure": true + }, + + "SES-EU-WEST-1": { + "host": "email-smtp.eu-west-1.amazonaws.com", + "port": 465, + "secure": true + }, + + "Sparkpost": { + "aliases": ["SparkPost", "SparkPost Mail"], + "domains": ["sparkpost.com"], + "host": "smtp.sparkpostmail.com", + "port": 587, + "secure": false + }, + + "Tipimail": { + "host": "smtp.tipimail.com", + "port": 587 + }, + + "Yahoo": { + "domains": ["yahoo.com"], + "host": "smtp.mail.yahoo.com", + "port": 465, + "secure": true + }, + + "Yandex": { + "domains": ["yandex.ru"], + "host": "smtp.yandex.ru", + "port": 465, + "secure": true + }, + + "Zoho": { + "host": "smtp.zoho.com", + "port": 465, + "secure": true, + "authMethod": "LOGIN" + }, + + "126": { + "host": "smtp.126.com", + "port": 465, + "secure": true + }, + + "163": { + "host": "smtp.163.com", + "port": 465, + "secure": true + } +} diff --git a/node_modules/nodemailer/lib/xoauth2/index.js b/node_modules/nodemailer/lib/xoauth2/index.js new file mode 100644 index 0000000..d826000 --- /dev/null +++ b/node_modules/nodemailer/lib/xoauth2/index.js @@ -0,0 +1,312 @@ +'use strict'; + +const Stream = require('stream').Stream; +const fetch = require('../fetch'); +const crypto = require('crypto'); +const shared = require('../shared'); + +/** + * XOAUTH2 access_token generator for Gmail. + * Create client ID for web applications in Google API console to use it. + * See Offline Access for receiving the needed refreshToken for an user + * https://developers.google.com/accounts/docs/OAuth2WebServer#offline + * + * Usage for generating access tokens with a custom method using provisionCallback: + * provisionCallback(user, renew, callback) + * * user is the username to get the token for + * * renew is a boolean that if true indicates that existing token failed and needs to be renewed + * * callback is the callback to run with (error, accessToken [, expires]) + * * accessToken is a string + * * expires is an optional expire time in milliseconds + * If provisionCallback is used, then Nodemailer does not try to attempt generating the token by itself + * + * @constructor + * @param {Object} options Client information for token generation + * @param {String} options.user User e-mail address + * @param {String} options.clientId Client ID value + * @param {String} options.clientSecret Client secret value + * @param {String} options.refreshToken Refresh token for an user + * @param {String} options.accessUrl Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token' + * @param {String} options.accessToken An existing valid accessToken + * @param {String} options.privateKey Private key for JSW + * @param {Number} options.expires Optional Access Token expire time in ms + * @param {Number} options.timeout Optional TTL for Access Token in seconds + * @param {Function} options.provisionCallback Function to run when a new access token is required + */ +class XOAuth2 extends Stream { + constructor(options, logger) { + super(); + + this.options = options || {}; + + if (options && options.serviceClient) { + if (!options.privateKey || !options.user) { + setImmediate(() => this.emit('error', new Error('Options "privateKey" and "user" are required for service account!'))); + return; + } + + let serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600); + this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60; + } + + this.logger = shared.getLogger( + { + logger + }, + { + component: this.options.component || 'OAuth2' + } + ); + + this.provisionCallback = typeof this.options.provisionCallback === 'function' ? this.options.provisionCallback : false; + + this.options.accessUrl = this.options.accessUrl || 'https://accounts.google.com/o/oauth2/token'; + this.options.customHeaders = this.options.customHeaders || {}; + this.options.customParams = this.options.customParams || {}; + + this.accessToken = this.options.accessToken || false; + + if (this.options.expires && Number(this.options.expires)) { + this.expires = this.options.expires; + } else { + let timeout = Math.max(Number(this.options.timeout) || 0, 0); + this.expires = (timeout && Date.now() + timeout * 1000) || 0; + } + } + + /** + * Returns or generates (if previous has expired) a XOAuth2 token + * + * @param {Boolean} renew If false then use cached access token (if available) + * @param {Function} callback Callback function with error object and token string + */ + getToken(renew, callback) { + if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) { + return callback(null, this.accessToken); + } + + let generateCallback = (...args) => { + if (args[0]) { + this.logger.error( + { + err: args[0], + tnx: 'OAUTH2', + user: this.options.user, + action: 'renew' + }, + 'Failed generating new Access Token for %s', + this.options.user + ); + } else { + this.logger.info( + { + tnx: 'OAUTH2', + user: this.options.user, + action: 'renew' + }, + 'Generated new Access Token for %s', + this.options.user + ); + } + callback(...args); + }; + + if (this.provisionCallback) { + this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => { + if (!err && accessToken) { + this.accessToken = accessToken; + this.expires = expires || 0; + } + generateCallback(err, accessToken); + }); + } else { + this.generateToken(generateCallback); + } + } + + /** + * Updates token values + * + * @param {String} accessToken New access token + * @param {Number} timeout Access token lifetime in seconds + * + * Emits 'token': { user: User email-address, accessToken: the new accessToken, timeout: TTL in seconds} + */ + updateToken(accessToken, timeout) { + this.accessToken = accessToken; + timeout = Math.max(Number(timeout) || 0, 0); + this.expires = (timeout && Date.now() + timeout * 1000) || 0; + + this.emit('token', { + user: this.options.user, + accessToken: accessToken || '', + expires: this.expires + }); + } + + /** + * Generates a new XOAuth2 token with the credentials provided at initialization + * + * @param {Function} callback Callback function with error object and token string + */ + generateToken(callback) { + let urlOptions; + if (this.options.serviceClient) { + // service account - https://developers.google.com/identity/protocols/OAuth2ServiceAccount + let iat = Math.floor(Date.now() / 1000); // unix time + let token = this.jwtSignRS256({ + iss: this.options.serviceClient, + scope: this.options.scope || 'https://mail.google.com/', + sub: this.options.user, + aud: this.options.accessUrl, + iat, + exp: iat + this.options.serviceRequestTimeout + }); + + urlOptions = { + grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', + assertion: token + }; + } else { + if (!this.options.refreshToken) { + return callback(new Error('Can\x27t create new access token for user')); + } + + // web app - https://developers.google.com/identity/protocols/OAuth2WebServer + urlOptions = { + client_id: this.options.clientId || '', + client_secret: this.options.clientSecret || '', + refresh_token: this.options.refreshToken, + grant_type: 'refresh_token' + }; + } + + Object.keys(this.options.customParams).forEach(key => { + urlOptions[key] = this.options.customParams[key]; + }); + + this.postRequest(this.options.accessUrl, urlOptions, this.options, (error, body) => { + let data; + + if (error) { + return callback(error); + } + + try { + data = JSON.parse(body.toString()); + } catch (E) { + return callback(E); + } + + if (!data || typeof data !== 'object') { + return callback(new Error('Invalid authentication response')); + } + + if (data.error) { + return callback(new Error(data.error)); + } + + if (data.access_token) { + this.updateToken(data.access_token, data.expires_in); + return callback(null, this.accessToken); + } + + return callback(new Error('No access token')); + }); + } + + /** + * Converts an access_token and user id into a base64 encoded XOAuth2 token + * + * @param {String} [accessToken] Access token string + * @return {String} Base64 encoded token for IMAP or SMTP login + */ + buildXOAuth2Token(accessToken) { + let authData = ['user=' + (this.options.user || ''), 'auth=Bearer ' + (accessToken || this.accessToken), '', '']; + return Buffer.from(authData.join('\x01'), 'utf-8').toString('base64'); + } + + /** + * Custom POST request handler. + * This is only needed to keep paths short in Windows – usually this module + * is a dependency of a dependency and if it tries to require something + * like the request module the paths get way too long to handle for Windows. + * As we do only a simple POST request we do not actually require complicated + * logic support (no redirects, no nothing) anyway. + * + * @param {String} url Url to POST to + * @param {String|Buffer} payload Payload to POST + * @param {Function} callback Callback function with (err, buff) + */ + postRequest(url, payload, params, callback) { + let returned = false; + + let chunks = []; + let chunklen = 0; + + let req = fetch(url, { + method: 'post', + headers: params.customHeaders, + body: payload + }); + + req.on('readable', () => { + let chunk; + while ((chunk = req.read()) !== null) { + chunks.push(chunk); + chunklen += chunk.length; + } + }); + + req.once('error', err => { + if (returned) { + return; + } + returned = true; + return callback(err); + }); + + req.once('end', () => { + if (returned) { + return; + } + returned = true; + return callback(null, Buffer.concat(chunks, chunklen)); + }); + } + + /** + * Encodes a buffer or a string into Base64url format + * + * @param {Buffer|String} data The data to convert + * @return {String} The encoded string + */ + toBase64URL(data) { + if (typeof data === 'string') { + data = Buffer.from(data); + } + + return data + .toString('base64') + .replace(/[=]+/g, '') // remove '='s + .replace(/\+/g, '-') // '+' → '-' + .replace(/\//g, '_'); // '/' → '_' + } + + /** + * Creates a JSON Web Token signed with RS256 (SHA256 + RSA) + * + * @param {Object} payload The payload to include in the generated token + * @return {String} The generated and signed token + */ + jwtSignRS256(payload) { + payload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map(val => this.toBase64URL(val)).join('.'); + let signature = crypto + .createSign('RSA-SHA256') + .update(payload) + .sign(this.options.privateKey); + return payload + '.' + this.toBase64URL(signature); + } +} + +module.exports = XOAuth2; diff --git a/node_modules/nodemailer/package.json b/node_modules/nodemailer/package.json new file mode 100644 index 0000000..4dc0d84 --- /dev/null +++ b/node_modules/nodemailer/package.json @@ -0,0 +1,71 @@ +{ + "_from": "nodemailer", + "_id": "nodemailer@4.6.8", + "_inBundle": false, + "_integrity": "sha512-A3s7EM/426OBIZbLHXq2KkgvmKbn2Xga4m4G+ZUA4IaZvG8PcZXrFh+2E4VaS2o+emhuUVRnzKN2YmpkXQ9qwA==", + "_location": "/nodemailer", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "nodemailer", + "name": "nodemailer", + "escapedName": "nodemailer", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.6.8.tgz", + "_shasum": "f82fb407828bf2e76d92acc34b823d83e774f89c", + "_spec": "nodemailer", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "author": { + "name": "Andris Reinman" + }, + "bugs": { + "url": "https://github.com/nodemailer/nodemailer/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "Easy as cake e-mail sending from your Node.js applications", + "devDependencies": { + "bunyan": "^1.8.12", + "chai": "^4.1.2", + "eslint-config-nodemailer": "^1.2.0", + "grunt": "^1.0.3", + "grunt-cli": "^1.2.0", + "grunt-eslint": "^21.0.0", + "grunt-mocha-test": "^0.13.3", + "libbase64": "^1.0.3", + "libmime": "^4.0.1", + "libqp": "^1.1.0", + "mocha": "^5.2.0", + "proxy": "^0.2.4", + "proxy-test-server": "^1.0.0", + "sinon": "^6.1.5", + "smtp-server": "^3.4.6" + }, + "engines": { + "node": ">=6.0.0" + }, + "homepage": "https://nodemailer.com/", + "keywords": [ + "Nodemailer" + ], + "license": "MIT", + "main": "lib/nodemailer.js", + "name": "nodemailer", + "repository": { + "type": "git", + "url": "git+https://github.com/nodemailer/nodemailer.git" + }, + "scripts": { + "test": "grunt" + }, + "version": "4.6.8" +} diff --git a/node_modules/object-assign/index.js b/node_modules/object-assign/index.js new file mode 100644 index 0000000..2164f93 --- /dev/null +++ b/node_modules/object-assign/index.js @@ -0,0 +1,39 @@ +'use strict'; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function ToObject(val) { + if (val == null) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function ownEnumerableKeys(obj) { + var keys = Object.getOwnPropertyNames(obj); + + if (Object.getOwnPropertySymbols) { + keys = keys.concat(Object.getOwnPropertySymbols(obj)); + } + + return keys.filter(function (key) { + return propIsEnumerable.call(obj, key); + }); +} + +module.exports = Object.assign || function (target, source) { + var from; + var keys; + var to = ToObject(target); + + for (var s = 1; s < arguments.length; s++) { + from = arguments[s]; + keys = ownEnumerableKeys(Object(from)); + + for (var i = 0; i < keys.length; i++) { + to[keys[i]] = from[keys[i]]; + } + } + + return to; +}; diff --git a/node_modules/object-assign/license b/node_modules/object-assign/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/node_modules/object-assign/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/object-assign/package.json b/node_modules/object-assign/package.json new file mode 100644 index 0000000..743e7df --- /dev/null +++ b/node_modules/object-assign/package.json @@ -0,0 +1,70 @@ +{ + "_from": "object-assign@^3.0.0", + "_id": "object-assign@3.0.0", + "_inBundle": false, + "_integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "_location": "/object-assign", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "object-assign@^3.0.0", + "name": "object-assign", + "escapedName": "object-assign", + "rawSpec": "^3.0.0", + "saveSpec": null, + "fetchSpec": "^3.0.0" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "_shasum": "9bedd5ca0897949bca47e7ff408062d549f587f2", + "_spec": "object-assign@^3.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/object-assign/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "ES6 Object.assign() ponyfill", + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/object-assign#readme", + "keywords": [ + "object", + "assign", + "extend", + "properties", + "es6", + "ecmascript", + "harmony", + "ponyfill", + "prollyfill", + "polyfill", + "shim", + "browser" + ], + "license": "MIT", + "name": "object-assign", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/object-assign.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "3.0.0" +} diff --git a/node_modules/object-assign/readme.md b/node_modules/object-assign/readme.md new file mode 100644 index 0000000..aee51c1 --- /dev/null +++ b/node_modules/object-assign/readme.md @@ -0,0 +1,51 @@ +# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) + +> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill + +> Ponyfill: A polyfill that doesn't overwrite the native method + + +## Install + +```sh +$ npm install --save object-assign +``` + + +## Usage + +```js +var objectAssign = require('object-assign'); + +objectAssign({foo: 0}, {bar: 1}); +//=> {foo: 0, bar: 1} + +// multiple sources +objectAssign({foo: 0}, {bar: 1}, {baz: 2}); +//=> {foo: 0, bar: 1, baz: 2} + +// overwrites equal keys +objectAssign({foo: 0}, {foo: 1}, {foo: 2}); +//=> {foo: 2} + +// ignores null and undefined sources +objectAssign({foo: 0}, null, {bar: 1}, undefined); +//=> {foo: 0, bar: 1} +``` + + +## API + +### objectAssign(target, source, [source, ...]) + +Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. + + +## Resources + +- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/on-finished/HISTORY.md b/node_modules/on-finished/HISTORY.md new file mode 100644 index 0000000..98ff0e9 --- /dev/null +++ b/node_modules/on-finished/HISTORY.md @@ -0,0 +1,88 @@ +2.3.0 / 2015-05-26 +================== + + * Add defined behavior for HTTP `CONNECT` requests + * Add defined behavior for HTTP `Upgrade` requests + * deps: ee-first@1.1.1 + +2.2.1 / 2015-04-22 +================== + + * Fix `isFinished(req)` when data buffered + +2.2.0 / 2014-12-22 +================== + + * Add message object to callback arguments + +2.1.1 / 2014-10-22 +================== + + * Fix handling of pipelined requests + +2.1.0 / 2014-08-16 +================== + + * Check if `socket` is detached + * Return `undefined` for `isFinished` if state unknown + +2.0.0 / 2014-08-16 +================== + + * Add `isFinished` function + * Move to `jshttp` organization + * Remove support for plain socket argument + * Rename to `on-finished` + * Support both `req` and `res` as arguments + * deps: ee-first@1.0.5 + +1.2.2 / 2014-06-10 +================== + + * Reduce listeners added to emitters + - avoids "event emitter leak" warnings when used multiple times on same request + +1.2.1 / 2014-06-08 +================== + + * Fix returned value when already finished + +1.2.0 / 2014-06-05 +================== + + * Call callback when called on already-finished socket + +1.1.4 / 2014-05-27 +================== + + * Support node.js 0.8 + +1.1.3 / 2014-04-30 +================== + + * Make sure errors passed as instanceof `Error` + +1.1.2 / 2014-04-18 +================== + + * Default the `socket` to passed-in object + +1.1.1 / 2014-01-16 +================== + + * Rename module to `finished` + +1.1.0 / 2013-12-25 +================== + + * Call callback when called on already-errored socket + +1.0.1 / 2013-12-20 +================== + + * Actually pass the error to the callback + +1.0.0 / 2013-12-20 +================== + + * Initial release diff --git a/node_modules/on-finished/LICENSE b/node_modules/on-finished/LICENSE new file mode 100644 index 0000000..5931fd2 --- /dev/null +++ b/node_modules/on-finished/LICENSE @@ -0,0 +1,23 @@ +(The MIT License) + +Copyright (c) 2013 Jonathan Ong +Copyright (c) 2014 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/on-finished/README.md b/node_modules/on-finished/README.md new file mode 100644 index 0000000..a0e1157 --- /dev/null +++ b/node_modules/on-finished/README.md @@ -0,0 +1,154 @@ +# on-finished + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Execute a callback when a HTTP request closes, finishes, or errors. + +## Install + +```sh +$ npm install on-finished +``` + +## API + +```js +var onFinished = require('on-finished') +``` + +### onFinished(res, listener) + +Attach a listener to listen for the response to finish. The listener will +be invoked only once when the response finished. If the response finished +to an error, the first argument will contain the error. If the response +has already finished, the listener will be invoked. + +Listening to the end of a response would be used to close things associated +with the response, like open files. + +Listener is invoked as `listener(err, res)`. + +```js +onFinished(res, function (err, res) { + // clean up open fds, etc. + // err contains the error is request error'd +}) +``` + +### onFinished(req, listener) + +Attach a listener to listen for the request to finish. The listener will +be invoked only once when the request finished. If the request finished +to an error, the first argument will contain the error. If the request +has already finished, the listener will be invoked. + +Listening to the end of a request would be used to know when to continue +after reading the data. + +Listener is invoked as `listener(err, req)`. + +```js +var data = '' + +req.setEncoding('utf8') +res.on('data', function (str) { + data += str +}) + +onFinished(req, function (err, req) { + // data is read unless there is err +}) +``` + +### onFinished.isFinished(res) + +Determine if `res` is already finished. This would be useful to check and +not even start certain operations if the response has already finished. + +### onFinished.isFinished(req) + +Determine if `req` is already finished. This would be useful to check and +not even start certain operations if the request has already finished. + +## Special Node.js requests + +### HTTP CONNECT method + +The meaning of the `CONNECT` method from RFC 7231, section 4.3.6: + +> The CONNECT method requests that the recipient establish a tunnel to +> the destination origin server identified by the request-target and, +> if successful, thereafter restrict its behavior to blind forwarding +> of packets, in both directions, until the tunnel is closed. Tunnels +> are commonly used to create an end-to-end virtual connection, through +> one or more proxies, which can then be secured using TLS (Transport +> Layer Security, [RFC5246]). + +In Node.js, these request objects come from the `'connect'` event on +the HTTP server. + +When this module is used on a HTTP `CONNECT` request, the request is +considered "finished" immediately, **due to limitations in the Node.js +interface**. This means if the `CONNECT` request contains a request entity, +the request will be considered "finished" even before it has been read. + +There is no such thing as a response object to a `CONNECT` request in +Node.js, so there is no support for for one. + +### HTTP Upgrade request + +The meaning of the `Upgrade` header from RFC 7230, section 6.1: + +> The "Upgrade" header field is intended to provide a simple mechanism +> for transitioning from HTTP/1.1 to some other protocol on the same +> connection. + +In Node.js, these request objects come from the `'upgrade'` event on +the HTTP server. + +When this module is used on a HTTP request with an `Upgrade` header, the +request is considered "finished" immediately, **due to limitations in the +Node.js interface**. This means if the `Upgrade` request contains a request +entity, the request will be considered "finished" even before it has been +read. + +There is no such thing as a response object to a `Upgrade` request in +Node.js, so there is no support for for one. + +## Example + +The following code ensures that file descriptors are always closed +once the response finishes. + +```js +var destroy = require('destroy') +var http = require('http') +var onFinished = require('on-finished') + +http.createServer(function onRequest(req, res) { + var stream = fs.createReadStream('package.json') + stream.pipe(res) + onFinished(res, function (err) { + destroy(stream) + }) +}) +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/on-finished.svg +[npm-url]: https://npmjs.org/package/on-finished +[node-version-image]: https://img.shields.io/node/v/on-finished.svg +[node-version-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/jshttp/on-finished/master.svg +[travis-url]: https://travis-ci.org/jshttp/on-finished +[coveralls-image]: https://img.shields.io/coveralls/jshttp/on-finished/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master +[downloads-image]: https://img.shields.io/npm/dm/on-finished.svg +[downloads-url]: https://npmjs.org/package/on-finished diff --git a/node_modules/on-finished/index.js b/node_modules/on-finished/index.js new file mode 100644 index 0000000..9abd98f --- /dev/null +++ b/node_modules/on-finished/index.js @@ -0,0 +1,196 @@ +/*! + * on-finished + * Copyright(c) 2013 Jonathan Ong + * Copyright(c) 2014 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = onFinished +module.exports.isFinished = isFinished + +/** + * Module dependencies. + * @private + */ + +var first = require('ee-first') + +/** + * Variables. + * @private + */ + +/* istanbul ignore next */ +var defer = typeof setImmediate === 'function' + ? setImmediate + : function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) } + +/** + * Invoke callback when the response has finished, useful for + * cleaning up resources afterwards. + * + * @param {object} msg + * @param {function} listener + * @return {object} + * @public + */ + +function onFinished(msg, listener) { + if (isFinished(msg) !== false) { + defer(listener, null, msg) + return msg + } + + // attach the listener to the message + attachListener(msg, listener) + + return msg +} + +/** + * Determine if message is already finished. + * + * @param {object} msg + * @return {boolean} + * @public + */ + +function isFinished(msg) { + var socket = msg.socket + + if (typeof msg.finished === 'boolean') { + // OutgoingMessage + return Boolean(msg.finished || (socket && !socket.writable)) + } + + if (typeof msg.complete === 'boolean') { + // IncomingMessage + return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable)) + } + + // don't know + return undefined +} + +/** + * Attach a finished listener to the message. + * + * @param {object} msg + * @param {function} callback + * @private + */ + +function attachFinishedListener(msg, callback) { + var eeMsg + var eeSocket + var finished = false + + function onFinish(error) { + eeMsg.cancel() + eeSocket.cancel() + + finished = true + callback(error) + } + + // finished on first message event + eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish) + + function onSocket(socket) { + // remove listener + msg.removeListener('socket', onSocket) + + if (finished) return + if (eeMsg !== eeSocket) return + + // finished on first socket event + eeSocket = first([[socket, 'error', 'close']], onFinish) + } + + if (msg.socket) { + // socket already assigned + onSocket(msg.socket) + return + } + + // wait for socket to be assigned + msg.on('socket', onSocket) + + if (msg.socket === undefined) { + // node.js 0.8 patch + patchAssignSocket(msg, onSocket) + } +} + +/** + * Attach the listener to the message. + * + * @param {object} msg + * @return {function} + * @private + */ + +function attachListener(msg, listener) { + var attached = msg.__onFinished + + // create a private single listener with queue + if (!attached || !attached.queue) { + attached = msg.__onFinished = createListener(msg) + attachFinishedListener(msg, attached) + } + + attached.queue.push(listener) +} + +/** + * Create listener on message. + * + * @param {object} msg + * @return {function} + * @private + */ + +function createListener(msg) { + function listener(err) { + if (msg.__onFinished === listener) msg.__onFinished = null + if (!listener.queue) return + + var queue = listener.queue + listener.queue = null + + for (var i = 0; i < queue.length; i++) { + queue[i](err, msg) + } + } + + listener.queue = [] + + return listener +} + +/** + * Patch ServerResponse.prototype.assignSocket for node.js 0.8. + * + * @param {ServerResponse} res + * @param {function} callback + * @private + */ + +function patchAssignSocket(res, callback) { + var assignSocket = res.assignSocket + + if (typeof assignSocket !== 'function') return + + // res.on('socket', callback) is broken in 0.8 + res.assignSocket = function _assignSocket(socket) { + assignSocket.call(this, socket) + callback(socket) + } +} diff --git a/node_modules/on-finished/package.json b/node_modules/on-finished/package.json new file mode 100644 index 0000000..81f3a62 --- /dev/null +++ b/node_modules/on-finished/package.json @@ -0,0 +1,70 @@ +{ + "_from": "on-finished@^2.3.0", + "_id": "on-finished@2.3.0", + "_inBundle": false, + "_integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "_location": "/on-finished", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "on-finished@^2.3.0", + "name": "on-finished", + "escapedName": "on-finished", + "rawSpec": "^2.3.0", + "saveSpec": null, + "fetchSpec": "^2.3.0" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "_shasum": "20f1336481b083cd75337992a16971aa2d906947", + "_spec": "on-finished@^2.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "bugs": { + "url": "https://github.com/jshttp/on-finished/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "dependencies": { + "ee-first": "1.1.1" + }, + "deprecated": false, + "description": "Execute a callback when a request closes, finishes, or errors", + "devDependencies": { + "istanbul": "0.3.9", + "mocha": "2.2.5" + }, + "engines": { + "node": ">= 0.8" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "index.js" + ], + "homepage": "https://github.com/jshttp/on-finished#readme", + "license": "MIT", + "name": "on-finished", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/on-finished.git" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "version": "2.3.0" +} diff --git a/node_modules/on-headers/package.json b/node_modules/on-headers/package.json index 92510de..a11ead5 100644 --- a/node_modules/on-headers/package.json +++ b/node_modules/on-headers/package.json @@ -1,27 +1,32 @@ { - "_from": "on-headers@~1.0.1", + "_args": [ + [ + "on-headers@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "on-headers@1.0.1", "_id": "on-headers@1.0.1", "_inBundle": false, "_integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", "_location": "/on-headers", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "on-headers@~1.0.1", + "raw": "on-headers@1.0.1", "name": "on-headers", "escapedName": "on-headers", - "rawSpec": "~1.0.1", + "rawSpec": "1.0.1", "saveSpec": null, - "fetchSpec": "~1.0.1" + "fetchSpec": "1.0.1" }, "_requiredBy": [ "/express-session" ], "_resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", - "_shasum": "928f5d0f470d49342651ea6794b0857c100693f7", - "_spec": "on-headers@~1.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" @@ -29,9 +34,7 @@ "bugs": { "url": "https://github.com/jshttp/on-headers/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Execute a listener when a response is about to write headers", "devDependencies": { "istanbul": "0.3.21", diff --git a/node_modules/once/package.json b/node_modules/once/package.json index ba0d5eb..e06c38c 100644 --- a/node_modules/once/package.json +++ b/node_modules/once/package.json @@ -1,28 +1,34 @@ { - "_from": "once@^1.3.0", + "_args": [ + [ + "once@1.4.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "once@1.4.0", "_id": "once@1.4.0", "_inBundle": false, "_integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "_location": "/once", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "once@^1.3.0", + "raw": "once@1.4.0", "name": "once", "escapedName": "once", - "rawSpec": "^1.3.0", + "rawSpec": "1.4.0", "saveSpec": null, - "fetchSpec": "^1.3.0" + "fetchSpec": "1.4.0" }, "_requiredBy": [ "/cli/glob", "/inflight" ], "_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "_shasum": "583b1aa775961d4b113ac17d9c50baef9dd76bd1", - "_spec": "once@^1.3.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/glob", + "_spec": "1.4.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -31,11 +37,9 @@ "bugs": { "url": "https://github.com/isaacs/once/issues" }, - "bundleDependencies": false, "dependencies": { "wrappy": "1" }, - "deprecated": false, "description": "Run a function exactly one time", "devDependencies": { "tap": "^7.0.1" diff --git a/node_modules/parseurl/package.json b/node_modules/parseurl/package.json index 89c9d2b..de47f92 100644 --- a/node_modules/parseurl/package.json +++ b/node_modules/parseurl/package.json @@ -1,31 +1,35 @@ { - "_from": "parseurl@~1.3.2", + "_args": [ + [ + "parseurl@1.3.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "parseurl@1.3.2", "_id": "parseurl@1.3.2", "_inBundle": false, "_integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", "_location": "/parseurl", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "parseurl@~1.3.2", + "raw": "parseurl@1.3.2", "name": "parseurl", "escapedName": "parseurl", - "rawSpec": "~1.3.2", + "rawSpec": "1.3.2", "saveSpec": null, - "fetchSpec": "~1.3.2" + "fetchSpec": "1.3.2" }, "_requiredBy": [ "/express-session" ], "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "_shasum": "fc289d4ed8993119460c156253262cdc8de65bf3", - "_spec": "parseurl@~1.3.2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "1.3.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/pillarjs/parseurl/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -37,7 +41,6 @@ "url": "http://jongleberry.com" } ], - "deprecated": false, "description": "parse a url with memoization", "devDependencies": { "beautify-benchmark": "0.2.4", diff --git a/node_modules/passport-local-mongoose/package.json b/node_modules/passport-local-mongoose/package.json index f361d06..8e3e655 100644 --- a/node_modules/passport-local-mongoose/package.json +++ b/node_modules/passport-local-mongoose/package.json @@ -1,26 +1,31 @@ { - "_from": "passport-local-mongoose@^1.0.0", + "_args": [ + [ + "passport-local-mongoose@1.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "passport-local-mongoose@1.3.0", "_id": "passport-local-mongoose@1.3.0", "_inBundle": false, "_integrity": "sha1-nQzY81AFMoQYsYdLolQJN/JJLB8=", "_location": "/passport-local-mongoose", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "passport-local-mongoose@^1.0.0", + "raw": "passport-local-mongoose@1.3.0", "name": "passport-local-mongoose", "escapedName": "passport-local-mongoose", - "rawSpec": "^1.0.0", + "rawSpec": "1.3.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.3.0" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/passport-local-mongoose/-/passport-local-mongoose-1.3.0.tgz", - "_shasum": "9d0cd8f35005328418b1874ba2540937f2492c1f", - "_spec": "passport-local-mongoose@^1.0.0", + "_spec": "1.3.0", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Christoph Walcher", @@ -29,12 +34,10 @@ "bugs": { "url": "https://github.com/saintedlama/passport-local-mongoose/issues" }, - "bundleDependencies": false, "dependencies": { "passport-local": "^1.0.0", "scmp": "^1.0.0" }, - "deprecated": false, "description": "Mongoose plugin that simplifies building username and password login with Passport", "devDependencies": { "chai": "^1.10.0", diff --git a/node_modules/passport-local/package.json b/node_modules/passport-local/package.json index 636d0fb..2df3645 100644 --- a/node_modules/passport-local/package.json +++ b/node_modules/passport-local/package.json @@ -1,27 +1,32 @@ { - "_from": "passport-local@^1.0.0", + "_args": [ + [ + "passport-local@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "passport-local@1.0.0", "_id": "passport-local@1.0.0", "_inBundle": false, "_integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=", "_location": "/passport-local", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "passport-local@^1.0.0", + "raw": "passport-local@1.0.0", "name": "passport-local", "escapedName": "passport-local", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/", "/passport-local-mongoose" ], "_resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", - "_shasum": "1fe63268c92e75606626437e3b906662c15ba6ee", - "_spec": "passport-local@^1.0.0", + "_spec": "1.0.0", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", @@ -31,11 +36,9 @@ "bugs": { "url": "http://github.com/jaredhanson/passport-local/issues" }, - "bundleDependencies": false, "dependencies": { "passport-strategy": "1.x.x" }, - "deprecated": false, "description": "Local username and password authentication strategy for Passport.", "devDependencies": { "chai": "1.x.x", diff --git a/node_modules/passport-strategy/package.json b/node_modules/passport-strategy/package.json index 6a6a87c..b64ba77 100644 --- a/node_modules/passport-strategy/package.json +++ b/node_modules/passport-strategy/package.json @@ -1,28 +1,33 @@ { - "_from": "passport-strategy@1.x.x", + "_args": [ + [ + "passport-strategy@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "passport-strategy@1.0.0", "_id": "passport-strategy@1.0.0", "_inBundle": false, "_integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=", "_location": "/passport-strategy", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "passport-strategy@1.x.x", + "raw": "passport-strategy@1.0.0", "name": "passport-strategy", "escapedName": "passport-strategy", - "rawSpec": "1.x.x", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "1.x.x" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/passport", "/passport-local" ], "_resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", - "_shasum": "b5539aa8fc225a3d1ad179476ddf236b440f52e4", - "_spec": "passport-strategy@1.x.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/passport", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", "email": "jaredhanson@gmail.com", @@ -31,9 +36,7 @@ "bugs": { "url": "http://github.com/jaredhanson/passport-strategy/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "An abstract class implementing Passport's strategy API.", "devDependencies": { "chai": "1.x.x", diff --git a/node_modules/passport/package.json b/node_modules/passport/package.json index dc49f3e..80016df 100644 --- a/node_modules/passport/package.json +++ b/node_modules/passport/package.json @@ -1,26 +1,31 @@ { - "_from": "passport@^0.2.1", + "_args": [ + [ + "passport@0.2.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "passport@0.2.2", "_id": "passport@0.2.2", "_inBundle": false, "_integrity": "sha1-nDjxe+uSnz2Br3uIOOhDDbhwPys=", "_location": "/passport", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "passport@^0.2.1", + "raw": "passport@0.2.2", "name": "passport", "escapedName": "passport", - "rawSpec": "^0.2.1", + "rawSpec": "0.2.2", "saveSpec": null, - "fetchSpec": "^0.2.1" + "fetchSpec": "0.2.2" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/passport/-/passport-0.2.2.tgz", - "_shasum": "9c38f17beb929f3d81af7b8838e8430db8703f2b", - "_spec": "passport@^0.2.1", + "_spec": "0.2.2", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", @@ -30,12 +35,10 @@ "bugs": { "url": "http://github.com/jaredhanson/passport/issues" }, - "bundleDependencies": false, "dependencies": { "passport-strategy": "1.x.x", "pause": "0.0.1" }, - "deprecated": false, "description": "Simple, unobtrusive authentication for Node.js.", "devDependencies": { "chai": "2.x.x", diff --git a/node_modules/path-is-absolute/package.json b/node_modules/path-is-absolute/package.json index 46ab6f5..71211e0 100644 --- a/node_modules/path-is-absolute/package.json +++ b/node_modules/path-is-absolute/package.json @@ -1,27 +1,33 @@ { - "_from": "path-is-absolute@^1.0.0", + "_args": [ + [ + "path-is-absolute@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "path-is-absolute@1.0.1", "_id": "path-is-absolute@1.0.1", "_inBundle": false, "_integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "_location": "/path-is-absolute", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "path-is-absolute@^1.0.0", + "raw": "path-is-absolute@1.0.1", "name": "path-is-absolute", "escapedName": "path-is-absolute", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.1", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.1" }, "_requiredBy": [ "/cli/glob" ], "_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "_shasum": "174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f", - "_spec": "path-is-absolute@^1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/cli/node_modules/glob", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -30,8 +36,6 @@ "bugs": { "url": "https://github.com/sindresorhus/path-is-absolute/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Node.js 0.12 path.isAbsolute() ponyfill", "devDependencies": { "xo": "^0.16.0" diff --git a/node_modules/pause/package.json b/node_modules/pause/package.json index e52ba8a..5f3226d 100644 --- a/node_modules/pause/package.json +++ b/node_modules/pause/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "pause@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "pause@0.0.1", "_id": "pause@0.0.1", "_inBundle": false, @@ -19,16 +25,13 @@ "/passport" ], "_resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", - "_shasum": "1d408b3fdb76923b9543d96fb4c9dfd535d9cb5d", - "_spec": "pause@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/passport", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Pause streams...", "devDependencies": { "mocha": "*", diff --git a/node_modules/process-nextick-args/package.json b/node_modules/process-nextick-args/package.json index a5da1e2..4512d2f 100644 --- a/node_modules/process-nextick-args/package.json +++ b/node_modules/process-nextick-args/package.json @@ -4,16 +4,6 @@ "_inBundle": false, "_integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "_location": "/process-nextick-args", - "_nodeVersion": "5.11.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/process-nextick-args-1.0.7.tgz_1462394251778_0.36989671061746776" - }, - "_npmUser": { - "name": "cwmma", - "email": "calvin.metcalf@gmail.com" - }, - "_npmVersion": "3.8.6", "_phantomChildren": {}, "_requested": { "type": "range", @@ -42,21 +32,9 @@ "devDependencies": { "tap": "~0.2.6" }, - "directories": {}, - "dist": { - "shasum": "150e20b756590ad3f91093f25a4f2ad8bff30ba3", - "tarball": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz" - }, - "gitHead": "5c00899ab01dd32f93ad4b5743da33da91404f39", "homepage": "https://github.com/calvinmetcalf/process-nextick-args", "license": "MIT", "main": "index.js", - "maintainers": [ - { - "name": "cwmma", - "email": "calvin.metcalf@gmail.com" - } - ], "name": "process-nextick-args", "repository": { "type": "git", diff --git a/node_modules/random-bytes/package.json b/node_modules/random-bytes/package.json index 789112f..caa2238 100644 --- a/node_modules/random-bytes/package.json +++ b/node_modules/random-bytes/package.json @@ -1,38 +1,41 @@ { - "_from": "random-bytes@~1.0.0", + "_args": [ + [ + "random-bytes@1.0.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "random-bytes@1.0.0", "_id": "random-bytes@1.0.0", "_inBundle": false, "_integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=", "_location": "/random-bytes", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "random-bytes@~1.0.0", + "raw": "random-bytes@1.0.0", "name": "random-bytes", "escapedName": "random-bytes", - "rawSpec": "~1.0.0", + "rawSpec": "1.0.0", "saveSpec": null, - "fetchSpec": "~1.0.0" + "fetchSpec": "1.0.0" }, "_requiredBy": [ "/uid-safe" ], "_resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", - "_shasum": "4f68a1dc0ae58bd3fb95848c30324db75d64360b", - "_spec": "random-bytes@~1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/uid-safe", + "_spec": "1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/crypto-utils/random-bytes/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "deprecated": false, "description": "URL and cookie safe UIDs", "devDependencies": { "bluebird": "3.1.1", diff --git a/node_modules/readable-stream/package.json b/node_modules/readable-stream/package.json index cd2cbf3..32da233 100644 --- a/node_modules/readable-stream/package.json +++ b/node_modules/readable-stream/package.json @@ -16,12 +16,13 @@ "fetchSpec": "2.2.7" }, "_requiredBy": [ - "/mongodb" + "/concat-stream", + "/mongoose/mongodb" ], "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", "_shasum": "07057acbe2467b22042d36f98c5ad507054e95b1", "_spec": "readable-stream@2.2.7", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose/node_modules/mongodb", "browser": { "util": false, "./readable.js": "./readable-browser.js", diff --git a/node_modules/regexp-clone/package.json b/node_modules/regexp-clone/package.json index ebed408..515f7a0 100644 --- a/node_modules/regexp-clone/package.json +++ b/node_modules/regexp-clone/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "regexp-clone@0.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "regexp-clone@0.0.1", "_id": "regexp-clone@0.0.1", "_inBundle": false, @@ -20,9 +26,8 @@ "/mquery" ], "_resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", - "_shasum": "a7c2e09891fdbf38fbb10d376fb73003e68ac589", - "_spec": "regexp-clone@0.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "0.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -30,8 +35,6 @@ "bugs": { "url": "https://github.com/aheckmann/regexp-clone/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Clone RegExps with options", "devDependencies": { "mocha": "1.8.1" diff --git a/node_modules/require_optional/package.json b/node_modules/require_optional/package.json index 16be885..6fb1634 100644 --- a/node_modules/require_optional/package.json +++ b/node_modules/require_optional/package.json @@ -1,5 +1,5 @@ { - "_from": "require_optional@~1.0.0", + "_from": "require_optional@^1.0.1", "_id": "require_optional@1.0.1", "_inBundle": false, "_integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", @@ -8,19 +8,20 @@ "_requested": { "type": "range", "registry": true, - "raw": "require_optional@~1.0.0", + "raw": "require_optional@^1.0.1", "name": "require_optional", "escapedName": "require_optional", - "rawSpec": "~1.0.0", + "rawSpec": "^1.0.1", "saveSpec": null, - "fetchSpec": "~1.0.0" + "fetchSpec": "^1.0.1" }, "_requiredBy": [ - "/mongodb-core" + "/mongodb-core", + "/mongoose/mongodb-core" ], "_resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", "_shasum": "4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e", - "_spec": "require_optional@~1.0.0", + "_spec": "require_optional@^1.0.1", "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb-core", "author": { "name": "Christian Kvalheim Amor" diff --git a/node_modules/safe-buffer/package.json b/node_modules/safe-buffer/package.json index 1cf2a66..de74907 100644 --- a/node_modules/safe-buffer/package.json +++ b/node_modules/safe-buffer/package.json @@ -1,5 +1,5 @@ { - "_from": "safe-buffer@~5.1.0", + "_from": "safe-buffer@^5.1.2", "_id": "safe-buffer@5.1.2", "_inBundle": false, "_integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", @@ -8,20 +8,22 @@ "_requested": { "type": "range", "registry": true, - "raw": "safe-buffer@~5.1.0", + "raw": "safe-buffer@^5.1.2", "name": "safe-buffer", "escapedName": "safe-buffer", - "rawSpec": "~5.1.0", + "rawSpec": "^5.1.2", "saveSpec": null, - "fetchSpec": "~5.1.0" + "fetchSpec": "^5.1.2" }, "_requiredBy": [ + "/mongodb", + "/mongodb-core", "/string_decoder" ], "_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "_shasum": "991ec69d296e0313747d59bdfd2b745c35f8828d", - "_spec": "safe-buffer@~5.1.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/string_decoder", + "_spec": "safe-buffer@^5.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", diff --git a/node_modules/saslprep/.editorconfig b/node_modules/saslprep/.editorconfig new file mode 100644 index 0000000..d1d8a41 --- /dev/null +++ b/node_modules/saslprep/.editorconfig @@ -0,0 +1,10 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/node_modules/saslprep/.eslintrc b/node_modules/saslprep/.eslintrc new file mode 100644 index 0000000..06c7684 --- /dev/null +++ b/node_modules/saslprep/.eslintrc @@ -0,0 +1,17 @@ +{ + "plugins": [ + "prettier" + ], + "env": { + "browser": true, + "node": true, + "es6": true + }, + "rules": { + "prettier/prettier": ["error", { + "semi": false, + "singleQuote": true, + "trailingComma": "es5" + }] + } +} diff --git a/node_modules/saslprep/.travis.yml b/node_modules/saslprep/.travis.yml new file mode 100644 index 0000000..53b824d --- /dev/null +++ b/node_modules/saslprep/.travis.yml @@ -0,0 +1,5 @@ +sudo: false +language: node_js +node_js: + - "6" + - "8" diff --git a/node_modules/saslprep/LICENSE b/node_modules/saslprep/LICENSE new file mode 100644 index 0000000..481c7a5 --- /dev/null +++ b/node_modules/saslprep/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2014 Dmitry Tsvettsikh + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/saslprep/index.js b/node_modules/saslprep/index.js new file mode 100644 index 0000000..2e2a50e --- /dev/null +++ b/node_modules/saslprep/index.js @@ -0,0 +1,122 @@ +'use strict' + +const { + unassigned_code_points, + commonly_mapped_to_nothing, + non_ASCII_space_characters, + prohibited_characters, + bidirectional_r_al, + bidirectional_l, +} = require('./lib/code-points') + +module.exports = saslprep + +// 2.1. Mapping + +/** + * non-ASCII space characters [StringPrep, C.1.2] that can be + * mapped to SPACE (U+0020) + * @type {Set} + */ +const mapping2space = non_ASCII_space_characters + +/** + * the "commonly mapped to nothing" characters [StringPrep, B.1] + * that can be mapped to nothing. + * @type {Set} + */ +const mapping2nothing = commonly_mapped_to_nothing + +// utils +const getCodePoint = character => character.codePointAt(0) +const first = x => x[0] +const last = x => x[x.length - 1] + +/** + * SASLprep. + * @param {string} input + * @param {object} opts + * @param {boolean} opts.allowUnassigned + */ +function saslprep(input, opts = {}) { + if (typeof input !== 'string') { + throw new TypeError('Expected string.') + } + + if (input.length === 0) { + return '' + } + + // 1. Map + const mapped_input = input + .split('') + .map(getCodePoint) + // 1.1 mapping to space + .map(character => (mapping2space.has(character) ? 0x20 : character)) + // 1.2 mapping to nothing + .filter(character => !mapping2nothing.has(character)) + + // 2. Normalize + const normalized_input = String.fromCodePoint(...mapped_input).normalize('NFKC') + + const normalized_map = normalized_input.split('').map(getCodePoint) + + // 3. Prohibit + const hasProhibited = normalized_map.some(character => + prohibited_characters.has(character) + ) + + if (hasProhibited) { + throw new Error( + 'Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3' + ) + } + + // Unassigned Code Points + if (opts.allowUnassigned !== true) { + const hasUnassigned = normalized_map.some(character => + unassigned_code_points.has(character) + ) + + if (hasUnassigned) { + throw new Error( + 'Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5' + ) + } + } + + // 4. check bidi + + const hasBidiRAL = normalized_map + .some((character) => bidirectional_r_al.has(character)) + + const hasBidiL = normalized_map + .some((character) => bidirectional_l.has(character)) + + // 4.1 If a string contains any RandALCat character, the string MUST NOT + // contain any LCat character. + if (hasBidiRAL && hasBidiL) { + throw new Error( + 'String must not contain RandALCat and LCat at the same time,' + + ' see https://tools.ietf.org/html/rfc3454#section-6' + ) + } + + /** + * 4.2 If a string contains any RandALCat character, a RandALCat + * character MUST be the first character of the string, and a + * RandALCat character MUST be the last character of the string. + */ + + const isFirstBidiRAL = bidirectional_r_al.has(getCodePoint(first(normalized_input))) + const isLastBidiRAL = bidirectional_r_al.has(getCodePoint(last(normalized_input))) + + if (hasBidiRAL && !(isFirstBidiRAL && isLastBidiRAL)) { + throw new Error( + 'Bidirectional RandALCat character must be the first and the last' + + ' character of the string, see https://tools.ietf.org/html/rfc3454#section-6' + ) + } + + return normalized_input +} diff --git a/node_modules/saslprep/lib/code-points.js b/node_modules/saslprep/lib/code-points.js new file mode 100644 index 0000000..4c5885a --- /dev/null +++ b/node_modules/saslprep/lib/code-points.js @@ -0,0 +1,996 @@ +'use strict' + +const { range } = require('./util') + +/** + * A.1 Unassigned code points in Unicode 3.2 + * @link https://tools.ietf.org/html/rfc3454#appendix-A.1 + */ +const unassigned_code_points = new Set([ + 0x0221, + ...range(0x0234, 0x024F), + ...range(0x02AE, 0x02AF), + ...range(0x02EF, 0x02FF), + ...range(0x0350, 0x035F), + ...range(0x0370, 0x0373), + ...range(0x0376, 0x0379), + ...range(0x037B, 0x037D), + ...range(0x037F, 0x0383), + 0x038B, + 0x038D, + 0x03A2, + 0x03CF, + ...range(0x03F7, 0x03FF), + 0x0487, + 0x04CF, + ...range(0x04F6, 0x04F7), + ...range(0x04FA, 0x04FF), + ...range(0x0510, 0x0530), + ...range(0x0557, 0x0558), + 0x0560, + 0x0588, + ...range(0x058B, 0x0590), + 0x05A2, + 0x05BA, + ...range(0x05C5, 0x05CF), + ...range(0x05EB, 0x05EF), + ...range(0x05F5, 0x060B), + ...range(0x060D, 0x061A), + ...range(0x061C, 0x061E), + 0x0620, + ...range(0x063B, 0x063F), + ...range(0x0656, 0x065F), + ...range(0x06EE, 0x06EF), + 0x06FF, + 0x070E, + ...range(0x072D, 0x072F), + ...range(0x074B, 0x077F), + ...range(0x07B2, 0x0900), + 0x0904, + ...range(0x093A, 0x093B), + ...range(0x094E, 0x094F), + ...range(0x0955, 0x0957), + ...range(0x0971, 0x0980), + 0x0984, + ...range(0x098D, 0x098E), + ...range(0x0991, 0x0992), + 0x09A9, + 0x09B1, + ...range(0x09B3, 0x09B5), + ...range(0x09BA, 0x09BB), + 0x09BD, + ...range(0x09C5, 0x09C6), + ...range(0x09C9, 0x09CA), + ...range(0x09CE, 0x09D6), + ...range(0x09D8, 0x09DB), + 0x09DE, + ...range(0x09E4, 0x09E5), + ...range(0x09FB, 0x0A01), + ...range(0x0A03, 0x0A04), + ...range(0x0A0B, 0x0A0E), + ...range(0x0A11, 0x0A12), + 0x0A29, + 0x0A31, + 0x0A34, + 0x0A37, + ...range(0x0A3A, 0x0A3B), + 0x0A3D, + ...range(0x0A43, 0x0A46), + ...range(0x0A49, 0x0A4A), + ...range(0x0A4E, 0x0A58), + 0x0A5D, + ...range(0x0A5F, 0x0A65), + ...range(0x0A75, 0x0A80), + 0x0A84, + 0x0A8C, + 0x0A8E, + 0x0A92, + 0x0AA9, + 0x0AB1, + 0x0AB4, + ...range(0x0ABA, 0x0ABB), + 0x0AC6, + 0x0ACA, + ...range(0x0ACE, 0x0ACF), + ...range(0x0AD1, 0x0ADF), + ...range(0x0AE1, 0x0AE5), + ...range(0x0AF0, 0x0B00), + 0x0B04, + ...range(0x0B0D, 0x0B0E), + ...range(0x0B11, 0x0B12), + 0x0B29, + 0x0B31, + ...range(0x0B34, 0x0B35), + ...range(0x0B3A, 0x0B3B), + ...range(0x0B44, 0x0B46), + ...range(0x0B49, 0x0B4A), + ...range(0x0B4E, 0x0B55), + ...range(0x0B58, 0x0B5B), + 0x0B5E, + ...range(0x0B62, 0x0B65), + ...range(0x0B71, 0x0B81), + 0x0B84, + ...range(0x0B8B, 0x0B8D), + 0x0B91, + ...range(0x0B96, 0x0B98), + 0x0B9B, + 0x0B9D, + ...range(0x0BA0, 0x0BA2), + ...range(0x0BA5, 0x0BA7), + ...range(0x0BAB, 0x0BAD), + 0x0BB6, + ...range(0x0BBA, 0x0BBD), + ...range(0x0BC3, 0x0BC5), + 0x0BC9, + ...range(0x0BCE, 0x0BD6), + ...range(0x0BD8, 0x0BE6), + ...range(0x0BF3, 0x0C00), + 0x0C04, + 0x0C0D, + 0x0C11, + 0x0C29, + 0x0C34, + ...range(0x0C3A, 0x0C3D), + 0x0C45, + 0x0C49, + ...range(0x0C4E, 0x0C54), + ...range(0x0C57, 0x0C5F), + ...range(0x0C62, 0x0C65), + ...range(0x0C70, 0x0C81), + 0x0C84, + 0x0C8D, + 0x0C91, + 0x0CA9, + 0x0CB4, + ...range(0x0CBA, 0x0CBD), + 0x0CC5, + 0x0CC9, + ...range(0x0CCE, 0x0CD4), + ...range(0x0CD7, 0x0CDD), + 0x0CDF, + ...range(0x0CE2, 0x0CE5), + ...range(0x0CF0, 0x0D01), + 0x0D04, + 0x0D0D, + 0x0D11, + 0x0D29, + ...range(0x0D3A, 0x0D3D), + ...range(0x0D44, 0x0D45), + 0x0D49, + ...range(0x0D4E, 0x0D56), + ...range(0x0D58, 0x0D5F), + ...range(0x0D62, 0x0D65), + ...range(0x0D70, 0x0D81), + 0x0D84, + ...range(0x0D97, 0x0D99), + 0x0DB2, + 0x0DBC, + ...range(0x0DBE, 0x0DBF), + ...range(0x0DC7, 0x0DC9), + ...range(0x0DCB, 0x0DCE), + 0x0DD5, + 0x0DD7, + ...range(0x0DE0, 0x0DF1), + ...range(0x0DF5, 0x0E00), + ...range(0x0E3B, 0x0E3E), + ...range(0x0E5C, 0x0E80), + 0x0E83, + ...range(0x0E85, 0x0E86), + 0x0E89, + ...range(0x0E8B, 0x0E8C), + ...range(0x0E8E, 0x0E93), + 0x0E98, + 0x0EA0, + 0x0EA4, + 0x0EA6, + ...range(0x0EA8, 0x0EA9), + 0x0EAC, + 0x0EBA, + ...range(0x0EBE, 0x0EBF), + 0x0EC5, + 0x0EC7, + ...range(0x0ECE, 0x0ECF), + ...range(0x0EDA, 0x0EDB), + ...range(0x0EDE, 0x0EFF), + 0x0F48, + ...range(0x0F6B, 0x0F70), + ...range(0x0F8C, 0x0F8F), + 0x0F98, + 0x0FBD, + ...range(0x0FCD, 0x0FCE), + ...range(0x0FD0, 0x0FFF), + 0x1022, + 0x1028, + 0x102B, + ...range(0x1033, 0x1035), + ...range(0x103A, 0x103F), + ...range(0x105A, 0x109F), + ...range(0x10C6, 0x10CF), + ...range(0x10F9, 0x10FA), + ...range(0x10FC, 0x10FF), + ...range(0x115A, 0x115E), + ...range(0x11A3, 0x11A7), + ...range(0x11FA, 0x11FF), + 0x1207, + 0x1247, + 0x1249, + ...range(0x124E, 0x124F), + 0x1257, + 0x1259, + ...range(0x125E, 0x125F), + 0x1287, + 0x1289, + ...range(0x128E, 0x128F), + 0x12AF, + 0x12B1, + ...range(0x12B6, 0x12B7), + 0x12BF, + 0x12C1, + ...range(0x12C6, 0x12C7), + 0x12CF, + 0x12D7, + 0x12EF, + 0x130F, + 0x1311, + ...range(0x1316, 0x1317), + 0x131F, + 0x1347, + ...range(0x135B, 0x1360), + ...range(0x137D, 0x139F), + ...range(0x13F5, 0x1400), + ...range(0x1677, 0x167F), + ...range(0x169D, 0x169F), + ...range(0x16F1, 0x16FF), + 0x170D, + ...range(0x1715, 0x171F), + ...range(0x1737, 0x173F), + ...range(0x1754, 0x175F), + 0x176D, + 0x1771, + ...range(0x1774, 0x177F), + ...range(0x17DD, 0x17DF), + ...range(0x17EA, 0x17FF), + 0x180F, + ...range(0x181A, 0x181F), + ...range(0x1878, 0x187F), + ...range(0x18AA, 0x1DFF), + ...range(0x1E9C, 0x1E9F), + ...range(0x1EFA, 0x1EFF), + ...range(0x1F16, 0x1F17), + ...range(0x1F1E, 0x1F1F), + ...range(0x1F46, 0x1F47), + ...range(0x1F4E, 0x1F4F), + 0x1F58, + 0x1F5A, + 0x1F5C, + 0x1F5E, + ...range(0x1F7E, 0x1F7F), + 0x1FB5, + 0x1FC5, + ...range(0x1FD4, 0x1FD5), + 0x1FDC, + ...range(0x1FF0, 0x1FF1), + 0x1FF5, + 0x1FFF, + ...range(0x2053, 0x2056), + ...range(0x2058, 0x205E), + ...range(0x2064, 0x2069), + ...range(0x2072, 0x2073), + ...range(0x208F, 0x209F), + ...range(0x20B2, 0x20CF), + ...range(0x20EB, 0x20FF), + ...range(0x213B, 0x213C), + ...range(0x214C, 0x2152), + ...range(0x2184, 0x218F), + ...range(0x23CF, 0x23FF), + ...range(0x2427, 0x243F), + ...range(0x244B, 0x245F), + 0x24FF, + ...range(0x2614, 0x2615), + 0x2618, + ...range(0x267E, 0x267F), + ...range(0x268A, 0x2700), + 0x2705, + ...range(0x270A, 0x270B), + 0x2728, + 0x274C, + 0x274E, + ...range(0x2753, 0x2755), + 0x2757, + ...range(0x275F, 0x2760), + ...range(0x2795, 0x2797), + 0x27B0, + ...range(0x27BF, 0x27CF), + ...range(0x27EC, 0x27EF), + ...range(0x2B00, 0x2E7F), + 0x2E9A, + ...range(0x2EF4, 0x2EFF), + ...range(0x2FD6, 0x2FEF), + ...range(0x2FFC, 0x2FFF), + 0x3040, + ...range(0x3097, 0x3098), + ...range(0x3100, 0x3104), + ...range(0x312D, 0x3130), + 0x318F, + ...range(0x31B8, 0x31EF), + ...range(0x321D, 0x321F), + ...range(0x3244, 0x3250), + ...range(0x327C, 0x327E), + ...range(0x32CC, 0x32CF), + 0x32FF, + ...range(0x3377, 0x337A), + ...range(0x33DE, 0x33DF), + 0x33FF, + ...range(0x4DB6, 0x4DFF), + ...range(0x9FA6, 0x9FFF), + ...range(0xA48D, 0xA48F), + ...range(0xA4C7, 0xABFF), + ...range(0xD7A4, 0xD7FF), + ...range(0xFA2E, 0xFA2F), + ...range(0xFA6B, 0xFAFF), + ...range(0xFB07, 0xFB12), + ...range(0xFB18, 0xFB1C), + 0xFB37, + 0xFB3D, + 0xFB3F, + 0xFB42, + 0xFB45, + ...range(0xFBB2, 0xFBD2), + ...range(0xFD40, 0xFD4F), + ...range(0xFD90, 0xFD91), + ...range(0xFDC8, 0xFDCF), + ...range(0xFDFD, 0xFDFF), + ...range(0xFE10, 0xFE1F), + ...range(0xFE24, 0xFE2F), + ...range(0xFE47, 0xFE48), + 0xFE53, + 0xFE67, + ...range(0xFE6C, 0xFE6F), + 0xFE75, + ...range(0xFEFD, 0xFEFE), + 0xFF00, + ...range(0xFFBF, 0xFFC1), + ...range(0xFFC8, 0xFFC9), + ...range(0xFFD0, 0xFFD1), + ...range(0xFFD8, 0xFFD9), + ...range(0xFFDD, 0xFFDF), + 0xFFE7, + ...range(0xFFEF, 0xFFF8), + ...range(0x10000, 0x102FF), + 0x1031F, + ...range(0x10324, 0x1032F), + ...range(0x1034B, 0x103FF), + ...range(0x10426, 0x10427), + ...range(0x1044E, 0x1CFFF), + ...range(0x1D0F6, 0x1D0FF), + ...range(0x1D127, 0x1D129), + ...range(0x1D1DE, 0x1D3FF), + 0x1D455, + 0x1D49D, + ...range(0x1D4A0, 0x1D4A1), + ...range(0x1D4A3, 0x1D4A4), + ...range(0x1D4A7, 0x1D4A8), + 0x1D4AD, + 0x1D4BA, + 0x1D4BC, + 0x1D4C1, + 0x1D4C4, + 0x1D506, + ...range(0x1D50B, 0x1D50C), + 0x1D515, + 0x1D51D, + 0x1D53A, + 0x1D53F, + 0x1D545, + ...range(0x1D547, 0x1D549), + 0x1D551, + ...range(0x1D6A4, 0x1D6A7), + ...range(0x1D7CA, 0x1D7CD), + ...range(0x1D800, 0x1FFFD), + ...range(0x2A6D7, 0x2F7FF), + ...range(0x2FA1E, 0x2FFFD), + ...range(0x30000, 0x3FFFD), + ...range(0x40000, 0x4FFFD), + ...range(0x50000, 0x5FFFD), + ...range(0x60000, 0x6FFFD), + ...range(0x70000, 0x7FFFD), + ...range(0x80000, 0x8FFFD), + ...range(0x90000, 0x9FFFD), + ...range(0xA0000, 0xAFFFD), + ...range(0xB0000, 0xBFFFD), + ...range(0xC0000, 0xCFFFD), + ...range(0xD0000, 0xDFFFD), + 0xE0000, + ...range(0xE0002, 0xE001F), + ...range(0xE0080, 0xEFFFD), +]) + +/** + * B.1 Commonly mapped to nothing + * @link https://tools.ietf.org/html/rfc3454#appendix-B.1 + */ +const commonly_mapped_to_nothing = new Set([ + 0x00AD, + 0x034F, + 0x1806, + 0x180B, + 0x180C, + 0x180D, + 0x200B, + 0x200C, + 0x200D, + 0x2060, + 0xFE00, + 0xFE01, + 0xFE02, + 0xFE03, + 0xFE04, + 0xFE05, + 0xFE06, + 0xFE07, + 0xFE08, + 0xFE09, + 0xFE0A, + 0xFE0B, + 0xFE0C, + 0xFE0D, + 0xFE0E, + 0xFE0F, + 0xFEFF, +]) + +/** + * C.1.2 Non-ASCII space characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2 + */ +const non_ASCII_space_characters = new Set([ + 0x00a0 /* NO-BREAK SPACE */, + 0x1680 /* OGHAM SPACE MARK */, + 0x2000 /* EN QUAD */, + 0x2001 /* EM QUAD */, + 0x2002 /* EN SPACE */, + 0x2003 /* EM SPACE */, + 0x2004 /* THREE-PER-EM SPACE */, + 0x2005 /* FOUR-PER-EM SPACE */, + 0x2006 /* SIX-PER-EM SPACE */, + 0x2007 /* FIGURE SPACE */, + 0x2008 /* PUNCTUATION SPACE */, + 0x2009 /* THIN SPACE */, + 0x200a /* HAIR SPACE */, + 0x200b /* ZERO WIDTH SPACE */, + 0x202f /* NARROW NO-BREAK SPACE */, + 0x205f /* MEDIUM MATHEMATICAL SPACE */, + 0x3000 /* IDEOGRAPHIC SPACE */, +]) + +/** + * 2.3. Prohibited Output + * @type {Set} + */ +const prohibited_characters = new Set([ + ...non_ASCII_space_characters, + + /** + * C.2.1 ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1 + */ + ...range(0, 0x001f) /* [CONTROL CHARACTERS] */, + 0x007f /* DELETE */, + + /** + * C.2.2 Non-ASCII control characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2 + */ + ...range(0x0080, 0x009F), /* [CONTROL CHARACTERS] */ + 0x06DD, /* ARABIC END OF AYAH */ + 0x070F, /* SYRIAC ABBREVIATION MARK */ + 0x180E, /* MONGOLIAN VOWEL SEPARATOR */ + 0x200C, /* ZERO WIDTH NON-JOINER */ + 0x200D, /* ZERO WIDTH JOINER */ + 0x2028, /* LINE SEPARATOR */ + 0x2029, /* PARAGRAPH SEPARATOR */ + 0x2060, /* WORD JOINER */ + 0x2061, /* FUNCTION APPLICATION */ + 0x2062, /* INVISIBLE TIMES */ + 0x2063, /* INVISIBLE SEPARATOR */ + ...range(0x206A, 0x206F), /* [CONTROL CHARACTERS] */ + 0xFEFF, /* ZERO WIDTH NO-BREAK SPACE */ + ...range(0xFFF9, 0xFFFC), /* [CONTROL CHARACTERS] */ + ...range(0x1D173, 0x1D17A), /* [MUSICAL CONTROL CHARACTERS] */ + + /** + * C.3 Private use + * @link https://tools.ietf.org/html/rfc3454#appendix-C.3 + */ + ...range(0xE000, 0xF8FF), /* [PRIVATE USE, PLANE 0] */ + ...range(0xF0000, 0xFFFFD), /* [PRIVATE USE, PLANE 15] */ + ...range(0x100000, 0x10FFFD), /* [PRIVATE USE, PLANE 16] */ + + /** + * C.4 Non-character code points + * @link https://tools.ietf.org/html/rfc3454#appendix-C.4 + */ + ...range(0xFDD0, 0xFDEF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xFFFE, 0xFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x1FFFE, 0x1FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x2FFFE, 0x2FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x3FFFE, 0x3FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x4FFFE, 0x4FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x5FFFE, 0x5FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x6FFFE, 0x6FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x7FFFE, 0x7FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x8FFFE, 0x8FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x9FFFE, 0x9FFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xAFFFE, 0xAFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xBFFFE, 0xBFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xCFFFE, 0xCFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xDFFFE, 0xDFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0xEFFFE, 0xEFFFF), /* [NONCHARACTER CODE POINTS] */ + ...range(0x10FFFE, 0x10FFFF), /* [NONCHARACTER CODE POINTS] */ + + /** + * C.5 Surrogate codes + * @link https://tools.ietf.org/html/rfc3454#appendix-C.5 + */ + ...range(0xD800, 0xDFFF), + + /** + * C.6 Inappropriate for plain text + * @link https://tools.ietf.org/html/rfc3454#appendix-C.6 + */ + 0xFFF9, /* INTERLINEAR ANNOTATION ANCHOR */ + 0xFFFA, /* INTERLINEAR ANNOTATION SEPARATOR */ + 0xFFFB, /* INTERLINEAR ANNOTATION TERMINATOR */ + 0xFFFC, /* OBJECT REPLACEMENT CHARACTER */ + 0xFFFD, /* REPLACEMENT CHARACTER */ + + /** + * C.7 Inappropriate for canonical representation + * @link https://tools.ietf.org/html/rfc3454#appendix-C.7 + */ + ...range(0x2FF0, 0x2FFB), /* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */ + + /** + * C.8 Change display properties or are deprecated + * @link https://tools.ietf.org/html/rfc3454#appendix-C.8 + */ + 0x0340, /* COMBINING GRAVE TONE MARK */ + 0x0341, /* COMBINING ACUTE TONE MARK */ + 0x200E, /* LEFT-TO-RIGHT MARK */ + 0x200F, /* RIGHT-TO-LEFT MARK */ + 0x202A, /* LEFT-TO-RIGHT EMBEDDING */ + 0x202B, /* RIGHT-TO-LEFT EMBEDDING */ + 0x202C, /* POP DIRECTIONAL FORMATTING */ + 0x202D, /* LEFT-TO-RIGHT OVERRIDE */ + 0x202E, /* RIGHT-TO-LEFT OVERRIDE */ + 0x206A, /* INHIBIT SYMMETRIC SWAPPING */ + 0x206B, /* ACTIVATE SYMMETRIC SWAPPING */ + 0x206C, /* INHIBIT ARABIC FORM SHAPING */ + 0x206D, /* ACTIVATE ARABIC FORM SHAPING */ + 0x206E, /* NATIONAL DIGIT SHAPES */ + 0x206F, /* NOMINAL DIGIT SHAPES */ + + /** + * C.9 Tagging characters + * @link https://tools.ietf.org/html/rfc3454#appendix-C.9 + */ + 0xE0001, /* LANGUAGE TAG */ + ...range(0xE0020, 0xE007F) /* [TAGGING CHARACTERS] */ +]) + +/** + * D.1 Characters with bidirectional property "R" or "AL" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.1 + */ +const bidirectional_r_al = new Set([ + 0x05BE, + 0x05C0, + 0x05C3, + ...range(0x05D0, 0x05EA), + ...range(0x05F0, 0x05F4), + 0x061B, + 0x061F, + ...range(0x0621, 0x063A), + ...range(0x0640, 0x064A), + ...range(0x066D, 0x066F), + ...range(0x0671, 0x06D5), + 0x06DD, + ...range(0x06E5, 0x06E6), + ...range(0x06FA, 0x06FE), + ...range(0x0700, 0x070D), + 0x0710, + ...range(0x0712, 0x072C), + ...range(0x0780, 0x07A5), + 0x07B1, + 0x200F, + 0xFB1D, + ...range(0xFB1F, 0xFB28), + ...range(0xFB2A, 0xFB36), + ...range(0xFB38, 0xFB3C), + 0xFB3E, + ...range(0xFB40, 0xFB41), + ...range(0xFB43, 0xFB44), + ...range(0xFB46, 0xFBB1), + ...range(0xFBD3, 0xFD3D), + ...range(0xFD50, 0xFD8F), + ...range(0xFD92, 0xFDC7), + ...range(0xFDF0, 0xFDFC), + ...range(0xFE70, 0xFE74), + ...range(0xFE76, 0xFEFC), +]) + +/** + * D.2 Characters with bidirectional property "L" + * @link https://tools.ietf.org/html/rfc3454#appendix-D.2 + */ +const bidirectional_l = new Set([ + ...range(0x0041, 0x005A), + ...range(0x0061, 0x007A), + 0x00AA, + 0x00B5, + 0x00BA, + ...range(0x00C0, 0x00D6), + ...range(0x00D8, 0x00F6), + ...range(0x00F8, 0x0220), + ...range(0x0222, 0x0233), + ...range(0x0250, 0x02AD), + ...range(0x02B0, 0x02B8), + ...range(0x02BB, 0x02C1), + ...range(0x02D0, 0x02D1), + ...range(0x02E0, 0x02E4), + 0x02EE, + 0x037A, + 0x0386, + ...range(0x0388, 0x038A), + 0x038C, + ...range(0x038E, 0x03A1), + ...range(0x03A3, 0x03CE), + ...range(0x03D0, 0x03F5), + ...range(0x0400, 0x0482), + ...range(0x048A, 0x04CE), + ...range(0x04D0, 0x04F5), + ...range(0x04F8, 0x04F9), + ...range(0x0500, 0x050F), + ...range(0x0531, 0x0556), + ...range(0x0559, 0x055F), + ...range(0x0561, 0x0587), + 0x0589, + 0x0903, + ...range(0x0905, 0x0939), + ...range(0x093D, 0x0940), + ...range(0x0949, 0x094C), + 0x0950, + ...range(0x0958, 0x0961), + ...range(0x0964, 0x0970), + ...range(0x0982, 0x0983), + ...range(0x0985, 0x098C), + ...range(0x098F, 0x0990), + ...range(0x0993, 0x09A8), + ...range(0x09AA, 0x09B0), + 0x09B2, + ...range(0x09B6, 0x09B9), + ...range(0x09BE, 0x09C0), + ...range(0x09C7, 0x09C8), + ...range(0x09CB, 0x09CC), + 0x09D7, + ...range(0x09DC, 0x09DD), + ...range(0x09DF, 0x09E1), + ...range(0x09E6, 0x09F1), + ...range(0x09F4, 0x09FA), + ...range(0x0A05, 0x0A0A), + ...range(0x0A0F, 0x0A10), + ...range(0x0A13, 0x0A28), + ...range(0x0A2A, 0x0A30), + ...range(0x0A32, 0x0A33), + ...range(0x0A35, 0x0A36), + ...range(0x0A38, 0x0A39), + ...range(0x0A3E, 0x0A40), + ...range(0x0A59, 0x0A5C), + 0x0A5E, + ...range(0x0A66, 0x0A6F), + ...range(0x0A72, 0x0A74), + 0x0A83, + ...range(0x0A85, 0x0A8B), + 0x0A8D, + ...range(0x0A8F, 0x0A91), + ...range(0x0A93, 0x0AA8), + ...range(0x0AAA, 0x0AB0), + ...range(0x0AB2, 0x0AB3), + ...range(0x0AB5, 0x0AB9), + ...range(0x0ABD, 0x0AC0), + 0x0AC9, + ...range(0x0ACB, 0x0ACC), + 0x0AD0, + 0x0AE0, + ...range(0x0AE6, 0x0AEF), + ...range(0x0B02, 0x0B03), + ...range(0x0B05, 0x0B0C), + ...range(0x0B0F, 0x0B10), + ...range(0x0B13, 0x0B28), + ...range(0x0B2A, 0x0B30), + ...range(0x0B32, 0x0B33), + ...range(0x0B36, 0x0B39), + ...range(0x0B3D, 0x0B3E), + 0x0B40, + ...range(0x0B47, 0x0B48), + ...range(0x0B4B, 0x0B4C), + 0x0B57, + ...range(0x0B5C, 0x0B5D), + ...range(0x0B5F, 0x0B61), + ...range(0x0B66, 0x0B70), + 0x0B83, + ...range(0x0B85, 0x0B8A), + ...range(0x0B8E, 0x0B90), + ...range(0x0B92, 0x0B95), + ...range(0x0B99, 0x0B9A), + 0x0B9C, + ...range(0x0B9E, 0x0B9F), + ...range(0x0BA3, 0x0BA4), + ...range(0x0BA8, 0x0BAA), + ...range(0x0BAE, 0x0BB5), + ...range(0x0BB7, 0x0BB9), + ...range(0x0BBE, 0x0BBF), + ...range(0x0BC1, 0x0BC2), + ...range(0x0BC6, 0x0BC8), + ...range(0x0BCA, 0x0BCC), + 0x0BD7, + ...range(0x0BE7, 0x0BF2), + ...range(0x0C01, 0x0C03), + ...range(0x0C05, 0x0C0C), + ...range(0x0C0E, 0x0C10), + ...range(0x0C12, 0x0C28), + ...range(0x0C2A, 0x0C33), + ...range(0x0C35, 0x0C39), + ...range(0x0C41, 0x0C44), + ...range(0x0C60, 0x0C61), + ...range(0x0C66, 0x0C6F), + ...range(0x0C82, 0x0C83), + ...range(0x0C85, 0x0C8C), + ...range(0x0C8E, 0x0C90), + ...range(0x0C92, 0x0CA8), + ...range(0x0CAA, 0x0CB3), + ...range(0x0CB5, 0x0CB9), + 0x0CBE, + ...range(0x0CC0, 0x0CC4), + ...range(0x0CC7, 0x0CC8), + ...range(0x0CCA, 0x0CCB), + ...range(0x0CD5, 0x0CD6), + 0x0CDE, + ...range(0x0CE0, 0x0CE1), + ...range(0x0CE6, 0x0CEF), + ...range(0x0D02, 0x0D03), + ...range(0x0D05, 0x0D0C), + ...range(0x0D0E, 0x0D10), + ...range(0x0D12, 0x0D28), + ...range(0x0D2A, 0x0D39), + ...range(0x0D3E, 0x0D40), + ...range(0x0D46, 0x0D48), + ...range(0x0D4A, 0x0D4C), + 0x0D57, + ...range(0x0D60, 0x0D61), + ...range(0x0D66, 0x0D6F), + ...range(0x0D82, 0x0D83), + ...range(0x0D85, 0x0D96), + ...range(0x0D9A, 0x0DB1), + ...range(0x0DB3, 0x0DBB), + 0x0DBD, + ...range(0x0DC0, 0x0DC6), + ...range(0x0DCF, 0x0DD1), + ...range(0x0DD8, 0x0DDF), + ...range(0x0DF2, 0x0DF4), + ...range(0x0E01, 0x0E30), + ...range(0x0E32, 0x0E33), + ...range(0x0E40, 0x0E46), + ...range(0x0E4F, 0x0E5B), + ...range(0x0E81, 0x0E82), + 0x0E84, + ...range(0x0E87, 0x0E88), + 0x0E8A, + 0x0E8D, + ...range(0x0E94, 0x0E97), + ...range(0x0E99, 0x0E9F), + ...range(0x0EA1, 0x0EA3), + 0x0EA5, + 0x0EA7, + ...range(0x0EAA, 0x0EAB), + ...range(0x0EAD, 0x0EB0), + ...range(0x0EB2, 0x0EB3), + 0x0EBD, + ...range(0x0EC0, 0x0EC4), + 0x0EC6, + ...range(0x0ED0, 0x0ED9), + ...range(0x0EDC, 0x0EDD), + ...range(0x0F00, 0x0F17), + ...range(0x0F1A, 0x0F34), + 0x0F36, + 0x0F38, + ...range(0x0F3E, 0x0F47), + ...range(0x0F49, 0x0F6A), + 0x0F7F, + 0x0F85, + ...range(0x0F88, 0x0F8B), + ...range(0x0FBE, 0x0FC5), + ...range(0x0FC7, 0x0FCC), + 0x0FCF, + ...range(0x1000, 0x1021), + ...range(0x1023, 0x1027), + ...range(0x1029, 0x102A), + 0x102C, + 0x1031, + 0x1038, + ...range(0x1040, 0x1057), + ...range(0x10A0, 0x10C5), + ...range(0x10D0, 0x10F8), + 0x10FB, + ...range(0x1100, 0x1159), + ...range(0x115F, 0x11A2), + ...range(0x11A8, 0x11F9), + ...range(0x1200, 0x1206), + ...range(0x1208, 0x1246), + 0x1248, + ...range(0x124A, 0x124D), + ...range(0x1250, 0x1256), + 0x1258, + ...range(0x125A, 0x125D), + ...range(0x1260, 0x1286), + 0x1288, + ...range(0x128A, 0x128D), + ...range(0x1290, 0x12AE), + 0x12B0, + ...range(0x12B2, 0x12B5), + ...range(0x12B8, 0x12BE), + 0x12C0, + ...range(0x12C2, 0x12C5), + ...range(0x12C8, 0x12CE), + ...range(0x12D0, 0x12D6), + ...range(0x12D8, 0x12EE), + ...range(0x12F0, 0x130E), + 0x1310, + ...range(0x1312, 0x1315), + ...range(0x1318, 0x131E), + ...range(0x1320, 0x1346), + ...range(0x1348, 0x135A), + ...range(0x1361, 0x137C), + ...range(0x13A0, 0x13F4), + ...range(0x1401, 0x1676), + ...range(0x1681, 0x169A), + ...range(0x16A0, 0x16F0), + ...range(0x1700, 0x170C), + ...range(0x170E, 0x1711), + ...range(0x1720, 0x1731), + ...range(0x1735, 0x1736), + ...range(0x1740, 0x1751), + ...range(0x1760, 0x176C), + ...range(0x176E, 0x1770), + ...range(0x1780, 0x17B6), + ...range(0x17BE, 0x17C5), + ...range(0x17C7, 0x17C8), + ...range(0x17D4, 0x17DA), + 0x17DC, + ...range(0x17E0, 0x17E9), + ...range(0x1810, 0x1819), + ...range(0x1820, 0x1877), + ...range(0x1880, 0x18A8), + ...range(0x1E00, 0x1E9B), + ...range(0x1EA0, 0x1EF9), + ...range(0x1F00, 0x1F15), + ...range(0x1F18, 0x1F1D), + ...range(0x1F20, 0x1F45), + ...range(0x1F48, 0x1F4D), + ...range(0x1F50, 0x1F57), + 0x1F59, + 0x1F5B, + 0x1F5D, + ...range(0x1F5F, 0x1F7D), + ...range(0x1F80, 0x1FB4), + ...range(0x1FB6, 0x1FBC), + 0x1FBE, + ...range(0x1FC2, 0x1FC4), + ...range(0x1FC6, 0x1FCC), + ...range(0x1FD0, 0x1FD3), + ...range(0x1FD6, 0x1FDB), + ...range(0x1FE0, 0x1FEC), + ...range(0x1FF2, 0x1FF4), + ...range(0x1FF6, 0x1FFC), + 0x200E, + 0x2071, + 0x207F, + 0x2102, + 0x2107, + ...range(0x210A, 0x2113), + 0x2115, + ...range(0x2119, 0x211D), + 0x2124, + 0x2126, + 0x2128, + ...range(0x212A, 0x212D), + ...range(0x212F, 0x2131), + ...range(0x2133, 0x2139), + ...range(0x213D, 0x213F), + ...range(0x2145, 0x2149), + ...range(0x2160, 0x2183), + ...range(0x2336, 0x237A), + 0x2395, + ...range(0x249C, 0x24E9), + ...range(0x3005, 0x3007), + ...range(0x3021, 0x3029), + ...range(0x3031, 0x3035), + ...range(0x3038, 0x303C), + ...range(0x3041, 0x3096), + ...range(0x309D, 0x309F), + ...range(0x30A1, 0x30FA), + ...range(0x30FC, 0x30FF), + ...range(0x3105, 0x312C), + ...range(0x3131, 0x318E), + ...range(0x3190, 0x31B7), + ...range(0x31F0, 0x321C), + ...range(0x3220, 0x3243), + ...range(0x3260, 0x327B), + ...range(0x327F, 0x32B0), + ...range(0x32C0, 0x32CB), + ...range(0x32D0, 0x32FE), + ...range(0x3300, 0x3376), + ...range(0x337B, 0x33DD), + ...range(0x33E0, 0x33FE), + ...range(0x3400, 0x4DB5), + ...range(0x4E00, 0x9FA5), + ...range(0xA000, 0xA48C), + ...range(0xAC00, 0xD7A3), + ...range(0xD800, 0xFA2D), + ...range(0xFA30, 0xFA6A), + ...range(0xFB00, 0xFB06), + ...range(0xFB13, 0xFB17), + ...range(0xFF21, 0xFF3A), + ...range(0xFF41, 0xFF5A), + ...range(0xFF66, 0xFFBE), + ...range(0xFFC2, 0xFFC7), + ...range(0xFFCA, 0xFFCF), + ...range(0xFFD2, 0xFFD7), + ...range(0xFFDA, 0xFFDC), + ...range(0x10300, 0x1031E), + ...range(0x10320, 0x10323), + ...range(0x10330, 0x1034A), + ...range(0x10400, 0x10425), + ...range(0x10428, 0x1044D), + ...range(0x1D000, 0x1D0F5), + ...range(0x1D100, 0x1D126), + ...range(0x1D12A, 0x1D166), + ...range(0x1D16A, 0x1D172), + ...range(0x1D183, 0x1D184), + ...range(0x1D18C, 0x1D1A9), + ...range(0x1D1AE, 0x1D1DD), + ...range(0x1D400, 0x1D454), + ...range(0x1D456, 0x1D49C), + ...range(0x1D49E, 0x1D49F), + 0x1D4A2, + ...range(0x1D4A5, 0x1D4A6), + ...range(0x1D4A9, 0x1D4AC), + ...range(0x1D4AE, 0x1D4B9), + 0x1D4BB, + ...range(0x1D4BD, 0x1D4C0), + ...range(0x1D4C2, 0x1D4C3), + ...range(0x1D4C5, 0x1D505), + ...range(0x1D507, 0x1D50A), + ...range(0x1D50D, 0x1D514), + ...range(0x1D516, 0x1D51C), + ...range(0x1D51E, 0x1D539), + ...range(0x1D53B, 0x1D53E), + ...range(0x1D540, 0x1D544), + 0x1D546, + ...range(0x1D54A, 0x1D550), + ...range(0x1D552, 0x1D6A3), + ...range(0x1D6A8, 0x1D7C9), + ...range(0x20000, 0x2A6D6), + ...range(0x2F800, 0x2FA1D), + ...range(0xF0000, 0xFFFFD), + ...range(0x100000, 0x10FFFD) +]) + +module.exports = { + unassigned_code_points, + commonly_mapped_to_nothing, + non_ASCII_space_characters, + prohibited_characters, + bidirectional_r_al, + bidirectional_l +} diff --git a/node_modules/saslprep/lib/util.js b/node_modules/saslprep/lib/util.js new file mode 100644 index 0000000..697e0d0 --- /dev/null +++ b/node_modules/saslprep/lib/util.js @@ -0,0 +1,15 @@ +'use strict' + +function range(from, to) { + // TODO: make this inlined. + const list = new Array(to - from + 1) + + for(let i = 0; i < list.length; ++i) { + list[i] = from + i + } + return list +} + +module.exports = { + range +} diff --git a/node_modules/saslprep/package.json b/node_modules/saslprep/package.json new file mode 100644 index 0000000..1081ba4 --- /dev/null +++ b/node_modules/saslprep/package.json @@ -0,0 +1,62 @@ +{ + "_from": "saslprep@^1.0.0", + "_id": "saslprep@1.0.1", + "_inBundle": false, + "_integrity": "sha512-ntN6SbE3hRqd45PKKadRPgA+xHPWg5lPSj2JWJdJvjTwXDDfkPVtXWvP8jJojvnm+rAsZ2b299C5NwZqq818EA==", + "_location": "/saslprep", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "saslprep@^1.0.0", + "name": "saslprep", + "escapedName": "saslprep", + "rawSpec": "^1.0.0", + "saveSpec": null, + "fetchSpec": "^1.0.0" + }, + "_requiredBy": [ + "/mongodb-core" + ], + "_resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.1.tgz", + "_shasum": "b644e0ba25b156b652f3cb90df7542f896049ba6", + "_spec": "saslprep@^1.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongodb-core", + "author": { + "name": "Dmitry Tsvettsikh", + "email": "me@reklatsmasters.com" + }, + "bugs": { + "url": "https://github.com/reklatsmasters/saslprep/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "SASLprep: Stringprep Profile for User Names and Passwords, rfc4013.", + "devDependencies": { + "ava": "^0.19.1", + "eslint-plugin-prettier": "^2.1.2", + "prettier": "^1.4.4" + }, + "engines": { + "node": ">=6" + }, + "homepage": "https://github.com/reklatsmasters/saslprep#readme", + "keywords": [ + "sasl", + "saslprep", + "stringprep", + "rfc4013", + "4013" + ], + "license": "MIT", + "main": "index.js", + "name": "saslprep", + "repository": { + "type": "git", + "url": "git+https://github.com/reklatsmasters/saslprep.git" + }, + "scripts": { + "test": "ava" + }, + "version": "1.0.1" +} diff --git a/node_modules/saslprep/readme.md b/node_modules/saslprep/readme.md new file mode 100644 index 0000000..a94e760 --- /dev/null +++ b/node_modules/saslprep/readme.md @@ -0,0 +1,31 @@ +# saslprep +[![Build Status](https://travis-ci.org/reklatsmasters/saslprep.svg?branch=master)](https://travis-ci.org/reklatsmasters/saslprep) +[![npm](https://img.shields.io/npm/v/saslprep.svg)](https://npmjs.org/package/saslprep) +[![node](https://img.shields.io/node/v/saslprep.svg)](https://npmjs.org/package/saslprep) +[![license](https://img.shields.io/npm/l/saslprep.svg)](https://npmjs.org/package/saslprep) +[![downloads](https://img.shields.io/npm/dm/saslprep.svg)](https://npmjs.org/package/saslprep) + +Stringprep Profile for User Names and Passwords, [rfc4013](https://tools.ietf.org/html/rfc4013) + +### Usage + +```js +const saslprep = require('saslprep') + +saslprep('password\u00AD') // password +saslprep('password\u0007') // Error: prohibited character +``` + +### API + +##### `saslprep(input: String, opts: Options): String` + +Normalize user name or password. + +##### `Options.allowUnassigned: bool` + +A special behavior for unassigned code points, see https://tools.ietf.org/html/rfc4013#section-2.5. Disabled by default. + +## License + +MIT, 2017 (c) Dmitriy Tsvettsikh diff --git a/node_modules/saslprep/test/index.js b/node_modules/saslprep/test/index.js new file mode 100644 index 0000000..1fb71cf --- /dev/null +++ b/node_modules/saslprep/test/index.js @@ -0,0 +1,70 @@ +import test from 'ava' +import saslprep from '../' + +const chr = String.fromCodePoint + +test('should work with liatin letters', (t) => { + const str = 'user' + t.is(saslprep(str), str) +}) + +test('should work be case preserved', (t) => { + const str = 'USER' + t.is(saslprep(str), str) +}) + +test('should remove `mapped to nothing` characters', (t) => { + t.is(saslprep('I\u00ADX'), 'IX') +}) + +test('should replace `Non-ASCII space characters` with space', (t) => { + t.is(saslprep('a\u00A0b'), 'a\u0020b') +}) + +test('should normalize as NFKC', (t) => { + t.is(saslprep('\u00AA'), 'a') + t.is(saslprep('\u2168'), 'IX') +}) + +test('should throws when prohibited characters', (t) => { + // C.2.1 ASCII control characters + t.throws(() => saslprep('a\u007Fb')) + + // C.2.2 Non-ASCII control characters + t.throws(() => saslprep('a\u06DDb')) + + // C.3 Private use + t.throws(() => saslprep('a\uE000b')) + + // C.4 Non-character code points + t.throws(() => saslprep(`a${chr(0x1FFFE)}b`)) + + // C.5 Surrogate codes + t.throws(() => saslprep('a\uD800b')) + + // C.6 Inappropriate for plain text + t.throws(() => saslprep('a\uFFF9b')) + + // C.7 Inappropriate for canonical representation + t.throws(() => saslprep('a\u2FF0b')) + + // C.8 Change display properties or are deprecated + t.throws(() => saslprep('a\u200Eb')) + + // C.9 Tagging characters + t.throws(() => saslprep(`a${chr(0xE0001)}b`)) +}) + +test('should not containt RandALCat and LCat bidi', (t) => { + t.throws(() => saslprep('a\u06DD\u00AAb')) +}) + +test('RandALCat should be first and last', (t) => { + t.notThrows(() => saslprep('\u0627\u0031\u0628')) + t.throws(() => saslprep('\u0627\u0031')) +}) + +test('should handle unassigned code points', (t) => { + t.throws(() => saslprep('a\u0487')) + t.notThrows(() => saslprep('a\u0487', {allowUnassigned: true})) +}) diff --git a/node_modules/saslprep/test/util.js b/node_modules/saslprep/test/util.js new file mode 100644 index 0000000..fb39a85 --- /dev/null +++ b/node_modules/saslprep/test/util.js @@ -0,0 +1,15 @@ +import { setFlagsFromString } from 'v8' +import { range } from '../lib/util' +import test from 'ava' + +// 984 by default. +setFlagsFromString('--stack_size=500') + +test('should work', (t) => { + const list = range(1, 3) + t.deepEqual(list, [1, 2, 3]) +}) + +test('should work for large ranges', (t) => { + t.notThrows(() => range(1, 1e6)) +}) diff --git a/node_modules/scmp/package.json b/node_modules/scmp/package.json index d7bfa20..3c0f790 100644 --- a/node_modules/scmp/package.json +++ b/node_modules/scmp/package.json @@ -1,35 +1,38 @@ { - "_from": "scmp@^1.0.0", + "_args": [ + [ + "scmp@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "scmp@1.0.2", "_id": "scmp@1.0.2", "_inBundle": false, "_integrity": "sha1-vE5OJxMlKwQhDN/5zvOt4sj6c3A=", "_location": "/scmp", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "scmp@^1.0.0", + "raw": "scmp@1.0.2", "name": "scmp", "escapedName": "scmp", - "rawSpec": "^1.0.0", + "rawSpec": "1.0.2", "saveSpec": null, - "fetchSpec": "^1.0.0" + "fetchSpec": "1.0.2" }, "_requiredBy": [ "/passport-local-mongoose" ], "_resolved": "https://registry.npmjs.org/scmp/-/scmp-1.0.2.tgz", - "_shasum": "bc4e4e2713252b04210cdff9cef3ade2c8fa7370", - "_spec": "scmp@^1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/passport-local-mongoose", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Sean Lavine" }, "bugs": { "url": "https://github.com/freewil/scmp/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "safe, constant-time string-comparison", "devDependencies": { "matcha": "^0.7.0", diff --git a/node_modules/semver/README.md b/node_modules/semver/README.md index 951c539..9f7161e 100644 --- a/node_modules/semver/README.md +++ b/node_modules/semver/README.md @@ -274,7 +274,7 @@ logical-or ::= ( ' ' ) * '||' ( ' ' ) * range ::= hyphen | simple ( ' ' simple ) * | '' hyphen ::= partial ' - ' partial simple ::= primitive | partial | tilde | caret -primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial +primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? xr ::= 'x' | 'X' | '*' | nr nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index d83ef05..eadf95c 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -1,8 +1,8 @@ { "_from": "semver@^5.1.0", - "_id": "semver@5.5.0", + "_id": "semver@5.5.1", "_inBundle": false, - "_integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "_integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", "_location": "/semver", "_phantomChildren": {}, "_requested": { @@ -18,8 +18,8 @@ "_requiredBy": [ "/require_optional" ], - "_resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "_shasum": "dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab", + "_resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", + "_shasum": "7dfdd8814bdb7cabc7be0fb1d734cfb66c940477", "_spec": "semver@^5.1.0", "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/require_optional", "bin": { @@ -32,7 +32,7 @@ "deprecated": false, "description": "The semantic version parser used by npm.", "devDependencies": { - "tap": "^10.7.0" + "tap": "^12.0.1" }, "files": [ "bin", @@ -50,5 +50,5 @@ "scripts": { "test": "tap test/*.js --cov -J" }, - "version": "5.5.0" + "version": "5.5.1" } diff --git a/node_modules/serve-favicon/node_modules/etag/package.json b/node_modules/serve-favicon/node_modules/etag/package.json index b1b5d22..edce1fa 100644 --- a/node_modules/serve-favicon/node_modules/etag/package.json +++ b/node_modules/serve-favicon/node_modules/etag/package.json @@ -1,7 +1,35 @@ { - "name": "etag", - "description": "Create simple ETags", - "version": "1.7.0", + "_args": [ + [ + "etag@1.7.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "etag@1.7.0", + "_id": "etag@1.7.0", + "_inBundle": false, + "_integrity": "sha1-A9MLX2fdbmMtKUXTDWZScxo01dg=", + "_location": "/serve-favicon/etag", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "etag@1.7.0", + "name": "etag", + "escapedName": "etag", + "rawSpec": "1.7.0", + "saveSpec": null, + "fetchSpec": "1.7.0" + }, + "_requiredBy": [ + "/serve-favicon" + ], + "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", + "_spec": "1.7.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/jshttp/etag/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -12,31 +40,34 @@ "email": "david.bjorklund@gmail.com" } ], - "license": "MIT", - "keywords": [ - "etag", - "http", - "res" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/etag.git" - }, + "description": "Create simple ETags", "devDependencies": { - "benchmark": "1.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "1.0.0", "istanbul": "0.3.14", "mocha": "~1.21.4", "seedrandom": "2.3.11" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/etag#readme", + "keywords": [ + "etag", + "http", + "res" + ], + "license": "MIT", + "name": "etag", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/etag.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -44,30 +75,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "a511f5c8c930fd9546dbd88acb080f96bc788cfc", - "bugs": { - "url": "https://github.com/jshttp/etag/issues" - }, - "homepage": "https://github.com/jshttp/etag", - "_id": "etag@1.7.0", - "_shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "_from": "etag@>=1.7.0 <1.8.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "03d30b5f67dd6e632d2945d30d6652731a34d5d8", - "tarball": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz", - "readme": "ERROR: No README data found!" + "version": "1.7.0" } diff --git a/node_modules/serve-favicon/node_modules/fresh/package.json b/node_modules/serve-favicon/node_modules/fresh/package.json index c0fc622..734b4db 100644 --- a/node_modules/serve-favicon/node_modules/fresh/package.json +++ b/node_modules/serve-favicon/node_modules/fresh/package.json @@ -1,12 +1,40 @@ { - "name": "fresh", - "description": "HTTP response freshness testing", - "version": "0.3.0", + "_args": [ + [ + "fresh@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "fresh@0.3.0", + "_id": "fresh@0.3.0", + "_inBundle": false, + "_integrity": "sha1-ZR+DjiJCTnVm3hYdg1jKoZn4PU8=", + "_location": "/serve-favicon/fresh", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "fresh@0.3.0", + "name": "fresh", + "escapedName": "fresh", + "rawSpec": "0.3.0", + "saveSpec": null, + "fetchSpec": "0.3.0" + }, + "_requiredBy": [ + "/serve-favicon" + ], + "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca", "url": "http://tjholowaychuk.com" }, + "bugs": { + "url": "https://github.com/jshttp/fresh/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -18,70 +46,36 @@ "url": "http://jongleberry.com" } ], - "license": "MIT", - "keywords": [ - "fresh", - "http", - "conditional", - "cache" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/jshttp/fresh.git" - }, + "description": "HTTP response freshness testing", "devDependencies": { "istanbul": "0.3.9", "mocha": "1.21.5" }, + "engines": { + "node": ">= 0.6" + }, "files": [ "HISTORY.md", "LICENSE", "index.js" ], - "engines": { - "node": ">= 0.6" + "homepage": "https://github.com/jshttp/fresh#readme", + "keywords": [ + "fresh", + "http", + "conditional", + "cache" + ], + "license": "MIT", + "name": "fresh", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/fresh.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" }, - "gitHead": "14616c9748368ca08cd6a955dd88ab659b778634", - "bugs": { - "url": "https://github.com/jshttp/fresh/issues" - }, - "homepage": "https://github.com/jshttp/fresh", - "_id": "fresh@0.3.0", - "_shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "_from": "fresh@0.3.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "jonathanong", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - } - ], - "dist": { - "shasum": "651f838e22424e7566de161d8358caa199f83d4f", - "tarball": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz", - "readme": "ERROR: No README data found!" + "version": "0.3.0" } diff --git a/node_modules/serve-favicon/node_modules/ms/package.json b/node_modules/serve-favicon/node_modules/ms/package.json index 706e8b8..e988710 100644 --- a/node_modules/serve-favicon/node_modules/ms/package.json +++ b/node_modules/serve-favicon/node_modules/ms/package.json @@ -1,31 +1,63 @@ { - "name": "ms", - "version": "0.7.2", - "description": "Tiny milisecond conversion utility", - "repository": { - "type": "git", - "url": "git+https://github.com/zeit/ms.git" + "_args": [ + [ + "ms@0.7.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "ms@0.7.2", + "_id": "ms@0.7.2", + "_inBundle": false, + "_integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "_location": "/serve-favicon/ms", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "ms@0.7.2", + "name": "ms", + "escapedName": "ms", + "rawSpec": "0.7.2", + "saveSpec": null, + "fetchSpec": "0.7.2" }, - "main": "./index", - "files": [ - "index.js" + "_requiredBy": [ + "/serve-favicon" ], - "scripts": { - "test": "xo && mocha test/index.js", - "test-browser": "serve ./test" + "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", + "_spec": "0.7.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", + "bugs": { + "url": "https://github.com/zeit/ms/issues" }, - "license": "MIT", + "component": { + "scripts": { + "ms/index.js": "index.js" + } + }, + "description": "Tiny milisecond conversion utility", "devDependencies": { "expect.js": "^0.3.1", "mocha": "^3.0.2", "serve": "^1.4.0", "xo": "^0.17.0" }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } + "files": [ + "index.js" + ], + "homepage": "https://github.com/zeit/ms#readme", + "license": "MIT", + "main": "./index", + "name": "ms", + "repository": { + "type": "git", + "url": "git+https://github.com/zeit/ms.git" + }, + "scripts": { + "test": "xo && mocha test/index.js", + "test-browser": "serve ./test" }, + "version": "0.7.2", "xo": { "space": true, "semicolon": false, @@ -35,40 +67,5 @@ "rules": { "complexity": 0 } - }, - "gitHead": "ac92a7e0790ba2622a74d9d60690ca0d2c070a45", - "bugs": { - "url": "https://github.com/zeit/ms/issues" - }, - "homepage": "https://github.com/zeit/ms#readme", - "_id": "ms@0.7.2", - "_shasum": "ae25cf2512b3885a1d95d7f037868d8431124765", - "_from": "ms@0.7.2", - "_npmVersion": "3.10.8", - "_nodeVersion": "6.8.0", - "_npmUser": { - "name": "leo", - "email": "leo@zeit.co" - }, - "dist": { - "shasum": "ae25cf2512b3885a1d95d7f037868d8431124765", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - }, - "maintainers": [ - { - "name": "leo", - "email": "leo@zeit.co" - }, - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/ms-0.7.2.tgz_1477383407940_0.4743474116548896" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "readme": "ERROR: No README data found!" + } } diff --git a/node_modules/serve-favicon/node_modules/parseurl/package.json b/node_modules/serve-favicon/node_modules/parseurl/package.json index 7f57caa..8a57bc9 100644 --- a/node_modules/serve-favicon/node_modules/parseurl/package.json +++ b/node_modules/serve-favicon/node_modules/parseurl/package.json @@ -1,38 +1,69 @@ { - "name": "parseurl", - "description": "parse a url with memoization", - "version": "1.3.1", + "_args": [ + [ + "parseurl@1.3.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "parseurl@1.3.1", + "_id": "parseurl@1.3.1", + "_inBundle": false, + "_integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", + "_location": "/serve-favicon/parseurl", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "parseurl@1.3.1", + "name": "parseurl", + "escapedName": "parseurl", + "rawSpec": "1.3.1", + "saveSpec": null, + "fetchSpec": "1.3.1" + }, + "_requiredBy": [ + "/serve-favicon" + ], + "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "_spec": "1.3.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jonathan Ong", "email": "me@jongleberry.com", "url": "http://jongleberry.com" }, + "bugs": { + "url": "https://github.com/pillarjs/parseurl/issues" + }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], - "repository": { - "type": "git", - "url": "git+https://github.com/pillarjs/parseurl.git" - }, - "license": "MIT", + "description": "parse a url with memoization", "devDependencies": { - "benchmark": "2.0.0", "beautify-benchmark": "0.2.4", + "benchmark": "2.0.0", "fast-url-parser": "1.1.3", "istanbul": "0.4.2", "mocha": "~1.21.5" }, + "engines": { + "node": ">= 0.8" + }, "files": [ "LICENSE", "HISTORY.md", "README.md", "index.js" ], - "engines": { - "node": ">= 0.8" + "homepage": "https://github.com/pillarjs/parseurl#readme", + "license": "MIT", + "name": "parseurl", + "repository": { + "type": "git", + "url": "git+https://github.com/pillarjs/parseurl.git" }, "scripts": { "bench": "node benchmark/index.js", @@ -40,50 +71,5 @@ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec test/" }, - "gitHead": "6d22d376d75b927ab2b5347ce3a1d6735133dd43", - "bugs": { - "url": "https://github.com/pillarjs/parseurl/issues" - }, - "homepage": "https://github.com/pillarjs/parseurl", - "_id": "parseurl@1.3.1", - "_shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "_from": "parseurl@>=1.3.1 <1.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "jongleberry", - "email": "jonathanrichardong@gmail.com" - }, - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "mscdex", - "email": "mscdex@mscdex.net" - }, - { - "name": "fishrock123", - "email": "fishrock123@rocketmail.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - } - ], - "dist": { - "shasum": "c8ab8c9223ba34888aa64a297b28853bec18da56", - "tarball": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "readme": "ERROR: No README data found!" + "version": "1.3.1" } diff --git a/node_modules/serve-favicon/package.json b/node_modules/serve-favicon/package.json index 3f1d57d..9fcc8ee 100644 --- a/node_modules/serve-favicon/package.json +++ b/node_modules/serve-favicon/package.json @@ -1,20 +1,38 @@ { - "name": "serve-favicon", - "description": "favicon serving middleware with caching", - "version": "2.3.2", + "_args": [ + [ + "serve-favicon@2.3.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "serve-favicon@2.3.2", + "_id": "serve-favicon@2.3.2", + "_inBundle": false, + "_integrity": "sha1-3UGeJo3gEqtysxnTN/IQUBP5OB8=", + "_location": "/serve-favicon", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "serve-favicon@2.3.2", + "name": "serve-favicon", + "escapedName": "serve-favicon", + "rawSpec": "2.3.2", + "saveSpec": null, + "fetchSpec": "2.3.2" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/serve-favicon/-/serve-favicon-2.3.2.tgz", + "_spec": "2.3.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, - "license": "MIT", - "keywords": [ - "express", - "favicon", - "middleware" - ], - "repository": { - "type": "git", - "url": "https://github.com/expressjs/serve-favicon" + "bugs": { + "url": "https://github.com/expressjs/serve-favicon/issues" }, "dependencies": { "etag": "~1.7.0", @@ -22,52 +40,37 @@ "ms": "0.7.2", "parseurl": "~1.3.1" }, + "description": "favicon serving middleware with caching", "devDependencies": { "istanbul": "0.4.5", "mocha": "2.5.3", "proxyquire": "1.4.0", "supertest": "1.1.0" }, + "engines": { + "node": ">= 0.8.0" + }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], - "engines": { - "node": ">= 0.8.0" + "homepage": "https://github.com/expressjs/serve-favicon#readme", + "keywords": [ + "express", + "favicon", + "middleware" + ], + "license": "MIT", + "name": "serve-favicon", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/serve-favicon.git" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, - "gitHead": "4dafcef8a2ddd26731ed12bfc8c958312889eb7e", - "bugs": { - "url": "https://github.com/expressjs/serve-favicon/issues" - }, - "homepage": "https://github.com/expressjs/serve-favicon", - "_id": "serve-favicon@2.3.2", - "_shasum": "dd419e268de012ab72b319d337f2105013f9381f", - "_from": "serve-favicon@>=2.3.0 <2.4.0", - "_npmVersion": "1.4.28", - "_npmUser": { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - }, - "maintainers": [ - { - "name": "dougwilson", - "email": "doug@somethingdoug.com" - } - ], - "dist": { - "shasum": "dd419e268de012ab72b319d337f2105013f9381f", - "tarball": "https://registry.npmjs.org/serve-favicon/-/serve-favicon-2.3.2.tgz" - }, - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/serve-favicon-2.3.2.tgz_1479350882429_0.391693202778697" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/serve-favicon/-/serve-favicon-2.3.2.tgz" + "version": "2.3.2" } diff --git a/node_modules/shelljs/package.json b/node_modules/shelljs/package.json index 6f79592..39b9e3e 100644 --- a/node_modules/shelljs/package.json +++ b/node_modules/shelljs/package.json @@ -1,27 +1,33 @@ { - "_from": "shelljs@0.3.x", + "_args": [ + [ + "shelljs@0.3.0", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "shelljs@0.3.0", "_id": "shelljs@0.3.0", "_inBundle": false, "_integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", "_location": "/shelljs", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "shelljs@0.3.x", + "raw": "shelljs@0.3.0", "name": "shelljs", "escapedName": "shelljs", - "rawSpec": "0.3.x", + "rawSpec": "0.3.0", "saveSpec": null, - "fetchSpec": "0.3.x" + "fetchSpec": "0.3.0" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "_shasum": "3596e6307a781544f591f37da618360f31db57b1", - "_spec": "shelljs@0.3.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "0.3.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Artur Adib", "email": "aadib@mozilla.com" @@ -32,9 +38,7 @@ "bugs": { "url": "https://github.com/arturadib/shelljs/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Portable Unix shell commands for Node.js", "devDependencies": { "jshint": "~2.1.11" diff --git a/node_modules/should/package.json b/node_modules/should/package.json index 24afbf2..29f502b 100644 --- a/node_modules/should/package.json +++ b/node_modules/should/package.json @@ -1,26 +1,31 @@ { - "_from": "should@~2.1.0", + "_args": [ + [ + "should@2.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "should@2.1.1", "_id": "should@2.1.1", "_inBundle": false, "_integrity": "sha1-xkixOotGRGXC+DjqDJPxLkrgbGs=", "_location": "/should", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "should@~2.1.0", + "raw": "should@2.1.1", "name": "should", "escapedName": "should", - "rawSpec": "~2.1.0", + "rawSpec": "2.1.1", "saveSpec": null, - "fetchSpec": "~2.1.0" + "fetchSpec": "2.1.1" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/should/-/should-2.1.1.tgz", - "_shasum": "c648b13a8b464465c2f838ea0c93f12e4ae06c6b", - "_spec": "should@~2.1.0", + "_spec": "2.1.1", "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "TJ Holowaychuk", @@ -29,14 +34,12 @@ "bugs": { "url": "https://github.com/visionmedia/should.js/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Aseem Kishore", "email": "aseem.kishore@gmail.com" } ], - "deprecated": false, "description": "test framework agnostic BDD-style assertions", "devDependencies": { "mocha": "*" diff --git a/node_modules/sigmund/package.json b/node_modules/sigmund/package.json index 13912b5..8c05621 100644 --- a/node_modules/sigmund/package.json +++ b/node_modules/sigmund/package.json @@ -1,27 +1,32 @@ { - "_from": "sigmund@~1.0.0", + "_args": [ + [ + "sigmund@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "sigmund@1.0.1", "_id": "sigmund@1.0.1", "_inBundle": false, "_integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", "_location": "/sigmund", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "sigmund@~1.0.0", + "raw": "sigmund@1.0.1", "name": "sigmund", "escapedName": "sigmund", - "rawSpec": "~1.0.0", + "rawSpec": "1.0.1", "saveSpec": null, - "fetchSpec": "~1.0.0" + "fetchSpec": "1.0.1" }, "_requiredBy": [ "/minimatch" ], "_resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "_shasum": "3ff21f198cad2175f9f3b781853fd94d0d19b590", - "_spec": "sigmund@~1.0.0", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/minimatch", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/isaacs/sigmund/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Quick and dirty signatures for Objects.", "devDependencies": { "tap": "~0.3.0" diff --git a/node_modules/sliced/package.json b/node_modules/sliced/package.json index 552bbe0..bc0065c 100644 --- a/node_modules/sliced/package.json +++ b/node_modules/sliced/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "sliced@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "sliced@1.0.1", "_id": "sliced@1.0.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/mongoose" ], "_resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", - "_shasum": "0b3a662b5d04c3177b1926bea82b03f837a2ef41", - "_spec": "sliced@1.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/mongoose", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Aaron Heckmann", "email": "aaron.heckmann+github@gmail.com" @@ -29,9 +34,7 @@ "bugs": { "url": "https://github.com/aheckmann/sliced/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "A faster Node.js alternative to Array.prototype.slice.call(arguments)", "devDependencies": { "benchmark": "~1.0.0", diff --git a/node_modules/streamsearch/package.json b/node_modules/streamsearch/package.json index 9d427b8..5c16207 100644 --- a/node_modules/streamsearch/package.json +++ b/node_modules/streamsearch/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "streamsearch@0.1.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "streamsearch@0.1.2", "_id": "streamsearch@0.1.2", "_inBundle": false, @@ -19,9 +25,8 @@ "/dicer" ], "_resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "_shasum": "808b9d0e56fc273d809ba57338e929919a1a9f1a", - "_spec": "streamsearch@0.1.2", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/dicer", + "_spec": "0.1.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Brian White", "email": "mscdex@mscdex.net" @@ -29,8 +34,6 @@ "bugs": { "url": "https://github.com/mscdex/streamsearch/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Streaming Boyer-Moore-Horspool searching for node.js", "engines": { "node": ">=0.8.0" diff --git a/node_modules/strip-json-comments/package.json b/node_modules/strip-json-comments/package.json index 03e7a10..8892cba 100644 --- a/node_modules/strip-json-comments/package.json +++ b/node_modules/strip-json-comments/package.json @@ -1,27 +1,33 @@ { - "_from": "strip-json-comments@1.0.x", + "_args": [ + [ + "strip-json-comments@1.0.4", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "strip-json-comments@1.0.4", "_id": "strip-json-comments@1.0.4", "_inBundle": false, "_integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", "_location": "/strip-json-comments", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "strip-json-comments@1.0.x", + "raw": "strip-json-comments@1.0.4", "name": "strip-json-comments", "escapedName": "strip-json-comments", - "rawSpec": "1.0.x", + "rawSpec": "1.0.4", "saveSpec": null, - "fetchSpec": "1.0.x" + "fetchSpec": "1.0.4" }, "_requiredBy": [ "/jshint" ], "_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "_shasum": "1e15fbcac97d3ee99bf2d73b4c656b082bbafb91", - "_spec": "strip-json-comments@1.0.x", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/jshint", + "_spec": "1.0.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -33,8 +39,6 @@ "bugs": { "url": "https://github.com/sindresorhus/strip-json-comments/issues" }, - "bundleDependencies": false, - "deprecated": false, "description": "Strip comments from JSON. Lets you use comments in your JSON files!", "devDependencies": { "mocha": "*" diff --git a/node_modules/type-detect/package.json b/node_modules/type-detect/package.json index e0f4e6f..644e638 100644 --- a/node_modules/type-detect/package.json +++ b/node_modules/type-detect/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "type-detect@0.1.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "type-detect@0.1.1", "_id": "type-detect@0.1.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/deep-eql" ], "_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", - "_shasum": "0ba5ec2a885640e470ea4e8505971900dac58822", - "_spec": "type-detect@0.1.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/deep-eql", + "_spec": "0.1.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jake Luer", "email": "jake@alogicalparadox.com", @@ -30,9 +35,7 @@ "bugs": { "url": "https://github.com/chaijs/type-detect/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Improved typeof detection for node.js and the browser.", "devDependencies": { "component": "*", diff --git a/node_modules/type-is/HISTORY.md b/node_modules/type-is/HISTORY.md new file mode 100644 index 0000000..183290c --- /dev/null +++ b/node_modules/type-is/HISTORY.md @@ -0,0 +1,236 @@ +1.6.16 / 2018-02-16 +=================== + + * deps: mime-types@~2.1.18 + - Add `application/raml+yaml` with extension `.raml` + - Add `application/wasm` with extension `.wasm` + - Add `text/shex` with extension `.shex` + - Add extensions for JPEG-2000 images + - Add extensions from IANA for `message/*` types + - Add extension `.mjs` to `application/javascript` + - Add extension `.wadl` to `application/vnd.sun.wadl+xml` + - Add extension `.gz` to `application/gzip` + - Add glTF types and extensions + - Add new mime types + - Update extensions `.md` and `.markdown` to be `text/markdown` + - Update font MIME types + - Update `text/hjson` to registered `application/hjson` + +1.6.15 / 2017-03-31 +=================== + + * deps: mime-types@~2.1.15 + - Add new mime types + +1.6.14 / 2016-11-18 +=================== + + * deps: mime-types@~2.1.13 + - Add new mime types + +1.6.13 / 2016-05-18 +=================== + + * deps: mime-types@~2.1.11 + - Add new mime types + +1.6.12 / 2016-02-28 +=================== + + * deps: mime-types@~2.1.10 + - Add new mime types + - Fix extension of `application/dash+xml` + - Update primary extension for `audio/mp4` + +1.6.11 / 2016-01-29 +=================== + + * deps: mime-types@~2.1.9 + - Add new mime types + +1.6.10 / 2015-12-01 +=================== + + * deps: mime-types@~2.1.8 + - Add new mime types + +1.6.9 / 2015-09-27 +================== + + * deps: mime-types@~2.1.7 + - Add new mime types + +1.6.8 / 2015-09-04 +================== + + * deps: mime-types@~2.1.6 + - Add new mime types + +1.6.7 / 2015-08-20 +================== + + * Fix type error when given invalid type to match against + * deps: mime-types@~2.1.5 + - Add new mime types + +1.6.6 / 2015-07-31 +================== + + * deps: mime-types@~2.1.4 + - Add new mime types + +1.6.5 / 2015-07-16 +================== + + * deps: mime-types@~2.1.3 + - Add new mime types + +1.6.4 / 2015-07-01 +================== + + * deps: mime-types@~2.1.2 + - Add new mime types + * perf: enable strict mode + * perf: remove argument reassignment + +1.6.3 / 2015-06-08 +================== + + * deps: mime-types@~2.1.1 + - Add new mime types + * perf: reduce try block size + * perf: remove bitwise operations + +1.6.2 / 2015-05-10 +================== + + * deps: mime-types@~2.0.11 + - Add new mime types + +1.6.1 / 2015-03-13 +================== + + * deps: mime-types@~2.0.10 + - Add new mime types + +1.6.0 / 2015-02-12 +================== + + * fix false-positives in `hasBody` `Transfer-Encoding` check + * support wildcard for both type and subtype (`*/*`) + +1.5.7 / 2015-02-09 +================== + + * fix argument reassignment + * deps: mime-types@~2.0.9 + - Add new mime types + +1.5.6 / 2015-01-29 +================== + + * deps: mime-types@~2.0.8 + - Add new mime types + +1.5.5 / 2014-12-30 +================== + + * deps: mime-types@~2.0.7 + - Add new mime types + - Fix missing extensions + - Fix various invalid MIME type entries + - Remove example template MIME types + - deps: mime-db@~1.5.0 + +1.5.4 / 2014-12-10 +================== + + * deps: mime-types@~2.0.4 + - Add new mime types + - deps: mime-db@~1.3.0 + +1.5.3 / 2014-11-09 +================== + + * deps: mime-types@~2.0.3 + - Add new mime types + - deps: mime-db@~1.2.0 + +1.5.2 / 2014-09-28 +================== + + * deps: mime-types@~2.0.2 + - Add new mime types + - deps: mime-db@~1.1.0 + +1.5.1 / 2014-09-07 +================== + + * Support Node.js 0.6 + * deps: media-typer@0.3.0 + * deps: mime-types@~2.0.1 + - Support Node.js 0.6 + +1.5.0 / 2014-09-05 +================== + + * fix `hasbody` to be true for `content-length: 0` + +1.4.0 / 2014-09-02 +================== + + * update mime-types + +1.3.2 / 2014-06-24 +================== + + * use `~` range on mime-types + +1.3.1 / 2014-06-19 +================== + + * fix global variable leak + +1.3.0 / 2014-06-19 +================== + + * improve type parsing + + - invalid media type never matches + - media type not case-sensitive + - extra LWS does not affect results + +1.2.2 / 2014-06-19 +================== + + * fix behavior on unknown type argument + +1.2.1 / 2014-06-03 +================== + + * switch dependency from `mime` to `mime-types@1.0.0` + +1.2.0 / 2014-05-11 +================== + + * support suffix matching: + + - `+json` matches `application/vnd+json` + - `*/vnd+json` matches `application/vnd+json` + - `application/*+json` matches `application/vnd+json` + +1.1.0 / 2014-04-12 +================== + + * add non-array values support + * expose internal utilities: + + - `.is()` + - `.hasBody()` + - `.normalize()` + - `.match()` + +1.0.1 / 2014-03-30 +================== + + * add `multipart` as a shorthand diff --git a/node_modules/type-is/LICENSE b/node_modules/type-is/LICENSE new file mode 100644 index 0000000..386b7b6 --- /dev/null +++ b/node_modules/type-is/LICENSE @@ -0,0 +1,23 @@ +(The MIT License) + +Copyright (c) 2014 Jonathan Ong +Copyright (c) 2014-2015 Douglas Christopher Wilson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/type-is/README.md b/node_modules/type-is/README.md new file mode 100644 index 0000000..70c47da --- /dev/null +++ b/node_modules/type-is/README.md @@ -0,0 +1,146 @@ +# type-is + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-version-image]][node-version-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Infer the content-type of a request. + +### Install + +This is a [Node.js](https://nodejs.org/en/) module available through the +[npm registry](https://www.npmjs.com/). Installation is done using the +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): + +```sh +$ npm install type-is +``` + +## API + +```js +var http = require('http') +var typeis = require('type-is') + +http.createServer(function (req, res) { + var istext = typeis(req, ['text/*']) + res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text') +}) +``` + +### type = typeis(request, types) + +`request` is the node HTTP request. `types` is an array of types. + + + +```js +// req.headers.content-type = 'application/json' + +typeis(req, ['json']) // 'json' +typeis(req, ['html', 'json']) // 'json' +typeis(req, ['application/*']) // 'application/json' +typeis(req, ['application/json']) // 'application/json' + +typeis(req, ['html']) // false +``` + +### typeis.hasBody(request) + +Returns a Boolean if the given `request` has a body, regardless of the +`Content-Type` header. + +Having a body has no relation to how large the body is (it may be 0 bytes). +This is similar to how file existence works. If a body does exist, then this +indicates that there is data to read from the Node.js request stream. + + + +```js +if (typeis.hasBody(req)) { + // read the body, since there is one + + req.on('data', function (chunk) { + // ... + }) +} +``` + +### type = typeis.is(mediaType, types) + +`mediaType` is the [media type](https://tools.ietf.org/html/rfc6838) string. `types` is an array of types. + + + +```js +var mediaType = 'application/json' + +typeis.is(mediaType, ['json']) // 'json' +typeis.is(mediaType, ['html', 'json']) // 'json' +typeis.is(mediaType, ['application/*']) // 'application/json' +typeis.is(mediaType, ['application/json']) // 'application/json' + +typeis.is(mediaType, ['html']) // false +``` + +### Each type can be: + +- An extension name such as `json`. This name will be returned if matched. +- A mime type such as `application/json`. +- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. The full mime type will be returned if matched. +- A suffix such as `+json`. This can be combined with a wildcard such as `*/vnd+json` or `application/*+json`. The full mime type will be returned if matched. + +`false` will be returned if no type matches or the content type is invalid. + +`null` will be returned if the request does not have a body. + +## Examples + +### Example body parser + +```js +var express = require('express') +var typeis = require('type-is') + +var app = express() + +app.use(function bodyParser (req, res, next) { + if (!typeis.hasBody(req)) { + return next() + } + + switch (typeis(req, ['urlencoded', 'json', 'multipart'])) { + case 'urlencoded': + // parse urlencoded body + throw new Error('implement urlencoded body parsing') + case 'json': + // parse json body + throw new Error('implement json body parsing') + case 'multipart': + // parse multipart body + throw new Error('implement multipart body parsing') + default: + // 415 error code + res.statusCode = 415 + res.end() + break + } +}) +``` + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/type-is.svg +[npm-url]: https://npmjs.org/package/type-is +[node-version-image]: https://img.shields.io/node/v/type-is.svg +[node-version-url]: https://nodejs.org/en/download/ +[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg +[travis-url]: https://travis-ci.org/jshttp/type-is +[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg +[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master +[downloads-image]: https://img.shields.io/npm/dm/type-is.svg +[downloads-url]: https://npmjs.org/package/type-is diff --git a/node_modules/type-is/index.js b/node_modules/type-is/index.js new file mode 100644 index 0000000..4da7301 --- /dev/null +++ b/node_modules/type-is/index.js @@ -0,0 +1,262 @@ +/*! + * type-is + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module dependencies. + * @private + */ + +var typer = require('media-typer') +var mime = require('mime-types') + +/** + * Module exports. + * @public + */ + +module.exports = typeofrequest +module.exports.is = typeis +module.exports.hasBody = hasbody +module.exports.normalize = normalize +module.exports.match = mimeMatch + +/** + * Compare a `value` content-type with `types`. + * Each `type` can be an extension like `html`, + * a special shortcut like `multipart` or `urlencoded`, + * or a mime type. + * + * If no types match, `false` is returned. + * Otherwise, the first `type` that matches is returned. + * + * @param {String} value + * @param {Array} types + * @public + */ + +function typeis (value, types_) { + var i + var types = types_ + + // remove parameters and normalize + var val = tryNormalizeType(value) + + // no type or invalid + if (!val) { + return false + } + + // support flattened arguments + if (types && !Array.isArray(types)) { + types = new Array(arguments.length - 1) + for (i = 0; i < types.length; i++) { + types[i] = arguments[i + 1] + } + } + + // no types, return the content type + if (!types || !types.length) { + return val + } + + var type + for (i = 0; i < types.length; i++) { + if (mimeMatch(normalize(type = types[i]), val)) { + return type[0] === '+' || type.indexOf('*') !== -1 + ? val + : type + } + } + + // no matches + return false +} + +/** + * Check if a request has a request body. + * A request with a body __must__ either have `transfer-encoding` + * or `content-length` headers set. + * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3 + * + * @param {Object} request + * @return {Boolean} + * @public + */ + +function hasbody (req) { + return req.headers['transfer-encoding'] !== undefined || + !isNaN(req.headers['content-length']) +} + +/** + * Check if the incoming request contains the "Content-Type" + * header field, and it contains any of the give mime `type`s. + * If there is no request body, `null` is returned. + * If there is no content type, `false` is returned. + * Otherwise, it returns the first `type` that matches. + * + * Examples: + * + * // With Content-Type: text/html; charset=utf-8 + * this.is('html'); // => 'html' + * this.is('text/html'); // => 'text/html' + * this.is('text/*', 'application/json'); // => 'text/html' + * + * // When Content-Type is application/json + * this.is('json', 'urlencoded'); // => 'json' + * this.is('application/json'); // => 'application/json' + * this.is('html', 'application/*'); // => 'application/json' + * + * this.is('html'); // => false + * + * @param {String|Array} types... + * @return {String|false|null} + * @public + */ + +function typeofrequest (req, types_) { + var types = types_ + + // no body + if (!hasbody(req)) { + return null + } + + // support flattened arguments + if (arguments.length > 2) { + types = new Array(arguments.length - 1) + for (var i = 0; i < types.length; i++) { + types[i] = arguments[i + 1] + } + } + + // request content type + var value = req.headers['content-type'] + + return typeis(value, types) +} + +/** + * Normalize a mime type. + * If it's a shorthand, expand it to a valid mime type. + * + * In general, you probably want: + * + * var type = is(req, ['urlencoded', 'json', 'multipart']); + * + * Then use the appropriate body parsers. + * These three are the most common request body types + * and are thus ensured to work. + * + * @param {String} type + * @private + */ + +function normalize (type) { + if (typeof type !== 'string') { + // invalid type + return false + } + + switch (type) { + case 'urlencoded': + return 'application/x-www-form-urlencoded' + case 'multipart': + return 'multipart/*' + } + + if (type[0] === '+') { + // "+json" -> "*/*+json" expando + return '*/*' + type + } + + return type.indexOf('/') === -1 + ? mime.lookup(type) + : type +} + +/** + * Check if `expected` mime type + * matches `actual` mime type with + * wildcard and +suffix support. + * + * @param {String} expected + * @param {String} actual + * @return {Boolean} + * @private + */ + +function mimeMatch (expected, actual) { + // invalid type + if (expected === false) { + return false + } + + // split types + var actualParts = actual.split('/') + var expectedParts = expected.split('/') + + // invalid format + if (actualParts.length !== 2 || expectedParts.length !== 2) { + return false + } + + // validate type + if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) { + return false + } + + // validate suffix wildcard + if (expectedParts[1].substr(0, 2) === '*+') { + return expectedParts[1].length <= actualParts[1].length + 1 && + expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length) + } + + // validate subtype + if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) { + return false + } + + return true +} + +/** + * Normalize a type and remove parameters. + * + * @param {string} value + * @return {string} + * @private + */ + +function normalizeType (value) { + // parse the type + var type = typer.parse(value) + + // remove the parameters + type.parameters = undefined + + // reformat it + return typer.format(type) +} + +/** + * Try to normalize a type and remove parameters. + * + * @param {string} value + * @return {string} + * @private + */ + +function tryNormalizeType (value) { + try { + return normalizeType(value) + } catch (err) { + return null + } +} diff --git a/node_modules/type-is/package.json b/node_modules/type-is/package.json new file mode 100644 index 0000000..f373c86 --- /dev/null +++ b/node_modules/type-is/package.json @@ -0,0 +1,84 @@ +{ + "_from": "type-is@^1.6.4", + "_id": "type-is@1.6.16", + "_inBundle": false, + "_integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "_location": "/type-is", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "type-is@^1.6.4", + "name": "type-is", + "escapedName": "type-is", + "rawSpec": "^1.6.4", + "saveSpec": null, + "fetchSpec": "^1.6.4" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "_shasum": "f89ce341541c672b25ee7ae3c73dee3b2be50194", + "_spec": "type-is@^1.6.4", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "bugs": { + "url": "https://github.com/jshttp/type-is/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Douglas Christopher Wilson", + "email": "doug@somethingdoug.com" + }, + { + "name": "Jonathan Ong", + "email": "me@jongleberry.com", + "url": "http://jongleberry.com" + } + ], + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + }, + "deprecated": false, + "description": "Infer the content-type of a request.", + "devDependencies": { + "eslint": "3.19.0", + "eslint-config-standard": "10.2.1", + "eslint-plugin-import": "2.8.0", + "eslint-plugin-markdown": "1.0.0-beta.6", + "eslint-plugin-node": "5.2.1", + "eslint-plugin-promise": "3.6.0", + "eslint-plugin-standard": "3.0.1", + "istanbul": "0.4.5", + "mocha": "1.21.5" + }, + "engines": { + "node": ">= 0.6" + }, + "files": [ + "LICENSE", + "HISTORY.md", + "index.js" + ], + "homepage": "https://github.com/jshttp/type-is#readme", + "keywords": [ + "content", + "type", + "checking" + ], + "license": "MIT", + "name": "type-is", + "repository": { + "type": "git", + "url": "git+https://github.com/jshttp/type-is.git" + }, + "scripts": { + "lint": "eslint --plugin markdown --ext js,md .", + "test": "mocha --reporter spec --check-leaks --bail test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "version": "1.6.16" +} diff --git a/node_modules/typedarray/.travis.yml b/node_modules/typedarray/.travis.yml new file mode 100644 index 0000000..cc4dba2 --- /dev/null +++ b/node_modules/typedarray/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/node_modules/typedarray/LICENSE b/node_modules/typedarray/LICENSE new file mode 100644 index 0000000..11adfae --- /dev/null +++ b/node_modules/typedarray/LICENSE @@ -0,0 +1,35 @@ +/* + Copyright (c) 2010, Linden Research, Inc. + Copyright (c) 2012, Joshua Bell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + $/LicenseInfo$ + */ + +// Original can be found at: +// https://bitbucket.org/lindenlab/llsd +// Modifications by Joshua Bell inexorabletash@gmail.com +// https://github.com/inexorabletash/polyfill + +// ES3/ES5 implementation of the Krhonos Typed Array Specification +// Ref: http://www.khronos.org/registry/typedarray/specs/latest/ +// Date: 2011-02-01 +// +// Variations: +// * Allows typed_array.get/set() as alias for subscripts (typed_array[]) diff --git a/node_modules/typedarray/example/tarray.js b/node_modules/typedarray/example/tarray.js new file mode 100644 index 0000000..8423d7c --- /dev/null +++ b/node_modules/typedarray/example/tarray.js @@ -0,0 +1,4 @@ +var Uint8Array = require('../').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); diff --git a/node_modules/typedarray/index.js b/node_modules/typedarray/index.js new file mode 100644 index 0000000..5e54084 --- /dev/null +++ b/node_modules/typedarray/index.js @@ -0,0 +1,630 @@ +var undefined = (void 0); // Paranoia + +// Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to +// create, and consume so much memory, that the browser appears frozen. +var MAX_ARRAY_LENGTH = 1e5; + +// Approximations of internal ECMAScript conversion functions +var ECMAScript = (function() { + // Stash a copy in case other scripts modify these + var opts = Object.prototype.toString, + ophop = Object.prototype.hasOwnProperty; + + return { + // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues: + Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); }, + HasProperty: function(o, p) { return p in o; }, + HasOwnProperty: function(o, p) { return ophop.call(o, p); }, + IsCallable: function(o) { return typeof o === 'function'; }, + ToInt32: function(v) { return v >> 0; }, + ToUint32: function(v) { return v >>> 0; } + }; +}()); + +// Snapshot intrinsics +var LN2 = Math.LN2, + abs = Math.abs, + floor = Math.floor, + log = Math.log, + min = Math.min, + pow = Math.pow, + round = Math.round; + +// ES5: lock down object properties +function configureProperties(obj) { + if (getOwnPropNames && defineProp) { + var props = getOwnPropNames(obj), i; + for (i = 0; i < props.length; i += 1) { + defineProp(obj, props[i], { + value: obj[props[i]], + writable: false, + enumerable: false, + configurable: false + }); + } + } +} + +// emulate ES5 getter/setter API using legacy APIs +// http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx +// (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but +// note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless) +var defineProp +if (Object.defineProperty && (function() { + try { + Object.defineProperty({}, 'x', {}); + return true; + } catch (e) { + return false; + } + })()) { + defineProp = Object.defineProperty; +} else { + defineProp = function(o, p, desc) { + if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object"); + if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); } + if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); } + if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; } + return o; + }; +} + +var getOwnPropNames = Object.getOwnPropertyNames || function (o) { + if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object"); + var props = [], p; + for (p in o) { + if (ECMAScript.HasOwnProperty(o, p)) { + props.push(p); + } + } + return props; +}; + +// ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value) +// for index in 0 ... obj.length +function makeArrayAccessors(obj) { + if (!defineProp) { return; } + + if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill"); + + function makeArrayAccessor(index) { + defineProp(obj, index, { + 'get': function() { return obj._getter(index); }, + 'set': function(v) { obj._setter(index, v); }, + enumerable: true, + configurable: false + }); + } + + var i; + for (i = 0; i < obj.length; i += 1) { + makeArrayAccessor(i); + } +} + +// Internal conversion functions: +// pack() - take a number (interpreted as Type), output a byte array +// unpack() - take a byte array, output a Type-like number + +function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; } +function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; } + +function packI8(n) { return [n & 0xff]; } +function unpackI8(bytes) { return as_signed(bytes[0], 8); } + +function packU8(n) { return [n & 0xff]; } +function unpackU8(bytes) { return as_unsigned(bytes[0], 8); } + +function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; } + +function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); } + +function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; } +function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); } + +function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; } +function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); } + +function packIEEE754(v, ebits, fbits) { + + var bias = (1 << (ebits - 1)) - 1, + s, e, f, ln, + i, bits, str, bytes; + + function roundToEven(n) { + var w = floor(n), f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } + + // Compute sign, exponent, fraction + if (v !== v) { + // NaN + // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping + e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + // Overflow + e = (1 << ebits) - 1; + f = 0; + } else { + // Normalized + e = e + bias; + f = f - pow(2, fbits); + } + } else { + // Denormalized + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + + // Pack sign, exponent, fraction + bits = []; + for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); } + for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); + + // Bits to bytes + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; +} + +function unpackIEEE754(bytes, ebits, fbits) { + + // Bytes to bits + var bits = [], i, j, b, str, + bias, s, e, f; + + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + + // Unpack sign, exponent, fraction + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + + // Produce number + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + // Normalized + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + // Denormalized + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } +} + +function unpackF64(b) { return unpackIEEE754(b, 11, 52); } +function packF64(v) { return packIEEE754(v, 11, 52); } +function unpackF32(b) { return unpackIEEE754(b, 8, 23); } +function packF32(v) { return packIEEE754(v, 8, 23); } + + +// +// 3 The ArrayBuffer Type +// + +(function() { + + /** @constructor */ + var ArrayBuffer = function ArrayBuffer(length) { + length = ECMAScript.ToInt32(length); + if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer'); + + this.byteLength = length; + this._bytes = []; + this._bytes.length = length; + + var i; + for (i = 0; i < this.byteLength; i += 1) { + this._bytes[i] = 0; + } + + configureProperties(this); + }; + + exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer; + + // + // 4 The ArrayBufferView Type + // + + // NOTE: this constructor is not exported + /** @constructor */ + var ArrayBufferView = function ArrayBufferView() { + //this.buffer = null; + //this.byteOffset = 0; + //this.byteLength = 0; + }; + + // + // 5 The Typed Array View Types + // + + function makeConstructor(bytesPerElement, pack, unpack) { + // Each TypedArray type requires a distinct constructor instance with + // identical logic, which this produces. + + var ctor; + ctor = function(buffer, byteOffset, length) { + var array, sequence, i, s; + + if (!arguments.length || typeof arguments[0] === 'number') { + // Constructor(unsigned long length) + this.length = ECMAScript.ToInt32(arguments[0]); + if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer'); + + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) { + // Constructor(TypedArray array) + array = arguments[0]; + + this.length = array.length; + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + this._setter(i, array._getter(i)); + } + } else if (typeof arguments[0] === 'object' && + !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(sequence array) + sequence = arguments[0]; + + this.length = ECMAScript.ToUint32(sequence.length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + this.buffer = new ArrayBuffer(this.byteLength); + this.byteOffset = 0; + + for (i = 0; i < this.length; i += 1) { + s = sequence[i]; + this._setter(i, Number(s)); + } + } else if (typeof arguments[0] === 'object' && + (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) { + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, optional unsigned long length) + this.buffer = buffer; + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (this.byteOffset % this.BYTES_PER_ELEMENT) { + // The given byteOffset must be a multiple of the element + // size of the specific type, otherwise an exception is raised. + throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size."); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + + if (this.byteLength % this.BYTES_PER_ELEMENT) { + throw new RangeError("length of buffer minus byteOffset not a multiple of the element size"); + } + this.length = this.byteLength / this.BYTES_PER_ELEMENT; + } else { + this.length = ECMAScript.ToUint32(length); + this.byteLength = this.length * this.BYTES_PER_ELEMENT; + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + + this.constructor = ctor; + + configureProperties(this); + makeArrayAccessors(this); + }; + + ctor.prototype = new ArrayBufferView(); + ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement; + ctor.prototype._pack = pack; + ctor.prototype._unpack = unpack; + ctor.BYTES_PER_ELEMENT = bytesPerElement; + + // getter type (unsigned long index); + ctor.prototype._getter = function(index) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = [], i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + bytes.push(this.buffer._bytes[o]); + } + return this._unpack(bytes); + }; + + // NONSTANDARD: convenience alias for getter: type get(unsigned long index); + ctor.prototype.get = ctor.prototype._getter; + + // setter void (unsigned long index, type value); + ctor.prototype._setter = function(index, value) { + if (arguments.length < 2) throw new SyntaxError("Not enough arguments"); + + index = ECMAScript.ToUint32(index); + if (index >= this.length) { + return undefined; + } + + var bytes = this._pack(value), i, o; + for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT; + i < this.BYTES_PER_ELEMENT; + i += 1, o += 1) { + this.buffer._bytes[o] = bytes[i]; + } + }; + + // void set(TypedArray array, optional unsigned long offset); + // void set(sequence array, optional unsigned long offset); + ctor.prototype.set = function(index, value) { + if (arguments.length < 1) throw new SyntaxError("Not enough arguments"); + var array, sequence, offset, len, + i, s, d, + byteOffset, byteLength, tmp; + + if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) { + // void set(TypedArray array, optional unsigned long offset); + array = arguments[0]; + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + array.length > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT; + byteLength = array.length * this.BYTES_PER_ELEMENT; + + if (array.buffer === this.buffer) { + tmp = []; + for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) { + tmp[i] = array.buffer._bytes[s]; + } + for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) { + this.buffer._bytes[d] = tmp[i]; + } + } else { + for (i = 0, s = array.byteOffset, d = byteOffset; + i < byteLength; i += 1, s += 1, d += 1) { + this.buffer._bytes[d] = array.buffer._bytes[s]; + } + } + } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') { + // void set(sequence array, optional unsigned long offset); + sequence = arguments[0]; + len = ECMAScript.ToUint32(sequence.length); + offset = ECMAScript.ToUint32(arguments[1]); + + if (offset + len > this.length) { + throw new RangeError("Offset plus length of array is out of range"); + } + + for (i = 0; i < len; i += 1) { + s = sequence[i]; + this._setter(offset + i, Number(s)); + } + } else { + throw new TypeError("Unexpected argument type(s)"); + } + }; + + // TypedArray subarray(long begin, optional long end); + ctor.prototype.subarray = function(start, end) { + function clamp(v, min, max) { return v < min ? min : v > max ? max : v; } + + start = ECMAScript.ToInt32(start); + end = ECMAScript.ToInt32(end); + + if (arguments.length < 1) { start = 0; } + if (arguments.length < 2) { end = this.length; } + + if (start < 0) { start = this.length + start; } + if (end < 0) { end = this.length + end; } + + start = clamp(start, 0, this.length); + end = clamp(end, 0, this.length); + + var len = end - start; + if (len < 0) { + len = 0; + } + + return new this.constructor( + this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len); + }; + + return ctor; + } + + var Int8Array = makeConstructor(1, packI8, unpackI8); + var Uint8Array = makeConstructor(1, packU8, unpackU8); + var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8); + var Int16Array = makeConstructor(2, packI16, unpackI16); + var Uint16Array = makeConstructor(2, packU16, unpackU16); + var Int32Array = makeConstructor(4, packI32, unpackI32); + var Uint32Array = makeConstructor(4, packU32, unpackU32); + var Float32Array = makeConstructor(4, packF32, unpackF32); + var Float64Array = makeConstructor(8, packF64, unpackF64); + + exports.Int8Array = exports.Int8Array || Int8Array; + exports.Uint8Array = exports.Uint8Array || Uint8Array; + exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray; + exports.Int16Array = exports.Int16Array || Int16Array; + exports.Uint16Array = exports.Uint16Array || Uint16Array; + exports.Int32Array = exports.Int32Array || Int32Array; + exports.Uint32Array = exports.Uint32Array || Uint32Array; + exports.Float32Array = exports.Float32Array || Float32Array; + exports.Float64Array = exports.Float64Array || Float64Array; +}()); + +// +// 6 The DataView View Type +// + +(function() { + function r(array, index) { + return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index]; + } + + var IS_BIG_ENDIAN = (function() { + var u16array = new(exports.Uint16Array)([0x1234]), + u8array = new(exports.Uint8Array)(u16array.buffer); + return r(u8array, 0) === 0x12; + }()); + + // Constructor(ArrayBuffer buffer, + // optional unsigned long byteOffset, + // optional unsigned long byteLength) + /** @constructor */ + var DataView = function DataView(buffer, byteOffset, byteLength) { + if (arguments.length === 0) { + buffer = new exports.ArrayBuffer(0); + } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) { + throw new TypeError("TypeError"); + } + + this.buffer = buffer || new exports.ArrayBuffer(0); + + this.byteOffset = ECMAScript.ToUint32(byteOffset); + if (this.byteOffset > this.buffer.byteLength) { + throw new RangeError("byteOffset out of range"); + } + + if (arguments.length < 3) { + this.byteLength = this.buffer.byteLength - this.byteOffset; + } else { + this.byteLength = ECMAScript.ToUint32(byteLength); + } + + if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) { + throw new RangeError("byteOffset and length reference an area beyond the end of the buffer"); + } + + configureProperties(this); + }; + + function makeGetter(arrayType) { + return function(byteOffset, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + byteOffset += this.byteOffset; + + var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT), + bytes = [], i; + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(uint8Array, i)); + } + + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0); + }; + } + + DataView.prototype.getUint8 = makeGetter(exports.Uint8Array); + DataView.prototype.getInt8 = makeGetter(exports.Int8Array); + DataView.prototype.getUint16 = makeGetter(exports.Uint16Array); + DataView.prototype.getInt16 = makeGetter(exports.Int16Array); + DataView.prototype.getUint32 = makeGetter(exports.Uint32Array); + DataView.prototype.getInt32 = makeGetter(exports.Int32Array); + DataView.prototype.getFloat32 = makeGetter(exports.Float32Array); + DataView.prototype.getFloat64 = makeGetter(exports.Float64Array); + + function makeSetter(arrayType) { + return function(byteOffset, value, littleEndian) { + + byteOffset = ECMAScript.ToUint32(byteOffset); + if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) { + throw new RangeError("Array index out of range"); + } + + // Get bytes + var typeArray = new arrayType([value]), + byteArray = new exports.Uint8Array(typeArray.buffer), + bytes = [], i, byteView; + + for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) { + bytes.push(r(byteArray, i)); + } + + // Flip if necessary + if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) { + bytes.reverse(); + } + + // Write them + byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT); + byteView.set(bytes); + }; + } + + DataView.prototype.setUint8 = makeSetter(exports.Uint8Array); + DataView.prototype.setInt8 = makeSetter(exports.Int8Array); + DataView.prototype.setUint16 = makeSetter(exports.Uint16Array); + DataView.prototype.setInt16 = makeSetter(exports.Int16Array); + DataView.prototype.setUint32 = makeSetter(exports.Uint32Array); + DataView.prototype.setInt32 = makeSetter(exports.Int32Array); + DataView.prototype.setFloat32 = makeSetter(exports.Float32Array); + DataView.prototype.setFloat64 = makeSetter(exports.Float64Array); + + exports.DataView = exports.DataView || DataView; + +}()); diff --git a/node_modules/typedarray/package.json b/node_modules/typedarray/package.json new file mode 100644 index 0000000..e518629 --- /dev/null +++ b/node_modules/typedarray/package.json @@ -0,0 +1,83 @@ +{ + "_from": "typedarray@^0.0.6", + "_id": "typedarray@0.0.6", + "_inBundle": false, + "_integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "_location": "/typedarray", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "typedarray@^0.0.6", + "name": "typedarray", + "escapedName": "typedarray", + "rawSpec": "^0.0.6", + "saveSpec": null, + "fetchSpec": "^0.0.6" + }, + "_requiredBy": [ + "/concat-stream" + ], + "_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "_shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", + "_spec": "typedarray@^0.0.6", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/concat-stream", + "author": { + "name": "James Halliday", + "email": "mail@substack.net", + "url": "http://substack.net" + }, + "bugs": { + "url": "https://github.com/substack/typedarray/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "TypedArray polyfill for old browsers", + "devDependencies": { + "tape": "~2.3.2" + }, + "homepage": "https://github.com/substack/typedarray", + "keywords": [ + "ArrayBuffer", + "DataView", + "Float32Array", + "Float64Array", + "Int8Array", + "Int16Array", + "Int32Array", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "typed", + "array", + "polyfill" + ], + "license": "MIT", + "main": "index.js", + "name": "typedarray", + "repository": { + "type": "git", + "url": "git://github.com/substack/typedarray.git" + }, + "scripts": { + "test": "tape test/*.js test/server/*.js" + }, + "testling": { + "files": "test/*.js", + "browsers": [ + "ie/6..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ] + }, + "version": "0.0.6" +} diff --git a/node_modules/typedarray/readme.markdown b/node_modules/typedarray/readme.markdown new file mode 100644 index 0000000..d18f6f7 --- /dev/null +++ b/node_modules/typedarray/readme.markdown @@ -0,0 +1,61 @@ +# typedarray + +TypedArray polyfill ripped from [this +module](https://raw.github.com/inexorabletash/polyfill). + +[![build status](https://secure.travis-ci.org/substack/typedarray.png)](http://travis-ci.org/substack/typedarray) + +[![testling badge](https://ci.testling.com/substack/typedarray.png)](https://ci.testling.com/substack/typedarray) + +# example + +``` js +var Uint8Array = require('typedarray').Uint8Array; +var ua = new Uint8Array(5); +ua[1] = 256 + 55; +console.log(ua[1]); +``` + +output: + +``` +55 +``` + +# methods + +``` js +var TA = require('typedarray') +``` + +The `TA` object has the following constructors: + +* TA.ArrayBuffer +* TA.DataView +* TA.Float32Array +* TA.Float64Array +* TA.Int8Array +* TA.Int16Array +* TA.Int32Array +* TA.Uint8Array +* TA.Uint8ClampedArray +* TA.Uint16Array +* TA.Uint32Array + +# install + +With [npm](https://npmjs.org) do: + +``` +npm install typedarray +``` + +To use this module in the browser, compile with +[browserify](http://browserify.org) +or download a UMD build from browserify CDN: + +http://wzrd.in/standalone/typedarray@latest + +# license + +MIT diff --git a/node_modules/typedarray/test/server/undef_globals.js b/node_modules/typedarray/test/server/undef_globals.js new file mode 100644 index 0000000..425950f --- /dev/null +++ b/node_modules/typedarray/test/server/undef_globals.js @@ -0,0 +1,19 @@ +var test = require('tape'); +var vm = require('vm'); +var fs = require('fs'); +var src = fs.readFileSync(__dirname + '/../../index.js', 'utf8'); + +test('u8a without globals', function (t) { + var c = { + module: { exports: {} }, + }; + c.exports = c.module.exports; + vm.runInNewContext(src, c); + var TA = c.module.exports; + var ua = new(TA.Uint8Array)(5); + + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/node_modules/typedarray/test/tarray.js b/node_modules/typedarray/test/tarray.js new file mode 100644 index 0000000..df596a3 --- /dev/null +++ b/node_modules/typedarray/test/tarray.js @@ -0,0 +1,10 @@ +var TA = require('../'); +var test = require('tape'); + +test('tiny u8a test', function (t) { + var ua = new(TA.Uint8Array)(5); + t.equal(ua.length, 5); + ua[1] = 256 + 55; + t.equal(ua[1], 55); + t.end(); +}); diff --git a/node_modules/uid-safe/package.json b/node_modules/uid-safe/package.json index 15d07ed..a24d5c2 100644 --- a/node_modules/uid-safe/package.json +++ b/node_modules/uid-safe/package.json @@ -1,31 +1,35 @@ { - "_from": "uid-safe@~2.1.5", + "_args": [ + [ + "uid-safe@2.1.5", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_from": "uid-safe@2.1.5", "_id": "uid-safe@2.1.5", "_inBundle": false, "_integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", "_location": "/uid-safe", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "uid-safe@~2.1.5", + "raw": "uid-safe@2.1.5", "name": "uid-safe", "escapedName": "uid-safe", - "rawSpec": "~2.1.5", + "rawSpec": "2.1.5", "saveSpec": null, - "fetchSpec": "~2.1.5" + "fetchSpec": "2.1.5" }, "_requiredBy": [ "/express-session" ], "_resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", - "_shasum": "2b3d5c7240e8fc2e58f8aa269e5ee49c0857bd3a", - "_spec": "uid-safe@~2.1.5", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "2.1.5", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "bugs": { "url": "https://github.com/crypto-utils/uid-safe/issues" }, - "bundleDependencies": false, "contributors": [ { "name": "Douglas Christopher Wilson", @@ -40,7 +44,6 @@ "dependencies": { "random-bytes": "~1.0.0" }, - "deprecated": false, "description": "URL and cookie safe UIDs", "devDependencies": { "bluebird": "3.5.0", diff --git a/node_modules/util-deprecate/package.json b/node_modules/util-deprecate/package.json index c1853a7..acba95e 100644 --- a/node_modules/util-deprecate/package.json +++ b/node_modules/util-deprecate/package.json @@ -4,12 +4,6 @@ "_inBundle": false, "_integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "_location": "/util-deprecate", - "_nodeVersion": "4.1.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_npmVersion": "2.14.4", "_phantomChildren": {}, "_requested": { "type": "range", @@ -40,12 +34,6 @@ "bundleDependencies": false, "deprecated": false, "description": "The Node.js `util.deprecate()` function with browser support", - "directories": {}, - "dist": { - "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf", - "tarball": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - }, - "gitHead": "475fb6857cd23fafff20c1be846c1350abf8e6d4", "homepage": "https://github.com/TooTallNate/util-deprecate", "keywords": [ "util", @@ -56,12 +44,6 @@ ], "license": "MIT", "main": "node.js", - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], "name": "util-deprecate", "repository": { "type": "git", diff --git a/node_modules/utils-merge/package.json b/node_modules/utils-merge/package.json index a0e9428..508d534 100644 --- a/node_modules/utils-merge/package.json +++ b/node_modules/utils-merge/package.json @@ -1,4 +1,10 @@ { + "_args": [ + [ + "utils-merge@1.0.1", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], "_from": "utils-merge@1.0.1", "_id": "utils-merge@1.0.1", "_inBundle": false, @@ -19,9 +25,8 @@ "/express-session" ], "_resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "_shasum": "9f95710f50a267947b2ccc124741c1028427e713", - "_spec": "utils-merge@1.0.1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/express-session", + "_spec": "1.0.1", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Jared Hanson", "email": "jaredhanson@gmail.com", @@ -30,9 +35,7 @@ "bugs": { "url": "http://github.com/jaredhanson/utils-merge/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "merge() utility function", "devDependencies": { "chai": "1.x.x", diff --git a/node_modules/wrappy/package.json b/node_modules/wrappy/package.json index c9d6cbb..d9318fb 100644 --- a/node_modules/wrappy/package.json +++ b/node_modules/wrappy/package.json @@ -1,28 +1,34 @@ { - "_from": "wrappy@1", + "_args": [ + [ + "wrappy@1.0.2", + "/Users/Bryan1/Projects/WebStormProjects/site" + ] + ], + "_development": true, + "_from": "wrappy@1.0.2", "_id": "wrappy@1.0.2", "_inBundle": false, "_integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "_location": "/wrappy", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "wrappy@1", + "raw": "wrappy@1.0.2", "name": "wrappy", "escapedName": "wrappy", - "rawSpec": "1", + "rawSpec": "1.0.2", "saveSpec": null, - "fetchSpec": "1" + "fetchSpec": "1.0.2" }, "_requiredBy": [ "/inflight", "/once" ], "_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "_shasum": "b5243d8f3ec1aa35f1364605bc0d1036e30ab69f", - "_spec": "wrappy@1", - "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/inflight", + "_spec": "1.0.2", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -31,9 +37,7 @@ "bugs": { "url": "https://github.com/npm/wrappy/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Callback wrapping utility", "devDependencies": { "tap": "^2.3.1" diff --git a/node_modules/xtend/.jshintrc b/node_modules/xtend/.jshintrc new file mode 100644 index 0000000..77887b5 --- /dev/null +++ b/node_modules/xtend/.jshintrc @@ -0,0 +1,30 @@ +{ + "maxdepth": 4, + "maxstatements": 200, + "maxcomplexity": 12, + "maxlen": 80, + "maxparams": 5, + + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": false, + "noarg": true, + "noempty": true, + "nonew": true, + "undef": true, + "unused": "vars", + "trailing": true, + + "quotmark": true, + "expr": true, + "asi": true, + + "browser": false, + "esnext": true, + "devel": false, + "node": false, + "nonstandard": false, + + "predef": ["require", "module", "__dirname", "__filename"] +} diff --git a/node_modules/xtend/.npmignore b/node_modules/xtend/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/node_modules/xtend/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/xtend/LICENCE b/node_modules/xtend/LICENCE new file mode 100644 index 0000000..1a14b43 --- /dev/null +++ b/node_modules/xtend/LICENCE @@ -0,0 +1,19 @@ +Copyright (c) 2012-2014 Raynos. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/xtend/Makefile b/node_modules/xtend/Makefile new file mode 100644 index 0000000..d583fcf --- /dev/null +++ b/node_modules/xtend/Makefile @@ -0,0 +1,4 @@ +browser: + node ./support/compile + +.PHONY: browser \ No newline at end of file diff --git a/node_modules/xtend/README.md b/node_modules/xtend/README.md new file mode 100644 index 0000000..093cb29 --- /dev/null +++ b/node_modules/xtend/README.md @@ -0,0 +1,32 @@ +# xtend + +[![browser support][3]][4] + +[![locked](http://badges.github.io/stability-badges/dist/locked.svg)](http://github.com/badges/stability-badges) + +Extend like a boss + +xtend is a basic utility library which allows you to extend an object by appending all of the properties from each object in a list. When there are identical properties, the right-most property takes precedence. + +## Examples + +```js +var extend = require("xtend") + +// extend returns a new object. Does not mutate arguments +var combination = extend({ + a: "a", + b: 'c' +}, { + b: "b" +}) +// { a: "a", b: "b" } +``` + +## Stability status: Locked + +## MIT Licenced + + + [3]: http://ci.testling.com/Raynos/xtend.png + [4]: http://ci.testling.com/Raynos/xtend diff --git a/node_modules/xtend/immutable.js b/node_modules/xtend/immutable.js new file mode 100644 index 0000000..94889c9 --- /dev/null +++ b/node_modules/xtend/immutable.js @@ -0,0 +1,19 @@ +module.exports = extend + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function extend() { + var target = {} + + for (var i = 0; i < arguments.length; i++) { + var source = arguments[i] + + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + target[key] = source[key] + } + } + } + + return target +} diff --git a/node_modules/xtend/mutable.js b/node_modules/xtend/mutable.js new file mode 100644 index 0000000..72debed --- /dev/null +++ b/node_modules/xtend/mutable.js @@ -0,0 +1,17 @@ +module.exports = extend + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function extend(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] + + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + target[key] = source[key] + } + } + } + + return target +} diff --git a/node_modules/xtend/package.json b/node_modules/xtend/package.json new file mode 100644 index 0000000..02e1d79 --- /dev/null +++ b/node_modules/xtend/package.json @@ -0,0 +1,86 @@ +{ + "_from": "xtend@^4.0.0", + "_id": "xtend@4.0.1", + "_inBundle": false, + "_integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "_location": "/xtend", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "xtend@^4.0.0", + "name": "xtend", + "escapedName": "xtend", + "rawSpec": "^4.0.0", + "saveSpec": null, + "fetchSpec": "^4.0.0" + }, + "_requiredBy": [ + "/multer" + ], + "_resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "_shasum": "a5c6d532be656e23db820efb943a1f04998d63af", + "_spec": "xtend@^4.0.0", + "_where": "/Users/Bryan1/Projects/WebStormProjects/site/node_modules/multer", + "author": { + "name": "Raynos", + "email": "raynos2@gmail.com" + }, + "bugs": { + "url": "https://github.com/Raynos/xtend/issues", + "email": "raynos2@gmail.com" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Jake Verbaten" + }, + { + "name": "Matt Esch" + } + ], + "dependencies": {}, + "deprecated": false, + "description": "extend like a boss", + "devDependencies": { + "tape": "~1.1.0" + }, + "engines": { + "node": ">=0.4" + }, + "homepage": "https://github.com/Raynos/xtend", + "keywords": [ + "extend", + "merge", + "options", + "opts", + "object", + "array" + ], + "license": "MIT", + "main": "immutable", + "name": "xtend", + "repository": { + "type": "git", + "url": "git://github.com/Raynos/xtend.git" + }, + "scripts": { + "test": "node test" + }, + "testling": { + "files": "test.js", + "browsers": [ + "ie/7..latest", + "firefox/16..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest" + ] + }, + "version": "4.0.1" +} diff --git a/node_modules/xtend/test.js b/node_modules/xtend/test.js new file mode 100644 index 0000000..093a2b0 --- /dev/null +++ b/node_modules/xtend/test.js @@ -0,0 +1,83 @@ +var test = require("tape") +var extend = require("./") +var mutableExtend = require("./mutable") + +test("merge", function(assert) { + var a = { a: "foo" } + var b = { b: "bar" } + + assert.deepEqual(extend(a, b), { a: "foo", b: "bar" }) + assert.end() +}) + +test("replace", function(assert) { + var a = { a: "foo" } + var b = { a: "bar" } + + assert.deepEqual(extend(a, b), { a: "bar" }) + assert.end() +}) + +test("undefined", function(assert) { + var a = { a: undefined } + var b = { b: "foo" } + + assert.deepEqual(extend(a, b), { a: undefined, b: "foo" }) + assert.deepEqual(extend(b, a), { a: undefined, b: "foo" }) + assert.end() +}) + +test("handle 0", function(assert) { + var a = { a: "default" } + var b = { a: 0 } + + assert.deepEqual(extend(a, b), { a: 0 }) + assert.deepEqual(extend(b, a), { a: "default" }) + assert.end() +}) + +test("is immutable", function (assert) { + var record = {} + + extend(record, { foo: "bar" }) + assert.equal(record.foo, undefined) + assert.end() +}) + +test("null as argument", function (assert) { + var a = { foo: "bar" } + var b = null + var c = void 0 + + assert.deepEqual(extend(b, a, c), { foo: "bar" }) + assert.end() +}) + +test("mutable", function (assert) { + var a = { foo: "bar" } + + mutableExtend(a, { bar: "baz" }) + + assert.equal(a.bar, "baz") + assert.end() +}) + +test("null prototype", function(assert) { + var a = { a: "foo" } + var b = Object.create(null) + b.b = "bar"; + + assert.deepEqual(extend(a, b), { a: "foo", b: "bar" }) + assert.end() +}) + +test("null prototype mutable", function (assert) { + var a = { foo: "bar" } + var b = Object.create(null) + b.bar = "baz"; + + mutableExtend(a, b) + + assert.equal(a.bar, "baz") + assert.end() +}) diff --git a/package-lock.json b/package-lock.json index ea812d9..d72e8e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -197,6 +197,11 @@ "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz", "integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg==" }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, "buffer-shims": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", @@ -289,6 +294,17 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "connect-flash": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/connect-flash/-/connect-flash-0.1.1.tgz", @@ -464,6 +480,11 @@ "domelementtype": "1" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, "entities": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", @@ -1411,6 +1432,29 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "mime": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz", + "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==" + }, + "mime-db": { + "version": "1.36.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz", + "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==" + }, + "mime-types": { + "version": "2.1.20", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", + "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", + "requires": { + "mime-db": "~1.36.0" + } + }, "minimatch": { "version": "0.2.14", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", @@ -1420,6 +1464,11 @@ "sigmund": "~1.0.0" } }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, "mkdirp": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", @@ -1468,22 +1517,30 @@ } }, "mongodb": { - "version": "2.2.34", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.34.tgz", - "integrity": "sha1-o09Zu+thdUrsQy3nLD/iFSakTBo=", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.4.tgz", + "integrity": "sha512-BGUxo4a/p5KtZpOn6+z6iZXTHfDxKDvibHQap9uMJqQouwoszvTIO/QbVZkaSX3Spny0jtTEeHc0FwfpGbtEzA==", "requires": { - "es6-promise": "3.2.1", - "mongodb-core": "2.1.18", - "readable-stream": "2.2.7" + "mongodb-core": "3.1.3", + "safe-buffer": "^5.1.2" } }, "mongodb-core": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz", - "integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.3.tgz", + "integrity": "sha512-dISiV3zHGJTwZpg0xDhi9zCqFGMhA5kDPByHlcaEp09NSKfzHJ7XQbqVrL7qhki1U9PZHsmRfbFzco+6b1h2wA==", "requires": { - "bson": "~1.0.4", - "require_optional": "~1.0.0" + "bson": "^1.1.0", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + }, + "dependencies": { + "bson": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.0.tgz", + "integrity": "sha512-9Aeai9TacfNtWXOYarkFJRW2CWo+dRon+fuLZYJmvLV3+MiUp0bEI6IAZfXEIg7/Pl/7IWlLaDnhzTsD81etQA==" + } } }, "mongoose": { @@ -1504,6 +1561,27 @@ "muri": "1.3.0", "regexp-clone": "0.0.1", "sliced": "1.0.1" + }, + "dependencies": { + "mongodb": { + "version": "2.2.34", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.34.tgz", + "integrity": "sha1-o09Zu+thdUrsQy3nLD/iFSakTBo=", + "requires": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.18", + "readable-stream": "2.2.7" + } + }, + "mongodb-core": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz", + "integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=", + "requires": { + "bson": "~1.0.4", + "require_optional": "~1.0.0" + } + } } }, "morgan": { @@ -1606,11 +1684,59 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "multer": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.3.1.tgz", + "integrity": "sha512-JHdEoxkA/5NgZRo91RNn4UT+HdcJV9XUo01DTkKC7vo1erNIngtuaw9Y0WI8RdTlyi+wMIbunflhghzVLuGJyw==", + "requires": { + "append-field": "^0.1.0", + "busboy": "^0.2.11", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.1", + "object-assign": "^3.0.0", + "on-finished": "^2.3.0", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "dependencies": { + "append-field": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz", + "integrity": "sha1-bdxY+gg8e8VF08WZWygwzCNm1Eo=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + } + } + }, "muri": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/muri/-/muri-1.3.0.tgz", "integrity": "sha512-FiaFwKl864onHFFUV/a2szAl7X0fxVlSKNdhTf+BM8i8goEgYut8u5P9MqQqIYwvaMxjzVESsoEm/2kfkFH1rg==" }, + "nodemailer": { + "version": "4.6.8", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.6.8.tgz", + "integrity": "sha512-A3s7EM/426OBIZbLHXq2KkgvmKbn2Xga4m4G+ZUA4IaZvG8PcZXrFh+2E4VaS2o+emhuUVRnzKN2YmpkXQ9qwA==" + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, "on-headers": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", @@ -1720,15 +1846,21 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "saslprep": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.1.tgz", + "integrity": "sha512-ntN6SbE3hRqd45PKKadRPgA+xHPWg5lPSj2JWJdJvjTwXDDfkPVtXWvP8jJojvnm+rAsZ2b299C5NwZqq818EA==", + "optional": true + }, "scmp": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/scmp/-/scmp-1.0.2.tgz", "integrity": "sha1-vE5OJxMlKwQhDN/5zvOt4sj6c3A=" }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", + "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==" }, "serve-favicon": { "version": "2.3.2", @@ -1808,6 +1940,20 @@ "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=" }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, "uid-safe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", @@ -1831,6 +1977,11 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" } } } diff --git a/package.json b/package.json index f2596e9..c0e3e11 100644 --- a/package.json +++ b/package.json @@ -24,17 +24,18 @@ "express-session": "^1.10.1", "growl": "^1.10.5", "jade": "^1.9.1", + "mime": "latest", "mocha": "~1.14.0", + "mongodb": "latest", "mongoose": "^4.4.1", "morgan": "^1.5.1", + "multer": "latest", + "nodemailer": "^4.6.8", "passport": "^0.2.1", "passport-local": "^1.0.0", "passport-local-mongoose": "^1.0.0", "serve-favicon": "^2.2.0", - "should": "~2.1.0", - "mongodb": "latest", - "mime": "latest", - "multer": "latest" + "should": "~2.1.0" }, "devDependencies": { "jshint": "^2.9.5"